From 1331e8add737ae66638fef468fbd31d879db78c9 Mon Sep 17 00:00:00 2001 From: John Date: Tue, 2 Jan 2018 17:19:42 +0100 Subject: [PATCH 1/7] fix filter for TYPE_SITUATION invoice --- htdocs/compta/facture/list.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 4b734a5e7d9..d7f9384399f 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -785,7 +785,8 @@ if ($resql) Facture::TYPE_STANDARD=>$langs->trans("InvoiceStandard"), Facture::TYPE_REPLACEMENT=>$langs->trans("InvoiceReplacement"), Facture::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"), - Facture::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"), + Facture::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"), + Facture::TYPE_SITUATION=>$langs->trans("InvoiceSituation"), ); //$listtype[Facture::TYPE_PROFORMA]=$langs->trans("InvoiceProForma"); // A proformat invoice is not an invoice but must be an order. print $form->selectarray('search_type', $listtype, $search_type, 1, 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth100'); From 61efda4cbd148b2656df9ddc8023c05fe6badfc3 Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Tue, 2 Jan 2018 17:21:04 +0100 Subject: [PATCH 2/7] FIX : product best price on product list --- htdocs/product/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 8322fec244e..84cf070b39d 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -821,7 +821,7 @@ else if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire) { $htmltext=$product_fourn->display_price_product_fournisseur(1, 1, 0, 1); - print $form->textwithpicto(price($product_fourn->fourn_unitprice).' '.$langs->trans("HT"),$htmltext); + print $form->textwithpicto(price($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent/100) + $product_fourn->fourn_unitcharges - $product_fourn->fourn_remise).' '.$langs->trans("HT"),$htmltext); } else print price($product_fourn->fourn_unitprice).' '.$langs->trans("HT"); } From 25390e5f73f5497ced8d451ea1e903255e619f96 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 3 Jan 2018 17:03:00 +0100 Subject: [PATCH 3/7] fix : linked object (new format of linked_object atribut on 6.0) --- htdocs/fourn/commande/orderstoinvoice.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/htdocs/fourn/commande/orderstoinvoice.php b/htdocs/fourn/commande/orderstoinvoice.php index b1a8c0c08c1..20f9a3674cf 100644 --- a/htdocs/fourn/commande/orderstoinvoice.php +++ b/htdocs/fourn/commande/orderstoinvoice.php @@ -171,16 +171,15 @@ if (($action == 'create' || $action == 'add') && ! $error) { if ($ret < 0) $error++; if ($_POST['origin'] && $_POST['originid']) { - $object->linked_objects = $orders_id; + $linked_orders_ids=array(); + foreach ( $orders_id as $origin => $origin_id ) { + $origin_id = (! empty($origin_id) ? $origin_id : $orders_id[$ii]); + $linked_orders_ids[]=$origin_id; + } + $object->linked_objects = array(GETPOST('origin')=>$linked_orders_ids); $id = $object->create($user); if ($id > 0) { - foreach ( $orders_id as $origin => $origin_id ) { - $origin_id = (! empty($origin_id) ? $origin_id : $orders_id[$ii]); - - $object->add_object_linked(GETPOST('origin'), $origin_id); - } - while ( $ii < $nn ) { $objectsrc = new CommandeFournisseur($db); dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines"); From 58470e0913ad38f4462185295f58379b21005b5a Mon Sep 17 00:00:00 2001 From: gauthier Date: Thu, 4 Jan 2018 12:01:21 +0100 Subject: [PATCH 4/7] FIX : $oldvatrateclean & $newvatrateclean must be set if preg_match === false --- htdocs/product/admin/product_tools.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/admin/product_tools.php b/htdocs/product/admin/product_tools.php index f19f672a25e..c9323f75823 100644 --- a/htdocs/product/admin/product_tools.php +++ b/htdocs/product/admin/product_tools.php @@ -73,7 +73,7 @@ if ($action == 'convert') { $vat_src_code_old = $reg[1]; $oldvatrateclean = preg_replace('/\s*\(.*\)/', '', $oldvatrate); // Remove code into vatrate. - } + } else $oldvatrateclean=$oldvatrate; // Clean vat code new $vat_src_code_new=''; @@ -81,7 +81,7 @@ if ($action == 'convert') { $vat_src_code_new = $reg[1]; $newvatrateclean = preg_replace('/\s*\(.*\)/', '', $newvatrate); // Remove code into vatrate. - } + } else $newvatrateclean=$newvatrate; // If country to edit is my country, so we change customer prices if ($country_id == $mysoc->country_id) From a1ac285a25c9dda1c5caffe4b4ba45bc84e43eb4 Mon Sep 17 00:00:00 2001 From: Paul Dermody Date: Mon, 1 Jan 2018 15:03:08 -0600 Subject: [PATCH 5/7] Fixed automated computation of surface and volume to use correct units. It was failing for inches and feet. --- htdocs/core/lib/product.lib.php | 39 ++++++++++++++++++++++++++ htdocs/product/class/product.class.php | 4 +-- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index b01637d7b08..dd756830f41 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -477,3 +477,42 @@ function measuring_units_string($unit,$measuring_style='') return $measuring_units[$unit]; } + +/** + * Transform a given unit into the square of that unit, if known + * + * @param int $unit Unit key (-3,-2,-1,0,98,99...) + * @return int Squared unit key (-6,-4,-2,0,98,99...) + * @see formproduct->load_measuring_units + */ +function measuring_units_squared($unit) +{ + $measuring_units=array(); + $measuring_units[0] = 0; // m -> m3 + $measuring_units[-1] = -2; // dm-> dm2 + $measuring_units[-2] = -4; // cm -> cm2 + $measuring_units[-3] = -6; // mm -> mm2 + $measuring_units[98] = 98; // foot -> foot2 + $measuring_units[99] = 99; // inch -> inch2 + return $measuring_units[$unit]; +} + + +/** + * Transform a given unit into the cube of that unit, if known + * + * @param int $unit Unit key (-3,-2,-1,0,98,99...) + * @return int Cubed unit key (-9,-6,-3,0,88,89...) + * @see formproduct->load_measuring_units + */ +function measuring_units_cubed($unit) +{ + $measuring_units=array(); + $measuring_units[0] = 0; // m -> m2 + $measuring_units[-1] = -3; // dm-> dm3 + $measuring_units[-2] = -6; // cm -> cm3 + $measuring_units[-3] = -9; // mm -> mm3 + $measuring_units[98] = 88; // foot -> foot3 + $measuring_units[99] = 89; // inch -> inch3 + return $measuring_units[$unit]; +} diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index ed5813c2998..0b40f815816 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -745,12 +745,12 @@ class Product extends CommonObject if (empty($this->surface) && !empty($this->length) && !empty($this->width) && $this->length_units == $this->width_units) { $this->surface = $this->length * $this->width; - $this->surface_units = $this->length_units + $this->width_units; + $this->surface_units = measuring_units_squared($this->length_units); } if (empty($this->volume) && !empty($this->surface_units) && !empty($this->height) && $this->length_units == $this->height_units) { $this->volume = $this->surface * $this->height; - $this->volume_units = $this->surface_units + $this->height_units; + $this->volume_units = measuring_units_cubed($this->height_units); } $this->surface = price2num($this->surface); From 22d92c05408bb42b0b85f2ebe3c36837b69f9fc2 Mon Sep 17 00:00:00 2001 From: atm-ph Date: Mon, 8 Jan 2018 15:25:18 +0100 Subject: [PATCH 6/7] Fix wrong address used into PDF model of supplier payment --- .../compta/paiement/class/paiement.class.php | 26 +++++++++++++++++++ .../doc/pdf_standard.modules.php | 4 +-- htdocs/fourn/class/paiementfourn.class.php | 26 +++++++++++++++++++ 3 files changed, 54 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 7c5b99e2945..729700093e6 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -1114,5 +1114,31 @@ class Paiement extends CommonObject }*/ return ''; } + + /** + * Load the third party of object, from id into this->thirdparty + * + * @param int $force_thirdparty_id Force thirdparty id + * @return int <0 if KO, >0 if OK + */ + function fetch_thirdparty($force_thirdparty_id=0) + { + require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; + + if (empty($force_thirdparty_id)) + { + $billsarray = $this->getBillsArray(); // From payment, the fk_soc isn't available, we should load the first invoice to get him + if (!empty($billsarray)) + { + $supplier_invoice = new FactureFournisseur($this->db); + if ($supplier_invoice->fetch($billsarray[0]) > 0) + { + $force_thirdparty_id = $supplier_invoice->fk_soc; + } + } + } + + return parent::fetch_thirdparty($force_thirdparty_id); + } } diff --git a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php index 6fbfb4b1bf4..7d0772f272c 100644 --- a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php @@ -723,12 +723,12 @@ class pdf_standard extends ModelePDFSuppliersPayments if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { $thirdparty = $object->contact; } else { - $thirdparty = $mysoc; + $thirdparty = $object->thirdparty; } $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); - $carac_client=pdf_build_address($outputlangs,$this->emetteur,$mysoc,((!empty($object->contact))?$object->contact:null),$usecontact,'target',$object); + $carac_client=pdf_build_address($outputlangs,$this->emetteur,$thirdparty,((!empty($object->contact))?$object->contact:null),$usecontact,'target',$object); // Show recipient $widthrecbox=90; diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index 7a709bbce94..c2c98b9f00d 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -734,4 +734,30 @@ class PaiementFourn extends Paiement return $way; } + + /** + * Load the third party of object, from id into this->thirdparty + * + * @param int $force_thirdparty_id Force thirdparty id + * @return int <0 if KO, >0 if OK + */ + function fetch_thirdparty($force_thirdparty_id=0) + { + require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; + + if (empty($force_thirdparty_id)) + { + $billsarray = $this->getBillsArray(); // From payment, the fk_soc isn't available, we should load the first supplier invoice to get him + if (!empty($billsarray)) + { + $supplier_invoice = new FactureFournisseur($this->db); + if ($supplier_invoice->fetch($billsarray[0]) > 0) + { + $force_thirdparty_id = $supplier_invoice->fk_soc; + } + } + } + + return parent::fetch_thirdparty($force_thirdparty_id); + } } From 0f51aa15d867b5c4a1235966b5e6f767d36f5f35 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 10 Jan 2018 10:52:30 +0100 Subject: [PATCH 7/7] Fix: avoid Warning: A non-numeric value encountered --- htdocs/contact/document.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/htdocs/contact/document.php b/htdocs/contact/document.php index da8ef616a4f..eb66ae21a4f 100644 --- a/htdocs/contact/document.php +++ b/htdocs/contact/document.php @@ -58,9 +58,7 @@ $result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', 'ro $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if ($page == -1) { - $page = 0; -} +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -108,7 +106,7 @@ if ($object->id) } $linkback = ''.$langs->trans("BackToList").''; - + $morehtmlref='
'; if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) { @@ -120,11 +118,11 @@ if ($object->id) else $morehtmlref.=$langs->trans("ContactNotLinkedToCompany"); } $morehtmlref.='
'; - + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref); - + print '
'; - + print '
'; print ''; @@ -147,7 +145,7 @@ if ($object->id) print ''; } }*/ - + // Civility print '
'.$langs->trans("UserTitle").''; print $object->getCivilityLabel(); @@ -160,7 +158,7 @@ if ($object->id) print ''; dol_fiche_end(); - + $modulepart = 'contact'; $permission = $user->rights->societe->contact->creer; $permtoedit = $user->rights->societe->contact->creer;