JezK
Edit File: fix_schema_s1.php
<?php // fix_schema_s1.php — Add stock_requests table to Software 1 require_once __DIR__ . '/config/config.php'; require_once __DIR__ . '/config/db.php'; $pdo = db(); $pdo->exec(" CREATE TABLE IF NOT EXISTS `stock_requests` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `lab_id` INT UNSIGNED NOT NULL, `inventory_id` INT UNSIGNED NOT NULL, `requested_by` INT UNSIGNED NOT NULL, `quantity_requested` DECIMAL(12,3) NOT NULL, `reason` TEXT, `status` ENUM('pending','approved','rejected') NOT NULL DEFAULT 'pending', `reviewed_by` INT UNSIGNED NULL, `review_note` TEXT, `reviewed_at` TIMESTAMP NULL, `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY `idx_sr_lab` (`lab_id`), KEY `idx_sr_status` (`status`), CONSTRAINT `fk_sr_lab` FOREIGN KEY (`lab_id`) REFERENCES `labs`(`id`), CONSTRAINT `fk_sr_inv` FOREIGN KEY (`inventory_id`) REFERENCES `inventory`(`id`), CONSTRAINT `fk_sr_user` FOREIGN KEY (`requested_by`) REFERENCES `users`(`id`), CONSTRAINT `fk_sr_rev` FOREIGN KEY (`reviewed_by`) REFERENCES `users`(`id`) ON DELETE SET NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; "); echo "stock_requests table created.\n"; // Ensure signatures upload dir exists $sigs_dir = APP_ROOT . '/uploads/signatures/'; if (!is_dir($sigs_dir)) { mkdir($sigs_dir, 0775, true); echo "Created uploads/signatures/\n"; } echo "Done.\n";