Fixing style errors.

This commit is contained in:
stickler-ci 2021-08-03 14:39:28 +00:00
parent ee52fc162c
commit 2577936670
3 changed files with 304 additions and 560 deletions

View File

@ -211,23 +211,18 @@ 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_STOCKTRANSFER_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;
} }
@ -237,17 +232,12 @@ 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'];
} }
@ -267,35 +257,27 @@ class pdf_eagle extends ModelePdfStockTransfer
if (!empty($conf->global->MAIN_GENERATE_STOCKTRANSFER_WITH_PICTURE)) $this->posxpicture -= (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images if (!empty($conf->global->MAIN_GENERATE_STOCKTRANSFER_WITH_PICTURE)) $this->posxpicture -= (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
} }
if ($conf->stocktransfer->dir_output) if ($conf->stocktransfer->dir_output) {
{
// Definition de $dir et $file // 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);
} }
@ -315,15 +297,13 @@ 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);
} }
@ -359,11 +339,9 @@ 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);
@ -380,8 +358,7 @@ class pdf_eagle extends ModelePdfStockTransfer
} }
} }
if (!empty($object->note_public) || !empty($object->tracking_number)) if (!empty($object->note_public) || !empty($object->tracking_number)) {
{
$tab_top = 88 + $height_incoterms; $tab_top = 88 + $height_incoterms;
$tab_top_alt = $tab_top; $tab_top_alt = $tab_top;
@ -390,24 +367,20 @@ 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;
} }
@ -420,8 +393,7 @@ 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);
} }
@ -435,9 +407,7 @@ 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;
} }
@ -447,8 +417,7 @@ 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);
@ -466,8 +435,7 @@ 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);
@ -478,12 +446,10 @@ class pdf_eagle extends ModelePdfStockTransfer
// Allows data in the first page if description is long enough to break in multiples pages // 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 else $showpricebeforepagebreak = 0;
$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->posxweightvol - $imglinesize['width'] $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 + (!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
@ -514,8 +480,7 @@ class pdf_eagle extends ModelePdfStockTransfer
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;
@ -525,28 +490,22 @@ 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 else $showpricebeforepagebreak = 0;
$showpricebeforepagebreak = 0;
} }
} } else // No pagebreak
else // No pagebreak
{ {
$pdf->commitTransaction(); $pdf->commitTransaction();
} }
@ -580,19 +539,16 @@ class pdf_eagle extends ModelePdfStockTransfer
// Weight // Weight
$pdf->SetXY($this->posxweightvol, $curY); $pdf->SetXY($this->posxweightvol, $curY);
$weighttxt = ''; $weighttxt = '';
if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight) if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight) {
{
$weighttxt = round($object->lines[$i]->weight * $object->lines[$i]->qty, 5).' '.measuringUnitString(0, "weight", $object->lines[$i]->weight_units, 1); $weighttxt = round($object->lines[$i]->weight * $object->lines[$i]->qty, 5).' '.measuringUnitString(0, "weight", $object->lines[$i]->weight_units, 1);
} }
$voltxt = ''; $voltxt = '';
if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume) if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume) {
{
$voltxt = round($object->lines[$i]->volume * $object->lines[$i]->qty, 5).' '.measuringUnitString(0, "volume", $object->lines[$i]->volume_units ? $object->lines[$i]->volume_units : 0, 1); $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 // Weight
if (empty($conf->global->STOCKTRANSFER_PDF_HIDE_WEIGHT_AND_VOLUME)) if (empty($conf->global->STOCKTRANSFER_PDF_HIDE_WEIGHT_AND_VOLUME)) {
{
$pdf->writeHTMLCell($this->posxqty - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt) ? '<br>' : '').$voltxt, 0, 0, false, true, 'C'); $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'); //$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?'<br>':'').$voltxt,'','C');
} }
@ -622,8 +578,7 @@ 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');
@ -635,8 +590,7 @@ 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);
@ -645,15 +599,11 @@ 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);
@ -662,14 +612,10 @@ class pdf_eagle extends ModelePdfStockTransfer
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. $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);
@ -682,13 +628,10 @@ 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;
} }
@ -709,8 +652,7 @@ 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;
} }
@ -721,15 +663,11 @@ 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;
} }
@ -785,8 +723,7 @@ class pdf_eagle extends ModelePdfStockTransfer
$totalQty+=$line->qty; $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;
} }
@ -800,14 +737,12 @@ 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->posxqty, $tab2_top + $tab2_hl * $index); $pdf->SetXY($this->posxqty, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($this->posxwarehousesource - $this->posxqty, $tab2_hl, $totalQty, 0, 'C', 1); $pdf->MultiCell($this->posxwarehousesource - $this->posxqty, $tab2_hl, $totalQty, 0, 'C', 1);
} }
if (!empty($conf->global->STOCKTRANSFER_PDF_DISPLAY_AMOUNT_HT)) if (!empty($conf->global->STOCKTRANSFER_PDF_DISPLAY_AMOUNT_HT)) {
{
$pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index); $pdf->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);
@ -815,18 +750,15 @@ class pdf_eagle extends ModelePdfStockTransfer
$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl, price($object->total_ht, 0, $outputlangs), 0, 'C', 1); $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->posxweightvol, $tab2_top + $tab2_hl * $index); $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell(($this->posxqty - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0, 'C', 1); $pdf->MultiCell(($this->posxqty - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0, 'C', 1);
$index++; $index++;
} }
if ($totalVolumetoshow) if ($totalVolumetoshow) {
{
$pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index); $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell(($this->posxqty - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0, 'C', 1); $pdf->MultiCell(($this->posxqty - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0, 'C', 1);
@ -873,8 +805,7 @@ 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);
@ -898,23 +829,20 @@ class pdf_eagle extends ModelePdfStockTransfer
} }
$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');
} }
@ -936,7 +864,8 @@ class pdf_eagle extends ModelePdfStockTransfer
}*/ }*/
} }
function atLeastOneBatch($object) { function atLeastOneBatch($object)
{
global $conf; global $conf;
@ -951,7 +880,6 @@ class pdf_eagle extends ModelePdfStockTransfer
} }
return false; return false;
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
@ -975,8 +903,7 @@ 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);
} }
@ -993,47 +920,36 @@ 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);
@ -1058,8 +974,7 @@ class pdf_eagle extends ModelePdfStockTransfer
$pdf->MultiCell($w, 4, $outputlangs->transnoentities("Ref")." : ".$object->ref, '', 'R'); $pdf->MultiCell($w, 4, $outputlangs->transnoentities("Ref")." : ".$object->ref, '', 'R');
// 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);
@ -1067,8 +982,7 @@ class pdf_eagle extends ModelePdfStockTransfer
} }
// 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);
@ -1076,8 +990,7 @@ 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);
@ -1085,16 +998,14 @@ 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);
@ -1110,15 +1021,13 @@ 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);
@ -1133,8 +1042,7 @@ 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
@ -1142,8 +1050,7 @@ 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;
@ -1192,8 +1099,7 @@ 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]);
} }

View File

@ -219,49 +219,35 @@ class pdf_eagle_proforma extends ModelePDFCommandes
// Loop on each lines to detect if there is at least one image to show // 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 (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo if ($obj['photo_vignette']) {
{
if ($obj['photo_vignette'])
{
$filename = $obj['photo_vignette']; $filename = $obj['photo_vignette'];
} } else {
else
{
$filename = $obj['photo']; $filename = $obj['photo'];
} }
} } else {
else
{
$filename = $obj['photo']; $filename = $obj['photo'];
} }
@ -278,39 +264,31 @@ class pdf_eagle_proforma extends ModelePDFCommandes
if ($conf->stocktransfer->dir_output) if ($conf->stocktransfer->dir_output) {
{
$object->fetch_thirdparty(); $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);
} }
@ -328,15 +306,13 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page $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);
} }
@ -377,11 +353,9 @@ 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);
@ -399,11 +373,9 @@ 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']);
@ -413,14 +385,12 @@ 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;
@ -439,8 +409,7 @@ 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
@ -464,8 +433,7 @@ 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++;
@ -488,8 +456,7 @@ 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);
} }
@ -507,8 +474,7 @@ 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();
@ -516,8 +482,7 @@ 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++;
@ -532,9 +497,7 @@ 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;
} }
@ -552,8 +515,7 @@ 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);
@ -570,11 +532,9 @@ 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);
@ -584,20 +544,17 @@ 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 else $showpricebeforepagebreak = 0;
$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')) {
@ -610,8 +567,7 @@ 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();
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;
@ -620,27 +576,21 @@ 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 else $showpricebeforepagebreak = 0;
$showpricebeforepagebreak = 0;
} }
} } else // No pagebreak
else // No pagebreak
{ {
$pdf->commitTransaction(); $pdf->commitTransaction();
} }
@ -665,16 +615,14 @@ 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);
@ -682,8 +630,7 @@ 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);
@ -691,24 +638,21 @@ 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);
@ -717,8 +661,7 @@ 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);
@ -757,8 +700,7 @@ 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];
@ -775,8 +717,7 @@ 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);
@ -786,15 +727,11 @@ 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);
@ -803,14 +740,10 @@ class pdf_eagle_proforma extends ModelePDFCommandes
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. $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);
@ -825,8 +758,7 @@ 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 else $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
$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
@ -857,8 +789,7 @@ 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;
} }
@ -869,15 +800,11 @@ 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;
} }
@ -913,8 +840,7 @@ 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);
@ -925,8 +851,7 @@ 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").':';
@ -969,8 +894,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes
}*/ }*/
// 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);
@ -982,9 +906,7 @@ 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").':';
@ -1017,13 +939,10 @@ 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);
@ -1032,23 +951,20 @@ 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);
@ -1059,10 +975,8 @@ 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);
@ -1103,8 +1017,7 @@ 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);
@ -1153,8 +1066,7 @@ 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++;
@ -1209,8 +1121,7 @@ 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);
@ -1260,8 +1171,7 @@ 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);
} }
@ -1274,34 +1184,25 @@ 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');
} }
@ -1324,8 +1225,7 @@ 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);
@ -1333,8 +1233,7 @@ 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);
@ -1342,8 +1241,7 @@ 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);
@ -1351,27 +1249,23 @@ 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);
@ -1379,11 +1273,9 @@ class pdf_eagle_proforma extends ModelePDFCommandes
} }
} }
if (!empty($conf->global->PDF_SHOW_PROJECT)) if (!empty($conf->global->PDF_SHOW_PROJECT)) {
{
$object->fetch_projet(); $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);
@ -1391,8 +1283,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes
} }
} }
if (!empty($conf->global->DOC_SHOW_CUSTOMER_CODE) && !empty($object->thirdparty->code_client)) if (!empty($conf->global->DOC_SHOW_CUSTOMER_CODE) && !empty($object->thirdparty->code_client)) {
{
$posy += 4; $posy += 4;
$pdf->SetXY($posx, $posy); $pdf->SetXY($posx, $posy);
$pdf->SetTextColor(0, 0, 60); $pdf->SetTextColor(0, 0, 60);
@ -1400,11 +1291,9 @@ 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;
@ -1420,13 +1309,11 @@ 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
@ -1434,8 +1321,7 @@ 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;
@ -1484,8 +1370,7 @@ 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]);
} }
@ -1631,8 +1516,7 @@ 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;
} }
@ -1740,16 +1624,11 @@ class pdf_eagle_proforma extends ModelePDFCommandes
); );
$reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook $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

@ -102,8 +102,7 @@ $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');
} }
@ -141,8 +140,7 @@ $parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $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('/product/stock/stocktransfer/stocktransfer_list.php', 1);
@ -170,17 +168,14 @@ 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');
@ -201,10 +196,8 @@ 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->ref), null, 'errors'); setEventMessages($langs->transnoentities("ErrorTryToMakeMoveOnProductRequiringBatchData", $prod->ref), null, 'errors');
@ -236,7 +229,6 @@ if (empty($reshook))
$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');
@ -257,10 +249,8 @@ 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');
@ -412,8 +402,7 @@ 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"].'">';
@ -461,8 +450,7 @@ 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);
@ -496,8 +484,7 @@ if (($id || $ref) && $action == 'edit')
} }
// 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);
@ -506,13 +493,11 @@ 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('Delete'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('Delete'), $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
@ -551,8 +536,7 @@ 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;
@ -597,8 +581,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
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') {
@ -662,8 +645,7 @@ 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();
@ -754,8 +736,7 @@ 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);
@ -771,8 +752,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
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 { else {
@ -796,8 +776,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
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) if ($conf->global->PRODUCT_USE_UNITS) {
{
print '<td class="linecoluseunit nowrap left">'; print '<td class="linecoluseunit nowrap left">';
$label = $productstatic->getLabelOfUnit('short'); $label = $productstatic->getLabelOfUnit('short');
if ($label !== '') { if ($label !== '') {
@ -813,7 +792,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
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>';
@ -925,7 +903,6 @@ 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>';
@ -940,25 +917,21 @@ 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
@ -967,38 +940,26 @@ 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 ($permissiontoadd) if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
{
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";
} }
@ -1028,8 +989,7 @@ 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
@ -1046,8 +1006,7 @@ 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