« Back to History
beam_entry_to_company_stock.php
|
20260723_000646.php
Initial Domain Snapshot
Copy Code
<?php if (!isset($pdo, $beam_id) || !$beam_id) { file_put_contents(__DIR__.'/hook_debug.log',"NO BEAM ID\n",FILE_APPEND); return; } file_put_contents(__DIR__.'/hook_debug.log',"HOOK CALLED | beam_id=$beam_id\n",FILE_APPEND); $st = $pdo->prepare("SELECT * FROM beam_entry WHERE id=?"); $st->execute([$beam_id]); $beam = $st->fetch(PDO::FETCH_ASSOC); if (!$beam) { file_put_contents(__DIR__.'/hook_debug.log',"NO BEAM ROW\n",FILE_APPEND); return; } if (empty($beam['beam_no'])) { file_put_contents(__DIR__.'/hook_debug.log',"EMPTY BEAM NO\n",FILE_APPEND); return; } $chk = $pdo->prepare(" SELECT 1 FROM company_beam_stock WHERE company_id=? AND beam_no=? "); $chk->execute([$beam['company_id'], $beam['beam_no']]); if ($chk->fetchColumn()) { file_put_contents( __DIR__.'/hook_debug.log', "SKIPPED EXISTS | ".$beam['beam_no']."\n", FILE_APPEND ); return; } file_put_contents( __DIR__.'/hook_debug.log', "INSERT TRY | ".$beam['beam_no']."\n", FILE_APPEND ); $ins = $pdo->prepare(" INSERT INTO company_beam_stock ( company_id, warp_date, beam_no, quality_id, beam_quality, beam_slot, taka, meter, tar, warper_id, beam_load_date, load_type, created_at ) VALUES ( ?,?,?,?,?,?,?,?,?,?,?,'stock',NOW() ) "); $ins->execute([ $beam['company_id'], $beam['entry_date'], $beam['beam_no'], $beam['quality_id'] ?? null, $beam['quality_id'] ?? null, $beam['beam_type'] ?? 'primary', $beam['taka'] ?? 0, $beam['meter'] ?? 0, $beam['tar'] ?? null, $beam['employee_id'] ?? null, $beam['entry_date'] ]); file_put_contents( __DIR__.'/hook_debug.log', "INSERTED | ".$beam['beam_no']."\n", FILE_APPEND );