|
@@ -33,6 +33,28 @@ if ($actor !== 'ICG' && (int) $job['vendor_id'] !== $vendor_id) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// --- Button-driven state transitions ---
|
|
// --- Button-driven state transitions ---
|
|
|
|
|
+// Undo is dynamic: it reverses one step based on current status. Vendors only.
|
|
|
|
|
+// Once ICG marks Received, undo is no longer available (vendor would need to
|
|
|
|
|
+// message ICG to get them to back it out).
|
|
|
|
|
+if ($action === 'undo') {
|
|
|
|
|
+ if ($actor === 'ICG') {
|
|
|
|
|
+ http_response_code(403);
|
|
|
|
|
+ echo 'Undo is a vendor action';
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($job['status'] === 'Finished') {
|
|
|
|
|
+ apply_job_change($job, 'status', '', $actor);
|
|
|
|
|
+ } elseif ($job['status'] === 'Shipped') {
|
|
|
|
|
+ apply_job_change($job, 'status', 'Finished', $actor);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ http_response_code(400);
|
|
|
|
|
+ echo 'Nothing to undo from current status';
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ echo 'Success';
|
|
|
|
|
+ return;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
if ($action !== '') {
|
|
if ($action !== '') {
|
|
|
$allowed = [
|
|
$allowed = [
|
|
|
'acknowledge' => ['ack', '', ['vendor']],
|
|
'acknowledge' => ['ack', '', ['vendor']],
|