FIX : weight and units display

This commit is contained in:
Gauthier PC portable 024 2021-08-03 16:00:32 +02:00
parent 335dca7fc3
commit 1d2527b991
4 changed files with 697 additions and 370 deletions

View File

@ -4,7 +4,7 @@
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr> * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -144,10 +144,11 @@ class pdf_eagle extends ModelePdfStockTransfer
// Define position of columns // Define position of columns
$this->posxdesc = $this->marge_gauche + 1; $this->posxdesc = $this->marge_gauche + 1;
$this->posxlot = $this->page_largeur - $this->marge_droite - 125; $this->posxlot = $this->page_largeur - $this->marge_droite - 135;
$this->posxqty = $this->page_largeur - $this->marge_droite - 105; $this->posxweightvol = $this->page_largeur - $this->marge_droite - 115;
$this->posxwarehousesource = $this->page_largeur - $this->marge_droite - 90; $this->posxqty = $this->page_largeur - $this->marge_droite - 95;
$this->posxwarehousedestination = $this->page_largeur - $this->marge_droite - 45; $this->posxwarehousesource = $this->page_largeur - $this->marge_droite - 70;
$this->posxwarehousedestination = $this->page_largeur - $this->marge_droite - 35;
$this->posxpuht = $this->page_largeur - $this->marge_droite; $this->posxpuht = $this->page_largeur - $this->marge_droite;
/*if (!empty($conf->global->STOCKTRANSFER_PDF_DISPLAY_AMOUNT_HT)) { // Show also the prices /*if (!empty($conf->global->STOCKTRANSFER_PDF_DISPLAY_AMOUNT_HT)) { // Show also the prices
@ -158,9 +159,10 @@ class pdf_eagle extends ModelePdfStockTransfer
$this->posxtotalht = $this->page_largeur - $this->marge_droite - 20; $this->posxtotalht = $this->page_largeur - $this->marge_droite - 20;
}*/ }*/
//if (!empty($conf->global->STOCKTRANSFER_PDF_HIDE_WEIGHT_AND_VOLUME)) $this->posxqty = $this->posxwarehousesource; if (!empty($conf->global->STOCKTRANSFER_PDF_HIDE_WEIGHT_AND_VOLUME)) $this->posxweightvol = $this->posxqty;
$this->posxpicture = $this->posxqty - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images $this->posxpicture = $this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
//var_dump($this->posxpicture, $this->posxweightvol);exit;
// To work with US executive format // To work with US executive format
if ($this->page_largeur < 210) { if ($this->page_largeur < 210) {
@ -170,11 +172,11 @@ class pdf_eagle extends ModelePdfStockTransfer
$this->posxwarehousedestination -= 20; $this->posxwarehousedestination -= 20;
} }
if (!empty($conf->global->STOCKTRANSFER_PDF_HIDE_ORDERED)) { /*if (!empty($conf->global->STOCKTRANSFER_PDF_HIDE_ORDERED)) {
$this->posxqty += ($this->posxwarehousedestination - $this->posxwarehousesource); $this->posxqty += ($this->posxwarehousedestination - $this->posxwarehousesource);
$this->posxpicture += ($this->posxwarehousedestination - $this->posxwarehousesource); $this->posxpicture += ($this->posxwarehousedestination - $this->posxwarehousesource);
$this->posxwarehousesource = $this->posxwarehousedestination; $this->posxwarehousesource = $this->posxwarehousedestination;
} }*/
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
@ -209,18 +211,23 @@ class pdf_eagle extends ModelePdfStockTransfer
// Loop on each lines to detect if there is at least one image to show // Loop on each lines to detect if there is at least one image to show
$realpatharray = array(); $realpatharray = array();
if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE)) { if (!empty($conf->global->MAIN_GENERATE_STOCKTRANSFER_WITH_PICTURE))
{
$objphoto = new Product($this->db); $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; if (empty($object->lines[$i]->fk_product)) continue;
$objphoto = new Product($this->db); $objphoto = new Product($this->db);
$objphoto->fetch($object->lines[$i]->fk_product); $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/"; $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; $dir = $conf->product->dir_output.'/'.$pdir;
} else { }
else
{
$pdir = get_exdir(0, 2, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; $pdir = get_exdir(0, 2, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/';
$dir = $conf->product->dir_output.'/'.$pdir; $dir = $conf->product->dir_output.'/'.$pdir;
} }
@ -230,12 +237,17 @@ class pdf_eagle extends ModelePdfStockTransfer
foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) { foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) { 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 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']; $filename = $obj['photo_vignette'];
} else { }
else
{
$filename = $obj['photo']; $filename = $obj['photo'];
} }
} else { }
else
{
$filename = $obj['photo']; $filename = $obj['photo'];
} }
@ -247,29 +259,43 @@ class pdf_eagle extends ModelePdfStockTransfer
} }
} }
if (count($realpatharray) == 0) $this->posxpicture = $this->posxqty; if (count($realpatharray) == 0) $this->posxpicture = $this->posxweightvol;
if ($conf->stocktransfer->dir_output) {
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 ($conf->stocktransfer->dir_output)
{
// Definition de $dir et $file // Definition de $dir et $file
if ($object->specimen) { if ($object->specimen)
{
$dir = $conf->stocktransfer->dir_output; $dir = $conf->stocktransfer->dir_output;
$file = $dir."/SPECIMEN.pdf"; $file = $dir."/SPECIMEN.pdf";
} else { }
else
{
$stocktransferref = dol_sanitizeFileName($object->ref); $stocktransferref = dol_sanitizeFileName($object->ref);
$dir = $conf->stocktransfer->dir_output.'/'.$object->element."/".$stocktransferref; $dir = $conf->stocktransfer->dir_output.'/'.$object->element."/".$stocktransferref;
$file = $dir."/".$stocktransferref.".pdf"; $file = $dir."/".$stocktransferref.".pdf";
} }
if (!file_exists($dir)) { if (!file_exists($dir))
if (dol_mkdir($dir) < 0) { {
if (dol_mkdir($dir) < 0)
{
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return 0; return 0;
} }
} }
if (file_exists($dir)) { if (file_exists($dir))
{
// Add pdfgeneration hook // Add pdfgeneration hook
if (!is_object($hookmanager)) { if (!is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager = new HookManager($this->db); $hookmanager = new HookManager($this->db);
} }
@ -289,13 +315,15 @@ class pdf_eagle extends ModelePdfStockTransfer
if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
$pdf->SetAutoPageBreak(1, 0); $pdf->SetAutoPageBreak(1, 0);
if (class_exists('TCPDF')) { if (class_exists('TCPDF'))
{
$pdf->setPrintHeader(false); $pdf->setPrintHeader(false);
$pdf->setPrintFooter(false); $pdf->setPrintFooter(false);
} }
$pdf->SetFont(pdf_getPDFFont($outputlangs)); $pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File // 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); $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
$tplidx = $pdf->importPage(1); $tplidx = $pdf->importPage(1);
} }
@ -331,9 +359,11 @@ class pdf_eagle extends ModelePdfStockTransfer
// Incoterm // Incoterm
$height_incoterms = 0; $height_incoterms = 0;
if ($conf->incoterm->enabled) { if ($conf->incoterm->enabled)
{
$desc_incoterms = $object->getIncotermsForPDF(); $desc_incoterms = $object->getIncotermsForPDF();
if ($desc_incoterms) { if ($desc_incoterms)
{
$tab_top = 88; $tab_top = 88;
$pdf->SetFont('', '', $default_font_size - 1); $pdf->SetFont('', '', $default_font_size - 1);
@ -350,7 +380,8 @@ 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 = 88 + $height_incoterms;
$tab_top_alt = $tab_top; $tab_top_alt = $tab_top;
@ -359,20 +390,24 @@ class pdf_eagle extends ModelePdfStockTransfer
//$tab_top_alt += 1; //$tab_top_alt += 1;
// Tracking number // 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'); $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(); $tab_top_alt = $pdf->GetY();
$object->getUrlTrackingStatus($object->tracking_number); $object->getUrlTrackingStatus($object->tracking_number);
if (!empty($object->tracking_url)) { if (!empty($object->tracking_url))
if ($object->shipping_method_id > 0) { {
if ($object->shipping_method_id > 0)
{
// Get code using getLabelFromKey // Get code using getLabelFromKey
$code = $outputlangs->getLabelFromKey($this->db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code'); $code = $outputlangs->getLabelFromKey($this->db, $object->shipping_method_id, 'c_shipment_mode', 'rowid', 'code');
$label = ''; $label = '';
if ($object->tracking_url != $object->tracking_number) $label .= $outputlangs->trans("LinkToTrackYourPackage")."<br>"; if ($object->tracking_url != $object->tracking_number) $label .= $outputlangs->trans("LinkToTrackYourPackage")."<br>";
$label .= $outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code)); $label .= $outputlangs->trans("SendingMethod").": ".$outputlangs->trans("SendingMethod".strtoupper($code));
//var_dump($object->tracking_url != $object->tracking_number);exit; //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 .= " : ";
$label .= $object->tracking_url; $label .= $object->tracking_url;
} }
@ -385,7 +420,8 @@ class pdf_eagle extends ModelePdfStockTransfer
} }
// Notes // Notes
if (!empty($object->note_public)) { if (!empty($object->note_public))
{
$pdf->SetFont('', '', $default_font_size - 1); // Dans boucle pour gerer multi-page $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); $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1);
} }
@ -399,7 +435,9 @@ class pdf_eagle extends ModelePdfStockTransfer
$tab_height = $tab_height - $height_note; $tab_height = $tab_height - $height_note;
$tab_top = $nexY + 6; $tab_top = $nexY + 6;
} else { }
else
{
$height_note = 0; $height_note = 0;
} }
@ -409,7 +447,8 @@ class pdf_eagle extends ModelePdfStockTransfer
$TCacheEntrepots=array(); $TCacheEntrepots=array();
// Loop on each lines // Loop on each lines
for ($i = 0; $i < $nblines; $i++) { for ($i = 0; $i < $nblines; $i++)
{
$curY = $nexY; $curY = $nexY;
$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
$pdf->SetTextColor(0, 0, 0); $pdf->SetTextColor(0, 0, 0);
@ -427,7 +466,8 @@ class pdf_eagle extends ModelePdfStockTransfer
$posYAfterDescription = 0; $posYAfterDescription = 0;
// We start with Photo of product line // 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); $pdf->AddPage('', '', true);
if (!empty($tplidx)) $pdf->useTemplate($tplidx); if (!empty($tplidx)) $pdf->useTemplate($tplidx);
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
@ -438,12 +478,15 @@ class pdf_eagle extends ModelePdfStockTransfer
// Allows data in the first page if description is long enough to break in multiples pages // 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)) if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
$showpricebeforepagebreak = 1; $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; $curX = $this->posxpicture - 1;
$pdf->Image($realpatharray[$i], $curX + (($this->posxqty - $this->posxpicture - $imglinesize['width']) / 2), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi $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
// $pdf->Image does not increase value return by getY, so we save it manually // $pdf->Image does not increase value return by getY, so we save it manually
$posYAfterImage = $curY + $imglinesize['height']; $posYAfterImage = $curY + $imglinesize['height'];
} }
@ -452,16 +495,27 @@ class pdf_eagle extends ModelePdfStockTransfer
$curX = $this->posxdesc - 1; $curX = $this->posxdesc - 1;
$pdf->startTransaction(); $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]->fetch_product();
$object->lines[$i]->label = $object->lines[$i]->product->label; $object->lines[$i]->label = $object->lines[$i]->product->label;
$object->lines[$i]->description = $object->lines[$i]->product->description; $object->lines[$i]->description = $object->lines[$i]->product->description;
$object->lines[$i]->weight = $object->lines[$i]->product->weight;
$object->lines[$i]->weight_units = $object->lines[$i]->product->weight_units;
$object->lines[$i]->length = $object->lines[$i]->product->length;
$object->lines[$i]->length_units = $object->lines[$i]->product->length_units;
$object->lines[$i]->surface = $object->lines[$i]->product->surface;
$object->lines[$i]->surface_units = $object->lines[$i]->product->surface_units;
$object->lines[$i]->volume = $object->lines[$i]->product->volume;
$object->lines[$i]->volume_units = $object->lines[$i]->product->volume_units;
$object->lines[$i]->fk_unit = $object->lines[$i]->product->fk_unit;
//var_dump($object->lines[$i]);exit;
} }
//var_dump($object->lines[$i]->product);exit;
pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc); pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
$pageposafter = $pdf->getPage(); $pageposafter = $pdf->getPage();
if ($pageposafter > $pageposbefore) { // There is a pagebreak if ($pageposafter > $pageposbefore) // There is a pagebreak
{
$pdf->rollbackTransaction(true); $pdf->rollbackTransaction(true);
$pageposafter = $pageposbefore; $pageposafter = $pageposbefore;
//print $pageposafter.'-'.$pageposbefore;exit; //print $pageposafter.'-'.$pageposbefore;exit;
@ -471,22 +525,28 @@ class pdf_eagle extends ModelePdfStockTransfer
$pageposafter = $pdf->getPage(); $pageposafter = $pdf->getPage();
$posyafter = $pdf->GetY(); $posyafter = $pdf->GetY();
//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; //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 ($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 ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page
{
$pdf->AddPage('', '', true); $pdf->AddPage('', '', true);
if (!empty($tplidx)) $pdf->useTemplate($tplidx); if (!empty($tplidx)) $pdf->useTemplate($tplidx);
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
$pdf->setPage($pageposafter + 1); $pdf->setPage($pageposafter + 1);
} }
} else { }
else
{
// We found a page break // We found a page break
// Allows data in the first page if description is long enough to break in multiples pages // 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)) if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
$showpricebeforepagebreak = 1; $showpricebeforepagebreak = 1;
else $showpricebeforepagebreak = 0; else
$showpricebeforepagebreak = 0;
} }
} else // No pagebreak }
else // No pagebreak
{ {
$pdf->commitTransaction(); $pdf->commitTransaction();
} }
@ -511,12 +571,30 @@ class pdf_eagle extends ModelePdfStockTransfer
$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
$pdf->SetXY($this->posxqty, $curY);
// Lot / série // Lot / série
if (!empty($conf->productbatch->enabled)) { if(!empty($conf->productbatch->enabled)) {
$pdf->SetXY($this->posxlot, $curY); $pdf->SetXY($this->posxlot, $curY);
$pdf->MultiCell(($this->posxqty - $this->posxlot), 3, $object->lines[$i]->batch, '', 'C'); $pdf->MultiCell(($this->posxweightvol - $this->posxlot), 3, $object->lines[$i]->batch, '', 'C');
}
// Weight
$pdf->SetXY($this->posxweightvol, $curY);
$weighttxt = '';
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)
{
$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))
{
$pdf->writeHTMLCell($this->posxqty - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt) ? '<br>' : '').$voltxt, 0, 0, false, true, 'C');
//$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?'<br>':'').$voltxt,'','C');
} }
// Qty // Qty
@ -526,7 +604,7 @@ class pdf_eagle extends ModelePdfStockTransfer
// Warehouse source // Warehouse source
$wh_source = new Entrepot($db); $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 { else {
$wh_source->fetch($object->lines[$i]->fk_warehouse_source); $wh_source->fetch($object->lines[$i]->fk_warehouse_source);
$TCacheEntrepots[$object->lines[$i]->fk_warehouse_source] = $wh_source; $TCacheEntrepots[$object->lines[$i]->fk_warehouse_source] = $wh_source;
@ -536,7 +614,7 @@ class pdf_eagle extends ModelePdfStockTransfer
// Warehouse destination // Warehouse destination
$wh_destination = new Entrepot($db); $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 { else {
$wh_destination->fetch($object->lines[$i]->fk_warehouse_destination); $wh_destination->fetch($object->lines[$i]->fk_warehouse_destination);
$TCacheEntrepots[$object->lines[$i]->fk_warehouse_destination] = $wh_destination; $TCacheEntrepots[$object->lines[$i]->fk_warehouse_destination] = $wh_destination;
@ -544,7 +622,8 @@ class pdf_eagle extends ModelePdfStockTransfer
$pdf->SetXY($this->posxwarehousedestination, $curY); $pdf->SetXY($this->posxwarehousedestination, $curY);
$pdf->MultiCell(($this->posxpuht - $this->posxwarehousedestination), 3, $wh_destination->ref.(!empty($wh_destination->lieu) ? ' - '.$wh_destination->lieu : ''), '', 'C'); $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->SetXY($this->posxpuht, $curY);
$pdf->MultiCell(($this->posxtotalht - $this->posxpuht - 1), 3, price($object->lines[$i]->subprice, 0, $outputlangs), '', 'R'); $pdf->MultiCell(($this->posxtotalht - $this->posxpuht - 1), 3, price($object->lines[$i]->subprice, 0, $outputlangs), '', 'R');
@ -556,7 +635,8 @@ class pdf_eagle extends ModelePdfStockTransfer
if ($weighttxt && $voltxt) $nexY += 2; if ($weighttxt && $voltxt) $nexY += 2;
// Add line // 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->setPage($pageposafter);
$pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80))); $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
//$pdf->SetDrawColor(190,190,200); //$pdf->SetDrawColor(190,190,200);
@ -565,11 +645,15 @@ class pdf_eagle extends ModelePdfStockTransfer
} }
// Detect if some page were added automatically and output _tableau for past pages // Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter) { while ($pagenb < $pageposafter)
{
$pdf->setPage($pagenb); $pdf->setPage($pagenb);
if ($pagenb == 1) { if ($pagenb == 1)
{
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 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->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
} }
$this->_pagefoot($pdf, $object, $outputlangs, 1); $this->_pagefoot($pdf, $object, $outputlangs, 1);
@ -578,10 +662,14 @@ class pdf_eagle extends ModelePdfStockTransfer
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. $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 (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 (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
if ($pagenb == 1) { {
if ($pagenb == 1)
{
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 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->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
} }
$this->_pagefoot($pdf, $object, $outputlangs, 1); $this->_pagefoot($pdf, $object, $outputlangs, 1);
@ -594,16 +682,19 @@ class pdf_eagle extends ModelePdfStockTransfer
} }
// Show square // 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); $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; $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); $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; $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
} }
// Affiche zone totaux // Affiche zone totaux
//$posy = $this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs); $posy = $this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
// Pied de page // Pied de page
$this->_pagefoot($pdf, $object, $outputlangs); $this->_pagefoot($pdf, $object, $outputlangs);
@ -618,7 +709,8 @@ class pdf_eagle extends ModelePdfStockTransfer
$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
global $action; global $action;
$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $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->error = $hookmanager->error;
$this->errors = $hookmanager->errors; $this->errors = $hookmanager->errors;
} }
@ -629,11 +721,15 @@ class pdf_eagle extends ModelePdfStockTransfer
$this->result = array('fullpath'=>$file); $this->result = array('fullpath'=>$file);
return 1; // No error return 1; // No error
} else { }
else
{
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return 0; return 0;
} }
} else { }
else
{
$this->error = $langs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR"); $this->error = $langs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR");
return 0; return 0;
} }
@ -683,10 +779,14 @@ class pdf_eagle extends ModelePdfStockTransfer
$tmparray = $object->getTotalWeightVolume(); $tmparray = $object->getTotalWeightVolume();
$totalWeight = $tmparray['weight']; $totalWeight = $tmparray['weight'];
$totalVolume = $tmparray['volume']; $totalVolume = $tmparray['volume'];
$totalOrdered = $tmparray['ordered']; $totalQty = 0;
$totalToShip = $tmparray['toship']; if(!empty($object->lines))
foreach ($object->lines as $line) {
$totalQty+=$line->qty;
}
// Set trueVolume and volume_units not currently stored into database // 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->trueVolume = price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0);
$object->volume_units = $object->size_units * 3; $object->volume_units = $object->size_units * 3;
} }
@ -700,17 +800,14 @@ class pdf_eagle extends ModelePdfStockTransfer
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1); $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->posxwarehousesource, $tab2_top + $tab2_hl * $index); {
$pdf->MultiCell($this->posxwarehousedestination - $this->posxwarehousesource, $tab2_hl, $totalOrdered, 0, 'C', 1); $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_HIDE_QTYTOSHIP)) { if (!empty($conf->global->STOCKTRANSFER_PDF_DISPLAY_AMOUNT_HT))
$pdf->SetXY($this->posxwarehousedestination, $tab2_top + $tab2_hl * $index); {
$pdf->MultiCell($this->posxpuht - $this->posxwarehousedestination, $tab2_hl, $totalToShip, 0, 'C', 1);
}
if (!empty($conf->global->STOCKTRANSFER_PDF_DISPLAY_AMOUNT_HT)) {
$pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index); $pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1); $pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1);
@ -718,17 +815,20 @@ 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); $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 // Total Weight
if ($totalWeighttoshow) { if ($totalWeighttoshow)
$pdf->SetXY($this->posxqty, $tab2_top + $tab2_hl * $index); {
$pdf->MultiCell(($this->posxwarehousesource - $this->posxqty), $tab2_hl, $totalWeighttoshow, 0, 'C', 1); $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell(($this->posxqty - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0, 'C', 1);
$index++; $index++;
} }
if ($totalVolumetoshow) { if ($totalVolumetoshow)
$pdf->SetXY($this->posxqty, $tab2_top + $tab2_hl * $index); {
$pdf->MultiCell(($this->posxwarehousesource - $this->posxqty), $tab2_hl, $totalVolumetoshow, 0, 'C', 1); $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell(($this->posxqty - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0, 'C', 1);
$index++; $index++;
} }
@ -773,36 +873,48 @@ class pdf_eagle extends ModelePdfStockTransfer
$pdf->SetDrawColor(128, 128, 128); $pdf->SetDrawColor(128, 128, 128);
$pdf->SetFont('', '', $default_font_size - 1); $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->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->SetXY($this->posxdesc - 1, $tab_top + 1);
$pdf->MultiCell($this->posxwarehousesource - $this->posxdesc, 2, $outputlangs->transnoentities("Description"), '', 'L'); $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); $pdf->line($this->posxlot - 1, $tab_top, $this->posxlot - 1, $tab_top + $tab_height);
if (empty($hidetop)) { if (empty($hidetop)) {
$pdf->SetXY($this->posxlot - 8, $tab_top + 1); $pdf->SetXY($this->posxlot, $tab_top + 1);
$pdf->MultiCell(($this->posxwarehousesource - $this->posxlot), 2, $outputlangs->transnoentities("Batch"), '', 'C'); $pdf->MultiCell(($this->posxweightvol - $this->posxlot), 2, $outputlangs->transnoentities("Batch"), '', 'C');
}
}
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);
$pdf->MultiCell(($this->posxqty - $this->posxweightvol), 2, $outputlangs->transnoentities("WeightVolShort"), '', 'C');
} }
} }
$pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height); $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->SetXY($this->posxqty - 1, $tab_top + 1);
$pdf->MultiCell(($this->posxwarehousesource - $this->posxqty), 2, $outputlangs->transnoentities("Qty"), '', 'C'); $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); $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->SetXY($this->posxwarehousesource - 1, $tab_top + 1);
$pdf->MultiCell(($this->posxwarehousedestination - $this->posxwarehousesource), 2, $outputlangs->transnoentities("WarehouseSource"), '', 'C'); $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); $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->SetXY($this->posxwarehousedestination-2.5, $tab_top + 1);
$pdf->MultiCell(($this->posxpuht - $this->posxwarehousedestination+4), 2, $outputlangs->transnoentities("WarehouseTarget"), '', 'C'); $pdf->MultiCell(($this->posxpuht - $this->posxwarehousedestination+4), 2, $outputlangs->transnoentities("WarehouseTarget"), '', 'C');
} }
@ -824,24 +936,22 @@ class pdf_eagle extends ModelePdfStockTransfer
}*/ }*/
} }
/** function atLeastOneBatch($object) {
* Used to know if at least one line of Stock Transfer object has a batch set
* global $conf;
* @param $object Stock Transfer object
* @return bool true if at least one line has batch set, false if not
*/
public function atLeastOneBatch($object)
{
$atLeastOneBatch = false; $atLeastOneBatch = false;
if(empty($conf->productbatch->enabled)) return false;
foreach ($object->lines as $line) { foreach ($object->lines as $line) {
if (!empty($line->batch)) { if(!empty($line->batch)) {
return true; return true;
} }
} }
return false; return false;
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
@ -865,7 +975,8 @@ class pdf_eagle extends ModelePdfStockTransfer
pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
// Show Draft Watermark // 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); pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SHIPPING_DRAFT_WATERMARK);
} }
@ -882,36 +993,47 @@ class pdf_eagle extends ModelePdfStockTransfer
// Logo // Logo
$logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
if ($this->emetteur->logo) { if ($this->emetteur->logo)
if (is_readable($logo)) { {
if (is_readable($logo))
{
$height = pdf_getHeightForLogo($logo); $height = pdf_getHeightForLogo($logo);
$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
} else { }
else
{
$pdf->SetTextColor(200, 0, 0); $pdf->SetTextColor(200, 0, 0);
$pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetFont('', 'B', $default_font_size - 2);
$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
} }
} else { }
else
{
$text = $this->emetteur->name; $text = $this->emetteur->name;
$pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
} }
// Show barcode // Show barcode
if (!empty($conf->barcode->enabled)) { if (!empty($conf->barcode->enabled))
{
$posx = 105; $posx = 105;
} else { }
else
{
$posx = $this->marge_gauche + 3; $posx = $this->marge_gauche + 3;
} }
//$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30); //$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 // 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->SetXY($this->marge_gauche+3, $this->marge_haute+3);
//$pdf->Image($logo,10, 5, 0, 24); //$pdf->Image($logo,10, 5, 0, 24);
} }
$pdf->SetDrawColor(128, 128, 128); $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 // 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->SetXY($this->marge_gauche+3, $this->marge_haute+3);
//$pdf->Image($logo,10, 5, 0, 24); //$pdf->Image($logo,10, 5, 0, 24);
@ -935,16 +1057,18 @@ class pdf_eagle extends ModelePdfStockTransfer
$pdf->SetTextColor(0, 0, 60); $pdf->SetTextColor(0, 0, 60);
$pdf->MultiCell($w, 4, $outputlangs->transnoentities("Ref")." : ".$object->ref, '', 'R'); $pdf->MultiCell($w, 4, $outputlangs->transnoentities("Ref")." : ".$object->ref, '', 'R');
// Date reelle depart // Date prévue depart
if (!empty($object->date_prevue_depart)) { if (!empty($object->date_prevue_depart))
{
$posy += 4; $posy += 4;
$pdf->SetXY($posx, $posy); $pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60); $pdf->SetTextColor(0, 0, 60);
$pdf->MultiCell($w, 4, $outputlangs->transnoentities("DatePrevueDepart")." : ".dol_print_date($object->date_prevue_depart, "day", false, $outputlangs, true), '', 'R'); $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DatePrevueDepart")." : ".dol_print_date($object->date_prevue_depart, "day", false, $outputlangs, true), '', 'R');
} }
// Date reelle arrivée // Date prévue arrivée
if (!empty($object->date_prevue_arrivee)) { if (!empty($object->date_prevue_arrivee))
{
$posy += 4; $posy += 4;
$pdf->SetXY($posx, $posy); $pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60); $pdf->SetTextColor(0, 0, 60);
@ -952,7 +1076,8 @@ class pdf_eagle extends ModelePdfStockTransfer
} }
// Date reelle depart // Date reelle depart
if (!empty($object->date_reelle_depart)) { if (!empty($object->date_reelle_depart))
{
$posy += 4; $posy += 4;
$pdf->SetXY($posx, $posy); $pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60); $pdf->SetTextColor(0, 0, 60);
@ -960,14 +1085,16 @@ class pdf_eagle extends ModelePdfStockTransfer
} }
// Date reelle arrivée // Date reelle arrivée
if (!empty($object->date_reelle_arrivee)) { if (!empty($object->date_reelle_arrivee))
{
$posy += 4; $posy += 4;
$pdf->SetXY($posx, $posy); $pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60); $pdf->SetTextColor(0, 0, 60);
$pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateReelleArrivee")." : ".dol_print_date($object->date_reelle_arrivee, "day", false, $outputlangs, true), '', 'R'); $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; $posy += 4;
$pdf->SetXY($posx, $posy); $pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60); $pdf->SetTextColor(0, 0, 60);
@ -983,13 +1110,15 @@ class pdf_eagle extends ModelePdfStockTransfer
$origin_id = $object->origin_id; $origin_id = $object->origin_id;
// TODO move to external function // TODO move to external function
if (!empty($conf->$origin->enabled)) { // commonly $origin='commande' if (!empty($conf->$origin->enabled)) // commonly $origin='commande'
{
$outputlangs->load('orders'); $outputlangs->load('orders');
$classname = ucfirst($origin); $classname = ucfirst($origin);
$linkedobject = new $classname($this->db); $linkedobject = new $classname($this->db);
$result = $linkedobject->fetch($origin_id); $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 //$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
$pdf->SetFont('', '', $default_font_size - 2); $pdf->SetFont('', '', $default_font_size - 2);
@ -1004,7 +1133,8 @@ class pdf_eagle extends ModelePdfStockTransfer
} }
} }
if ($showaddress) { if ($showaddress)
{
// Sender properties // Sender properties
$carac_emetteur = ''; $carac_emetteur = '';
// Add internal contact of origin element if defined // Add internal contact of origin element if defined
@ -1012,7 +1142,8 @@ class pdf_eagle extends ModelePdfStockTransfer
$arrayidcontact = $object->getIdContact('external', 'STFROM'); $arrayidcontact = $object->getIdContact('external', 'STFROM');
$usecontact = false; $usecontact = false;
if (count($arrayidcontact) > 0) { if (count($arrayidcontact) > 0)
{
/*$object->fetch_user(reset($arrayidcontact)); /*$object->fetch_user(reset($arrayidcontact));
$carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";*/ $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";*/
$usecontact = true; $usecontact = true;
@ -1022,9 +1153,9 @@ class pdf_eagle extends ModelePdfStockTransfer
if ($usecontact) $thirdparty = $object->contact; if ($usecontact) $thirdparty = $object->contact;
else $thirdparty = $this->emetteur; 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); else $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
// Show sender // Show sender
@ -1061,7 +1192,8 @@ class pdf_eagle extends ModelePdfStockTransfer
// If SHIPPING contact defined, we use it // If SHIPPING contact defined, we use it
$usecontact = false; $usecontact = false;
$arrayidcontact = $object->getIdContact('external', 'STDEST'); $arrayidcontact = $object->getIdContact('external', 'STDEST');
if (count($arrayidcontact) > 0) { if (count($arrayidcontact) > 0)
{
$usecontact = true; $usecontact = true;
$result = $object->fetch_contact($arrayidcontact[0]); $result = $object->fetch_contact($arrayidcontact[0]);
} }
@ -1074,7 +1206,7 @@ class pdf_eagle extends ModelePdfStockTransfer
$thirdparty = $object->thirdparty; $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); $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact : null), $usecontact, 'targetwithdetails', $object);

View File

@ -8,6 +8,7 @@
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com> * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es> * Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2018-2019 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2018-2019 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -218,35 +219,49 @@ class pdf_eagle_proforma extends ModelePDFCommandes
// Loop on each lines to detect if there is at least one image to show // Loop on each lines to detect if there is at least one image to show
$realpatharray = array(); $realpatharray = array();
$this->atleastonephoto = false; $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); $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; if (empty($object->lines[$i]->fk_product)) continue;
$objphoto->fetch($object->lines[$i]->fk_product); $objphoto->fetch($object->lines[$i]->fk_product);
//var_dump($objphoto->ref);exit; //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[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).'/'; $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[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 $pdir[1] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; // alternative
} }
$arephoto = false; $arephoto = false;
foreach ($pdir as $midir) { foreach ($pdir as $midir)
if (!$arephoto) { {
if (!$arephoto)
{
$dir = $conf->product->dir_output.'/'.$midir; $dir = $conf->product->dir_output.'/'.$midir;
foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) { 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 (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']; $filename = $obj['photo_vignette'];
} else { }
else
{
$filename = $obj['photo']; $filename = $obj['photo'];
} }
} else { }
else
{
$filename = $obj['photo']; $filename = $obj['photo'];
} }
@ -263,31 +278,39 @@ class pdf_eagle_proforma extends ModelePDFCommandes
if ($conf->stocktransfer->dir_output) { if ($conf->stocktransfer->dir_output)
{
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$deja_regle = 0; $deja_regle = 0;
// Definition of $dir and $file // Definition of $dir and $file
if ($object->specimen) { if ($object->specimen)
{
$dir = $conf->stocktransfer->multidir_output[$conf->entity]; $dir = $conf->stocktransfer->multidir_output[$conf->entity];
$file = $dir."/SPECIMEN.pdf"; $file = $dir."/SPECIMEN.pdf";
} else { }
else
{
$objectref = dol_sanitizeFileName($object->ref); $objectref = dol_sanitizeFileName($object->ref);
$dir = $conf->stocktransfer->multidir_output[$conf->entity]."/".$object->element."/".$objectref; $dir = $conf->stocktransfer->multidir_output[$conf->entity]."/".$object->element."/".$objectref;
$file = $dir."/".$objectref.".pdf"; $file = $dir."/".$objectref.".pdf";
} }
if (!file_exists($dir)) { if (!file_exists($dir))
if (dol_mkdir($dir) < 0) { {
if (dol_mkdir($dir) < 0)
{
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return 0; return 0;
} }
} }
if (file_exists($dir)) { if (file_exists($dir))
{
// Add pdfgeneration hook // Add pdfgeneration hook
if (!is_object($hookmanager)) { if (!is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager = new HookManager($this->db); $hookmanager = new HookManager($this->db);
} }
@ -305,13 +328,15 @@ 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 $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) $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->setPrintHeader(false);
$pdf->setPrintFooter(false); $pdf->setPrintFooter(false);
} }
$pdf->SetFont(pdf_getPDFFont($outputlangs)); $pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File // 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); $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
$tplidx = $pdf->importPage(1); $tplidx = $pdf->importPage(1);
} }
@ -352,9 +377,11 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10); $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
// Incoterm // Incoterm
if ($conf->incoterm->enabled) { if ($conf->incoterm->enabled)
{
$desc_incoterms = $object->getIncotermsForPDF(); $desc_incoterms = $object->getIncotermsForPDF();
if ($desc_incoterms) { if ($desc_incoterms)
{
$tab_top -= 2; $tab_top -= 2;
$pdf->SetFont('', '', $default_font_size - 1); $pdf->SetFont('', '', $default_font_size - 1);
@ -372,9 +399,11 @@ class pdf_eagle_proforma extends ModelePDFCommandes
// Displays notes // Displays notes
$notetoshow = empty($object->note_public) ? '' : $object->note_public; $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 // Get first sale rep
if (is_object($object->thirdparty)) { if (is_object($object->thirdparty))
{
$salereparray = $object->thirdparty->getSalesRepresentatives($user); $salereparray = $object->thirdparty->getSalesRepresentatives($user);
$salerepobj = new User($this->db); $salerepobj = new User($this->db);
$salerepobj->fetch($salereparray[0]['id']); $salerepobj->fetch($salereparray[0]['id']);
@ -384,12 +413,14 @@ class pdf_eagle_proforma extends ModelePDFCommandes
// Extrafields in note // Extrafields in note
$extranote = $this->getExtrafieldsInHtml($object, $outputlangs); $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
if (!empty($extranote)) { if (!empty($extranote))
{
$notetoshow = dol_concatdesc($notetoshow, $extranote); $notetoshow = dol_concatdesc($notetoshow, $extranote);
} }
$pagenb = $pdf->getPage(); $pagenb = $pdf->getPage();
if ($notetoshow) { if ($notetoshow)
{
$tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite; $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
$pageposbeforenote = $pagenb; $pageposbeforenote = $pagenb;
@ -408,7 +439,8 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$pageposafternote = $pdf->getPage(); $pageposafternote = $pdf->getPage();
$posyafter = $pdf->GetY(); $posyafter = $pdf->GetY();
if ($pageposafternote > $pageposbeforenote) { if ($pageposafternote > $pageposbeforenote)
{
$pdf->rollbackTransaction(true); $pdf->rollbackTransaction(true);
// prepare pages to receive notes // prepare pages to receive notes
@ -432,7 +464,8 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$posyafter = $pdf->GetY(); $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); $pdf->AddPage('', '', true);
$pagenb++; $pagenb++;
$pageposafternote++; $pageposafternote++;
@ -455,7 +488,8 @@ class pdf_eagle_proforma extends ModelePDFCommandes
if ($i > $pageposbeforenote) { if ($i > $pageposbeforenote) {
$height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter); $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
$pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
} else { }
else {
$height_note = $this->page_hauteur - ($tab_top + $heightforfooter); $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
$pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1); $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
} }
@ -473,7 +507,8 @@ class pdf_eagle_proforma extends ModelePDFCommandes
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
$height_note = $posyafter - $tab_top_newpage; $height_note = $posyafter - $tab_top_newpage;
$pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
} else // No pagebreak }
else // No pagebreak
{ {
$pdf->commitTransaction(); $pdf->commitTransaction();
$posyafter = $pdf->GetY(); $posyafter = $pdf->GetY();
@ -481,7 +516,8 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1); $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 // not enough space, need to add page
$pdf->AddPage('', '', true); $pdf->AddPage('', '', true);
$pagenb++; $pagenb++;
@ -496,7 +532,9 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$tab_height = $tab_height - $height_note; $tab_height = $tab_height - $height_note;
$tab_top = $posyafter + 6; $tab_top = $posyafter + 6;
} else { }
else
{
$height_note = 0; $height_note = 0;
} }
@ -514,7 +552,8 @@ class pdf_eagle_proforma extends ModelePDFCommandes
// Loop on each lines // Loop on each lines
$pageposbeforeprintlines = $pdf->getPage(); $pageposbeforeprintlines = $pdf->getPage();
$pagenb = $pageposbeforeprintlines; $pagenb = $pageposbeforeprintlines;
for ($i = 0; $i < $nblines; $i++) { for ($i = 0; $i < $nblines; $i++)
{
$curY = $nexY; $curY = $nexY;
$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
$pdf->SetTextColor(0, 0, 0); $pdf->SetTextColor(0, 0, 0);
@ -531,9 +570,11 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$showpricebeforepagebreak = 1; $showpricebeforepagebreak = 1;
$posYAfterImage = 0; $posYAfterImage = 0;
if ($this->getColumnStatus('photo')) { if ($this->getColumnStatus('photo'))
{
// We start with Photo of product line // 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); $pdf->AddPage('', '', true);
if (!empty($tplidx)) $pdf->useTemplate($tplidx); if (!empty($tplidx)) $pdf->useTemplate($tplidx);
$pdf->setPage($pageposbefore + 1); $pdf->setPage($pageposbefore + 1);
@ -543,29 +584,34 @@ class pdf_eagle_proforma extends ModelePDFCommandes
// Allows data in the first page if description is long enough to break in multiples pages // 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)) if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
$showpricebeforepagebreak = 1; $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($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 // $pdf->Image does not increase value return by getY, so we save it manually
$posYAfterImage = $curY + $imglinesize['height']; $posYAfterImage = $curY + $imglinesize['height'];
} }
} }
if ($this->getColumnStatus('desc')) { if ($this->getColumnStatus('desc'))
{
$pdf->startTransaction(); $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]->fetch_product();
$object->lines[$i]->label = $object->lines[$i]->product->label; $object->lines[$i]->label = $object->lines[$i]->product->label;
$object->lines[$i]->description = $object->lines[$i]->product->description; $object->lines[$i]->description = $object->lines[$i]->product->description;
$object->lines[$i]->fk_unit = $object->lines[$i]->product->fk_unit;
} }
$this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc); $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
$pageposafter = $pdf->getPage(); $pageposafter = $pdf->getPage();
if ($pageposafter > $pageposbefore) { // There is a pagebreak if ($pageposafter > $pageposbefore) // There is a pagebreak
{
$pdf->rollbackTransaction(true); $pdf->rollbackTransaction(true);
$pageposafter = $pageposbefore; $pageposafter = $pageposbefore;
//print $pageposafter.'-'.$pageposbefore;exit; //print $pageposafter.'-'.$pageposbefore;exit;
@ -574,21 +620,27 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc); $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
$pageposafter = $pdf->getPage(); $pageposafter = $pdf->getPage();
$posyafter = $pdf->GetY(); $posyafter = $pdf->GetY();
if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text 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 ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page
{
$pdf->AddPage('', '', true); $pdf->AddPage('', '', true);
if (!empty($tplidx)) $pdf->useTemplate($tplidx); if (!empty($tplidx)) $pdf->useTemplate($tplidx);
//if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); //if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
$pdf->setPage($pageposafter + 1); $pdf->setPage($pageposafter + 1);
} }
} else { }
else
{
// We found a page break // We found a page break
// Allows data in the first page if description is long enough to break in multiples pages // 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)) if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
$showpricebeforepagebreak = 1; $showpricebeforepagebreak = 1;
else $showpricebeforepagebreak = 0; else
$showpricebeforepagebreak = 0;
} }
} else // No pagebreak }
else // No pagebreak
{ {
$pdf->commitTransaction(); $pdf->commitTransaction();
} }
@ -613,14 +665,16 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font
// VAT Rate // VAT Rate
if ($this->getColumnStatus('vat')) { if ($this->getColumnStatus('vat'))
{
$vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
$this->printStdColumnContent($pdf, $curY, 'vat', $vat_rate); $this->printStdColumnContent($pdf, $curY, 'vat', $vat_rate);
$nexY = max($pdf->GetY(), $nexY); $nexY = max($pdf->GetY(), $nexY);
} }
// Unit price before discount // Unit price before discount
if ($this->getColumnStatus('subprice')) { if ($this->getColumnStatus('subprice'))
{
$pmp = $object->lines[$i]->pmp; $pmp = $object->lines[$i]->pmp;
$this->printStdColumnContent($pdf, $curY, 'subprice', price($pmp)); $this->printStdColumnContent($pdf, $curY, 'subprice', price($pmp));
$nexY = max($pdf->GetY(), $nexY); $nexY = max($pdf->GetY(), $nexY);
@ -628,7 +682,8 @@ class pdf_eagle_proforma extends ModelePDFCommandes
// Quantity // Quantity
// Enough for 6 chars // Enough for 6 chars
if ($this->getColumnStatus('qty')) { if ($this->getColumnStatus('qty'))
{
$qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
$this->printStdColumnContent($pdf, $curY, 'qty', $qty); $this->printStdColumnContent($pdf, $curY, 'qty', $qty);
$nexY = max($pdf->GetY(), $nexY); $nexY = max($pdf->GetY(), $nexY);
@ -636,21 +691,24 @@ class pdf_eagle_proforma extends ModelePDFCommandes
// Unit // Unit
if ($this->getColumnStatus('unit')) { if ($this->getColumnStatus('unit'))
{
$unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager); $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
$this->printStdColumnContent($pdf, $curY, 'unit', $unit); $this->printStdColumnContent($pdf, $curY, 'unit', $unit);
$nexY = max($pdf->GetY(), $nexY); $nexY = max($pdf->GetY(), $nexY);
} }
// Discount on line // 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); $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
$this->printStdColumnContent($pdf, $curY, 'discount', $remise_percent); $this->printStdColumnContent($pdf, $curY, 'discount', $remise_percent);
$nexY = max($pdf->GetY(), $nexY); $nexY = max($pdf->GetY(), $nexY);
} }
// Total HT line // Total HT line
if ($this->getColumnStatus('totalexcltax')) { if ($this->getColumnStatus('totalexcltax'))
{
$pmp_qty = $pmp * $object->lines[$i]->qty; $pmp_qty = $pmp * $object->lines[$i]->qty;
$this->printStdColumnContent($pdf, $curY, 'totalexcltax', price($pmp_qty)); $this->printStdColumnContent($pdf, $curY, 'totalexcltax', price($pmp_qty));
$nexY = max($pdf->GetY(), $nexY); $nexY = max($pdf->GetY(), $nexY);
@ -659,7 +717,8 @@ class pdf_eagle_proforma extends ModelePDFCommandes
// Extrafields // Extrafields
if (!empty($object->lines[$i]->array_options)) { if (!empty($object->lines[$i]->array_options)) {
foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) { foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
if ($this->getColumnStatus($extrafieldColKey)) { if ($this->getColumnStatus($extrafieldColKey))
{
$extrafieldValue = $this->getExtrafieldContent($object->lines[$i], $extrafieldColKey); $extrafieldValue = $this->getExtrafieldContent($object->lines[$i], $extrafieldColKey);
$this->printStdColumnContent($pdf, $curY, $extrafieldColKey, $extrafieldValue); $this->printStdColumnContent($pdf, $curY, $extrafieldColKey, $extrafieldValue);
$nexY = max($pdf->GetY(), $nexY); $nexY = max($pdf->GetY(), $nexY);
@ -698,7 +757,8 @@ class pdf_eagle_proforma extends ModelePDFCommandes
// Retrieve type from database for backward compatibility with old records // 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 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); $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
$localtax1_type = $localtaxtmp_array[0]; $localtax1_type = $localtaxtmp_array[0];
$localtax2_type = $localtaxtmp_array[2]; $localtax2_type = $localtaxtmp_array[2];
@ -715,7 +775,8 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$this->tva[$vatrate] += $tvaligne; $this->tva[$vatrate] += $tvaligne;
// Add line // 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->setPage($pageposafter);
$pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80))); $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
//$pdf->SetDrawColor(190,190,200); //$pdf->SetDrawColor(190,190,200);
@ -725,11 +786,15 @@ class pdf_eagle_proforma extends ModelePDFCommandes
// Detect if some page were added automatically and output _tableau for past pages // Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter) { while ($pagenb < $pageposafter)
{
$pdf->setPage($pagenb); $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); $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->_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); $this->_pagefoot($pdf, $object, $outputlangs, 1);
@ -738,10 +803,14 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. $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 (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 (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
if ($pagenb == $pageposafter) { {
if ($pagenb == $pageposafter)
{
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code); $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->_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); $this->_pagefoot($pdf, $object, $outputlangs, 1);
@ -756,7 +825,8 @@ class pdf_eagle_proforma extends ModelePDFCommandes
// Show square // Show square
if ($pagenb == $pageposbeforeprintlines) if ($pagenb == $pageposbeforeprintlines)
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code); $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; $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
// Affiche zone infos // Affiche zone infos
@ -787,7 +857,8 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
global $action; global $action;
$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $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->error = $hookmanager->error;
$this->errors = $hookmanager->errors; $this->errors = $hookmanager->errors;
} }
@ -798,11 +869,15 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$this->result = array('fullpath'=>$file); $this->result = array('fullpath'=>$file);
return 1; // No error return 1; // No error
} else { }
else
{
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return 0; return 0;
} }
} else { }
else
{
$this->error = $langs->transnoentities("ErrorConstantNotDefined", "STOCKTRANSFER_OUTPUTDIR"); $this->error = $langs->transnoentities("ErrorConstantNotDefined", "STOCKTRANSFER_OUTPUTDIR");
return 0; return 0;
} }
@ -838,7 +913,8 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$pdf->SetFont('', '', $default_font_size - 1); $pdf->SetFont('', '', $default_font_size - 1);
// If France, show VAT mention if not applicable // 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->SetFont('', 'B', $default_font_size - 2);
$pdf->SetXY($this->marge_gauche, $posy); $pdf->SetXY($this->marge_gauche, $posy);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
@ -849,7 +925,8 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$posxval = 52; $posxval = 52;
// Show payments conditions // 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->SetFont('', 'B', $default_font_size - 2);
$pdf->SetXY($this->marge_gauche, $posy); $pdf->SetXY($this->marge_gauche, $posy);
$titre = $outputlangs->transnoentities("PaymentConditions").':'; $titre = $outputlangs->transnoentities("PaymentConditions").':';
@ -882,17 +959,18 @@ class pdf_eagle_proforma extends ModelePDFCommandes
/* TODO /* TODO
else if (! empty($object->availability_code)) else if (! empty($object->availability_code))
{ {
$pdf->SetXY($this->marge_gauche, $posy); $pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetTextColor(200,0,0); $pdf->SetTextColor(200,0,0);
$pdf->SetFont('','B', $default_font_size - 2); $pdf->SetFont('','B', $default_font_size - 2);
$pdf->MultiCell(80, 3, $outputlangs->transnoentities("AvailabilityPeriod").': '.,0,'L',0); $pdf->MultiCell(80, 3, $outputlangs->transnoentities("AvailabilityPeriod").': '.,0,'L',0);
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$posy=$pdf->GetY()+1; $posy=$pdf->GetY()+1;
}*/ }*/
// Show planed date of delivery // Show planed date of delivery
if (!empty($object->date_livraison)) { if (!empty($object->date_livraison))
{
$outputlangs->load("sendings"); $outputlangs->load("sendings");
$pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetFont('', 'B', $default_font_size - 2);
$pdf->SetXY($this->marge_gauche, $posy); $pdf->SetXY($this->marge_gauche, $posy);
@ -904,7 +982,9 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$pdf->MultiCell(80, 4, $dlp, 0, 'L'); $pdf->MultiCell(80, 4, $dlp, 0, 'L');
$posy = $pdf->GetY() + 1; $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->SetFont('', 'B', $default_font_size - 2);
$pdf->SetXY($this->marge_gauche, $posy); $pdf->SetXY($this->marge_gauche, $posy);
$titre = $outputlangs->transnoentities("AvailabilityPeriod").':'; $titre = $outputlangs->transnoentities("AvailabilityPeriod").':';
@ -937,10 +1017,13 @@ class pdf_eagle_proforma extends ModelePDFCommandes
} }
// Show payment mode CHQ // 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 // Si mode reglement non force ou si force a CHQ
if (!empty($conf->global->FACTURE_CHQ_NUMBER)) { if (!empty($conf->global->FACTURE_CHQ_NUMBER))
if ($conf->global->FACTURE_CHQ_NUMBER > 0) { {
if ($conf->global->FACTURE_CHQ_NUMBER > 0)
{
$account = new Account($this->db); $account = new Account($this->db);
$account->fetch($conf->global->FACTURE_CHQ_NUMBER); $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
@ -949,20 +1032,23 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0); $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0);
$posy = $pdf->GetY() + 1; $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->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('', '', $default_font_size - 3); $pdf->SetFont('', '', $default_font_size - 3);
$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0); $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
$posy = $pdf->GetY() + 2; $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->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('', 'B', $default_font_size - 3); $pdf->SetFont('', 'B', $default_font_size - 3);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0); $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
$posy = $pdf->GetY() + 1; $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->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('', '', $default_font_size - 3); $pdf->SetFont('', '', $default_font_size - 3);
$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0); $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
@ -973,8 +1059,10 @@ class pdf_eagle_proforma extends ModelePDFCommandes
} }
// If payment mode not forced or forced to VIR, show payment with BAN // 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->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->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); $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 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); $account = new Account($this->db);
@ -1015,7 +1103,8 @@ class pdf_eagle_proforma extends ModelePDFCommandes
// Tableau total // Tableau total
$col1x = 120; $col2x = 170; $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; $col2x -= 20;
} }
$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x); $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
@ -1064,7 +1153,8 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT');
if (!empty($object->paye)) $resteapayer = 0; if (!empty($object->paye)) $resteapayer = 0;
if ($deja_regle > 0) { if ($deja_regle > 0)
{
// Already paid + Deposits // Already paid + Deposits
$index++; $index++;
@ -1119,7 +1209,8 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$pdf->SetTextColor(0, 0, 0); $pdf->SetTextColor(0, 0, 0);
$pdf->SetFont('', '', $default_font_size - 2); $pdf->SetFont('', '', $default_font_size - 2);
if (empty($hidetop)) { if (empty($hidetop))
{
$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4); $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
@ -1169,7 +1260,8 @@ class pdf_eagle_proforma extends ModelePDFCommandes
pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
// Show Draft Watermark // 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); pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK);
} }
@ -1182,25 +1274,34 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$pdf->SetXY($this->marge_gauche, $posy); $pdf->SetXY($this->marge_gauche, $posy);
// Logo // Logo
if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO)) { if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
if ($this->emetteur->logo) { {
if ($this->emetteur->logo)
{
$logodir = $conf->mycompany->dir_output; $logodir = $conf->mycompany->dir_output;
if (!empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity]; 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; $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
} else { }
else {
$logo = $logodir.'/logos/'.$this->emetteur->logo; $logo = $logodir.'/logos/'.$this->emetteur->logo;
} }
if (is_readable($logo)) { if (is_readable($logo))
{
$height = pdf_getHeightForLogo($logo); $height = pdf_getHeightForLogo($logo);
$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
} else { }
else
{
$pdf->SetTextColor(200, 0, 0); $pdf->SetTextColor(200, 0, 0);
$pdf->SetFont('', 'B', $default_font_size - 2); $pdf->SetFont('', 'B', $default_font_size - 2);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
} }
} else { }
else
{
$text = $this->emetteur->name; $text = $this->emetteur->name;
$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
} }
@ -1223,7 +1324,8 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$pdf->SetFont('', '', $default_font_size - 1); $pdf->SetFont('', '', $default_font_size - 1);
// Date prévue depart // Date prévue depart
if (!empty($object->date_prevue_depart)) { if (!empty($object->date_prevue_depart))
{
$posy += 4; $posy += 4;
$pdf->SetXY($posx, $posy); $pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60); $pdf->SetTextColor(0, 0, 60);
@ -1231,7 +1333,8 @@ class pdf_eagle_proforma extends ModelePDFCommandes
} }
// Date prévue arrivée // Date prévue arrivée
if (!empty($object->date_prevue_arrivee)) { if (!empty($object->date_prevue_arrivee))
{
$posy += 4; $posy += 4;
$pdf->SetXY($posx, $posy); $pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60); $pdf->SetTextColor(0, 0, 60);
@ -1239,7 +1342,8 @@ class pdf_eagle_proforma extends ModelePDFCommandes
} }
// Date reelle depart // Date reelle depart
if (!empty($object->date_reelle_depart)) { if (!empty($object->date_reelle_depart))
{
$posy += 4; $posy += 4;
$pdf->SetXY($posx, $posy); $pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60); $pdf->SetTextColor(0, 0, 60);
@ -1247,23 +1351,27 @@ class pdf_eagle_proforma extends ModelePDFCommandes
} }
// Date reelle arrivée // Date reelle arrivée
if (!empty($object->date_reelle_arrivee)) { if (!empty($object->date_reelle_arrivee))
{
$posy += 4; $posy += 4;
$pdf->SetXY($posx, $posy); $pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60); $pdf->SetTextColor(0, 0, 60);
$pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateReelleArrivee")." : ".dol_print_date($object->date_reelle_arrivee, "day", false, $outputlangs, true), '', 'R'); $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; $posy += 5;
$pdf->SetXY($posx, $posy); $pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60); $pdf->SetTextColor(0, 0, 60);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R'); $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(); $object->fetch_projet();
if (!empty($object->project->ref)) { if (!empty($object->project->ref))
{
$posy += 3; $posy += 3;
$pdf->SetXY($posx, $posy); $pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60); $pdf->SetTextColor(0, 0, 60);
@ -1271,9 +1379,11 @@ class pdf_eagle_proforma extends ModelePDFCommandes
} }
} }
if (!empty($conf->global->PDF_SHOW_PROJECT)) { if (!empty($conf->global->PDF_SHOW_PROJECT))
{
$object->fetch_projet(); $object->fetch_projet();
if (!empty($object->project->ref)) { if (!empty($object->project->ref))
{
$posy += 3; $posy += 3;
$pdf->SetXY($posx, $posy); $pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60); $pdf->SetTextColor(0, 0, 60);
@ -1281,7 +1391,8 @@ 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; $posy += 4;
$pdf->SetXY($posx, $posy); $pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60); $pdf->SetTextColor(0, 0, 60);
@ -1289,9 +1400,11 @@ class pdf_eagle_proforma extends ModelePDFCommandes
} }
// Get contact // 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'); $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
if (count($arrayidcontact) > 0) { if (count($arrayidcontact) > 0)
{
$usertmp = new User($this->db); $usertmp = new User($this->db);
$usertmp->fetch($arrayidcontact[0]); $usertmp->fetch($arrayidcontact[0]);
$posy += 4; $posy += 4;
@ -1307,11 +1420,13 @@ class pdf_eagle_proforma extends ModelePDFCommandes
// Show list of linked objects // Show list of linked objects
$current_y = $pdf->getY(); $current_y = $pdf->getY();
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); $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; $top_shift = $pdf->getY() - $current_y;
} }
if ($showaddress) { if ($showaddress)
{
// Sender properties // Sender properties
$carac_emetteur = ''; $carac_emetteur = '';
// Add internal contact of origin element if defined // Add internal contact of origin element if defined
@ -1319,7 +1434,8 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$arrayidcontact = $object->getIdContact('external', 'STFROM'); $arrayidcontact = $object->getIdContact('external', 'STFROM');
$usecontact = false; $usecontact = false;
if (count($arrayidcontact) > 0) { if (count($arrayidcontact) > 0)
{
/*$object->fetch_user(reset($arrayidcontact)); /*$object->fetch_user(reset($arrayidcontact));
$carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";*/ $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";*/
$usecontact = true; $usecontact = true;
@ -1329,9 +1445,9 @@ class pdf_eagle_proforma extends ModelePDFCommandes
if ($usecontact) $thirdparty = $object->contact; if ($usecontact) $thirdparty = $object->contact;
else $thirdparty = $this->emetteur; 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); else $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
// Show sender // Show sender
@ -1368,7 +1484,8 @@ class pdf_eagle_proforma extends ModelePDFCommandes
// If SHIPPING contact defined, we use it // If SHIPPING contact defined, we use it
$usecontact = false; $usecontact = false;
$arrayidcontact = $object->getIdContact('external', 'STDEST'); $arrayidcontact = $object->getIdContact('external', 'STDEST');
if (count($arrayidcontact) > 0) { if (count($arrayidcontact) > 0)
{
$usecontact = true; $usecontact = true;
$result = $object->fetch_contact($arrayidcontact[0]); $result = $object->fetch_contact($arrayidcontact[0]);
} }
@ -1381,7 +1498,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$thirdparty = $object->thirdparty; $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); $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact : null), $usecontact, 'targetwithdetails', $object);
@ -1514,7 +1631,8 @@ class pdf_eagle_proforma extends ModelePDFCommandes
'border-left' => false, // remove left line separator '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; $this->cols['photo']['status'] = true;
} }
@ -1541,7 +1659,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes
'width' => 19, // in mm 'width' => 19, // in mm
'status' => true, 'status' => true,
'title' => array( 'title' => array(
'textkey' => 'PriceUHT' 'textkey' => 'PMPValueShort'
), ),
'border-left' => true, // add left line separator 'border-left' => true, // add left line separator
); );
@ -1602,7 +1720,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes
'width' => 26, // in mm 'width' => 26, // in mm
'status' => true, 'status' => true,
'title' => array( 'title' => array(
'textkey' => 'TotalHT' 'textkey' => 'PMPValue'
), ),
'border-left' => true, // add left line separator 'border-left' => true, // add left line separator
); );
@ -1622,11 +1740,16 @@ class pdf_eagle_proforma extends ModelePDFCommandes
); );
$reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook $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'); 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 $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
} else { }
else
{
$this->cols = $hookmanager->resArray; $this->cols = $hookmanager->resArray;
} }
} }

View File

@ -24,14 +24,14 @@
*/ */
// Put here all includes required by your class file // Put here all includes required by your class file
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php';
//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; //require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
/** /**
* Class for StockTransferLine * Class for StockTransferLine
*/ */
class StockTransferLine extends CommonObject class StockTransferLine extends CommonObjectLine
{ {
/** /**
* @var string ID to identify managed object. * @var string ID to identify managed object.

View File

@ -1,6 +1,5 @@
<?php <?php
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) ---Put here your own copyright and developer email--- * Copyright (C) ---Put here your own copyright and developer email---
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -62,6 +61,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/stock/stocktransfer/class/stocktransfer.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/stocktransfer/class/stocktransfer.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/stock/stocktransfer/class/stocktransferline.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/stocktransfer/class/stocktransferline.class.php';
@ -102,7 +102,8 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen
// Initialize array of search criterias // Initialize array of search criterias
$search_all = trim(GETPOST("search_all", 'alpha')); $search_all = trim(GETPOST("search_all", 'alpha'));
$search = array(); $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'); if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha');
} }
@ -140,15 +141,16 @@ $parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $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 ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook)) { if (empty($reshook))
{
$error = 0; $error = 0;
$backurlforlist = dol_buildpath('/product/stock/stocktransfer/stocktransfer_list.php', 1); $backurlforlist = dol_buildpath('/stocktransfer/stocktransfer_list.php', 1);
if (empty($backtopage) || ($cancel && empty($id))) { if (empty($backtopage) || ($cancel && empty($id))) {
if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) { if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist; if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist;
else $backtopage = dol_buildpath('/product/stock/stocktransfer/stocktransfer_card.php', 1).'?id='.($id > 0 ? $id : '__ID__'); else $backtopage = dol_buildpath('/stocktransfer/stocktransfer_card.php', 1).'?id='.($id > 0 ? $id : '__ID__');
} }
} }
$triggermodname = 'STOCKTRANSFER_STOCKTRANSFER_MODIFY'; // Name of trigger action code to execute when we modify record $triggermodname = 'STOCKTRANSFER_STOCKTRANSFER_MODIFY'; // Name of trigger action code to execute when we modify record
@ -168,27 +170,30 @@ if (empty($reshook)) {
// Action to build doc // Action to build doc
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; 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'); $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')); $object->setProject(GETPOST('projectid', 'int'));
} }
if ($action == 'addline' && $permissiontoadd) { if($action == 'addline' && $permissiontoadd) {
if ($qty <= 0) {
if($qty <= 0) {
$error++; $error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Qty")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Qty")), null, 'errors');
$action = 'view'; $action = 'view';
} }
if ($fk_warehouse_source <= 0) { if($fk_warehouse_source <= 0) {
$error++; $error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseSource")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseSource")), null, 'errors');
$action = 'view'; $action = 'view';
} }
if ($fk_warehouse_destination <= 0) { if($fk_warehouse_destination <= 0) {
$error++; $error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseTarget")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseTarget")), null, 'errors');
$action = 'view'; $action = 'view';
@ -196,23 +201,25 @@ if (empty($reshook)) {
$prod = new Product($db); $prod = new Product($db);
$prod->fetch($fk_product); $prod->fetch($fk_product);
if ($prod->hasbatch()) { if ($prod->hasbatch())
if (empty($batch)) { {
if (empty($batch))
{
$error++; $error++;
$langs->load("errors"); $langs->load("errors");
setEventMessages($langs->transnoentities("ErrorTryToMakeMoveOnProductRequiringBatchData", $prod->getNomUrl()), null, 'errors'); setEventMessages($langs->trans("ErrorTryToMakeMoveOnProductRequiringBatchData", $prod->ref), null, 'errors');
} }
} else { } else {
if (!empty($batch)) { if(!empty($batch)) {
$error++; $error++;
setEventMessages($langs->transnoentities('StockTransferNoBatchForProduct', $prod->getNomUrl()), '', 'errors'); setEventMessages($langs->trans('StockTransferNoBatchForProduct', $prod->getNomUrl()), '', 'errors');
} }
} }
if (empty($error)) { if(empty($error)) {
$line = new StockTransferLine($db); $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.'"' ).')')); $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->fk_stocktransfer = $id;
$line->qty += $qty; $line->qty += $qty;
$line->fk_warehouse_source = $fk_warehouse_source; $line->fk_warehouse_source = $fk_warehouse_source;
@ -221,27 +228,28 @@ if (empty($reshook)) {
$line->batch = $batch; $line->batch = $batch;
$line->pmp = $prod->pmp; $line->pmp = $prod->pmp;
if ($line->id > 0) $line->update($user); if($line->id > 0) $line->update($user);
else { else {
$line->rang = count($object->lines) + 1; $line->rang = count($object->lines) + 1;
$line->create($user); $line->create($user);
} }
$object->fetchLines(); $object->fetchLines();
} }
} elseif ($action === 'updateline' && $permissiontoadd) { } elseif($action === 'updateline' && $permissiontoadd) {
if ($qty <= 0) {
if($qty <= 0) {
$error++; $error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Qty")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Qty")), null, 'errors');
$action = 'editline'; $action = 'editline';
} }
if ($fk_warehouse_source <= 0) { if($fk_warehouse_source <= 0) {
$error++; $error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseSource")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseSource")), null, 'errors');
$action = 'editline'; $action = 'editline';
} }
if ($fk_warehouse_destination <= 0) { if($fk_warehouse_destination <= 0) {
$error++; $error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseTarget")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WarehouseTarget")), null, 'errors');
$action = 'editline'; $action = 'editline';
@ -249,22 +257,24 @@ if (empty($reshook)) {
$prod = new Product($db); $prod = new Product($db);
$prod->fetch($fk_product); $prod->fetch($fk_product);
if ($prod->hasbatch()) { if ($prod->hasbatch())
if (empty($batch)) { {
if (empty($batch))
{
$error++; $error++;
$langs->load("errors"); $langs->load("errors");
setEventMessages($langs->trans("ErrorTryToMakeMoveOnProductRequiringBatchData", $prod->ref), null, 'errors'); setEventMessages($langs->trans("ErrorTryToMakeMoveOnProductRequiringBatchData", $prod->ref), null, 'errors');
$action = 'editline'; $action = 'editline';
} }
} else { } else {
if (!empty($batch)) { if(!empty($batch)) {
$error++; $error++;
setEventMessages($langs->trans('StockTransferNoBatchForProduct', $prod->getNomUrl()), '', 'errors'); setEventMessages($langs->trans('StockTransferNoBatchForProduct', $prod->getNomUrl()), '', 'errors');
$action = 'editline'; $action = 'editline';
} }
} }
if (empty($error)) { if(empty($error)) {
$line = new StockTransferLine($db); $line = new StockTransferLine($db);
$line->fetch($lineid); $line->fetch($lineid);
$line->qty = $qty; $line->qty = $qty;
@ -278,18 +288,18 @@ if (empty($reshook)) {
} }
// Décrémentation // 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(); $lines = $object->getLinesArray();
if (!empty($lines)) { if(!empty($lines)) {
$db->begin(); $db->begin();
foreach ($lines as $line) { foreach ($lines as $line) {
$res = $line->doStockMovement($label, $line->fk_warehouse_source); $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(); else $db->rollback();
} }
if (empty($error)) { if(empty($error)) {
$object->setStatut($object::STATUS_TRANSFERED, $id); $object->setStatut($object::STATUS_TRANSFERED, $id);
$object->status = $object::STATUS_TRANSFERED; $object->status = $object::STATUS_TRANSFERED;
$object->date_reelle_depart = date('Y-m-d'); $object->date_reelle_depart = date('Y-m-d');
@ -299,18 +309,18 @@ if (empty($reshook)) {
} }
// Annulation décrémentation // 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(); $lines = $object->getLinesArray();
if (!empty($lines)) { if(!empty($lines)) {
$db->begin(); $db->begin();
foreach ($lines as $line) { foreach ($lines as $line) {
$res = $line->doStockMovement($label, $line->fk_warehouse_source, 0); $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(); else $db->rollback();
} }
if (empty($error)) { if(empty($error)) {
$object->setStatut($object::STATUS_VALIDATED, $id); $object->setStatut($object::STATUS_VALIDATED, $id);
$object->status = $object::STATUS_VALIDATED; $object->status = $object::STATUS_VALIDATED;
$object->date_reelle_depart = null; $object->date_reelle_depart = null;
@ -320,18 +330,18 @@ if (empty($reshook)) {
} }
// Incrémentation // 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(); $lines = $object->getLinesArray();
if (!empty($lines)) { if(!empty($lines)) {
$db->begin(); $db->begin();
foreach ($lines as $line) { foreach ($lines as $line) {
$res = $line->doStockMovement($label, $line->fk_warehouse_destination, 0); $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(); else $db->rollback();
} }
if (empty($error)) { if(empty($error)) {
$object->setStatut($object::STATUS_CLOSED, $id); $object->setStatut($object::STATUS_CLOSED, $id);
$object->status = $object::STATUS_CLOSED; $object->status = $object::STATUS_CLOSED;
$object->date_reelle_arrivee = date('Y-m-d'); $object->date_reelle_arrivee = date('Y-m-d');
@ -341,18 +351,18 @@ if (empty($reshook)) {
} }
// Annulation incrémentation // 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(); $lines = $object->getLinesArray();
if (!empty($lines)) { if(!empty($lines)) {
$db->begin(); $db->begin();
foreach ($lines as $line) { foreach ($lines as $line) {
$res = $line->doStockMovement($label, $line->fk_warehouse_destination); $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(); else $db->rollback();
} }
if (empty($error)) { if(empty($error)) {
$object->setStatut($object::STATUS_TRANSFERED, $id); $object->setStatut($object::STATUS_TRANSFERED, $id);
$object->status = $object::STATUS_TRANSFERED; $object->status = $object::STATUS_TRANSFERED;
$object->date_reelle_arrivee = null; $object->date_reelle_arrivee = null;
@ -390,8 +400,8 @@ jQuery(document).ready(function() {';
// Affichage alerte date prévue de départ si transfert concerné // Affichage alerte date prévue de départ si transfert concerné
$date_prevue_depart = $object->date_prevue_depart; $date_prevue_depart = $object->date_prevue_depart;
$date_prevue_depart_plus_delai = $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($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(!empty($date_prevue_depart) && $date_prevue_depart_plus_delai < strtotime(date('Y-m-d'))) {
print "$('.valuefield.fieldname_date_prevue_depart').append('"; print "$('.valuefield.fieldname_date_prevue_depart').append('";
print img_warning($langs->trans('Alert').' - '.$langs->trans('Late')); print img_warning($langs->trans('Alert').' - '.$langs->trans('Late'));
print "');"; print "');";
@ -402,7 +412,8 @@ print '});
// Part to create // Part to create
if ($action == 'create') { if ($action == 'create')
{
print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("StockTransfer")), '', 'object_'.$object->picto); print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("StockTransfer")), '', 'object_'.$object->picto);
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
@ -450,41 +461,43 @@ if ($action == 'create') {
} }
// Part to edit record // Part to edit record
if (($id || $ref) && $action == 'edit') { if (($id || $ref) && $action == 'edit')
{
//if($object->status < 3) { //if($object->status < 3) {
print load_fiche_titre($langs->trans("StockTransfer"), '', 'object_' . $object->picto); print load_fiche_titre($langs->trans("StockTransfer"), '', 'object_' . $object->picto);
print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">'; print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">';
print '<input type="hidden" name="token" value="' . newToken() . '">'; print '<input type="hidden" name="token" value="' . newToken() . '">';
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="id" value="' . $object->id . '">'; print '<input type="hidden" name="id" value="' . $object->id . '">';
if ($backtopage) print '<input type="hidden" name="backtopage" value="' . $backtopage . '">'; if ($backtopage) print '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
if ($backtopageforcancel) print '<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel . '">'; if ($backtopageforcancel) print '<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel . '">';
dol_fiche_head(); dol_fiche_head();
print '<table class="border centpercent tableforfieldedit">' . "\n"; print '<table class="border centpercent tableforfieldedit">' . "\n";
// Common attributes // Common attributes
include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php'; include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php';
// Other attributes // Other attributes
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php'; include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php';
print '</table>'; print '</table>';
dol_fiche_end(); dol_fiche_end();
print '<div class="center"><input type="submit" class="button" name="save" value="' . $langs->trans("Save") . '">'; print '<div class="center"><input type="submit" class="button" name="save" value="' . $langs->trans("Save") . '">';
print ' &nbsp; <input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '">'; print ' &nbsp; <input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '">';
print '</div>'; print '</div>';
print '</form>'; print '</form>';
//} else $action = 'view'; //} else $action = 'view';
} }
// Part to show record // Part to show record
if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create')))
{
$res = $object->fetch_optionals(); $res = $object->fetch_optionals();
$head = stocktransferPrepareHead($object); $head = stocktransferPrepareHead($object);
@ -493,11 +506,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$formconfirm = ''; $formconfirm = '';
// Confirmation to delete // Confirmation to delete
if ($action == 'delete') { if ($action == 'delete')
{
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteStockTransfer'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteStockTransfer'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
} }
// Confirmation to delete line // Confirmation to delete line
if ($action == 'deleteline') { if ($action == 'deleteline')
{
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
} }
// Clone confirmation // Clone confirmation
@ -505,22 +520,30 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Create an array for form // Create an array for form
$formquestion = array(); $formquestion = array();
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
} elseif ($action == 'destock') { // Destock confirmation }
// Destock confirmation
elseif ($action == 'destock') {
// Create an array for form // Create an array for form
$formquestion = array( 'text' => '', $formquestion = array( 'text' => '',
array('type' => 'text', 'name' => 'label', 'label' => $langs->trans("Label"), 'value' => $langs->trans('ConfirmDestock', $object->ref), 'size'=>40)); array('type' => 'text', 'name' => 'label', 'label' => $langs->trans("Label"), 'value' => $langs->trans('ConfirmDestock', $object->ref), 'size'=>40));
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DestockAllProduct'), '', 'confirm_destock', $formquestion, 'yes', 1); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DestockAllProduct'), '', 'confirm_destock', $formquestion, 'yes', 1);
} elseif ($action == 'destockcancel') { // Destock confirmation cancel }
// Destock confirmation cancel
elseif ($action == 'destockcancel') {
// Create an array for form // Create an array for form
$formquestion = array( 'text' => '', $formquestion = array( 'text' => '',
array('type' => 'text', 'name' => 'label', 'label' => $langs->trans("Label"), 'value' => $langs->trans('ConfirmDestockCancel', $object->ref), 'size'=>40)); array('type' => 'text', 'name' => 'label', 'label' => $langs->trans("Label"), 'value' => $langs->trans('ConfirmDestockCancel', $object->ref), 'size'=>40));
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DestockAllProductCancel'), '', 'confirm_destockcancel', $formquestion, 'yes', 1); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DestockAllProductCancel'), '', 'confirm_destockcancel', $formquestion, 'yes', 1);
} elseif ($action == 'addstock') { // Addstock confirmation }
// Addstock confirmation
elseif ($action == 'addstock') {
// Create an array for form // Create an array for form
$formquestion = array( 'text' => '', $formquestion = array( 'text' => '',
array('type' => 'text', 'name' => 'label', 'label' => $langs->trans("Label").'&nbsp;:', 'value' => $langs->trans('ConfirmAddStock', $object->ref), 'size'=>40)); array('type' => 'text', 'name' => 'label', 'label' => $langs->trans("Label").'&nbsp;:', 'value' => $langs->trans('ConfirmAddStock', $object->ref), 'size'=>40));
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('AddStockAllProduct'), '', 'confirm_addstock', $formquestion, 'yes', 1); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('AddStockAllProduct'), '', 'confirm_addstock', $formquestion, 'yes', 1);
} elseif ($action == 'addstockcancel') { // Addstock confirmation cancel }
// Addstock confirmation cancel
elseif ($action == 'addstockcancel') {
// Create an array for form // Create an array for form
$formquestion = array( 'text' => '', $formquestion = array( 'text' => '',
array('type' => 'text', 'name' => 'label', 'label' => $langs->trans("Label").'&nbsp;:', 'value' => $langs->trans('ConfirmAddStockCancel', $object->ref), 'size'=>40)); array('type' => 'text', 'name' => 'label', 'label' => $langs->trans("Label").'&nbsp;:', 'value' => $langs->trans('ConfirmAddStockCancel', $object->ref), 'size'=>40));
@ -528,7 +551,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
} }
// Confirmation of action xxxx // Confirmation of action xxxx
if ($action == 'xxx') { if ($action == 'xxx')
{
$formquestion = array(); $formquestion = array();
/* /*
$forcecombo=0; $forcecombo=0;
@ -546,7 +570,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
if ($action == 'valid' && $permissiontoadd) { if ($action == 'valid' && $permissiontoadd) {
$nextref=$object->getNextNumRef(); $nextref=$object->getNextNumRef();
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Validate'), $langs->transnoentities('ConfirmValidateStockTransfer', $nextref), 'confirm_validate', $formquestion, 0, 2); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Validate'), $langs->trans('ConfirmValidateStockTransfer', $nextref), 'confirm_validate', $formquestion, 0, 2);
} }
// Call Hook formConfirm // Call Hook formConfirm
@ -561,18 +585,20 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Object card // Object card
// ------------------------------------------------------------ // ------------------------------------------------------------
$linkback = '<a href="'.dol_buildpath('/product/stock/stocktransfer/stocktransfer_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.dol_buildpath('/stocktransfer/stocktransfer_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
$morehtmlref = '<div class="refidno">'; $morehtmlref = '<div class="refidno">';
if ($conf->societe->enabled) {
// Thirdparty // Thirdparty
if($conf->societe->enabled) {
$morehtmlref .= $langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '').'<br>'; $morehtmlref .= $langs->trans('ThirdParty') . ' : ' . (is_object($object->thirdparty) ? $object->thirdparty->getNomUrl(1) : '').'<br>';
} }
// Project // Project
if (! empty($conf->projet->enabled)) { if (! empty($conf->projet->enabled)) {
$langs->load("projects"); $langs->load("projects");
$morehtmlref.=$langs->trans('Project') . ' '; $morehtmlref.=$langs->trans('Project') . ' ';
if ($permissiontoadd) { if ($permissiontoadd)
{
//if ($action != 'classify') $morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> '; //if ($action != 'classify') $morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> ';
$morehtmlref.=' : '; $morehtmlref.=' : ';
if ($action == 'classify') { if ($action == 'classify') {
@ -636,7 +662,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
* Lines * Lines
*/ */
if (!empty($object->table_element_line)) { if (!empty($object->table_element_line))
{
// Show object lines // Show object lines
/*$result = $object->getLinesArray(); /*$result = $object->getLinesArray();
@ -693,14 +720,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
<input type="hidden" name="mode" value=""> <input type="hidden" name="mode" value="">
<input type="hidden" name="id" value="' . $object->id.'"> <input type="hidden" name="id" value="' . $object->id.'">
'; ';
if ($lineid > 0) print '<input type="hidden" name="lineid" value="'.$lineid.'" />'; if($lineid > 0) print '<input type="hidden" name="lineid" value="'.$lineid.'" />';
print '<table id="tablelines" class="liste centpercent">'; print '<table id="tablelines" class="liste centpercent">';
//print '<div class="tagtable centpercent">'; //print '<div class="tagtable centpercent">';
$param = ''; $param = '';
$conf->global->MAIN_DISABLE_WRAPPING_ON_COLUMN_TITLE=true; // Full display needed to see all column title details
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print getTitleFieldOfList($langs->trans('ProductRef'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'tagtd maxwidthonsmartphone '); print getTitleFieldOfList($langs->trans('ProductRef'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'tagtd maxwidthonsmartphone ');
if ($conf->productbatch->enabled) { if ($conf->productbatch->enabled) {
@ -709,9 +734,12 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print getTitleFieldOfList($langs->trans('WarehouseSource'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'tagtd maxwidthonsmartphone '); print getTitleFieldOfList($langs->trans('WarehouseSource'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'tagtd maxwidthonsmartphone ');
print getTitleFieldOfList($langs->trans('WarehouseTarget'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'tagtd maxwidthonsmartphone '); print getTitleFieldOfList($langs->trans('WarehouseTarget'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'tagtd maxwidthonsmartphone ');
print getTitleFieldOfList($langs->trans('Qty'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'center tagtd maxwidthonsmartphone '); print getTitleFieldOfList($langs->trans('Qty'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'center tagtd maxwidthonsmartphone ');
if ($conf->global->PRODUCT_USE_UNITS) {
print getTitleFieldOfList($langs->trans('Unit'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'tagtd maxwidthonsmartphone ');
}
print getTitleFieldOfList($langs->trans('AverageUnitPricePMPShort'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'center tagtd maxwidthonsmartphone '); print getTitleFieldOfList($langs->trans('AverageUnitPricePMPShort'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'center tagtd maxwidthonsmartphone ');
print getTitleFieldOfList($langs->trans('EstimatedStockValueShort'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'center tagtd maxwidthonsmartphone '); print getTitleFieldOfList($langs->trans('PMPValue'), 0, $_SERVER["PHP_SELF"], '', $param, '', '', $sortfield, $sortorder, 'center tagtd maxwidthonsmartphone ');
if (empty($object->status)) { if(empty($object->status)) {
print getTitleFieldOfList('', 0); print getTitleFieldOfList('', 0);
print getTitleFieldOfList('', 0); print getTitleFieldOfList('', 0);
print getTitleFieldOfList('', 0); print getTitleFieldOfList('', 0);
@ -724,7 +752,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$warehousestatics = new Entrepot($db); $warehousestatics = new Entrepot($db);
$warehousestatict = new Entrepot($db); $warehousestatict = new Entrepot($db);
foreach ($listofdata as $key => $line) { foreach ($listofdata as $key => $line)
{
$productstatic->fetch($line->fk_product); $productstatic->fetch($line->fk_product);
$warehousestatics->fetch($line->fk_warehouse_source); $warehousestatics->fetch($line->fk_warehouse_source);
$warehousestatict->fetch($line->fk_warehouse_destination); $warehousestatict->fetch($line->fk_warehouse_destination);
@ -737,33 +766,53 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<tr id="row-'.$line->id.'" class="drag drop oddeven" '.$domData.'>'; print '<tr id="row-'.$line->id.'" class="drag drop oddeven" '.$domData.'>';
print '<td class="titlefield">'; print '<td class="titlefield">';
if ($action === 'editline' && $line->id == $lineid) $form->select_produits($line->fk_product, 'fk_product', $filtertype, $limit, 0, -1, 2, '', 0, array(), 0, 0, 0, 'minwidth200imp maxwidth300', 1); if($action === 'editline' && $line->id == $lineid) $form->select_produits($line->fk_product, 'fk_product', $filtertype, $limit, 0, -1, 2, '', 0, array(), 0, 0, 0, 'minwidth200imp maxwidth300', 1);
else print $productstatic->getNomUrl(1).' - '.$productstatic->label; else print $productstatic->getNomUrl(1).' - '.$productstatic->label;
print '</td>'; print '</td>';
if ($conf->productbatch->enabled) { if ($conf->productbatch->enabled)
{
print '<td>'; print '<td>';
if ($action === 'editline' && $line->id == $lineid) print '<input type="text" value="'.$line->batch.'" name="batch" class="flat maxwidth50"/>'; if($action === 'editline' && $line->id == $lineid) print '<input type="text" value="'.$line->batch.'" name="batch" class="flat maxwidth50"/>';
else print $line->batch; else {
$productlot = new Productlot($db);
if($productlot->fetch(0, $line->fk_product, $line->batch) > 0) {
print $productlot->getNomUrl(1);
} elseif(!empty($line->batch)) print $line->batch.'&nbsp;'.img_warning($langs->trans('BatchNotFound'));;
}
print '</td>'; print '</td>';
} }
print '<td>'; print '<td>';
if ($action === 'editline' && $line->id == $lineid) print $formproduct->selectWarehouses($line->fk_warehouse_source, 'fk_warehouse_source', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200', $TExcludedWarehouseSource);
if($action === 'editline' && $line->id == $lineid) print $formproduct->selectWarehouses($line->fk_warehouse_source, 'fk_warehouse_source', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200', $TExcludedWarehouseSource);
else print $warehousestatics->getNomUrl(1); else print $warehousestatics->getNomUrl(1);
print '</td>'; print '</td>';
print '<td>'; print '<td>';
if ($action === 'editline' && $line->id == $lineid) print $formproduct->selectWarehouses($line->fk_warehouse_destination, 'fk_warehouse_destination', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200', $TExcludedWarehouseDestination); if($action === 'editline' && $line->id == $lineid) print $formproduct->selectWarehouses($line->fk_warehouse_destination,'fk_warehouse_destination', 'warehouseopen,warehouseinternal', 1, 0, 0, '', 0, 0, array(), 'minwidth200imp maxwidth200', $TExcludedWarehouseDestination);
else print $warehousestatict->getNomUrl(1); else print $warehousestatict->getNomUrl(1);
print '</td>'; print '</td>';
if ($action === 'editline' && $line->id == $lineid) print '<td class="center"><input type="text" class="flat maxwidth50" name="qty" value="'.$line->qty.'"></td>'; if($action === 'editline' && $line->id == $lineid) print '<td class="center"><input type="text" class="flat maxwidth50" name="qty" value="'.$line->qty.'"></td>';
else print '<td class="center">'.$line->qty.'</td>'; else print '<td class="center">'.$line->qty.'</td>';
if ($conf->global->PRODUCT_USE_UNITS)
{
print '<td class="linecoluseunit nowrap left">';
$label = $productstatic->getLabelOfUnit('short');
if ($label !== '') {
print $langs->trans($label);
}
print '</td>';
}
print '<td class="center">'; print '<td class="center">';
print price($line->pmp, 0, '', 1, -1, -1, $conf->currency); print price($line->pmp, 0, '', 1, -1, -1, $conf->currency);
print '</td>'; print '</td>';
print '<td class="center">'; print '<td class="center">';
print price($line->pmp * $line->qty, 0, '', 1, -1, -1, $conf->currency); print price($line->pmp * $line->qty, 0, '', 1, -1, -1, $conf->currency);
print '</td>'; print '</td>';
if (empty($object->status)) { if(empty($object->status)) {
if ($action === 'editline' && $line->id == $lineid) {
if($action === 'editline' && $line->id == $lineid) {
//print '<td class="right" colspan="2"><input type="submit" class="button" name="addline" value="' . dol_escape_htmltag($langs->trans('Save')) . '"></td>'; //print '<td class="right" colspan="2"><input type="submit" class="button" name="addline" value="' . dol_escape_htmltag($langs->trans('Save')) . '"></td>';
print '<td class="center valignmiddle" colspan="2"><input type="submit" class="button buttongen marginbottomonly" id="savelinebutton marginbottomonly" name="save" value="'.$langs->trans("Save").'"><br>'; print '<td class="center valignmiddle" colspan="2"><input type="submit" class="button buttongen marginbottomonly" id="savelinebutton marginbottomonly" name="save" value="'.$langs->trans("Save").'"><br>';
print '<input type="submit" class="button buttongen marginbottomonly" id="cancellinebutton" name="cancel" value="'.$langs->trans("Cancel").'"></td>'; print '<input type="submit" class="button buttongen marginbottomonly" id="cancellinebutton" name="cancel" value="'.$langs->trans("Cancel").'"></td>';
@ -802,9 +851,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '</tr>'; print '</tr>';
} }
if (empty($object->status) && $action !== 'editline') { if(empty($object->status) && $action !== 'editline') {
print '<tr class="oddeven">'; print '<tr class="oddeven">';
// Product // Product
print '<td class="titlefield">'; print '<td class="titlefield">';
$filtertype = 0; $filtertype = 0;
if (!empty($conf->global->STOCK_SUPPORTS_SERVICES)) $filtertype = ''; if (!empty($conf->global->STOCK_SUPPORTS_SERVICES)) $filtertype = '';
@ -827,21 +876,21 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// On stock ceux qui ne doivent pas être proposés dans la liste // On stock ceux qui ne doivent pas être proposés dans la liste
$TExcludedWarehouseSource=array(); $TExcludedWarehouseSource=array();
if (!empty($object->fk_warehouse_source)) { if(!empty($object->fk_warehouse_source)) {
$source_ent = new Entrepot($db); $source_ent = new Entrepot($db);
$source_ent->fetch($object->fk_warehouse_source); $source_ent->fetch($object->fk_warehouse_source);
foreach ($formproduct->cache_warehouses as $TDataCacheWarehouse) { foreach ($formproduct->cache_warehouses as $TDataCacheWarehouse) {
if (strpos($TDataCacheWarehouse['full_label'], $source_ent->label) === false) $TExcludedWarehouseSource[] = $TDataCacheWarehouse['id']; if(strpos($TDataCacheWarehouse['full_label'], $source_ent->label) === false) $TExcludedWarehouseSource[] = $TDataCacheWarehouse['id'];
} }
} }
// On stock ceux qui ne doivent pas être proposés dans la liste // On stock ceux qui ne doivent pas être proposés dans la liste
$TExcludedWarehouseDestination=array(); $TExcludedWarehouseDestination=array();
if (!empty($object->fk_warehouse_destination)) { if(!empty($object->fk_warehouse_destination)) {
$dest_ent = new Entrepot($db); $dest_ent = new Entrepot($db);
$dest_ent->fetch($object->fk_warehouse_destination); $dest_ent->fetch($object->fk_warehouse_destination);
foreach ($formproduct->cache_warehouses as $TDataCacheWarehouse) { foreach ($formproduct->cache_warehouses as $TDataCacheWarehouse) {
if (strpos($TDataCacheWarehouse['full_label'], $dest_ent->label) === false) $TExcludedWarehouseDestination[] = $TDataCacheWarehouse['id']; if(strpos($TDataCacheWarehouse['full_label'], $dest_ent->label) === false) $TExcludedWarehouseDestination[] = $TDataCacheWarehouse['id'];
} }
} }
@ -863,6 +912,10 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<td class="center"><input type="text" class="flat maxwidth50" name="qty" '.(!empty($error) ? 'value="'.$qty.'"' : '').'></td>'; print '<td class="center"><input type="text" class="flat maxwidth50" name="qty" '.(!empty($error) ? 'value="'.$qty.'"' : '').'></td>';
// PMP // PMP
print '<td></td>'; print '<td></td>';
if($conf->global->PRODUCT_USE_UNITS) {
// Unité
print '<td></td>';
}
// PMP * Qty // PMP * Qty
print '<td></td>'; print '<td></td>';
// Button to add line // Button to add line
@ -870,6 +923,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Grad and drop lines // Grad and drop lines
print '<td></td>'; print '<td></td>';
print '</tr>'; print '</tr>';
} }
print '</table>'; print '</table>';
@ -884,21 +938,25 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook)) { if (empty($reshook))
{
// Send // Send
if (empty($user->socid)) { if (empty($user->socid)) {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a>'."\n"; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a>'."\n";
} }
// Back to draft // Back to draft
if ($object->status == $object::STATUS_VALIDATED) { if ($object->status == $object::STATUS_VALIDATED)
if ($permissiontoadd) { {
if ($permissiontoadd)
{
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes">'.$langs->trans("SetToDraft").'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_setdraft&confirm=yes">'.$langs->trans("SetToDraft").'</a>';
} }
} }
// Modify // Modify
if ($permissiontoadd) { if ($permissiontoadd)
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit">'.$langs->trans("Modify").'</a>'."\n"; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=edit">'.$langs->trans("Modify").'</a>'."\n";
} }
/*else /*else
@ -907,26 +965,38 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
}*/ }*/
// Validate // Validate
if ($object->status == $object::STATUS_DRAFT) { if ($object->status == $object::STATUS_DRAFT)
if ($permissiontoadd) { {
if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) { if ($permissiontoadd)
{
if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0))
{
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=valid">'.$langs->trans("Validate").'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=valid">'.$langs->trans("Validate").'</a>';
} else { }
else
{
$langs->load("errors"); $langs->load("errors");
print '<a class="butActionRefused" href="" title="'.$langs->trans("ErrorAddAtLeastOneLineFirst").'">'.$langs->trans("Validate").'</a>'; print '<a class="butActionRefused" href="" title="'.$langs->trans("ErrorAddAtLeastOneLineFirst").'">'.$langs->trans("Validate").'</a>';
} }
} }
} elseif ($object->status == $object::STATUS_VALIDATED) { }
elseif($object->status == $object::STATUS_VALIDATED) {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=destock">'.$langs->trans("StockTransferDecrementation").'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=destock">'.$langs->trans("StockTransferDecrementation").'</a>';
} elseif ($object->status == $object::STATUS_TRANSFERED) { }
elseif($object->status == $object::STATUS_TRANSFERED) {
print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=destockcancel">'.$langs->trans("StockTransferDecrementationCancel").'</a>'; print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=destockcancel">'.$langs->trans("StockTransferDecrementationCancel").'</a>';
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=addstock">'.$langs->trans("StockTransferIncrementation").'</a>'; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=addstock">'.$langs->trans("StockTransferIncrementation").'</a>';
} elseif ($object->status == $object::STATUS_CLOSED) { }
elseif($object->status == $object::STATUS_CLOSED) {
print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=addstockcancel">'.$langs->trans("StockTransferIncrementationCancel").'</a>'; print '<a class="butActionDelete" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=addstockcancel">'.$langs->trans("StockTransferIncrementationCancel").'</a>';
} }
// Clone // Clone
if ($permissiontoadd) { if ($permissiontoadd)
{
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=stocktransfer">'.$langs->trans("ToClone").'</a>'."\n"; print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=stocktransfer">'.$langs->trans("ToClone").'</a>'."\n";
} }
@ -956,7 +1026,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
*/ */
// Delete (need delete permission, or if draft, just need create/modify permission) // Delete (need delete permission, or if draft, just need create/modify permission)
if ($object->status < $object::STATUS_TRANSFERED && $permissiontoadd) { if ($object->status < $object::STATUS_TRANSFERED && $permissiontoadd)
{
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans('Delete').'</a>'."\n"; print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans('Delete').'</a>'."\n";
} }
/*else /*else
@ -973,7 +1044,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$action = 'presend'; $action = 'presend';
} }
if ($action != 'presend') { if ($action != 'presend')
{
print '<div class="fichecenter"><div class="fichehalfleft">'; print '<div class="fichecenter"><div class="fichehalfleft">';
print '<a name="builddoc"></a>'; // ancre print '<a name="builddoc"></a>'; // ancre
@ -999,7 +1071,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$MAXEVENT = 10; $MAXEVENT = 10;
$morehtmlright = '<a href="'.dol_buildpath('/product/stock/stocktransfer/stocktransfer_agenda.php', 1).'?id='.$object->id.'">'; $morehtmlright = '<a href="'.dol_buildpath('/stocktransfer/stocktransfer_agenda.php', 1).'?id='.$object->id.'">';
$morehtmlright .= $langs->trans("SeeAll"); $morehtmlright .= $langs->trans("SeeAll");
$morehtmlright .= '</a>'; $morehtmlright .= '</a>';