From 5ecef88b35c44b429c4731c6fb6b8a14fd08ce26 Mon Sep 17 00:00:00 2001 From: ATM john Date: Sun, 23 Feb 2020 23:04:24 +0100 Subject: [PATCH 01/45] allow in extrafield conf to choose to add extrafield in a new col or append it to description, it could be useful for html or long text extrafields --- htdocs/core/actions_extrafields.inc.php | 4 +- .../core/class/commondocgenerator.class.php | 37 +++++++++++++++---- .../facture/doc/pdf_sponge.modules.php | 24 +++++++++++- htdocs/core/tpl/admin_extrafields_add.tpl.php | 2 +- .../core/tpl/admin_extrafields_edit.tpl.php | 2 +- .../core/tpl/admin_extrafields_view.tpl.php | 2 +- 6 files changed, 58 insertions(+), 13 deletions(-) diff --git a/htdocs/core/actions_extrafields.inc.php b/htdocs/core/actions_extrafields.inc.php index 486764b167e..b61c9209aa8 100644 --- a/htdocs/core/actions_extrafields.inc.php +++ b/htdocs/core/actions_extrafields.inc.php @@ -184,7 +184,7 @@ if ($action == 'add') GETPOST('langfile', 'alpha'), 1, (GETPOST('totalizable', 'alpha')?1:0), - (GETPOST('documentpdf', 'alpha')?1:0) + GETPOST('documentpdf', 'alpha') ); if ($result > 0) { @@ -354,7 +354,7 @@ if ($action == 'update') GETPOST('langfile'), 1, (GETPOST('totalizable', 'alpha')?1:0), - (GETPOST('documentpdf', 'alpha')?1:0) + GETPOST('documentpdf', 'alpha') ); if ($result > 0) { diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index eb214516a6f..753002a39ee 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -1074,7 +1074,7 @@ abstract class CommonDocGenerator /** * print standard column content * - * @param PDF $pdf pdf object + * @param TCPDF $pdf pdf object * @param float $curY curent Y position * @param string $colKey the column key * @param string $columnText column text @@ -1179,6 +1179,8 @@ abstract class CommonDocGenerator $defaultParams = array( 'style' => '', 'display' => 'auto', // auto, table, list + 'documentpdfEnable' => array(1), + 'documentpdfEnableNotEmpty' => array(2), 'table' => array( 'maxItemsInRow' => 2, @@ -1213,7 +1215,18 @@ abstract class CommonDocGenerator foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $label) { // Enable extrafield ? - $enabled = !empty($extrafields->attributes[$object->table_element]['documentpdf'][$key]); + $enabled = 0; + $disableOnEmpty = 0; + if(!empty($extrafields->attributes[$object->table_element]['documentpdf'][$key])) { + $documentpdf = intval($extrafields->attributes[$object->table_element]['documentpdf'][$key]); + if(in_array($documentpdf,$params['documentpdfEnable']) || in_array($documentpdf,$params['documentpdfEnableNotEmpty']) ) { + $enabled = 1; + } + + if (in_array($documentpdf,$params['documentpdfEnableNotEmpty'])) { + $disableOnEmpty = 1; + } + } if(empty($enabled)){ continue; @@ -1225,6 +1238,11 @@ abstract class CommonDocGenerator $field->label = $outputlangs->transnoentities($label); $field->type = $extrafields->attributes[$object->table_element]['type'][$key]; + // dont display if empty + if($disableOnEmpty && empty($field->content)) { + continue; + } + $fields[] = $field; } } @@ -1234,10 +1252,7 @@ abstract class CommonDocGenerator // Sort extrafields by rank uasort($fields, function ($a, $b) { return ($a->rank > $b->rank) ? -1 : 1; - } - ); - - + }); // define some HTML content with style $html.= ''; @@ -1425,8 +1440,16 @@ abstract class CommonDocGenerator } // Enable extrafield ? - $enabled = !empty($extrafields->attributes[$object->table_element]['documentpdf'][$key]); + $enabled = 0; + if(!empty($extrafields->attributes[$object->table_element]['documentpdf'][$key])) { + $documentpdf = intval($extrafields->attributes[$object->table_element]['documentpdf'][$key]); + if($documentpdf === 1 || $documentpdf === 2) { + $enabled = 1; + } + // Note : if $documentpdf === 3 or 4 so, it's displayed after line description not in cols + } + if (!$enabled){ continue; } // don't wast resourses if we don't need them... // Load language if required if (!empty($extrafields->attributes[$object->table_element]['langfile'][$key])) $outputlangs->load($extrafields->attributes[$object->table_element]['langfile'][$key]); diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index cd9327e25b9..90290caaf61 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -638,12 +638,34 @@ class pdf_sponge extends ModelePDFFactures { $pdf->startTransaction(); pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc); + $posYAfterDescription = $pdf->GetY(); + $params = array( + 'display' => 'list', + 'documentpdfEnable' => array(3), + 'documentpdfEnableNotEmpty' => array(4) + ); + $extrafieldDesc = $this->getExtrafieldsInHtml($object->lines[$i], $outputlangs, $params); + if(!empty($extrafieldDesc)){ + $this->printStdColumnContent($pdf, $posYAfterDescription, 'desc', $extrafieldDesc); + } + $pageposafter = $pdf->getPage(); if ($pageposafter > $pageposbefore) // There is a pagebreak { $pdf->rollbackTransaction(true); $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc); + $posYAfterDescription = $pdf->GetY(); + $params = array( + 'display' => 'list', + 'documentpdfEnable' => array(3), + 'documentpdfEnableNotEmpty' => array(4) + ); + $extrafieldDesc = $this->getExtrafieldsInHtml($object->lines[$i], $outputlangs, $params); + if(!empty($extrafieldDesc)){ + $this->printStdColumnContent($pdf, $posYAfterDescription, 'desc', $extrafieldDesc); + } + $pageposafter = $pdf->getPage(); $posyafter = $pdf->GetY(); //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; @@ -673,7 +695,7 @@ class pdf_sponge extends ModelePDFFactures $posYAfterDescription = $pdf->GetY(); } - $nexY = $pdf->GetY(); + $nexY = $pdf->GetY(); $pageposafter = $pdf->getPage(); $pdf->setPage($pageposbefore); $pdf->setTopMargin($this->marge_haute); diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php index 37872f2a5c0..a31b83309af 100644 --- a/htdocs/core/tpl/admin_extrafields_add.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php @@ -198,7 +198,7 @@ $langs->load("modulebuilder"); textwithpicto($langs->trans("DisplayOnPdf"), $langs->trans("DisplayOnPdfDesc")); ?> -> + trans("Totalizable"); ?>> diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php index 8e14ad978ca..f92bdd1ada6 100644 --- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php @@ -267,7 +267,7 @@ else textwithpicto($langs->trans("DisplayOnPdf"), $langs->trans("DisplayOnPdfDesc")); ?> -> + textwithpicto($langs->trans("Totalizable"), $langs->trans("TotalizableDesc")); ?>> textwithpicto($langs->trans("HelpOnTooltip"), $langs->trans("HelpOnTooltipDesc")); ?> diff --git a/htdocs/core/tpl/admin_extrafields_view.tpl.php b/htdocs/core/tpl/admin_extrafields_view.tpl.php index 3bec8cb8d6f..6ed1480a0ea 100644 --- a/htdocs/core/tpl/admin_extrafields_view.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_view.tpl.php @@ -93,7 +93,7 @@ if (is_array($extrafields->attributes[$elementtype]['type']) && count($extrafiel print ''.yn($extrafields->attributes[$elementtype]['required'][$key])."\n"; print ''.yn($extrafields->attributes[$elementtype]['alwayseditable'][$key])."\n"; print ''.$extrafields->attributes[$elementtype]['list'][$key]."\n"; - print ''.yn($extrafields->attributes[$elementtype]['documentpdf'][$key])."\n"; + print ''.$extrafields->attributes[$elementtype]['documentpdf'][$key]."\n"; print ''.yn($extrafields->attributes[$elementtype]['totalizable'][$key])."\n"; if (! empty($conf->multicompany->enabled)) { print ''; From 316fa4068aecb20fe11b0e10d77095edd3993f8d Mon Sep 17 00:00:00 2001 From: ATM john Date: Sun, 23 Feb 2020 23:14:01 +0100 Subject: [PATCH 02/45] revert commit fdfc45bbe978afa2e7c460749304e6fa30282c2f and fix y position --- htdocs/core/class/commondocgenerator.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 753002a39ee..c0656758789 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -1094,9 +1094,9 @@ abstract class CommonDocGenerator if (!$reshook) { if (empty($columnText)) return; - $pdf->SetXY($this->getColumnContentXStart($colKey) - 1, $curY); // Set curent position + $pdf->SetXY($this->getColumnContentXStart($colKey), $curY); // Set curent position $colDef = $this->cols[$colKey]; - $pdf->writeHTMLCell($this->getColumnContentWidth($colKey) + 2, 2, $this->getColumnContentXStart($colKey) - 1, $curY, $columnText, 0, 0, 0, true, $colDef['content']['align']); + $pdf->writeHTMLCell($this->getColumnContentWidth($colKey), 2, $this->getColumnContentXStart($colKey), $curY, $columnText, 0, 1, 0, true, $colDef['content']['align']); } } From acacbfd85e8651d396db7b07e5c59f0cf643dbd6 Mon Sep 17 00:00:00 2001 From: ATM john Date: Sun, 23 Feb 2020 23:17:10 +0100 Subject: [PATCH 03/45] Fix list separator on first loop --- htdocs/core/class/commondocgenerator.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index c0656758789..e54527c0173 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -1255,7 +1255,7 @@ abstract class CommonDocGenerator }); // define some HTML content with style - $html.= ''; + $html.= !empty($params['style'])?'':''; // auto select display format if($params['display'] == 'auto') { @@ -1270,10 +1270,12 @@ abstract class CommonDocGenerator if($params['display'] == 'list') { // Display in list format + $i=0; foreach ($fields as $field) { - $html .= !empty($html)?$params['list']['separator']:''; + $html .= !empty($i)?$params['list']['separator']:''; $html .= '' . $field->label . ' : '; $html .= $field->content; + $i++; } } elseif($params['display'] == 'table') { From 33f3083f7039752e4de21840300c0d69cbd3a73a Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 23 Feb 2020 22:26:27 +0000 Subject: [PATCH 04/45] Fixing style errors. --- htdocs/core/class/commondocgenerator.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index e54527c0173..80e5ec53181 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -1219,11 +1219,11 @@ abstract class CommonDocGenerator $disableOnEmpty = 0; if(!empty($extrafields->attributes[$object->table_element]['documentpdf'][$key])) { $documentpdf = intval($extrafields->attributes[$object->table_element]['documentpdf'][$key]); - if(in_array($documentpdf,$params['documentpdfEnable']) || in_array($documentpdf,$params['documentpdfEnableNotEmpty']) ) { + if(in_array($documentpdf, $params['documentpdfEnable']) || in_array($documentpdf, $params['documentpdfEnableNotEmpty']) ) { $enabled = 1; } - if (in_array($documentpdf,$params['documentpdfEnableNotEmpty'])) { + if (in_array($documentpdf, $params['documentpdfEnableNotEmpty'])) { $disableOnEmpty = 1; } } From fab34d5114b04096d995cb9b7be48850ab6537a4 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 23 Feb 2020 22:40:41 +0000 Subject: [PATCH 05/45] Fixing style errors. --- htdocs/core/class/commondocgenerator.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index d53cb5ebc69..7fa97349f01 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -1219,11 +1219,11 @@ abstract class CommonDocGenerator $disableOnEmpty = 0; if(!empty($extrafields->attributes[$object->table_element]['printable'][$key])) { $printable = intval($extrafields->attributes[$object->table_element]['printable'][$key]); - if(in_array($printable,$params['printableEnable']) || in_array($printable,$params['printableEnableNotEmpty']) ) { + if(in_array($printable, $params['printableEnable']) || in_array($printable, $params['printableEnableNotEmpty']) ) { $enabled = 1; } - if (in_array($printable,$params['printableEnableNotEmpty'])) { + if (in_array($printable, $params['printableEnableNotEmpty'])) { $disableOnEmpty = 1; } } From 377b9a6b88d1f2c18c1038abf053f7af8fa643ed Mon Sep 17 00:00:00 2001 From: ATM john Date: Mon, 24 Feb 2020 00:14:43 +0100 Subject: [PATCH 06/45] Add extrafields on PDF object lines desc for compatible pdf --- .../commande/doc/pdf_eratosthene.modules.php | 15 ++++++++++- .../expedition/doc/pdf_espadon.modules.php | 27 ++++++++++++++++++- .../facture/doc/pdf_sponge.modules.php | 11 +++++--- .../modules/propale/doc/pdf_cyan.modules.php | 25 +++++++++++++++++ .../supplier_order/doc/pdf_cornas.modules.php | 26 ++++++++++++++++++ 5 files changed, 98 insertions(+), 6 deletions(-) diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index fc1d737a7d5..18945fc6c43 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -604,7 +604,20 @@ class pdf_eratosthene extends ModelePDFCommandes { $pdf->startTransaction(); pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc); - $pageposafter = $pdf->getPage(); + $posYAfterDescription = $pdf->GetY(); + + // Display extrafield if needed + $params = array( + 'display' => 'list', + 'printableEnable' => array(3), + 'printableEnableNotEmpty' => array(4) + ); + $extrafieldDesc = $this->getExtrafieldsInHtml($object->lines[$i], $outputlangs, $params); + if(!empty($extrafieldDesc)){ + $this->printStdColumnContent($pdf, $posYAfterDescription, 'desc', $extrafieldDesc); + } + + $pageposafter = $pdf->getPage(); if ($pageposafter > $pageposbefore) // There is a pagebreak { $pdf->rollbackTransaction(true); diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index 0ef7acc7bef..29dee279924 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -474,7 +474,20 @@ class pdf_espadon extends ModelePdfExpedition { $pdf->startTransaction(); pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc); - $pageposafter = $pdf->getPage(); + $posYAfterDescription = $pdf->GetY(); + + // Display extrafield if needed + $params = array( + 'display' => 'list', + 'printableEnable' => array(3), + 'printableEnableNotEmpty' => array(4) + ); + $extrafieldDesc = $this->getExtrafieldsInHtml($object->lines[$i], $outputlangs, $params); + if(!empty($extrafieldDesc)){ + $this->printStdColumnContent($pdf, $posYAfterDescription, 'desc', $extrafieldDesc); + } + + $pageposafter = $pdf->getPage(); if ($pageposafter > $pageposbefore) // There is a pagebreak { $pdf->rollbackTransaction(true); @@ -482,6 +495,18 @@ class pdf_espadon extends ModelePdfExpedition //print $pageposafter.'-'.$pageposbefore;exit; $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc); + $posYAfterDescription = $pdf->GetY(); + + // Display extrafield if needed + $params = array( + 'display' => 'list', + 'printableEnable' => array(3), + 'printableEnableNotEmpty' => array(4) + ); + $extrafieldDesc = $this->getExtrafieldsInHtml($object->lines[$i], $outputlangs, $params); + if(!empty($extrafieldDesc)){ + $this->printStdColumnContent($pdf, $posYAfterDescription, 'desc', $extrafieldDesc); + } $pageposafter = $pdf->getPage(); $posyafter = $pdf->GetY(); diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 90290caaf61..c4e0ef792ac 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -639,10 +639,13 @@ class pdf_sponge extends ModelePDFFactures $pdf->startTransaction(); pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc); $posYAfterDescription = $pdf->GetY(); + + // Display extrafield if needed + $params = array( 'display' => 'list', - 'documentpdfEnable' => array(3), - 'documentpdfEnableNotEmpty' => array(4) + 'printableEnable' => array(3), + 'printableEnableNotEmpty' => array(4) ); $extrafieldDesc = $this->getExtrafieldsInHtml($object->lines[$i], $outputlangs, $params); if(!empty($extrafieldDesc)){ @@ -658,8 +661,8 @@ class pdf_sponge extends ModelePDFFactures $posYAfterDescription = $pdf->GetY(); $params = array( 'display' => 'list', - 'documentpdfEnable' => array(3), - 'documentpdfEnableNotEmpty' => array(4) + 'printableEnable' => array(3), + 'printableEnableNotEmpty' => array(4) ); $extrafieldDesc = $this->getExtrafieldsInHtml($object->lines[$i], $outputlangs, $params); if(!empty($extrafieldDesc)){ diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 702202be988..f55fd370132 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -622,6 +622,19 @@ class pdf_cyan extends ModelePDFPropales { $pdf->startTransaction(); pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc); + $posYAfterDescription = $pdf->GetY(); + + // Display extrafield if needed + $params = array( + 'display' => 'list', + 'printableEnable' => array(3), + 'printableEnableNotEmpty' => array(4) + ); + $extrafieldDesc = $this->getExtrafieldsInHtml($object->lines[$i], $outputlangs, $params); + if(!empty($extrafieldDesc)){ + $this->printStdColumnContent($pdf, $posYAfterDescription, 'desc', $extrafieldDesc); + } + $pageposafter = $pdf->getPage(); if ($pageposafter > $pageposbefore) // There is a pagebreak { @@ -630,6 +643,18 @@ class pdf_cyan extends ModelePDFPropales //print $pageposafter.'-'.$pageposbefore;exit; $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc); + $posYAfterDescription = $pdf->GetY(); + + // Display extrafield if needed + $params = array( + 'display' => 'list', + 'printableEnable' => array(3), + 'printableEnableNotEmpty' => array(4) + ); + $extrafieldDesc = $this->getExtrafieldsInHtml($object->lines[$i], $outputlangs, $params); + if(!empty($extrafieldDesc)){ + $this->printStdColumnContent($pdf, $posYAfterDescription, 'desc', $extrafieldDesc); + } $pageposafter = $pdf->getPage(); $posyafter = $pdf->GetY(); diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index 92bc5219688..24ad06fee38 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -556,6 +556,19 @@ class pdf_cornas extends ModelePDFSuppliersOrders { $pdf->startTransaction(); pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc); + $posYAfterDescription = $pdf->GetY(); + + // Display extrafield if needed + $params = array( + 'display' => 'list', + 'printableEnable' => array(3), + 'printableEnableNotEmpty' => array(4) + ); + $extrafieldDesc = $this->getExtrafieldsInHtml($object->lines[$i], $outputlangs, $params); + if(!empty($extrafieldDesc)){ + $this->printStdColumnContent($pdf, $posYAfterDescription, 'desc', $extrafieldDesc); + } + $pageposafter = $pdf->getPage(); if ($pageposafter > $pageposbefore) // There is a pagebreak { @@ -564,6 +577,19 @@ class pdf_cornas extends ModelePDFSuppliersOrders //print $pageposafter.'-'.$pageposbefore;exit; $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc); + $posYAfterDescription = $pdf->GetY(); + + // Display extrafield if needed + $params = array( + 'display' => 'list', + 'printableEnable' => array(3), + 'printableEnableNotEmpty' => array(4) + ); + $extrafieldDesc = $this->getExtrafieldsInHtml($object->lines[$i], $outputlangs, $params); + if(!empty($extrafieldDesc)){ + $this->printStdColumnContent($pdf, $posYAfterDescription, 'desc', $extrafieldDesc); + } + $pageposafter = $pdf->getPage(); $posyafter = $pdf->GetY(); if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text From 98407347e77b35c34282c5a62807580bf1836766 Mon Sep 17 00:00:00 2001 From: John Botella Date: Mon, 24 Feb 2020 13:44:26 +0100 Subject: [PATCH 07/45] Update extrafield printable desc --- htdocs/langs/en_US/modulebuilder.lang | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 9f64e93f9d1..9dd6e9c9b30 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -84,7 +84,7 @@ ListOfPermissionsDefined=List of defined permissions SeeExamples=See examples here EnabledDesc=Condition to have this field active (Examples: 1 or $conf->global->MYMODULE_MYOPTION) VisibleDesc=Is the field visible ? (Examples: 0=Never visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create), 5=Visible on list end view form only (not create, not update). Using a negative value means field is not shown by default on list but can be selected for viewing). It can be an expression, for example:
preg_match('/public/', $_SERVER['PHP_SELF'])?0:1
($user->rights->holiday->define_holiday ? 1 : 0) -DisplayOnPdfDesc=Display this field on compatible PDF documents, you can manage position with "Position" field.
Currently, known compatibles PDF models are : eratostene (order), espadon (ship), sponge (invoices), cyan (propal/quotation), cornas (supplier order) +DisplayOnPdfDesc=Display this field on compatible PDF documents, you can manage position with "Position" field.
Currently, known compatibles PDF models are : eratostene (order), espadon (ship), sponge (invoices), cyan (propal/quotation), cornas (supplier order)

For document :
0 = not displayed
1 = display
2 = display only if not empty

For document lines :
0 = not displayed
1 = displayed in a column
3 = display in line description column after the description
4 = display in description column after the description only if not empty DisplayOnPdf=Display on PDF IsAMeasureDesc=Can the value of field be cumulated to get a total into list? (Examples: 1 or 0) SearchAllDesc=Is the field used to make a search from the quick search tool? (Examples: 1 or 0) @@ -138,4 +138,4 @@ NotEditable=Not editable ForeignKey=Foreign key TypeOfFieldsHelp=Type of fields:
varchar(99), double(24,8), real, text, html, datetime, timestamp, integer, integer:ClassName:relativepath/to/classfile.class.php[:1[:filter]] ('1' means we add a + button after the combo to create the record, 'filter' can be 'status=1 AND fk_user = __USER_ID AND entity IN (__SHARED_ENTITIES__)' for example) AsciiToHtmlConverter=Ascii to HTML converter -AsciiToPdfConverter=Ascii to PDF converter \ No newline at end of file +AsciiToPdfConverter=Ascii to PDF converter From 06b2d459c03ea622e4e71d8ce353f3f12a4d276e Mon Sep 17 00:00:00 2001 From: John Botella Date: Mon, 24 Feb 2020 14:18:49 +0100 Subject: [PATCH 08/45] Fix cell padding --- htdocs/core/class/commondocgenerator.class.php | 4 ++++ htdocs/core/modules/facture/doc/pdf_sponge.modules.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 7fa97349f01..9e78672f0bd 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -1096,7 +1096,11 @@ abstract class CommonDocGenerator if (empty($columnText)) return; $pdf->SetXY($this->getColumnContentXStart($colKey), $curY); // Set curent position $colDef = $this->cols[$colKey]; + $curentCellPaddinds = $pdf->getCellPaddings(); + $pdf->setCellPadding(0); $pdf->writeHTMLCell($this->getColumnContentWidth($colKey), 2, $this->getColumnContentXStart($colKey), $curY, $columnText, 0, 1, 0, true, $colDef['content']['align']); + $curentCellPaddinds = $pdf->getCellPaddings(); + $pdf->setCellPaddings( $curentCellPaddinds['L'], $curentCellPaddinds['T'], $curentCellPaddinds['R'], $curentCellPaddinds['B']); } } diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index c4e0ef792ac..68101161ce1 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -2242,7 +2242,7 @@ class pdf_sponge extends ModelePDFFactures // Default field style for content $this->defaultContentsFieldsStyle = array( 'align' => 'R', // R,C,L - 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + 'padding' => array(0.5, 1, 0.5, 1), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ); // Default field style for content From d07e2ab8fba5e825686107196d3eaa28cc9eaeda Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 24 Feb 2020 16:44:46 +0000 Subject: [PATCH 09/45] Fixing style errors. --- htdocs/core/class/commondocgenerator.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 9e78672f0bd..6ba5d446ecf 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -1100,7 +1100,7 @@ abstract class CommonDocGenerator $pdf->setCellPadding(0); $pdf->writeHTMLCell($this->getColumnContentWidth($colKey), 2, $this->getColumnContentXStart($colKey), $curY, $columnText, 0, 1, 0, true, $colDef['content']['align']); $curentCellPaddinds = $pdf->getCellPaddings(); - $pdf->setCellPaddings( $curentCellPaddinds['L'], $curentCellPaddinds['T'], $curentCellPaddinds['R'], $curentCellPaddinds['B']); + $pdf->setCellPaddings($curentCellPaddinds['L'], $curentCellPaddinds['T'], $curentCellPaddinds['R'], $curentCellPaddinds['B']); } } From 1ca1f0677b51c9a72387daed2dfc200e9215ea8c Mon Sep 17 00:00:00 2001 From: John Botella Date: Mon, 24 Feb 2020 17:48:01 +0100 Subject: [PATCH 10/45] fix PDF cell padding --- htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php | 4 ++-- htdocs/core/modules/expedition/doc/pdf_espadon.modules.php | 4 ++-- htdocs/core/modules/facture/doc/pdf_sponge.modules.php | 2 +- htdocs/core/modules/propale/doc/pdf_cyan.modules.php | 4 ++-- htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index 18945fc6c43..69bb0be2529 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -1704,7 +1704,7 @@ class pdf_eratosthene extends ModelePDFCommandes // Default field style for content $this->defaultContentsFieldsStyle = array( 'align' => 'R', // R,C,L - 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + 'padding' => array(0.5, 1, 0.5, 1), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ); // Default field style for content @@ -1741,7 +1741,7 @@ class pdf_eratosthene extends ModelePDFCommandes 'align' => 'L', // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label // 'label' => ' ', // the final label - 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + 'padding' => array(0.5, 1, 0.5, 1), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ), 'content' => array( 'align' => 'L', diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index 29dee279924..7843eb6e087 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -1146,7 +1146,7 @@ class pdf_espadon extends ModelePdfExpedition // Default field style for content $this->defaultContentsFieldsStyle = array( 'align' => 'R', // R,C,L - 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + 'padding' => array(0.5, 1, 0.5, 1), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ); // Default field style for content @@ -1183,7 +1183,7 @@ class pdf_espadon extends ModelePdfExpedition 'align' => 'L', // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label // 'label' => ' ', // the final label - 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + 'padding' => array(0.5, 1, 0.5, 1), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ), 'content' => array( 'align' => 'L', diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 68101161ce1..3c914dbd478 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -2279,7 +2279,7 @@ class pdf_sponge extends ModelePDFFactures 'align' => 'L', // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label // 'label' => ' ', // the final label - 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + 'padding' => array(0.5, 1, 0.5, 1), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ), 'content' => array( 'align' => 'L', diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index f55fd370132..aaa64b266de 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -1865,7 +1865,7 @@ class pdf_cyan extends ModelePDFPropales // Default field style for content $this->defaultContentsFieldsStyle = array( 'align' => 'R', // R,C,L - 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + 'padding' => array(0.5, 1, 0.5, 1), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ); // Default field style for content @@ -1902,7 +1902,7 @@ class pdf_cyan extends ModelePDFPropales 'align' => 'L', // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label // 'label' => ' ', // the final label - 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + 'padding' => array(0.5, 1, 0.5, 1), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ), 'content' => array( 'align' => 'L', diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index 24ad06fee38..e454e29835c 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -1509,7 +1509,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders // Default field style for content $this->defaultContentsFieldsStyle = array( 'align' => 'R', // R,C,L - 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + 'padding' => array(0.5, 1, 0.5, 1), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ); // Default field style for content @@ -1546,7 +1546,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders 'align' => 'L', // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label // 'label' => ' ', // the final label - 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + 'padding' => array(0.5, 1, 0.5, 1), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ), 'content' => array( 'align' => 'L', From 3c4e7f7b07825a6fedd7299374f2119a460c1eb0 Mon Sep 17 00:00:00 2001 From: ATM john Date: Mon, 24 Feb 2020 20:47:19 +0100 Subject: [PATCH 11/45] Fix cell padding sponge --- .../core/class/commondocgenerator.class.php | 50 +++++++++++++++++-- .../facture/doc/pdf_sponge.modules.php | 41 ++++----------- 2 files changed, 56 insertions(+), 35 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 6ba5d446ecf..048c70e7f68 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -1096,14 +1096,58 @@ abstract class CommonDocGenerator if (empty($columnText)) return; $pdf->SetXY($this->getColumnContentXStart($colKey), $curY); // Set curent position $colDef = $this->cols[$colKey]; + // save curent cell padding $curentCellPaddinds = $pdf->getCellPaddings(); - $pdf->setCellPadding(0); - $pdf->writeHTMLCell($this->getColumnContentWidth($colKey), 2, $this->getColumnContentXStart($colKey), $curY, $columnText, 0, 1, 0, true, $colDef['content']['align']); - $curentCellPaddinds = $pdf->getCellPaddings(); + // set cell padding with column content definition + $pdf->setCellPaddings($colDef['content']['padding'][3], $colDef['content']['padding'][0], $colDef['content']['padding'][1], $colDef['content']['padding'][2]); + $pdf->writeHTMLCell($colDef['width'], 2, $colDef['xStartPos'], $curY, $columnText, 0, 1, 0, true, $colDef['content']['align']); + + // restore cell padding $pdf->setCellPaddings($curentCellPaddinds['L'], $curentCellPaddinds['T'], $curentCellPaddinds['R'], $curentCellPaddinds['B']); } } + + /** + * print standard column content + * + * @param TCPDF $pdf pdf object + * @param object $object CommonObject + * @param string $colKey the column key + * @param $i + * @param $outputlangs + * @param float $curY curent Y position + * @param $hideref + * @param $hidedesc + * @param $issupplierline + */ + function printColDescContent($pdf, &$curY, $colKey, $object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $issupplierline = 0){ + // load desc col params + $colDef = $this->cols[$colKey]; + // save curent cell padding + $curentCellPaddinds = $pdf->getCellPaddings(); + // set cell padding with column content definition + $pdf->setCellPaddings($colDef['content']['padding'][3], $colDef['content']['padding'][0], $colDef['content']['padding'][1], $colDef['content']['padding'][2]); + + // line description + pdf_writelinedesc($pdf, $object, $i, $outputlangs, $colDef['width'], 3, $colDef['xStartPos'], $curY, $hideref, $hidedesc, $issupplierline); + $posYAfterDescription = $pdf->GetY() - $colDef['content']['padding'][0]; + + // restore cell padding + $pdf->setCellPaddings($curentCellPaddinds['L'], $curentCellPaddinds['T'], $curentCellPaddinds['R'], $curentCellPaddinds['B']); + + // Display extrafield if needed + $params = array( + 'display' => 'list', + 'printableEnable' => array(3), + 'printableEnableNotEmpty' => array(4) + ); + $extrafieldDesc = $this->getExtrafieldsInHtml($object->lines[$i], $outputlangs, $params); + if(!empty($extrafieldDesc)){ + $this->printStdColumnContent($pdf, $posYAfterDescription, $colKey, $extrafieldDesc); + } + } + /** * get extrafield content for pdf writeHtmlCell compatibility * usage for PDF line columns and object note block diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 3c914dbd478..224f3522382 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -584,7 +584,7 @@ class pdf_sponge extends ModelePDFFactures $iniY = $tab_top + $this->tabTitleHeight + 2; $curY = $tab_top + $this->tabTitleHeight + 2; - $nexY = $tab_top + $this->tabTitleHeight + 2; + $nexY = $tab_top + $this->tabTitleHeight + 0; // Loop on each lines $pageposbeforeprintlines = $pdf->getPage(); @@ -637,37 +637,15 @@ class pdf_sponge extends ModelePDFFactures if ($this->getColumnStatus('desc')) { $pdf->startTransaction(); - pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc); - $posYAfterDescription = $pdf->GetY(); - - // Display extrafield if needed - - $params = array( - 'display' => 'list', - 'printableEnable' => array(3), - 'printableEnableNotEmpty' => array(4) - ); - $extrafieldDesc = $this->getExtrafieldsInHtml($object->lines[$i], $outputlangs, $params); - if(!empty($extrafieldDesc)){ - $this->printStdColumnContent($pdf, $posYAfterDescription, 'desc', $extrafieldDesc); - } + $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc); $pageposafter = $pdf->getPage(); if ($pageposafter > $pageposbefore) // There is a pagebreak { $pdf->rollbackTransaction(true); $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. - pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc); - $posYAfterDescription = $pdf->GetY(); - $params = array( - 'display' => 'list', - 'printableEnable' => array(3), - 'printableEnableNotEmpty' => array(4) - ); - $extrafieldDesc = $this->getExtrafieldsInHtml($object->lines[$i], $outputlangs, $params); - if(!empty($extrafieldDesc)){ - $this->printStdColumnContent($pdf, $posYAfterDescription, 'desc', $extrafieldDesc); - } + + $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc); $pageposafter = $pdf->getPage(); $posyafter = $pdf->GetY(); @@ -695,7 +673,6 @@ class pdf_sponge extends ModelePDFFactures { $pdf->commitTransaction(); } - $posYAfterDescription = $pdf->GetY(); } $nexY = $pdf->GetY(); @@ -848,12 +825,10 @@ class pdf_sponge extends ModelePDFFactures $pdf->setPage($pageposafter); $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80))); //$pdf->SetDrawColor(190,190,200); - $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1); + $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY); $pdf->SetLineStyle(array('dash'=>0)); } - $nexY += 2; // Add space between lines - // Detect if some page were added automatically and output _tableau for past pages while ($pagenb < $pageposafter) { $pdf->setPage($pagenb); @@ -2242,7 +2217,7 @@ class pdf_sponge extends ModelePDFFactures // Default field style for content $this->defaultContentsFieldsStyle = array( 'align' => 'R', // R,C,L - 'padding' => array(0.5, 1, 0.5, 1), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + 'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ); // Default field style for content @@ -2279,10 +2254,11 @@ class pdf_sponge extends ModelePDFFactures 'align' => 'L', // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label // 'label' => ' ', // the final label - 'padding' => array(0.5, 1, 0.5, 1), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ), 'content' => array( 'align' => 'L', + 'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ), ); @@ -2429,4 +2405,5 @@ class pdf_sponge extends ModelePDFFactures $this->cols = $hookmanager->resArray; } } + } From 6de74e774ec0d4af6ae43e2812448941553f2d6f Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 24 Feb 2020 19:50:07 +0000 Subject: [PATCH 12/45] Fixing style errors. --- htdocs/core/class/commondocgenerator.class.php | 3 ++- htdocs/core/modules/facture/doc/pdf_sponge.modules.php | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 048c70e7f68..886e0a6df26 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -1121,7 +1121,8 @@ abstract class CommonDocGenerator * @param $hidedesc * @param $issupplierline */ - function printColDescContent($pdf, &$curY, $colKey, $object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $issupplierline = 0){ + function printColDescContent($pdf, &$curY, $colKey, $object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $issupplierline = 0) + { // load desc col params $colDef = $this->cols[$colKey]; // save curent cell padding diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 224f3522382..b47fc724c63 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -2405,5 +2405,4 @@ class pdf_sponge extends ModelePDFFactures $this->cols = $hookmanager->resArray; } } - } From 7f2dd19bb07621f975d60b108d4d3a5096f24470 Mon Sep 17 00:00:00 2001 From: ATM john Date: Mon, 24 Feb 2020 21:43:33 +0100 Subject: [PATCH 13/45] Fix pdf cell padding for model cyan, erathosthene, espadon, cornas --- .../core/class/commondocgenerator.class.php | 7 +-- .../commande/doc/pdf_eratosthene.modules.php | 32 ++++--------- .../expedition/doc/pdf_espadon.modules.php | 44 +++--------------- .../facture/doc/pdf_sponge.modules.php | 6 +-- .../modules/propale/doc/pdf_cyan.modules.php | 46 +++++-------------- .../supplier_order/doc/pdf_cornas.modules.php | 43 +++-------------- 6 files changed, 39 insertions(+), 139 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 886e0a6df26..d1334a5cf03 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -1112,16 +1112,17 @@ abstract class CommonDocGenerator * print standard column content * * @param TCPDF $pdf pdf object - * @param object $object CommonObject + * @param float $curY curent Y position * @param string $colKey the column key + * @param object $object CommonObject * @param $i * @param $outputlangs - * @param float $curY curent Y position * @param $hideref * @param $hidedesc * @param $issupplierline + * @return null */ - function printColDescContent($pdf, &$curY, $colKey, $object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $issupplierline = 0) + public function printColDescContent($pdf, &$curY, $colKey, $object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $issupplierline = 0) { // load desc col params $colDef = $this->cols[$colKey]; diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index 69bb0be2529..e83e164d076 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -546,9 +546,7 @@ class pdf_eratosthene extends ModelePDFCommandes $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop); $pdf->rollbackTransaction(true); - $iniY = $tab_top + $this->tabTitleHeight + 2; - $curY = $tab_top + $this->tabTitleHeight + 2; - $nexY = $tab_top + $this->tabTitleHeight + 2; + $nexY = $tab_top + $this->tabTitleHeight; // Loop on each lines $pageposbeforeprintlines = $pdf->getPage(); @@ -567,12 +565,9 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. $pageposbefore = $pdf->getPage(); - // Description of product line - $curX = $this->posxdesc - 1; $showpricebeforepagebreak = 1; $posYAfterImage = 0; - $posYAfterDescription = 0; if ($this->getColumnStatus('photo')) { @@ -603,19 +598,8 @@ class pdf_eratosthene extends ModelePDFCommandes if ($this->getColumnStatus('desc')) { $pdf->startTransaction(); - pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc); - $posYAfterDescription = $pdf->GetY(); - // Display extrafield if needed - $params = array( - 'display' => 'list', - 'printableEnable' => array(3), - 'printableEnableNotEmpty' => array(4) - ); - $extrafieldDesc = $this->getExtrafieldsInHtml($object->lines[$i], $outputlangs, $params); - if(!empty($extrafieldDesc)){ - $this->printStdColumnContent($pdf, $posYAfterDescription, 'desc', $extrafieldDesc); - } + $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc); $pageposafter = $pdf->getPage(); if ($pageposafter > $pageposbefore) // There is a pagebreak @@ -624,7 +608,8 @@ class pdf_eratosthene extends ModelePDFCommandes $pageposafter = $pageposbefore; //print $pageposafter.'-'.$pageposbefore;exit; $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. - pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc); + + $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc); $pageposafter = $pdf->getPage(); $posyafter = $pdf->GetY(); if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text @@ -651,7 +636,6 @@ class pdf_eratosthene extends ModelePDFCommandes { $pdf->commitTransaction(); } - $posYAfterDescription = $pdf->GetY(); } @@ -788,11 +772,10 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->setPage($pageposafter); $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80))); //$pdf->SetDrawColor(190,190,200); - $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1); + $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY); $pdf->SetLineStyle(array('dash'=>0)); } - $nexY += 2; // Add space between lines // Detect if some page were added automatically and output _tableau for past pages while ($pagenb < $pageposafter) @@ -1704,7 +1687,7 @@ class pdf_eratosthene extends ModelePDFCommandes // Default field style for content $this->defaultContentsFieldsStyle = array( 'align' => 'R', // R,C,L - 'padding' => array(0.5, 1, 0.5, 1), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + 'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ); // Default field style for content @@ -1741,10 +1724,11 @@ class pdf_eratosthene extends ModelePDFCommandes 'align' => 'L', // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label // 'label' => ' ', // the final label - 'padding' => array(0.5, 1, 0.5, 1), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + 'padding' => array(0.5, 1, 0.5, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ), 'content' => array( 'align' => 'L', + 'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ), ); diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index 7843eb6e087..6268f84d127 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -418,9 +418,7 @@ class pdf_espadon extends ModelePdfExpedition $pdf->rollbackTransaction(true); - $iniY = $tab_top + $this->tabTitleHeight + 2; - $curY = $tab_top + $this->tabTitleHeight + 2; - $nexY = $tab_top + $this->tabTitleHeight + 2; + $nexY = $tab_top + $this->tabTitleHeight; // Loop on each lines for ($i = 0; $i < $nblines; $i++) @@ -473,40 +471,15 @@ class pdf_espadon extends ModelePdfExpedition if ($this->getColumnStatus('desc')) { $pdf->startTransaction(); - pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc); - $posYAfterDescription = $pdf->GetY(); - // Display extrafield if needed - $params = array( - 'display' => 'list', - 'printableEnable' => array(3), - 'printableEnableNotEmpty' => array(4) - ); - $extrafieldDesc = $this->getExtrafieldsInHtml($object->lines[$i], $outputlangs, $params); - if(!empty($extrafieldDesc)){ - $this->printStdColumnContent($pdf, $posYAfterDescription, 'desc', $extrafieldDesc); - } + $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc); $pageposafter = $pdf->getPage(); if ($pageposafter > $pageposbefore) // There is a pagebreak { $pdf->rollbackTransaction(true); - $pageposafter = $pageposbefore; - //print $pageposafter.'-'.$pageposbefore;exit; - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. - pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc); - $posYAfterDescription = $pdf->GetY(); - // Display extrafield if needed - $params = array( - 'display' => 'list', - 'printableEnable' => array(3), - 'printableEnableNotEmpty' => array(4) - ); - $extrafieldDesc = $this->getExtrafieldsInHtml($object->lines[$i], $outputlangs, $params); - if(!empty($extrafieldDesc)){ - $this->printStdColumnContent($pdf, $posYAfterDescription, 'desc', $extrafieldDesc); - } + $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc); $pageposafter = $pdf->getPage(); $posyafter = $pdf->GetY(); @@ -607,16 +580,13 @@ class pdf_espadon extends ModelePdfExpedition } } - $nexY += 3; - if ($weighttxt && $voltxt) $nexY += 2; - // Add line if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) { $pdf->setPage($pageposafter); $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80))); //$pdf->SetDrawColor(190,190,200); - $pdf->line($this->marge_gauche, $nexY - 1, $this->page_largeur - $this->marge_droite, $nexY - 1); + $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY); $pdf->SetLineStyle(array('dash'=>0)); } @@ -1146,7 +1116,7 @@ class pdf_espadon extends ModelePdfExpedition // Default field style for content $this->defaultContentsFieldsStyle = array( 'align' => 'R', // R,C,L - 'padding' => array(0.5, 1, 0.5, 1), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + 'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ); // Default field style for content @@ -1183,10 +1153,10 @@ class pdf_espadon extends ModelePdfExpedition 'align' => 'L', // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label // 'label' => ' ', // the final label - 'padding' => array(0.5, 1, 0.5, 1), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + 'padding' => array(0.5, 1, 0.5, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ), 'content' => array( - 'align' => 'L', + 'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ), ); diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index b47fc724c63..09acbbda46a 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -582,9 +582,7 @@ class pdf_sponge extends ModelePDFFactures $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop); $pdf->rollbackTransaction(true); - $iniY = $tab_top + $this->tabTitleHeight + 2; - $curY = $tab_top + $this->tabTitleHeight + 2; - $nexY = $tab_top + $this->tabTitleHeight + 0; + $nexY = $tab_top + $this->tabTitleHeight; // Loop on each lines $pageposbeforeprintlines = $pdf->getPage(); @@ -605,7 +603,6 @@ class pdf_sponge extends ModelePDFFactures $showpricebeforepagebreak = 1; $posYAfterImage = 0; - $posYAfterDescription = 0; if ($this->getColumnStatus('photo')) { @@ -640,6 +637,7 @@ class pdf_sponge extends ModelePDFFactures $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc); $pageposafter = $pdf->getPage(); + if ($pageposafter > $pageposbefore) // There is a pagebreak { $pdf->rollbackTransaction(true); diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index aaa64b266de..c45db2f8380 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -564,9 +564,7 @@ class pdf_cyan extends ModelePDFPropales $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop); $pdf->rollbackTransaction(true); - $iniY = $tab_top + $this->tabTitleHeight + 2; - $curY = $tab_top + $this->tabTitleHeight + 2; - $nexY = $tab_top + $this->tabTitleHeight + 2; + $nexY = $tab_top + $this->tabTitleHeight; // Loop on each lines $pageposbeforeprintlines = $pdf->getPage(); @@ -621,40 +619,17 @@ class pdf_cyan extends ModelePDFPropales if ($this->getColumnStatus('desc')) { $pdf->startTransaction(); - pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc); - $posYAfterDescription = $pdf->GetY(); - - // Display extrafield if needed - $params = array( - 'display' => 'list', - 'printableEnable' => array(3), - 'printableEnableNotEmpty' => array(4) - ); - $extrafieldDesc = $this->getExtrafieldsInHtml($object->lines[$i], $outputlangs, $params); - if(!empty($extrafieldDesc)){ - $this->printStdColumnContent($pdf, $posYAfterDescription, 'desc', $extrafieldDesc); - } + $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc); $pageposafter = $pdf->getPage(); + if ($pageposafter > $pageposbefore) // There is a pagebreak { $pdf->rollbackTransaction(true); - $pageposafter = $pageposbefore; - //print $pageposafter.'-'.$pageposbefore;exit; - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. - pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc); - $posYAfterDescription = $pdf->GetY(); - // Display extrafield if needed - $params = array( - 'display' => 'list', - 'printableEnable' => array(3), - 'printableEnableNotEmpty' => array(4) - ); - $extrafieldDesc = $this->getExtrafieldsInHtml($object->lines[$i], $outputlangs, $params); - if(!empty($extrafieldDesc)){ - $this->printStdColumnContent($pdf, $posYAfterDescription, 'desc', $extrafieldDesc); - } + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. + + $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc); $pageposafter = $pdf->getPage(); $posyafter = $pdf->GetY(); @@ -819,11 +794,11 @@ class pdf_cyan extends ModelePDFPropales $pdf->setPage($pageposafter); $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80))); //$pdf->SetDrawColor(190,190,200); - $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1); + $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY); $pdf->SetLineStyle(array('dash'=>0)); } - $nexY += 2; // Add space between lines + // Detect if some page were added automatically and output _tableau for past pages while ($pagenb < $pageposafter) @@ -1865,7 +1840,7 @@ class pdf_cyan extends ModelePDFPropales // Default field style for content $this->defaultContentsFieldsStyle = array( 'align' => 'R', // R,C,L - 'padding' => array(0.5, 1, 0.5, 1), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + 'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ); // Default field style for content @@ -1902,10 +1877,11 @@ class pdf_cyan extends ModelePDFPropales 'align' => 'L', // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label // 'label' => ' ', // the final label - 'padding' => array(0.5, 1, 0.5, 1), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + 'padding' => array(0.5, 1, 0.5, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ), 'content' => array( 'align' => 'L', + 'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ), ); diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index e454e29835c..2d3c766a7c2 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -496,9 +496,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders $height_note = 0; } - $iniY = $tab_top + 7; - $curY = $tab_top + 7; - $nexY = $tab_top + 7; + $nexY = $tab_top + 5; // Use new auto collum system $this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -555,40 +553,14 @@ class pdf_cornas extends ModelePDFSuppliersOrders if ($this->getColumnStatus('desc')) { $pdf->startTransaction(); - pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc); - $posYAfterDescription = $pdf->GetY(); - - // Display extrafield if needed - $params = array( - 'display' => 'list', - 'printableEnable' => array(3), - 'printableEnableNotEmpty' => array(4) - ); - $extrafieldDesc = $this->getExtrafieldsInHtml($object->lines[$i], $outputlangs, $params); - if(!empty($extrafieldDesc)){ - $this->printStdColumnContent($pdf, $posYAfterDescription, 'desc', $extrafieldDesc); - } + $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc, 1); $pageposafter = $pdf->getPage(); if ($pageposafter > $pageposbefore) // There is a pagebreak { $pdf->rollbackTransaction(true); - $pageposafter = $pageposbefore; - //print $pageposafter.'-'.$pageposbefore;exit; - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. - pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->getColumnContentWidth('desc'), 3, $this->getColumnContentXStart('desc'), $curY, $hideref, $hidedesc); - $posYAfterDescription = $pdf->GetY(); - // Display extrafield if needed - $params = array( - 'display' => 'list', - 'printableEnable' => array(3), - 'printableEnableNotEmpty' => array(4) - ); - $extrafieldDesc = $this->getExtrafieldsInHtml($object->lines[$i], $outputlangs, $params); - if(!empty($extrafieldDesc)){ - $this->printStdColumnContent($pdf, $posYAfterDescription, 'desc', $extrafieldDesc); - } + $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc, 1); $pageposafter = $pdf->getPage(); $posyafter = $pdf->GetY(); @@ -750,12 +722,10 @@ class pdf_cornas extends ModelePDFSuppliersOrders $pdf->setPage($pageposafter); $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80))); //$pdf->SetDrawColor(190,190,200); - $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1); + $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY); $pdf->SetLineStyle(array('dash'=>0)); } - $nexY += 2; // Add space between lines - // Detect if some page were added automatically and output _tableau for past pages while ($pagenb < $pageposafter) { @@ -1509,7 +1479,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders // Default field style for content $this->defaultContentsFieldsStyle = array( 'align' => 'R', // R,C,L - 'padding' => array(0.5, 1, 0.5, 1), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + 'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ); // Default field style for content @@ -1546,10 +1516,11 @@ class pdf_cornas extends ModelePDFSuppliersOrders 'align' => 'L', // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label // 'label' => ' ', // the final label - 'padding' => array(0.5, 1, 0.5, 1), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + 'padding' => array(0.5, 1, 0.5, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ), 'content' => array( 'align' => 'L', + 'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left ), ); From ae890d021c60d43169bc1abda18155615bd9b01e Mon Sep 17 00:00:00 2001 From: ATM john Date: Mon, 24 Feb 2020 21:50:01 +0100 Subject: [PATCH 14/45] Fix comments --- htdocs/core/class/commondocgenerator.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index d1334a5cf03..bf1fabb7d19 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -1109,17 +1109,17 @@ abstract class CommonDocGenerator /** - * print standard column content + * print description column content * * @param TCPDF $pdf pdf object * @param float $curY curent Y position * @param string $colKey the column key * @param object $object CommonObject - * @param $i - * @param $outputlangs - * @param $hideref - * @param $hidedesc - * @param $issupplierline + * @param int $i + * @param Translate $outputlangs Output language + * @param int $hideref hide ref + * @param int $hidedesc hide desc + * @param int $issupplierline if object need supplier product * @return null */ public function printColDescContent($pdf, &$curY, $colKey, $object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, $issupplierline = 0) From 3e492b8a5bbf1c5aede1cc33149c64932914442d Mon Sep 17 00:00:00 2001 From: ATM john Date: Mon, 24 Feb 2020 22:08:04 +0100 Subject: [PATCH 15/45] Fix title padding --- .../core/class/commondocgenerator.class.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index bf1fabb7d19..7f56832ece8 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -1400,7 +1400,7 @@ abstract class CommonDocGenerator /** * Print standard column content * - * @param PDF $pdf Pdf object + * @param TCPDI $pdf Pdf object * @param float $tab_top Tab top position * @param float $tab_height Default tab height * @param Translate $outputlangs Output language @@ -1436,18 +1436,27 @@ abstract class CommonDocGenerator } if (empty($hidetop)) { - $pdf->SetXY($colDef['xStartPos'] + $colDef['title']['padding'][3], $tab_top + $colDef['title']['padding'][0]); - $textWidth = $colDef['width'] - $colDef['title']['padding'][3] - $colDef['title']['padding'][1]; + + // save curent cell padding + $curentCellPaddinds = $pdf->getCellPaddings(); + // set cell padding with column content definition + $pdf->setCellPaddings($colDef['content']['padding'][3], $colDef['content']['padding'][0], $colDef['content']['padding'][1], $colDef['content']['padding'][2]); + + $pdf->SetXY($colDef['xStartPos'], $tab_top); + $textWidth = $colDef['width']; $pdf->MultiCell($textWidth, 2, $colDef['title']['label'], '', $colDef['title']['align']); global $outputlangsbis; if (is_object($outputlangsbis)) { - $pdf->SetXY($colDef['xStartPos'] + $colDef['title']['padding'][3], $tab_top + $colDef['title']['padding'][0] + 4); + $pdf->SetXY($colDef['xStartPos'], $pdf->GetY() - $colDef['content']['padding'][0]); $textbis = $outputlangsbis->transnoentities($colDef['title']['textkey']); $pdf->MultiCell($textWidth, 2, $textbis, '', $colDef['title']['align']); } - $this->tabTitleHeight = max($pdf->GetY() - $tab_top + $colDef['title']['padding'][2], $this->tabTitleHeight); + $this->tabTitleHeight = max($pdf->GetY() - $tab_top, $this->tabTitleHeight); + + // restore cell padding + $pdf->setCellPaddings($curentCellPaddinds['L'], $curentCellPaddinds['T'], $curentCellPaddinds['R'], $curentCellPaddinds['B']); } } } From 5a77716b93b3ac55e0aa102ef68cbe76c7bcd5d1 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 24 Feb 2020 21:10:14 +0000 Subject: [PATCH 16/45] Fixing style errors. --- htdocs/core/class/commondocgenerator.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 7f56832ece8..4c256537609 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -1436,7 +1436,6 @@ abstract class CommonDocGenerator } if (empty($hidetop)) { - // save curent cell padding $curentCellPaddinds = $pdf->getCellPaddings(); // set cell padding with column content definition From 9c1fdf1c5273ed03f91bbc96db46af5d35d38cfd Mon Sep 17 00:00:00 2001 From: ATM john Date: Mon, 24 Feb 2020 22:12:36 +0100 Subject: [PATCH 17/45] Fix missing php doc --- htdocs/core/class/commondocgenerator.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 7f56832ece8..932edd92901 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -1115,7 +1115,7 @@ abstract class CommonDocGenerator * @param float $curY curent Y position * @param string $colKey the column key * @param object $object CommonObject - * @param int $i + * @param int $i the $object->lines array key * @param Translate $outputlangs Output language * @param int $hideref hide ref * @param int $hidedesc hide desc From c216b7cae5c2fdcf89a27db33971f988c0610b40 Mon Sep 17 00:00:00 2001 From: ATM john Date: Mon, 24 Feb 2020 22:34:34 +0100 Subject: [PATCH 18/45] fix title padding definition source --- htdocs/core/class/commondocgenerator.class.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index f1065e170a8..6b82f3f11c1 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -1438,16 +1438,25 @@ abstract class CommonDocGenerator if (empty($hidetop)) { // save curent cell padding $curentCellPaddinds = $pdf->getCellPaddings(); - // set cell padding with column content definition - $pdf->setCellPaddings($colDef['content']['padding'][3], $colDef['content']['padding'][0], $colDef['content']['padding'][1], $colDef['content']['padding'][2]); + + global $outputlangsbis; + if (is_object($outputlangsbis)) { + // set cell padding with column title definition + $pdf->setCellPaddings($colDef['title']['padding'][3], $colDef['title']['padding'][0], $colDef['title']['padding'][1], 0.5); + } + else{ + // set cell padding with column title definition + $pdf->setCellPaddings($colDef['title']['padding'][3], $colDef['title']['padding'][0], $colDef['title']['padding'][1], $colDef['title']['padding'][2]); + } $pdf->SetXY($colDef['xStartPos'], $tab_top); $textWidth = $colDef['width']; $pdf->MultiCell($textWidth, 2, $colDef['title']['label'], '', $colDef['title']['align']); - global $outputlangsbis; + if (is_object($outputlangsbis)) { - $pdf->SetXY($colDef['xStartPos'], $pdf->GetY() - $colDef['content']['padding'][0]); + $pdf->setCellPaddings($colDef['title']['padding'][3], 0, $colDef['title']['padding'][1], $colDef['title']['padding'][2]); + $pdf->SetXY($colDef['xStartPos'], $pdf->GetY()); $textbis = $outputlangsbis->transnoentities($colDef['title']['textkey']); $pdf->MultiCell($textWidth, 2, $textbis, '', $colDef['title']['align']); } From d9b9913e8a106060b7abafe3e24f5939713ca787 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Sun, 1 Mar 2020 04:52:12 +0100 Subject: [PATCH 19/45] NEW: Accountancy - Add mode intra & export for product or service bought --- htdocs/accountancy/admin/defaultaccounts.php | 12 +- htdocs/accountancy/admin/productaccount.php | 125 ++++++++++++++++-- htdocs/accountancy/supplier/index.php | 21 ++- htdocs/accountancy/supplier/list.php | 89 ++++++++++--- htdocs/core/modules/modProduct.class.php | 17 ++- htdocs/core/modules/modService.class.php | 13 +- .../install/mysql/migration/11.0.0-12.0.0.sql | 3 + htdocs/install/mysql/tables/llx_product.sql | 2 + htdocs/langs/en_US/accountancy.lang | 9 ++ htdocs/langs/en_US/products.lang | 4 +- htdocs/product/card.php | 114 ++++++++++++++++ htdocs/product/class/product.class.php | 45 +++++-- htdocs/product/list.php | 38 +++++- 13 files changed, 429 insertions(+), 63 deletions(-) diff --git a/htdocs/accountancy/admin/defaultaccounts.php b/htdocs/accountancy/admin/defaultaccounts.php index c0c3f835481..7f3ba99a157 100644 --- a/htdocs/accountancy/admin/defaultaccounts.php +++ b/htdocs/accountancy/admin/defaultaccounts.php @@ -54,19 +54,27 @@ $list_account_main = array ( $list_account = array (); $list_account[] = '---Product---'; -$list_account[] = 'ACCOUNTING_PRODUCT_BUY_ACCOUNT'; $list_account[] = 'ACCOUNTING_PRODUCT_SOLD_ACCOUNT'; if ($mysoc->isInEEC()) { $list_account[] = 'ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT'; } $list_account[] = 'ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT'; +$list_account[] = 'ACCOUNTING_PRODUCT_BUY_ACCOUNT'; +if ($mysoc->isInEEC()) { + $list_account[] = 'ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT'; +} +$list_account[] = 'ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT'; $list_account[] = '---Service---'; -$list_account[] = 'ACCOUNTING_SERVICE_BUY_ACCOUNT'; $list_account[] = 'ACCOUNTING_SERVICE_SOLD_ACCOUNT'; if ($mysoc->isInEEC()) { $list_account[] = 'ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT'; } $list_account[] = 'ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT'; +$list_account[] = 'ACCOUNTING_SERVICE_BUY_ACCOUNT'; +if ($mysoc->isInEEC()) { + $list_account[] = 'ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT'; +} +$list_account[] = 'ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT'; $list_account[] = '---Other---'; $list_account[] = 'ACCOUNTING_VAT_BUY_ACCOUNT'; $list_account[] = 'ACCOUNTING_VAT_SOLD_ACCOUNT'; diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 60c9c88f0c8..0e68703846e 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -117,7 +117,9 @@ if ($action == 'update') { 'ACCOUNTANCY_SELL', 'ACCOUNTANCY_SELL_INTRA', 'ACCOUNTANCY_SELL_EXPORT', - 'ACCOUNTANCY_BUY' + 'ACCOUNTANCY_BUY', + 'ACCOUNTANCY_BUY_INTRA', + 'ACCOUNTANCY_BUY_EXPORT' ); if (in_array($accounting_product_mode, $accounting_product_modes)) { @@ -159,6 +161,12 @@ if ($action == 'update') { if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { $sql .= " SET accountancy_code_buy = ".$accounting->account_number; } + if ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { + $sql .= " SET accountancy_code_buy = ".$accounting->account_number; + } + if ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { + $sql .= " SET accountancy_code_buy = ".$accounting->account_number; + } if ($accounting_product_mode == 'ACCOUNTANCY_SELL') { $sql .= " SET accountancy_code_sell = ".$accounting->account_number; } @@ -204,7 +212,11 @@ $form = new FormAccounting($db); $accounting = new AccountingAccount($db); // TODO: we should need to check if result is already exists accountaccount rowid..... $aarowid_servbuy = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT, 1); +$aarowid_servbuy_intra = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT, 1); +$aarowid_servbuy_export = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT, 1); $aarowid_prodbuy = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT, 1); +$aarowid_prodbuy_intra = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT, 1); +$aarowid_prodbuy_export = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT, 1); $aarowid_servsell = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT, 1); $aarowid_servsell_intra = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT, 1); $aarowid_servsell_export = $accounting->fetch('', $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT, 1); @@ -213,7 +225,11 @@ $aarowid_prodsell_intra = $accounting->fetch('', $conf->global->ACCOUNTING_P $aarowid_prodsell_export = $accounting->fetch('', $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT, 1); $aacompta_servbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); +$aacompta_servbuy_intra = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); +$aacompta_servbuy_export = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); $aacompta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); +$aacompta_prodbuy_intra = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); +$aacompta_prodbuy_export = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); $aacompta_servsell = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT : $langs->trans("CodeNotDef")); $aacompta_servsell_intra = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); $aacompta_servsell_export = (! empty($conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); @@ -228,7 +244,8 @@ $pcgvercode = dol_getIdFromCode($db, $pcgverid, 'accounting_system', 'rowid', 'p if (empty($pcgvercode)) $pcgvercode=$pcgverid; $sql = "SELECT p.rowid, p.ref, p.label, p.description, p.tosell, p.tobuy,"; -$sql.= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export, p.accountancy_code_buy,"; +$sql.= " p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,"; +$sql.= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export,"; $sql.= " p.tms, p.fk_product_type as product_type,"; $sql.= " aa.rowid as aaid"; $sql.= " FROM " . MAIN_DB_PREFIX . "product as p"; @@ -236,6 +253,14 @@ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON"; if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { $sql.=" p.accountancy_code_buy = aa.account_number AND aa.fk_pcg_version = '" . $pcgvercode . "'"; } +elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') +{ + $sql.=" p.accountancy_code_buy_intra = aa.account_number AND aa.fk_pcg_version = '" . $pcgvercode . "'"; +} +elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') +{ + $sql.=" p.accountancy_code_buy_export = aa.account_number AND aa.fk_pcg_version = '" . $pcgvercode . "'"; +} elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') { $sql.=" p.accountancy_code_sell = aa.account_number AND aa.fk_pcg_version = '" . $pcgvercode . "'"; @@ -253,6 +278,14 @@ if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { if (strlen(trim($search_current_account))) { $sql .= natural_search("p.accountancy_code_buy", $search_current_account); } +} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { + if (strlen(trim($search_current_account))) { + $sql .= natural_search("p.accountancy_code_buy_intra", $search_current_account); + } +} elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { + if (strlen(trim($search_current_account))) { + $sql .= natural_search("p.accountancy_code_buy_export", $search_current_account); + } } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') { if (strlen(trim($search_current_account))) { $sql .= natural_search("p.accountancy_code_sell", $search_current_account); @@ -356,6 +389,13 @@ if ($result) print "\n"; print ' ' . $langs->trans('OptionModeProductBuy') . ''; print ''.$langs->trans('OptionModeProductBuyDesc')."\n"; + if ($mysoc->isInEEC()) + { + print ' ' . $langs->trans('OptionModeProductBuyIntra') . ''; + print '' . $langs->trans('OptionModeProductBuyDesc') . "\n"; + } + print ' ' . $langs->trans('OptionModeProductBuyExport') . ''; + print ''.$langs->trans('OptionModeProductBuyDesc')."\n"; print "\n"; print '
'; @@ -386,7 +426,7 @@ if ($result) print ''.$form->selectyesno('search_onsell', $search_onsell, 1, false, 1).''; } // On buy - elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY') { + elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY' || $accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { print ''.$form->selectyesno('search_onpurchase', $search_onpurchase, 1, false, 1).''; } // Current account @@ -416,10 +456,16 @@ if ($result) } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') { print_liste_field_titre("OnSell", $_SERVER["PHP_SELF"], "p.tosell", "", $param, '', $sortfield, $sortorder, 'center '); $fieldtosortaccount="p.accountancy_code_sell_export"; - } else { - if ($accounting_product_mode == 'ACCOUNTANCY_BUY') print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center '); + } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY') { + print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center '); $fieldtosortaccount="p.accountancy_code_buy"; - } + } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { + print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center '); + $fieldtosortaccount="p.accountancy_code_buy_intra"; + } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { + print_liste_field_titre("OnBuy", $_SERVER["PHP_SELF"], "p.tobuy", "", $param, '', $sortfield, $sortorder, 'center '); + $fieldtosortaccount="p.accountancy_code_buy_export"; + } print_liste_field_titre("CurrentDedicatedAccountingAccount", $_SERVER["PHP_SELF"], $fieldtosortaccount, "", $param, '', $sortfield, $sortorder); print_liste_field_titre("AssignDedicatedAccountingAccount"); $clickpitco=$form->showCheckAddButtons('checkforselect', 1); @@ -482,11 +528,40 @@ if ($result) // Purchases if ($obj->product_type == 0) { - $compta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); - $compta_prodbuy_id = $aarowid_prodbuy; - } else { - $compta_prodbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); - $compta_prodbuy_id = $aarowid_servbuy; + if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { + $compta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy_id = $aarowid_prodbuy; + } + elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { + $compta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy_id = $aarowid_prodbuy_intra; + } + elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { + $compta_prodbuy = (! empty($conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy_id = $aarowid_prodbuy_export; + } + else { + $compta_prodbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy_id = $aarowid_servbuy; + } + } + else { + if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { + $compta_prodbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy_id = $aarowid_prodbuy; + } + elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { + $compta_prodbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy_id = $aarowid_prodbuy_intra; + } + elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { + $compta_prodbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy_id = $aarowid_prodbuy_export; + } + else { + $compta_prodbuy = (! empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef")); + $compta_prodbuy_id = $aarowid_servbuy; + } } print ''; @@ -509,7 +584,7 @@ if ($result) if ($accounting_product_mode == 'ACCOUNTANCY_SELL' || $accounting_product_mode == 'ACCOUNTANCY_SELL_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_SELL_EXPORT') print ''.$product_static->getLibStatut(3, 0).''; - if ($accounting_product_mode == 'ACCOUNTANCY_BUY') + if ($accounting_product_mode == 'ACCOUNTANCY_BUY' || $accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA' || $accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') print ''.$product_static->getLibStatut(3, 1).''; // Current accounting account @@ -517,6 +592,12 @@ if ($result) if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { print length_accountg($obj->accountancy_code_buy); if ($obj->accountancy_code_buy && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); + } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { + print length_accountg($obj->accountancy_code_buy_intra); + if ($obj->accountancy_code_sell && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); + } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { + print length_accountg($obj->accountancy_code_buy_export); + if ($obj->accountancy_code_sell && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') { print length_accountg($obj->accountancy_code_sell); if ($obj->accountancy_code_sell && empty($obj->aaid)) print ' '.img_warning($langs->trans("ValueNotIntoChartOfAccount")); @@ -540,6 +621,26 @@ if ($result) if (! empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid print $form->select_account($defaultvalue, 'codeventil_' . $product_static->id, 1, array(), 1); print ''; + } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_INTRA') { + // Accounting account buy intra (In EEC) + print ''; + //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code + if (empty($defaultvalue)) $defaultvalue=$compta_prodbuy_intra; + $codesell=length_accountg($obj->accountancy_code_buy_intra); + //var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell); + if (! empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid + print $form->select_account($defaultvalue, 'codeventil_' . $product_static->id, 1, array(), 1); + print ''; + } elseif ($accounting_product_mode == 'ACCOUNTANCY_BUY_EXPORT') { + // Accounting account buy export (Out of EEC) + print ''; + //$defaultvalue=GETPOST('codeventil_' . $product_static->id,'alpha'); This is id and we need a code + if (empty($defaultvalue)) $defaultvalue=$compta_prodbuy_export; + $codesell=length_accountg($obj->accountancy_code_buy_export); + //var_dump($defaultvalue.' - '.$codesell.' - '.$compta_prodsell); + if (! empty($obj->aaid)) $defaultvalue = ''; // Do not suggest default new value is code is already valid + print $form->select_account($defaultvalue, 'codeventil_' . $product_static->id, 1, array(), 1); + print ''; } elseif ($accounting_product_mode == 'ACCOUNTANCY_SELL') { // Accounting account sell print ''; diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index 3bc44698029..3d32694218d 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -119,8 +119,9 @@ if ($action == 'validatehistory') { // Supplier Invoice Lines (must be same request than into page list.php for manual binding) $sql = "SELECT f.rowid as facid, f.ref, f.ref_supplier, f.libelle as invoice_label, f.datef, f.type as ftype,"; $sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; - $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_buy as code_buy, p.tva_tx as tva_tx_prod,"; - $sql .= " aa.rowid as aarowid,"; + $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type,"; + $sql .= " p.accountancy_code_buy as code_buy, p.accountancy_code_buy_intra as code_buy_intra, p.accountancy_code_buy_export as code_buy_export, p.tva_tx as tva_tx_prod,"; + $sql .= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export,"; $sql .= " co.code as country_code, co.label as country_label,"; $sql .= " s.tva_intra"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; @@ -128,7 +129,9 @@ if ($action == 'validatehistory') { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays "; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn_det as l ON f.rowid = l.fk_facture_fourn"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$chartaccountcode."' AND aa.entity = ".$conf->entity; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$chartaccountcode."' AND aa.entity = ".$conf->entity; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON p.accountancy_code_buy_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$chartaccountcode."' AND aa2.entity = ".$conf->entity; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON p.accountancy_code_buy_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$chartaccountcode."' AND aa3.entity = ".$conf->entity; $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; $sql .= " AND l.product_type <= 2"; @@ -157,16 +160,12 @@ if ($action == 'validatehistory') { $suggestedaccountingaccountfor = ''; } else { if ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale - //$objp->code_buy_p = $objp->code_buy_intra; - $objp->code_buy_p = $objp->code_buy; - //$objp->aarowid_suggest = $objp->aarowid_intra; - $objp->aarowid_suggest = $objp->aarowid; + $objp->code_buy_p = $objp->code_buy_intra; + $objp->aarowid_suggest = $objp->aarowid_intra; $suggestedaccountingaccountfor = 'eec'; } else { // Foreign sale - //$objp->code_buy_p = $objp->code_buy_export; - $objp->code_buy_p = $objp->code_buy; - //$objp->aarowid_suggest = $objp->aarowid_export; - $objp->aarowid_suggest = $objp->aarowid; + $objp->code_buy_p = $objp->code_buy_export; + $objp->aarowid_suggest = $objp->aarowid_export; $suggestedaccountingaccountfor = 'export'; } } diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index ecd41f2f9da..d7a650e1f3d 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -211,7 +211,8 @@ if (empty($chartaccountcode)) $sql = "SELECT f.rowid as facid, f.ref, f.ref_supplier, f.libelle as invoice_label, f.datef, f.type as ftype,"; $sql .= " l.rowid, l.fk_product, l.description, l.total_ht, l.fk_code_ventilation, l.product_type as type_l, l.tva_tx as tva_tx_line, l.vat_src_code,"; $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type, p.accountancy_code_buy as code_buy, p.tva_tx as tva_tx_prod,"; -$sql .= " aa.rowid as aarowid,"; +$sql .= " p.accountancy_code_buy_intra as code_buy_intra, p.accountancy_code_buy_export as code_buy_export,"; +$sql .= " aa.rowid as aarowid, aa2.rowid as aarowid_intra, aa3.rowid as aarowid_export,"; $sql .= " co.code as country_code, co.label as country_label,"; $sql .= " s.tva_intra"; $parameters = array(); @@ -222,7 +223,9 @@ $sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = s.fk_pays "; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."facture_fourn_det as l ON f.rowid = l.fk_facture_fourn"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = l.fk_product"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON p.accountancy_code_buy = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$chartaccountcode."' AND aa.entity = ".$conf->entity; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON p.accountancy_code_sell = aa.account_number AND aa.active = 1 AND aa.fk_pcg_version = '".$chartaccountcode."' AND aa.entity = ".$conf->entity; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa2 ON p.accountancy_code_sell_intra = aa2.account_number AND aa2.active = 1 AND aa2.fk_pcg_version = '".$chartaccountcode."' AND aa2.entity = ".$conf->entity; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa3 ON p.accountancy_code_sell_export = aa3.account_number AND aa3.active = 1 AND aa3.fk_pcg_version = '".$chartaccountcode."' AND aa3.entity = ".$conf->entity; $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; $sql .= " AND l.product_type <= 2"; // Add search filter like @@ -414,7 +417,6 @@ if ($result) { // issue : if we change product_type value in product DB it should differ from the value stored in facturedet DB ! $objp->code_buy_l = ''; $objp->code_buy_p = ''; - $objp->aarowid_suggest = ''; $product_static->ref = $objp->product_ref; $product_static->id = $objp->product_id; @@ -426,28 +428,67 @@ if ($result) { $facturefourn_static->type = $objp->type; $code_buy_p_notset = ''; - $objp->aarowid_suggest = $objp->aarowid; + $objp->aarowid_suggest = ''; // Will be set later + $isBuyerInEEC = isInEEC($objp); + + $suggestedaccountingaccountbydefaultfor = ''; if ($objp->type_l == 1) { - $objp->code_buy_l = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : ''); - if ($objp->aarowid == '') - $objp->aarowid_suggest = $aarowid_s; + if ($objp->country_code == $mysoc->country_code || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) + $objp->code_buy_l = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT : ''); + $suggestedaccountingaccountbydefaultfor = ''; + } else { + if ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale + $objp->code_buy_l = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT : ''); + $suggestedaccountingaccountbydefaultfor = 'eec'; + } else { // Foreign sale + $objp->code_buy_l = (!empty($conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT : ''); + $suggestedaccountingaccountbydefaultfor = 'export'; + } + } } elseif ($objp->type_l == 0) { - $objp->code_buy_l = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT : ''); - if ($objp->aarowid == '') - $objp->aarowid_suggest = $aarowid_p; + if ($objp->country_code == $mysoc->country_code || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) + $objp->code_buy_l = (!empty($conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT : ''); + $suggestedaccountingaccountbydefaultfor = ''; + } else { + if ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale + $objp->code_buy_l = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT : ''); + $suggestedaccountingaccountbydefaultfor = 'eec'; + } else { + $objp->code_buy_l = (!empty($conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT) ? $conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT : ''); + $suggestedaccountingaccountbydefaultfor = 'export'; + } + } } - if ($objp->code_buy_l == -1) $objp->code_buy_l = ''; + if ($objp->code_sell_l == -1) $objp->code_sell_l = ''; - if (!empty($objp->code_buy)) { - $objp->code_buy_p = $objp->code_buy; // Code on product + // Search suggested account for product/service + $suggestedaccountingaccountfor = ''; + if (($objp->country_code == $mysoc->country_code) || empty($objp->country_code)) { // If buyer in same country than seller (if not defined, we assume it is same country) + $objp->code_buy_p = $objp->code_buy; + $objp->aarowid_suggest = $objp->aarowid; + $suggestedaccountingaccountfor = ''; + } else { + if ($isSellerInEEC && $isBuyerInEEC) { // European intravat sale + $objp->code_buy_p = $objp->code_buy_intra; + $objp->aarowid_suggest = $objp->aarowid_intra; + $suggestedaccountingaccountfor = 'eec'; + } else { // Foreign sale + $objp->code_buy_p = $objp->code_buy_export; + $objp->aarowid_suggest = $objp->aarowid_export; + $suggestedaccountingaccountfor = 'export'; + } + } + + if (! empty($objp->code_buy_p)) { + // Value was defined previously } else { $code_buy_p_notset = 'color:orange'; } if (empty($objp->code_buy_l) && empty($objp->code_buy_p)) $code_buy_p_notset = 'color:red'; - // $objp->code_buy_p is now code of product/service - // $objp->code_buy_l is now default code of product/service + // $objp->code_sell_l is now default code of product/service + // $objp->code_sell_p is now code of product/service print ''; @@ -520,6 +561,21 @@ if ($result) { // Suggested accounting account print ''; $suggestedid = $objp->aarowid_suggest; + if (empty($suggestedid) && empty($objp->code_buy_p) && ! empty($objp->code_buy_l) && empty($conf->global->ACCOUNTANCY_DO_NOT_AUTOFILL_ACCOUNT_WITH_GENERIC)) + { + if (empty($accountingaccount_codetotid_cache[$objp->code_buy_l])) + { + $tmpaccount = new AccountingAccount($db); + $tmpaccount->fetch(0, $objp->code_buy_l, 1); + if ($tmpaccount->id > 0) { + $suggestedid = $tmpaccount->id; + } + $accountingaccount_codetotid_cache[$objp->code_buy_l] = $tmpaccount->id; + } + else { + $suggestedid = $accountingaccount_codetotid_cache[$objp->code_buy_l]; + } + } print $formaccounting->select_account($suggestedid, 'codeventil'.$objp->rowid, 1, array(), 0, 0, 'codeventil maxwidth200 maxwidthonsmartphone', 'cachewithshowemptyone'); print ''; @@ -540,6 +596,9 @@ if ($result) { } else { print $db->error(); } +if ($db->type == 'mysqli') { + $db->query("SET SQL_BIG_SELECTS=0"); // Enable MAX_JOIN_SIZE limitation +} // Add code to auto check the box when we select an account print ' '; if ($invoice->socid != $conf->global->$constforcompanyid) { - print ''; print '

'; - print $langs->trans("Customer").': '.$soc->name; $constantforkey = 'CASHDESK_NO_DECREASE_STOCK'.$_SESSION["takeposterminal"]; if (!empty($conf->stock->enabled) && $conf->global->$constantforkey != "1") diff --git a/htdocs/takepos/takepos.php b/htdocs/takepos/takepos.php index 8d4f8f929c8..13689eed6ff 100644 --- a/htdocs/takepos/takepos.php +++ b/htdocs/takepos/takepos.php @@ -672,7 +672,7 @@ if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) { echo ' - '.dol_print_date(dol_now(), "day").''; ?> - trans("Customer"); ?> + trans("Customer"); ?>

-
+
"parent.$.colorbox.close();", - "span" => "id='printtext'", - "text" => $langs->trans("Cancel"), + "span" => "id='printtext' style='font-weight: bold; font-size: 18pt;'", + "text" => "X", "class" => "poscolordelete" ), ); $numpad = $conf->global->TAKEPOS_NUMPAD; + +print ''; +print ''; +print ''; ?> - - - 0) { $paycode = $paiements[0]->code; - if ($paycode == 'LIQ') $paycode = 'cash'; - if ($paycode == 'CB') $paycode = 'card'; - if ($paycode == 'CHQ') $paycode = 'cheque'; - ?> - - - - - - - + $payIcon = ''; + if ($paycode == 'LIQ') { + $paycode = 'cash'; + $payIcon = 'coins'; + } elseif ($paycode == 'CB') { + $paycode = 'card'; + $payIcon = 'credit-card'; + } elseif ($paycode == 'CHQ') { + $paycode = 'cheque'; + $payIcon = 'money-check'; + } + + print ''; + +} else { + print ''; +} + +print ''; +print ''; +print ''; +?> 1) { $paycode = $paiements[1]->code; - if ($paycode == 'LIQ') $paycode = 'cash'; - if ($paycode == 'CB') $paycode = 'card'; - if ($paycode == 'CHQ') $paycode = 'cheque'; - ?> - - - - - - - + $payIcon = ''; + if ($paycode == 'LIQ') { + $paycode = 'cash'; + $payIcon = 'coins'; + } elseif ($paycode == 'CB') { + $paycode = 'card'; + $payIcon = 'credit-card'; + } elseif ($paycode == 'CHQ') { + $paycode = 'cheque'; + $payIcon = 'money-check'; + } + + print ''; +} else { + $button = array_pop($action_buttons); + print ''; +} + +print ''; +print ''; +print ''; +?> 2) { $paycode = $paiements[2]->code; - if ($paycode == 'LIQ') $paycode = 'cash'; - if ($paycode == 'CB') $paycode = 'card'; - if ($paycode == 'CHQ') $paycode = 'cheque'; - ?> - -trans($paycode).'\');">' . (!empty($payIcon) ? '' : $langs->trans("PaymentTypeShort".$paiements[2]->code)) . ''; +} else { $button = array_pop($action_buttons); - ?> - - - - - -' . $button["text"] . ''; +} + +print ''; +print ''; +print ''; + $i = 3; while ($i < count($paiements)) { - ?> - - trans($paiements[$i]->code).'\');">' . $langs->trans("PaymentTypeShort".$paiements[$i]->code) . ''; $i = $i + 1; } @@ -320,9 +347,7 @@ if ($conf->global->TAKEPOS_ENABLE_SUMUP) { $class = ($i == 3) ? "calcbutton3" : "calcbutton2"; foreach ($action_buttons as $button) { $newclass = $class.($button["class"] ? " ".$button["class"] : ""); - ?> - - '.$button["text"].''; } ?>
From e2a918b9d26454acf3d652a5c09e9cb2efe4697c Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Tue, 10 Mar 2020 11:33:39 +0100 Subject: [PATCH 39/45] FIX blank failure --- htdocs/takepos/pay.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/takepos/pay.php b/htdocs/takepos/pay.php index ad663c90750..4c3762f672e 100644 --- a/htdocs/takepos/pay.php +++ b/htdocs/takepos/pay.php @@ -270,7 +270,6 @@ print ''; - } else { print ''; } From cef268536886a4ac99cb3ed8f202add702edb74f Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Tue, 10 Mar 2020 14:08:28 +0100 Subject: [PATCH 40/45] NEW search on key code "enter" if defined in cash desk --- htdocs/takepos/takepos.php | 52 ++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/htdocs/takepos/takepos.php b/htdocs/takepos/takepos.php index 8d4f8f929c8..93d1a96e805 100644 --- a/htdocs/takepos/takepos.php +++ b/htdocs/takepos/takepos.php @@ -446,28 +446,36 @@ function New() { */ function Search2(keyCodeForEnter) { console.log("Search2 Call ajax search to replace products"); - if(window.event.keyCode == keyCodeForEnter) var key=13; - pageproducts=0; - jQuery(".wrapper2 .catwatermark").hide(); - $.getJSON('/takepos/ajax/ajax.php?action=search&term='+$('#search').val(), function(data) { - for (i = 0; i < ; i++) { - if (typeof (data[i]) == "undefined"){ - $("#prodesc"+i).text(""); - $("#proimg"+i).attr("src","genimg/empty.png"); - $("#prodiv"+i).data("rowid",""); - continue; + + var search = false; + var eventKeyCode = window.event.keyCode; + if (typeof keyCodeForEnter === 'undefined' || eventKeyCode == keyCodeForEnter) { + search = true; + } + + if (search === true) { + pageproducts = 0; + jQuery(".wrapper2 .catwatermark").hide(); + $.getJSON('/takepos/ajax/ajax.php?action=search&term=' + $('#search').val(), function (data) { + for (i = 0; i < ; i++) { + if (typeof (data[i]) == "undefined") { + $("#prodesc" + i).text(""); + $("#proimg" + i).attr("src", "genimg/empty.png"); + $("#prodiv" + i).data("rowid", ""); + continue; + } + var titlestring = 'transnoentities('Ref') . ': '); ?>' + data[i]['ref']; + $("#prodesc" + i).text(data[i]['label']); + $("#prodivdesc" + i).show(); + $("#proimg" + i).attr("title", titlestring); + $("#proimg" + i).attr("src", "genimg/index.php?query=pro&id=" + data[i]['rowid']); + $("#prodiv" + i).data("rowid", data[i]['rowid']); + $("#prodiv" + i).data("iscat", 0); } - var titlestring = 'transnoentities('Ref').': '); ?>'+data[i]['ref']; - $("#prodesc"+i).text(data[i]['label']); - $("#prodivdesc"+i).show(); - $("#proimg"+i).attr("title", titlestring); - $("#proimg"+i).attr("src", "genimg/index.php?query=pro&id="+data[i]['rowid']); - $("#prodiv"+i).data("rowid", data[i]['rowid']); - $("#prodiv"+i).data("iscat", 0); - } - }).always(function(data) { - if(key==13 && data.length==1) ClickProduct(0); - }); + }).always(function (data) { + if (eventKeyCode == keyCodeForEnter && data.length == 1) ClickProduct(0); + }); + } } function Edit(number) { @@ -655,7 +663,7 @@ $( document ).ready(function() { '.$langs->trans('TerminalSelect').'
'; -$keyCodeForEnter = $conf->global->{'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION['takeposterminal']} > 0 ? $conf->global->{'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION['takeposterminal']} : 13; +$keyCodeForEnter = $conf->global->{'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION['takeposterminal']} > 0 ? $conf->global->{'CASHDESK_READER_KEYCODE_FOR_ENTER'.$_SESSION['takeposterminal']} : ''; ?>
From 31e59bbe870d0a45a5412ab0c8cfcc4c7b5863e5 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Tue, 10 Mar 2020 14:18:39 +0100 Subject: [PATCH 41/45] NEW add product if only one found --- htdocs/takepos/takepos.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/takepos.php b/htdocs/takepos/takepos.php index 93d1a96e805..ebced38c37f 100644 --- a/htdocs/takepos/takepos.php +++ b/htdocs/takepos/takepos.php @@ -473,7 +473,7 @@ function Search2(keyCodeForEnter) { $("#prodiv" + i).data("iscat", 0); } }).always(function (data) { - if (eventKeyCode == keyCodeForEnter && data.length == 1) ClickProduct(0); + if (data.length == 1) ClickProduct(0); }); } } From 8f768c6ecae7720b310675385d0d738bc35a4977 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Tue, 10 Mar 2020 14:33:58 +0100 Subject: [PATCH 42/45] NEW add a parameter to sort product by label in cash desk --- htdocs/takepos/admin/setup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/admin/setup.php b/htdocs/takepos/admin/setup.php index 0e8ba28e0bb..19ba5755e7b 100644 --- a/htdocs/takepos/admin/setup.php +++ b/htdocs/takepos/admin/setup.php @@ -175,7 +175,7 @@ print ''; print $langs->trans("SortProductField"); print ''; $prod = new Product($db); -$array = array('rowid' => 'ID', 'ref' => 'Ref', 'datec' => 'DateCreation', 'tms' => 'DateModification'); +$array = array('rowid' => 'ID', 'ref' => 'Ref', 'label' => 'Label', 'datec' => 'DateCreation', 'tms' => 'DateModification'); print $form->selectarray('TAKEPOS_SORTPRODUCTFIELD', $array, (empty($conf->global->TAKEPOS_SORTPRODUCTFIELD) ? 'rowid' : $conf->global->TAKEPOS_SORTPRODUCTFIELD), 0, 0, 0, '', 1); print "\n"; From e4608a1ee58182eb22b83764923ce330b82dc4dd Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Wed, 11 Mar 2020 09:15:52 +0100 Subject: [PATCH 43/45] FIX add only one product if no key code defined --- htdocs/takepos/takepos.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/takepos/takepos.php b/htdocs/takepos/takepos.php index ebced38c37f..13fc910cb9e 100644 --- a/htdocs/takepos/takepos.php +++ b/htdocs/takepos/takepos.php @@ -473,7 +473,7 @@ function Search2(keyCodeForEnter) { $("#prodiv" + i).data("iscat", 0); } }).always(function (data) { - if (data.length == 1) ClickProduct(0); + if ($('#search').val().length > 0 && data.length == 1) ClickProduct(0); }); } } From 898007f0b454760a52e312cd1ba95c0f548a235b Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Wed, 11 Mar 2020 12:30:07 +0100 Subject: [PATCH 44/45] NEW add global reduction in cash desk --- htdocs/takepos/invoice.php | 6 + htdocs/takepos/reduction.php | 219 +++++++++++++++++++++++++++++++++++ htdocs/takepos/takepos.php | 7 ++ 3 files changed, 232 insertions(+) create mode 100644 htdocs/takepos/reduction.php diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 4660032cc15..e6811319199 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -453,6 +453,12 @@ if ($action == "updatereduction") else $result = $invoice->updateline($line->id, $line->desc, $line->multicurrency_subprice, $line->qty, $number, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); } } + $invoice->fetch($placeid); +} elseif ($action == 'update_reduction_global') { + foreach ($invoice->lines as $line) { + $result = $invoice->updateline($line->id, $line->desc, $line->subprice, $line->qty, $number, $line->date_start, $line->date_end, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit); + } + $invoice->fetch($placeid); } diff --git a/htdocs/takepos/reduction.php b/htdocs/takepos/reduction.php new file mode 100644 index 00000000000..a8f77f1ffd7 --- /dev/null +++ b/htdocs/takepos/reduction.php @@ -0,0 +1,219 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/takepos/reduction.php + * \ingroup takepos + * \brief Page with the content of the popup to enter reductions + */ + +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Not disabled cause need to load personalized language +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); // Not disabled cause need to load personalized language +//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); +if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); +if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); +if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); +if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); +if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); + +require '../main.inc.php'; // Load $user and permissions +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; + +$place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant + +$invoiceid = GETPOST('invoiceid', 'int'); + + +/* + * View + */ + +$invoice = new Facture($db); +if ($invoiceid > 0) +{ + $invoice->fetch($invoiceid); +} +else +{ + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'"; + $resql = $db->query($sql); + $obj = $db->fetch_object($resql); + if ($obj) + { + $invoiceid = $obj->rowid; + } + if (!$invoiceid) + { + $invoiceid = 0; // Invoice does not exist yet + } + else + { + $invoice->fetch($invoiceid); + } +} + +$arrayofcss = array('/takepos/css/pos.css.php'); +$arrayofjs = array(); + +top_htmlhead($head, '', 0, 0, $arrayofjs, $arrayofcss); + +$langs->loadLangs(array('main', 'bills', 'cashdesk')); +?> + + + + + + +
+
+trans('Reduction') . '">'; +?> +
+
+ +
+7'; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +?> +
+ + + diff --git a/htdocs/takepos/takepos.php b/htdocs/takepos/takepos.php index 8d4f8f929c8..da1a7f1cd1f 100644 --- a/htdocs/takepos/takepos.php +++ b/htdocs/takepos/takepos.php @@ -398,6 +398,12 @@ function History() $.colorbox({href:"../compta/facture/list.php?contextpage=poslist", width:"90%", height:"80%", transition:"none", iframe:"true", title:"trans("History"); ?>"}); } +function Reduction() { + invoiceid = $("#invoiceid").val(); + console.log("Open popup to enter reduction on invoiceid="+invoiceid); + $.colorbox({href:"reduction.php?place="+place+"&invoiceid="+invoiceid, width:"80%", height:"90%", transition:"none", iframe:"true", title:""}); +} + function CloseBill() { invoiceid = $("#invoiceid").val(); console.log("Open popup to enter payment on invoiceid="+invoiceid); @@ -766,6 +772,7 @@ if (!empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) { } $menus[$r++] = array('title'=>'
'.$langs->trans("History").'
', 'action'=>'History();'); $menus[$r++] = array('title'=>'
'.$langs->trans("FreeZone").'
', 'action'=>'FreeZone();'); +$menus[$r++] = array('title'=>'
'.$langs->trans("Reduction").'
', 'action'=>'Reduction();'); $menus[$r++] = array('title'=>'
'.$langs->trans("Payment").'
', 'action'=>'CloseBill();'); if ($conf->global->TAKEPOS_DIRECT_PAYMENT) { From fc4a98b29c392dfc9e0c57cb168e1ba3bab54e36 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Wed, 11 Mar 2020 15:36:36 +0100 Subject: [PATCH 45/45] NEW add const TAKEPOS_NUMPAD_USE_PAYMENT_ICON to use icons on payment buttons --- htdocs/langs/en_US/cashdesk.lang | 1 + htdocs/langs/fr_FR/cashdesk.lang | 1 + htdocs/takepos/admin/setup.php | 7 +++++++ htdocs/takepos/pay.php | 18 +++++++++--------- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang index 7ddbc71f3e9..d4355566872 100644 --- a/htdocs/langs/en_US/cashdesk.lang +++ b/htdocs/langs/en_US/cashdesk.lang @@ -91,3 +91,4 @@ TakeposConnectorMethodDescription=External module with extra features. Posibilit PrintMethod=Print method ReceiptPrinterMethodDescription=Powerful method with a lot of parameters. Full customizable with templates. Cannot print from the cloud. ByTerminal=By terminal +TakeposNumpadUsePaymentIcon=Use payment icon on numpad diff --git a/htdocs/langs/fr_FR/cashdesk.lang b/htdocs/langs/fr_FR/cashdesk.lang index d14acc778df..03ca0155daa 100644 --- a/htdocs/langs/fr_FR/cashdesk.lang +++ b/htdocs/langs/fr_FR/cashdesk.lang @@ -82,3 +82,4 @@ ReceiptName=Nom du reçu ProductSupplements=Suppléments de produit SupplementCategory=Catégorie des suppléments SortProductField=Champ pour le tri des produits +TakeposNumpadUsePaymentIcon=Utilisation d'icônes sur les touches des modes de règlement du pavé numérique diff --git a/htdocs/takepos/admin/setup.php b/htdocs/takepos/admin/setup.php index 0e8ba28e0bb..9dd398d5240 100644 --- a/htdocs/takepos/admin/setup.php +++ b/htdocs/takepos/admin/setup.php @@ -201,6 +201,13 @@ $array = array(0=>$langs->trans("Numberspad"), 1=>$langs->trans("BillsCoinsPad") print $form->selectarray('TAKEPOS_NUMPAD', $array, (empty($conf->global->TAKEPOS_NUMPAD) ? '0' : $conf->global->TAKEPOS_NUMPAD), 0); print "\n"; +// Numpad use payment icons +print ''; +print $langs->trans('TakeposNumpadUsePaymentIcon'); +print ''; +print ajax_constantonoff("TAKEPOS_NUMPAD_USE_PAYMENT_ICON", array(), $conf->entity, 0, 0, 1, 0); +print "\n"; + // Direct Payment print ''; print $langs->trans('DirectPaymentButton'); diff --git a/htdocs/takepos/pay.php b/htdocs/takepos/pay.php index 4c3762f672e..ce2a4943b84 100644 --- a/htdocs/takepos/pay.php +++ b/htdocs/takepos/pay.php @@ -260,13 +260,13 @@ print ''; @@ -283,13 +283,13 @@ print ''; @@ -307,13 +307,13 @@ print '';