95 lines
3.3 KiB
PHP
95 lines
3.3 KiB
PHP
<?php
|
|
use App\Models\WelderTest;
|
|
use Barryvdh\DomPDF\Facade\Pdf;
|
|
|
|
$documentInfo = document_template("Pipeline_certificate");
|
|
$j = j($documentInfo->json);
|
|
$lineLists = db("line_lists");
|
|
if(getisset("line_no")) {
|
|
$lineLists = $lineLists
|
|
//->select("id","pic","name", "name_ru", "registration_no AS welder_id")
|
|
->whereIn("line_no", get("line_no"));
|
|
}
|
|
if(getisset("first")) {
|
|
$lineLists = $lineLists->take(1);
|
|
}
|
|
|
|
$lineLists = $lineLists->join("weld_logs","line_lists.line_no", "weld_logs.line_number")->whereNotNull("welding_date")->groupBy("line_no")->get();
|
|
$projectNameRu = setting('project_name_ru');
|
|
$prefix = "📂 line-certificate-generator";
|
|
Log::debug("$prefix start " . simdi());
|
|
$count = 0;
|
|
foreach($lineLists AS $lineList) {
|
|
|
|
//dump($lineList);
|
|
$fileName = $lineList->line_no;
|
|
$string = $documentInfo->html;
|
|
$string = pdf_html_content($string);
|
|
$string = str_replace("{project_name}", $projectNameRu, $string);
|
|
$string = workPermitReplacer($string, null, $documentInfo);
|
|
|
|
$certificate_no = $lineList->line_no;
|
|
|
|
try {
|
|
$content = db("subcontractors")->where("job_description", "CONSTRUCTION")->first()->company_name_ru;
|
|
} catch (\Throwable $th) {
|
|
$content = "СТЕЛЛАР";
|
|
}
|
|
|
|
$certificate_title = "Линия ({$lineList->line_no}, Категория {$lineList->category} {$lineList->fluid_group}";
|
|
$press_title = "Продукт - {$lineList->fluid_ru}, Ррасч. = {$lineList->design_pressure_mpa} MPa/FV, Трасч. = {$lineList->design_temperature}°C";
|
|
$content3 = "{$lineList->p_id}, {$lineList->iso_number}";
|
|
$content4 = getBeforeSlash($lineList->welding_method);
|
|
$content5 = "ВК - 100%, РК - %{$lineList->rt_scope}";
|
|
|
|
if($lineList->pwht == "YES") {
|
|
$content6 = "Требуется в соответствии с ГОСТ 32569-2013";
|
|
} else {
|
|
$content6 = "не требуется";
|
|
}
|
|
|
|
if($lineList->pmi_scope != "") {
|
|
$pmi_status = "Требуется в соответствии с ОСТ 36-50-86";
|
|
} else {
|
|
$pmi_status = "Не Требуется";
|
|
}
|
|
|
|
$content7 = "";
|
|
$content8 = df($lineList->date_test);
|
|
$content9 = "";
|
|
|
|
$string = str_replace("{date}", date("d.m.Y", strtotime($lineList->welding_date)), $string);
|
|
$string = str_replace("{pmi_status}", $pmi_status, $string);
|
|
$string = str_replace("{certificate_no}", $certificate_no, $string);
|
|
$string = str_replace("{content}", $content, $string);
|
|
$string = str_replace("{certificate_title}", $certificate_title, $string);
|
|
$string = str_replace("{press_title}", $press_title, $string);
|
|
$string = str_replace("{content3}", $content3, $string);
|
|
$string = str_replace("{content4}", $content4, $string);
|
|
$string = str_replace("{content5}", $content5, $string);
|
|
$string = str_replace("{content6}", $content6, $string);
|
|
$string = str_replace("{content7}", $content7, $string);
|
|
$string = str_replace("{content8}", $content8, $string);
|
|
$string = str_replace("{content9}", $content9, $string);
|
|
|
|
// echo $string; exit();
|
|
|
|
|
|
$path = $documentInfo->kid;//"005_PTO/03_свидетельство";
|
|
$path = "$path/$fileName";
|
|
html_create($path, $string);
|
|
|
|
$count++;
|
|
|
|
}
|
|
echo $count;
|
|
Log::debug("$prefix finish " . simdi());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
?>
|
|
|