From 4c99e3e0173c82fffd2f54f54c2d4245621947e9 Mon Sep 17 00:00:00 2001 From: mikael-zakaria Date: Fri, 7 Mar 2025 01:02:05 +0700 Subject: [PATCH] Update Printer Barcode Ruang Sampling Bali, Nama File Barcode dan Views Sidebar All Role --- app/Config/Routes.php | 9 +- app/Controllers/PrintLabel.php | 119 ++++++++++++++------------ app/Controllers/PrintLabelSby.php | 4 +- app/Views/fo/layout/sidebar.php | 2 +- app/Views/sampling/layout/sidebar.php | 2 +- 5 files changed, 75 insertions(+), 61 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 5bd14b5..e7c45cd 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -128,13 +128,14 @@ $routes->group('fo', ['filter' => 'role:fo'], static function ($routes) { $routes->get('dashboard/viewAccess/(:any)', 'FoController::viewAccess/$1'); }); -// Printers +// Printers Bali +$routes->get('printLabel/collection/(:any)', 'PrintLabel::labelCollection/$1'); $routes->get('printLabel/single/(:any)/(:any)', 'PrintLabel::printSingle/$1/$2'); -$routes->get('printLabel/collection/(:any)', 'PrintLabel::labelPostekCollection/$1'); $routes->get('printLabel/all/(:any)', 'PrintLabel::printAll/$1'); -$routes->get('printResult/(:any)', 'PrintResult::printResultTest/$1'); -$routes->get('printLabelSby/single/(:any)/(:any)', 'PrintLabelSby::printSingle/$1/$2'); +// Printers Surabaya $routes->get('printLabelSby/collection/(:any)', 'PrintLabelSby::labelZebraCollection/$1'); +$routes->get('printLabelSby/single/(:any)/(:any)', 'PrintLabelSby::printSingle/$1/$2'); $routes->get('printLabelSby/all/(:any)', 'PrintLabelSby::printAll/$1'); +$routes->get('printResult/(:any)', 'PrintResult::printResultTest/$1'); \ No newline at end of file diff --git a/app/Controllers/PrintLabel.php b/app/Controllers/PrintLabel.php index da966c3..9e6689c 100644 --- a/app/Controllers/PrintLabel.php +++ b/app/Controllers/PrintLabel.php @@ -3,6 +3,20 @@ namespace App\Controllers; class PrintLabel extends BaseController { + public function printerLab() { + exec('net use L: \\\\10.148.5.20\\Labelshare /user:Administrator 2>&1', $output, $return_var); + $pathNetworkFolder = 'L:/Sampling_Labels/'; + $letterPath = 'L:'; + return array($pathNetworkFolder, $letterPath); + } + + public function printerSampling() { + exec('net use S: \\\\10.148.3.169\\Labelshare /user:Administrator 2>&1', $output, $return_var); + $pathNetworkFolder = 'S:/Sampling_Labels/'; + $letterPath = 'S:'; + return array($pathNetworkFolder, $letterPath); + } + public function splitName($fullName) { $words = explode(' ', $fullName); // Pisahkan nama berdasarkan spasi $line1 = ''; @@ -32,13 +46,12 @@ class PrintLabel extends BaseController { } // Untuk Ruang Laboratorium - public function labelPostekCollection($access) { + public function labelCollection($access) { $time = microtime(true); $logTime = date('d-m-Y_H_i_s', $time) . sprintf('_%03d', ($time - floor($time)) * 1000); - $filename = "sample_".$logTime; + $filename = "collection(".$access.")_".$logTime; - $role = session()->get('userrole'); $networkPath = ""; $db = \Config\Database::connect(); @@ -86,7 +99,11 @@ class PrintLabel extends BaseController { $jarak = '53'; } - $label = "N + $label=""; + $role = session()->get('userrole'); + // Ruang Analis Printer POSTEK C168/200s + if ($role == 'admin' || $role == 'user') { + $label = "N OD q400 Q200,10+0 @@ -104,11 +121,29 @@ A195,164,0,2,1,1,N,\"$collectiondate\" P1 "; - // Ruang Analis Printer POSTEK C168/200s - if ($role === 'admin' || $role === 'user') { $printer = $this->printerLab(); - } else if ($role === 'sampling') { + + } else if ($role == 'sampling') { + $label = "N +OD +q400 +Q185,10+0 +I8,A,001 +D10 +A4,3,0,2,1,1,N,\"$title.$name1\" +A$jarak,20,0,2,1,1,N,\"$name2\" +A4,42,0,1,1,1,N,\"DoB: $birthdate\" +A337,42,0,1,1,1,N,\"$sex {$age}Y\" +B15,57,0,1,4,8,70,N,\"$access\" +A120,132,0,1,1,1,N,\"REQ# $access\" +A4,164,0,2,1,1,N,\"RM:$uhid\" +A4,147,0,2,1,1,N,\"VN:$bv\" +A195,164,0,2,1,1,N,\"$collectiondate\" + +P1 +"; $printer = $this->printerSampling(); + } else { // Eksekusi Kode Berikut Apabila Role Bukan Analis atau Sampling return $this->response->setJSON([ @@ -176,69 +211,47 @@ A195,165,0,2,1,1,N,\"$collection_date\" P1 "; - -// $sampleLabel ="N -// OD -// q400 -// Q200,10+0 -// I8,A,001 -// D10 -// A4,3,0,2,1,1,N,\"$title.$name\" -// A4,25,0,2,1,1,N,\"$sex {$age}Y\" -// A4,55,0,2,1,1,N,\"$sample\" -// A4,75,0,2,1,1,N,\"Chapter\" -// B149,35,0,1,3,8,70,N,\"$barcode\" -// A195,110,0,2,1,1,N,\"SAM# $barcode\" -// A4,140,0,2,1,1,N,\"RM : $uhid\" -// A4,160,0,2,1,1,N,\"VN : $bv\" -// A195,156,0,2,1,1,N,\"$collection_date\" - -// P1 -// "; return $sampleLabel; } // Untuk Ruang Sampling - public function labelZebra($sample, $title, $name, $sex, $age, $barcode, $uhid, $bv, $collection_date) { + public function labelZebra($sample, $title, $name, $sex, $age, $barcode, $uhid, $bv, $collection_date, $birthdate) { + $fixName = $this->splitName($name); + $name1 = $fixName['line1']; + $name2 = $fixName['line2']; + + if ($sex == 'M') { + $jarak = '42'; + } else { + $jarak = '53'; + } + $sampleLabel ="N OD q400 Q185,10+0 I8,A,001 D10 -A4,3,0,2,1,1,N,\"$title.$name\" -A4,25,0,2,1,1,N,\"$sex {$age}Y\" -A4,55,0,2,1,1,N,\"$sample\" -A4,75,0,2,1,1,N,\"Chapter\" -B149,35,0,1,3,8,70,N,\"$barcode\" -A195,110,0,2,1,1,N,\"SAM# $barcode\" -A4,140,0,2,1,1,N,\"RM : $uhid\" -A4,160,0,2,1,1,N,\"VN : $bv\" -A195,156,0,2,1,1,N,\"$collection_date\" +A4,3,0,2,1,1,N,\"$title.$name1\" +A$jarak,20,0,2,1,1,N,\"$name2\" +A325,25,0,2,1,1,N,\"$sex {$age}Y\" +A4,47,0,2,1,1,N,\"$sample\" +A204,47,0,2,1,1,N,\"DoB: $birthdate\" +B37,68,0,1,4,8,70,N,\"$barcode\" +A115,143,0,2,1,1,N,\"SAM# $barcode\" +A4,165,0,2,1,1,N,\"RM:$uhid\" +A195,165,0,2,1,1,N,\"$collection_date\" P1 "; - } - - public function printerLab() { - exec('net use L: \\\\10.148.5.20\\Labelshare /user:Administrator 2>&1', $output, $return_var); - $pathNetworkFolder = 'L:/Sampling_Labels/'; - $letterPath = 'L:'; - return array($pathNetworkFolder, $letterPath); - } - - public function printerSampling() { - exec('net use S: \\\\10.148.3.169\\Labelshare /user:Administrator 2>&1', $output, $return_var); - $pathNetworkFolder = 'S:/Sampling_Labels/'; - $letterPath = 'S:'; - return array($pathNetworkFolder, $letterPath); + return $sampleLabel; } public function printSingle($access, $sampletype) { $time = microtime(true); $logTime = date('d-m-Y_H_i_s', $time) . sprintf('_%03d', ($time - floor($time)) * 1000); - $filename = "sample_".$logTime; + $filename = "sample(".$sampletype.")_".$logTime; $role = session()->get('userrole'); $networkPath = ""; @@ -296,7 +309,7 @@ P1 $label = $this->labelPostek($sample, $title, $name, $sex, $age, $barcode, $uhid, $bv, $collectiondate, $birthdate); } else if ($role === 'sampling') { $printer = $this->printerSampling(); - $label = $this->labelZebra($sample, $title, $name, $sex, $age, $barcode, $uhid, $bv, $collectiondate); + $label = $this->labelZebra($sample, $title, $name, $sex, $age, $barcode, $uhid, $bv, $collectiondate, $birthdate); } else { // Eksekusi Kode Berikut Apabila Role Bukan Analis atau Sampling return $this->response->setJSON([ @@ -341,6 +354,6 @@ P1 $sample = $data['SAMPLETYPE']; $this->printSingle($access, $sample); } - $this->labelPostekCollection($access); + $this->labelCollection($access); } } \ No newline at end of file diff --git a/app/Controllers/PrintLabelSby.php b/app/Controllers/PrintLabelSby.php index 4850db0..1cdce59 100644 --- a/app/Controllers/PrintLabelSby.php +++ b/app/Controllers/PrintLabelSby.php @@ -35,7 +35,7 @@ class PrintLabelSby extends BaseController { $time = microtime(true); $logTime = date('d-m-Y_H_i_s', $time) . sprintf('_%03d', ($time - floor($time)) * 1000); - $filename = "sample_".$logTime; + $filename = "collection(".$access.")_".$logTime; $role = session()->get('userrole'); $networkPath = ""; @@ -171,7 +171,7 @@ class PrintLabelSby extends BaseController { $time = microtime(true); $logTime = date('d-m-Y_H_i_s', $time) . sprintf('_%03d', ($time - floor($time)) * 1000); - $filename = "sample_".$logTime; + $filename = "sample(".$sampletype.")_".$logTime; $role = session()->get('userrole'); $networkPath = ""; diff --git a/app/Views/fo/layout/sidebar.php b/app/Views/fo/layout/sidebar.php index 6880040..22f6a13 100644 --- a/app/Views/fo/layout/sidebar.php +++ b/app/Views/fo/layout/sidebar.php @@ -3,7 +3,7 @@
diff --git a/app/Views/sampling/layout/sidebar.php b/app/Views/sampling/layout/sidebar.php index 074565b..0a88dfc 100644 --- a/app/Views/sampling/layout/sidebar.php +++ b/app/Views/sampling/layout/sidebar.php @@ -3,7 +3,7 @@