json); $tableName = "m_t_o_s"; $mtos = db($tableName); $mtos = $mtos->groupBy("line") //->where("line","NI-80-AH01JL-FA00.830") ->get(); $prefix = "📂 line-specification"; Log::debug("$prefix start " . simdi()); $k = 0; foreach($mtos AS $mto) { $tableRows1 = ""; $tableRows2 = ""; $tableRows3 = ""; $fileName = $mto->line; $string = $documentInfo->html; $string = pdf_html_content($string); $string .= ""; $c1 = $mto->line; $c2 = ""; $string = str_replace("{c1}", $c1, $string); $string = str_replace("{c2}", $c2, $string); $pipes = db($tableName) ->where("line", $mto->line) ->where(function($query) use($tableName) { $types = ['PIPE']; foreach($types AS $type) { $query->orWhere("$tableName.longdescription", "like", "%$type%"); } $types = ['ТРУБА']; foreach($types AS $type) { $query->orWhere("$tableName.description_ru", "like", "%$type%"); } }) ->get(); $others = db($tableName) ->where("line", $mto->line) ->where(function($query) { $types = ['flange', 'elbow', 'Tee', 'reducer']; foreach($types AS $type) { $query->orWhere("longdescription", "like", "%$type%"); } }) ->get(); $others2 = db($tableName) ->where("line", $mto->line) ->where(function($query) { $types = ['support', 'gasket', 'nuts', 'bolt']; foreach($types AS $type) { $query->orWhere("longdescription", "like", "%$type%"); } }) ->get(); foreach($pipes AS $pipe) { $weldLog = db("weld_logs") ->where("line_number", $pipe->line) ->where("element_code_1", $pipe->component_code_id) ->first(); $tableRow1 = " {$weldLog?->pose_no_1}
({$pipe->component_code_id}) {$pipe->description_ru} {$pipe->odmm_1}x{$pipe->thicknessmm_1} {$pipe->material} {$pipe->quantity} m "; $tableRows1 .= $tableRow1; } foreach($others AS $pipe) { $weldLog = db("weld_logs") ->where("line_number", $pipe->line) ->where("element_code_1", $pipe->component_code_id) ->first(); $dn1 = "{$pipe->dn_1}x{$pipe->dn_2}"; if($pipe->dn_2 == "") { $dn1 = $pipe->dn_1; } $tableRow2 = " {$weldLog?->pose_no_1}
({$pipe->component_code_id}) {$pipe->description_ru} $dn1 {$pipe->pn_mpa} {$pipe->material} {$pipe->quantity} шт "; $tableRows2 .= $tableRow2; } foreach($others2 AS $pipe) { $weldLog = db("weld_logs") ->where("line_number", $pipe->line) ->where("element_code_1", $pipe->component_code_id) ->first(); $dn1 = "{$pipe->dn_1}x{$pipe->dn_2}"; if($pipe->dn_2 == "") { $dn1 = $pipe->dn_1; } $tableRow3 = " {$weldLog?->pose_no_1}
({$pipe->component_code_id}) {$pipe->description_ru} {$pipe->material} {$pipe->quantity} шт "; $tableRows3 .= $tableRow3; } $string = str_replace("", $tableRows1, $string); $string = str_replace("", $tableRows2, $string); $string = str_replace("", $tableRows3, $string); $string = workPermitReplacer($string, null, $documentInfo); $path = $documentInfo->kid; //"005_PTO/08_Спецификация"; $path = "$path/$fileName"; html_create($path, $string); $k++; } echo $k; Log::debug("$prefix finish processed $k " . simdi()); ?>