İlk temizlik tamamlandı bir önceki projeden
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
$id = $request['key'];
|
||||
// Get the line list record before deletion
|
||||
$lineList = $oldData;
|
||||
|
||||
$lineNumber = $lineList->line_no ?? null;
|
||||
$area = $lineList->unit ?? null;
|
||||
|
||||
if ($lineNumber) {
|
||||
// Delete from paint_follow_ups where primer coating has not started
|
||||
$deletedFollowUps = db('paint_follow_ups')
|
||||
->where(
|
||||
[
|
||||
'line' => $lineNumber,
|
||||
'area' => $area,
|
||||
]
|
||||
)
|
||||
->whereNull('primer_coating_start_date')
|
||||
->whereNull('primer_coating_finish_date')
|
||||
->whereNull('start_intermediate_date2')
|
||||
->whereNull('finish_intermediate_date2')
|
||||
->whereNull('final_coat_start_date3')
|
||||
->whereNull('final_coat_finish_date3')
|
||||
->delete();
|
||||
|
||||
// Delete from construction_paint_logs (spool-based, where painting has not started)
|
||||
// Get all spools for this line from weld_logs
|
||||
$spools = db("weld_logs")
|
||||
->where("line_number", $lineNumber)
|
||||
->whereNotNull('spool_number')
|
||||
->where('spool_number', '!=', '')
|
||||
->distinct()
|
||||
->pluck('spool_number');
|
||||
|
||||
$deletedConstructionLogs = 0;
|
||||
|
||||
if ($spools->isNotEmpty()) {
|
||||
// Spool-based deletion
|
||||
$deletedConstructionLogs = db('construction_paint_logs')
|
||||
->where('line', $lineNumber)
|
||||
->whereIn('spool', $spools)
|
||||
->whereNull('blasting_date')
|
||||
->whereNull('blasting_finish_date')
|
||||
->whereNull('painting_date_1')
|
||||
->whereNull('painting_finish_date_1')
|
||||
->whereNull('painting_date_2')
|
||||
->whereNull('painting_finish_date_2')
|
||||
->whereNull('painting_date_3')
|
||||
->whereNull('painting_finish_date_3')
|
||||
->delete();
|
||||
|
||||
Log::debug("Construction Paint Logs deleted (spool-based)", [
|
||||
'line' => $lineNumber,
|
||||
'spool_count' => $spools->count(),
|
||||
'deleted_count' => $deletedConstructionLogs
|
||||
]);
|
||||
} else {
|
||||
// Fallback to unit-based deletion if no spools found
|
||||
$deletedConstructionLogs = db('construction_paint_logs')
|
||||
->where([
|
||||
'line' => $lineNumber,
|
||||
'unit' => $area,
|
||||
])
|
||||
->whereNull('blasting_date')
|
||||
->whereNull('blasting_finish_date')
|
||||
->whereNull('painting_date_1')
|
||||
->whereNull('painting_finish_date_1')
|
||||
->whereNull('painting_date_2')
|
||||
->whereNull('painting_finish_date_2')
|
||||
->whereNull('painting_date_3')
|
||||
->whereNull('painting_finish_date_3')
|
||||
->delete();
|
||||
|
||||
Log::debug("Construction Paint Logs deleted (unit-based fallback)", [
|
||||
'line' => $lineNumber,
|
||||
'unit' => $area,
|
||||
'deleted_count' => $deletedConstructionLogs
|
||||
]);
|
||||
}
|
||||
|
||||
spoolStatusChanger($lineNumber);
|
||||
|
||||
Log::info("Deleted related paint records for line: $lineNumber (Line List ID: $id)", [
|
||||
'deleted_follow_ups' => $deletedFollowUps,
|
||||
'deleted_construction_logs' => $deletedConstructionLogs,
|
||||
'spool_based' => $spools->isNotEmpty()
|
||||
]);
|
||||
} else {
|
||||
Log::error("Line number not found for line list ID: $id");
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
$uniqueFields = [
|
||||
'line_number' => $oldData->line,
|
||||
'support_code' => $oldData->component_code_id,
|
||||
];
|
||||
|
||||
echo db('supports')->where($uniqueFields)->delete();
|
||||
dump("delete trigger");
|
||||
dump($oldData);
|
||||
?>
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
$id = $request['key'];
|
||||
|
||||
// Get the paint matrix record before deletion
|
||||
$paintMatrix = db('paint_matrices')->where('id', $id)->first();
|
||||
|
||||
if ($paintMatrix) {
|
||||
// Delete from paint_follow_ups
|
||||
db('paint_follow_ups')
|
||||
->where([
|
||||
'line' => $paintMatrix->line,
|
||||
'area' => $paintMatrix->area,
|
||||
])
|
||||
->whereNull('primer_coating_start_date') // Only delete if primer coating start date is null
|
||||
->delete();
|
||||
|
||||
// Delete from construction_paint_logs
|
||||
db('construction_paint_logs')
|
||||
->where([
|
||||
'line' => $paintMatrix->line,
|
||||
'unit' => $paintMatrix->area,
|
||||
])
|
||||
->whereNull('painting_date_1') // Only delete if primer coating start date is null
|
||||
->delete();
|
||||
|
||||
dump("Deleted related records for paint matrix ID: $id");
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
$uniqueFields = [
|
||||
'line' => $oldData->line_number,
|
||||
'component_code_id' => $oldData->support_code,
|
||||
];
|
||||
|
||||
echo db('m_t_o_s')->where($uniqueFields)->delete();
|
||||
dump("delete trigger");
|
||||
dump($oldData);
|
||||
?>
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
// Get the test_pack_base_status that is being deleted
|
||||
$testPackBaseStatus = db("test_pack_base_statuses")->where("id", $request['key'])->first();
|
||||
|
||||
if ($testPackBaseStatus) {
|
||||
try {
|
||||
$testPackageNo = $testPackBaseStatus->test_package_no;
|
||||
|
||||
// Check if there are any remaining test_pack_base_statuses records with the same test_package_no
|
||||
$remainingCount = db("test_pack_base_statuses")
|
||||
->where("test_package_no", $testPackageNo)
|
||||
->where("id", "!=", $request['key']) // Exclude the current record being deleted
|
||||
->count();
|
||||
|
||||
// Only delete test_packages if no other test_pack_base_statuses records exist for this test_package_no
|
||||
if ($remainingCount == 0) {
|
||||
// Check if there are any weld_logs records with this test_package_no
|
||||
$weldLogsCount = db("weld_logs")
|
||||
->where("test_package_no", $testPackageNo)
|
||||
->count();
|
||||
|
||||
if ($weldLogsCount > 0) {
|
||||
dump("Cannot delete test_packages. Found $weldLogsCount weld_logs records for test_package_no: $testPackageNo");
|
||||
} else {
|
||||
$deletedCount = db("test_packages")
|
||||
->where("test_package_number", $testPackageNo)
|
||||
->delete();
|
||||
|
||||
dump("No remaining test_pack_base_statuses for test_package_no: $testPackageNo. Deleted $deletedCount test_packages records.");
|
||||
}
|
||||
} else {
|
||||
dump("Found $remainingCount remaining test_pack_base_statuses for test_package_no: $testPackageNo. Keeping test_packages records.");
|
||||
}
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
dump("Error processing test_packages deletion: " . $th->getMessage());
|
||||
Log::error("DeleteTrigger test_pack_base_statuses error: " . $th->getMessage());
|
||||
}
|
||||
} else {
|
||||
dump("Test pack base status not found with id: " . $request['key']);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
// Get the test package that is being deleted
|
||||
$testPackage = db("test_packages")->where("id", $request['key'])->first();
|
||||
|
||||
if ($testPackage) {
|
||||
try {
|
||||
// Check if there are any weld_logs records with this test_package_number
|
||||
$weldLogsCount = db("weld_logs")
|
||||
->where("test_package_no", $testPackage->test_package_number)
|
||||
->count();
|
||||
|
||||
if ($weldLogsCount > 0) {
|
||||
dump("Cannot delete test_pack_base_statuses. Found $weldLogsCount weld_logs records for test_package_no: " . $testPackage->test_package_number);
|
||||
} else {
|
||||
// Delete related test_pack_base_statuses records based on test_package_number
|
||||
$deletedCount = db("test_pack_base_statuses")
|
||||
->where("test_package_no", $testPackage->test_package_number)
|
||||
->delete();
|
||||
|
||||
dump("Deleted $deletedCount test_pack_base_statuses records for test_package_no: " . $testPackage->test_package_number);
|
||||
}
|
||||
|
||||
} catch (\Throwable $th) {
|
||||
dump("Error deleting test_pack_base_statuses: " . $th->getMessage());
|
||||
Log::error("DeleteTrigger test_packages error: " . $th->getMessage());
|
||||
}
|
||||
} else {
|
||||
dump("Test package not found with id: " . $request['key']);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
if(isset($oldData->test_package_no))
|
||||
{
|
||||
$testPackWhereData = [
|
||||
'test_package_number' => $oldData->test_package_no
|
||||
];
|
||||
|
||||
$testPackBaseStatusWhereData = [
|
||||
'test_package_no' => $oldData->test_package_no,
|
||||
'drawing_no' => $oldData->iso_number,
|
||||
];
|
||||
|
||||
// Önce weld_logs tablosunda aynı test_package_no var mı kontrol et
|
||||
$weldLogCount = db("weld_logs")
|
||||
->where(['test_package_no' => $oldData->test_package_no])
|
||||
->count();
|
||||
|
||||
if ($weldLogCount > 0) {
|
||||
Log::info("{$oldData->test_package_no} nolu test package weld_logs tablosunda mevcut, silme işlemi yapılmadı.");
|
||||
} else {
|
||||
$testPackagesChanged = db("test_packages")
|
||||
->where($testPackWhereData)
|
||||
->delete();
|
||||
|
||||
$tpBaseChanged = db("test_pack_base_statuses")
|
||||
->where($testPackBaseStatusWhereData)
|
||||
->delete();
|
||||
|
||||
Log::info("{$oldData->test_package_no} nolu test package {$oldData->iso_number} iso number dan silindi\ntpBaseDeleted: $tpBaseChanged\ntestPackagesDeleted: $testPackagesChanged\n");
|
||||
}
|
||||
|
||||
} else {
|
||||
Log::error("Weld log testp package no not found for ISO number: {$oldData->iso_number}");
|
||||
}
|
||||
|
||||
spoolStatusChanger($oldData->iso_number);
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user