105 lines
2.9 KiB
PHP
105 lines
2.9 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("Hydro_test");
|
|
$j = j($documentInfo->json);
|
|
|
|
function mb_str_replace($search, $replace, $subject) {
|
|
return implode($replace, explode($search, $subject, 2));
|
|
}
|
|
|
|
$weldLogs = db("weld_logs");
|
|
$weldLogs = $weldLogs->join("subcontractors", "weld_logs.general_contractor", "subcontractors.company_name_en");
|
|
|
|
$montajContractor = db("subcontractors")->where("job_description", "MONTAJ")->first();
|
|
$constructionContractor = db("subcontractors")->where("job_description", "CONSTRUCTION")->first();
|
|
|
|
$weldLogs = $weldLogs->groupBy("line_number")->get();
|
|
|
|
$prefix = "📂 hydro-test-generator";
|
|
Log::debug("$prefix start " . simdi());
|
|
|
|
$k = 0;
|
|
|
|
$projectNameRu = setting('project_name_ru');
|
|
|
|
foreach($weldLogs AS $weldLog) {
|
|
$contractorInfo = db("subcontractors")->where("company_name_en", $weldLog->contractor)->first();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$fileName = $weldLog->line_number;
|
|
$string = $documentInfo->html;
|
|
$string = pdf_html_content($string);
|
|
|
|
$string = str_replace("{project_name}", $projectNameRu, $string);
|
|
|
|
|
|
$string = workPermitReplacer($string, $weldLog, $documentInfo);
|
|
|
|
|
|
$date = (new Carbon($weldLog->date_test));
|
|
$c1 = $contractorInfo?->project_city_ru;
|
|
$c2 = $date->translatedFormat('d');
|
|
$c3 = $date->translatedFormat('F');
|
|
$c4 = $date->translatedFormat('y');
|
|
$c5 = $weldLog->general_contractor . "<hr>" . $weldLog->address;
|
|
$c6 = $montajContractor?->company_name_ru;
|
|
$c7 = $contractorInfo?->company_name_ru ;
|
|
|
|
$c11 = $contractorInfo?->company_name_ru;
|
|
$c12 = $constructionContractor?->company_name_ru;
|
|
$c13 = $weldLog->iso_number;
|
|
|
|
$c14 = "вода";
|
|
if($weldLog->type_of_test == "Hydraulic") {
|
|
$c14 = "водой";
|
|
}
|
|
|
|
$c15 = $weldLog->design_pressure_mpa;
|
|
$c16 = $weldLog->test_pressure;
|
|
$c17 = "0,5";
|
|
|
|
$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("{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);
|
|
|
|
|
|
|
|
|
|
$path = $documentInfo->kid; //"005_PTO/06_Прочность и плотность";
|
|
$path = "$path/$fileName";
|
|
html_create($path, $string);
|
|
|
|
/*
|
|
echo $string;
|
|
exit();
|
|
*/
|
|
|
|
$k++;
|
|
|
|
|
|
}
|
|
|
|
echo $k;
|
|
Log::debug("$prefix finish processed $k " . simdi());
|
|
?>
|
|
|