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

View File

@ -13,12 +13,15 @@ class ApiValidateController extends BaseController
*/
public function unvalidated()
{
$date1 = $this->request->getGet('date1');
$date2 = $this->request->getGet('date2');
$userid = session()->get('userid');
$date1 = $this->request->getGet("date1");
$date2 = $this->request->getGet("date2");
$userid = session()->get("userid");
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();
@ -33,18 +36,25 @@ class ApiValidateController extends BaseController
-- Exclude requests already validated by current user
AND (r.VAL1USER != '$userid' OR r.VAL1USER 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";
$result = $db->query($sql)->getResultArray();
// Format dates
foreach ($result as &$row) {
$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['COLLECTIONDATE'] = date('Y-m-d H:i', strtotime($row['COLLECTIONDATE']));
$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["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,
]);
}
}