diff --git a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php index 075609fda2a..935c2c3f400 100644 --- a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php @@ -262,9 +262,11 @@ class pdf_merou extends ModelePdfExpedition $pdf->SetFont('','', $default_font_size - 3); - //Creation des cases a cocher + // Check boxes + $pdf->SetDrawColor(120,120,120); $pdf->Rect(10+3, $curY, 3, 3); $pdf->Rect(20+3, $curY, 3, 3); + //Insertion de la reference du produit $pdf->SetXY(30, $curY); $pdf->SetFont('','B', $default_font_size - 3); @@ -522,7 +524,7 @@ class pdf_merou extends ModelePdfExpedition $origin_id = $object->origin_id; // Add list of linked elements - $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size, $hookmanager); + $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size - 1, $hookmanager); //$this->Code39($Xoff+43, $Yoff+1, $object->commande->ref,$ext = true, $cks = false, $w = 0.4, $h = 4, $wide = true); //Definition Emplacement du bloc Societe @@ -560,18 +562,18 @@ class pdf_merou extends ModelePdfExpedition $Yoff = $Yoff+7; $pdf->SetXY($blSocX-80,$blSocY+17); - $pdf->SetFont('','B', $default_font_size - 2); + $pdf->SetFont('','B', $default_font_size - 3); $pdf->SetTextColor(0,0,0); - $pdf->MultiCell(50, 8, $outputlangs->transnoentities("DateDelivery")." : " . dol_print_date($object->date_delivery,'day',false,$outputlangs,true), '', 'L'); + $pdf->MultiCell(50, 8, $outputlangs->transnoentities("DateDeliveryPlanned")." : " . dol_print_date($object->date_delivery,'day',false,$outputlangs,true), '', 'L'); $pdf->SetXY($blSocX-80,$blSocY+20); - $pdf->SetFont('','B', $default_font_size - 2); + $pdf->SetFont('','B', $default_font_size - 3); $pdf->SetTextColor(0,0,0); $pdf->MultiCell(50, 8, $outputlangs->transnoentities("TrackingNumber")." : " . $object->tracking_number, '', 'L'); // Deliverer $pdf->SetXY($blSocX-80,$blSocY+23); - $pdf->SetFont('','', $default_font_size - 2); + $pdf->SetFont('','', $default_font_size - 3); $pdf->SetTextColor(0,0,0); if (! empty($object->tracking_number)) @@ -592,7 +594,7 @@ class pdf_merou extends ModelePdfExpedition $label.=" : "; $label.=$object->tracking_url; } - $pdf->SetFont('','B', $default_font_size - 2); + $pdf->SetFont('','B', $default_font_size - 3); $pdf->writeHTMLCell(50, 8, '', '', $label, '', 'L'); } } @@ -603,9 +605,7 @@ class pdf_merou extends ModelePdfExpedition } - /**********************************/ - //Emplacement Informations Expediteur (My Company) - /**********************************/ + // Shipping company (My Company) $Yoff = $blSocY; $blExpX=$Xoff-20; $blW=52; @@ -623,7 +623,7 @@ class pdf_merou extends ModelePdfExpedition $result=$object->fetch_contact($arrayidcontact[0]); } - //Recipient name + // Recipient name // On peut utiliser le nom de la societe du contact if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { $thirdparty = $object->contact; @@ -631,15 +631,15 @@ class pdf_merou extends ModelePdfExpedition $thirdparty = $object->client; } - $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); + $carac_client_name=pdfBuildThirdpartyName($thirdparty, $outputlangs); $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,((!empty($object->contact))?$object->contact:null),$usecontact,'targetwithdetails'); $blDestX=$blExpX+55; - $blW=50; + $blW=54; $Yoff = $Ydef +1; - // Show recipient frame + // Show Recipient frame $pdf->SetFont('','B', $default_font_size - 3); $pdf->SetXY($blDestX,$Yoff-4); $pdf->MultiCell($blW,3, $outputlangs->transnoentities("Recipient"), 0, 'L'); @@ -653,8 +653,8 @@ class pdf_merou extends ModelePdfExpedition $posy = $pdf->getY(); // Show recipient information - $pdf->SetFont('','', $default_font_size - 1); - $pdf->SetXY($posx+2,$posy); + $pdf->SetFont('','', $default_font_size - 3); + $pdf->SetXY($blDestX,$posy); $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L'); } } diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 300132eb986..091f754a01c 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -71,6 +71,14 @@ class pdf_rouget extends ModelePdfExpedition $this->posxdesc=$this->marge_gauche+1; $this->posxqtyordered=$this->page_largeur - $this->marge_droite - 70; $this->posxqtytoship=$this->page_largeur - $this->marge_droite - 35; + $this->posxpicture=$this->posxqtyordered - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images + + if ($this->page_largeur < 210) // To work with US executive format + { + $this->posxpicture-=20; + $this->posxqtyordered-=20; + $this->posxqtytoship-=20; + } } /** @@ -103,6 +111,68 @@ class pdf_rouget extends ModelePdfExpedition $outputlangs->load("deliveries"); $outputlangs->load("sendings"); + $nblignes = count($object->lines); + + // Loop on each lines to detect if there is at least one image to show + $realpatharray=array(); + if (! empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE)) + { + $objphoto = new Product($this->db); + + for ($i = 0 ; $i < $nblignes ; $i++) + { + if (empty($object->lines[$i]->fk_product)) continue; + + $objphoto->fetch($object->lines[$i]->fk_product); + //var_dump($objphoto->ref);exit; + if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) + { + $pdir[0] = get_exdir($objphoto->id,2,0,0,$objphoto,'product') . $objphoto->id ."/photos/"; + $pdir[1] = get_exdir(0,0,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/'; + } + else + { + $pdir[0] = get_exdir(0,0,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/'; // default + $pdir[1] = get_exdir($objphoto->id,2,0,0,$objphoto,'product') . $objphoto->id ."/photos/"; // alternative + } + + $arephoto = false; + foreach ($pdir as $midir) + { + if (! $arephoto) + { + $dir = $conf->product->dir_output.'/'.$midir; + + foreach ($objphoto->liste_photos($dir,1) as $key => $obj) + { + if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo + { + if ($obj['photo_vignette']) + { + $filename= $obj['photo_vignette']; + } + else + { + $filename=$obj['photo']; + } + } + else + { + $filename=$obj['photo']; + } + + $realpath = $dir.$filename; + $arephoto = true; + } + } + } + + if ($realpath && $arephoto) $realpatharray[$i]=$realpath; + } + } + + if (count($realpatharray) == 0) $this->posxpicture=$this->posxqtyordered; + if ($conf->expedition->dir_output) { // Definition de $dir et $file @@ -140,8 +210,6 @@ class pdf_rouget extends ModelePdfExpedition global $action; $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks - $nblignes = count($object->lines); - $pdf=pdf_getInstance($this->format); $default_font_size = pdf_getPDFFontSize($outputlangs); $heightforinfotot = 0; // Height reserved to output the info and total part @@ -278,27 +346,98 @@ class pdf_rouget extends ModelePdfExpedition $curY = $tab_top + 7; $nexY = $tab_top + 7; - $num=count($object->lines); // Loop on each lines - for ($i = 0; $i < $num; $i++) + for ($i = 0; $i < $nblignes; $i++) { $curY = $nexY; $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage $pdf->SetTextColor(0,0,0); + // Define size of image if we need it + $imglinesize=array(); + if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]); + $pdf->setTopMargin($tab_top_newpage); $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. $pageposbefore=$pdf->getPage(); - // Description de la ligne produit - pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxqtyordered-10,3,$this->posxdesc,$curY,0,1); + $showpricebeforepagebreak=1; + $posYAfterImage=0; + $posYAfterDescription=0; + // We start with Photo of product line + if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur-($heightforfooter+$heightforfreetext+$heightforinfotot))) // If photo too high, we moved completely on new page + { + $pdf->AddPage('','',true); + if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + $pdf->setPage($pageposbefore+1); + + $curY = $tab_top_newpage; + $showpricebeforepagebreak=0; + } + + if (isset($imglinesize['width']) && isset($imglinesize['height'])) + { + $curX = $this->posxpicture-1; + $pdf->Image($realpatharray[$i], $curX + (($this->posxqtyordered-$this->posxpicture-$imglinesize['width'])/2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi + // $pdf->Image does not increase value return by getY, so we save it manually + $posYAfterImage=$curY+$imglinesize['height']; + } + + // Description of product line + $curX = $this->posxdesc-1; + + $pdf->startTransaction(); + // Description de la ligne produit + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc); + + $pageposafter=$pdf->getPage(); + if ($pageposafter > $pageposbefore) // There is a pagebreak + { + $pdf->rollbackTransaction(true); + $pageposafter=$pageposbefore; + //print $pageposafter.'-'.$pageposbefore;exit; + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. + pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc); + + $pageposafter=$pdf->getPage(); + $posyafter=$pdf->GetY(); + //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; + if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text + { + if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page + { + $pdf->AddPage('','',true); + if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + $pdf->setPage($pageposafter+1); + } + } + else + { + // We found a page break + $showpricebeforepagebreak=0; + } + } + else // No pagebreak + { + $pdf->commitTransaction(); + } + $posYAfterDescription=$pdf->GetY(); + $nexY = $pdf->GetY(); $pageposafter=$pdf->getPage(); + $pdf->setPage($pageposbefore); $pdf->setTopMargin($this->marge_haute); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. + // We suppose that a too long description or photo were moved completely on next page + if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { + $pdf->setPage($pageposafter); $curY = $tab_top_newpage; + } + // We suppose that a too long description is moved completely on next page if ($pageposafter > $pageposbefore) { $pdf->setPage($pageposafter); $curY = $tab_top_newpage; @@ -563,12 +702,15 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetTextColor(0,0,60); $pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefSending") ." : ".$object->ref, '', 'R'); - // Date Expedition - $posy+=4; - $pdf->SetXY($posx,$posy); - $pdf->SetTextColor(0,0,60); - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery,"daytext",false,$outputlangs,true), '', 'R'); - + // Date planned delivery + if (! empty($object->date_delivery)) + { + $posy+=4; + $pdf->SetXY($posx,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery,"day",false,$outputlangs,true), '', 'R'); + } + if (! empty($object->client->code_client)) { $posy+=4; diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 4e03a0c4237..8f5109eb4ec 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -395,7 +395,7 @@ class pdf_azur extends ModelePDFPropales $nexY = $tab_top + 7; // Loop on each lines - for ($i = 0 ; $i < $nblignes ; $i++) + for ($i = 0; $i < $nblignes; $i++) { $curY = $nexY; $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage