Files
2026-04-28 21:15:09 +03:00

269 lines
13 KiB
PHP
Raw Permalink 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
use App\Models\WelderTest;
use Barryvdh\DomPDF\Facade\Pdf;
$userInfo = db("users");
if(getisset("id")) {
$userInfos = $userInfo
//->select("id","pic","name", "name_ru", "registration_no AS welder_id")
->where("registration_no", get("id"));
}
$userInfos = $userInfo->whereIn("level", ['Welder'])->get();
foreach($userInfos AS $userInfo) {
$documentInfo = document_template("WQTR_Dopusk_list");
$j = j($documentInfo->json);
$welderInfo = db("naks_welders")->where("welder_id", $userInfo->registration_no)->first();
$welderTests = WelderTest::where("naks_id", $userInfo->registration_no)
->select("*")
->selectRaw(DB::raw("(GROUP_CONCAT(kss_number SEPARATOR ' / ')) AS kss_number"))
->selectRaw(DB::raw("(GROUP_CONCAT(vt_report_no SEPARATOR ' <br> ')) AS vt_reports"))
->selectRaw(DB::raw("(GROUP_CONCAT(vt_date SEPARATOR ' <br> ')) AS vt_dates"))
->selectRaw(DB::raw("(GROUP_CONCAT(vt_result SEPARATOR ' <br> ')) AS vt_results"))
->selectRaw(DB::raw("(GROUP_CONCAT(rt_report_no SEPARATOR ' <br> ')) AS rt_reports"))
->selectRaw(DB::raw("(GROUP_CONCAT(rt_result SEPARATOR ' <br> ')) AS rt_results"))
->selectRaw(DB::raw("(GROUP_CONCAT(rt_date SEPARATOR ' <br> ')) AS rt_dates"))
->selectRaw(DB::raw("(GROUP_CONCAT(pmi_report_no SEPARATOR ' <br> ')) AS pmi_reports"))
->selectRaw(DB::raw("(GROUP_CONCAT(pmi_result SEPARATOR ' <br> ')) AS pmi_results"))
->selectRaw(DB::raw("(GROUP_CONCAT(pmi_date SEPARATOR ' <br> ')) AS pmi_dates"))
->selectRaw(DB::raw("(GROUP_CONCAT(ht_report_no SEPARATOR ' <br> ')) AS ht_reports"))
->selectRaw(DB::raw("(GROUP_CONCAT(ht_result SEPARATOR ' <br> ')) AS ht_results"))
->selectRaw(DB::raw("(GROUP_CONCAT(ht_date SEPARATOR ' <br> ')) AS ht_dates"))
->selectRaw(DB::raw("(GROUP_CONCAT(ferrit_report_no SEPARATOR ' <br> ')) AS ferrite_reports"))
->selectRaw(DB::raw("(GROUP_CONCAT(ferrit_result SEPARATOR ' <br> ')) AS ferrite_results"))
->selectRaw(DB::raw("(GROUP_CONCAT(ferrit_date SEPARATOR ' <br> ')) AS ferrite_dates"))
->selectRaw(DB::raw("(GROUP_CONCAT(metallography_report_no SEPARATOR ' <br> ')) AS mt_reports"))
->selectRaw(DB::raw("(GROUP_CONCAT(metallography_result SEPARATOR ' <br> ')) AS mt_results"))
->selectRaw(DB::raw("(GROUP_CONCAT(metallography_date SEPARATOR ' <br> ')) AS mt_dates"))
->selectRaw(DB::raw("(GROUP_CONCAT(intergranullar_corrosion_report_no SEPARATOR ' <br> ')) AS icr_reports"))
->selectRaw(DB::raw("(GROUP_CONCAT(intergranullar_corrosion_result SEPARATOR ' <br> ')) AS icr_results"))
->selectRaw(DB::raw("(GROUP_CONCAT(intergranullar_corrosion_test_date SEPARATOR ' <br> ')) AS icr_dates"))
->groupBy("wpq_document_no")
->get();
$dateOfWelds = [];
$groupMaterials = [];
$process = [];
$naksDate = date("d.m.Y", strtotime($welderInfo->period_of_validity));
$naksNo = $welderInfo->naks_certificate_no;
$naksNo = "$naksNo до дд$naksDate";
foreach($welderTests AS $welderTest) {
$dateOfWeld = date("d.m.Y", strtotime($welderTest->welding_date));
$fileName = $welderTest->wpq_document_no;
$string = $documentInfo->html;
$string = pdf_html_content($string);
$object = $welderInfo->qualitification_category;
$company = $welderInfo->company;
$contractor = $welderInfo->company;
$document_no = $welderInfo->order_no;
$document_date = date("d.m.Y");
$full_name = $welderInfo->welder_name_en;
$birth_year = date("Y", strtotime($welderInfo->year_of_birth));
$qualification_category = $welderInfo->qualitification_category;
$work_experience_in_welding = $welderInfo->work_experience;
$naks_number = $naksNo;
$order_number = $welderInfo->welder_id;
$date_of_weld = $dateOfWeld;
$type_of_weld = $welderInfo->process;
$welding_regulatory_document = $welderInfo->naks_certificate_no . "<br> " . $welderInfo->order_no;
$weld_joint_mark = $welderTest->kss_number;
$group_and_grade_of_welded_materal = "{$welderTest->material_group_1} {$welderTest->grade_1}";
if($welderTest->material_group_1 != $welderTest->material_group_2) {
$group_and_grade_of_welded_materal .= ", {$welderTest->material_group_2} {$welderTest->grade_2}";
}
$type_of_welded_parts = $welderInfo->weld_type;
$outside_dia = $welderTest->dia_max;
$wall_thk = $welderTest->thk_max;
$seam_type = $welderTest->joint_type;
$type_of_welded_joint = "Труба+труба / Pipe + pipe";
if($welderTest->shield_gas == "AR") {
$joint_layers = "многопроходной / multipass";
} else {
$joint_layers = "одинокий / single";
}
$position_during_welding = $welderInfo->welding_position;
$welding_equipment = "Lincoln Electric Invertec 270-TP";
$type_and_classification_of_electrodes = "Н";
$welding_filler_wire_class = $welderTest->wire;
$shielding_gas_type = $welderTest->shield_gas;
$thermal_treatment_date = "Н";
$testing_regulatory_documents = "";
$vt_reports = $welderTest->vt_reports;
$vt_date = $welderTest->vt_dates;
$vt_status = $welderTest->vt_results;
$rt_reports = $welderTest->rt_reports;
$rt_date = $welderTest->rt_dates;
$rt_status = $welderTest->rt_results;
$ut_reports = $welderTest?->ut_reports;
$ut_date = "";
$ut_status = "";
$mt_reports = $welderTest->mt_reports;
$mt_date = $welderTest->mt_dates;
$mt_status = $welderTest->mt_results;
$pmi_reports = $welderTest->pmi_reports;
$pmi_date = $welderTest->pmi_dates;
$pmi_status = $welderTest->pmi_results;
$ht_reports = $welderTest->ht_reports;
$ht_date = $welderTest->ht_dates;
$ht_status = $welderTest->ht_results;
$st_status = "";
$sb_reports = "";
$sb_date = "";
$sb_status = "";
$ibt_reports = "";
$ibt_date = "";
$ibt_status = "";
$metallography_reports = $welderTest->mt_reports;
$metallography_date = $welderTest->mt_dates;
$metallography_status = $welderTest->mt_results;
$ferrite_reports = $welderTest->ferrite_reports;
$ferrite_date = $welderTest->ferrite_dates;
$ferrite_status = $welderTest->ferrite_results;
$icr_reports = $welderTest->icr_reports;
$icr_date = $welderTest->icr_dates;
$icr_status = $welderTest->icr_results;
$welding_up = $welderInfo->process;
$type_of_welded_parts = $welderInfo->component;
$joint_types = $welderInfo->weld_type;
$welds_types = "Стыковое, угловое, нахлесточное/ butt weld, fillet weld, T-Join Weld";
$joint_types = "Все/ All";
$outer_dia = "от {$welderTest->dia_min} до {$welderTest->dia_max}";
$parts_thk = "от {$welderTest->thk_min} до {$welderTest->thk_max}
";
$welded_material_group = $welderTest->material_1;
$welded_material_type = "{$welderTest->wire}, {$welderTest->electrode}, {$welderTest->flux}";
$equipment_group = $welderTest->technology_range;
$welded_joint = "{$welderTest->process} ос (бп)";
$head_of_welding = "";
$welding_inspector = "";
$welding_engineer = "";
$string = str_replace("{object}", $object, $string);
$string = str_replace("{company}", $company, $string);
$string = str_replace("{contractor}", $contractor, $string);
$string = str_replace("{document_no}", $document_no, $string);
$string = str_replace("{document_no}", $document_no, $string);
$string = str_replace("{document_date}", $document_date, $string);
$string = str_replace("{full_name}", $full_name, $string);
$string = str_replace("{birth_year}", $birth_year, $string);
$string = str_replace("{qualification_category}", $qualification_category, $string);
$string = str_replace("{work_experience_in_welding}", $work_experience_in_welding, $string);
$string = str_replace("{naks_number}", $naks_number, $string);
$string = str_replace("{order_number}", $order_number, $string);
$string = str_replace("{date_of_weld}", $date_of_weld, $string);
$string = str_replace("{type_of_weld}", $type_of_weld, $string);
$string = str_replace("{welding_regulatory_document}", $welding_regulatory_document, $string);
$string = str_replace("{weld_joint_mark}", $weld_joint_mark, $string);
$string = str_replace("{group_and_grade_of_welded_materal}", $group_and_grade_of_welded_materal, $string);
$string = str_replace("{type_of_welded_parts}", $type_of_welded_parts, $string);
$string = str_replace("{outside_dia}", $outside_dia, $string);
$string = str_replace("{wall_thk}", $wall_thk, $string);
$string = str_replace("{seam_type}", $seam_type, $string);
$string = str_replace("{type_of_welded_joint}", $type_of_welded_joint, $string);
$string = str_replace("{joint_layers}", $joint_layers, $string);
$string = str_replace("{position_during_welding}", $position_during_welding, $string);
$string = str_replace("{welding_equipment}", $welding_equipment, $string);
$string = str_replace("{type_and_classification_of_electrodes}", $type_and_classification_of_electrodes, $string);
$string = str_replace("{welding_filler_wire_class}", $welding_filler_wire_class, $string);
$string = str_replace("{shielding_gas_type}", $shielding_gas_type, $string);
$string = str_replace("{thermal_treatment_date}", $thermal_treatment_date, $string);
$string = str_replace("{testing_regulatory_documents}", $testing_regulatory_documents, $string);
$string = str_replace("{vt_reports}", $vt_reports, $string);
$string = str_replace("{vt_date}", $vt_date, $string);
$string = str_replace("{vt_status}", $vt_status, $string);
$string = str_replace("{rt_reports}", $rt_reports, $string);
$string = str_replace("{rt_date}", $rt_date, $string);
$string = str_replace("{rt_status}", $rt_status, $string);
$string = str_replace("{ut_reports}", $ut_reports, $string);
$string = str_replace("{ut_date}", $ut_date, $string);
$string = str_replace("{ut_status}", $ut_status, $string);
$string = str_replace("{mt_reports}", $mt_reports, $string);
$string = str_replace("{mt_date}", $mt_date, $string);
$string = str_replace("{mt_status}", $mt_status, $string);
$string = str_replace("{pmi_reports}", $pmi_reports, $string);
$string = str_replace("{pmi_date}", $pmi_date, $string);
$string = str_replace("{pmi_status}", $pmi_status, $string);
$string = str_replace("{ht_reports}", $ht_reports, $string);
$string = str_replace("{ht_date}", $ht_date, $string);
$string = str_replace("{ht_status}", $ht_status, $string);
$string = str_replace("{rt_reports}", $rt_reports, $string);
$string = str_replace("{rt_date}", $rt_date, $string);
$string = str_replace("{st_status}", $st_status, $string);
$string = str_replace("{sb_reports}", $sb_reports, $string);
$string = str_replace("{sb_date}", $sb_date, $string);
$string = str_replace("{sb_status}", $sb_status, $string);
$string = str_replace("{ibt_reports}", $ibt_reports, $string);
$string = str_replace("{ibt_date}", $ibt_date, $string);
$string = str_replace("{ibt_status}", $ibt_status, $string);
$string = str_replace("{metallography_reports}", $metallography_reports, $string);
$string = str_replace("{metallography_date}", $metallography_date, $string);
$string = str_replace("{metallography_status}", $metallography_status, $string);
$string = str_replace("{ferrite_reports}", $ferrite_reports, $string);
$string = str_replace("{ferrite_date}", $ferrite_date, $string);
$string = str_replace("{ferrite_status}", $ferrite_status, $string);
$string = str_replace("{icr_reports}", $icr_reports, $string);
$string = str_replace("{icr_date}", $icr_date, $string);
$string = str_replace("{icr_status}", $icr_status, $string);
$string = str_replace("{welding_up}", $welding_up, $string);
$string = str_replace("{type_of_welded_parts}", $type_of_welded_parts, $string);
$string = str_replace("{joint_types}", $joint_types, $string);
$string = str_replace("{welds_types}", $welds_types, $string);
$string = str_replace("{joint_types}", $joint_types, $string);
$string = str_replace("{outer_dia}", $outer_dia, $string);
$string = str_replace("{parts_thk}", $parts_thk, $string);
$string = str_replace("{welded_material_group}", $welded_material_group, $string);
$string = str_replace("{welded_material_type}", $welded_material_type, $string);
$string = str_replace("{welding_equipment}", $welding_equipment, $string);
$string = str_replace("{equipment_group}", $equipment_group, $string);
$string = str_replace("{welded_joint}", $welded_joint, $string);
$string = str_replace("{head_of_welding}", $head_of_welding, $string);
$string = str_replace("{welding_inspector}", $welding_inspector, $string);
$string = str_replace("{welding_engineer}", $welding_engineer, $string);
// echo $string;
$path = "004_QA/0015_WQTR";
$path = "$path/$fileName";
html_create($path, $string);
if(getisset("id")) {
yonlendir(url("storage/documents/$path"));
}
}
}
?>