107 lines
3.2 KiB
PHP
107 lines
3.2 KiB
PHP
|
||
<?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());
|
||
|
||
?>
|