From 7e8fda2d71ef31181c104c9eec81f1001cdb7511 Mon Sep 17 00:00:00 2001 From: sschwebel Date: Fri, 5 Jan 2018 12:09:45 +0100 Subject: [PATCH 1/8] FIX #8029 Unable to make leave request in holyday module wrong variable name in card.php --- htdocs/holiday/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 8e8ab6f287c..0a4d0cb37ca 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -149,7 +149,7 @@ if ($action == 'create') if (! $error) { - $object->fk_user = $userid; + $object->fk_user = $fuserid; $object->description = $description; $object->date_debut = $date_debut; $object->date_fin = $date_fin; From a1ac285a25c9dda1c5caffe4b4ba45bc84e43eb4 Mon Sep 17 00:00:00 2001 From: Paul Dermody Date: Mon, 1 Jan 2018 15:03:08 -0600 Subject: [PATCH 2/8] 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 3/8] 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 4/8] 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; From d99535d9da8af239e41ecdcb1299295fe52fd40a Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Wed, 10 Jan 2018 16:40:43 +0100 Subject: [PATCH 5/8] Fix: Still using property ->client instead of ->thirdparty. --- .../contract/doc/doc_generic_contract_odt.modules.php | 5 +++-- .../modules/product/doc/doc_generic_product_odt.modules.php | 4 ++-- .../core/modules/user/doc/doc_generic_user_odt.modules.php | 4 ++-- .../usergroup/doc/doc_generic_usergroup_odt.modules.php | 4 ++-- htdocs/fichinter/card.php | 6 +++--- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php index f9dac51389f..72ea8925177 100644 --- a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php +++ b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php @@ -1,6 +1,7 @@ * Copyright (C) 2012 Juanjo Menent + * Copyright (C) 2018 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 @@ -280,14 +281,14 @@ class doc_generic_contract_odt extends ModelePDFContract // On peut utiliser le nom de la societe du contact if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; else { - $socobject = $object->client; + $socobject = $object->thirdparty; // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use $contactobject = $object->contact; } } else { - $socobject=$object->client; + $socobject=$object->thirdparty; } // Make substitution $substitutionarray=array( diff --git a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php index 811a99d5b2a..a05e1d6327f 100644 --- a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php +++ b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php @@ -307,14 +307,14 @@ class doc_generic_product_odt extends ModelePDFProduct // On peut utiliser le nom de la societe du contact if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; else { - $socobject = $object->client; + $socobject = $object->thirdparty; // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use $contactobject = $object->contact; } } else { - $socobject=$object->client; + $socobject=$object->thirdparty; } // Make substitution $substitutionarray=array( diff --git a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php index 11ae5729b3b..ee329b0bd7a 100644 --- a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php +++ b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php @@ -304,14 +304,14 @@ class doc_generic_user_odt extends ModelePDFUser // On peut utiliser le nom de la societe du contact if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; else { - $socobject = $object->client; + $socobject = $object->thirdparty; // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use $contactobject = $object->contact; } } else { - $socobject=$object->client; + $socobject=$object->thirdparty; } // Open and load template diff --git a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php index 35367052796..fe54e587e46 100644 --- a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php +++ b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php @@ -306,14 +306,14 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup // On peut utiliser le nom de la societe du contact if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; else { - $socobject = $object->client; + $socobject = $object->thirdparty; // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use $contactobject = $object->contact; } } else { - $socobject=$object->client; + $socobject=$object->thirdparty; } // Make substitution $substitutionarray=array( diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 2cce9534873..c8951a3f035 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -4,7 +4,7 @@ * Copyright (C) 2005-2015 Regis Houssin * Copyright (C) 2011-2017 Juanjo Menent * Copyright (C) 2013 Florian Henry - * Copyright (C) 2014-2015 Ferran Marcet + * Copyright (C) 2014-2018 Ferran Marcet * Copyright (C) 2014-2015 Charlie Benke * Copyright (C) 2015-2016 Abbes Bahfir * @@ -297,7 +297,7 @@ if (empty($reshook)) $outputlangs = $langs; $newlang=''; if (empty($newlang) && GETPOST('lang_id','aZ09')) $newlang=GETPOST('lang_id','aZ09'); - if (empty($newlang)) $newlang=$srcobject->client->default_lang; + if (empty($newlang)) $newlang=$srcobject->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); @@ -878,7 +878,7 @@ if ($action == 'create') $projectid = (!empty($objectsrc->fk_project)?$objectsrc->fk_project:''); - $soc = $objectsrc->client; + $soc = $objectsrc->thirdparty; $note_private = (! empty($objectsrc->note) ? $objectsrc->note : (! empty($objectsrc->note_private) ? $objectsrc->note_private : GETPOST('note_private'))); $note_public = (! empty($objectsrc->note_public) ? $objectsrc->note_public : GETPOST('note_public')); From 0bd45dc64bf93312a4ca19e468442393fd0d07ae Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 10 Jan 2018 20:34:32 +0100 Subject: [PATCH 6/8] fix: search translation into external module files also --- htdocs/admin/translation.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index 651335d0a6d..0c4df916943 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -367,6 +367,14 @@ if ($mode == 'searchkey') foreach($filearray as $file) { $tmpfile=preg_replace('/.lang/i', '', basename($file['name'])); + //Detect if trans coming from extranl module + foreach ($conf->file->dol_document_root as $keyconf=>$dirconfalt) { + if (($keyconf!='main') && (preg_match('$'.preg_quote($dirconfalt).'$i', $file['fullname']))) { + //In this case load modulename@nmodulename + $tmpfile=$tmpfile.'@'.$tmpfile; + break; + } + } $newlang->load($tmpfile, 0, 0, '', 0); // Load translation files + database overwrite $newlangfileonly->load($tmpfile, 0, 0, '', 1); // Load translation files only //print 'After loading lang '.$tmpfile.', newlang has '.count($newlang->tab_translate).' records
'."\n"; From 8000777864bf54eb4a7b8023ec8949d8175d4543 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 10 Jan 2018 20:43:56 +0100 Subject: [PATCH 7/8] Code comment --- htdocs/compta/paiement/class/paiement.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 4fa9c5b9575..a7bc5249f46 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -143,7 +143,7 @@ class Paiement extends CommonObject * @param int $closepaidinvoices 1=Also close payed invoices to paid, 0=Do nothing more * @return int id of created payment, < 0 if error */ - function create($user,$closepaidinvoices=0) + function create($user, $closepaidinvoices=0) { global $conf, $langs; @@ -154,7 +154,7 @@ class Paiement extends CommonObject // Clean parameters $totalamount = 0; $atleastonepaymentnotnull = 0; - foreach ($this->amounts as $key => $value) // How payment is dispatch + foreach ($this->amounts as $key => $value) // How payment is dispatched (invoice id => amount) { $newvalue = price2num($value,'MT'); $this->amounts[$key] = $newvalue; @@ -696,7 +696,7 @@ class Paiement extends CommonObject /** * Information sur l'objet - * + * * @param int $id id du paiement dont il faut afficher les infos * @return void */ From 9253fed75414e75562f56d85c3cde2efb7e3263c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Jan 2018 00:17:32 +0100 Subject: [PATCH 8/8] Revert "Code comment" This reverts commit 8000777864bf54eb4a7b8023ec8949d8175d4543. --- htdocs/compta/paiement/class/paiement.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index a7bc5249f46..4fa9c5b9575 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -143,7 +143,7 @@ class Paiement extends CommonObject * @param int $closepaidinvoices 1=Also close payed invoices to paid, 0=Do nothing more * @return int id of created payment, < 0 if error */ - function create($user, $closepaidinvoices=0) + function create($user,$closepaidinvoices=0) { global $conf, $langs; @@ -154,7 +154,7 @@ class Paiement extends CommonObject // Clean parameters $totalamount = 0; $atleastonepaymentnotnull = 0; - foreach ($this->amounts as $key => $value) // How payment is dispatched (invoice id => amount) + foreach ($this->amounts as $key => $value) // How payment is dispatch { $newvalue = price2num($value,'MT'); $this->amounts[$key] = $newvalue; @@ -696,7 +696,7 @@ class Paiement extends CommonObject /** * Information sur l'objet - * + * * @param int $id id du paiement dont il faut afficher les infos * @return void */