diff --git a/app/Controllers/PrintResult.php b/app/Controllers/PrintResult.php index 9dfff25..02193cc 100644 --- a/app/Controllers/PrintResult.php +++ b/app/Controllers/PrintResult.php @@ -3,7 +3,7 @@ namespace App\Controllers; class PrintResult extends BaseController { - public function otherTests($access){ + public function otherTests($access, $collection){ $fullPage=""; $headPage = " @@ -73,8 +73,22 @@ class PrintResult extends BaseController { $resultTest =""; - $item = end($access); + $items = end($access); + // Untuk Collection + if ($collection != null) { + $cm_output = []; + $sp_output = []; + + foreach ($collection as $item) { + $cm_output[] = "{$item['SHORTTEXT']} " . date('Y-m-d H:i:s', strtotime($item['CM_collection_datetime'])); + $sp_output[] = "{$item['SHORTTEXT']} " . date('Y-m-d H:i:s', strtotime($item['SP_reception_datetime'])); + } + + $collectionText = implode(' | ', $cm_output) . "\n"; + $receptionText = implode(' | ', $sp_output) . "\n"; + } + $resultNoteandSpecimen = "
@@ -84,7 +98,7 @@ class PrintResult extends BaseController { - ".$item['RESVALUE']." + ".$items['RESVALUE']." @@ -93,10 +107,10 @@ class PrintResult extends BaseController { - + - +
Collection datetime : - 
Collection datetime : $collectionText 
Reception datetime  : - 
Reception datetime  : $receptionText 
"; @@ -200,6 +214,18 @@ class PrintResult extends BaseController { public function printResultTest($access) { $db = \Config\Database::connect(); + + // Untuk Collection + $sql = "select tu.SAMPLETYPE, ds.SHORTTEXT, tu.COLLECTIONDATE as CM_collection_datetime, ct.COLLECTIONDATE as SP_reception_datetime + from SP_TUBES tu + left join DICT_SAMPLES_TYPES ds on ds.SAMPCODE= tu.SAMPLETYPE + left join cmod.dbo.CM_TUBES ct on ct.SAMPLETYPE=tu.SAMPLETYPE and ct.ACCESSNUMBER=tu.SP_ACCESSNUMBER + where tu.SP_ACCESSNUMBER='$access' + "; + $query = $db->query($sql); + $results = $query->getResultArray(); + $collection = $results; + $sql = " select dc.CHAPID, dc.FULLTEXT as chap_eng,dc.FULLTEXT as chap_ind, RESULT=case when cr.RESTYPE in('NM','TX') then cr.RESVALUE when cr.RESTYPE='CE' then tx.FULLTEXT end, @@ -224,7 +250,6 @@ class PrintResult extends BaseController { $query = $db->query($sql); $results = $query->getResultArray(); - $data_urine = array_filter($results, function($item) { $chapterid = $item["CHAPID"]; $tesscode = $item['TESTCODE']; @@ -250,13 +275,13 @@ class PrintResult extends BaseController { $fullPage = ""; if ($data_urine != null && count($data_urine) > 1) { - $fullPage .= $this->otherTests($data_urine); + $fullPage .= $this->otherTests($data_urine, $collection); } if ($data_feces != null && count($data_feces) > 1) { - $fullPage .= $this->otherTests($data_feces); + $fullPage .= $this->otherTests($data_feces, $collection); } if ($data_others != null && count($data_others) > 1) { - $fullPage .= $this->otherTests($data_others); + $fullPage .= $this->otherTests($data_others, $collection); } return view('result_report', ['data' => $fullPage]);