* SPDX-License-Identifier: AGPL-3.0-only ************************************/ require_once('include/utils/utils.php'); global $app_strings,$current_user,$theme,$adb,$table_prefix; $image_path = 'themes/'.$theme.'/images/'; $language = VteSession::get('authenticated_user_language'); $pdf_strings = return_module_language($language, "PDFMaker"); $id = $_REQUEST["return_id"]; $sql="SELECT CASE WHEN ".$table_prefix."_products.productid != '' THEN ".$table_prefix."_products.productname ELSE ".$table_prefix."_service.servicename END AS productname, ".$table_prefix."_inventoryproductrel.productid, ".$table_prefix."_inventoryproductrel.sequence_no, ".$table_prefix."_attachments.attachmentsid, name, path FROM ".$table_prefix."_inventoryproductrel LEFT JOIN ".$table_prefix."_seattachmentsrel ON ".$table_prefix."_seattachmentsrel.crmid=".$table_prefix."_inventoryproductrel.productid LEFT JOIN ".$table_prefix."_attachments ON ".$table_prefix."_attachments.attachmentsid=".$table_prefix."_seattachmentsrel.attachmentsid LEFT JOIN ".$table_prefix."_products ON ".$table_prefix."_products.productid=".$table_prefix."_inventoryproductrel.productid LEFT JOIN ".$table_prefix."_service ON ".$table_prefix."_service.serviceid=".$table_prefix."_inventoryproductrel.productid WHERE ".$table_prefix."_inventoryproductrel.id=? ORDER BY ".$table_prefix."_inventoryproductrel.sequence_no"; $res=$adb->pquery($sql,array($id)); $products=array(); while($row=$adb->fetchByAssoc($res)) { $products[$row["productid"]."#_#".$row["productname"]."#_#".$row["sequence_no"]][$row["attachmentsid"]]["path"]=$row["path"]; $products[$row["productid"]."#_#".$row["productname"]."#_#".$row["sequence_no"]][$row["attachmentsid"]]["name"]=$row["name"]; } $saved_sql="SELECT productid, sequence, attachmentid, width, height FROM ".$table_prefix."_pdfmaker_images WHERE crmid=?"; $saved_res=$adb->pquery($saved_sql,array($id)); $saved_products=array(); $saved_wh=array(); while($saved_row=$adb->fetchByAssoc($saved_res)){ $saved_products[$saved_row["productid"]."_".$saved_row["sequence"]] = $saved_row["attachmentid"]; $saved_wh[$saved_row["productid"]."_".$saved_row["sequence"]]["width"] = ($saved_row["width"]>0 ? $saved_row["width"] : ""); $saved_wh[$saved_row["productid"]."_".$saved_row["sequence"]]["height"] = ($saved_row["height"]>0 ? $saved_row["height"] : ""); } $imgHTML=""; foreach($products as $productnameid=>$data) { list($productid, $productname, $seq) = explode("#_#", $productnameid, 3); $prodImg=""; $i=0; $noCheck=' checked="checked" '; $width="100"; $height=""; foreach($data as $attid=>$images) { if($attid!="") { if($i==3) $prodImg.="
| ';
$imgHTML.=' | ';
$imgHTML.=$prodImg."