From a158f5ab9db752a8d821e4e2bcee7b83083f299d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Sep 2017 12:01:51 +0200 Subject: [PATCH 01/48] Doc --- ChangeLog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ChangeLog b/ChangeLog index e82fdf33d8a..b566652226b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,9 @@ English Dolibarr ChangeLog -------------------------------------------------------------- +***** ChangeLog for 5.0.6 compared to 5.0.5 ***** +FIX: Removed a bad symbolic link into custom directory. +FIX: Renaming a resouce ref rename also the directory of attached files. ***** ChangeLog for 5.0.5 compared to 5.0.4 ***** FIX: #7075 : bad path for document From d66fac5662b85539469bf9fc3edac6f5ee9f9426 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Sep 2017 12:12:50 +0200 Subject: [PATCH 02/48] Prepare 5.0.7 --- htdocs/filefunc.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php index f3f60885697..422a26d1866 100644 --- a/htdocs/filefunc.inc.php +++ b/htdocs/filefunc.inc.php @@ -31,7 +31,7 @@ */ if (! defined('DOL_APPLICATION_TITLE')) define('DOL_APPLICATION_TITLE','Dolibarr'); -if (! defined('DOL_VERSION')) define('DOL_VERSION','5.0.6'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c +if (! defined('DOL_VERSION')) define('DOL_VERSION','5.0.7'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c if (! defined('EURO')) define('EURO',chr(128)); From 52986c5c07d1a97188910bd05abc31d31e157f51 Mon Sep 17 00:00:00 2001 From: Jacques83300 Date: Mon, 4 Sep 2017 15:59:50 +0200 Subject: [PATCH 03/48] Add some missing attributes in Adherent:makeSubstitution (type, phone numbers) for use in substitution of tags --- htdocs/adherents/class/adherent.class.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index ba6728586f1..9e6110bb35e 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -198,6 +198,9 @@ class Adherent extends CommonObject $infos.= $langs->transnoentities("Town").": ".$this->town."\n"; $infos.= $langs->transnoentities("Country").": ".$this->country."\n"; $infos.= $langs->transnoentities("EMail").": ".$this->email."\n"; + $infos.= $langs->transnoentities("PhonePro").": ".$this->phone."\n"; + $infos.= $langs->transnoentities("PhonePerso").": ".$this->phone_perso."\n"; + $infos.= $langs->transnoentities("PhoneMobile").": ".$this->phone_mobile."\n"; if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) { $infos.= $langs->transnoentities("Login").": ".$this->login."\n"; @@ -225,6 +228,10 @@ class Adherent extends CommonObject '%PHOTO%'=>$msgishtml?dol_htmlentitiesbr($this->photo):$this->photo, '%LOGIN%'=>$msgishtml?dol_htmlentitiesbr($this->login):$this->login, '%PASSWORD%'=>$msgishtml?dol_htmlentitiesbr($this->pass):$this->pass, + '%TYPE%'=>$msgishtml?dol_htmlentitiesbr($this->type):$this->type, + '%PHONE_PRO%'=>$msgishtml?dol_htmlentitiesbr($this->phone):$this->phone, + '%PHONE_PERSO%'=>$msgishtml?dol_htmlentitiesbr($this->phone_perso):$this->phone_perso, + '%PHONE_MOBILE%'=>$msgishtml?dol_htmlentitiesbr($this->phone_mobile):$this->phone_mobile, // For backward compatibility '%INFOS%'=>$msgishtml?dol_htmlentitiesbr($infos):$infos, '%SOCIETE%'=>$msgishtml?dol_htmlentitiesbr($this->societe):$this->societe, From e599e47e844bf2640c9f30da3402ac6172ff38bf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Sep 2017 13:06:34 +0200 Subject: [PATCH 04/48] Missing translation --- htdocs/supplier_proposal/list.php | 55 ++++++++++++++++--------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php index 7a841a13b19..f72cc3cd837 100644 --- a/htdocs/supplier_proposal/list.php +++ b/htdocs/supplier_proposal/list.php @@ -43,6 +43,7 @@ if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $langs->load('companies'); +$langs->load('propal'); $langs->load('supplier_proposal'); $langs->load('compta'); $langs->load('bills'); @@ -322,11 +323,11 @@ if ($result) { $title = $langs->trans('ListOfProposals'); } - + $num = $db->num_rows($result); $arrayofselected=is_array($toselect)?$toselect:array(); - + $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; @@ -358,7 +359,7 @@ if ($result) if ($user->rights->supplier_proposal->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete"); if ($massaction == 'presend') $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); - + // Lignes des champs de filtre print '
'; if ($optioncss != '') print ''; @@ -367,13 +368,13 @@ if ($result) print ''; print ''; print ''; - + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_commercial.png', 0, '', '', $limit); if ($massaction == 'presend') { $langs->load("mails"); - + if (! GETPOST('cancel')) { $objecttmp=new SupplierProposal($db); @@ -392,17 +393,17 @@ if ($result) } } } - + print ''; - + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); - + dol_fiche_head(null, '', ''); - + $topicmail="SendProposalRef"; $modelmail="propal_send"; - + // Cree l'objet formulaire mail include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); @@ -455,25 +456,25 @@ if ($result) $formmail->substit['__REFCLIENT__']='__REFCLIENT__'; // We want to keep the tag $formmail->substit['__PERSONALIZED__']=''; $formmail->substit['__CONTACTCIVNAME__']=''; - + // Tableau des parametres complementaires du post $formmail->param['action']=$action; $formmail->param['models']=$modelmail; $formmail->param['models_id']=GETPOST('modelmailselected','int'); $formmail->param['id']=join(',',$arrayofselected); //$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; - + print $formmail->get_form(); - + dol_fiche_end(); } - + if ($sall) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); } - + $i = 0; $moreforfilter=''; @@ -499,20 +500,20 @@ if ($result) $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; - + if (! empty($moreforfilter)) { print '
'; print $moreforfilter; print '
'; } - + $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - + print '
'; print ''; - + // Fields title print ''; print_liste_field_titre($langs->trans('Ref'),$_SERVER["PHP_SELF"],'sp.ref','',$param,'',$sortfield,$sortorder); @@ -541,7 +542,7 @@ if ($result) $syearvalid = $yearvalid; $formother->select_year($syearvalid,'yearvalid',1, 20, 5); print ''; - + // Date print '\n"; - + // Date delivery print '
'; //print $langs->trans('Month').': '; @@ -632,7 +633,7 @@ if ($result) print ''; print dol_print_date($db->jdate($obj->date_valid), 'day'); print "'; print dol_print_date($db->jdate($obj->dp), 'day'); @@ -686,16 +687,16 @@ if ($result) } $db->free($resql); - + $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - + print '
'."\n"; print '
'."\n"; print '
'."\n"; - + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { /* @@ -703,18 +704,18 @@ if ($result) */ $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; $urlsource.=str_replace('&','&',$param); - + $filedir=$diroutputmassaction; $genallowed=$user->rights->propal->lire; $delallowed=$user->rights->propal->lire; - + print $formfile->showdocuments('massfilesarea_proposals','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,'',''); } else { print '
'.$langs->trans("ShowTempMassFilesArea").''; } - + } else { From 7648d300b5a01c3105cf0be912f2b8faff64bc55 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Thu, 7 Sep 2017 17:13:48 +0200 Subject: [PATCH 05/48] FIX: Bad link to unpayed suppliers invoices --- htdocs/fourn/class/fournisseur.facture.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index f4cf4762a91..7af1480d7cd 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -4,7 +4,7 @@ * Copyright (C) 2004 Christophe Combelles * Copyright (C) 2005 Marc Barilley * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2010-2016 Juanjo Menent + * Copyright (C) 2010-2017 Juanjo Menent * Copyright (C) 2013 Philippe Grand * Copyright (C) 2013 Florian Henry * Copyright (C) 2014-2016 Marcos García @@ -1788,7 +1788,7 @@ class FactureFournisseur extends CommonInvoice $response = new WorkboardResponse(); $response->warning_delay=$conf->facture->fournisseur->warning_delay/60/60/24; $response->label=$langs->trans("SupplierBillsToPay"); - $response->url=DOL_URL_ROOT.'/fourn/facture/list.php?filtre=fac.fk_statut:1,paye:0&mainmenu=accountancy&leftmenu=suppliers_bills'; + $response->url=DOL_URL_ROOT.'/fourn/facture/list.php?search_status=1&mainmenu=accountancy&leftmenu=suppliers_bills'; $response->img=img_object($langs->trans("Bills"),"bill"); $facturestatic = new FactureFournisseur($this->db); From d4c20a919d5f1f4843382efb8706cd51c4a4ddb0 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 8 Sep 2017 12:52:56 +0200 Subject: [PATCH 06/48] Fix: avoid warning --- .../user/doc/doc_generic_user_odt.modules.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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 b7079dde30e..1a9074fbedf 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 @@ -313,7 +313,7 @@ class doc_generic_user_odt extends ModelePDFUser { $socobject=$object->client; } - + // Open and load template require_once ODTPHP_PATH.'odf.php'; try { @@ -332,7 +332,7 @@ class doc_generic_user_odt extends ModelePDFUser $this->error=$e->getMessage(); return -1; } - + // Make substitutions into odt $array_user=$this->get_substitutionarray_user($object,$outputlangs); $array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs); @@ -366,7 +366,7 @@ class doc_generic_user_odt extends ModelePDFUser { } } - + // Replace labels translated $tmparray=$outputlangs->get_translations_for_substitutions(); foreach($tmparray as $key=>$value) @@ -420,12 +420,12 @@ class doc_generic_user_odt extends ModelePDFUser return -1; } - function get_substitutionarray_object($object,$outputlangs) { + function get_substitutionarray_object($object,$outputlangs,$array_key='object') { foreach($object as $key => $value) { - if(!is_array($value) && !is_object($value)) { - $array_other['object_'.$key] = $value; + if (!is_array($value) && !is_object($value)) { + $array_other['object_'.$key] = $value; } - } + } return $array_other; } From c1c75208eccbe6177aaa5ac7716c9b367bc2eceb Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 9 Sep 2017 09:46:21 +0200 Subject: [PATCH 07/48] Fix: missing parameters for filter and sort (contact list) --- htdocs/contact/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 50bb85ace6e..7508381e6cd 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -642,7 +642,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab } } // Hook fields -$parameters=array('arrayfields'=>$arrayfields); +$parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; if (! empty($arrayfields['p.datec']['checked'])) print_liste_field_titre("DateCreationShort",$_SERVER["PHP_SELF"],"p.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); From 7404a6cf980468b5b749bf1edcc303234f1f4177 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 9 Sep 2017 12:15:59 +0200 Subject: [PATCH 08/48] Fix: avoid htmlentities --- htdocs/admin/index.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/index.php b/htdocs/admin/index.php index 9ac33f1cc3d..65b38970a6e 100644 --- a/htdocs/admin/index.php +++ b/htdocs/admin/index.php @@ -70,13 +70,13 @@ if (! empty($conf->global->MAIN_MOTD_SETUPPAGE)) print $langs->trans("SetupDescription1").' '; print $langs->trans("AreaForAdminOnly").' '; -print $langs->trans("SetupDescription2", $langs->trans("MenuCompanySetup"), $langs->trans("Modules"))."

"; +print $langs->trans("SetupDescription2", $langs->transnoentities("MenuCompanySetup"), $langs->transnoentities("Modules"))."

"; print '
'; // Show info setup company if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) $setupcompanynotcomplete=1; -print img_picto('','puce').' '.$langs->trans("SetupDescription3", DOL_URL_ROOT.'/admin/company.php?mainmenu=home'.(empty($setupcompanynotcomplete)?'':'&action=edit'), $langs->trans("Setup"), $langs->trans("MenuCompanySetup")); +print img_picto('','puce').' '.$langs->trans("SetupDescription3", DOL_URL_ROOT.'/admin/company.php?mainmenu=home'.(empty($setupcompanynotcomplete)?'':'&action=edit'), $langs->transnoentities("Setup"), $langs->transnoentities("MenuCompanySetup")); if (! empty($setupcompanynotcomplete)) { $langs->load("errors"); @@ -88,7 +88,7 @@ print '
'; print '
'; // Show info setup module -print img_picto('','puce').' '.$langs->trans("SetupDescription4", DOL_URL_ROOT.'/admin/modules.php?mainmenu=home', $langs->trans("Setup"), $langs->trans("Modules")); +print img_picto('','puce').' '.$langs->trans("SetupDescription4", DOL_URL_ROOT.'/admin/modules.php?mainmenu=home', $langs->transnoentities("Setup"), $langs->transnoentities("Modules")); if (count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)?1:$conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) // If only user module enabled { $langs->load("errors"); From a8fdf0b5eafe3628689d6a3e886491da437466a0 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 9 Sep 2017 16:49:26 +0200 Subject: [PATCH 09/48] Fix: missing salaries upgrade reload module --- htdocs/install/upgrade2.php | 478 ++++++++++++++++++------------------ 1 file changed, 245 insertions(+), 233 deletions(-) diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 2c032ffa7c0..7bf283f828d 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -375,39 +375,40 @@ if (! GETPOST('action','aZ09') || preg_match('/upgrade/i',GETPOST('action','aZ09 } } - // Code executed only if migrate is LAST ONE. Must always be done. - if (versioncompare($versiontoarray,$versionranarray) >= 0 || versioncompare($versiontoarray,$versionranarray) <= -3) - { - // Reload modules (this must be always done and only into last targeted version, because code to reload module may need table structure of last version) - $listofmodule=array( - 'MAIN_MODULE_AGENDA'=>'newboxdefonly', - 'MAIN_MODULE_BARCODE'=>'newboxdefonly', - 'MAIN_MODULE_CRON'=>'newboxdefonly', - 'MAIN_MODULE_COMMANDE'=>'newboxdefonly', - 'MAIN_MODULE_DEPLACEMENT'=>'newboxdefonly', - 'MAIN_MODULE_DON'=>'newboxdefonly', - 'MAIN_MODULE_ECM'=>'newboxdefonly', - 'MAIN_MODULE_FACTURE'=>'newboxdefonly', - 'MAIN_MODULE_FOURNISSEUR'=>'newboxdefonly', - 'MAIN_MODULE_HOLIDAY'=>'newboxdefonly', - 'MAIN_MODULE_OPENSURVEY'=>'newboxdefonly', - 'MAIN_MODULE_PAYBOX'=>'newboxdefonly', - 'MAIN_MODULE_PRODUIT'=>'newboxdefonly', - 'MAIN_MODULE_SOCIETE'=>'newboxdefonly', - 'MAIN_MODULE_SERVICE'=>'newboxdefonly', - 'MAIN_MODULE_USER'=>'newboxdefonly', - 'MAIN_MODULE_ACCOUNTING'=>'newboxdefonly', - 'MAIN_MODULE_BARCODE'=>'newboxdefonly', - 'MAIN_MODULE_CRON'=>'newboxdefonly', - 'MAIN_MODULE_PRINTING'=>'newboxdefonly', + // Code executed only if migrate is LAST ONE. Must always be done. + if (versioncompare($versiontoarray,$versionranarray) >= 0 || versioncompare($versiontoarray,$versionranarray) <= -3) + { + // Reload modules (this must be always done and only into last targeted version, because code to reload module may need table structure of last version) + $listofmodule=array( + 'MAIN_MODULE_AGENDA'=>'newboxdefonly', + 'MAIN_MODULE_BARCODE'=>'newboxdefonly', + 'MAIN_MODULE_CRON'=>'newboxdefonly', + 'MAIN_MODULE_COMMANDE'=>'newboxdefonly', + 'MAIN_MODULE_DEPLACEMENT'=>'newboxdefonly', + 'MAIN_MODULE_DON'=>'newboxdefonly', + 'MAIN_MODULE_ECM'=>'newboxdefonly', + 'MAIN_MODULE_FACTURE'=>'newboxdefonly', + 'MAIN_MODULE_FOURNISSEUR'=>'newboxdefonly', + 'MAIN_MODULE_HOLIDAY'=>'newboxdefonly', + 'MAIN_MODULE_OPENSURVEY'=>'newboxdefonly', + 'MAIN_MODULE_PAYBOX'=>'newboxdefonly', + 'MAIN_MODULE_PRODUIT'=>'newboxdefonly', + 'MAIN_MODULE_SOCIETE'=>'newboxdefonly', + 'MAIN_MODULE_SERVICE'=>'newboxdefonly', + 'MAIN_MODULE_USER'=>'newboxdefonly', + 'MAIN_MODULE_ACCOUNTING'=>'newboxdefonly', + 'MAIN_MODULE_BARCODE'=>'newboxdefonly', + 'MAIN_MODULE_CRON'=>'newboxdefonly', + 'MAIN_MODULE_PRINTING'=>'newboxdefonly', + 'MAIN_MODULE_SALARIES'=>'newboxdefonly', - 'MAIN_MODULE_USER'=>'newboxdefonly', //This one must be always done and only into last targeted version) - ); - migrate_reload_modules($db,$langs,$conf,$listofmodule); + 'MAIN_MODULE_USER'=>'newboxdefonly', //This one must be always done and only into last targeted version) + ); + migrate_reload_modules($db,$langs,$conf,$listofmodule); - // Reload menus (this must be always and only into last targeted version) - migrate_reload_menu($db,$langs,$conf,$versionto); - } + // Reload menus (this must be always and only into last targeted version) + migrate_reload_menu($db,$langs,$conf,$versionto); + } // Can force activation of some module during migration with paramater 'enablemodules=MAIN_MODULE_XXX,MAIN_MODULE_YYY,...' if (! $error && $enablemodules) @@ -4112,216 +4113,227 @@ function migrate_delete_old_dir($db,$langs,$conf) */ function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0) { - dolibarr_install_syslog("upgrade2::migrate_reload_modules force=".$force); + dolibarr_install_syslog("upgrade2::migrate_reload_modules force=".$force); - // If no info is provided, we reload all modules with mode newboxdefonly. - if (count($listofmodule) == 0) - { - $listofmodule=array( - 'MAIN_MODULE_AGENDA'=>'newboxdefonly', - 'MAIN_MODULE_SOCIETE'=>'newboxdefonly', - 'MAIN_MODULE_PRODUIT'=>'newboxdefonly', - 'MAIN_MODULE_SERVICE'=>'newboxdefonly', - 'MAIN_MODULE_COMMANDE'=>'newboxdefonly', - 'MAIN_MODULE_FACTURE'=>'newboxdefonly', - 'MAIN_MODULE_FOURNISSEUR'=>'newboxdefonly', - 'MAIN_MODULE_HOLIDAY'=>'newboxdefonly', - 'MAIN_MODULE_USER'=>'newboxdefonly', - 'MAIN_MODULE_DEPLACEMENT'=>'newboxdefonly', - 'MAIN_MODULE_DON'=>'newboxdefonly', - 'MAIN_MODULE_ECM'=>'newboxdefonly', - 'MAIN_MODULE_PAYBOX'=>'newboxdefonly', - 'MAIN_MODULE_OPENSURVEY'=>'newboxdefonly' - ); - } + // If no info is provided, we reload all modules with mode newboxdefonly. + if (count($listofmodule) == 0) + { + $listofmodule=array( + 'MAIN_MODULE_AGENDA'=>'newboxdefonly', + 'MAIN_MODULE_SOCIETE'=>'newboxdefonly', + 'MAIN_MODULE_PRODUIT'=>'newboxdefonly', + 'MAIN_MODULE_SERVICE'=>'newboxdefonly', + 'MAIN_MODULE_COMMANDE'=>'newboxdefonly', + 'MAIN_MODULE_FACTURE'=>'newboxdefonly', + 'MAIN_MODULE_FOURNISSEUR'=>'newboxdefonly', + 'MAIN_MODULE_HOLIDAY'=>'newboxdefonly', + 'MAIN_MODULE_USER'=>'newboxdefonly', + 'MAIN_MODULE_DEPLACEMENT'=>'newboxdefonly', + 'MAIN_MODULE_DON'=>'newboxdefonly', + 'MAIN_MODULE_ECM'=>'newboxdefonly', + 'MAIN_MODULE_PAYBOX'=>'newboxdefonly', + 'MAIN_MODULE_OPENSURVEY'=>'newboxdefonly', + 'MAIN_MODULE_SALARIES'=>'newboxdefonly' + ); + } - foreach($listofmodule as $moduletoreload => $reloadmode) - { - if (empty($moduletoreload) || (empty($conf->global->$moduletoreload) && ! $force)) continue; // Discard reload if module not enabled + foreach($listofmodule as $moduletoreload => $reloadmode) + { + if (empty($moduletoreload) || (empty($conf->global->$moduletoreload) && ! $force)) continue; // Discard reload if module not enabled - $mod=null; + $mod=null; - if ($moduletoreload == 'MAIN_MODULE_AGENDA') - { - dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Agenda module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modAgenda.class.php'; - if ($res) { - $mod=new modAgenda($db); - $mod->remove('noboxes'); - $mod->init($reloadmode); - } - } - if ($moduletoreload == 'MAIN_MODULE_API') - { - dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Rest API module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modApi.class.php'; - if ($res) { - $mod=new modApi($db); - //$mod->remove('noboxes'); - $mod->init($reloadmode); - } - } - if ($moduletoreload == 'MAIN_MODULE_BARCODE') - { - dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Barcode module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modBarcode.class.php'; - if ($res) { - $mod=new modBarcode($db); - $mod->remove('noboxes'); - $mod->init($reloadmode); - } - } - if ($moduletoreload == 'MAIN_MODULE_CRON') - { - dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Cron module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modCron.class.php'; - if ($res) { - $mod=new modCron($db); - $mod->remove('noboxes'); - $mod->init($reloadmode); - } - } - if ($moduletoreload == 'MAIN_MODULE_SOCIETE') - { - dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Societe module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modSociete.class.php'; - if ($res) { - $mod=new modSociete($db); - $mod->remove('noboxes'); - $mod->init($reloadmode); - } - } - if ($moduletoreload == 'MAIN_MODULE_PRODUIT') // Permission has changed into 2.7 - { - dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Produit module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modProduct.class.php'; - if ($res) { - $mod=new modProduct($db); - //$mod->remove('noboxes'); - $mod->init($reloadmode); - } - } - if ($moduletoreload == 'MAIN_MODULE_SERVICE') // Permission has changed into 2.7 - { - dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Service module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modService.class.php'; - if ($res) { - $mod=new modService($db); - //$mod->remove('noboxes'); - $mod->init($reloadmode); - } - } - if ($moduletoreload == 'MAIN_MODULE_COMMANDE') // Permission has changed into 2.9 - { - dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Commande module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modCommande.class.php'; - if ($res) { - $mod=new modCommande($db); - //$mod->remove('noboxes'); - $mod->init($reloadmode); - } - } - if ($moduletoreload == 'MAIN_MODULE_FACTURE') // Permission has changed into 2.9 - { - dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Facture module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modFacture.class.php'; - if ($res) { - $mod=new modFacture($db); - //$mod->remove('noboxes'); - $mod->init($reloadmode); - } - } - if ($moduletoreload == 'MAIN_MODULE_FOURNISSEUR') // Permission has changed into 2.9 - { - dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Fournisseur module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modFournisseur.class.php'; - if ($res) { - $mod=new modFournisseur($db); - //$mod->remove('noboxes'); - $mod->init($reloadmode); - } - } - if ($moduletoreload == 'MAIN_MODULE_HOLIDAY') // Permission and tabs has changed into 3.8 - { - dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Leave Request module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modHoliday.class.php'; - if ($res) { - $mod=new modHoliday($db); - $mod->remove('noboxes'); - $mod->init($reloadmode); - } - } - if ($moduletoreload == 'MAIN_MODULE_DEPLACEMENT') // Permission has changed into 3.0 - { - dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Deplacement module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modDeplacement.class.php'; - if ($res) { - $mod=new modDeplacement($db); - //$mod->remove('noboxes'); - $mod->init($reloadmode); - } - } - if ($moduletoreload == 'MAIN_MODULE_DON') // Permission has changed into 3.0 - { - dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Don module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modDon.class.php'; - if ($res) { - $mod=new modDon($db); - //$mod->remove('noboxes'); - $mod->init($reloadmode); - } - } - if ($moduletoreload == 'MAIN_MODULE_ECM') // Permission has changed into 3.0 and 3.1 - { - dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate ECM module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modECM.class.php'; - if ($res) { - $mod=new modECM($db); - $mod->remove('noboxes'); // We need to remove because a permission id has been removed - $mod->init($reloadmode); - } - } - if ($moduletoreload == 'MAIN_MODULE_PAYBOX') // Permission has changed into 3.0 - { - dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Paybox module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modPaybox.class.php'; - if ($res) { - $mod=new modPaybox($db); - $mod->remove('noboxes'); // We need to remove because id of module has changed - $mod->init($reloadmode); - } - } - if ($moduletoreload == 'MAIN_MODULE_OPENSURVEY') // Permission has changed into 3.0 - { - dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Opensurvey module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modOpenSurvey.class.php'; - if ($res) { - $mod=new modOpenSurvey($db); - $mod->remove('noboxes'); // We need to remove because menu entries has changed - $mod->init($reloadmode); - } - } - if ($moduletoreload == 'MAIN_MODULE_USER') // Permission has changed into 3.0 - { - dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate User module"); - $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modUser.class.php'; - if ($res) { - $mod=new modUser($db); - //$mod->remove('noboxes'); - $mod->init($reloadmode); - } - } + if ($moduletoreload == 'MAIN_MODULE_AGENDA') + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Agenda module"); + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modAgenda.class.php'; + if ($res) { + $mod=new modAgenda($db); + $mod->remove('noboxes'); + $mod->init($reloadmode); + } + } + if ($moduletoreload == 'MAIN_MODULE_API') + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Rest API module"); + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modApi.class.php'; + if ($res) { + $mod=new modApi($db); + //$mod->remove('noboxes'); + $mod->init($reloadmode); + } + } + if ($moduletoreload == 'MAIN_MODULE_BARCODE') + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Barcode module"); + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modBarcode.class.php'; + if ($res) { + $mod=new modBarcode($db); + $mod->remove('noboxes'); + $mod->init($reloadmode); + } + } + if ($moduletoreload == 'MAIN_MODULE_CRON') + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Cron module"); + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modCron.class.php'; + if ($res) { + $mod=new modCron($db); + $mod->remove('noboxes'); + $mod->init($reloadmode); + } + } + if ($moduletoreload == 'MAIN_MODULE_SOCIETE') + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Societe module"); + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modSociete.class.php'; + if ($res) { + $mod=new modSociete($db); + $mod->remove('noboxes'); + $mod->init($reloadmode); + } + } + if ($moduletoreload == 'MAIN_MODULE_PRODUIT') // Permission has changed into 2.7 + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Produit module"); + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modProduct.class.php'; + if ($res) { + $mod=new modProduct($db); + //$mod->remove('noboxes'); + $mod->init($reloadmode); + } + } + if ($moduletoreload == 'MAIN_MODULE_SERVICE') // Permission has changed into 2.7 + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Service module"); + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modService.class.php'; + if ($res) { + $mod=new modService($db); + //$mod->remove('noboxes'); + $mod->init($reloadmode); + } + } + if ($moduletoreload == 'MAIN_MODULE_COMMANDE') // Permission has changed into 2.9 + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Commande module"); + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modCommande.class.php'; + if ($res) { + $mod=new modCommande($db); + //$mod->remove('noboxes'); + $mod->init($reloadmode); + } + } + if ($moduletoreload == 'MAIN_MODULE_FACTURE') // Permission has changed into 2.9 + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Facture module"); + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modFacture.class.php'; + if ($res) { + $mod=new modFacture($db); + //$mod->remove('noboxes'); + $mod->init($reloadmode); + } + } + if ($moduletoreload == 'MAIN_MODULE_FOURNISSEUR') // Permission has changed into 2.9 + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Fournisseur module"); + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modFournisseur.class.php'; + if ($res) { + $mod=new modFournisseur($db); + //$mod->remove('noboxes'); + $mod->init($reloadmode); + } + } + if ($moduletoreload == 'MAIN_MODULE_HOLIDAY') // Permission and tabs has changed into 3.8 + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Leave Request module"); + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modHoliday.class.php'; + if ($res) { + $mod=new modHoliday($db); + $mod->remove('noboxes'); + $mod->init($reloadmode); + } + } + if ($moduletoreload == 'MAIN_MODULE_DEPLACEMENT') // Permission has changed into 3.0 + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Deplacement module"); + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modDeplacement.class.php'; + if ($res) { + $mod=new modDeplacement($db); + //$mod->remove('noboxes'); + $mod->init($reloadmode); + } + } + if ($moduletoreload == 'MAIN_MODULE_DON') // Permission has changed into 3.0 + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Don module"); + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modDon.class.php'; + if ($res) { + $mod=new modDon($db); + //$mod->remove('noboxes'); + $mod->init($reloadmode); + } + } + if ($moduletoreload == 'MAIN_MODULE_ECM') // Permission has changed into 3.0 and 3.1 + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate ECM module"); + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modECM.class.php'; + if ($res) { + $mod=new modECM($db); + $mod->remove('noboxes'); // We need to remove because a permission id has been removed + $mod->init($reloadmode); + } + } + if ($moduletoreload == 'MAIN_MODULE_PAYBOX') // Permission has changed into 3.0 + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Paybox module"); + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modPaybox.class.php'; + if ($res) { + $mod=new modPaybox($db); + $mod->remove('noboxes'); // We need to remove because id of module has changed + $mod->init($reloadmode); + } + } + if ($moduletoreload == 'MAIN_MODULE_OPENSURVEY') // Permission has changed into 3.0 + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Opensurvey module"); + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modOpenSurvey.class.php'; + if ($res) { + $mod=new modOpenSurvey($db); + $mod->remove('noboxes'); // We need to remove because menu entries has changed + $mod->init($reloadmode); + } + } + if ($moduletoreload == 'MAIN_MODULE_SALARIES') // Permission has changed into 6.0 + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate Salaries module"); + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modSalaries.class.php'; + if ($res) { + $mod=new modSalaries($db); + //$mod->remove('noboxes'); + $mod->init($reloadmode); + } + } + if ($moduletoreload == 'MAIN_MODULE_USER') // Permission has changed into 3.0 + { + dolibarr_install_syslog("upgrade2::migrate_reload_modules Reactivate User module"); + $res=@include_once DOL_DOCUMENT_ROOT.'/core/modules/modUser.class.php'; + if ($res) { + $mod=new modUser($db); + //$mod->remove('noboxes'); + $mod->init($reloadmode); + } + } if (! empty($mod) && is_object($mod)) { - print ''; - print ''.$langs->trans('Upgrade').': '; - print $langs->trans('MigrationReloadModule').' '.$mod->getName(); // We keep getName outside of trans because getName is already encoded/translated - print ""; - print "
\n"; - print ''; + print ''; + print ''.$langs->trans('Upgrade').': '; + print $langs->trans('MigrationReloadModule').' '.$mod->getName(); // We keep getName outside of trans because getName is already encoded/translated + print ""; + print "
\n"; + print ''; } - } + } } From 67e9b65a2e1fc6ed3c9e6c4c6a37b862384c4423 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 9 Sep 2017 17:07:08 +0200 Subject: [PATCH 10/48] Fix: use $array_key value instead --- htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 1a9074fbedf..11ae5729b3b 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 @@ -421,9 +421,10 @@ class doc_generic_user_odt extends ModelePDFUser } function get_substitutionarray_object($object,$outputlangs,$array_key='object') { + $array_other=array(); foreach($object as $key => $value) { if (!is_array($value) && !is_object($value)) { - $array_other['object_'.$key] = $value; + $array_other[$array_key.'_'.$key] = $value; } } return $array_other; From 762b4eb8768a0b09d69c06529566954f7efbc1c0 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 9 Sep 2017 17:48:04 +0200 Subject: [PATCH 11/48] Fix: some problems with medias in multicompany --- htdocs/core/class/conf.class.php | 15 ++++++++++----- htdocs/core/lib/files.lib.php | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 77c24ff4109..da44eeeb6f6 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -83,11 +83,12 @@ class Conf $this->file = new stdClass(); $this->db = new stdClass(); $this->global = new stdClass(); - $this->mycompany = new stdClass(); - $this->admin = new stdClass(); + $this->mycompany = new stdClass(); + $this->admin = new stdClass(); $this->user = new stdClass(); $this->syslog = new stdClass(); $this->browser = new stdClass(); + $this->medias = new stdClass(); $this->multicompany = new stdClass(); //! Charset for HTML output and for storing data in memory @@ -96,7 +97,7 @@ class Conf // First level object // TODO Remove this part. $this->expedition_bon = new stdClass(); - $this->livraison_bon = new stdClass(); + $this->livraison_bon = new stdClass(); $this->fournisseur = new stdClass(); $this->product = new stdClass(); $this->service = new stdClass(); @@ -106,12 +107,12 @@ class Conf $this->propal = new stdClass(); $this->facture = new stdClass(); $this->contrat = new stdClass(); - $this->usergroup = new stdClass(); + $this->usergroup = new stdClass(); $this->adherent = new stdClass(); $this->bank = new stdClass(); $this->notification = new stdClass(); $this->mailing = new stdClass(); - $this->expensereport = new stdClass(); + $this->expensereport = new stdClass(); } @@ -322,6 +323,10 @@ class Conf $this->propal->dir_output=$rootfordata."/propale"; $this->propal->dir_temp=$rootfordata."/propale/temp"; + // For medias storage + $this->medias->multidir_output = array($this->entity => $rootfordata."/medias"); + $this->medias->multidir_temp = array($this->entity => $rootfordata."/medias/temp"); + // Exception: Some dir are not the name of module. So we keep exception here for backward compatibility. // Sous module bons d'expedition diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index e3419be0d14..9ff9ec0df63 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1875,7 +1875,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, if ($modulepart == 'medias' && !empty($dolibarr_main_data_root)) { $accessallowed=1; - $original_file=$dolibarr_main_data_root.'/medias/'.$original_file; + $original_file=$conf->medias->multidir_output[$entity].'/'.$original_file; } // Wrapping for *.log files, like when used with url http://.../document.php?modulepart=logs&file=dolibarr.log elseif ($modulepart == 'logs' && !empty($dolibarr_main_data_root)) From b87ce172c35f389c27bbde5ae15a9eb60d811414 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Sep 2017 13:39:03 +0200 Subject: [PATCH 12/48] FIX hidden option MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN --- htdocs/commande/card.php | 3 ++- htdocs/commande/class/commande.class.php | 3 ++- htdocs/compta/facture/card.php | 3 ++- htdocs/compta/facture/class/facture.class.php | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index ddb44153e49..b7e79def212 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -398,6 +398,7 @@ if (empty($reshook)) } // Now we create same links to contact than the ones found on origin object + /* Useless, already into the create if (! empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN)) { $originforcontact = $object->origin; @@ -420,7 +421,7 @@ if (empty($reshook)) } } else dol_print_error($resqlcontact); - } + }*/ // Hooks $parameters = array('objFrom' => $srcobject); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index f9ebf8a4cde..235e3a1aa75 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -920,7 +920,8 @@ class Commande extends CommonOrder foreach ($exp->linkedObjectsIds['commande'] as $key => $value) { $originforcontact = 'commande'; - $originidforcontact = $value->id; + if (is_object($value)) $originidforcontact = $value->id; + else $originidforcontact = $value; break; // We take first one } } diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 7adc13d3724..60f711688cc 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1249,6 +1249,7 @@ if (empty($reshook)) } // Now we create same links to contact than the ones found on origin object + /* Useless, already into the create if (! empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN)) { $originforcontact = $object->origin; @@ -1271,7 +1272,7 @@ if (empty($reshook)) } } else dol_print_error($resqlcontact); - } + }*/ // Hooks $parameters = array('objFrom' => $srcobject); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index b5a399675e7..1f8d17f0468 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -489,7 +489,8 @@ class Facture extends CommonInvoice foreach ($exp->linkedObjectsIds['commande'] as $key => $value) { $originforcontact = 'commande'; - $originidforcontact = $value->id; + if (is_object($value)) $originidforcontact = $value->id; + else $originidforcontact = $value; break; // We take first one } } From 646e8713f2187808875c4dfd3a7ac169e2a6dcce Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Sep 2017 13:41:40 +0200 Subject: [PATCH 13/48] Remove duplicated logs --- htdocs/compta/facture/class/facture.class.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 1f8d17f0468..3fa36602d39 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -430,7 +430,6 @@ class Facture extends CommonInvoice $sql.= ", ".(double) $this->multicurrency_tx; $sql.=")"; - dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) { @@ -440,7 +439,6 @@ class Facture extends CommonInvoice $this->ref='(PROV'.$this->id.')'; $sql = 'UPDATE '.MAIN_DB_PREFIX."facture SET facnumber='".$this->db->escape($this->ref)."' WHERE rowid=".$this->id; - dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql=$this->db->query($sql); if (! $resql) $error++; @@ -749,12 +747,12 @@ class Facture extends CommonInvoice // Charge facture source $facture=new Facture($this->db); - + $this->fetch_optionals(); if(!empty($this->array_options)){ $facture->array_options = $this->array_options; } - + foreach($this->lines as &$line){ $line->fetch_optionals();//fetch extrafields } From 6da5a6b82fe2e3c85c9ea84498e0c638bac7f59d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Sep 2017 14:41:46 +0200 Subject: [PATCH 14/48] FIX #7359 Conflicts: htdocs/fichinter/class/fichinter.class.php --- htdocs/fichinter/class/fichinter.class.php | 41 +++++++++++----------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 6142d87de7a..490cfde8c99 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -39,7 +39,7 @@ class Fichinter extends CommonObject public $fk_element='fk_fichinter'; public $table_element_line='fichinterdet'; public $picto = 'intervention'; - + /** * {@inheritdoc} */ @@ -361,7 +361,7 @@ class Fichinter extends CommonObject $this->fk_contrat = $obj->fk_contrat; $this->user_creation= $obj->fk_user_author; - + $this->extraparams = (array) json_decode($obj->extraparams, true); if ($this->statut == 0) $this->brouillon = 1; @@ -542,27 +542,26 @@ class Fichinter extends CommonObject /** * Returns amount based on user thm * - * @return float amount + * @return float Amount */ - function getAmount() { + function getAmount() + { global $db; - + $amount = 0; - + $this->author = new User($db); $this->author->fetch($this->user_creation); - + $thm = $this->author->thm; - - foreach($this->lines as &$line) { - - $amount+=$line->qty * $thm; - + + foreach($this->lines as $line) { + $amount += ($line->duration / 60 / 60 * $thm); } - - return $amount; + + return price2num($amount, 'MT'); } - + /** * Returns the label status * @@ -599,7 +598,7 @@ class Fichinter extends CommonObject return ''.$langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),$this->statuts_logo[$statut]); if ($mode == 6) return ''.$langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),$this->statuts_logo[$statut]); - + return ''; } @@ -949,7 +948,7 @@ class Fichinter extends CommonObject return -2; } - + /** * Load an object from its id and create a new one in database @@ -1001,7 +1000,7 @@ class Fichinter extends CommonObject $this->date_creation = ''; $this->date_validation = ''; $this->ref_client = ''; - + // Create clone $result=$this->create($user); if ($result < 0) $error++; @@ -1013,7 +1012,7 @@ class Fichinter extends CommonObject { $this->addline($user, $this->id, $line->desc, $line->datei, $line->duration); } - + // Hook of thirdparty module if (is_object($hookmanager)) { @@ -1043,8 +1042,8 @@ class Fichinter extends CommonObject return -1; } } - - + + /** * Adding a line of intervention into data base * From 2fdad0f11d6479b02b6c51eee21bf3558c427634 Mon Sep 17 00:00:00 2001 From: reeperbahnause Date: Sat, 9 Sep 2017 20:00:09 +0200 Subject: [PATCH 15/48] fix #7361 missing generateDocument function fix #7361 Function generateDocument was missing for Class Fichinter --- htdocs/fichinter/class/fichinter.class.php | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 490cfde8c99..90b65763832 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -561,6 +561,38 @@ class Fichinter extends CommonObject return price2num($amount, 'MT'); } + + /** + * Create a document onto disk according to template module. + * + * @param string $modele Force model to use ('' to not force) + * @param Translate $outputlangs Object langs to use for output + * @param int $hidedetails Hide details of lines + * @param int $hidedesc Hide description + * @param int $hideref Hide ref + * @return int 0 if KO, 1 if OK + */ + public function generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) + { + global $conf,$langs; + + $langs->load("interventions"); + + if (! dol_strlen($modele)) { + + $modele = 'azur'; + + if ($this->modelpdf) { + $modele = $this->modelpdf; + } elseif (! empty($conf->global->PROPALE_ADDON_PDF)) { + $modele = $conf->global->PROPALE_ADDON_PDF; + } + } + + $modelpath = "core/modules/fichinter/doc/"; + + return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref); + } /** * Returns the label status From e9bc5b719d51450664e31eb41ba974e0c226c195 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Sep 2017 14:50:00 +0200 Subject: [PATCH 16/48] Complete #7361 --- htdocs/fichinter/class/fichinter.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 90b65763832..70192c460d2 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -561,7 +561,7 @@ class Fichinter extends CommonObject return price2num($amount, 'MT'); } - + /** * Create a document onto disk according to template module. * @@ -580,12 +580,12 @@ class Fichinter extends CommonObject if (! dol_strlen($modele)) { - $modele = 'azur'; + $modele = 'soleil'; if ($this->modelpdf) { $modele = $this->modelpdf; - } elseif (! empty($conf->global->PROPALE_ADDON_PDF)) { - $modele = $conf->global->PROPALE_ADDON_PDF; + } elseif (! empty($conf->global->FICHEINTER_ADDON_PDF)) { + $modele = $conf->global->FICHEINTER_ADDON_PDF; } } From 44405e5415fb2d3fd9aac3f444b10f436ba3a1ee Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Sep 2017 15:04:29 +0200 Subject: [PATCH 17/48] Fix #7335 #7365 Better fix --- htdocs/compta/facture/card.php | 8 ++++++++ htdocs/core/class/discount.class.php | 10 +++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 60f711688cc..82eeb3d49c0 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3156,6 +3156,14 @@ else if ($id > 0 || ! empty($ref)) $facthatreplace->fetch($objectidnext); print ' (' . $langs->transnoentities("ReplacedByInvoice", $facthatreplace->getNomUrl(1)) . ')'; } + + if ($object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT) { + $discount = new DiscountAbsolute($db); + $result = $discount->fetch(0, $object->id); + if ($result > 0){ + print '. '.$langs->trans("CreditNoteConvertedIntoDiscount", $object->getLibType(), $discount->getNomUrl(1, 'discount')).'
'; + } + } print ''; // Relative and absolute discounts diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index 41c5d67688c..443534eb1b3 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -64,7 +64,7 @@ class DiscountAbsolute * @param int $fk_facture_source fk_facture_source * @return int <0 if KO, =0 if not found, >0 if OK */ - function fetch($rowid,$fk_facture_source=0) + function fetch($rowid, $fk_facture_source=0) { global $conf; @@ -386,7 +386,7 @@ class DiscountAbsolute function getSumDepositsUsed($invoice, $multicurrency=0) { dol_syslog(get_class($this)."::getSumDepositsUsed", LOG_DEBUG); - + if ($invoice->element == 'facture' || $invoice->element == 'invoice') { $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; @@ -407,7 +407,7 @@ class DiscountAbsolute dol_print_error($this->error); return -1; } - + $resql=$this->db->query($sql); if ($resql) { @@ -432,7 +432,7 @@ class DiscountAbsolute function getSumCreditNotesUsed($invoice, $multicurrency=0) { dol_syslog(get_class($this)."::getSumCreditNotesUsed", LOG_DEBUG); - + if ($invoice->element == 'facture' || $invoice->element == 'invoice') { $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; @@ -453,7 +453,7 @@ class DiscountAbsolute dol_print_error($this->error); return -1; } - + $resql=$this->db->query($sql); if ($resql) { From e038e1a2f5825d02343565336017d89a64614b7c Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 12 Sep 2017 09:27:59 +0200 Subject: [PATCH 18/48] Fix: missing select2 combobox --- htdocs/core/class/html.form.class.php | 57 +++++++++++++++------------ 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index c8ea494ad3a..a296fc9079a 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4296,7 +4296,7 @@ class Form */ function select_currency($selected='',$htmlname='currency_id') { - print $this->selectcurrency($selected,$htmlname); + print $this->selectCurrency($selected,$htmlname); } /** @@ -4306,35 +4306,40 @@ class Form * @param string $htmlname name of HTML select list * @return string */ - function selectCurrency($selected='',$htmlname='currency_id') - { - global $conf,$langs,$user; + function selectCurrency($selected='',$htmlname='currency_id') + { + global $conf,$langs,$user; - $langs->loadCacheCurrencies(''); + $langs->loadCacheCurrencies(''); - $out=''; + $out=''; - if ($selected=='euro' || $selected=='euros') $selected='EUR'; // Pour compatibilite + if ($selected=='euro' || $selected=='euros') $selected='EUR'; // Pour compatibilite - $out.= ''; - if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); - return $out; - } + $out.= ''; + if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); + + // Make select dynamic + include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; + $out .= ajax_combobox($htmlname); + + return $out; + } /** * Return array of currencies in user language From cd888a2149e6fad8982d97ed11cc1b1256a1b1d9 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 12 Sep 2017 15:13:12 +0200 Subject: [PATCH 19/48] Fix: hide bank account field if module disabled --- htdocs/comm/card.php | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index dfdc9183886..2da33334a92 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -330,25 +330,27 @@ if ($id > 0) print ""; print ''; - // Compte bancaire par défaut - print ''; - print ''; - print '
'; - print $langs->trans('PaymentBankAccount'); - print ''; - if (($action != 'editbankaccount') && $user->rights->societe->creer) print 'id.'">'.img_edit($langs->trans('SetBankAccount'),1).'
'; - print ''; - if ($action == 'editbankaccount') + if (! empty($conf->banque->enabled)) { - $form->formSelectAccount($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->fk_account,'fk_account',1); + // Compte bancaire par défaut + print ''; + print ''; + print '
'; + print $langs->trans('PaymentBankAccount'); + print ''; + if (($action != 'editbankaccount') && $user->rights->societe->creer) print 'id.'">'.img_edit($langs->trans('SetBankAccount'),1).'
'; + print ''; + if ($action == 'editbankaccount') + { + $form->formSelectAccount($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->fk_account,'fk_account',1); + } + else + { + $form->formSelectAccount($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->fk_account,'none'); + } + print ""; + print ''; } - else - { - $form->formSelectAccount($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->fk_account,'none'); - } - print ""; - print ''; - // Relative discounts (Discounts-Drawbacks-Rebates) print ''; From f0e0df2660b771d0106694524317df48708e6ca6 Mon Sep 17 00:00:00 2001 From: Inovea Conseil Date: Tue, 12 Sep 2017 16:29:06 +0200 Subject: [PATCH 20/48] add translation publisher translation for modulehelp.php --- htdocs/langs/en_US/admin.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 2c2fe276146..f932ec05959 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1,6 +1,7 @@ # Dolibarr language file - Source file is en_US - admin Foundation=Foundation Version=Version +Publisher=Publisher VersionProgram=Version program VersionLastInstall=Initial install version VersionLastUpgrade=Latest version upgrade From 30eb03af4ccff3e6ca673fa76c7c3e3c032d291a Mon Sep 17 00:00:00 2001 From: atm-ph Date: Tue, 12 Sep 2017 16:36:14 +0200 Subject: [PATCH 21/48] Fix get_class(self) instead of get_class($this) --- htdocs/core/class/commonobject.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index b32aa8cca05..3f4ca3e5d05 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5023,7 +5023,7 @@ abstract class CommonObject if (!$notrigger) { // Call triggers - $result=$this->call_trigger(strtoupper(get_class(self)).'_CREATE',$user); + $result=$this->call_trigger(strtoupper(get_class($this)).'_CREATE',$user); if ($result < 0) { $error++; } // End call triggers } @@ -5185,7 +5185,7 @@ abstract class CommonObject if (! $error && ! $notrigger) { // Call triggers - $result=$this->call_trigger(strtoupper(get_class(self)).'_MODIFY',$user); + $result=$this->call_trigger(strtoupper(get_class($this)).'_MODIFY',$user); if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail // End call triggers } @@ -5216,7 +5216,7 @@ abstract class CommonObject if (! $error) { if (! $notrigger) { // Call triggers - $result=$this->call_trigger(strtoupper(get_class(self)).'_DELETE', $user); + $result=$this->call_trigger(strtoupper(get_class($this)).'_DELETE', $user); if ($result < 0) { $error++; } // Do also here what you must do to rollback action if trigger fail // End call triggers } From d572e1ddad58675d0b9026c90d4db9c4cb71402b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Sep 2017 17:30:18 +0200 Subject: [PATCH 22/48] Fix duration output --- htdocs/product/list.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 4534e6514e3..7b7985d2e89 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -779,13 +779,13 @@ else if (! empty($arrayfields['p.duration']['checked'])) { print ''; - if (preg_match('/([0-9]+)[a-z]/i',$obj->duration)) + if (preg_match('/([^a-z]+)[a-z]/i',$obj->duration)) { - if (preg_match('/([0-9]+)y/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationYear"); - elseif (preg_match('/([0-9]+)m/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationMonth"); - elseif (preg_match('/([0-9]+)w/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationWeek"); - elseif (preg_match('/([0-9]+)d/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationDay"); - //elseif (preg_match('/([0-9]+)h/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationHour"); + if (preg_match('/([^a-z]+)y/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationYear"); + elseif (preg_match('/([^a-z]+)m/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationMonth"); + elseif (preg_match('/([^a-z]+)w/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationWeek"); + elseif (preg_match('/([^a-z]+)d/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationDay"); + //elseif (preg_match('/([^a-z]+)h/i',$obj->duration,$regs)) print $regs[1].' '.$langs->trans("DurationHour"); else print $obj->duration; } print ''; From 6e3174e71a17b27fa1cc4f9f135e8c35efefea00 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Sep 2017 17:36:19 +0200 Subject: [PATCH 23/48] Fix menu to member cards generation page was lost. --- htdocs/core/menus/standard/eldy.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 95d3f41661b..f3d89ec514e 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1426,8 +1426,8 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $newmenu->add("/adherents/list.php?leftmenu=members&statut=1&filter=outofdate",$langs->trans("MenuMembersNotUpToDate"),2,$user->rights->adherent->lire); $newmenu->add("/adherents/list.php?leftmenu=members&statut=0",$langs->trans("MenuMembersResiliated"),2,$user->rights->adherent->lire); $newmenu->add("/adherents/stats/index.php?leftmenu=members",$langs->trans("MenuMembersStats"),1,$user->rights->adherent->lire); - if (! empty($conf->global->MEMBER_LINK_TO_HTPASSWDFILE) && ($usemenuhider || empty($leftmenu) || $leftmenu=="export")) $newmenu->add("/adherents/htpasswd.php?leftmenu=export",$langs->trans("Filehtpasswd"),1,$user->rights->adherent->export); - if ($usemenuhider || empty($leftmenu) || $leftmenu=="export") $newmenu->add("/adherents/cartes/carte.php?leftmenu=export",$langs->trans("MembersCards"),1,$user->rights->adherent->export); + if (! empty($conf->global->MEMBER_LINK_TO_HTPASSWDFILE) && ($usemenuhider || empty($leftmenu) || $leftmenu=='none' || $leftmenu=="members" || $leftmenu=="export")) $newmenu->add("/adherents/htpasswd.php?leftmenu=export",$langs->trans("Filehtpasswd"),1,$user->rights->adherent->export); + $newmenu->add("/adherents/cartes/carte.php?leftmenu=export",$langs->trans("MembersCards"),1,$user->rights->adherent->export); $newmenu->add("/adherents/index.php?leftmenu=members&mainmenu=members",$langs->trans("Subscriptions"),0,$user->rights->adherent->cotisation->lire); $newmenu->add("/adherents/list.php?leftmenu=members&statut=-1,1&mainmenu=members",$langs->trans("NewSubscription"),1,$user->rights->adherent->cotisation->creer); From 0744b5d91b450ba09db0673e13f24d3f579c247a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Sep 2017 18:37:54 +0200 Subject: [PATCH 24/48] Fix typo Conflicts: htdocs/public/payment/newpayment.php --- htdocs/public/payment/newpayment.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index cdfaaa2afc6..e1b215d4ebd 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -750,7 +750,8 @@ if (GETPOST("source") == 'contractline') if ($action != 'dopayment') // Do not change amount if we just click on first dopayment { $amount=$contractline->total_ttc; - if ($contractline->fk_product) + + if ($contractline->fk_product && ! empty($conf->global->PAYMENT_USE_NEW_PRICE_FOR_CONTRACTLINES)) { $product=new Product($db); $result=$product->fetch($contractline->fk_product); From 939d33cce7c22ce4acf36b029d031c47089f9c3a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Sep 2017 19:12:39 +0200 Subject: [PATCH 25/48] Fix bug reported by scrutinizer --- htdocs/comm/mailing/class/advtargetemailing.class.php | 8 ++++---- htdocs/product/class/html.formproduct.class.php | 4 ++-- htdocs/product/class/product.class.php | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index ce6a9cf9896..ea2569b863e 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -640,16 +640,16 @@ class AdvanceTargetingMailing extends CommonObject $sqlwhere[]=$this->transformToSQL('t.firstname',$arrayquery['contact_firstname']); } if (!empty($arrayquery['contact_country']) && count($arrayquery['contact_country'])) { - $sqlwhere[]= " (t.fk_pays IN (".$db->escape(implode(',',$arrayquery['contact_country']))."))"; + $sqlwhere[]= " (t.fk_pays IN (".$this->db->escape(implode(',',$arrayquery['contact_country']))."))"; } if (!empty($arrayquery['contact_status']) && count($arrayquery['contact_status'])>0) { - $sqlwhere[]= " (t.statut IN (".$db->escape(implode(',',$arrayquery['contact_status']))."))"; + $sqlwhere[]= " (t.statut IN (".$this->db->escape(implode(',',$arrayquery['contact_status']))."))"; } if (!empty($arrayquery['contact_civility']) && count($arrayquery['contact_civility'])>0) { - $sqlwhere[]= " (t.civility IN ('".$db->escape(implode("','",$arrayquery['contact_civility']))."'))"; + $sqlwhere[]= " (t.civility IN ('".$this->db->escape(implode("','",$arrayquery['contact_civility']))."'))"; } if ($arrayquery['contact_no_email']!='') { - $sqlwhere[]= " (t.no_email='".$db->escape($arrayquery['contact_no_email'])."')"; + $sqlwhere[]= " (t.no_email='".$this->db->escape($arrayquery['contact_no_email'])."')"; } if ($arrayquery['contact_update_st_dt']!='') { $sqlwhere[]= " (t.tms >= '".$this->db->idate($arrayquery['contact_update_st_dt'])."' AND t.tms <= '".$this->db->idate($arrayquery['contact_update_end_dt'])."')"; diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index c526e7ae52b..1c4c3249791 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -115,14 +115,14 @@ class FormProduct $sql.= " WHERE e.entity IN (".getEntity('stock').")"; if (count($warehouseStatus)) { - $sql.= " AND e.statut IN (".$db->escape(implode(',',$warehouseStatus)).")"; + $sql.= " AND e.statut IN (".$this->db->escape(implode(',',$warehouseStatus)).")"; } else { $sql.= " AND e.statut = 1"; } - if(!empty($exclude)) $sql.= ' AND e.rowid NOT IN('.$db->escape(implode(',', $exclude)).')'; + if(!empty($exclude)) $sql.= ' AND e.rowid NOT IN('.$this->db->escape(implode(',', $exclude)).')'; if ($sumStock && empty($fk_product)) $sql.= " GROUP BY e.rowid, e.label, e.description, e.fk_parent"; $sql.= " ORDER BY e.label"; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 06afce94c89..a6a4ef25f09 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3750,7 +3750,7 @@ class Product extends CommonObject $sql.= " WHERE w.entity IN (".getEntity('stock').")"; $sql.= " AND w.rowid = ps.fk_entrepot"; $sql.= " AND ps.fk_product = ".$this->id; - if ($conf->global->ENTREPOT_EXTRA_STATUS && count($warehouseStatus)) $sql.= " AND w.statut IN (".$db->escape(implode(',',$warehouseStatus)).")"; + if ($conf->global->ENTREPOT_EXTRA_STATUS && count($warehouseStatus)) $sql.= " AND w.statut IN (".$this->db->escape(implode(',',$warehouseStatus)).")"; dol_syslog(get_class($this)."::load_stock", LOG_DEBUG); $result = $this->db->query($sql); From e11c7a08ea5dbdc204b87946da1e5f67517582f5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Sep 2017 14:24:03 +0200 Subject: [PATCH 26/48] Fix translation --- htdocs/langs/en_US/stocks.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 81945b17f85..f2115666a36 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -55,7 +55,7 @@ IndependantSubProductStock=Product stock and subproduct stock are independant QtyDispatched=Quantity dispatched QtyDispatchedShort=Qty dispatched QtyToDispatchShort=Qty to dispatch -OrderDispatch=Goods Receptions +OrderDispatch=Item receipts RuleForStockManagementDecrease=Rule for automatic stock management decrease (manual decrease is always possible, even if an automatic decrease rule is activated) RuleForStockManagementIncrease=Rule for automatic stock management increase (manual increase is always possible, even if an automatic increase rule is activated) DeStockOnBill=Decrease real stocks on customers invoices/credit notes validation From c44a5ede43ae14be12714d798b38a60d706d6e36 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Sep 2017 15:12:54 +0200 Subject: [PATCH 27/48] FIX Several problem with the last event box on project/tasks Conflicts: htdocs/core/lib/functions2.lib.php --- htdocs/comm/action/card.php | 2 +- htdocs/comm/action/class/actioncomm.class.php | 4 ++- htdocs/core/class/html.formactions.class.php | 30 ++++++++++++++----- htdocs/core/lib/functions2.lib.php | 6 ++++ ...terface_50_modAgenda_ActionsAuto.class.php | 5 +++- htdocs/langs/en_US/main.lang | 1 + htdocs/projet/card.php | 4 +++ htdocs/projet/tasks/task.php | 5 ++++ 8 files changed, 47 insertions(+), 10 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index c2dbdd46ed6..7b1c81af59c 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -670,7 +670,7 @@ if ($action == 'create') } // Title - print 'global->AGENDA_USE_EVENT_TYPE)?' class="fieldrequired titlefieldcreate"':'').'>'.$langs->trans("Title").''; + print 'global->AGENDA_USE_EVENT_TYPE)?' class="fieldrequired titlefieldcreate"':'').'>'.$langs->trans("Label").''; // Full day print ''.$langs->trans("EventOnFullDay").''; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 84e75e06cbd..6dd3cbb4f84 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -860,9 +860,10 @@ class ActionComm extends CommonObject * @param string $filter Other filter * @param string $sortfield Sort on this field * @param string $sortorder ASC or DESC + * @param string $limit Limit number of answers * @return array or string Error string if KO, array with actions if OK */ - static function getActions($db, $socid=0, $fk_element=0, $elementtype='', $filter='', $sortfield='', $sortorder='') + static function getActions($db, $socid=0, $fk_element=0, $elementtype='', $filter='', $sortfield='datep', $sortorder='DESC', $limit=0) { global $conf, $langs; @@ -879,6 +880,7 @@ class ActionComm extends CommonObject } if (! empty($filter)) $sql.= $filter; if ($sortorder && $sortfield) $sql.=$db->order($sortfield, $sortorder); + if ($limit) $sql.=$db->plimit($limit); dol_syslog(get_class()."::getActions", LOG_DEBUG); $resql=$db->query($sql); diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index 7b312ea784a..785ada1429c 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -155,16 +155,18 @@ class FormActions * @param int $socid socid of user * @param int $forceshowtitle Show title even if there is no actions to show * @param string $morecss More css on table + * @param int $max Max number of record + * @param string $moreparambacktopage More param for the backtopage * @return int <0 if KO, >=0 if OK */ - function showactions($object,$typeelement,$socid=0,$forceshowtitle=0,$morecss='listactions') + function showactions($object, $typeelement, $socid=0, $forceshowtitle=0, $morecss='listactions', $max=0, $moreparambacktopage='') { global $langs,$conf,$user; global $bc; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; - $listofactions=ActionComm::getActions($this->db, $socid, $object->id, $typeelement); + $listofactions=ActionComm::getActions($this->db, $socid, $object->id, $typeelement, '', '', '', ($max?($max+1):0)); if (! is_array($listofactions)) dol_print_error($this->db,'FailedToGetActions'); $num = count($listofactions); @@ -177,12 +179,15 @@ class FormActions elseif ($typeelement == 'supplier_proposal') $title=$langs->trans('ActionsOnSupplierProposal'); elseif ($typeelement == 'order') $title=$langs->trans('ActionsOnOrder'); elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') $title=$langs->trans('ActionsOnOrder'); - elseif ($typeelement == 'project') $title=$langs->trans('ActionsOnProject'); elseif ($typeelement == 'shipping') $title=$langs->trans('ActionsOnShipping'); elseif ($typeelement == 'fichinter') $title=$langs->trans('ActionsOnFicheInter'); - else $title=$langs->trans("Actions"); + elseif ($typeelement == 'project') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); + elseif ($typeelement == 'task') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); + else $title=$langs->trans("Actions"); - $buttontoaddnewevent = ''; + $urlbacktopage=$_SERVER['PHP_SELF'].'?id='.$object->id.($moreparambacktopage?'&'.$moreparambacktopage:''); + + $buttontoaddnewevent = ''; $buttontoaddnewevent.= $langs->trans("AddEvent"); $buttontoaddnewevent.= ''; print load_fiche_titre($title, $buttontoaddnewevent, ''); @@ -197,7 +202,7 @@ class FormActions print_liste_field_titre('Ref', $_SERVER["PHP_SELF"], '', $page, $param, ''); print_liste_field_titre('Action', $_SERVER["PHP_SELF"], '', $page, $param, ''); print_liste_field_titre('Type', $_SERVER["PHP_SELF"], '', $page, $param, ''); - print_liste_field_titre('Date', $_SERVER["PHP_SELF"], '', $page, $param, ''); + print_liste_field_titre('Date', $_SERVER["PHP_SELF"], '', $page, $param, 'align="center"'); print_liste_field_titre('By', $_SERVER["PHP_SELF"], '', $page, $param, ''); print_liste_field_titre('', $_SERVER["PHP_SELF"], '', $page, $param, 'align="right"'); print ''; @@ -205,8 +210,11 @@ class FormActions $userstatic = new User($this->db); + $cursorevent = 0; foreach($listofactions as $action) { + if ($max && $cursorevent >= $max) break; + $ref=$action->getNomUrl(1,-1); $label=$action->getNomUrl(0,38); @@ -226,7 +234,7 @@ class FormActions } print $action->type; print ''; - print ''.dol_print_date($action->datep,'dayhour'); + print ''.dol_print_date($action->datep,'dayhour'); if ($action->datef) { $tmpa=dol_getdate($action->datep); @@ -254,7 +262,15 @@ class FormActions } print ''; print ''; + + $cursorevent++; } + + if ($max && $num > $max) + { + print ''.$langs->trans("More").'...'; + } + print ''; print ''; } diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 181e8a7fe11..54bf70981b7 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -1780,6 +1780,11 @@ function dolGetElementUrl($objectid,$objecttype,$withpicto=0,$option='') $module='ficheinter'; $subelement='fichinter'; } + if ($objecttype == 'task') { + $classpath = 'projet/class'; + $module='projet'; + $subelement='task'; + } //print "objecttype=".$objecttype." module=".$module." subelement=".$subelement; @@ -2212,3 +2217,4 @@ function getModuleDirForApiClass($module) return $moduledirforclass; } + diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 751a5fa1361..4e09fef4d43 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -747,6 +747,9 @@ class InterfaceActionsAuto extends DolibarrTriggers // Set societeforaction. if ($object->socid > 0) $societeforaction->fetch($object->socid); + $projectid = isset($object->fk_project)?$object->fk_project:0; + if ($object->element == 'project') $projectid = $object->id; + // Insertion action require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; $actioncomm = new ActionComm($this->db); @@ -754,7 +757,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $actioncomm->code = 'AC_'.$action; $actioncomm->label = $object->actionmsg2; $actioncomm->note = $object->actionmsg; // TODO Replace with $actioncomm->email_msgid ? $object->email_content : $object->actionmsg - $actioncomm->fk_project = isset($object->fk_project)?$object->fk_project:0; + $actioncomm->fk_project = $projectid; $actioncomm->datep = $now; $actioncomm->datef = $now; $actioncomm->durationp = 0; diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index a314f59b6b5..02f3f80982e 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -406,6 +406,7 @@ ActionRunningNotStarted=To start ActionRunningShort=In progress ActionDoneShort=Finished ActionUncomplete=Uncomplete +LatestLinkedEvents=Latest %s linked events CompanyFoundation=Company/Organisation ContactsForCompany=Contacts for this third party ContactsAddressesForCompany=Contacts/addresses for this third party diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index b8528e9863c..849ea5cd47d 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -1198,6 +1198,10 @@ elseif ($object->id > 0) print '
'; + // List of actions on element + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, 'project', $socid, 1, '', 10); print '
'; } diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index a04a4573aea..1b43940029f 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -588,6 +588,11 @@ if ($id > 0 || ! empty($ref)) print '
'; + // List of actions on element + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, 'task', $socid, 1, '', 10, 'withproject='.$withproject); + print '
'; } } From 3deacaa5c47e53b9c3509f2979cff7c92191c1f7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Sep 2017 17:10:04 +0200 Subject: [PATCH 28/48] Fix css pb --- htdocs/theme/eldy/style.css.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index e6e49dcc85c..32032ba583b 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -441,9 +441,10 @@ hr { border: 0; border-top: 1px solid #ccc; } box-shadow: 0px 0px 6px 1px rgba(0, 0, 60, 0.2), 0px 0px 0px rgba(60,60,60,0.1); } .button:hover, .buttonDelete:hover { - -moz-box-shadow: 0px 0px 6px 1px rgba(0, 0, 0, 0.2), 0px 0px 0px rgba(60,60,60,0.1); - -webkit-box-shadow: 0px 0px 6px 1px rgba(0, 0, 0, 0.2), 0px 0px 0px rgba(60,60,60,0.1); - box-shadow: 0px 0px 6px 1px rgba(0, 0, 0, 0.2), 0px 0px 0px rgba(60,60,60,0.1); + /* warning: having a larger shadow has side effect when button is completely on left of a table */ + -moz-box-shadow: 0px 0px 1px 1px rgba(0, 0, 0, 0.2), 0px 0px 0px rgba(60,60,60,0.1); + -webkit-box-shadow: 0px 0px 1px 1px rgba(0, 0, 0, 0.2), 0px 0px 0px rgba(60,60,60,0.1); + box-shadow: 0px 0px 1px 1px rgba(0, 0, 0, 0.2), 0px 0px 0px rgba(60,60,60,0.1); } .button:disabled, .buttonDelete:disabled { opacity: 0.4; From 58b49f9a080bb58a64a6a2c13814dbb407d226df Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Sep 2017 17:10:23 +0200 Subject: [PATCH 29/48] Fix position of field to avoid errors --- htdocs/compta/paiement.php | 54 ++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 29 deletions(-) diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 37b23c03724..7a494113090 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -585,11 +585,11 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('MulticurrencyAmountTTC').''; if (!empty($conf->multicurrency->enabled)) print ''.$multicurrencyalreadypayedlabel.''; if (!empty($conf->multicurrency->enabled)) print ''.$multicurrencyremaindertopay.''; + if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('MulticurrencyPaymentAmount').''; print ''.$langs->trans('AmountTTC').''; print ''.$alreadypayedlabel.''; print ''.$remaindertopay.''; print ''.$langs->trans('PaymentAmount').''; - if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('MulticurrencyPaymentAmount').''; print ' '; print "\n"; @@ -659,6 +659,29 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) print price($sign * $multicurrency_remaintopay); print ''; + + print ''; + + // Add remind multicurrency amount + $namef = 'multicurrency_amount_'.$objp->facid; + $nameRemain = 'multicurrency_remain_'.$objp->facid; + + if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) + { + if ($action != 'add_paiement') + { + if (!empty($conf->use_javascript_ajax)) + print img_picto("Auto fill",'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $multicurrency_remaintopay)."'"); + print ''; + print ''; + } + else + { + print ''; + print ''; + } + } + print ""; } // Price @@ -695,33 +718,6 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie } print ""; - // Multicurrency Price - if (! empty($conf->multicurrency->enabled)) - { - print ''; - - // Add remind multicurrency amount - $namef = 'multicurrency_amount_'.$objp->facid; - $nameRemain = 'multicurrency_remain_'.$objp->facid; - - if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) - { - if ($action != 'add_paiement') - { - if (!empty($conf->use_javascript_ajax)) - print img_picto("Auto fill",'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $multicurrency_remaintopay)."'"); - print ''; - print ''; - } - else - { - print ''; - print ''; - } - } - print ""; - } - // Warning print ''; //print "xx".$amounts[$invoice->id]."-".$amountsresttopay[$invoice->id]."
"; @@ -754,6 +750,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie if (!empty($conf->multicurrency->enabled)) print ''; if (!empty($conf->multicurrency->enabled)) print ''; if (!empty($conf->multicurrency->enabled)) print ''; + if (!empty($conf->multicurrency->enabled)) print ''; print ''.price($sign * $total_ttc).''; print ''.price($sign * $totalrecu); if ($totalrecucreditnote) print '+'.price($totalrecucreditnote); @@ -761,7 +758,6 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; print ''.price($sign * price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits,'MT')).''; print ''; // Autofilled - if (!empty($conf->multicurrency->enabled)) print ''; print ' '; print "\n"; } From 60078300b828e66e41f91bb0e89a3b27d18ef817 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Sep 2017 17:57:41 +0200 Subject: [PATCH 30/48] FIX PDF output was sharing 2 different currencies in same total --- .../commande/doc/pdf_einstein.modules.php | 5 +- .../expedition/doc/pdf_rouget.modules.php | 100 +++++++-------- .../modules/facture/doc/pdf_crabe.modules.php | 23 ++-- .../product/doc/pdf_standard.modules.php | 119 +++++++++--------- .../modules/propale/doc/pdf_azur.modules.php | 3 +- .../pdf/pdf_canelle.modules.php | 23 +++- .../pdf/pdf_muscadet.modules.php | 2 +- 7 files changed, 146 insertions(+), 129 deletions(-) diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index c87a66de791..74a72b36581 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -862,6 +862,8 @@ class pdf_einstein extends ModelePDFCommandes // Show VAT by rates and total $pdf->SetFillColor(248,248,248); + $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; + $this->atleastoneratenotnull=0; if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { @@ -1035,7 +1037,6 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetFillColor(224,224,224); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); - $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1); } @@ -1048,7 +1049,7 @@ class pdf_einstein extends ModelePDFCommandes //$creditnoteamount=$object->getSumCreditNotesUsed(); //$depositsamount=$object->getSumDepositsUsed(); //print "x".$creditnoteamount."-".$depositsamount;exit; - $resteapayer = price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); + $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); if (! empty($object->paye)) $resteapayer=0; if ($deja_regle > 0) diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 3f7a73a650c..8f51e9b9e40 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -84,7 +84,7 @@ class pdf_rouget extends ModelePdfExpedition } $this->posxpicture=$this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images - + if ($this->page_largeur < 210) // To work with US executive format { $this->posxweightvol-=20; @@ -92,7 +92,7 @@ class pdf_rouget extends ModelePdfExpedition $this->posxqtyordered-=20; $this->posxqtytoship-=20; } - + if (! empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) { $this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered); @@ -139,17 +139,17 @@ class pdf_rouget extends ModelePdfExpedition if (! empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE)) { $objphoto = new Product($this->db); - + for ($i = 0 ; $i < $nblignes ; $i++) { if (empty($object->lines[$i]->fk_product)) continue; - + $objphoto = new Product($this->db); $objphoto->fetch($object->lines[$i]->fk_product); - + $pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/"; $dir = $conf->product->dir_output.'/'.$pdir; - + $realpath=''; foreach ($objphoto->liste_photos($dir,1) as $key => $obj) @@ -169,17 +169,17 @@ class pdf_rouget extends ModelePdfExpedition { $filename=$obj['photo']; } - + $realpath = $dir.$filename; break; } - + if ($realpath) $realpatharray[$i]=$realpath; } } - - if (count($realpatharray) == 0) $this->posxpicture=$this->posxweightvol; - + + if (count($realpatharray) == 0) $this->posxpicture=$this->posxweightvol; + if ($conf->expedition->dir_output) { // Definition de $dir et $file @@ -219,7 +219,7 @@ class pdf_rouget extends ModelePdfExpedition // Set nblignes with the new facture lines content after hook $nblignes = count($object->lines); - + $pdf=pdf_getInstance($this->format); $default_font_size = pdf_getPDFFontSize($outputlangs); $heightforinfotot = 8; // Height reserved to output the info and total part @@ -282,11 +282,11 @@ class pdf_rouget extends ModelePdfExpedition $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1); $nexY = $pdf->GetY(); $height_incoterms=$nexY-$tab_top; - + // Rect prend une longueur en 3eme param $pdf->SetDrawColor(192,192,192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); - + $tab_top = $nexY+6; $height_incoterms += 4; } @@ -343,7 +343,7 @@ class pdf_rouget extends ModelePdfExpedition // Rect prend une longueur en 3eme param $pdf->SetDrawColor(192,192,192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); - + $tab_height = $tab_height - $height_note; $tab_top = $nexY+6; } @@ -400,7 +400,7 @@ class pdf_rouget extends ModelePdfExpedition $pdf->startTransaction(); pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc); - + $pageposafter=$pdf->getPage(); if ($pageposafter > $pageposbefore) // There is a pagebreak { @@ -434,10 +434,10 @@ class pdf_rouget extends ModelePdfExpedition $pdf->commitTransaction(); } $posYAfterDescription=$pdf->GetY(); - + $nexY = $pdf->GetY(); $pageposafter=$pdf->getPage(); - + $pdf->setPage($pageposbefore); $pdf->setTopMargin($this->marge_haute); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. @@ -456,29 +456,29 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetXY($this->posxweightvol, $curY); $weighttxt=''; - if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight) + if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight) { $weighttxt=round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->weight_units,"weight"); } $voltxt=''; - if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume) + if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume) { $voltxt=round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->volume_units?$object->lines[$i]->volume_units:0,"volume"); } - + $pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt)?'
':'').$voltxt, 0, 0, false, true, 'C'); //$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?'
':'').$voltxt,'','C'); - + if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) { $pdf->SetXY($this->posxqtyordered, $curY); $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked,'','C'); } - + $pdf->SetXY($this->posxqtytoship, $curY); $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty_shipped,'','C'); - if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) + if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) { $pdf->SetXY($this->posxpuht, $curY); $pdf->MultiCell(($this->posxtotalht - $this->posxpuht-1), 3, price($object->lines[$i]->subprice, 0, $outputlangs),'','R'); @@ -489,7 +489,7 @@ class pdf_rouget extends ModelePdfExpedition $nexY+=3; if ($weighttxt && $voltxt) $nexY+=2; - + // Add line if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) { @@ -548,7 +548,7 @@ class pdf_rouget extends ModelePdfExpedition } // Affiche zone totaux - $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); + $posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs); // Pied de page $this->_pagefoot($pdf,$object,$outputlangs); @@ -612,7 +612,7 @@ class pdf_rouget extends ModelePdfExpedition }*/ if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxqtyordered - $this->posxweightvol); else $largcol2 = ($this->posxqtytoship - $this->posxweightvol); - + $useborder=0; $index = 0; @@ -626,12 +626,12 @@ class pdf_rouget extends ModelePdfExpedition $totalOrdered=$tmparray['ordered']; $totalToShip=$tmparray['toship']; // Set trueVolume and volume_units not currently stored into database - if ($object->trueWidth && $object->trueHeight && $object->trueDepth) + if ($object->trueWidth && $object->trueHeight && $object->trueDepth) { $object->trueVolume=price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0); $object->volume_units=$object->size_units * 3; } - + if ($totalWeight!='') $totalWeighttoshow=showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs); if ($totalVolume!='') $totalVolumetoshow=showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs); if ($object->trueWeight) $totalWeighttoshow=showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); @@ -640,48 +640,48 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetFillColor(255,255,255); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1); - + if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) { $pdf->SetXY($this->posxqtyordered, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, $tab2_hl, $totalOrdered, 0, 'C', 1); } - + $pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1); - + if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) { $pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1); - + $pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl, price($object->total_ht, 0, $outputlangs), 0, 'C', 1); } - + // Total Weight if ($totalWeighttoshow) { $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index); $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0, 'C', 1); - + $index++; } if ($totalVolumetoshow) { $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index); $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0, 'C', 1); - + $index++; } if (! $totalWeighttoshow && ! $totalVolumetoshow) $index++; - + $pdf->SetTextColor(0,0,0); return ($tab2_top + ($tab2_hl * $index)); } - + /** * Show table for lines * @@ -728,7 +728,7 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetXY($this->posxweightvol-1, $tab_top+1); $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities("WeightVolShort"),'','C'); } - + if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) { $pdf->line($this->posxqtyordered-1, $tab_top, $this->posxqtyordered-1, $tab_top + $tab_height); @@ -738,14 +738,14 @@ class pdf_rouget extends ModelePdfExpedition $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"),'','C'); } } - + $pdf->line($this->posxqtytoship-1, $tab_top, $this->posxqtytoship-1, $tab_top + $tab_height); if (empty($hidetop)) { $pdf->SetXY($this->posxqtytoship, $tab_top+1); $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities("QtyToShip"),'','C'); } - + if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) { $pdf->line($this->posxpuht-1, $tab_top, $this->posxpuht-1, $tab_top + $tab_height); @@ -754,7 +754,7 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetXY($this->posxpuht-1, $tab_top+1); $pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities("PriceUHT"),'','C'); } - + $pdf->line($this->posxtotalht-1, $tab_top, $this->posxtotalht-1, $tab_top + $tab_height); if (empty($hidetop)) { @@ -763,7 +763,7 @@ class pdf_rouget extends ModelePdfExpedition } } - + } /** @@ -780,7 +780,7 @@ class pdf_rouget extends ModelePdfExpedition global $conf,$langs,$mysoc; $langs->load("orders"); - + $default_font_size = pdf_getPDFFontSize($outputlangs); pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); @@ -796,7 +796,7 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetFont('','B', $default_font_size + 3); $w = 110; - + $posy=$this->marge_haute; $posx=$this->page_largeur-$this->marge_droite-$w; @@ -863,7 +863,7 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetFont('','', $default_font_size + 1); $posy+=5; - + $pdf->SetXY($posx,$posy); $pdf->SetTextColor(0,0,60); $pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefSending") ." : ".$object->ref, '', 'R'); @@ -876,7 +876,7 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetTextColor(0,0,60); $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery,"day",false,$outputlangs,true), '', 'R'); } - + if (! empty($object->thirdparty->code_client)) { $posy+=4; @@ -904,7 +904,7 @@ class pdf_rouget extends ModelePdfExpedition if ($result >= 0) { //$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects - + $pdf->SetFont('','', $default_font_size - 2); $text=$linkedobject->ref; if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')'; @@ -939,7 +939,7 @@ class pdf_rouget extends ModelePdfExpedition $hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40; $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82; - + // Show sender frame $pdf->SetTextColor(0,0,0); $pdf->SetFont('','', $default_font_size - 2); @@ -950,7 +950,7 @@ class pdf_rouget extends ModelePdfExpedition $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1); $pdf->SetTextColor(0,0,60); $pdf->SetFillColor(255,255,255); - + // Show sender name $pdf->SetXY($posx+2,$posy+3); $pdf->SetFont('','B',$default_font_size); diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index c473740a05d..338a6019b56 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -214,9 +214,9 @@ class pdf_crabe extends ModelePDFFactures { $object->fetch_thirdparty(); - $deja_regle = $object->getSommePaiement(); - $amount_credit_notes_included = $object->getSumCreditNotesUsed(); - $amount_deposits_included = $object->getSumDepositsUsed(); + $deja_regle = $object->getSommePaiement(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); + $amount_credit_notes_included = $object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); + $amount_deposits_included = $object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); // Definition of $dir and $file if ($object->specimen) @@ -771,7 +771,7 @@ class pdf_crabe extends ModelePDFFactures // Loop on each deposits and credit notes included - $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; + $sql = "SELECT re.rowid, re.amount_ht, re.multicurrency_amount_ht, re.amount_tva, re.multicurrency_amount_tva, re.amount_ttc, re.multicurrency_amount_ttc,"; $sql.= " re.description, re.fk_facture_source,"; $sql.= " f.type, f.datef"; $sql.= " FROM ".MAIN_DB_PREFIX ."societe_remise_except as re, ".MAIN_DB_PREFIX ."facture as f"; @@ -796,7 +796,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetXY($tab3_posx, $tab3_top+$y); $pdf->MultiCell(20, 3, dol_print_date($obj->datef,'day',false,$outputlangs,true), 0, 'L', 0); $pdf->SetXY($tab3_posx+21, $tab3_top+$y); - $pdf->MultiCell(20, 3, price($obj->amount_ttc, 0, $outputlangs), 0, 'L', 0); + $pdf->MultiCell(20, 3, price(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0, 'L', 0); $pdf->SetXY($tab3_posx+40, $tab3_top+$y); $pdf->MultiCell(20, 3, $text, 0, 'L', 0); $pdf->SetXY($tab3_posx+58, $tab3_top+$y); @@ -815,7 +815,7 @@ class pdf_crabe extends ModelePDFFactures // Loop on each payment // TODO Call getListOfPaymentsgetListOfPayments instead of hard coded sql - $sql = "SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount,"; + $sql = "SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,"; $sql.= " cp.code"; $sql.= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id"; @@ -835,7 +835,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetXY($tab3_posx, $tab3_top+$y); $pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date),'day',false,$outputlangs,true), 0, 'L', 0); $pdf->SetXY($tab3_posx+21, $tab3_top+$y); - $pdf->MultiCell(20, 3, price($sign * $row->amount, 0, $outputlangs), 0, 'L', 0); + $pdf->MultiCell(20, 3, price($sign * (($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0, 'L', 0); $pdf->SetXY($tab3_posx+40, $tab3_top+$y); $oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->code); @@ -1060,6 +1060,8 @@ class pdf_crabe extends ModelePDFFactures // Show VAT by rates and total $pdf->SetFillColor(248,248,248); + $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; + $this->atleastoneratenotnull=0; if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { @@ -1270,7 +1272,6 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetFillColor(224,224,224); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); - $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $total_ttc, 0, $outputlangs), $useborder, 'R', 1); } @@ -1278,10 +1279,10 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetTextColor(0,0,0); - $creditnoteamount=$object->getSumCreditNotesUsed(); - $depositsamount=$object->getSumDepositsUsed(); + $creditnoteamount=$object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); + $depositsamount=$object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); //print "x".$creditnoteamount."-".$depositsamount;exit; - $resteapayer = price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); + $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); if ($object->paye) $resteapayer=0; if ($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) diff --git a/htdocs/core/modules/product/doc/pdf_standard.modules.php b/htdocs/core/modules/product/doc/pdf_standard.modules.php index 29df1127242..2ceca5791a8 100644 --- a/htdocs/core/modules/product/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/product/doc/pdf_standard.modules.php @@ -40,28 +40,28 @@ class pdf_standard extends ModelePDFProduct * @var DoliDb Database handler */ public $db; - + /** * @var string model name */ public $name; - + /** * @var string model description (short text) */ public $description; - + /** * @var string document type */ public $type; - + /** * @var array() Minimum version of PHP required by module. * e.g.: PHP ≥ 5.3 = array(5, 3) */ - public $phpmin = array(5, 2); - + public $phpmin = array(5, 2); + /** * Dolibarr version of the loaded document * @public string @@ -77,7 +77,7 @@ class pdf_standard extends ModelePDFProduct public $marge_basse; public $emetteur; // Objet societe qui emet - + /** * Constructor @@ -105,7 +105,7 @@ class pdf_standard extends ModelePDFProduct $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; - + $this->option_logo = 1; // Affiche logo $this->option_codeproduitservice = 0; // Affiche code produit-service $this->option_multilang = 1; // Dispo en plusieurs langues @@ -145,7 +145,7 @@ class pdf_standard extends ModelePDFProduct $outputlangs->load("deliveries"); $nblignes = count($object->lines); - + if ($conf->produit->dir_output) { // Definition of $dir and $file @@ -160,7 +160,7 @@ class pdf_standard extends ModelePDFProduct $dir = $conf->produit->dir_output . "/" . $objectref; $file = $dir . "/" . $objectref . ".pdf"; } - + $productFournisseur = new ProductFournisseur($this->db); $supplierprices = $productFournisseur->list_product_fournisseur_price($object->id); $object->supplierprices = $supplierprices; @@ -191,11 +191,11 @@ class pdf_standard extends ModelePDFProduct $pdf=pdf_getInstance($this->format); $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance $pdf->SetAutoPageBreak(1,0); - + $heightforinfotot = 40; // Height reserved to output the info and total part $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) - + if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); @@ -242,7 +242,7 @@ class pdf_standard extends ModelePDFProduct $pdf->SetFont('','B', $default_font_size); $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $tab_top, dol_htmlentitiesbr($object->label), 0, 1); $nexY = $pdf->GetY(); - + $pdf->SetFont('','', $default_font_size); $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $nexY, dol_htmlentitiesbr($object->description), 0, 1); $nexY = $pdf->GetY(); @@ -270,7 +270,7 @@ class pdf_standard extends ModelePDFProduct $nexY = $pdf->GetY(); } - + // Affiche notes // TODO There is no public note on product yet $notetoshow=empty($object->note_public)?'':$object->note_public; @@ -424,7 +424,7 @@ class pdf_standard extends ModelePDFProduct // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva; else $tvaligne=$object->lines[$i]->total_tva; - + $localtax1ligne=$object->lines[$i]->total_localtax1; $localtax2ligne=$object->lines[$i]->total_localtax2; $localtax1_rate=$object->lines[$i]->localtax1_tx; @@ -518,13 +518,10 @@ class pdf_standard extends ModelePDFProduct $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } */ - + // Affiche zone infos //$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); - // Affiche zone totaux - //$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); - // Pied de page $this->_pagefoot($pdf,$object,$outputlangs); if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); @@ -557,7 +554,7 @@ class pdf_standard extends ModelePDFProduct } } - + /** * Show table for lines * @@ -574,42 +571,42 @@ class pdf_standard extends ModelePDFProduct function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='') { global $conf; - + // Force to disable hidetop and hidebottom $hidebottom=0; if ($hidetop) $hidetop=-1; - + $currency = !empty($currency) ? $currency : $conf->currency; $default_font_size = pdf_getPDFFontSize($outputlangs); - + // Amount in (at tab_top - 1) $pdf->SetTextColor(0,0,0); $pdf->SetFont('','', $default_font_size - 2); - + if (empty($hidetop)) { $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency)); $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4); $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); - + //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_droite-$this->marge_gauche, 5, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); } - + $pdf->SetDrawColor(128,128,128); $pdf->SetFont('','', $default_font_size - 1); - + // Output Rect $this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param - + if (empty($hidetop)) { $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param - + $pdf->SetXY($this->posxdesc-1, $tab_top+1); $pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L'); } - + if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) { $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height); @@ -619,14 +616,14 @@ class pdf_standard extends ModelePDFProduct $pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C'); } } - + $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); if (empty($hidetop)) { $pdf->SetXY($this->posxup-1, $tab_top+1); $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceUHT"),'','C'); } - + $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); if (empty($hidetop)) { @@ -640,7 +637,7 @@ class pdf_standard extends ModelePDFProduct $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); } } - + if($conf->global->PRODUCT_USE_UNITS) { $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height); if (empty($hidetop)) { @@ -649,7 +646,7 @@ class pdf_standard extends ModelePDFProduct 'C'); } } - + $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height); if (empty($hidetop)) { @@ -659,7 +656,7 @@ class pdf_standard extends ModelePDFProduct $pdf->MultiCell($this->postotalht-$this->posxdiscount+1,2, $outputlangs->transnoentities("ReductionShort"),'','C'); } } - + if ($this->atleastonediscount) { $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height); @@ -670,7 +667,7 @@ class pdf_standard extends ModelePDFProduct $pdf->MultiCell(30,2, $outputlangs->transnoentities("TotalHT"),'','C'); } } - + /** * Show top header of page. * @@ -684,33 +681,33 @@ class pdf_standard extends ModelePDFProduct function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="") { global $conf,$langs,$hookmanager; - + $outputlangs->load("main"); $outputlangs->load("bills"); $outputlangs->load("propal"); $outputlangs->load("companies"); $outputlangs->load("orders"); $default_font_size = pdf_getPDFFontSize($outputlangs); - + if ($object->type == 1) $titlekey='ServiceSheet'; else $titlekey='ProductSheet'; - + pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); - + // Show Draft Watermark if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) ) { pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK); } - + $pdf->SetTextColor(0,0,60); $pdf->SetFont('','B', $default_font_size + 3); - + $posy=$this->marge_haute; $posx=$this->page_largeur-$this->marge_droite-100; - + $pdf->SetXY($this->marge_gauche,$posy); - + // Logo $logo=$conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; if ($this->emetteur->logo) @@ -733,23 +730,23 @@ class pdf_standard extends ModelePDFProduct $text=$this->emetteur->name; $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); } - + $pdf->SetFont('','B', $default_font_size + 3); $pdf->SetXY($posx,$posy); $pdf->SetTextColor(0,0,60); $title=$outputlangs->transnoentities($titlekey); $pdf->MultiCell(100, 3, $title, '', 'R'); - + $pdf->SetFont('','B',$default_font_size); - + $posy+=5; $pdf->SetXY($posx,$posy); $pdf->SetTextColor(0,0,60); $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R'); - + $posy+=1; $pdf->SetFont('','', $default_font_size - 1); - + /*if ($object->ref_client) { $posy+=5; @@ -757,13 +754,13 @@ class pdf_standard extends ModelePDFProduct $pdf->SetTextColor(0,0,60); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R'); }*/ - + /*$posy+=4; $pdf->SetXY($posx,$posy); $pdf->SetTextColor(0,0,60); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date,"%d %b %Y",false,$outputlangs,true), '', 'R'); */ - + // Get contact /* if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) @@ -779,24 +776,24 @@ class pdf_standard extends ModelePDFProduct $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R'); } }*/ - + $posy+=2; - + // Show list of linked objects $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); - + if ($showaddress) { /* // Sender properties $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); - + // Show sender $posy=42; $posx=$this->marge_gauche; if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; $hautcadre=40; - + // Show sender frame $pdf->SetTextColor(0,0,0); $pdf->SetFont('','', $default_font_size - 2); @@ -806,23 +803,23 @@ class pdf_standard extends ModelePDFProduct $pdf->SetFillColor(230,230,230); $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); $pdf->SetTextColor(0,0,60); - + // Show sender name $pdf->SetXY($posx+2,$posy+3); $pdf->SetFont('','B', $default_font_size); $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); $posy=$pdf->getY(); - + // Show sender information $pdf->SetXY($posx+2,$posy); $pdf->SetFont('','', $default_font_size - 1); $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); */ } - + $pdf->SetTextColor(0,0,0); } - + /** * Show footer of page. Need this->emetteur object * @@ -838,6 +835,6 @@ class pdf_standard extends ModelePDFProduct $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; return pdf_pagefoot($pdf,$outputlangs,'PRODUCT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); } - + } diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 9a928a7ce2b..8b9929f2880 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -1010,6 +1010,8 @@ class pdf_azur extends ModelePDFPropales // Show VAT by rates and total $pdf->SetFillColor(248,248,248); + $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; + $this->atleastoneratenotnull=0; if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { @@ -1186,7 +1188,6 @@ class pdf_azur extends ModelePDFPropales $pdf->SetFillColor(224,224,224); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); - $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1); } diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php index 8737c39f67f..b488252f77c 100644 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -717,6 +717,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $useborder=0; + // Total TTC $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $pdf->SetTextColor(0,0,60); @@ -727,6 +728,14 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc), $useborder, 'R', 1); + $creditnoteamount=0; + $depositsamount=0; + //$creditnoteamount=$object->getSumCreditNotesUsed(); + //$depositsamount=$object->getSumDepositsUsed(); + //print "x".$creditnoteamount."-".$depositsamount;exit; + $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); + if (! empty($object->paye)) $resteapayer=0; + if ($deja_regle > 0) { $index++; @@ -743,7 +752,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle), $useborder, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1); $pdf->SetFont('','', $default_font_size - 1); $pdf->SetTextColor(0,0,0); } @@ -877,6 +886,11 @@ class pdf_canelle extends ModelePDFSuppliersInvoices */ function _tableau_versements(&$pdf, $object, $posy, $outputlangs) { + global $conf; + + $sign=1; + if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; + $tab3_posx = 120; $tab3_top = $posy + 8; $tab3_width = 80; @@ -910,8 +924,11 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->SetFont('','', $default_font_size - 4); + // Loop on each deposits and credit notes included + // + // Loop on each payment - $sql = "SELECT p.datep as date, p.fk_paiement as type, p.num_paiement as num, pf.amount as amount,"; + $sql = "SELECT p.datep as date, p.fk_paiement as type, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,"; $sql.= " cp.code"; $sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf, ".MAIN_DB_PREFIX."paiementfourn as p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id"; @@ -929,7 +946,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->SetXY($tab3_posx, $tab3_top+$y); $pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date),'day',false,$outputlangs,true), 0, 'L', 0); $pdf->SetXY($tab3_posx+21, $tab3_top+$y); - $pdf->MultiCell(20, 3, price($row->amount), 0, 'L', 0); + $pdf->MultiCell(20, 3, price($sign * (($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount)), 0, 'L', 0); $pdf->SetXY($tab3_posx+40, $tab3_top+$y); $oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->code); diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php index 8380ff65e9a..78ecb9d52c2 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -840,7 +840,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders //$creditnoteamount=$object->getSumCreditNotesUsed(); //$depositsamount=$object->getSumDepositsUsed(); //print "x".$creditnoteamount."-".$depositsamount;exit; - $resteapayer = price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); + $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); if (! empty($object->paye)) $resteapayer=0; if ($deja_regle > 0) From e0eef2080e2340a1f6c81651bb38be23df10f350 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Sep 2017 17:57:41 +0200 Subject: [PATCH 31/48] FIX PDF output was sharing 2 different currencies in same total Conflicts: htdocs/core/modules/commande/doc/pdf_einstein.modules.php htdocs/core/modules/facture/doc/pdf_crabe.modules.php htdocs/core/modules/product/doc/pdf_standard.modules.php htdocs/core/modules/propale/doc/pdf_azur.modules.php --- .../commande/doc/pdf_einstein.modules.php | 21 ++-- .../expedition/doc/pdf_rouget.modules.php | 100 +++++++++--------- .../modules/facture/doc/pdf_crabe.modules.php | 69 ++++++------ .../modules/propale/doc/pdf_azur.modules.php | 25 ++--- .../pdf/pdf_canelle.modules.php | 23 +++- .../pdf/pdf_muscadet.modules.php | 2 +- 6 files changed, 130 insertions(+), 110 deletions(-) diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 54c1f546903..e8dee5b8068 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -216,11 +216,11 @@ class pdf_einstein extends ModelePDFCommandes $pdf=pdf_getInstance($this->format); $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance $pdf->SetAutoPageBreak(1,0); - + $heightforinfotot = 40; // Height reserved to output the info and total part $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) - + if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); @@ -293,16 +293,16 @@ class pdf_einstein extends ModelePDFCommandes $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1); $nexY = $pdf->GetY(); $height_incoterms=$nexY-$tab_top; - + // Rect prend une longueur en 3eme param $pdf->SetDrawColor(192,192,192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); - + $tab_top = $nexY+6; $height_incoterms += 4; } } - + // Affiche notes $notetoshow=empty($object->note_public)?'':$object->note_public; if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) @@ -454,7 +454,7 @@ class pdf_einstein extends ModelePDFCommandes // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva; else $tvaligne=$object->lines[$i]->total_tva; - + $localtax1ligne=$object->lines[$i]->total_localtax1; $localtax2ligne=$object->lines[$i]->total_localtax2; $localtax1_rate=$object->lines[$i]->localtax1_tx; @@ -561,7 +561,7 @@ class pdf_einstein extends ModelePDFCommandes $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs); } */ - + // Pied de page $this->_pagefoot($pdf,$object,$outputlangs); if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); @@ -838,6 +838,8 @@ class pdf_einstein extends ModelePDFCommandes // Show VAT by rates and total $pdf->SetFillColor(248,248,248); + $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; + $this->atleastoneratenotnull=0; if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { @@ -1011,7 +1013,6 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetFillColor(224,224,224); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); - $total_ttc = ($conf->multicurrency->enabled && $object->multiccurency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1); } @@ -1024,7 +1025,7 @@ class pdf_einstein extends ModelePDFCommandes //$creditnoteamount=$object->getSumCreditNotesUsed(); //$depositsamount=$object->getSumDepositsUsed(); //print "x".$creditnoteamount."-".$depositsamount;exit; - $resteapayer = price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); + $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); if (! empty($object->paye)) $resteapayer=0; if ($deja_regle > 0) @@ -1270,7 +1271,7 @@ class pdf_einstein extends ModelePDFCommandes $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R'); } } - + $posy+=2; // Show list of linked objects diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index d1697b767bd..62862e06e11 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -84,7 +84,7 @@ class pdf_rouget extends ModelePdfExpedition } $this->posxpicture=$this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images - + if ($this->page_largeur < 210) // To work with US executive format { $this->posxweightvol-=20; @@ -92,7 +92,7 @@ class pdf_rouget extends ModelePdfExpedition $this->posxqtyordered-=20; $this->posxqtytoship-=20; } - + if (! empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) { $this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered); @@ -139,17 +139,17 @@ class pdf_rouget extends ModelePdfExpedition if (! empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE)) { $objphoto = new Product($this->db); - + for ($i = 0 ; $i < $nblignes ; $i++) { if (empty($object->lines[$i]->fk_product)) continue; - + $objphoto = new Product($this->db); $objphoto->fetch($object->lines[$i]->fk_product); - + $pdir = get_exdir($object->lines[$i]->fk_product,2,0,0,$objphoto,'product') . $object->lines[$i]->fk_product ."/photos/"; $dir = $conf->product->dir_output.'/'.$pdir; - + $realpath=''; foreach ($objphoto->liste_photos($dir,1) as $key => $obj) @@ -169,17 +169,17 @@ class pdf_rouget extends ModelePdfExpedition { $filename=$obj['photo']; } - + $realpath = $dir.$filename; break; } - + if ($realpath) $realpatharray[$i]=$realpath; } } - - if (count($realpatharray) == 0) $this->posxpicture=$this->posxweightvol; - + + if (count($realpatharray) == 0) $this->posxpicture=$this->posxweightvol; + if ($conf->expedition->dir_output) { // Definition de $dir et $file @@ -219,7 +219,7 @@ class pdf_rouget extends ModelePdfExpedition // Set nblignes with the new facture lines content after hook $nblignes = count($object->lines); - + $pdf=pdf_getInstance($this->format); $default_font_size = pdf_getPDFFontSize($outputlangs); $heightforinfotot = 8; // Height reserved to output the info and total part @@ -282,11 +282,11 @@ class pdf_rouget extends ModelePdfExpedition $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1); $nexY = $pdf->GetY(); $height_incoterms=$nexY-$tab_top; - + // Rect prend une longueur en 3eme param $pdf->SetDrawColor(192,192,192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1); - + $tab_top = $nexY+6; $height_incoterms += 4; } @@ -343,7 +343,7 @@ class pdf_rouget extends ModelePdfExpedition // Rect prend une longueur en 3eme param $pdf->SetDrawColor(192,192,192); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); - + $tab_height = $tab_height - $height_note; $tab_top = $nexY+6; } @@ -400,7 +400,7 @@ class pdf_rouget extends ModelePdfExpedition $pdf->startTransaction(); pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxpicture-$curX,3,$curX,$curY,$hideref,$hidedesc); - + $pageposafter=$pdf->getPage(); if ($pageposafter > $pageposbefore) // There is a pagebreak { @@ -434,10 +434,10 @@ class pdf_rouget extends ModelePdfExpedition $pdf->commitTransaction(); } $posYAfterDescription=$pdf->GetY(); - + $nexY = $pdf->GetY(); $pageposafter=$pdf->getPage(); - + $pdf->setPage($pageposbefore); $pdf->setTopMargin($this->marge_haute); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. @@ -456,29 +456,29 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetXY($this->posxweightvol, $curY); $weighttxt=''; - if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight) + if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight) { $weighttxt=round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->weight_units,"weight"); } $voltxt=''; - if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume) + if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume) { $voltxt=round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, 5).' '.measuring_units_string($object->lines[$i]->volume_units?$object->lines[$i]->volume_units:0,"volume"); } - + $pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt)?'
':'').$voltxt, 0, 0, false, true, 'C'); //$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?'
':'').$voltxt,'','C'); - + if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) { $pdf->SetXY($this->posxqtyordered, $curY); $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked,'','C'); } - + $pdf->SetXY($this->posxqtytoship, $curY); $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty_shipped,'','C'); - if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) + if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) { $pdf->SetXY($this->posxpuht, $curY); $pdf->MultiCell(($this->posxtotalht - $this->posxpuht-1), 3, price($object->lines[$i]->subprice, 0, $outputlangs),'','R'); @@ -489,7 +489,7 @@ class pdf_rouget extends ModelePdfExpedition $nexY+=3; if ($weighttxt && $voltxt) $nexY+=2; - + // Add line if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) { @@ -548,7 +548,7 @@ class pdf_rouget extends ModelePdfExpedition } // Affiche zone totaux - $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); + $posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs); // Pied de page $this->_pagefoot($pdf,$object,$outputlangs); @@ -612,7 +612,7 @@ class pdf_rouget extends ModelePdfExpedition }*/ if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxqtyordered - $this->posxweightvol); else $largcol2 = ($this->posxqtytoship - $this->posxweightvol); - + $useborder=0; $index = 0; @@ -626,12 +626,12 @@ class pdf_rouget extends ModelePdfExpedition $totalOrdered=$tmparray['ordered']; $totalToShip=$tmparray['toship']; // Set trueVolume and volume_units not currently stored into database - if ($object->trueWidth && $object->trueHeight && $object->trueDepth) + if ($object->trueWidth && $object->trueHeight && $object->trueDepth) { $object->trueVolume=price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0); $object->volume_units=$object->size_units * 3; } - + if ($totalWeight!='') $totalWeighttoshow=showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs); if ($totalVolume!='') $totalVolumetoshow=showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs); if ($object->trueWeight) $totalWeighttoshow=showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); @@ -640,48 +640,48 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetFillColor(255,255,255); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1); - + if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) { $pdf->SetXY($this->posxqtyordered, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, $tab2_hl, $totalOrdered, 0, 'C', 1); } - + $pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1); - + if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) { $pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1); - + $pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl, price($object->total_ht, 0, $outputlangs), 0, 'C', 1); } - + // Total Weight if ($totalWeighttoshow) { $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index); $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0, 'C', 1); - + $index++; } if ($totalVolumetoshow) { $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index); $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0, 'C', 1); - + $index++; } if (! $totalWeighttoshow && ! $totalVolumetoshow) $index++; - + $pdf->SetTextColor(0,0,0); return ($tab2_top + ($tab2_hl * $index)); } - + /** * Show table for lines * @@ -728,7 +728,7 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetXY($this->posxweightvol-1, $tab_top+1); $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities("WeightVolShort"),'','C'); } - + if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) { $pdf->line($this->posxqtyordered-1, $tab_top, $this->posxqtyordered-1, $tab_top + $tab_height); @@ -738,14 +738,14 @@ class pdf_rouget extends ModelePdfExpedition $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"),'','C'); } } - + $pdf->line($this->posxqtytoship-1, $tab_top, $this->posxqtytoship-1, $tab_top + $tab_height); if (empty($hidetop)) { $pdf->SetXY($this->posxqtytoship, $tab_top+1); $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities("QtyToShip"),'','C'); } - + if(!empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT)) { $pdf->line($this->posxpuht-1, $tab_top, $this->posxpuht-1, $tab_top + $tab_height); @@ -754,7 +754,7 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetXY($this->posxpuht-1, $tab_top+1); $pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities("PriceUHT"),'','C'); } - + $pdf->line($this->posxtotalht-1, $tab_top, $this->posxtotalht-1, $tab_top + $tab_height); if (empty($hidetop)) { @@ -763,7 +763,7 @@ class pdf_rouget extends ModelePdfExpedition } } - + } /** @@ -780,7 +780,7 @@ class pdf_rouget extends ModelePdfExpedition global $conf,$langs,$mysoc; $langs->load("orders"); - + $default_font_size = pdf_getPDFFontSize($outputlangs); pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); @@ -796,7 +796,7 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetFont('','B', $default_font_size + 3); $w = 110; - + $posy=$this->marge_haute; $posx=$this->page_largeur-$this->marge_droite-$w; @@ -863,7 +863,7 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetFont('','', $default_font_size + 1); $posy+=5; - + $pdf->SetXY($posx,$posy); $pdf->SetTextColor(0,0,60); $pdf->MultiCell($w, 4, $outputlangs->transnoentities("RefSending") ." : ".$object->ref, '', 'R'); @@ -876,7 +876,7 @@ class pdf_rouget extends ModelePdfExpedition $pdf->SetTextColor(0,0,60); $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery,"day",false,$outputlangs,true), '', 'R'); } - + if (! empty($object->thirdparty->code_client)) { $posy+=4; @@ -904,7 +904,7 @@ class pdf_rouget extends ModelePdfExpedition if ($result >= 0) { //$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects - + $pdf->SetFont('','', $default_font_size - 2); $text=$linkedobject->ref; if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')'; @@ -939,7 +939,7 @@ class pdf_rouget extends ModelePdfExpedition $hautcadre=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40; $widthrecbox=!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82; - + // Show sender frame $pdf->SetTextColor(0,0,0); $pdf->SetFont('','', $default_font_size - 2); @@ -950,7 +950,7 @@ class pdf_rouget extends ModelePdfExpedition $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1); $pdf->SetTextColor(0,0,60); $pdf->SetFillColor(255,255,255); - + // Show sender name $pdf->SetXY($posx+2,$posy+3); $pdf->SetFont('','B',$default_font_size); diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 02d239105b0..be88b7d4114 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -214,9 +214,9 @@ class pdf_crabe extends ModelePDFFactures { $object->fetch_thirdparty(); - $deja_regle = $object->getSommePaiement(); - $amount_credit_notes_included = $object->getSumCreditNotesUsed(); - $amount_deposits_included = $object->getSumDepositsUsed(); + $deja_regle = $object->getSommePaiement(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); + $amount_credit_notes_included = $object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); + $amount_deposits_included = $object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); // Definition of $dir and $file if ($object->specimen) @@ -255,16 +255,16 @@ class pdf_crabe extends ModelePDFFactures // Set nblignes with the new facture lines content after hook $nblignes = count($object->lines); $nbpayments = count($object->getListOfPayments()); - + // Create pdf instance $pdf=pdf_getInstance($this->format); $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance $pdf->SetAutoPageBreak(1,0); - + $heightforinfotot = 50+(4*$nbpayments); // Height reserved to output the info and total part and payment part $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) - + if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); @@ -509,7 +509,7 @@ class pdf_crabe extends ModelePDFFactures $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); $pdf->SetXY($this->posxqty, $curY); // Enough for 6 chars - + if ($this->situationinvoice) { $pdf->MultiCell($this->posxprogress-$this->posxqty-0.8, 4, $qty, 0, 'R'); @@ -769,9 +769,9 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetFont('','', $default_font_size - 4); - + // Loop on each deposits and credit notes included - $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; + $sql = "SELECT re.rowid, re.amount_ht, re.multicurrency_amount_ht, re.amount_tva, re.multicurrency_amount_tva, re.amount_ttc, re.multicurrency_amount_ttc,"; $sql.= " re.description, re.fk_facture_source,"; $sql.= " f.type, f.datef"; $sql.= " FROM ".MAIN_DB_PREFIX ."societe_remise_except as re, ".MAIN_DB_PREFIX ."facture as f"; @@ -796,7 +796,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetXY($tab3_posx, $tab3_top+$y); $pdf->MultiCell(20, 3, dol_print_date($obj->datef,'day',false,$outputlangs,true), 0, 'L', 0); $pdf->SetXY($tab3_posx+21, $tab3_top+$y); - $pdf->MultiCell(20, 3, price($obj->amount_ttc, 0, $outputlangs), 0, 'L', 0); + $pdf->MultiCell(20, 3, price(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0, 'L', 0); $pdf->SetXY($tab3_posx+40, $tab3_top+$y); $pdf->MultiCell(20, 3, $text, 0, 'L', 0); $pdf->SetXY($tab3_posx+58, $tab3_top+$y); @@ -815,14 +815,14 @@ class pdf_crabe extends ModelePDFFactures // Loop on each payment // TODO Call getListOfPaymentsgetListOfPayments instead of hard coded sql - $sql = "SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount,"; + $sql = "SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,"; $sql.= " cp.code"; $sql.= " FROM ".MAIN_DB_PREFIX."paiement_facture as pf, ".MAIN_DB_PREFIX."paiement as p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id"; $sql.= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$object->id; //$sql.= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = 1"; $sql.= " ORDER BY p.datep"; - + $resql=$this->db->query($sql); if ($resql) { @@ -835,7 +835,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetXY($tab3_posx, $tab3_top+$y); $pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date),'day',false,$outputlangs,true), 0, 'L', 0); $pdf->SetXY($tab3_posx+21, $tab3_top+$y); - $pdf->MultiCell(20, 3, price($sign * $row->amount, 0, $outputlangs), 0, 'L', 0); + $pdf->MultiCell(20, 3, price($sign * (($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0, 'L', 0); $pdf->SetXY($tab3_posx+40, $tab3_top+$y); $oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->code); @@ -1052,7 +1052,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetFillColor(255,255,255); $pdf->SetXY($col1x, $tab2_top + 0); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); - + $total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht); $pdf->SetXY($col2x, $tab2_top + 0); $pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($total_ht + (! empty($object->remise)?$object->remise:0)), 0, $outputlangs), 0, 'R', 1); @@ -1060,6 +1060,8 @@ class pdf_crabe extends ModelePDFFactures // Show VAT by rates and total $pdf->SetFillColor(248,248,248); + $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; + $this->atleastoneratenotnull=0; if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { @@ -1071,7 +1073,7 @@ class pdf_crabe extends ModelePDFFactures else { // FIXME amount of vat not supported with multicurrency - + //Local tax 1 before VAT //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') //{ @@ -1141,26 +1143,26 @@ class pdf_crabe extends ModelePDFFactures } //} - + // VAT // Situations totals migth be wrong on huge amounts if ($object->situation_cycle_ref && $object->situation_counter > 1) { - + $sum_pdf_tva = 0; foreach($this->tva as $tvakey => $tvaval){ $sum_pdf_tva+=$tvaval; // sum VAT amounts to compare to object } - + if($sum_pdf_tva!=$object->total_tva) { // apply coef to recover the VAT object amount (the good one) $coef_fix_tva = $object->total_tva / $sum_pdf_tva; - + foreach($this->tva as $tvakey => $tvaval) { $this->tva[$tvakey]=$tvaval * $coef_fix_tva; } } - + } - + foreach($this->tva as $tvakey => $tvaval) { if ($tvakey != 0) // On affiche pas taux 0 @@ -1270,7 +1272,6 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetFillColor(224,224,224); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); - $total_ttc = ($conf->multicurrency->enabled && $object->multiccurency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($sign * $total_ttc, 0, $outputlangs), $useborder, 'R', 1); } @@ -1278,10 +1279,10 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetTextColor(0,0,0); - $creditnoteamount=$object->getSumCreditNotesUsed(); - $depositsamount=$object->getSumDepositsUsed(); + $creditnoteamount=$object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); + $depositsamount=$object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); //print "x".$creditnoteamount."-".$depositsamount;exit; - $resteapayer = price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); + $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); if ($object->paye) $resteapayer=0; if ($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) @@ -1416,7 +1417,7 @@ class pdf_crabe extends ModelePDFFactures if (empty($hidetop)) { $pdf->SetXY($this->posxqty-1, $tab_top+1); - + if($this->situationinvoice) { $pdf->MultiCell($this->posxprogress-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); @@ -1430,14 +1431,14 @@ class pdf_crabe extends ModelePDFFactures $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); } } - + if ($this->situationinvoice) { $pdf->line($this->posxprogress - 1, $tab_top, $this->posxprogress - 1, $tab_top + $tab_height); - + if (empty($hidetop)) { - + $pdf->SetXY($this->posxprogress, $tab_top+1); - + if($conf->global->PRODUCT_USE_UNITS) { $pdf->MultiCell($this->posxunit-$this->posxprogress,2, $outputlangs->transnoentities("Progress"),'','C'); @@ -1450,9 +1451,9 @@ class pdf_crabe extends ModelePDFFactures { $pdf->MultiCell($this->postotalht-$this->posxprogress,2, $outputlangs->transnoentities("Progress"),'','C'); } - + } - + } if($conf->global->PRODUCT_USE_UNITS) { @@ -1617,7 +1618,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->SetTextColor(0,0,60); $pdf->MultiCell($w, 3, $outputlangs->transnoentities("DatePointOfTax")." : " . dol_print_date($object->date_pointoftax,"day",false,$outputlangs), '', 'R'); } - + if ($object->type != 2) { $posy+=3; @@ -1648,7 +1649,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->MultiCell($w, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R'); } } - + $posy+=1; // Show list of linked objects diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index d2ecfb60d81..54f3a4e351e 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -273,7 +273,7 @@ class pdf_azur extends ModelePDFPropales $pdf=pdf_getInstance($this->format); $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance $pdf->SetAutoPageBreak(1,0); - + if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); @@ -322,19 +322,19 @@ class pdf_azur extends ModelePDFPropales $pdf->AddPage(); if (! empty($tplidx)) $pdf->useTemplate($tplidx); $pagenb++; - + $heightforinfotot = 40; // Height reserved to output the info and total part $heightforsignature = empty($conf->global->PROPAL_DISABLE_SIGNATURE)?(pdfGetHeightForHtmlContent($pdf, $outputlangs->transnoentities("ProposalCustomerSignature"))+10):0; $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) - //print $heightforinfotot + $heightforsignature + $heightforfreetext + $heightforfooter;exit; - + //print $heightforinfotot + $heightforsignature + $heightforfreetext + $heightforfooter;exit; + $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('','', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0,0,0); - + $tab_top = 90; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10); $tab_height = 130; @@ -383,7 +383,7 @@ class pdf_azur extends ModelePDFPropales $notetoshow.='Affaire suivi par '.$tmpuser->getFullName($langs); if ($tmpuser->email) $notetoshow.=', Mail: '.$tmpuser->email; if ($tmpuser->office_phone) $notetoshow.=', Tel: '.$tmpuser->office_phone; - } + } if ($notetoshow) { $tab_top = 88 + $height_incoterms; @@ -552,14 +552,14 @@ class pdf_azur extends ModelePDFPropales // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva; else $tvaligne=$object->lines[$i]->total_tva; - + $localtax1ligne=$object->lines[$i]->total_localtax1; $localtax2ligne=$object->lines[$i]->total_localtax2; $localtax1_rate=$object->lines[$i]->localtax1_tx; $localtax2_rate=$object->lines[$i]->localtax2_tx; $localtax1_type=$object->lines[$i]->localtax1_type; - $localtax2_type=$object->lines[$i]->localtax2_type; - + $localtax2_type=$object->lines[$i]->localtax2_type; + if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100; if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; @@ -667,7 +667,7 @@ class pdf_azur extends ModelePDFPropales { $posy=$this->_signature_area($pdf, $object, $posy, $outputlangs); } - + // Pied de page $this->_pagefoot($pdf,$object,$outputlangs); if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); @@ -1010,6 +1010,8 @@ class pdf_azur extends ModelePDFPropales // Show VAT by rates and total $pdf->SetFillColor(248,248,248); + $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; + $this->atleastoneratenotnull=0; if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { @@ -1186,7 +1188,6 @@ class pdf_azur extends ModelePDFPropales $pdf->SetFillColor(224,224,224); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); - $total_ttc = ($conf->multicurrency->enabled && $object->multiccurency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc; $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1); } @@ -1479,7 +1480,7 @@ class pdf_azur extends ModelePDFPropales $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R'); } } - + $posy+=2; // Show list of linked objects diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php index 1e7e6f4bcad..2578509cf71 100644 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -717,6 +717,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $useborder=0; + // Total TTC $index++; $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $pdf->SetTextColor(0,0,60); @@ -727,6 +728,14 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc), $useborder, 'R', 1); + $creditnoteamount=0; + $depositsamount=0; + //$creditnoteamount=$object->getSumCreditNotesUsed(); + //$depositsamount=$object->getSumDepositsUsed(); + //print "x".$creditnoteamount."-".$depositsamount;exit; + $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); + if (! empty($object->paye)) $resteapayer=0; + if ($deja_regle > 0) { $index++; @@ -743,7 +752,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle), $useborder, 'R', 1); + $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1); $pdf->SetFont('','', $default_font_size - 1); $pdf->SetTextColor(0,0,0); } @@ -877,6 +886,11 @@ class pdf_canelle extends ModelePDFSuppliersInvoices */ function _tableau_versements(&$pdf, $object, $posy, $outputlangs) { + global $conf; + + $sign=1; + if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; + $tab3_posx = 120; $tab3_top = $posy + 8; $tab3_width = 80; @@ -910,8 +924,11 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->SetFont('','', $default_font_size - 4); + // Loop on each deposits and credit notes included + // + // Loop on each payment - $sql = "SELECT p.datep as date, p.fk_paiement as type, p.num_paiement as num, pf.amount as amount,"; + $sql = "SELECT p.datep as date, p.fk_paiement as type, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,"; $sql.= " cp.code"; $sql.= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf, ".MAIN_DB_PREFIX."paiementfourn as p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON p.fk_paiement = cp.id"; @@ -929,7 +946,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $pdf->SetXY($tab3_posx, $tab3_top+$y); $pdf->MultiCell(20, 3, dol_print_date($this->db->jdate($row->date),'day',false,$outputlangs,true), 0, 'L', 0); $pdf->SetXY($tab3_posx+21, $tab3_top+$y); - $pdf->MultiCell(20, 3, price($row->amount), 0, 'L', 0); + $pdf->MultiCell(20, 3, price($sign * (($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount)), 0, 'L', 0); $pdf->SetXY($tab3_posx+40, $tab3_top+$y); $oper = $outputlangs->transnoentitiesnoconv("PaymentTypeShort" . $row->code); diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php index c882ed89800..2be42687f80 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -840,7 +840,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders //$creditnoteamount=$object->getSumCreditNotesUsed(); //$depositsamount=$object->getSumDepositsUsed(); //print "x".$creditnoteamount."-".$depositsamount;exit; - $resteapayer = price2num($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); + $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); if (! empty($object->paye)) $resteapayer=0; if ($deja_regle > 0) From a5a08006e92c04701d10efa8bf9d1de328f78c3c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Sep 2017 19:27:21 +0200 Subject: [PATCH 32/48] FIX multicompany better accuracy in rounding and with revenue stamp. --- htdocs/core/class/commonobject.class.php | 27 ++++++----- htdocs/core/lib/price.lib.php | 60 ++++++++++++++++-------- 2 files changed, 56 insertions(+), 31 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index b32aa8cca05..7fbd6125015 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2263,6 +2263,8 @@ abstract class CommonObject $error=0; + $multicurrency_tx = !empty($this->multicurrency_tx) ? $this->multicurrency_tx : 1; + // Define constants to find lines to sum $fieldtva='total_tva'; $fieldlocaltax1='total_localtax1'; @@ -2315,7 +2317,6 @@ abstract class CommonObject $obj = $this->db->fetch_object($resql); // Note: There is no check on detail line and no check on total, if $forcedroundingmode = 'none' - $multicurrency_tx = !empty($this->multicurrency_tx) ? $this->multicurrency_tx : 1; if ($forcedroundingmode == '0') // Check if data on line are consistent. This may solve lines that were not consistent because set with $forcedroundingmode='auto' { $localtax_array=array($obj->localtax1_type,$obj->localtax1_tx,$obj->localtax2_type,$obj->localtax2_tx); @@ -2333,11 +2334,14 @@ abstract class CommonObject } } - $this->total_ht += $obj->total_ht; // The only field visible at end of line detail + $this->total_ht += $obj->total_ht; // The field visible at end of line detail $this->total_tva += $obj->total_tva; $this->total_localtax1 += $obj->total_localtax1; $this->total_localtax2 += $obj->total_localtax2; $this->total_ttc += $obj->total_ttc; + $this->multicurrency_total_ht += $obj->multicurrency_total_ht; // The field visible at end of line detail + $this->multicurrency_total_tva += $obj->multicurrency_total_tva; + $this->multicurrency_total_ttc += $obj->multicurrency_total_ttc; if (! isset($total_ht_by_vats[$obj->vatrate])) $total_ht_by_vats[$obj->vatrate]=0; if (! isset($total_tva_by_vats[$obj->vatrate])) $total_tva_by_vats[$obj->vatrate]=0; @@ -2346,7 +2350,7 @@ abstract class CommonObject $total_tva_by_vats[$obj->vatrate] += $obj->total_tva; $total_ttc_by_vats[$obj->vatrate] += $obj->total_ttc; - if ($forcedroundingmode == '1') // Check if we need adjustement onto line for vat + if ($forcedroundingmode == '1') // Check if we need adjustement onto line for vat. TODO This works on the company currency but not on multicurrency { $tmpvat=price2num($total_ht_by_vats[$obj->vatrate] * $obj->vatrate / 100, 'MT', 1); $diff=price2num($total_tva_by_vats[$obj->vatrate]-$tmpvat, 'MT', 1); @@ -2370,26 +2374,25 @@ abstract class CommonObject } // Add revenue stamp to total - $this->total_ttc += isset($this->revenuestamp)?$this->revenuestamp:0; + $this->total_ttc += isset($this->revenuestamp)?$this->revenuestamp:0; + $this->multicurrency_total_ttc += isset($this->revenuestamp)?($this->revenuestamp * $multicurrency_tx):0; // Situations totals - if ($this->situation_cycle_ref && $this->situation_counter > 1) { + if ($this->situation_cycle_ref && $this->situation_counter > 1 && method_exists($this, 'get_prev_sits')) { $prev_sits = $this->get_prev_sits(); - foreach ($prev_sits as $sit) { + foreach ($prev_sits as $sit) { // $sit is an object Facture loaded with a fetch. $this->total_ht -= $sit->total_ht; $this->total_tva -= $sit->total_tva; $this->total_localtax1 -= $sit->total_localtax1; $this->total_localtax2 -= $sit->total_localtax2; $this->total_ttc -= $sit->total_ttc; + $this->multicurrency_total_ht -= $sit->multicurrency_total_ht; + $this->multicurrency_total_tva -= $sit->multicurrency_total_tva; + $this->multicurrency_total_ttc -= $sit->multicurrency_total_ttc; } } - // Multicurrency - $this->multicurrency_total_ht += $this->total_ht * $multicurrency_tx; - $this->multicurrency_total_tva += $this->total_tva * $multicurrency_tx; - $this->multicurrency_total_ttc += $this->total_ttc * $multicurrency_tx; - $this->db->free($resql); // Now update global field total_ht, total_ttc and tva @@ -2403,7 +2406,7 @@ abstract class CommonObject if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') $fieldtva='total_tva'; if ($this->element == 'propal') $fieldttc='total'; if ($this->element == 'expensereport') $fieldtva='total_tva'; - if ($this->element == 'supplier_proposal') $fieldttc='total'; + if ($this->element == 'supplier_proposal') $fieldttc='total'; if (empty($nodatabaseupdate)) { diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php index 2fe652f6ac9..dca5ef8e50f 100644 --- a/htdocs/core/lib/price.lib.php +++ b/htdocs/core/lib/price.lib.php @@ -50,8 +50,8 @@ * @param array $localtaxes_array Array with localtaxes info array('0'=>type1,'1'=>rate1,'2'=>type2,'3'=>rate2) (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function). * @param integer $progress Situation invoices progress (value from 0 to 100, 100 by default) * @param double $multicurrency_tx Currency rate (1 by default) - * @param double $pu_ht_devise Amount in currency - * @return array [ + * @param double $pu_devise Amount in currency + * @return array [ * 0=total_ht, * 1=total_vat, (main vat only) * 2=total_ttc, (total_ht + main vat + local taxes) @@ -65,15 +65,16 @@ * 10=total_tax2 for total_ht, * 11=pu_tax1 for pu_ht, !! should not be used * 12=pu_tax2 for pu_ht, !! should not be used - * 13=!! should not be used + * 13=?? !! should not be used * 14=total_tax1 for total_ht_without_discount, - * 15=total_tax2 for total_ht_without_discount] + * 15=total_tax2 for total_ht_without_discount, + * * 16=multicurrency_total_ht * 17=multicurrency_total_tva * 18=multicurrency_total_ttc * 19=multicurrency_pu_ht */ -function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller = '', $localtaxes_array='', $progress=100, $multicurrency_tx=1, $pu_ht_devise=0) +function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller = '', $localtaxes_array='', $progress=100, $multicurrency_tx=1, $pu_devise=0) { global $conf,$mysoc,$db; @@ -101,10 +102,10 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt //dol_syslog("Price.lib::calcul_price_total qty=".$qty." pu=".$pu." remiserpercent_ligne=".$remise_percent_ligne." txtva=".$txtva." uselocaltax1_rate=".$uselocaltax1_rate." uselocaltax2_rate=".$uselocaltax2_rate.' remise_percent_global='.$remise_percent_global.' price_base_type='.$ice_base_type.' type='.$type.' progress='.$progress); $countryid=$seller->country_id; - + if (is_numeric($uselocaltax1_rate)) $uselocaltax1_rate=(float) $uselocaltax1_rate; if (is_numeric($uselocaltax2_rate)) $uselocaltax2_rate=(float) $uselocaltax2_rate; - + if ($uselocaltax1_rate < 0) $uselocaltax1_rate=$seller->localtax1_assuj; if ($uselocaltax2_rate < 0) $uselocaltax2_rate=$seller->localtax2_assuj; @@ -143,14 +144,15 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt } else dol_print_error($db); } - + // pu calculation from pu_devise if pu empty - if(empty($pu) && !empty($pu_ht_devise)) { - $pu = $pu_ht_devise / $multicurrency_tx; - } else { - $pu_ht_devise = $pu * $multicurrency_tx; + if(empty($pu) && !empty($pu_devise)) { + $pu = $pu_devise / $multicurrency_tx; } - + if(empty($pu_devise) && !empty($multicurrency_tx)) { + $pu_devise = $pu * $multicurrency_tx; + } + // initialize total (may be HT or TTC depending on price_base_type) $tot_sans_remise = $pu * $qty * $progress / 100; $tot_avec_remise_ligne = $tot_sans_remise * (1 - ($remise_percent_ligne / 100)); @@ -338,13 +340,33 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt $result[10]=round($result[10]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT; } } - + // Multicurrency - $result[16] = price2num($result[0] * $multicurrency_tx, 'MT'); - $result[17] = price2num($result[1] * $multicurrency_tx, 'MT'); - $result[18] = price2num($result[2] * $multicurrency_tx, 'MT'); - $result[19] = price2num($pu_ht_devise, 'MU'); - + if ($conf->multicurrency->enabled && $multicurrency_tx != 1) + { + // Recal function using the multicurrency price as reference price. We must set param $multicurrency_tx to 1 to avoid infinite loop. + $newresult = calcul_price_total($qty, $pu_devise, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller, $localtaxes_array, $progress, 1, 0); + + $result[16] = $newresult[0]; + $result[17] = $newresult[1]; + $result[18] = $newresult[2]; + $result[19] = $newresult[3]; + $result[20] = $newresult[4]; + $result[21] = $newresult[5]; + $result[22] = $newresult[6]; + $result[23] = $newresult[7]; + $result[24] = $newresult[8]; + $result[25] = $newresult[9]; + $result[26] = $newresult[10]; + /* + $result[16] = price2num($result[0] * $multicurrency_tx, 'MT'); + $result[17] = price2num($result[1] * $multicurrency_tx, 'MT'); + $result[18] = price2num($result[2] * $multicurrency_tx, 'MT'); + $result[19] = price2num($pu_devise, 'MU'); + */ + } + + //var_dump($result); // initialize result array //for ($i=0; $i <= 18; $i++) $result[$i] = (float) $result[$i]; From 9b22f046f5e30205f28445d49ad68269116fe2f2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Sep 2017 19:27:21 +0200 Subject: [PATCH 33/48] FIX multicompany better accuracy in rounding and with revenue stamp. --- htdocs/core/class/commonobject.class.php | 27 ++++++----- htdocs/core/lib/price.lib.php | 60 ++++++++++++++++-------- 2 files changed, 56 insertions(+), 31 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 16450fd9feb..ab7afea77a4 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2239,6 +2239,8 @@ abstract class CommonObject $error=0; + $multicurrency_tx = !empty($this->multicurrency_tx) ? $this->multicurrency_tx : 1; + // Define constants to find lines to sum $fieldtva='total_tva'; $fieldlocaltax1='total_localtax1'; @@ -2291,7 +2293,6 @@ abstract class CommonObject $obj = $this->db->fetch_object($resql); // Note: There is no check on detail line and no check on total, if $forcedroundingmode = 'none' - $multicurrency_tx = !empty($this->multicurrency_tx) ? $this->multicurrency_tx : 1; if ($forcedroundingmode == '0') // Check if data on line are consistent. This may solve lines that were not consistent because set with $forcedroundingmode='auto' { $localtax_array=array($obj->localtax1_type,$obj->localtax1_tx,$obj->localtax2_type,$obj->localtax2_tx); @@ -2309,11 +2310,14 @@ abstract class CommonObject } } - $this->total_ht += $obj->total_ht; // The only field visible at end of line detail + $this->total_ht += $obj->total_ht; // The field visible at end of line detail $this->total_tva += $obj->total_tva; $this->total_localtax1 += $obj->total_localtax1; $this->total_localtax2 += $obj->total_localtax2; $this->total_ttc += $obj->total_ttc; + $this->multicurrency_total_ht += $obj->multicurrency_total_ht; // The field visible at end of line detail + $this->multicurrency_total_tva += $obj->multicurrency_total_tva; + $this->multicurrency_total_ttc += $obj->multicurrency_total_ttc; if (! isset($total_ht_by_vats[$obj->vatrate])) $total_ht_by_vats[$obj->vatrate]=0; if (! isset($total_tva_by_vats[$obj->vatrate])) $total_tva_by_vats[$obj->vatrate]=0; @@ -2322,7 +2326,7 @@ abstract class CommonObject $total_tva_by_vats[$obj->vatrate] += $obj->total_tva; $total_ttc_by_vats[$obj->vatrate] += $obj->total_ttc; - if ($forcedroundingmode == '1') // Check if we need adjustement onto line for vat + if ($forcedroundingmode == '1') // Check if we need adjustement onto line for vat. TODO This works on the company currency but not on multicurrency { $tmpvat=price2num($total_ht_by_vats[$obj->vatrate] * $obj->vatrate / 100, 'MT', 1); $diff=price2num($total_tva_by_vats[$obj->vatrate]-$tmpvat, 'MT', 1); @@ -2346,26 +2350,25 @@ abstract class CommonObject } // Add revenue stamp to total - $this->total_ttc += isset($this->revenuestamp)?$this->revenuestamp:0; + $this->total_ttc += isset($this->revenuestamp)?$this->revenuestamp:0; + $this->multicurrency_total_ttc += isset($this->revenuestamp)?($this->revenuestamp * $multicurrency_tx):0; // Situations totals - if ($this->situation_cycle_ref && $this->situation_counter > 1) { + if ($this->situation_cycle_ref && $this->situation_counter > 1 && method_exists($this, 'get_prev_sits')) { $prev_sits = $this->get_prev_sits(); - foreach ($prev_sits as $sit) { + foreach ($prev_sits as $sit) { // $sit is an object Facture loaded with a fetch. $this->total_ht -= $sit->total_ht; $this->total_tva -= $sit->total_tva; $this->total_localtax1 -= $sit->total_localtax1; $this->total_localtax2 -= $sit->total_localtax2; $this->total_ttc -= $sit->total_ttc; + $this->multicurrency_total_ht -= $sit->multicurrency_total_ht; + $this->multicurrency_total_tva -= $sit->multicurrency_total_tva; + $this->multicurrency_total_ttc -= $sit->multicurrency_total_ttc; } } - // Multicurrency - $this->multicurrency_total_ht += $this->total_ht * $multicurrency_tx; - $this->multicurrency_total_tva += $this->total_tva * $multicurrency_tx; - $this->multicurrency_total_ttc += $this->total_ttc * $multicurrency_tx; - $this->db->free($resql); // Now update global field total_ht, total_ttc and tva @@ -2379,7 +2382,7 @@ abstract class CommonObject if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') $fieldtva='total_tva'; if ($this->element == 'propal') $fieldttc='total'; if ($this->element == 'expensereport') $fieldtva='total_tva'; - if ($this->element == 'supplier_proposal') $fieldttc='total'; + if ($this->element == 'supplier_proposal') $fieldttc='total'; if (empty($nodatabaseupdate)) { diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php index 2fe652f6ac9..dca5ef8e50f 100644 --- a/htdocs/core/lib/price.lib.php +++ b/htdocs/core/lib/price.lib.php @@ -50,8 +50,8 @@ * @param array $localtaxes_array Array with localtaxes info array('0'=>type1,'1'=>rate1,'2'=>type2,'3'=>rate2) (loaded by getLocalTaxesFromRate(vatrate, 0, ...) function). * @param integer $progress Situation invoices progress (value from 0 to 100, 100 by default) * @param double $multicurrency_tx Currency rate (1 by default) - * @param double $pu_ht_devise Amount in currency - * @return array [ + * @param double $pu_devise Amount in currency + * @return array [ * 0=total_ht, * 1=total_vat, (main vat only) * 2=total_ttc, (total_ht + main vat + local taxes) @@ -65,15 +65,16 @@ * 10=total_tax2 for total_ht, * 11=pu_tax1 for pu_ht, !! should not be used * 12=pu_tax2 for pu_ht, !! should not be used - * 13=!! should not be used + * 13=?? !! should not be used * 14=total_tax1 for total_ht_without_discount, - * 15=total_tax2 for total_ht_without_discount] + * 15=total_tax2 for total_ht_without_discount, + * * 16=multicurrency_total_ht * 17=multicurrency_total_tva * 18=multicurrency_total_ttc * 19=multicurrency_pu_ht */ -function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller = '', $localtaxes_array='', $progress=100, $multicurrency_tx=1, $pu_ht_devise=0) +function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller = '', $localtaxes_array='', $progress=100, $multicurrency_tx=1, $pu_devise=0) { global $conf,$mysoc,$db; @@ -101,10 +102,10 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt //dol_syslog("Price.lib::calcul_price_total qty=".$qty." pu=".$pu." remiserpercent_ligne=".$remise_percent_ligne." txtva=".$txtva." uselocaltax1_rate=".$uselocaltax1_rate." uselocaltax2_rate=".$uselocaltax2_rate.' remise_percent_global='.$remise_percent_global.' price_base_type='.$ice_base_type.' type='.$type.' progress='.$progress); $countryid=$seller->country_id; - + if (is_numeric($uselocaltax1_rate)) $uselocaltax1_rate=(float) $uselocaltax1_rate; if (is_numeric($uselocaltax2_rate)) $uselocaltax2_rate=(float) $uselocaltax2_rate; - + if ($uselocaltax1_rate < 0) $uselocaltax1_rate=$seller->localtax1_assuj; if ($uselocaltax2_rate < 0) $uselocaltax2_rate=$seller->localtax2_assuj; @@ -143,14 +144,15 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt } else dol_print_error($db); } - + // pu calculation from pu_devise if pu empty - if(empty($pu) && !empty($pu_ht_devise)) { - $pu = $pu_ht_devise / $multicurrency_tx; - } else { - $pu_ht_devise = $pu * $multicurrency_tx; + if(empty($pu) && !empty($pu_devise)) { + $pu = $pu_devise / $multicurrency_tx; } - + if(empty($pu_devise) && !empty($multicurrency_tx)) { + $pu_devise = $pu * $multicurrency_tx; + } + // initialize total (may be HT or TTC depending on price_base_type) $tot_sans_remise = $pu * $qty * $progress / 100; $tot_avec_remise_ligne = $tot_sans_remise * (1 - ($remise_percent_ligne / 100)); @@ -338,13 +340,33 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt $result[10]=round($result[10]/$conf->global->MAIN_ROUNDING_RULE_TOT, 0)*$conf->global->MAIN_ROUNDING_RULE_TOT; } } - + // Multicurrency - $result[16] = price2num($result[0] * $multicurrency_tx, 'MT'); - $result[17] = price2num($result[1] * $multicurrency_tx, 'MT'); - $result[18] = price2num($result[2] * $multicurrency_tx, 'MT'); - $result[19] = price2num($pu_ht_devise, 'MU'); - + if ($conf->multicurrency->enabled && $multicurrency_tx != 1) + { + // Recal function using the multicurrency price as reference price. We must set param $multicurrency_tx to 1 to avoid infinite loop. + $newresult = calcul_price_total($qty, $pu_devise, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller, $localtaxes_array, $progress, 1, 0); + + $result[16] = $newresult[0]; + $result[17] = $newresult[1]; + $result[18] = $newresult[2]; + $result[19] = $newresult[3]; + $result[20] = $newresult[4]; + $result[21] = $newresult[5]; + $result[22] = $newresult[6]; + $result[23] = $newresult[7]; + $result[24] = $newresult[8]; + $result[25] = $newresult[9]; + $result[26] = $newresult[10]; + /* + $result[16] = price2num($result[0] * $multicurrency_tx, 'MT'); + $result[17] = price2num($result[1] * $multicurrency_tx, 'MT'); + $result[18] = price2num($result[2] * $multicurrency_tx, 'MT'); + $result[19] = price2num($pu_devise, 'MU'); + */ + } + + //var_dump($result); // initialize result array //for ($i=0; $i <= 18; $i++) $result[$i] = (float) $result[$i]; From 38621b622e797bcebc034ac14c8281dca20537a6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Sep 2017 20:11:51 +0200 Subject: [PATCH 34/48] Fix specimen not complete for multicompany --- htdocs/compta/facture/class/facture.class.php | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 3fa36602d39..9cc9a63f313 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3828,6 +3828,9 @@ class Facture extends CommonInvoice $line->total_ht=-100; $line->total_ttc=-119.6; $line->total_tva=-19.6; + $line->multicurrency_total_ht=-200; + $line->multicurrency_total_ttc=-239.2; + $line->multicurrency_total_tva=-39.2; } else if ($xnbp == 2) // UP is negative (free line) { @@ -3836,6 +3839,9 @@ class Facture extends CommonInvoice $line->total_ttc=-119.6; $line->total_tva=-19.6; $line->remise_percent=0; + $line->multicurrency_total_ht=-200; + $line->multicurrency_total_ttc=-239.2; + $line->multicurrency_total_tva=-39.2; } else if ($xnbp == 3) // Discount is 50% (product line) { @@ -3844,6 +3850,9 @@ class Facture extends CommonInvoice $line->total_ht=50; $line->total_ttc=59.8; $line->total_tva=9.8; + $line->multicurrency_total_ht=100; + $line->multicurrency_total_ttc=119.6; + $line->multicurrency_total_tva=19.6; $line->remise_percent=50; } else // (product line) @@ -3853,15 +3862,22 @@ class Facture extends CommonInvoice $line->total_ht=100; $line->total_ttc=119.6; $line->total_tva=19.6; - $line->remise_percent=00; + $line->multicurrency_total_ht=200; + $line->multicurrency_total_ttc=239.2; + $line->multicurrency_total_tva=39.2; + $line->remise_percent=0; } $this->lines[$xnbp]=$line; $xnbp++; + $this->total_ht += $line->total_ht; $this->total_tva += $line->total_tva; $this->total_ttc += $line->total_ttc; + $this->multicurrency_total_ht += $line->multicurrency_total_ht; + $this->multicurrency_total_tva += $line->multicurrency_total_tva; + $this->multicurrency_total_ttc += $line->multicurrency_total_ttc; } $this->revenuestamp = 0; @@ -3877,6 +3893,9 @@ class Facture extends CommonInvoice $line->total_ht=0; $line->total_ttc=0; // 90 * 1.196 $line->total_tva=0; + $line->multicurrency_total_ht=0; + $line->multicurrency_total_ttc=0; + $line->multicurrency_total_tva=0; $prodid = mt_rand(1, $num_prods); $line->fk_product=$prodids[$prodid]; From dc38ec50515bc9a4d41f1d7cb5d923c75a10422a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Sep 2017 20:48:24 +0200 Subject: [PATCH 35/48] Fix regression --- htdocs/core/lib/price.lib.php | 7 +++++++ test/phpunit/PricesTest.php | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php index dca5ef8e50f..b8eeeae432c 100644 --- a/htdocs/core/lib/price.lib.php +++ b/htdocs/core/lib/price.lib.php @@ -365,6 +365,13 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt $result[19] = price2num($pu_devise, 'MU'); */ } + else + { + $result[16] = price2num($result[0], 'MT'); + $result[17] = price2num($result[1], 'MT'); + $result[18] = price2num($result[2], 'MT'); + $result[19] = price2num($result[3], 'MU'); + } //var_dump($result); // initialize result array diff --git a/test/phpunit/PricesTest.php b/test/phpunit/PricesTest.php index 3e09450b9cb..46d36db3b27 100755 --- a/test/phpunit/PricesTest.php +++ b/test/phpunit/PricesTest.php @@ -159,16 +159,16 @@ class PricesTest extends PHPUnit_Framework_TestCase $result1=calcul_price_total(2, 8.56, 0, 10, 0, 0, 0, 'HT', 0, 0, '', '', 100, 1.09205); print __METHOD__." result1=".join(', ',$result1)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(17.12, 1.71, 18.83, 8.56, 0.856, 9.416, 17.12, 1.71, 18.83, 0, 0, 0, 0, 0, 0, 0, 18.7, 1.87, 20.56, 9.34795),$result1,'Test1 FR'); - + $this->assertEquals(array(17.12, 1.71, 18.83, 8.56, 0.856, 9.416, 17.12, 1.71, 18.83, 0, 0, 0, 0, 0, 0, 0, 18.7, 1.87, 20.57, 9.34795, 0.93479, 10.28274, 18.7, 1.87, 20.57, 0, 0),$result1,'Test1 FR'); + // qty=2, unit_price=0, discount_line=0, vat_rate=10, price_base_type='HT', multicurrency_tx=1.09205 (method we provide value), pu_ht_devise=100 $mysoc->country_code='FR'; $mysoc->country_id=1; $result1=calcul_price_total(2, 0, 0, 10, 0, 0, 0, 'HT', 0, 0, '', '', 100, 1.09205, 20); print __METHOD__." result1=".join(', ',$result1)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(36.63, 3.66, 40.29, 18.31418, 1.83142, 20.1456, 36.63, 3.66, 40.29, 0, 0, 0, 0, 0, 0, 0, 40, 4, 44, 20),$result1,'Test1 FR'); - + $this->assertEquals(array(36.63, 3.66, 40.29, 18.31418, 1.83142, 20.1456, 36.63, 3.66, 40.29, 0, 0, 0, 0, 0, 0, 0, 40, 4, 44, 20, 2, 22, 40, 4, 44, 0, 0),$result1,'Test1 FR'); + /* * Country Spain */ From 6d40f797d261e21e7c04d73bc872473fbeb80814 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Sep 2017 21:50:14 +0200 Subject: [PATCH 36/48] Fix regression --- htdocs/core/lib/price.lib.php | 17 ++++++++++++----- test/phpunit/PricesTest.php | 36 +++++++++++++++++++++-------------- 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php index b8eeeae432c..0cb1f755450 100644 --- a/htdocs/core/lib/price.lib.php +++ b/htdocs/core/lib/price.lib.php @@ -342,7 +342,7 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt } // Multicurrency - if ($conf->multicurrency->enabled && $multicurrency_tx != 1) + if ($multicurrency_tx != 1) { // Recal function using the multicurrency price as reference price. We must set param $multicurrency_tx to 1 to avoid infinite loop. $newresult = calcul_price_total($qty, $pu_devise, $remise_percent_ligne, $txtva, $uselocaltax1_rate, $uselocaltax2_rate, $remise_percent_global, $price_base_type, $info_bits, $type, $seller, $localtaxes_array, $progress, 1, 0); @@ -367,10 +367,17 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt } else { - $result[16] = price2num($result[0], 'MT'); - $result[17] = price2num($result[1], 'MT'); - $result[18] = price2num($result[2], 'MT'); - $result[19] = price2num($result[3], 'MU'); + $result[16] = $result[0]; + $result[17] = $result[1]; + $result[18] = $result[2]; + $result[19] = $result[3]; + $result[20] = $result[4]; + $result[21] = $result[5]; + $result[22] = $result[6]; + $result[23] = $result[7]; + $result[24] = $result[8]; + $result[25] = $result[9]; + $result[26] = $result[10]; } //var_dump($result); diff --git a/test/phpunit/PricesTest.php b/test/phpunit/PricesTest.php index 46d36db3b27..50c0d20ad10 100755 --- a/test/phpunit/PricesTest.php +++ b/test/phpunit/PricesTest.php @@ -1,4 +1,7 @@ * Copyright (C) 2015 Juanjo Menent * @@ -141,6 +144,11 @@ class PricesTest extends PHPUnit_Framework_TestCase global $mysoc; $mysoc=new Societe($db); + // To force status that say module multicompany is on + //$conf->multicurrency=new stdClass(); + //$conf->multicurrency->enabled = 0; + + /* * Country France */ @@ -151,7 +159,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $result1=calcul_price_total(1, 1.24, 0, 10, 0, 0, 0, 'HT', 0, 0); print __METHOD__." result1=".join(', ',$result1)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(1.24, 0.12, 1.36, 1.24, 0.124, 1.364, 1.24, 0.12, 1.36, 0, 0, 0, 0, 0, 0, 0, 1.24, 0.12, 1.36, 1.24),$result1,'Test1 FR'); + $this->assertEquals(array(1.24, 0.12, 1.36, 1.24, 0.124, 1.364, 1.24, 0.12, 1.36, 0, 0, 0, 0, 0, 0, 0, 1.24, 0.12, 1.36, 1.24, 0.124, 1.364, 1.24, 0.12, 1.36, 0, 0),$result1,'Test1 FR'); // qty=1, unit_price=1.24, discount_line=0, vat_rate=10, price_base_type='HT', multicurrency_tx=1.09205 (method we provide value) $mysoc->country_code='FR'; @@ -159,7 +167,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $result1=calcul_price_total(2, 8.56, 0, 10, 0, 0, 0, 'HT', 0, 0, '', '', 100, 1.09205); print __METHOD__." result1=".join(', ',$result1)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(17.12, 1.71, 18.83, 8.56, 0.856, 9.416, 17.12, 1.71, 18.83, 0, 0, 0, 0, 0, 0, 0, 18.7, 1.87, 20.57, 9.34795, 0.93479, 10.28274, 18.7, 1.87, 20.57, 0, 0),$result1,'Test1 FR'); + $this->assertEquals(array(17.12, 1.71, 18.83, 8.56, 0.856, 9.416, 17.12, 1.71, 18.83, 0, 0, 0, 0, 0, 0, 0, 18.7, 1.87, 20.57, 9.34795, 0.93479, 10.28274, 18.7, 1.87, 20.57, 0, 0),$result1,'Test1b FR'); // qty=2, unit_price=0, discount_line=0, vat_rate=10, price_base_type='HT', multicurrency_tx=1.09205 (method we provide value), pu_ht_devise=100 $mysoc->country_code='FR'; @@ -167,7 +175,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $result1=calcul_price_total(2, 0, 0, 10, 0, 0, 0, 'HT', 0, 0, '', '', 100, 1.09205, 20); print __METHOD__." result1=".join(', ',$result1)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(36.63, 3.66, 40.29, 18.31418, 1.83142, 20.1456, 36.63, 3.66, 40.29, 0, 0, 0, 0, 0, 0, 0, 40, 4, 44, 20, 2, 22, 40, 4, 44, 0, 0),$result1,'Test1 FR'); + $this->assertEquals(array(36.63, 3.66, 40.29, 18.31418, 1.83142, 20.1456, 36.63, 3.66, 40.29, 0, 0, 0, 0, 0, 0, 0, 40, 4, 44, 20, 2, 22, 40, 4, 44, 0, 0),$result1,'Test1c FR'); /* * Country Spain @@ -181,7 +189,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $result2=calcul_price_total(10, 10, 0, 10, 0, 0, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1, 0% localtax2 print __METHOD__." result2=".join(', ',$result2)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0, 100, 10, 110, 10),$result2,'Test1 ES'); + $this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0, 100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0),$result2,'Test1 ES'); // 10 * 10 HT - 0% discount with 10% vat, seller not using localtax1, not localtax2 (other method autodetect) $mysoc->country_code='ES'; @@ -191,7 +199,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1, 0% localtax2 print __METHOD__." result2=".join(', ',$result2)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0, 100, 10, 110, 10),$result2,'Test2 ES'); + $this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0, 100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0),$result2,'Test2 ES'); // -------------------------------------------------------- @@ -203,7 +211,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $result2=calcul_price_total(10, 10, 0, 10, 1.4, 0, 0, 'HT', 0, 0); print __METHOD__." result2=".join(', ',$result2)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0, 0.14, 0, 0, 1.4, 0, 100, 10, 111.4, 10),$result2,'Test3 ES'); + $this->assertEquals(array(100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0, 0.14, 0, 0, 1.4, 0, 100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0),$result2,'Test3 ES'); // 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1 type 3, 0% localtax2 type 5 (other method autodetect) $mysoc->country_code='ES'; @@ -213,7 +221,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 0); print __METHOD__." result2=".join(', ',$result2)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0, 0.14, 0, 0, 1.4, 0, 100, 10, 111.4, 10),$result2,'Test4 ES'); + $this->assertEquals(array(100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0, 0.14, 0, 0, 1.4, 0, 100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0),$result2,'Test4 ES'); // -------------------------------------------------------- @@ -224,7 +232,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $mysoc->localtax2_assuj=1; $result2=calcul_price_total(10, 10, 0, 10, 0, -19, 0, 'HT', 0, 1); // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19, 0, -1.90, 0, 0, -19, 100, 10, 91, 10),$result2,'Test5 ES for service'); + $this->assertEquals(array(100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19, 0, -1.90, 0, 0, -19, 100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19),$result2,'Test5 ES for service'); // 10 * 10 HT - 0% discount with 10% vat and 0% localtax1 type 3, 21% localtax2 type 5 (other method autodetect), we provide a service and not a product $mysoc->country_code='ES'; @@ -234,7 +242,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 0); print __METHOD__." result2=".join(', ',$result2)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0, 100, 10, 110, 10),$result2,'Test6 ES for product'); + $this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0, 100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0),$result2,'Test6 ES for product'); // 10 * 10 HT - 0% discount with 10% vat and 0% localtax1 type 3, 21% localtax2 type 5 (other method autodetect), we provide a product and not a service $mysoc->country_code='ES'; @@ -244,7 +252,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 1); print __METHOD__." result2=".join(', ',$result2)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19, 0, -1.90, 0, 0, -19, 100, 10, 91, 10),$result2,'Test6 ES for service'); + $this->assertEquals(array(100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19, 0, -1.90, 0, 0, -19, 100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19),$result2,'Test6 ES for service'); // -------------------------------------------------------- @@ -256,7 +264,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $result2=calcul_price_total(10, -10, 0, 10, 0, 19, 0, 'HT', 0, 0); print __METHOD__." result2=".join(', ',$result2)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(-100, -10, -110, -10, -1, -11, -100, -10, -110, 0, 0, 0, 0, 0, 0, 0, -100, -10, -110, -10),$result2,'Test7 ES for product'); + $this->assertEquals(array(-100, -10, -110, -10, -1, -11, -100, -10, -110, 0, 0, 0, 0, 0, 0, 0, -100, -10, -110, -10, -1, -11, -100, -10, -110, 0, 0),$result2,'Test7 ES for product'); // Credit Note: 10 * -10 HT - 0% discount with 10% vat and 1.4% localtax1 type 3, 0% localtax2 type 5 (other method autodetect), we provide a service and not a product $mysoc->country_code='ES'; @@ -265,7 +273,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $mysoc->localtax2_assuj=1; $result2=calcul_price_total(10, -10, 0, 10, -1, -1, 0, 'HT', 0, 1); print __METHOD__." result2=".join(', ',$result2)."\n"; - $this->assertEquals(array(-100, -10, -91, -10, -1, -9.1, -100, -10, -91, 0, 19, 0, 1.90, 0, 0, 19, -100, -10, -91, -10),$result2,'Test8 ES for service'); + $this->assertEquals(array(-100, -10, -91, -10, -1, -9.1, -100, -10, -91, 0, 19, 0, 1.90, 0, 0, 19, -100, -10, -91, -10, -1, -9.1, -100, -10, -91, 0, 19),$result2,'Test8 ES for service'); /* @@ -282,7 +290,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $result3=calcul_price_total(10, 10, 0, 18, 7.5, 0, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 18% vat and 7.5% localtax1, 0% localtax2 print __METHOD__." result3=".join(', ',$result3)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0, 0.885, 0, 0, 8.85, 0, 100, 18, 126.85, 10),$result3,'Test9 CI'); + $this->assertEquals(array(100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0, 0.885, 0, 0, 8.85, 0, 100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0),$result3,'Test9 CI'); // 10 * 10 HT - 0% discount with 18% vat, seller using localtax1 type 2, not localtax2 (other method autodetect) $mysoc->country_code='CI'; @@ -292,7 +300,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $result3=calcul_price_total(10, 10, 0, 18, -1, -1, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 18% vat and 7.5% localtax1, 0% localtax2 print __METHOD__." result3=".join(', ',$result3)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0, 0.885, 0, 0, 8.85, 0, 100, 18, 126.85, 10),$result3,'Test10 CI'); + $this->assertEquals(array(100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0, 0.885, 0, 0, 8.85, 0, 100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0),$result3,'Test10 CI'); return true; } From 4b8862c1ecb9a1a56f7c3d09f1c61c0fbfe45298 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Sep 2017 21:54:16 +0200 Subject: [PATCH 37/48] Remove useless import --- test/phpunit/PricesTest.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/phpunit/PricesTest.php b/test/phpunit/PricesTest.php index 50c0d20ad10..d3b1efaf072 100755 --- a/test/phpunit/PricesTest.php +++ b/test/phpunit/PricesTest.php @@ -1,7 +1,4 @@ * Copyright (C) 2015 Juanjo Menent * From d7b84bd35fa7d6fa111d7acece2477fc5e825287 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Sep 2017 22:56:24 +0200 Subject: [PATCH 38/48] Fix responsive --- htdocs/societe/rib.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/rib.php b/htdocs/societe/rib.php index 92b3ef01552..615fba52659 100644 --- a/htdocs/societe/rib.php +++ b/htdocs/societe/rib.php @@ -440,7 +440,8 @@ if ($socid && $action != 'edit' && $action != "create") $var = false; if (is_array($rib_list)) { - print ''; + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print '
'; print ''; print_liste_field_titre("LabelRIB"); @@ -617,6 +618,7 @@ if ($socid && $action != 'edit' && $action != "create") } print '
'; + print ''; } else { dol_print_error($db); } From 3b56663e4dbaa0f6d52714299f745924d4cf2fa5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Sep 2017 09:40:10 +0200 Subject: [PATCH 39/48] Reduce travis load --- .travis.yml | 47 +++++++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 509578e57ef..cbbffd28f0f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,14 +7,9 @@ sudo: required language: php -php: -- '5.3' -- '5.4' -- '5.5' -- '5.6' -- '7.0' -- '7.1' -- nightly +# Start on every boot +services: +- memcached addons: mariadb: '10.0' @@ -33,10 +28,16 @@ addons: - libapache2-mod-fastcgi # We need pgloader for import mysql database into pgsql - pgloader - -# Start on every boot -services: -- memcached + +php: +- '5.3' +- '5.4' +- '5.5' +- '5.6' +- '7.0' +- '7.1' +- hhvm +- nightly env: global: @@ -57,11 +58,22 @@ env: matrix: fast_finish: true allow_failures: - - php: 7.1 + - php: hhvm - php: nightly - #- env: DB=postgresql - # TODO - #- env: DB=sqlite + # We exclude some combinations not usefull to save Travis CPU + exclude: + - php: '5.4' + env: DB=postgresql + - php: '5.5' + env: DB=postgresql + - php: '5.6' + env: DB=postgresql + - php: '7.0' + env: DB=postgresql + - php: hhvm + env: DB=postgresql + - php: nightly + env: DB=postgresql notifications: email: @@ -305,6 +317,9 @@ script: php upgrade.php 5.0.0 6.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade500600.log php upgrade2.php 5.0.0 6.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL > $TRAVIS_BUILD_DIR/upgrade500600-2.log php step5.php 5.0.0 6.0.0 > $TRAVIS_BUILD_DIR/upgrade500600-3.log + php upgrade.php 6.0.0 7.0.0 ignoredbversion > $TRAVIS_BUILD_DIR/upgrade600700.log + php upgrade2.php 6.0.0 7.0.0 MAIN_MODULE_API,MAIN_MODULE_SUPPLIERPROPOSAL > $TRAVIS_BUILD_DIR/upgrade600700-2.log + php step5.php 6.0.0 7.0.0 > $TRAVIS_BUILD_DIR/upgrade600700-3.log cd - set +e echo From aafc108260a49c4d9697e2e44a70dbafd4c46631 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Sep 2017 10:08:49 +0200 Subject: [PATCH 40/48] Remove hhvm --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index cbbffd28f0f..bac020e13c5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ # from Dolibarr GitHub repository. # For syntax, see http://about.travis-ci.org/docs/user/languages/php/ +# We use dist: precise to have php 5.3 available dist: precise sudo: required @@ -36,7 +37,7 @@ php: - '5.6' - '7.0' - '7.1' -- hhvm +#- hhvm only with dist: trusty - nightly env: From ed013c1b7e007a05d1b0983864107ed4a66cb729 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Sep 2017 10:21:04 +0200 Subject: [PATCH 41/48] Compatibilty php 7.2 --- htdocs/core/class/commonobject.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 7fbd6125015..e37c525b513 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4142,7 +4142,7 @@ abstract class CommonObject * * @param int $rowid Id of line. Use the id of object if not defined. Deprecated. Function must be called without parameters. * @param array $optionsArray Array resulting of call of extrafields->fetch_name_optionals_label(). Deprecated. Function must be called without parameters. - * @return int <0 if error, 0 if no optionals to find nor found, 1 if a line is found and optional loaded + * @return int <0 if error, 0 if no values of extrafield to find nor found, 1 if an attribute is found and value loaded */ function fetch_optionals($rowid=null,$optionsArray=null) { @@ -4176,7 +4176,7 @@ abstract class CommonObject if ($table_element == 'categorie') $table_element = 'categories'; // For compatibility // Request to get complementary values - if (count($optionsArray) > 0) + if (is_array($optionsArray) && count($optionsArray) > 0) { $sql = "SELECT rowid"; foreach ($optionsArray as $name => $label) From 9523bf5fbd6793e82734bbedc6b66f034a05ee57 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Sep 2017 10:23:17 +0200 Subject: [PATCH 42/48] Remove useless code --- test/phpunit/PricesTest.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/phpunit/PricesTest.php b/test/phpunit/PricesTest.php index 50c0d20ad10..d3b1efaf072 100755 --- a/test/phpunit/PricesTest.php +++ b/test/phpunit/PricesTest.php @@ -1,7 +1,4 @@ * Copyright (C) 2015 Juanjo Menent * From fe1ce5b3ac41d99d531732bda017455e8ced459d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Sep 2017 11:44:47 +0200 Subject: [PATCH 43/48] Fix php 7.2 compatibility --- htdocs/core/lib/json.lib.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/json.lib.php b/htdocs/core/lib/json.lib.php index 6b868663aa7..ac2372c5825 100644 --- a/htdocs/core/lib/json.lib.php +++ b/htdocs/core/lib/json.lib.php @@ -42,19 +42,21 @@ if (! function_exists('json_encode')) * * @param mixed $elements PHP Object to json encode * @return string Json encoded string - * @deprecated PHP >= 5.3 supports native json_encode * @see json_encode() */ function dol_json_encode($elements) { - dol_syslog('dol_json_encode() is deprecated. Please update your code to use native json_encode().', LOG_WARNING); + dol_syslog("For better permorfance, enable the native json in your PHP", LOG_WARNING); - $num=count($elements); + $num=0; if (is_object($elements)) // Count number of properties for an object { - $num=0; foreach($elements as $key => $value) $num++; } + else + { + $num=count($elements); + } //var_dump($num); // determine type From 7d5dc08a0a71b8cd4c131c1dbce08e25f90c4a35 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Sep 2017 14:45:11 +0200 Subject: [PATCH 44/48] Fix PHP7.2 --- htdocs/includes/tcpdi/tcpdi.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/includes/tcpdi/tcpdi.php b/htdocs/includes/tcpdi/tcpdi.php index 48fdd8198f5..999ff99ea5b 100644 --- a/htdocs/includes/tcpdi/tcpdi.php +++ b/htdocs/includes/tcpdi/tcpdi.php @@ -580,7 +580,7 @@ class TCPDI extends FPDF_TPL { * close all files opened by parsers */ function _closeParsers() { - if ($this->state > 2 && count($this->parsers) > 0) { + if ($this->state > 2 && is_array($this->parsers) && count($this->parsers) > 0) { $this->cleanUp(); return true; } From ed8e08b78ad34a1686e87c4c433546bbee916985 Mon Sep 17 00:00:00 2001 From: arnaud Date: Mon, 11 Sep 2017 16:56:50 +0200 Subject: [PATCH 45/48] FIX time.php crashed without project id in param --- htdocs/projet/tasks/time.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 595617110c7..79fc8aeafcb 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -442,7 +442,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) else $object->next_prev_filter=" fk_projet = ".$projectstatic->id; $morehtmlref=''; - + // Project if (empty($withproject)) { @@ -450,10 +450,12 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $morehtmlref.=$langs->trans("Project").': '; $morehtmlref.=$projectstatic->getNomUrl(1); $morehtmlref.='
'; - + // Third party - $morehtmlref.=$langs->trans("ThirdParty").': '; - $morehtmlref.=$projectstatic->thirdparty->getNomUrl(1); + $morehtmlref.=$langs->trans("ThirdParty").': '; + if (!empty($projectstatic->thirdparty)) { + $morehtmlref.=$projectstatic->thirdparty->getNomUrl(1); + } $morehtmlref.=''; } From 24436b550d4da62910602bbab23f44f394de5f56 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Sep 2017 12:01:32 +0200 Subject: [PATCH 46/48] Update time.php --- htdocs/projet/tasks/time.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 79fc8aeafcb..4f27ce5af5f 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -453,7 +453,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) // Third party $morehtmlref.=$langs->trans("ThirdParty").': '; - if (!empty($projectstatic->thirdparty)) { + if (is_object($projectstatic->thirdparty)) { $morehtmlref.=$projectstatic->thirdparty->getNomUrl(1); } $morehtmlref.=''; @@ -464,7 +464,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) print '
'; print '
'; - print '
'; + print '
'; print ''; // Date start - Date end From 93defa5f595062dea438feb780c595eccc1bc919 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20BERTHELOT?= Date: Mon, 11 Sep 2017 18:01:24 +0200 Subject: [PATCH 47/48] Fix dates in commande and remisecheque for PostgreSQL (should be treated like strings) --- htdocs/commande/class/commande.class.php | 2 +- htdocs/compta/paiement/cheque/class/remisecheque.class.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 235e3a1aa75..9ed198eefa3 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -2234,7 +2234,7 @@ class Commande extends CommonOrder $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."commande"; - $sql.= " SET date_commande = ".($date ? $this->db->idate($date) : 'null'); + $sql.= " SET date_commande = ".($date ? "'".$this->db->idate($date)."'" : 'null'); $sql.= " WHERE rowid = ".$this->id." AND fk_statut = ".self::STATUS_DRAFT; dol_syslog(__METHOD__, LOG_DEBUG); diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 20afa14e0ca..03dffbabf34 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -861,8 +861,8 @@ class RemiseCheque extends CommonObject if ($user->rights->banque->cheque) { $sql = "UPDATE ".MAIN_DB_PREFIX."bordereau_cheque"; - $sql.= " SET date_bordereau = ".($date ? $this->db->idate($date) : 'null'); - $sql.= " WHERE rowid = ".$this->id; + $sql.= " SET date_bordereau = '".($date ? $this->db->idate($date) : 'null'); + $sql.= "' WHERE rowid = ".$this->id; dol_syslog("RemiseCheque::set_date", LOG_DEBUG); $resql=$this->db->query($sql); From 8392158ee37121844775370a839f823ae44b94ba Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Sep 2017 12:05:34 +0200 Subject: [PATCH 48/48] Update remisecheque.class.php --- htdocs/compta/paiement/cheque/class/remisecheque.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 03dffbabf34..808d2cbb00b 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -861,8 +861,8 @@ class RemiseCheque extends CommonObject if ($user->rights->banque->cheque) { $sql = "UPDATE ".MAIN_DB_PREFIX."bordereau_cheque"; - $sql.= " SET date_bordereau = '".($date ? $this->db->idate($date) : 'null'); - $sql.= "' WHERE rowid = ".$this->id; + $sql.= " SET date_bordereau = ".($date ? "'".$this->db->idate($date)."'" : 'null'); + $sql.= " WHERE rowid = ".$this->id; dol_syslog("RemiseCheque::set_date", LOG_DEBUG); $resql=$this->db->query($sql);