diff --git a/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php b/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php
index 2c1d647f659..ccdfee026d0 100644
--- a/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php
+++ b/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php
@@ -211,23 +211,18 @@ class pdf_eagle extends ModelePdfStockTransfer
// Loop on each lines to detect if there is at least one image to show
$realpatharray = array();
- if (!empty($conf->global->MAIN_GENERATE_STOCKTRANSFER_WITH_PICTURE))
- {
+ if (!empty($conf->global->MAIN_GENERATE_STOCKTRANSFER_WITH_PICTURE)) {
$objphoto = new Product($this->db);
- for ($i = 0; $i < $nblines; $i++)
- {
+ for ($i = 0; $i < $nblines; $i++) {
if (empty($object->lines[$i]->fk_product)) continue;
$objphoto = new Product($this->db);
$objphoto->fetch($object->lines[$i]->fk_product);
- if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
- {
+ if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) {
$pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/";
$dir = $conf->product->dir_output.'/'.$pdir;
- }
- else
- {
+ } else {
$pdir = get_exdir(0, 2, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/';
$dir = $conf->product->dir_output.'/'.$pdir;
}
@@ -237,17 +232,12 @@ class pdf_eagle extends ModelePdfStockTransfer
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'])
- {
+ if ($obj['photo_vignette']) {
$filename = $obj['photo_vignette'];
- }
- else
- {
+ } else {
$filename = $obj['photo'];
}
- }
- else
- {
+ } else {
$filename = $obj['photo'];
}
@@ -262,40 +252,32 @@ class pdf_eagle extends ModelePdfStockTransfer
if (count($realpatharray) == 0) $this->posxpicture = $this->posxweightvol;
- if(!empty($this->atLeastOneBatch)) {
+ if (!empty($this->atLeastOneBatch)) {
$this->posxpicture = $this->posxlot;
- if(!empty($conf->global->MAIN_GENERATE_STOCKTRANSFER_WITH_PICTURE)) $this->posxpicture -= (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
+ if (!empty($conf->global->MAIN_GENERATE_STOCKTRANSFER_WITH_PICTURE)) $this->posxpicture -= (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
}
- if ($conf->stocktransfer->dir_output)
- {
+ if ($conf->stocktransfer->dir_output) {
// Definition de $dir et $file
- if ($object->specimen)
- {
+ if ($object->specimen) {
$dir = $conf->stocktransfer->dir_output;
$file = $dir."/SPECIMEN.pdf";
- }
- else
- {
+ } else {
$stocktransferref = dol_sanitizeFileName($object->ref);
$dir = $conf->stocktransfer->dir_output.'/'.$object->element."/".$stocktransferref;
$file = $dir."/".$stocktransferref.".pdf";
}
- if (!file_exists($dir))
- {
- if (dol_mkdir($dir) < 0)
- {
+ if (!file_exists($dir)) {
+ if (dol_mkdir($dir) < 0) {
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return 0;
}
}
- if (file_exists($dir))
- {
+ if (file_exists($dir)) {
// Add pdfgeneration hook
- if (!is_object($hookmanager))
- {
+ if (!is_object($hookmanager)) {
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager = new HookManager($this->db);
}
@@ -315,15 +297,13 @@ class pdf_eagle extends ModelePdfStockTransfer
if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
$pdf->SetAutoPageBreak(1, 0);
- if (class_exists('TCPDF'))
- {
+ if (class_exists('TCPDF')) {
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
}
$pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File
- if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
- {
+ if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
$tplidx = $pdf->importPage(1);
}
@@ -359,11 +339,9 @@ class pdf_eagle extends ModelePdfStockTransfer
// Incoterm
$height_incoterms = 0;
- if ($conf->incoterm->enabled)
- {
+ if ($conf->incoterm->enabled) {
$desc_incoterms = $object->getIncotermsForPDF();
- if ($desc_incoterms)
- {
+ if ($desc_incoterms) {
$tab_top = 88;
$pdf->SetFont('', '', $default_font_size - 1);
@@ -380,8 +358,7 @@ class pdf_eagle extends ModelePdfStockTransfer
}
}
- if (!empty($object->note_public) || !empty($object->tracking_number))
- {
+ if (!empty($object->note_public) || !empty($object->tracking_number)) {
$tab_top = 88 + $height_incoterms;
$tab_top_alt = $tab_top;
@@ -390,24 +367,20 @@ class pdf_eagle extends ModelePdfStockTransfer
//$tab_top_alt += 1;
// Tracking number
- if (!empty($object->tracking_number))
- {
+ if (!empty($object->tracking_number)) {
$pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities("TrackingNumber")." : ".$object->tracking_number, 0, 1, false, true, 'L');
$tab_top_alt = $pdf->GetY();
$object->getUrlTrackingStatus($object->tracking_number);
- if (!empty($object->tracking_url))
- {
- if ($object->shipping_method_id > 0)
- {
+ if (!empty($object->tracking_url)) {
+ if ($object->shipping_method_id > 0) {
// Get code using getLabelFromKey
$code = $outputlangs->getLabelFromKey($this->db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code');
$label = '';
if ($object->tracking_url != $object->tracking_number) $label .= $outputlangs->trans("LinkToTrackYourPackage")."
";
$label .= $outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code));
//var_dump($object->tracking_url != $object->tracking_number);exit;
- if ($object->tracking_url != $object->tracking_number)
- {
+ if ($object->tracking_url != $object->tracking_number) {
$label .= " : ";
$label .= $object->tracking_url;
}
@@ -420,8 +393,7 @@ class pdf_eagle extends ModelePdfStockTransfer
}
// Notes
- if (!empty($object->note_public))
- {
+ if (!empty($object->note_public)) {
$pdf->SetFont('', '', $default_font_size - 1); // Dans boucle pour gerer multi-page
$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1);
}
@@ -435,9 +407,7 @@ class pdf_eagle extends ModelePdfStockTransfer
$tab_height = $tab_height - $height_note;
$tab_top = $nexY + 6;
- }
- else
- {
+ } else {
$height_note = 0;
}
@@ -447,8 +417,7 @@ class pdf_eagle extends ModelePdfStockTransfer
$TCacheEntrepots=array();
// Loop on each lines
- for ($i = 0; $i < $nblines; $i++)
- {
+ for ($i = 0; $i < $nblines; $i++) {
$curY = $nexY;
$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
$pdf->SetTextColor(0, 0, 0);
@@ -466,8 +435,7 @@ class pdf_eagle extends ModelePdfStockTransfer
$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
- {
+ 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);
@@ -478,12 +446,10 @@ class pdf_eagle extends ModelePdfStockTransfer
// Allows data in the first page if description is long enough to break in multiples pages
if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
$showpricebeforepagebreak = 1;
- else
- $showpricebeforepagebreak = 0;
+ else $showpricebeforepagebreak = 0;
}
- if (isset($imglinesize['width']) && isset($imglinesize['height']))
- {
+ if (isset($imglinesize['width']) && isset($imglinesize['height'])) {
$curX = $this->posxpicture - 1;
$pdf->Image($realpatharray[$i], $curX + (($this->posxqty - $this->posxweightvol - $imglinesize['width']
+ (!empty($conf->global->STOCKTRANSFER_PDF_HIDE_WEIGHT_AND_VOLUME) ? (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) : 0)) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
@@ -495,7 +461,7 @@ class pdf_eagle extends ModelePdfStockTransfer
$curX = $this->posxdesc - 1;
$pdf->startTransaction();
- if(method_exists($object->lines[$i], 'fetch_product')) {
+ if (method_exists($object->lines[$i], 'fetch_product')) {
$object->lines[$i]->fetch_product();
$object->lines[$i]->label = $object->lines[$i]->product->label;
$object->lines[$i]->description = $object->lines[$i]->product->description;
@@ -514,8 +480,7 @@ class pdf_eagle extends ModelePdfStockTransfer
pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
$pageposafter = $pdf->getPage();
- if ($pageposafter > $pageposbefore) // There is a pagebreak
- {
+ if ($pageposafter > $pageposbefore) { // There is a pagebreak
$pdf->rollbackTransaction(true);
$pageposafter = $pageposbefore;
//print $pageposafter.'-'.$pageposbefore;exit;
@@ -525,28 +490,22 @@ class pdf_eagle extends ModelePdfStockTransfer
$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 == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page
- {
+ if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text
+ if ($i == ($nblines - 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
- {
+ } else {
// We found a page break
// Allows data in the first page if description is long enough to break in multiples pages
if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
$showpricebeforepagebreak = 1;
- else
- $showpricebeforepagebreak = 0;
+ else $showpricebeforepagebreak = 0;
}
- }
- else // No pagebreak
+ } else // No pagebreak
{
$pdf->commitTransaction();
}
@@ -572,7 +531,7 @@ class pdf_eagle extends ModelePdfStockTransfer
$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
// Lot / série
- if(!empty($conf->productbatch->enabled)) {
+ if (!empty($conf->productbatch->enabled)) {
$pdf->SetXY($this->posxlot, $curY);
$pdf->MultiCell(($this->posxweightvol - $this->posxlot), 3, $object->lines[$i]->batch, '', 'C');
}
@@ -580,19 +539,16 @@ class pdf_eagle extends ModelePdfStockTransfer
// Weight
$pdf->SetXY($this->posxweightvol, $curY);
$weighttxt = '';
- if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight)
- {
+ if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight) {
$weighttxt = round($object->lines[$i]->weight * $object->lines[$i]->qty, 5).' '.measuringUnitString(0, "weight", $object->lines[$i]->weight_units, 1);
}
$voltxt = '';
- if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume)
- {
+ if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume) {
$voltxt = round($object->lines[$i]->volume * $object->lines[$i]->qty, 5).' '.measuringUnitString(0, "volume", $object->lines[$i]->volume_units ? $object->lines[$i]->volume_units : 0, 1);
}
// Weight
- if (empty($conf->global->STOCKTRANSFER_PDF_HIDE_WEIGHT_AND_VOLUME))
- {
+ if (empty($conf->global->STOCKTRANSFER_PDF_HIDE_WEIGHT_AND_VOLUME)) {
$pdf->writeHTMLCell($this->posxqty - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt) ? '
' : '').$voltxt, 0, 0, false, true, 'C');
//$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?'
':'').$voltxt,'','C');
}
@@ -604,7 +560,7 @@ class pdf_eagle extends ModelePdfStockTransfer
// Warehouse source
$wh_source = new Entrepot($db);
- if(!empty($TCacheEntrepots[$object->lines[$i]->fk_warehouse_source])) $wh_source = $TCacheEntrepots[$object->lines[$i]->fk_warehouse_source];
+ if (!empty($TCacheEntrepots[$object->lines[$i]->fk_warehouse_source])) $wh_source = $TCacheEntrepots[$object->lines[$i]->fk_warehouse_source];
else {
$wh_source->fetch($object->lines[$i]->fk_warehouse_source);
$TCacheEntrepots[$object->lines[$i]->fk_warehouse_source] = $wh_source;
@@ -614,7 +570,7 @@ class pdf_eagle extends ModelePdfStockTransfer
// Warehouse destination
$wh_destination = new Entrepot($db);
- if(!empty($TCacheEntrepots[$object->lines[$i]->fk_warehouse_destination])) $wh_destination = $TCacheEntrepots[$object->lines[$i]->fk_warehouse_destination];
+ if (!empty($TCacheEntrepots[$object->lines[$i]->fk_warehouse_destination])) $wh_destination = $TCacheEntrepots[$object->lines[$i]->fk_warehouse_destination];
else {
$wh_destination->fetch($object->lines[$i]->fk_warehouse_destination);
$TCacheEntrepots[$object->lines[$i]->fk_warehouse_destination] = $wh_destination;
@@ -622,8 +578,7 @@ class pdf_eagle extends ModelePdfStockTransfer
$pdf->SetXY($this->posxwarehousedestination, $curY);
$pdf->MultiCell(($this->posxpuht - $this->posxwarehousedestination), 3, $wh_destination->ref.(!empty($wh_destination->lieu) ? ' - '.$wh_destination->lieu : ''), '', 'C');
- if (!empty($conf->global->STOCKTRANSFER_PDF_DISPLAY_AMOUNT_HT))
- {
+ if (!empty($conf->global->STOCKTRANSFER_PDF_DISPLAY_AMOUNT_HT)) {
$pdf->SetXY($this->posxpuht, $curY);
$pdf->MultiCell(($this->posxtotalht - $this->posxpuht - 1), 3, price($object->lines[$i]->subprice, 0, $outputlangs), '', 'R');
@@ -635,8 +590,7 @@ class pdf_eagle extends ModelePdfStockTransfer
if ($weighttxt && $voltxt) $nexY += 2;
// Add line
- if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
- {
+ if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
$pdf->setPage($pageposafter);
$pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
//$pdf->SetDrawColor(190,190,200);
@@ -645,15 +599,11 @@ class pdf_eagle extends ModelePdfStockTransfer
}
// Detect if some page were added automatically and output _tableau for past pages
- while ($pagenb < $pageposafter)
- {
+ while ($pagenb < $pageposafter) {
$pdf->setPage($pagenb);
- if ($pagenb == 1)
- {
+ if ($pagenb == 1) {
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
- }
- else
- {
+ } else {
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
}
$this->_pagefoot($pdf, $object, $outputlangs, 1);
@@ -662,14 +612,10 @@ class pdf_eagle extends ModelePdfStockTransfer
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
}
- if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
- {
- if ($pagenb == 1)
- {
+ if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
+ if ($pagenb == 1) {
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
- }
- else
- {
+ } else {
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
}
$this->_pagefoot($pdf, $object, $outputlangs, 1);
@@ -682,13 +628,10 @@ class pdf_eagle extends ModelePdfStockTransfer
}
// Show square
- if ($pagenb == 1)
- {
+ if ($pagenb == 1) {
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
- }
- else
- {
+ } else {
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
}
@@ -709,8 +652,7 @@ class pdf_eagle extends ModelePdfStockTransfer
$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
global $action;
$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
- if ($reshook < 0)
- {
+ if ($reshook < 0) {
$this->error = $hookmanager->error;
$this->errors = $hookmanager->errors;
}
@@ -721,15 +663,11 @@ class pdf_eagle extends ModelePdfStockTransfer
$this->result = array('fullpath'=>$file);
return 1; // No error
- }
- else
- {
+ } else {
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return 0;
}
- }
- else
- {
+ } else {
$this->error = $langs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR");
return 0;
}
@@ -780,13 +718,12 @@ class pdf_eagle extends ModelePdfStockTransfer
$totalWeight = $tmparray['weight'];
$totalVolume = $tmparray['volume'];
$totalQty = 0;
- if(!empty($object->lines))
- foreach ($object->lines as $line) {
- $totalQty+=$line->qty;
- }
+ if (!empty($object->lines))
+ foreach ($object->lines as $line) {
+ $totalQty+=$line->qty;
+ }
// Set trueVolume and volume_units not currently stored into database
- if ($object->trueWidth && $object->trueHeight && $object->trueDepth)
- {
+ if ($object->trueWidth && $object->trueHeight && $object->trueDepth) {
$object->trueVolume = price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0);
$object->volume_units = $object->size_units * 3;
}
@@ -800,14 +737,12 @@ class pdf_eagle extends ModelePdfStockTransfer
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1);
- if (empty($conf->global->STOCKTRANSFER_PDF_HIDE_ORDERED))
- {
+ if (empty($conf->global->STOCKTRANSFER_PDF_HIDE_ORDERED)) {
$pdf->SetXY($this->posxqty, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($this->posxwarehousesource - $this->posxqty, $tab2_hl, $totalQty, 0, 'C', 1);
}
- if (!empty($conf->global->STOCKTRANSFER_PDF_DISPLAY_AMOUNT_HT))
- {
+ if (!empty($conf->global->STOCKTRANSFER_PDF_DISPLAY_AMOUNT_HT)) {
$pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1);
@@ -815,18 +750,15 @@ class pdf_eagle extends ModelePdfStockTransfer
$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl, price($object->total_ht, 0, $outputlangs), 0, 'C', 1);
}
- if (empty($conf->global->STOCKTRANSFER_PDF_HIDE_WEIGHT_AND_VOLUME))
- {
+ if (empty($conf->global->STOCKTRANSFER_PDF_HIDE_WEIGHT_AND_VOLUME)) {
// Total Weight
- if ($totalWeighttoshow)
- {
+ if ($totalWeighttoshow) {
$pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell(($this->posxqty - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0, 'C', 1);
$index++;
}
- if ($totalVolumetoshow)
- {
+ if ($totalVolumetoshow) {
$pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell(($this->posxqty - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0, 'C', 1);
@@ -873,15 +805,14 @@ class pdf_eagle extends ModelePdfStockTransfer
$pdf->SetDrawColor(128, 128, 128);
$pdf->SetFont('', '', $default_font_size - 1);
- if (empty($hidetop))
- {
+ if (empty($hidetop)) {
$pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
$pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
$pdf->MultiCell($this->posxlot - $this->posxdesc, 2, $outputlangs->transnoentities("Description"), '', 'L');
}
- if(!empty($conf->productbatch->enabled) && $this->atLeastOneBatch) {
+ if (!empty($conf->productbatch->enabled) && $this->atLeastOneBatch) {
$pdf->line($this->posxlot - 1, $tab_top, $this->posxlot - 1, $tab_top + $tab_height);
if (empty($hidetop)) {
$pdf->SetXY($this->posxlot, $tab_top + 1);
@@ -889,7 +820,7 @@ class pdf_eagle extends ModelePdfStockTransfer
}
}
- if(empty($conf->global->STOCKTRANSFER_PDF_HIDE_WEIGHT_AND_VOLUME)) {
+ if (empty($conf->global->STOCKTRANSFER_PDF_HIDE_WEIGHT_AND_VOLUME)) {
$pdf->line($this->posxweightvol - 1, $tab_top, $this->posxweightvol - 1, $tab_top + $tab_height);
if (empty($hidetop)) {
$pdf->SetXY($this->posxweightvol - 1, $tab_top + 1);
@@ -898,23 +829,20 @@ class pdf_eagle extends ModelePdfStockTransfer
}
$pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
- if (empty($hidetop))
- {
+ if (empty($hidetop)) {
$pdf->SetXY($this->posxqty - 1, $tab_top + 1);
$pdf->MultiCell(($this->posxwarehousesource - $this->posxqty), 2, $outputlangs->transnoentities("Qty"), '', 'C');
}
$pdf->line($this->posxwarehousesource - 1, $tab_top, $this->posxwarehousesource - 1, $tab_top + $tab_height);
- if (empty($hidetop))
- {
+ if (empty($hidetop)) {
$pdf->SetXY($this->posxwarehousesource - 1, $tab_top + 1);
$pdf->MultiCell(($this->posxwarehousedestination - $this->posxwarehousesource), 2, $outputlangs->transnoentities("WarehouseSource"), '', 'C');
}
$pdf->line($this->posxwarehousedestination - 1, $tab_top, $this->posxwarehousedestination - 1, $tab_top + $tab_height);
- if (empty($hidetop))
- {
+ if (empty($hidetop)) {
$pdf->SetXY($this->posxwarehousedestination-2.5, $tab_top + 1);
$pdf->MultiCell(($this->posxpuht - $this->posxwarehousedestination+4), 2, $outputlangs->transnoentities("WarehouseTarget"), '', 'C');
}
@@ -936,22 +864,22 @@ class pdf_eagle extends ModelePdfStockTransfer
}*/
}
- function atLeastOneBatch($object) {
+ function atLeastOneBatch($object)
+ {
global $conf;
$atLeastOneBatch = false;
- if(empty($conf->productbatch->enabled)) return false;
+ if (empty($conf->productbatch->enabled)) return false;
foreach ($object->lines as $line) {
- if(!empty($line->batch)) {
+ if (!empty($line->batch)) {
return true;
}
}
return false;
-
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
@@ -975,8 +903,7 @@ class pdf_eagle extends ModelePdfStockTransfer
pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
// Show Draft Watermark
- if ($object->statut == 0 && (!empty($conf->global->SHIPPING_DRAFT_WATERMARK)))
- {
+ if ($object->statut == 0 && (!empty($conf->global->SHIPPING_DRAFT_WATERMARK))) {
pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SHIPPING_DRAFT_WATERMARK);
}
@@ -993,47 +920,36 @@ class pdf_eagle extends ModelePdfStockTransfer
// Logo
$logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
- if ($this->emetteur->logo)
- {
- if (is_readable($logo))
- {
+ if ($this->emetteur->logo) {
+ if (is_readable($logo)) {
$height = pdf_getHeightForLogo($logo);
$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
- }
- else
- {
+ } else {
$pdf->SetTextColor(200, 0, 0);
$pdf->SetFont('', 'B', $default_font_size - 2);
$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
}
- }
- else
- {
+ } else {
$text = $this->emetteur->name;
$pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
}
// Show barcode
- if (!empty($conf->barcode->enabled))
- {
+ if (!empty($conf->barcode->enabled)) {
$posx = 105;
- }
- else
- {
+ } else {
$posx = $this->marge_gauche + 3;
}
//$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30);
- if (!empty($conf->barcode->enabled))
- {
+ if (!empty($conf->barcode->enabled)) {
// TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref
//$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
//$pdf->Image($logo,10, 5, 0, 24);
}
$pdf->SetDrawColor(128, 128, 128);
- if (!empty($conf->barcode->enabled))
- {
+ if (!empty($conf->barcode->enabled)) {
// TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref
//$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
//$pdf->Image($logo,10, 5, 0, 24);
@@ -1058,8 +974,7 @@ class pdf_eagle extends ModelePdfStockTransfer
$pdf->MultiCell($w, 4, $outputlangs->transnoentities("Ref")." : ".$object->ref, '', 'R');
// Date prévue depart
- if (!empty($object->date_prevue_depart))
- {
+ if (!empty($object->date_prevue_depart)) {
$posy += 4;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
@@ -1067,8 +982,7 @@ class pdf_eagle extends ModelePdfStockTransfer
}
// Date prévue arrivée
- if (!empty($object->date_prevue_arrivee))
- {
+ if (!empty($object->date_prevue_arrivee)) {
$posy += 4;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
@@ -1076,8 +990,7 @@ class pdf_eagle extends ModelePdfStockTransfer
}
// Date reelle depart
- if (!empty($object->date_reelle_depart))
- {
+ if (!empty($object->date_reelle_depart)) {
$posy += 4;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
@@ -1085,16 +998,14 @@ class pdf_eagle extends ModelePdfStockTransfer
}
// Date reelle arrivée
- if (!empty($object->date_reelle_arrivee))
- {
+ if (!empty($object->date_reelle_arrivee)) {
$posy += 4;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
$pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateReelleArrivee")." : ".dol_print_date($object->date_reelle_arrivee, "day", false, $outputlangs, true), '', 'R');
}
- if (!empty($object->thirdparty->code_client))
- {
+ if (!empty($object->thirdparty->code_client)) {
$posy += 4;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
@@ -1110,15 +1021,13 @@ class pdf_eagle extends ModelePdfStockTransfer
$origin_id = $object->origin_id;
// TODO move to external function
- if (!empty($conf->$origin->enabled)) // commonly $origin='commande'
- {
+ if (!empty($conf->$origin->enabled)) { // commonly $origin='commande'
$outputlangs->load('orders');
$classname = ucfirst($origin);
$linkedobject = new $classname($this->db);
$result = $linkedobject->fetch($origin_id);
- if ($result >= 0)
- {
+ if ($result >= 0) {
//$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
$pdf->SetFont('', '', $default_font_size - 2);
@@ -1133,8 +1042,7 @@ class pdf_eagle extends ModelePdfStockTransfer
}
}
- if ($showaddress)
- {
+ if ($showaddress) {
// Sender properties
$carac_emetteur = '';
// Add internal contact of origin element if defined
@@ -1142,8 +1050,7 @@ class pdf_eagle extends ModelePdfStockTransfer
$arrayidcontact = $object->getIdContact('external', 'STFROM');
$usecontact = false;
- if (count($arrayidcontact) > 0)
- {
+ if (count($arrayidcontact) > 0) {
/*$object->fetch_user(reset($arrayidcontact));
$carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";*/
$usecontact = true;
@@ -1153,9 +1060,9 @@ class pdf_eagle extends ModelePdfStockTransfer
if ($usecontact) $thirdparty = $object->contact;
else $thirdparty = $this->emetteur;
- if(!empty($thirdparty)) $carac_emetteur_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
+ if (!empty($thirdparty)) $carac_emetteur_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
- if($usecontact) $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, $object->contact, 1, 'targetwithdetails', $object);
+ if ($usecontact) $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, $object->contact, 1, 'targetwithdetails', $object);
else $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
// Show sender
@@ -1192,8 +1099,7 @@ class pdf_eagle extends ModelePdfStockTransfer
// If SHIPPING contact defined, we use it
$usecontact = false;
$arrayidcontact = $object->getIdContact('external', 'STDEST');
- if (count($arrayidcontact) > 0)
- {
+ if (count($arrayidcontact) > 0) {
$usecontact = true;
$result = $object->fetch_contact($arrayidcontact[0]);
}
@@ -1206,7 +1112,7 @@ class pdf_eagle extends ModelePdfStockTransfer
$thirdparty = $object->thirdparty;
}
- if(!empty($thirdparty)) $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
+ if (!empty($thirdparty)) $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact : null), $usecontact, 'targetwithdetails', $object);
diff --git a/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php b/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php
index 9ba4d869ec0..accbf4e0dbb 100644
--- a/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php
+++ b/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php
@@ -219,49 +219,35 @@ class pdf_eagle_proforma extends ModelePDFCommandes
// Loop on each lines to detect if there is at least one image to show
$realpatharray = array();
$this->atleastonephoto = false;
- if (!empty($conf->global->MAIN_GENERATE_ORDERS_WITH_PICTURE))
- {
+ if (!empty($conf->global->MAIN_GENERATE_ORDERS_WITH_PICTURE)) {
$objphoto = new Product($this->db);
- for ($i = 0; $i < $nblines; $i++)
- {
+ for ($i = 0; $i < $nblines; $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))
- {
+ 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
- {
+ } 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)
- {
+ 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'])
- {
+ 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
- {
+ } else {
$filename = $obj['photo'];
}
- }
- else
- {
+ } else {
$filename = $obj['photo'];
}
@@ -278,39 +264,31 @@ class pdf_eagle_proforma extends ModelePDFCommandes
- if ($conf->stocktransfer->dir_output)
- {
+ if ($conf->stocktransfer->dir_output) {
$object->fetch_thirdparty();
$deja_regle = 0;
// Definition of $dir and $file
- if ($object->specimen)
- {
+ if ($object->specimen) {
$dir = $conf->stocktransfer->multidir_output[$conf->entity];
$file = $dir."/SPECIMEN.pdf";
- }
- else
- {
+ } else {
$objectref = dol_sanitizeFileName($object->ref);
$dir = $conf->stocktransfer->multidir_output[$conf->entity]."/".$object->element."/".$objectref;
$file = $dir."/".$objectref.".pdf";
}
- if (!file_exists($dir))
- {
- if (dol_mkdir($dir) < 0)
- {
+ if (!file_exists($dir)) {
+ if (dol_mkdir($dir) < 0) {
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return 0;
}
}
- if (file_exists($dir))
- {
+ if (file_exists($dir)) {
// Add pdfgeneration hook
- if (!is_object($hookmanager))
- {
+ if (!is_object($hookmanager)) {
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager = new HookManager($this->db);
}
@@ -328,15 +306,13 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 12 : 22); // Height reserved to output the footer (value include bottom margin)
- if (class_exists('TCPDF'))
- {
+ if (class_exists('TCPDF')) {
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
}
$pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File
- if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
- {
+ if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
$pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
$tplidx = $pdf->importPage(1);
}
@@ -377,11 +353,9 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
// Incoterm
- if ($conf->incoterm->enabled)
- {
+ if ($conf->incoterm->enabled) {
$desc_incoterms = $object->getIncotermsForPDF();
- if ($desc_incoterms)
- {
+ if ($desc_incoterms) {
$tab_top -= 2;
$pdf->SetFont('', '', $default_font_size - 1);
@@ -399,11 +373,9 @@ class pdf_eagle_proforma extends ModelePDFCommandes
// Displays notes
$notetoshow = empty($object->note_public) ? '' : $object->note_public;
- if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
- {
+ if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) {
// Get first sale rep
- if (is_object($object->thirdparty))
- {
+ if (is_object($object->thirdparty)) {
$salereparray = $object->thirdparty->getSalesRepresentatives($user);
$salerepobj = new User($this->db);
$salerepobj->fetch($salereparray[0]['id']);
@@ -413,14 +385,12 @@ class pdf_eagle_proforma extends ModelePDFCommandes
// Extrafields in note
$extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
- if (!empty($extranote))
- {
+ if (!empty($extranote)) {
$notetoshow = dol_concatdesc($notetoshow, $extranote);
}
$pagenb = $pdf->getPage();
- if ($notetoshow)
- {
+ if ($notetoshow) {
$tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
$pageposbeforenote = $pagenb;
@@ -439,8 +409,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$pageposafternote = $pdf->getPage();
$posyafter = $pdf->GetY();
- if ($pageposafternote > $pageposbeforenote)
- {
+ if ($pageposafternote > $pageposbeforenote) {
$pdf->rollbackTransaction(true);
// prepare pages to receive notes
@@ -464,8 +433,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$posyafter = $pdf->GetY();
- if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) // There is no space left for total+free text
- {
+ if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { // There is no space left for total+free text
$pdf->AddPage('', '', true);
$pagenb++;
$pageposafternote++;
@@ -488,8 +456,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes
if ($i > $pageposbeforenote) {
$height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
$pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
- }
- else {
+ } else {
$height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
$pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
}
@@ -507,8 +474,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
$height_note = $posyafter - $tab_top_newpage;
$pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
- }
- else // No pagebreak
+ } else // No pagebreak
{
$pdf->commitTransaction();
$posyafter = $pdf->GetY();
@@ -516,8 +482,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
- if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20)))
- {
+ if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
// not enough space, need to add page
$pdf->AddPage('', '', true);
$pagenb++;
@@ -532,9 +497,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$tab_height = $tab_height - $height_note;
$tab_top = $posyafter + 6;
- }
- else
- {
+ } else {
$height_note = 0;
}
@@ -552,8 +515,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes
// Loop on each lines
$pageposbeforeprintlines = $pdf->getPage();
$pagenb = $pageposbeforeprintlines;
- for ($i = 0; $i < $nblines; $i++)
- {
+ for ($i = 0; $i < $nblines; $i++) {
$curY = $nexY;
$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
$pdf->SetTextColor(0, 0, 0);
@@ -570,11 +532,9 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$showpricebeforepagebreak = 1;
$posYAfterImage = 0;
- if ($this->getColumnStatus('photo'))
- {
+ if ($this->getColumnStatus('photo')) {
// 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
- {
+ 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);
$pdf->setPage($pageposbefore + 1);
@@ -584,23 +544,20 @@ class pdf_eagle_proforma extends ModelePDFCommandes
// Allows data in the first page if description is long enough to break in multiples pages
if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
$showpricebeforepagebreak = 1;
- else
- $showpricebeforepagebreak = 0;
+ else $showpricebeforepagebreak = 0;
}
- if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height']))
- {
+ if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) {
$pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $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'];
}
}
- if ($this->getColumnStatus('desc'))
- {
+ if ($this->getColumnStatus('desc')) {
$pdf->startTransaction();
- if(method_exists($object->lines[$i], 'fetch_product')) {
+ if (method_exists($object->lines[$i], 'fetch_product')) {
$object->lines[$i]->fetch_product();
$object->lines[$i]->label = $object->lines[$i]->product->label;
$object->lines[$i]->description = $object->lines[$i]->product->description;
@@ -610,8 +567,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
$pageposafter = $pdf->getPage();
- if ($pageposafter > $pageposbefore) // There is a pagebreak
- {
+ if ($pageposafter > $pageposbefore) { // There is a pagebreak
$pdf->rollbackTransaction(true);
$pageposafter = $pageposbefore;
//print $pageposafter.'-'.$pageposbefore;exit;
@@ -620,27 +576,21 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
$pageposafter = $pdf->getPage();
$posyafter = $pdf->GetY();
- if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text
- {
- if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page
- {
+ if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text
+ if ($i == ($nblines - 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
- {
+ } else {
// We found a page break
// Allows data in the first page if description is long enough to break in multiples pages
if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
$showpricebeforepagebreak = 1;
- else
- $showpricebeforepagebreak = 0;
+ else $showpricebeforepagebreak = 0;
}
- }
- else // No pagebreak
+ } else // No pagebreak
{
$pdf->commitTransaction();
}
@@ -665,16 +615,14 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font
// VAT Rate
- if ($this->getColumnStatus('vat'))
- {
+ if ($this->getColumnStatus('vat')) {
$vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
$this->printStdColumnContent($pdf, $curY, 'vat', $vat_rate);
$nexY = max($pdf->GetY(), $nexY);
}
// Unit price before discount
- if ($this->getColumnStatus('subprice'))
- {
+ if ($this->getColumnStatus('subprice')) {
$pmp = $object->lines[$i]->pmp;
$this->printStdColumnContent($pdf, $curY, 'subprice', price($pmp));
$nexY = max($pdf->GetY(), $nexY);
@@ -682,8 +630,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes
// Quantity
// Enough for 6 chars
- if ($this->getColumnStatus('qty'))
- {
+ if ($this->getColumnStatus('qty')) {
$qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
$this->printStdColumnContent($pdf, $curY, 'qty', $qty);
$nexY = max($pdf->GetY(), $nexY);
@@ -691,24 +638,21 @@ class pdf_eagle_proforma extends ModelePDFCommandes
// Unit
- if ($this->getColumnStatus('unit'))
- {
+ if ($this->getColumnStatus('unit')) {
$unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
$this->printStdColumnContent($pdf, $curY, 'unit', $unit);
$nexY = max($pdf->GetY(), $nexY);
}
// Discount on line
- if ($this->getColumnStatus('discount') && $object->lines[$i]->remise_percent)
- {
+ if ($this->getColumnStatus('discount') && $object->lines[$i]->remise_percent) {
$remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
$this->printStdColumnContent($pdf, $curY, 'discount', $remise_percent);
$nexY = max($pdf->GetY(), $nexY);
}
// Total HT line
- if ($this->getColumnStatus('totalexcltax'))
- {
+ if ($this->getColumnStatus('totalexcltax')) {
$pmp_qty = $pmp * $object->lines[$i]->qty;
$this->printStdColumnContent($pdf, $curY, 'totalexcltax', price($pmp_qty));
$nexY = max($pdf->GetY(), $nexY);
@@ -717,8 +661,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes
// Extrafields
if (!empty($object->lines[$i]->array_options)) {
foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
- if ($this->getColumnStatus($extrafieldColKey))
- {
+ if ($this->getColumnStatus($extrafieldColKey)) {
$extrafieldValue = $this->getExtrafieldContent($object->lines[$i], $extrafieldColKey);
$this->printStdColumnContent($pdf, $curY, $extrafieldColKey, $extrafieldValue);
$nexY = max($pdf->GetY(), $nexY);
@@ -757,8 +700,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes
// Retrieve type from database for backward compatibility with old records
if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
- && (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax
- {
+ && (!empty($localtax1_rate) || !empty($localtax2_rate))) { // and there is local tax
$localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
$localtax1_type = $localtaxtmp_array[0];
$localtax2_type = $localtaxtmp_array[2];
@@ -775,8 +717,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$this->tva[$vatrate] += $tvaligne;
// Add line
- if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
- {
+ if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
$pdf->setPage($pageposafter);
$pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
//$pdf->SetDrawColor(190,190,200);
@@ -786,15 +727,11 @@ class pdf_eagle_proforma extends ModelePDFCommandes
// Detect if some page were added automatically and output _tableau for past pages
- while ($pagenb < $pageposafter)
- {
+ while ($pagenb < $pageposafter) {
$pdf->setPage($pagenb);
- if ($pagenb == $pageposbeforeprintlines)
- {
+ if ($pagenb == $pageposbeforeprintlines) {
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
- }
- else
- {
+ } else {
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
}
$this->_pagefoot($pdf, $object, $outputlangs, 1);
@@ -803,14 +740,10 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
}
- if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
- {
- if ($pagenb == $pageposafter)
- {
+ if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
+ if ($pagenb == $pageposafter) {
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
- }
- else
- {
+ } else {
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
}
$this->_pagefoot($pdf, $object, $outputlangs, 1);
@@ -825,8 +758,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes
// Show square
if ($pagenb == $pageposbeforeprintlines)
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code);
- else
- $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
+ else $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
// Affiche zone infos
@@ -857,8 +789,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
global $action;
$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
- if ($reshook < 0)
- {
+ if ($reshook < 0) {
$this->error = $hookmanager->error;
$this->errors = $hookmanager->errors;
}
@@ -869,15 +800,11 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$this->result = array('fullpath'=>$file);
return 1; // No error
- }
- else
- {
+ } else {
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return 0;
}
- }
- else
- {
+ } else {
$this->error = $langs->transnoentities("ErrorConstantNotDefined", "STOCKTRANSFER_OUTPUTDIR");
return 0;
}
@@ -913,8 +840,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$pdf->SetFont('', '', $default_font_size - 1);
// If France, show VAT mention if not applicable
- if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj))
- {
+ if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj)) {
$pdf->SetFont('', 'B', $default_font_size - 2);
$pdf->SetXY($this->marge_gauche, $posy);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
@@ -925,8 +851,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$posxval = 52;
// Show payments conditions
- if ($object->cond_reglement_code || $object->cond_reglement)
- {
+ if ($object->cond_reglement_code || $object->cond_reglement) {
$pdf->SetFont('', 'B', $default_font_size - 2);
$pdf->SetXY($this->marge_gauche, $posy);
$titre = $outputlangs->transnoentities("PaymentConditions").':';
@@ -959,18 +884,17 @@ class pdf_eagle_proforma extends ModelePDFCommandes
/* TODO
else if (! empty($object->availability_code))
{
- $pdf->SetXY($this->marge_gauche, $posy);
- $pdf->SetTextColor(200,0,0);
- $pdf->SetFont('','B', $default_font_size - 2);
- $pdf->MultiCell(80, 3, $outputlangs->transnoentities("AvailabilityPeriod").': '.,0,'L',0);
- $pdf->SetTextColor(0,0,0);
+ $pdf->SetXY($this->marge_gauche, $posy);
+ $pdf->SetTextColor(200,0,0);
+ $pdf->SetFont('','B', $default_font_size - 2);
+ $pdf->MultiCell(80, 3, $outputlangs->transnoentities("AvailabilityPeriod").': '.,0,'L',0);
+ $pdf->SetTextColor(0,0,0);
- $posy=$pdf->GetY()+1;
+ $posy=$pdf->GetY()+1;
}*/
// Show planed date of delivery
- if (!empty($object->date_livraison))
- {
+ if (!empty($object->date_livraison)) {
$outputlangs->load("sendings");
$pdf->SetFont('', 'B', $default_font_size - 2);
$pdf->SetXY($this->marge_gauche, $posy);
@@ -982,9 +906,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$pdf->MultiCell(80, 4, $dlp, 0, 'L');
$posy = $pdf->GetY() + 1;
- }
- elseif ($object->availability_code || $object->availability) // Show availability conditions
- {
+ } elseif ($object->availability_code || $object->availability) { // Show availability conditions
$pdf->SetFont('', 'B', $default_font_size - 2);
$pdf->SetXY($this->marge_gauche, $posy);
$titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
@@ -1017,13 +939,10 @@ class pdf_eagle_proforma extends ModelePDFCommandes
}
// Show payment mode CHQ
- if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
- {
+ if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') {
// Si mode reglement non force ou si force a CHQ
- if (!empty($conf->global->FACTURE_CHQ_NUMBER))
- {
- if ($conf->global->FACTURE_CHQ_NUMBER > 0)
- {
+ if (!empty($conf->global->FACTURE_CHQ_NUMBER)) {
+ if ($conf->global->FACTURE_CHQ_NUMBER > 0) {
$account = new Account($this->db);
$account->fetch($conf->global->FACTURE_CHQ_NUMBER);
@@ -1032,23 +951,20 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0);
$posy = $pdf->GetY() + 1;
- if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
- {
+ if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) {
$pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('', '', $default_font_size - 3);
$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
$posy = $pdf->GetY() + 2;
}
}
- if ($conf->global->FACTURE_CHQ_NUMBER == -1)
- {
+ if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
$pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('', 'B', $default_font_size - 3);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
$posy = $pdf->GetY() + 1;
- if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
- {
+ if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) {
$pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('', '', $default_font_size - 3);
$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
@@ -1059,10 +975,8 @@ class pdf_eagle_proforma extends ModelePDFCommandes
}
// If payment mode not forced or forced to VIR, show payment with BAN
- if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')
- {
- if (!empty($object->fk_account) || !empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER))
- {
+ if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') {
+ if (!empty($object->fk_account) || !empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER)) {
$bankid = (empty($object->fk_account) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
if (!empty($object->fk_bank)) $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank
$account = new Account($this->db);
@@ -1103,8 +1017,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes
// Tableau total
$col1x = 120; $col2x = 170;
- if ($this->page_largeur < 210) // To work with US executive format
- {
+ if ($this->page_largeur < 210) { // To work with US executive format
$col2x -= 20;
}
$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
@@ -1153,8 +1066,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
if (!empty($object->paye)) $resteapayer = 0;
- if ($deja_regle > 0)
- {
+ if ($deja_regle > 0) {
// Already paid + Deposits
$index++;
@@ -1209,8 +1121,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFont('', '', $default_font_size - 2);
- if (empty($hidetop))
- {
+ if (empty($hidetop)) {
$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
@@ -1260,8 +1171,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes
pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
// Show Draft Watermark
- if ($object->statut == 0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK)))
- {
+ if ($object->statut == 0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK))) {
pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK);
}
@@ -1274,34 +1184,25 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$pdf->SetXY($this->marge_gauche, $posy);
// Logo
- if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
- {
- if ($this->emetteur->logo)
- {
+ if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO)) {
+ if ($this->emetteur->logo) {
$logodir = $conf->mycompany->dir_output;
if (!empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity];
- if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO))
- {
+ if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) {
$logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
- }
- else {
+ } else {
$logo = $logodir.'/logos/'.$this->emetteur->logo;
}
- if (is_readable($logo))
- {
+ if (is_readable($logo)) {
$height = pdf_getHeightForLogo($logo);
$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
- }
- else
- {
+ } else {
$pdf->SetTextColor(200, 0, 0);
$pdf->SetFont('', 'B', $default_font_size - 2);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
}
- }
- else
- {
+ } else {
$text = $this->emetteur->name;
$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
}
@@ -1324,8 +1225,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$pdf->SetFont('', '', $default_font_size - 1);
// Date prévue depart
- if (!empty($object->date_prevue_depart))
- {
+ if (!empty($object->date_prevue_depart)) {
$posy += 4;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
@@ -1333,8 +1233,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes
}
// Date prévue arrivée
- if (!empty($object->date_prevue_arrivee))
- {
+ if (!empty($object->date_prevue_arrivee)) {
$posy += 4;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
@@ -1342,8 +1241,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes
}
// Date reelle depart
- if (!empty($object->date_reelle_depart))
- {
+ if (!empty($object->date_reelle_depart)) {
$posy += 4;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
@@ -1351,27 +1249,23 @@ class pdf_eagle_proforma extends ModelePDFCommandes
}
// Date reelle arrivée
- if (!empty($object->date_reelle_arrivee))
- {
+ if (!empty($object->date_reelle_arrivee)) {
$posy += 4;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
$pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateReelleArrivee")." : ".dol_print_date($object->date_reelle_arrivee, "day", false, $outputlangs, true), '', 'R');
}
- if ($object->ref_client)
- {
+ if ($object->ref_client) {
$posy += 5;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
}
- if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE))
- {
+ if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) {
$object->fetch_projet();
- if (!empty($object->project->ref))
- {
+ if (!empty($object->project->ref)) {
$posy += 3;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
@@ -1379,11 +1273,9 @@ class pdf_eagle_proforma extends ModelePDFCommandes
}
}
- if (!empty($conf->global->PDF_SHOW_PROJECT))
- {
+ if (!empty($conf->global->PDF_SHOW_PROJECT)) {
$object->fetch_projet();
- if (!empty($object->project->ref))
- {
+ if (!empty($object->project->ref)) {
$posy += 3;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
@@ -1391,8 +1283,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes
}
}
- if (!empty($conf->global->DOC_SHOW_CUSTOMER_CODE) && !empty($object->thirdparty->code_client))
- {
+ if (!empty($conf->global->DOC_SHOW_CUSTOMER_CODE) && !empty($object->thirdparty->code_client)) {
$posy += 4;
$pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60);
@@ -1400,11 +1291,9 @@ class pdf_eagle_proforma extends ModelePDFCommandes
}
// Get contact
- if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
- {
+ if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) {
$arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
- if (count($arrayidcontact) > 0)
- {
+ if (count($arrayidcontact) > 0) {
$usertmp = new User($this->db);
$usertmp->fetch($arrayidcontact[0]);
$posy += 4;
@@ -1420,13 +1309,11 @@ class pdf_eagle_proforma extends ModelePDFCommandes
// Show list of linked objects
$current_y = $pdf->getY();
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
- if ($current_y < $pdf->getY())
- {
+ if ($current_y < $pdf->getY()) {
$top_shift = $pdf->getY() - $current_y;
}
- if ($showaddress)
- {
+ if ($showaddress) {
// Sender properties
$carac_emetteur = '';
// Add internal contact of origin element if defined
@@ -1434,8 +1321,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$arrayidcontact = $object->getIdContact('external', 'STFROM');
$usecontact = false;
- if (count($arrayidcontact) > 0)
- {
+ if (count($arrayidcontact) > 0) {
/*$object->fetch_user(reset($arrayidcontact));
$carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";*/
$usecontact = true;
@@ -1445,9 +1331,9 @@ class pdf_eagle_proforma extends ModelePDFCommandes
if ($usecontact) $thirdparty = $object->contact;
else $thirdparty = $this->emetteur;
- if(!empty($thirdparty)) $carac_emetteur_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
+ if (!empty($thirdparty)) $carac_emetteur_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
- if($usecontact) $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, $object->contact, 1, 'targetwithdetails', $object);
+ if ($usecontact) $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, $object->contact, 1, 'targetwithdetails', $object);
else $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
// Show sender
@@ -1484,8 +1370,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes
// If SHIPPING contact defined, we use it
$usecontact = false;
$arrayidcontact = $object->getIdContact('external', 'STDEST');
- if (count($arrayidcontact) > 0)
- {
+ if (count($arrayidcontact) > 0) {
$usecontact = true;
$result = $object->fetch_contact($arrayidcontact[0]);
}
@@ -1498,7 +1383,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$thirdparty = $object->thirdparty;
}
- if(!empty($thirdparty)) $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
+ if (!empty($thirdparty)) $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
$carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact : null), $usecontact, 'targetwithdetails', $object);
@@ -1631,8 +1516,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes
'border-left' => false, // remove left line separator
);
- if (!empty($conf->global->MAIN_GENERATE_ORDERS_WITH_PICTURE))
- {
+ if (!empty($conf->global->MAIN_GENERATE_ORDERS_WITH_PICTURE)) {
$this->cols['photo']['status'] = true;
}
@@ -1740,16 +1624,11 @@ class pdf_eagle_proforma extends ModelePDFCommandes
);
$reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook
- if ($reshook < 0)
- {
+ if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
- }
- elseif (empty($reshook))
- {
+ } elseif (empty($reshook)) {
$this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
- }
- else
- {
+ } else {
$this->cols = $hookmanager->resArray;
}
}
diff --git a/htdocs/product/stock/stocktransfer/stocktransfer_card.php b/htdocs/product/stock/stocktransfer/stocktransfer_card.php
index ae80b55b51d..9de775f29d6 100644
--- a/htdocs/product/stock/stocktransfer/stocktransfer_card.php
+++ b/htdocs/product/stock/stocktransfer/stocktransfer_card.php
@@ -102,8 +102,7 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen
// Initialize array of search criterias
$search_all = trim(GETPOST("search_all", 'alpha'));
$search = array();
-foreach ($object->fields as $key => $val)
-{
+foreach ($object->fields as $key => $val) {
if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha');
}
@@ -141,8 +140,7 @@ $parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
-if (empty($reshook))
-{
+if (empty($reshook)) {
$error = 0;
$backurlforlist = dol_buildpath('/product/stock/stocktransfer/stocktransfer_list.php', 1);
@@ -170,30 +168,27 @@ if (empty($reshook))
// Action to build doc
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
- if ($action == 'set_thirdparty' && $permissiontoadd)
- {
+ if ($action == 'set_thirdparty' && $permissiontoadd) {
$object->setValueFrom('fk_soc', GETPOST('fk_soc', 'int'), '', '', 'date', '', $user, 'STOCKTRANSFER_MODIFY');
}
- if ($action == 'classin' && $permissiontoadd)
- {
+ if ($action == 'classin' && $permissiontoadd) {
$object->setProject(GETPOST('projectid', 'int'));
}
- if($action == 'addline' && $permissiontoadd) {
-
- if($qty <= 0) {
+ if ($action == 'addline' && $permissiontoadd) {
+ if ($qty <= 0) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Qty")), null, 'errors');
$action = 'view';
}
- if($fk_warehouse_source <= 0) {
+ if ($fk_warehouse_source <= 0) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseSource")), null, 'errors');
$action = 'view';
}
- if($fk_warehouse_destination <= 0) {
+ if ($fk_warehouse_destination <= 0) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseTarget")), null, 'errors');
$action = 'view';
@@ -201,25 +196,23 @@ if (empty($reshook))
$prod = new Product($db);
$prod->fetch($fk_product);
- if ($prod->hasbatch())
- {
- if (empty($batch))
- {
+ if ($prod->hasbatch()) {
+ if (empty($batch)) {
$error++;
$langs->load("errors");
setEventMessages($langs->transnoentities("ErrorTryToMakeMoveOnProductRequiringBatchData", $prod->ref), null, 'errors');
}
} else {
- if(!empty($batch)) {
+ if (!empty($batch)) {
$error++;
setEventMessages($langs->transnoentities('StockTransferNoBatchForProduct', $prod->getNomUrl()), '', 'errors');
}
}
- if(empty($error)) {
+ if (empty($error)) {
$line = new StockTransferLine($db);
$records = $line->fetchAll('', '', 0, 0, array('customsql'=>' fk_stocktransfer = '.$id.' AND fk_product = '.$fk_product.' AND fk_warehouse_source = '.$fk_warehouse_source.' AND fk_warehouse_destination = '.$fk_warehouse_destination.' AND ('.(empty($batch) ? 'batch = "" or batch IS NULL' : 'batch = "'.$batch.'"' ).')'));
- if(!empty($records[key($records)])) $line = $records[key($records)];
+ if (!empty($records[key($records)])) $line = $records[key($records)];
$line->fk_stocktransfer = $id;
$line->qty += $qty;
$line->fk_warehouse_source = $fk_warehouse_source;
@@ -228,28 +221,27 @@ if (empty($reshook))
$line->batch = $batch;
$line->pmp = $prod->pmp;
- if($line->id > 0) $line->update($user);
+ if ($line->id > 0) $line->update($user);
else {
$line->rang = count($object->lines) + 1;
$line->create($user);
}
$object->fetchLines();
}
- } elseif($action === 'updateline' && $permissiontoadd) {
-
- if($qty <= 0) {
+ } elseif ($action === 'updateline' && $permissiontoadd) {
+ if ($qty <= 0) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Qty")), null, 'errors');
$action = 'editline';
}
- if($fk_warehouse_source <= 0) {
+ if ($fk_warehouse_source <= 0) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseSource")), null, 'errors');
$action = 'editline';
}
- if($fk_warehouse_destination <= 0) {
+ if ($fk_warehouse_destination <= 0) {
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseTarget")), null, 'errors');
$action = 'editline';
@@ -257,24 +249,22 @@ if (empty($reshook))
$prod = new Product($db);
$prod->fetch($fk_product);
- if ($prod->hasbatch())
- {
- if (empty($batch))
- {
+ if ($prod->hasbatch()) {
+ if (empty($batch)) {
$error++;
$langs->load("errors");
setEventMessages($langs->trans("ErrorTryToMakeMoveOnProductRequiringBatchData", $prod->ref), null, 'errors');
$action = 'editline';
}
} else {
- if(!empty($batch)) {
+ if (!empty($batch)) {
$error++;
setEventMessages($langs->trans('StockTransferNoBatchForProduct', $prod->getNomUrl()), '', 'errors');
$action = 'editline';
}
}
- if(empty($error)) {
+ if (empty($error)) {
$line = new StockTransferLine($db);
$line->fetch($lineid);
$line->qty = $qty;
@@ -288,18 +278,18 @@ if (empty($reshook))
}
// Décrémentation
- if($action == 'confirm_destock' && $confirm == 'yes' && $object->status == $object::STATUS_VALIDATED) {
+ if ($action == 'confirm_destock' && $confirm == 'yes' && $object->status == $object::STATUS_VALIDATED) {
$lines = $object->getLinesArray();
- if(!empty($lines)) {
+ if (!empty($lines)) {
$db->begin();
foreach ($lines as $line) {
$res = $line->doStockMovement($label, $line->fk_warehouse_source);
- if($res <= 0) $error++;
+ if ($res <= 0) $error++;
}
- if(empty($error)) $db->commit();
+ if (empty($error)) $db->commit();
else $db->rollback();
}
- if(empty($error)) {
+ if (empty($error)) {
$object->setStatut($object::STATUS_TRANSFERED, $id);
$object->status = $object::STATUS_TRANSFERED;
$object->date_reelle_depart = date('Y-m-d');
@@ -309,18 +299,18 @@ if (empty($reshook))
}
// Annulation décrémentation
- if($action == 'confirm_destockcancel' && $confirm == 'yes' && $object->status == $object::STATUS_TRANSFERED) {
+ if ($action == 'confirm_destockcancel' && $confirm == 'yes' && $object->status == $object::STATUS_TRANSFERED) {
$lines = $object->getLinesArray();
- if(!empty($lines)) {
+ if (!empty($lines)) {
$db->begin();
foreach ($lines as $line) {
$res = $line->doStockMovement($label, $line->fk_warehouse_source, 0);
- if($res <= 0) $error++;
+ if ($res <= 0) $error++;
}
- if(empty($error)) $db->commit();
+ if (empty($error)) $db->commit();
else $db->rollback();
}
- if(empty($error)) {
+ if (empty($error)) {
$object->setStatut($object::STATUS_VALIDATED, $id);
$object->status = $object::STATUS_VALIDATED;
$object->date_reelle_depart = null;
@@ -330,18 +320,18 @@ if (empty($reshook))
}
// Incrémentation
- if($action == 'confirm_addstock' && $confirm == 'yes' && $object->status == $object::STATUS_TRANSFERED) {
+ if ($action == 'confirm_addstock' && $confirm == 'yes' && $object->status == $object::STATUS_TRANSFERED) {
$lines = $object->getLinesArray();
- if(!empty($lines)) {
+ if (!empty($lines)) {
$db->begin();
foreach ($lines as $line) {
$res = $line->doStockMovement($label, $line->fk_warehouse_destination, 0);
- if($res <= 0) $error++;
+ if ($res <= 0) $error++;
}
- if(empty($error)) $db->commit();
+ if (empty($error)) $db->commit();
else $db->rollback();
}
- if(empty($error)) {
+ if (empty($error)) {
$object->setStatut($object::STATUS_CLOSED, $id);
$object->status = $object::STATUS_CLOSED;
$object->date_reelle_arrivee = date('Y-m-d');
@@ -351,18 +341,18 @@ if (empty($reshook))
}
// Annulation incrémentation
- if($action == 'confirm_addstockcancel' && $confirm == 'yes' && $object->status == $object::STATUS_CLOSED) {
+ if ($action == 'confirm_addstockcancel' && $confirm == 'yes' && $object->status == $object::STATUS_CLOSED) {
$lines = $object->getLinesArray();
- if(!empty($lines)) {
+ if (!empty($lines)) {
$db->begin();
foreach ($lines as $line) {
$res = $line->doStockMovement($label, $line->fk_warehouse_destination);
- if($res <= 0) $error++;
+ if ($res <= 0) $error++;
}
- if(empty($error)) $db->commit();
+ if (empty($error)) $db->commit();
else $db->rollback();
}
- if(empty($error)) {
+ if (empty($error)) {
$object->setStatut($object::STATUS_TRANSFERED, $id);
$object->status = $object::STATUS_TRANSFERED;
$object->date_reelle_arrivee = null;
@@ -400,8 +390,8 @@ jQuery(document).ready(function() {';
// Affichage alerte date prévue de départ si transfert concerné
$date_prevue_depart = $object->date_prevue_depart;
$date_prevue_depart_plus_delai = $date_prevue_depart;
-if($object->lead_time_for_warning > 0) $date_prevue_depart_plus_delai = strtotime(date('Y-m-d', $date_prevue_depart) . ' + '.$object->lead_time_for_warning.' day');
-if(!empty($date_prevue_depart) && $date_prevue_depart_plus_delai < strtotime(date('Y-m-d'))) {
+if ($object->lead_time_for_warning > 0) $date_prevue_depart_plus_delai = strtotime(date('Y-m-d', $date_prevue_depart) . ' + '.$object->lead_time_for_warning.' day');
+if (!empty($date_prevue_depart) && $date_prevue_depart_plus_delai < strtotime(date('Y-m-d'))) {
print "$('.valuefield.fieldname_date_prevue_depart').append('";
print img_warning($langs->trans('Alert').' - '.$langs->trans('Late'));
print "');";
@@ -412,8 +402,7 @@ print '});
// Part to create
-if ($action == 'create')
-{
+if ($action == 'create') {
print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("StockTransfer")), '', 'object_'.$object->picto);
print '