Files
citrus-cms/resources/views/cron-documents/cleaning-blowing-generator.blade.php
2026-04-28 21:15:09 +03:00

100 lines
3.3 KiB
PHP

<?php
use App\Models\WelderTest;
use Barryvdh\DomPDF\Facade\Pdf;
use Carbon\Carbon;
setlocale(LC_ALL, 'ru_RU.utf8');
App::setLocale("ru");
$documentInfo = document_template("Cleaning_Blowing");
$j = j($documentInfo->json);
$weldLogs = db("weld_logs");
$weldLogs = $weldLogs->join("subcontractors", "weld_logs.general_contractor", "subcontractors.company_name_en");
$weldLogs = $weldLogs->groupBy("line_number")->get();
$prefix = "📂 cleainig-blowing-generator";
Log::debug("$prefix start " . simdi());
$k = 0;
foreach($weldLogs AS $weldLog) {
$contractorInfo = db("subcontractors")->where("company_name_en", $weldLog->contractor)->first();
$workPermitInfo = db("work_permit_documents")
->where("duty", "Главный Начальник участка")
->where("zone", "like", "%{$weldLog->project}%")->first();
$fileName = $weldLog->line_number;
$string = $documentInfo->html;
$string = pdf_html_content($string);
$date = (new Carbon($weldLog->date_test));
$city = $contractorInfo?->city;
$c1 = $date->translatedFormat('d');
$c2 = $date->translatedFormat('F');
$c3 = $date->translatedFormat('y');
$c4 = $weldLog->general_contractor . "<hr>" . $weldLog->address;
$c5 = $contractorInfo?->company_name_ru;
$c6 = "";
$c7 = $workPermitInfo?->duty . " " . $workPermitInfo?->name_surname;
$c8 = "";
$c9 = $workPermitInfo?->third_party;
$c10 = $workPermitInfo?->duty;
$c11 = $contractorInfo?->company_name_ru;
$c12 = "";
$c13 = $weldLog->iso_number;
$c14 = "воздух";
if($weldLog->type_of_test == "Hydraulic") {
$c14 = "водой";
}
$c15 = $weldLog->design_pressure_mpa;
$c16 = $weldLog->test_pressure;
$c17 = "0,5";
$c18 = $workPermitInfo?->name_surname;
$c19 = $workPermitInfo?->name_surname;
$c20 = $workPermitInfo?->name_surname;
$c21 = "";
$c22 = "";
$c23 = "";
$string = str_replace("{city}", $city, $string);
$string = str_replace("{c1}", $c1, $string);
$string = str_replace("{c2}", $c2, $string);
$string = str_replace("{c3}", $c3, $string);
$string = str_replace("{c4}", $c4, $string);
$string = str_replace("{c5}", $c5, $string);
$string = str_replace("{c6}", $c6, $string);
$string = str_replace("{c7}", $c7, $string);
$string = str_replace("{c8}", $c8, $string);
$string = str_replace("{c9}", $c9, $string);
$string = str_replace("{c10}", $c10, $string);
$string = str_replace("{c11}", $c11, $string);
$string = str_replace("{c12}", $c12, $string);
$string = str_replace("{c13}", $c13, $string);
$string = str_replace("{c14}", $c14, $string);
$string = str_replace("{c15}", $c15, $string);
$string = str_replace("{c16}", $c16, $string);
$string = str_replace("{c17}", $c17, $string);
$string = str_replace("{c18}", $c18, $string);
$string = str_replace("{c19}", $c19, $string);
$string = str_replace("{c20}", $c20, $string);
$string = str_replace("{c21}", $c21, $string);
$string = str_replace("{c22}", $c22, $string);
$string = str_replace("{c23}", $c23, $string);
$path = $documentInfo->kid;//"005_PTO/08_Спецификация";
$path = "$path/$fileName";
html_create($path, $string);
$k++;
}
Log::debug("$prefix finish processed $k " . simdi());
?>