389 lines
13 KiB
PHP
389 lines
13 KiB
PHP
<?php
|
||
set_time_limit(-1);
|
||
use Barryvdh\DomPDF\Facade\Pdf;
|
||
|
||
|
||
|
||
$temperatures = j(setting("temperatures"));
|
||
if(getisset("all")) {
|
||
$drawings = apply_welded_filter(
|
||
db("weld_logs")->select("line_number")
|
||
)
|
||
->groupBy("line_number")
|
||
->get()
|
||
->pluck("line_number")
|
||
->toArray();
|
||
} else {
|
||
$drawings = explode(",", get("line_number"));
|
||
}
|
||
$count = 0;
|
||
foreach($drawings AS $draw) {
|
||
$documentInfo = document_template("Welding_Jurnal");
|
||
$j = j($documentInfo->json);
|
||
|
||
$fileName = $draw;
|
||
|
||
$weldLogs = apply_welded_filter(
|
||
db("weld_logs")->where("line_number", $draw)
|
||
)
|
||
->whereNotNull("welding_date")
|
||
->orderBy("welding_date", "ASC")
|
||
->get();
|
||
|
||
$line_list_fluid_ru = "";
|
||
$allRowData = "";
|
||
$basinc = "";
|
||
$sicaklik = "";
|
||
|
||
if($weldLogs->count() != 0) {
|
||
$drawing_no = $weldLogs[0]->line_number;
|
||
$cover_zone = __($weldLogs[0]->project);
|
||
$first_welding_date = df(
|
||
apply_welded_filter(
|
||
db("weld_logs")->where("line_number", $draw)
|
||
)
|
||
->whereNotNull("welding_date")
|
||
->orderBy("welding_date", "ASC")
|
||
->first()->welding_date
|
||
);
|
||
|
||
|
||
|
||
$last_welding_date = df(apply_welded_filter(
|
||
db("weld_logs")->where("line_number", $draw)
|
||
)
|
||
->selectRaw('MAX(GREATEST(
|
||
COALESCE(welding_date, "1000-01-01"),
|
||
COALESCE(vt_test_date, "1000-01-01"),
|
||
COALESCE(pt_test_date, "1000-01-01"),
|
||
COALESCE(mt_test_date, "1000-01-01"),
|
||
COALESCE(ut_test_date, "1000-01-01"),
|
||
COALESCE(rt_test_date, "1000-01-01"),
|
||
COALESCE(pmi_test_date, "1000-01-01"),
|
||
COALESCE(ht_test_date, "1000-01-01"),
|
||
COALESCE(ferrite_test_date, "1000-01-01")
|
||
)) AS latest_date')
|
||
->first()->latest_date);
|
||
|
||
|
||
|
||
$lineList = db("line_lists")
|
||
->where("line_no", $weldLogs[0]->line_number)
|
||
->where("fluid_code", $weldLogs[0]->fluid_code)
|
||
->first();
|
||
|
||
if($lineList) {
|
||
$line_list_fluid_ru = $lineList->fluid_ru;
|
||
} else {
|
||
Log::error("{$weldLogs[0]->line_number} {$weldLogs[0]->fluid_code} datası bulunamadı Generate ZHCP Welding Journal ERROR! ");
|
||
}
|
||
|
||
|
||
|
||
$k = 1;
|
||
$work_permit_documents = db("work_permit_documents")->where("duty", "NDT")->where("level", 3)->first();
|
||
$work_permit_documents2 = db("work_permit_documents")->where("duty", "инженер по сварке")->where("level", 3)->first();
|
||
|
||
foreach($weldLogs AS $weldLog) {
|
||
$basinc = $weldLog->operating_pressure_mpa;
|
||
$sicaklik = $weldLog->operating_temperature_s;
|
||
|
||
|
||
$weldLog->welding_date = rejected_date($weldLog->welding_date) ? "-" : df($weldLog->welding_date);
|
||
$weldLog->vt_test_date = rejected_date($weldLog->vt_test_date) ? "-" : df($weldLog->vt_test_date);
|
||
$weldLog->pt_test_date = rejected_date($weldLog->pt_test_date) ? "-" : df($weldLog->pt_test_date);
|
||
$weldLog->mt_test_date = rejected_date($weldLog->mt_test_date) ? "-" : df($weldLog->mt_test_date);
|
||
$weldLog->ut_test_date = rejected_date($weldLog->ut_test_date) ? "-" : df($weldLog->ut_test_date);
|
||
$weldLog->rt_test_date = rejected_date($weldLog->rt_test_date) ? "-" : df($weldLog->rt_test_date);
|
||
$weldLog->pmi_test_date = rejected_date($weldLog->pmi_test_date) ? "-" : df($weldLog->pmi_test_date);
|
||
$weldLog->ht_test_date = rejected_date($weldLog->ht_test_date) ? "-" : df($weldLog->ht_test_date);
|
||
$weldLog->ferrite_test_date = rejected_date($weldLog->ferrite_test_date) ? "-" : df($weldLog->ferrite_test_date);
|
||
|
||
$weldLog->pwht_date = rejected_date($weldLog->pwht_date) ? "-" : df($weldLog->pwht_date);
|
||
|
||
$naksWelder = db("naks_welders")->where("welder_id", $weldLog->welder_1)->first();
|
||
|
||
if($weldLog->welder_2 != "") {
|
||
$naksWelder2 = db("naks_welders")->where("welder_id", $weldLog->welder_2)->first();
|
||
}
|
||
|
||
|
||
$col24 = "";
|
||
if($work_permit_documents) {
|
||
$col24 = "{$work_permit_documents->name_surname}, {$work_permit_documents->certificate_number}";
|
||
}
|
||
|
||
$col25 = "";
|
||
if($work_permit_documents2) {
|
||
$col25 = "{$work_permit_documents2->name_surname}, {$work_permit_documents2->certificate_number}";
|
||
}
|
||
$wps = db("w_p_s")->where("details", $weldLog->wps_no)->first();
|
||
$mtos = db("incoming_controls")->where("certificate_no", $weldLog->certificate_number_of_1)->first();
|
||
$mtos2 = db("incoming_controls")->where("certificate_no", $weldLog->certificate_number_of_2)->first();
|
||
$naks_consumables = db("naks_consumables")->where("inspection_test_report", $weldLog->welding_materials_2_certificate_no)->first();
|
||
|
||
$naks_consumables2 = db("naks_consumables")->where("inspection_test_report", $weldLog->welding_materials_1_certificate_no)->first();
|
||
$naks_consumables3 = db("naks_consumables")->where("inspection_test_report", $weldLog->welding_materials_3_certificate_no)->first();
|
||
|
||
$naksConsumablesData = "";
|
||
$naksConsumablesData2 = "";
|
||
$naksConsumablesData3 = "";
|
||
|
||
if($naks_consumables) {
|
||
$certification_date = df($naks_consumables->certification_date);
|
||
|
||
$reportNumber = $naks_consumables->inspection_test_report;
|
||
|
||
|
||
$naksConsumablesData = "⌀{$naks_consumables->diameter} {$naks_consumables->inspection_certificate_standart}, серт. $reportNumber от $certification_date";
|
||
}
|
||
|
||
if($naks_consumables2) {
|
||
$certification_date = df($naks_consumables2->certification_date);
|
||
|
||
$reportNumber = $naks_consumables2->inspection_test_report;
|
||
|
||
$naksConsumablesData2 = "⌀{$naks_consumables2->diameter} {$naks_consumables2->inspection_certificate_standart}, серт. $reportNumber от $certification_date";
|
||
}
|
||
|
||
if($naks_consumables3) {
|
||
$certification_date = df($naks_consumables3->certification_date);
|
||
|
||
$reportNumber = $naks_consumables3->inspection_test_report;
|
||
|
||
$naksConsumablesData3 = " ⌀{$naks_consumables3->diameter} {$naks_consumables3->inspection_certificate_standart}, серт. $reportNumber от $certification_date";
|
||
}
|
||
|
||
$welders = "{$naksWelder?->welder_name_ru}, {$weldLog->welder_1}";
|
||
if($weldLog->welder_2 != "") {
|
||
$welders .= "+ {$naksWelder2?->welder_name_ru}, {$weldLog->welder_2}";
|
||
}
|
||
|
||
|
||
$jointTypeRu = "";
|
||
|
||
|
||
|
||
if($wps) {
|
||
$jointTypeRu = $wps->joint_type_ru;
|
||
}
|
||
|
||
$manufacturing_standard_1 = "";
|
||
|
||
if($mtos) {
|
||
$manufacturing_standard_1 = $mtos?->manufacturing_standard;
|
||
}
|
||
|
||
$manufacturing_standard_2 = "";
|
||
|
||
if($mtos2) {
|
||
$manufacturing_standard_2 = $mtos?->manufacturing_standard;
|
||
}
|
||
|
||
if(strpos($weldLog->welding_materials_3, "Aргон") !== false) {
|
||
$col6 = "-";
|
||
} else {
|
||
$col6 = "{$weldLog->welding_materials_3} $naksConsumablesData3";
|
||
}
|
||
|
||
if(strpos($weldLog->welding_materials_3, "Aргон") !== false) {
|
||
$col7 = "{$weldLog->welding_materials_3} $naksConsumablesData3";
|
||
|
||
} else {
|
||
$col7 = "-";
|
||
}
|
||
|
||
$tempData = $temperatures[date("z", strtotime($weldLog->welding_date))];
|
||
|
||
|
||
if($weldLog->type_of_joint == "S") {
|
||
$thisTempData = $tempData['shop_ambient'];
|
||
$thisTempData2 = $tempData['temp_material_shop'];
|
||
} else {
|
||
$thisTempData = $tempData['field_ambient'];
|
||
$thisTempData2 = $tempData['temp_material_field'];
|
||
}
|
||
|
||
$col9 = "20 - 50 °С";
|
||
|
||
if($thisTempData>=5) {
|
||
$col9 = "просушка 20 - 50 °С";
|
||
}
|
||
|
||
$col10 = "Н/П";
|
||
|
||
|
||
|
||
if($weldLog->rt_report !="") {
|
||
$col19 = "РК";
|
||
} elseif($weldLog->ut_report !="") {
|
||
$col19 = "узк";
|
||
} else {
|
||
$col19 = "-";
|
||
}
|
||
|
||
$pmiData = "н/п";
|
||
|
||
if($weldLog->pmi_report !="") {
|
||
$pmiData = "Заключение №{$weldLog->pmi_report} от {$weldLog->pmi_test_date} годен ";
|
||
}
|
||
|
||
$htData = "н/п";
|
||
|
||
if($weldLog->ht_report !="") {
|
||
$htData = "Заключение №{$weldLog->ht_report} от {$weldLog->ht_test_date} годен";
|
||
}
|
||
|
||
$vtData = "";
|
||
|
||
if($weldLog->vt_report !="") {
|
||
$vtData = "Акт №{$weldLog->vt_report} от {$weldLog->vt_test_date} годен <br> ";
|
||
}
|
||
|
||
$ptData = "";
|
||
|
||
if($weldLog->pt_report !="") {
|
||
$ptData = "ЦД: Заключение №{$weldLog->pt_report} от {$weldLog->pt_test_date} годен <br> ";
|
||
}
|
||
|
||
$mtData = "";
|
||
|
||
if($weldLog->mt_report !="") {
|
||
$mtData = "Мк: Заключение №{$weldLog->mt_report} от {$weldLog->mt_test_date} годен <br>";
|
||
}
|
||
|
||
$rtData = "";
|
||
|
||
if($weldLog->rt_report !="") {
|
||
$rtData = "Рк: Заключение №{$weldLog->rt_report} от {$weldLog->rt_test_date} годен <br>";
|
||
}
|
||
|
||
$utData = "";
|
||
|
||
if($weldLog->ut_report !="") {
|
||
$utData = "узк: Заключение №{$weldLog->ut_report} от {$weldLog->ut_test_date} годен <br>";
|
||
}
|
||
|
||
$ferriteData = "н/п";
|
||
|
||
if($weldLog->ferrite_report !="") {
|
||
$ferriteData = "Заключение №{$weldLog->ferrite_report} от {$weldLog->ferrite_test_date} годен <br>";
|
||
}
|
||
|
||
if($weldLog->ut_report == "" && $weldLog->rt_report == "") {
|
||
$utData = "н/п";
|
||
}
|
||
|
||
$pwhtData = "н/п";
|
||
|
||
if($weldLog->pwht !="NO") {
|
||
$pwhtData = "-";
|
||
}
|
||
|
||
$diagram_number_pwht = "н/п";
|
||
|
||
if($weldLog->diagram_number_pwht !="") {
|
||
$diagram_number_pwht = $weldLog->diagram_number_pwht;
|
||
}
|
||
|
||
$weldingMethod = $weldLog->welding_method;
|
||
$weldingMethod = str_replace("/141", "", $weldingMethod);
|
||
$weldingMethod = str_replace("/111", "", $weldingMethod);
|
||
$weldingMethod = str_replace(",", " + ", $weldingMethod);
|
||
|
||
$naksConsumablesTitle = "Проволока";
|
||
if($weldLog->welding_materials_2 != "")
|
||
{
|
||
$naksConsumablesTitle = "Электроды";
|
||
}
|
||
$rowData = "
|
||
<tr class='bordered text-center'>
|
||
<td>$k</td>
|
||
<td>{$weldLog->type_of_joint}{$weldLog->no_of_the_joint_as_per_as_built_survey} - $jointTypeRu</td>
|
||
<td>$welders</td>
|
||
<td width='100'>
|
||
{$weldLog->member_no_1}, {$weldLog->material_no_1}, $manufacturing_standard_1 серт.№ {$weldLog->certificate_number_of_1}
|
||
<br> + <br>
|
||
{$weldLog->member_no_2}, {$weldLog->material_no_2}, $manufacturing_standard_2 серт.№ {$weldLog->certificate_number_of_2}
|
||
</td>
|
||
<td>
|
||
Ø{$weldLog->outside_diameter_1} x {$weldLog->wall_thickness_1} <br>
|
||
Ø{$weldLog->outside_diameter_2} x {$weldLog->wall_thickness_2}
|
||
</td>
|
||
<td>{$weldLog->welding_date} <br> $thisTempData °С</td>
|
||
<td>$weldingMethod</td>
|
||
<td>
|
||
$naksConsumablesTitle
|
||
{$weldLog->welding_materials_1} $naksConsumablesData, <br>
|
||
{$weldLog->welding_materials_2} $naksConsumablesData2, <br>
|
||
{$weldLog->welding_materials_3} $naksConsumablesData3
|
||
</td>
|
||
<td>$col9</td>
|
||
<td>$col10</td>
|
||
<td>$pmiData</td>
|
||
<td>$pwhtData</td>
|
||
<td>$diagram_number_pwht</td>
|
||
<td>$htData</td>
|
||
<td>$vtData $ptData $mtData</td>
|
||
<td>$rtData $utData</td>
|
||
<td>$ferriteData</td>
|
||
|
||
</tr>";
|
||
$rowData = str_replace(", - +", "", $rowData);
|
||
$rowData = str_replace(", +", "", $rowData);
|
||
$rowData = str_replace(", -", "", $rowData);
|
||
$rowData = str_replace(", \n", "", $rowData);
|
||
$rowData = str_replace("Φ \n", "", $rowData);
|
||
$rowData = str_replace("+ \n", "", $rowData);
|
||
$allRowData .= $rowData;
|
||
$k++;
|
||
|
||
}
|
||
|
||
//<!-- row_data -->
|
||
|
||
|
||
$document = $documentInfo->html;
|
||
|
||
$document = pdf_html_content($document);
|
||
$document = str_replace("<!-- row_data -->", $allRowData, $document);
|
||
$document = str_replace("{iso_number}", $draw, $document);
|
||
$document = str_replace("{basinc}", $basinc, $document);
|
||
$document = str_replace("{sicaklik}", $sicaklik, $document);
|
||
$document = str_replace("{line_list_fluid_ru}", $line_list_fluid_ru, $document);
|
||
$document = str_replace("{drawing_no}", $drawing_no, $document);
|
||
$document = str_replace("{first_welding_date}", $first_welding_date, $document);
|
||
$document = str_replace("{last_welding_date}", $last_welding_date, $document);
|
||
$document = str_replace("{cover_zone}", $cover_zone, $document);
|
||
|
||
$path = "005_PTO/02_ЖСР";
|
||
$path2 = "005_PTO/00_ИД/$fileName";
|
||
$path = "$path/$fileName";
|
||
$path2 = "$path2/ЖСР-$fileName";
|
||
|
||
html_create($path, $document, "landscape");
|
||
html_create($path2, $document, "landscape");
|
||
|
||
if(!getisset("all")) {
|
||
if(!isset($redirect)) {
|
||
yonlendir(url("storage/documents/$path.pdf"));
|
||
}
|
||
|
||
} else {
|
||
$count++;
|
||
}
|
||
|
||
}
|
||
|
||
|
||
}
|
||
|
||
if(getisset("all")) {
|
||
echo $count;
|
||
}
|
||
|
||
|
||
|
||
?>
|
||
|