feat: Update lab printer path and validation date filtering logic

This commit is contained in:
mahdahar 2026-02-11 15:18:35 +07:00
parent 1534544bb9
commit dcb09804f5
2 changed files with 35 additions and 25 deletions

View File

@ -7,29 +7,29 @@ use CodeIgniter\Config\BaseConfig;
class Printers extends BaseConfig class Printers extends BaseConfig
{ {
public array $printers = [ public array $printers = [
'lab' => [ "lab" => [
'name' => 'Lab Printer', "name" => "Lab Printer",
'command' => 'copy /B file.txt \\\\print-server\\lab-printer', "command" => "copy /B file.txt \\\\glenlis\\zebralab",
], ],
'phlebo' => [ "phlebo" => [
'name' => 'Phlebo Printer', "name" => "Phlebo Printer",
'command' => 'copy /B file.txt \\\\print-server\\phlebo-printer', "command" => "copy /B file.txt \\\\print-server\\phlebo-printer",
], ],
'reception' => [ "reception" => [
'name' => 'Reception Printer', "name" => "Reception Printer",
'command' => 'copy /B file.txt \\\\print-server\\reception-printer', "command" => 'copy /B file.txt \\\\print-server\\reception-printer',
], ],
]; ];
public array $roleDefaults = [ public array $roleDefaults = [
0 => 'lab', 0 => "lab",
1 => 'lab', 1 => "lab",
2 => 'lab', 2 => "lab",
3 => 'phlebo', 3 => "phlebo",
4 => 'reception', 4 => "reception",
]; ];
public string $defaultPrinter = 'lab'; public string $defaultPrinter = "lab";
public function getPrinter(string $printerKey): ?array public function getPrinter(string $printerKey): ?array
{ {
@ -38,7 +38,7 @@ class Printers extends BaseConfig
public function getCommand(string $printerKey): ?string public function getCommand(string $printerKey): ?string
{ {
return $this->printers[$printerKey]['command'] ?? null; return $this->printers[$printerKey]["command"] ?? null;
} }
public function getDefaultForRole(int $roleId): string public function getDefaultForRole(int $roleId): string

View File

@ -13,12 +13,15 @@ class ApiValidateController extends BaseController
*/ */
public function unvalidated() public function unvalidated()
{ {
$date1 = $this->request->getGet('date1'); $date1 = $this->request->getGet("date1");
$date2 = $this->request->getGet('date2'); $date2 = $this->request->getGet("date2");
$userid = session()->get('userid'); $userid = session()->get("userid");
if (empty($date1) || empty($date2)) { if (empty($date1) || empty($date2)) {
return $this->response->setJSON(['status' => 'error', 'message' => 'Date range required']); return $this->response->setJSON([
"status" => "error",
"message" => "Date range required",
]);
} }
$db = \Config\Database::connect(); $db = \Config\Database::connect();
@ -33,18 +36,25 @@ class ApiValidateController extends BaseController
-- Exclude requests already validated by current user -- Exclude requests already validated by current user
AND (r.VAL1USER != '$userid' OR r.VAL1USER IS NULL) AND (r.VAL1USER != '$userid' OR r.VAL1USER IS NULL)
AND (r.VAL2USER != '$userid' OR r.VAL2USER IS NULL) AND (r.VAL2USER != '$userid' OR r.VAL2USER IS NULL)
AND d.REQDATE BETWEEN '$date1 00:00:00' AND '$date2 23:59:59' and d.COLLECTIONDATE between '$date1 00:00' and '$date2 23:59'
and d.ODR_DDATE between '$date1 00:00' and '$date2 23:59'
ORDER BY d.REQDATE DESC"; ORDER BY d.REQDATE DESC";
$result = $db->query($sql)->getResultArray(); $result = $db->query($sql)->getResultArray();
// Format dates // Format dates
foreach ($result as &$row) { foreach ($result as &$row) {
$row['REQDATE'] = date('Y-m-d H:i', strtotime($row['REQDATE'])); $row["REQDATE"] = date("Y-m-d H:i", strtotime($row["REQDATE"]));
$row['ODR_DDATE'] = date('Y-m-d H:i', strtotime($row['ODR_DDATE'])); $row["ODR_DDATE"] = date("Y-m-d H:i", strtotime($row["ODR_DDATE"]));
$row['COLLECTIONDATE'] = date('Y-m-d H:i', strtotime($row['COLLECTIONDATE'])); $row["COLLECTIONDATE"] = date(
"Y-m-d H:i",
strtotime($row["COLLECTIONDATE"]),
);
} }
return $this->response->setJSON(['status' => 'success', 'data' => $result]); return $this->response->setJSON([
"status" => "success",
"data" => $result,
]);
} }
} }