« Back to History
jobwork_action.php
|
20260721_154033.php
Initial Bulk Import
Copy Code
<?php // Jobwork Save Logic with Transaction if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action_save'])) { try { $pdo->beginTransaction(); // 1. Insert in Jobwork Send Table $ins = $pdo->prepare("INSERT INTO jobwork_send (company_id, party_id, entry_date, material, denier, color, weight, boxes, created_at) VALUES (?,?,?,?,?,?,?,?, NOW())"); $ins->execute([$company_id, $_POST['party_id'], $_POST['entry_date'], $_POST['material'], $_POST['denier'], $_POST['color'], $_POST['weight'], $_POST['boxes']]); // 2. Insert in Yarn IO (Out Entry) to maintain stock $io = $pdo->prepare("INSERT INTO yarn_io (company_id, type, flow, weight, boxes, ref_id) VALUES (?,?,'out',?,?, LAST_INSERT_ID())"); $io->execute([$company_id, $_POST['material'], $_POST['weight'], $_POST['boxes']]); $pdo->commit(); $message = "Success: Material sent to Jobworker."; } catch (Exception $e) { if ($pdo->inTransaction()) $pdo->rollBack(); die("Error: " . $e->getMessage()); } } ?>