From 4a3ffbb6d4ab4d3456d486435bc83280a46ca228 Mon Sep 17 00:00:00 2001 From: Alfredo Altamirano Date: Wed, 14 Oct 2020 21:57:17 -0500 Subject: [PATCH 1/6] FIX #14927 Change ContratLigne property type to product_type This bug is produced because the ContratLigne class gives a property type instead of a product_type --- htdocs/contrat/class/contrat.class.php | 4 +++- htdocs/core/boxes/box_services_contracts.php | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index e81febde6df..77272c39c62 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -753,6 +753,7 @@ class Contrat extends CommonObject $sql.= " d.total_localtax1,"; $sql.= " d.total_localtax2,"; $sql.= " d.total_ttc,"; + $sql .= " d.product_type,"; $sql.= " d.info_bits, d.fk_product,"; $sql.= " d.date_ouverture_prevue, d.date_ouverture,"; $sql.= " d.date_fin_validite, d.date_cloture,"; @@ -799,6 +800,7 @@ class Contrat extends CommonObject $line->total_ttc = $objp->total_ttc; $line->fk_product = (($objp->fk_product > 0)?$objp->fk_product:0); $line->info_bits = $objp->info_bits; + $line->product_type = $objp->product_type; $line->fk_fournprice = $objp->fk_fournprice; $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); @@ -2563,7 +2565,7 @@ class ContratLigne extends CommonObjectLine public $fk_product; public $statut; // 0 inactive, 4 active, 5 closed - public $type; // 0 for product, 1 for service + public $product_type; // 0 for product, 1 for service /** * @var string diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php index b1330192a11..2b3d3f89727 100644 --- a/htdocs/core/boxes/box_services_contracts.php +++ b/htdocs/core/boxes/box_services_contracts.php @@ -120,7 +120,7 @@ class box_services_contracts extends ModeleBoxes $contratlignestatic->fk_contrat=$objp->rowid; $contratlignestatic->label=$objp->label; $contratlignestatic->description=$objp->description; - $contratlignestatic->type=$objp->type; + $contratlignestatic->product_type = $objp->type; $contratlignestatic->product_id=$objp->product_id; $contratlignestatic->product_ref=$objp->product_ref; From b9cbd84d4ebd380fb6e9850c4b08dbba70dfb195 Mon Sep 17 00:00:00 2001 From: ATM john Date: Thu, 15 Oct 2020 09:30:48 +0200 Subject: [PATCH 2/6] Fix page break --- .../doc/pdf_standard.modules.php | 32 ++++++------------- .../tecnickcom/tcpdf/include/tcpdf_fonts.php | 3 +- 2 files changed, 11 insertions(+), 24 deletions(-) diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index 8aec0cc4105..cdc5f1e1bad 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -361,32 +361,18 @@ class pdf_standard extends ModeleExpenseReport $curY = $nexY; $pdf->startTransaction(); $this->printLine($pdf, $object, $i, $curY, $default_font_size, $outputlangs, $hidedetails); - $pageposafter=$pdf->getPage(); + $pageposafter=$pdf->getPage(); if ($pageposafter > $pageposbefore) { // There is a pagebreak $pdf->rollbackTransaction(true); - $pageposafter = $pageposbefore; - //print $pageposafter.'-'.$pageposbefore;exit; + + $pdf->AddPage('', '', true); + $pdf->setPage($pageposbefore+1); $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. - $this->printLine($pdf, $object, $i, $curY, $default_font_size, $outputlangs, $hidedetails); - $pageposafter = $pdf->getPage(); - $posyafter = $pdf->GetY(); - //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) { - // There is no space left for total+free text - if ($i == ($nblignes-1)) { - // No more lines, and no space left to show total, so we create a new page - $pdf->AddPage('', '', true); - if (! empty($tplidx)) $pdf->useTemplate($tplidx); - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); - $pdf->setPage($pageposafter+1); - } - } - else - { - // We found a page break - $showpricebeforepagebreak=0; - } + if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + + $this->printLine($pdf, $object, $i, $tab_top_newpage, $default_font_size, $outputlangs, $hidedetails); } else // No pagebreak { @@ -554,7 +540,7 @@ class pdf_standard extends ModeleExpenseReport { global $conf; $pdf->SetFont('', '', $default_font_size - 1); - + $pdf->SetTextColor(0, 0, 0); // Accountancy piece $pdf->SetXY($this->posxpiece, $curY); $pdf->writeHTMLCell($this->posxcomment-$this->posxpiece-0.8, 4, $this->posxpiece-1, $curY, $linenumber + 1, 0, 1); diff --git a/htdocs/includes/tecnickcom/tcpdf/include/tcpdf_fonts.php b/htdocs/includes/tecnickcom/tcpdf/include/tcpdf_fonts.php index 9242ca4bfdb..8681dfbdbfa 100644 --- a/htdocs/includes/tecnickcom/tcpdf/include/tcpdf_fonts.php +++ b/htdocs/includes/tecnickcom/tcpdf/include/tcpdf_fonts.php @@ -1149,7 +1149,7 @@ class TCPDF_FONTS { $subsetglyphs[$g] = true; } } - } + } break; } case 6: { // Format 6: Trimmed table mapping @@ -1664,6 +1664,7 @@ class TCPDF_FONTS { * @public static */ public static function unichr($c, $unicode=true) { + $c = intval($c); if (!$unicode) { return chr($c); } elseif ($c <= 0x7F) { From 32d823c7390fdb9fb39edd6fad0203f6f064ae08 Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Thu, 15 Oct 2020 09:40:50 +0200 Subject: [PATCH 3/6] FIX: Unable to edit extrafields in expense report --- htdocs/expensereport/class/expensereport.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index bb543642733..171e82db7bb 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -4,7 +4,7 @@ * Copyright (C) 2015 Alexandre Spangaro * Copyright (C) 2018 Nicolas ZABOURI * Copyright (c) 2018 Frédéric France - * Copyright (C) 2016-2018 Ferran Marcet + * Copyright (C) 2016-2020 Ferran Marcet * * 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 @@ -538,6 +538,8 @@ class ExpenseReport extends CommonObject $this->code_statut = $obj->code_statut; $this->code_paiement = $obj->code_paiement; + $this->fetch_optionals(); + $this->lines = array(); $result=$this->fetch_lines(); From c3a02d0391fe2c7dae117e0a052e14922121eeec Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Oct 2020 20:24:26 +0200 Subject: [PATCH 4/6] Update contrat.class.php --- htdocs/contrat/class/contrat.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 77272c39c62..f548a069a22 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2565,7 +2565,7 @@ class ContratLigne extends CommonObjectLine public $fk_product; public $statut; // 0 inactive, 4 active, 5 closed - public $product_type; // 0 for product, 1 for service + public $type; // 0 for product, 1 for service /** * @var string @@ -2584,6 +2584,7 @@ class ContratLigne extends CommonObjectLine */ public $description; + public $product_type; // 0 for product, 1 for service public $product_ref; public $product_label; From 75290d1bd45e1cf23b44e202daf69b4d3876e1d7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Oct 2020 20:26:12 +0200 Subject: [PATCH 5/6] Update contrat.class.php --- htdocs/contrat/class/contrat.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index f548a069a22..1a7c08551f4 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -800,7 +800,7 @@ class Contrat extends CommonObject $line->total_ttc = $objp->total_ttc; $line->fk_product = (($objp->fk_product > 0)?$objp->fk_product:0); $line->info_bits = $objp->info_bits; - $line->product_type = $objp->product_type; + $line->type = $objp->type; $line->fk_fournprice = $objp->fk_fournprice; $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); @@ -813,6 +813,7 @@ class Contrat extends CommonObject $line->ref = $objp->product_ref; // deprecated $line->product_ref = $objp->product_ref; // Product Ref + $line->product_type = $objp->product_type; // Product Type $line->product_desc = $objp->product_desc; // Product Description $line->product_label = $objp->product_label; // Product Label From 3d68ab405950303ebc24d6513c1a959fbeb8407c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 15 Oct 2020 20:28:27 +0200 Subject: [PATCH 6/6] Update box_services_contracts.php --- htdocs/core/boxes/box_services_contracts.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php index 2b3d3f89727..da88369be51 100644 --- a/htdocs/core/boxes/box_services_contracts.php +++ b/htdocs/core/boxes/box_services_contracts.php @@ -91,7 +91,7 @@ class box_services_contracts extends ModeleBoxes $sql = "SELECT s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; $sql.= " c.rowid, c.ref, c.statut as contract_status, c.ref_customer, c.ref_supplier,"; $sql.= " cd.rowid as cdid, cd.label, cd.description, cd.tms as datem, cd.statut, cd.product_type as type,"; - $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as plabel, p.fk_product_type as ptype, p.entity"; + $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as product_type, p.entity"; $sql.= " FROM (".MAIN_DB_PREFIX."societe as s"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."contrat as c ON s.rowid = c.fk_soc"; $sql.= " INNER JOIN ".MAIN_DB_PREFIX."contratdet as cd ON c.rowid = cd.fk_contrat"; @@ -120,7 +120,8 @@ class box_services_contracts extends ModeleBoxes $contratlignestatic->fk_contrat=$objp->rowid; $contratlignestatic->label=$objp->label; $contratlignestatic->description=$objp->description; - $contratlignestatic->product_type = $objp->type; + $contratlignestatic->type = $objp->type; + $contratlignestatic->product_type = $objp->product_type; $contratlignestatic->product_id=$objp->product_id; $contratlignestatic->product_ref=$objp->product_ref; @@ -164,21 +165,21 @@ class box_services_contracts extends ModeleBoxes $productstatic->type=$objp->ptype; $productstatic->ref=$objp->product_ref; $productstatic->entity=$objp->pentity; - $productstatic->label=$objp->plabel; + $productstatic->label=$objp->product_label; $text = $productstatic->getNomUrl(1, '', 20); - if ($objp->plabel) + if ($objp->product_label) { $text .= ' - '; //$productstatic->ref=$objp->label; //$text .= $productstatic->getNomUrl(0,'',16); - $text .= $objp->plabel; + $text .= $objp->product_label; } $description = $objp->description; // Add description in form if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) { - //$text .= (! empty($objp->description) && $objp->description!=$objp->plabel)?'
'.dol_htmlentitiesbr($objp->description):''; + //$text .= (! empty($objp->description) && $objp->description!=$objp->product_label)?'
'.dol_htmlentitiesbr($objp->description):''; $description = ''; // Already added into main visible desc }