[OOP] contact,inventory,ics,dashboard

This commit is contained in:
Thanakorn S
2026-04-28 15:44:57 +07:00
parent 3d3b497c08
commit 2061624641
49 changed files with 1946 additions and 2146 deletions
+4 -25
View File
@@ -6,44 +6,23 @@
$type = $data['type'] ?? '';
$whMgmt = new WarehouseManager($pdo2, $company_id);
// Resolve warehouse — supports warehouse, warehouse_from, warehouse_to
$warehouse = (int)($data['warehouse'] ?? 0);
if (isset($data['warehouse_from']) && $type === 'from') $warehouse = (int)$data['warehouse_from'];
if (isset($data['warehouse_to']) && $type === 'to') $warehouse = (int)$data['warehouse_to'];
if ($type === 'to') {
// Stock_in destination — empty racks only
if (!empty($data['id'])) {
$output = $whMgmt->getZonesAll($warehouse);
} elseif ($type === 'to') {
$output = $whMgmt->getZonesIn($warehouse);
} elseif ($type === 'from') {
// Stock_out source — filter by sku + lot + serial
$output = $whMgmt->getZonesOut(
$warehouse,
$data['product_sku'] ?? '',
$data['lot_number'] ?? null,
$data['serial_number'] ?? null
);
} else {
// Admin / read-only — all zones in the warehouse
$sth = $pdo2->prepare(
"SELECT DISTINCT zone FROM md_rack
WHERE company_id = :company_id AND warehouse = :warehouse
ORDER BY CAST(zone AS UNSIGNED), zone"
);
$sth->execute([':company_id' => $company_id, ':warehouse' => $warehouse]);
$output = $sth->fetchAll(PDO::FETCH_ASSOC);
}
// Edit mode — return all zones regardless of occupancy
if (!empty($data['id'])) {
$sth = $pdo2->prepare(
"SELECT DISTINCT zone FROM md_rack
WHERE company_id = :company_id AND warehouse = :warehouse
ORDER BY CAST(zone AS UNSIGNED), zone"
);
$sth->execute([':company_id' => $company_id, ':warehouse' => $warehouse]);
$output = $sth->fetchAll(PDO::FETCH_ASSOC);
$output = $whMgmt->getZonesAll($warehouse);
}
$answer['output'] = $output;