« Back to History
beam_install_helper.php
|
20260723_000646.php
Initial Domain Snapshot
Copy Code
<?php // modules/helpers/beam_install_helper.php if (!function_exists('auto_beam_install_insert')) { function auto_beam_install_insert($pdo, $company_id, $data) { $minDate = '2025-12-01'; if (empty($data['installation_date'])) { return ['ok'=>false,'msg'=>'installation_date missing']; } $d = date('Y-m-d', strtotime($data['installation_date'])); if ($d < $minDate) return ['ok'=>false,'msg'=>"installation_date < {$minDate} ignored"]; $sql = "INSERT INTO beam_installation_record (company_id, source_table, source_id, beam_no, beam_type, machine_no, pasaria_id, pissing_entry_id, installation_date, note, details, created_by, created_at) VALUES (:cid,:src_table,:src_id,:beam_no,:beam_type,:machine_no,:pasaria_id,:pissing_id,:installation_date,:note,:details,:created_by,NOW())"; $stmt = $pdo->prepare($sql); try { $stmt->execute([ ':cid' => $company_id, ':src_table' => $data['source_table'] ?? null, ':src_id' => $data['source_id'] ?? null, ':beam_no' => $data['beam_no'] ?? null, ':beam_type' => $data['beam_type'] ?? null, ':machine_no' => $data['machine_no'] ?? null, ':pasaria_id' => $data['pasaria_id'] ?? null, ':pissing_id' => $data['pissing_entry_id'] ?? null, ':installation_date' => $d, ':note' => $data['note'] ?? null, ':details' => isset($data['details']) ? json_encode($data['details'], JSON_UNESCAPED_UNICODE) : null, ':created_by' => $data['created_by'] ?? null ]); return ['ok'=>true,'msg'=>'Inserted','id'=>$pdo->lastInsertId()]; } catch (Exception $e) { error_log("auto_beam_install_insert error: ".$e->getMessage()); return ['ok'=>false,'msg'=>'DB error: '.$e->getMessage()]; } } }