maintaince module

This commit is contained in:
2026-08-12 21:29:55 +03:00
parent 41c4838dab
commit 55d83c12b0
51 changed files with 8200 additions and 48 deletions
+13 -6
View File
@@ -16,17 +16,24 @@ try {
$toolType = trim($_POST['tool_type'] ?? '');
$manufacturer = trim($_POST['manufacturer'] ?? '');
$description = trim($_POST['description'] ?? '');
$isActive = isset($_POST['is_active']) ? (int)$_POST['is_active'] : 1;
$status = (string)($_POST['status'] ?? 'active');
if ($name === '') {
echo json_encode(['success' => false, 'message' => 'Name is required.']);
exit;
}
$sql = "INSERT INTO production_tools
(name, registration_number, serial_number, tool_type, manufacturer, description, is_active)
VALUES
(:name, :registration_number, :serial_number, :tool_type, :manufacturer, :description, :is_active)";
if (!in_array($status, ['active', 'out_of_service', 'decommissioned'], true)) {
$status = 'active';
}
// production_tools is now inv_equipment; tools created here land in the
// "Attrezzature" category of the registry.
$sql = "INSERT INTO inv_equipment
(name, registration_number, serial_number, tool_type, manufacturer, description, status, category_id)
VALUES
(:name, :registration_number, :serial_number, :tool_type, :manufacturer, :description, :status,
(SELECT id FROM inv_categories WHERE code = 'equipment'))";
$stmt = $pdo->prepare($sql);
$stmt->execute([
@@ -36,7 +43,7 @@ try {
'tool_type' => $toolType ?: null,
'manufacturer' => $manufacturer ?: null,
'description' => $description ?: null,
'is_active' => $isActive
'status' => $status
]);
echo json_encode(['success' => true]);