Files
citrus-cms/resources/views/cron/pdf-db-naks-consumables-sync.blade.php
T
2026-04-28 21:15:09 +03:00

107 lines
3.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
//document_revisions
$table = "naks_consumables";
$mainPath = "003_Welding_Database/0003_Naks_Consumables";
$mainPath2 = "003_Welding_Database/0003_Naks_Consumables";
$nullDownload = db($table);
// Eğer fileName değişkeni varsa, sadece ilgili kayıtları filtrele
if(isset($fileName) && !empty($fileName)) {
$nullDownload = $nullDownload->where(function($query) use ($fileName) {
$query->where('naks_certificate_no', 'LIKE', "$fileName")
->orWhere('batch_number', 'LIKE', "$fileName")
->orWhere('inspection_test_report', 'LIKE', "$fileName")
->orWhere('icm_akt_no', 'LIKE', "$fileName");
});
}
$nullDownload = $nullDownload->get();
//dump($nullDownload->count());
DB::beginTransaction();
$say = 0;
$k = 0;
Log::debug("📄$table PDF Link to DB Start " . simdi());
try {
foreach($nullDownload AS $ne) {
$data = "{$ne->naks_certificate_no}";
$data = str_replace("/", "*", $data);
$data = str_replace(" ", "*", $data);
$data2 = "{" . $ne->batch_number . "," . $ne->inspection_test_report . "}";
$data2 = str_replace("/", "*", $data2);
$data2 = str_replace(" ", "*", $data2);
// ICM Akt No için arama kriteri
$data3 = "{$ne->icm_akt_no}";
$data3 = str_replace("/", "*", $data3);
$data3 = str_replace(" ", "*", $data3);
if(trim($data) != "") {
$path = "storage/documents/$mainPath/*$data*";
$searchPDF = glob($path);
$path2 = "storage/documents/$mainPath/*$data2*";
//dump($path2);
$searchPDF2 = glob($path2, GLOB_BRACE);
// ICM Akt No için PDF arama
$path3 = "storage/documents/$mainPath/*$data3*";
$searchPDF3 = glob($path3);
$updateData = [];
$updateData['naks_technology'] = null;
$updateData['inspection_test_report_download'] = null;
$updateData['icm_akt_no_download'] = null;
if(isset($searchPDF[0])) {
$updateData['naks_technology'] = $searchPDF[0];
}
$updateData['inspection_test_report_download'] = null;
if(isset($searchPDF2[0])) {
$updateData['inspection_test_report_download'] = $searchPDF2[0];
}
if(isset($searchPDF3[0])) {
$updateData['icm_akt_no_download'] = $searchPDF3[0];
}
//dump($updateData);
echo db($table)
->where("id", $ne->id)
->update($updateData);
$k++;
if($say == $commitSize) {
DB::commit();
DB::beginTransaction();
$say = 0;
}
$say++;
}
}
DB::commit();
Log::debug("$table update PDF link for $k rows");
//dump("$table update PDF link for $k rows");
} catch (\Throwable $th) {
DB::rollback();
Log::error("not update PDF links " . $th->getMessage());
////dump($th->getMessage());
}
Log::debug("📄$table PDF Link to DB Finish " . simdi());
?>