From cf55b54cf561aadc3b2422b5dce9fb83f76a4fe5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 14 Jan 2019 10:02:48 +0100 Subject: [PATCH 001/115] correct list of links --- htdocs/core/class/html.formfile.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index a1e1049b045..acaf6c2e61e 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -776,16 +776,16 @@ class FormFile { $colspan=2; - foreach($link_list as $file) + foreach($link_list as $link) { $out.=''; $out.=''; $out.=''; - $out.=$file->label; + $out.=$link->label; $out.=''; $out.=''; $out.=''; - $out.=dol_print_date($file->datea,'dayhour'); + $out.=dol_print_date($link->datea,'dayhour'); $out.=''; if ($delallowed || $printer || $morepicto) $out.=''; $out.=''."\n"; From 2a7b3c7d7d327128f4b33acf4287185af501daa3 Mon Sep 17 00:00:00 2001 From: ATM-Nicolas Date: Mon, 14 Jan 2019 10:48:34 +0100 Subject: [PATCH 002/115] FIX : Check for old picture name if the new one was not found --- htdocs/theme/eldy/style.css.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 0097eb4715c..14dad44a89d 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -1783,6 +1783,12 @@ foreach($mainmenuusedarray as $val) $found=1; break; } + else if (file_exists($dirroot."/".$val."/img/".$val.".png")) // Retro compatibilité + { + $url=dol_buildpath('/'.$val.'/img/'.$val.'.png', 1); + $found=1; + break; + } } // Img file not found if (! $found) From 7c9d85d091ba0d3754bc474e5e9cf47af07e3420 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 15 Jan 2019 12:18:04 +0100 Subject: [PATCH 003/115] FIX problem with multicompany transverse mode Signed-off-by: Regis Houssin --- htdocs/core/lib/security.lib.php | 6 +++--- htdocs/user/card.php | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index d2b768d75d5..d12ee339909 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -484,9 +484,9 @@ function checkUserAccessToObject($user, $featuresarray, $objectid=0, $tableandsh { $sql.= ",".MAIN_DB_PREFIX."usergroup_user as ug"; $sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")"; - $sql.= " AND (ug.fk_user = dbt.rowid"; - $sql.= " AND ug.entity IN (".getEntity('user')."))"; - $sql.= " OR dbt.entity = 0"; // Show always superadmin + $sql.= " AND ((ug.fk_user = dbt.rowid"; + $sql.= " AND ug.entity IN (".getEntity('usergroup')."))"; + $sql.= " OR dbt.entity = 0)"; // Show always superadmin } } else { diff --git a/htdocs/user/card.php b/htdocs/user/card.php index f0b3fb819f2..bb3d7e7d8f6 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -84,9 +84,9 @@ $socid=0; if ($user->societe_id > 0) $socid = $user->societe_id; $feature2='user'; if ($user->id == $id) { $feature2=''; $canreaduser=1; } // A user can always read its own card -if (!$canreaduser) { - $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); -} + +$result = restrictedArea($user, 'user', $id, 'user&user', $feature2); + if ($user->id <> $id && ! $canreaduser) accessforbidden(); // Load translation files required by page From 41a38b3a0aa3308bbc73765ba8b816f1b161bd15 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 15 Jan 2019 15:44:45 +0100 Subject: [PATCH 004/115] FIX avoid php warning Signed-off-by: Regis Houssin --- htdocs/install/inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index 0a2a6866f26..0b924122ebb 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -196,7 +196,7 @@ if (constant('DOL_DATA_ROOT') === null) { } if (@file_exists($lockfile)) { - if (! is_object($langs)) + if (! isset($langs) || ! is_object($langs)) { $langs = new Translate('..', $conf); $langs->setDefaultLang('auto'); From adc442232398b95825e0559c894b2b0925514aba Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 15 Jan 2019 17:57:30 +0100 Subject: [PATCH 005/115] Update card.php --- htdocs/user/card.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index bb3d7e7d8f6..6db383ed515 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -85,7 +85,9 @@ if ($user->societe_id > 0) $socid = $user->societe_id; $feature2='user'; if ($user->id == $id) { $feature2=''; $canreaduser=1; } // A user can always read its own card -$result = restrictedArea($user, 'user', $id, 'user&user', $feature2); +if (! $canreaduser) { + $result = restrictedArea($user, 'user', $id, 'user&user', $feature2); +} if ($user->id <> $id && ! $canreaduser) accessforbidden(); From 0d384eea008994aea4b7def68ad5f9493fa2a63d Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Wed, 16 Jan 2019 09:30:48 +0100 Subject: [PATCH 006/115] FIX credit note can have negative value --- htdocs/compta/facture/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 9ad79393499..8541581fb49 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1695,7 +1695,7 @@ if (empty($reshook)) setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors'); $error++; } - if ($prod_entry_mode == 'free' && empty($idprod) && (($price_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) || $price_ht == '') && $price_ht_devise == '') // Unit price can be 0 but not '' + if (($prod_entry_mode == 'free' && empty($idprod) && (($price_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) || $price_ht == '') && $price_ht_devise == '') && $object->type != Facture::TYPE_CREDIT_NOTE) // Unit price can be 0 but not '' { if ($price_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) { @@ -2155,7 +2155,7 @@ if (empty($reshook)) setEventMessages($langs->trans('ErrorQtyForCustomerInvoiceCantBeNegative'), null, 'errors'); $error++; } - if (empty($productid) && (($pu_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) || $pu_ht == '') && $pu_ht_devise == '') // Unit price can be 0 but not '' + if ((empty($productid) && (($pu_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) || $pu_ht == '') && $pu_ht_devise == '') && $object->type != Facture::TYPE_CREDIT_NOTE) // Unit price can be 0 but not '' { if ($pu_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) { From 7df86cb630d19a2ae3bda96f2792958bf77fe26b Mon Sep 17 00:00:00 2001 From: a-schild Date: Wed, 16 Jan 2019 13:06:12 +0100 Subject: [PATCH 007/115] Fix for issue #10333 paymentterm.class.php invalid SQL in fetch --- htdocs/compta/facture/class/paymentterm.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/paymentterm.class.php b/htdocs/compta/facture/class/paymentterm.class.php index 3697a61672b..90a564fa006 100644 --- a/htdocs/compta/facture/class/paymentterm.class.php +++ b/htdocs/compta/facture/class/paymentterm.class.php @@ -164,7 +164,7 @@ class PaymentTerm // extends CommonObject global $langs; $sql = "SELECT"; $sql.= " t.rowid,"; - $sql.= " t.entity"; + $sql.= " t.entity,"; $sql.= " t.code,"; $sql.= " t.sortorder,"; From 7e3bfd332e42e521dc8e708611a817802a260868 Mon Sep 17 00:00:00 2001 From: a-schild Date: Wed, 16 Jan 2019 13:07:00 +0100 Subject: [PATCH 008/115] Fix for issue #10333 paymentterm.class.php invalid SQL in fetch --- htdocs/compta/facture/class/paymentterm.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/paymentterm.class.php b/htdocs/compta/facture/class/paymentterm.class.php index bc13b0d5876..06a76d6559e 100644 --- a/htdocs/compta/facture/class/paymentterm.class.php +++ b/htdocs/compta/facture/class/paymentterm.class.php @@ -167,7 +167,7 @@ class PaymentTerm // extends CommonObject global $langs; $sql = "SELECT"; $sql.= " t.rowid,"; - $sql.= " t.entity"; + $sql.= " t.entity,"; $sql.= " t.code,"; $sql.= " t.sortorder,"; From 6becdc8af4684dfb2c1400afe19e7a4e254cdda3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Jan 2019 16:34:36 +0100 Subject: [PATCH 009/115] Fix missing substitution of ID --- htdocs/adherents/class/adherent.class.php | 4 +++- htdocs/adherents/subscription.php | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 11fb1a1a111..b4cedc98118 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -213,7 +213,9 @@ class Adherent extends CommonObject // Substitutions $substitutionarray=array( - '__CIVILITY__'=>$this->getCivilityLabel(), + '__ID__'=>$this->id, + '__MEMBER_ID__'=>$this->id, + '__CIVILITY__'=>$this->getCivilityLabel(), '__FIRSTNAME__'=>$msgishtml?dol_htmlentitiesbr($this->firstname):$this->firstname, '__LASTNAME__'=>$msgishtml?dol_htmlentitiesbr($this->lastname):$this->lastname, '__FULLNAME__'=>$msgishtml?dol_htmlentitiesbr($this->getFullName($langs)):$this->getFullName($langs), diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 60969908a44..69e22adf882 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -558,7 +558,7 @@ if ($user->rights->adherent->cotisation->creer && $action == 'subscription' && ! if (! $error) { // Send confirmation Email - if ($object->email && $_POST["sendmail"]) + if ($object->email && $_POST["sendmail"]) // $object is 'Adherent' { $subjecttosend=$object->makeSubstitution($conf->global->ADHERENT_MAIL_COTIS_SUBJECT); $texttosend=$object->makeSubstitution($adht->getMailOnSubscription()); From d997309bcb278f2aeebdfacaf6fffb00ae7154bb Mon Sep 17 00:00:00 2001 From: gauthier Date: Thu, 17 Jan 2019 14:49:04 +0100 Subject: [PATCH 010/115] FIX : if(!method_exists(dol_loginfunction)) --- htdocs/core/lib/security2.lib.php | 324 +++++++++++++++--------------- 1 file changed, 163 insertions(+), 161 deletions(-) diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index d0def9d5627..ea05adf79f7 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -126,179 +126,181 @@ function checkLoginPassEntity($usertotest,$passwordtotest,$entitytotest,$authmod * @param Societe $mysoc Company object * @return void */ -function dol_loginfunction($langs,$conf,$mysoc) -{ - global $dolibarr_main_demo,$db; - global $smartphone,$hookmanager; - - // Instantiate hooks of thirdparty module only if not already define - $hookmanager->initHooks(array('mainloginpage')); - - $langs->load("main"); - $langs->load("other"); - $langs->load("help"); - $langs->load("admin"); - - $main_authentication=$conf->file->main_authentication; - $session_name=session_name(); - - $dol_url_root = DOL_URL_ROOT; - - // Title - $appli=constant('DOL_APPLICATION_TITLE'); - $title=$appli.' '.constant('DOL_VERSION'); - if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title=$conf->global->MAIN_APPLICATION_TITLE; - $titletruedolibarrversion=constant('DOL_VERSION'); // $title used by login template after the @ to inform of true Dolibarr version - - // Note: $conf->css looks like '/theme/eldy/style.css.php' - $conf->css = "/theme/".(GETPOST('theme','alpha')?GETPOST('theme','alpha'):$conf->theme)."/style.css.php"; - $themepath=dol_buildpath($conf->css,1); - if (! empty($conf->modules_parts['theme'])) // Using this feature slow down application +if (! function_exists('dol_loginfunction')) { + function dol_loginfunction($langs,$conf,$mysoc) { - foreach($conf->modules_parts['theme'] as $reldir) + global $dolibarr_main_demo,$db; + global $smartphone,$hookmanager; + + // Instantiate hooks of thirdparty module only if not already define + $hookmanager->initHooks(array('mainloginpage')); + + $langs->load("main"); + $langs->load("other"); + $langs->load("help"); + $langs->load("admin"); + + $main_authentication=$conf->file->main_authentication; + $session_name=session_name(); + + $dol_url_root = DOL_URL_ROOT; + + // Title + $appli=constant('DOL_APPLICATION_TITLE'); + $title=$appli.' '.constant('DOL_VERSION'); + if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $title=$conf->global->MAIN_APPLICATION_TITLE; + $titletruedolibarrversion=constant('DOL_VERSION'); // $title used by login template after the @ to inform of true Dolibarr version + + // Note: $conf->css looks like '/theme/eldy/style.css.php' + $conf->css = "/theme/".(GETPOST('theme','alpha')?GETPOST('theme','alpha'):$conf->theme)."/style.css.php"; + $themepath=dol_buildpath($conf->css,1); + if (! empty($conf->modules_parts['theme'])) // Using this feature slow down application { - if (file_exists(dol_buildpath($reldir.$conf->css, 0))) + foreach($conf->modules_parts['theme'] as $reldir) { - $themepath=dol_buildpath($reldir.$conf->css, 1); - break; + if (file_exists(dol_buildpath($reldir.$conf->css, 0))) + { + $themepath=dol_buildpath($reldir.$conf->css, 1); + break; + } } } - } - $conf_css = $themepath."?lang=".$langs->defaultlang; - - // Select templates dir - if (! empty($conf->modules_parts['tpl'])) // Using this feature slow down application - { - $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl/')); - foreach($dirtpls as $reldir) + $conf_css = $themepath."?lang=".$langs->defaultlang; + + // Select templates dir + if (! empty($conf->modules_parts['tpl'])) // Using this feature slow down application { - $tmp=dol_buildpath($reldir.'login.tpl.php'); - if (file_exists($tmp)) { $template_dir=preg_replace('/login\.tpl\.php$/','',$tmp); break; } + $dirtpls=array_merge($conf->modules_parts['tpl'],array('/core/tpl/')); + foreach($dirtpls as $reldir) + { + $tmp=dol_buildpath($reldir.'login.tpl.php'); + if (file_exists($tmp)) { $template_dir=preg_replace('/login\.tpl\.php$/','',$tmp); break; } + } } - } - else - { - $template_dir = DOL_DOCUMENT_ROOT."/core/tpl/"; - } - - // Set cookie for timeout management - $prefix=dol_getprefix(); - $sessiontimeout='DOLSESSTIMEOUT_'.$prefix; - if (! empty($conf->global->MAIN_SESSION_TIMEOUT)) setcookie($sessiontimeout, $conf->global->MAIN_SESSION_TIMEOUT, 0, "/", '', 0); - - if (GETPOST('urlfrom','alpha')) $_SESSION["urlfrom"]=GETPOST('urlfrom','alpha'); - else unset($_SESSION["urlfrom"]); - - if (! GETPOST("username")) $focus_element='username'; - else $focus_element='password'; - - $demologin=''; - $demopassword=''; - if (! empty($dolibarr_main_demo)) - { - $tab=explode(',',$dolibarr_main_demo); - $demologin=$tab[0]; - $demopassword=$tab[1]; - } - - // Execute hook getLoginPageOptions (for table) - $parameters=array('entity' => GETPOST('entity','int')); - $reshook = $hookmanager->executeHooks('getLoginPageOptions',$parameters); // Note that $action and $object may have been modified by some hooks. - if (is_array($hookmanager->resArray) && ! empty($hookmanager->resArray)) { - $morelogincontent = $hookmanager->resArray; // (deprecated) For compatibility - } else { - $morelogincontent = $hookmanager->resPrint; - } - - // Execute hook getLoginPageExtraOptions (eg for js) - $parameters=array('entity' => GETPOST('entity','int')); - $reshook = $hookmanager->executeHooks('getLoginPageExtraOptions',$parameters); // Note that $action and $object may have been modified by some hooks. - $moreloginextracontent = $hookmanager->resPrint; - - // Login - $login = (! empty($hookmanager->resArray['username']) ? $hookmanager->resArray['username'] : (GETPOST("username","alpha") ? GETPOST("username","alpha") : $demologin)); - $password = $demopassword; - - // Show logo (search in order: small company logo, large company logo, theme logo, common logo) - $width=0; - $urllogo=DOL_URL_ROOT.'/theme/login_logo.png'; - - if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) - { - $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('thumbs/'.$mysoc->logo_small); - } - elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) - { - $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode($mysoc->logo); - $width=128; - } - elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/img/dolibarr_logo.png')) - { - $urllogo=DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/dolibarr_logo.png'; - } - elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo.png')) - { - $urllogo=DOL_URL_ROOT.'/theme/dolibarr_logo.png'; - } - - // Security graphical code - $captcha=0; - $captcha_refresh=''; - if (function_exists("imagecreatefrompng") && ! empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA)) - { - $captcha=1; - $captcha_refresh=img_picto($langs->trans("Refresh"),'refresh','id="captcha_refresh_img"'); - } - - // Extra link - $forgetpasslink=0; - $helpcenterlink=0; - if (empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK) || empty($conf->global->MAIN_HELPCENTER_DISABLELINK)) - { - if (empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK)) + else { - $forgetpasslink=1; + $template_dir = DOL_DOCUMENT_ROOT."/core/tpl/"; } - - if (empty($conf->global->MAIN_HELPCENTER_DISABLELINK)) + + // Set cookie for timeout management + $prefix=dol_getprefix(); + $sessiontimeout='DOLSESSTIMEOUT_'.$prefix; + if (! empty($conf->global->MAIN_SESSION_TIMEOUT)) setcookie($sessiontimeout, $conf->global->MAIN_SESSION_TIMEOUT, 0, "/", '', 0); + + if (GETPOST('urlfrom','alpha')) $_SESSION["urlfrom"]=GETPOST('urlfrom','alpha'); + else unset($_SESSION["urlfrom"]); + + if (! GETPOST("username")) $focus_element='username'; + else $focus_element='password'; + + $demologin=''; + $demopassword=''; + if (! empty($dolibarr_main_demo)) { - $helpcenterlink=1; + $tab=explode(',',$dolibarr_main_demo); + $demologin=$tab[0]; + $demopassword=$tab[1]; } + + // Execute hook getLoginPageOptions (for table) + $parameters=array('entity' => GETPOST('entity','int')); + $reshook = $hookmanager->executeHooks('getLoginPageOptions',$parameters); // Note that $action and $object may have been modified by some hooks. + if (is_array($hookmanager->resArray) && ! empty($hookmanager->resArray)) { + $morelogincontent = $hookmanager->resArray; // (deprecated) For compatibility + } else { + $morelogincontent = $hookmanager->resPrint; + } + + // Execute hook getLoginPageExtraOptions (eg for js) + $parameters=array('entity' => GETPOST('entity','int')); + $reshook = $hookmanager->executeHooks('getLoginPageExtraOptions',$parameters); // Note that $action and $object may have been modified by some hooks. + $moreloginextracontent = $hookmanager->resPrint; + + // Login + $login = (! empty($hookmanager->resArray['username']) ? $hookmanager->resArray['username'] : (GETPOST("username","alpha") ? GETPOST("username","alpha") : $demologin)); + $password = $demopassword; + + // Show logo (search in order: small company logo, large company logo, theme logo, common logo) + $width=0; + $urllogo=DOL_URL_ROOT.'/theme/login_logo.png'; + + if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) + { + $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode('thumbs/'.$mysoc->logo_small); + } + elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) + { + $urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&modulepart=mycompany&file='.urlencode($mysoc->logo); + $width=128; + } + elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/img/dolibarr_logo.png')) + { + $urllogo=DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/dolibarr_logo.png'; + } + elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo.png')) + { + $urllogo=DOL_URL_ROOT.'/theme/dolibarr_logo.png'; + } + + // Security graphical code + $captcha=0; + $captcha_refresh=''; + if (function_exists("imagecreatefrompng") && ! empty($conf->global->MAIN_SECURITY_ENABLECAPTCHA)) + { + $captcha=1; + $captcha_refresh=img_picto($langs->trans("Refresh"),'refresh','id="captcha_refresh_img"'); + } + + // Extra link + $forgetpasslink=0; + $helpcenterlink=0; + if (empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK) || empty($conf->global->MAIN_HELPCENTER_DISABLELINK)) + { + if (empty($conf->global->MAIN_SECURITY_DISABLEFORGETPASSLINK)) + { + $forgetpasslink=1; + } + + if (empty($conf->global->MAIN_HELPCENTER_DISABLELINK)) + { + $helpcenterlink=1; + } + } + + // Home message + $main_home=''; + if (! empty($conf->global->MAIN_HOME)) + { + $substitutionarray=getCommonSubstitutionArray($langs); + complete_substitutions_array($substitutionarray, $langs); + $texttoshow = make_substitutions($conf->global->MAIN_HOME, $substitutionarray, $langs); + + $main_home=dol_htmlcleanlastbr($texttoshow); + } + + // Google AD + $main_google_ad_client = ((! empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && ! empty($conf->global->MAIN_GOOGLE_AD_SLOT))?1:0); + + // Set jquery theme + $dol_loginmesg = (! empty($_SESSION["dol_loginmesg"])?$_SESSION["dol_loginmesg"]:''); + $favicon=dol_buildpath('/theme/'.$conf->theme.'/img/favicon.ico',1); + if (! empty($conf->global->MAIN_FAVICON_URL)) $favicon=$conf->global->MAIN_FAVICON_URL; + $jquerytheme = 'smoothness'; + if (! empty($conf->global->MAIN_USE_JQUERY_THEME)) $jquerytheme = $conf->global->MAIN_USE_JQUERY_THEME; + + // Set dol_hide_topmenu, dol_hide_leftmenu, dol_optimize_smallscreen, dol_no_mouse_hover + $dol_hide_topmenu=GETPOST('dol_hide_topmenu','int'); + $dol_hide_leftmenu=GETPOST('dol_hide_leftmenu','int'); + $dol_optimize_smallscreen=GETPOST('dol_optimize_smallscreen','int'); + $dol_no_mouse_hover=GETPOST('dol_no_mouse_hover','int'); + $dol_use_jmobile=GETPOST('dol_use_jmobile','int'); + + // Include login page template + include $template_dir.'login.tpl.php'; + + + $_SESSION["dol_loginmesg"] = ''; } - - // Home message - $main_home=''; - if (! empty($conf->global->MAIN_HOME)) - { - $substitutionarray=getCommonSubstitutionArray($langs); - complete_substitutions_array($substitutionarray, $langs); - $texttoshow = make_substitutions($conf->global->MAIN_HOME, $substitutionarray, $langs); - - $main_home=dol_htmlcleanlastbr($texttoshow); - } - - // Google AD - $main_google_ad_client = ((! empty($conf->global->MAIN_GOOGLE_AD_CLIENT) && ! empty($conf->global->MAIN_GOOGLE_AD_SLOT))?1:0); - - // Set jquery theme - $dol_loginmesg = (! empty($_SESSION["dol_loginmesg"])?$_SESSION["dol_loginmesg"]:''); - $favicon=dol_buildpath('/theme/'.$conf->theme.'/img/favicon.ico',1); - if (! empty($conf->global->MAIN_FAVICON_URL)) $favicon=$conf->global->MAIN_FAVICON_URL; - $jquerytheme = 'smoothness'; - if (! empty($conf->global->MAIN_USE_JQUERY_THEME)) $jquerytheme = $conf->global->MAIN_USE_JQUERY_THEME; - - // Set dol_hide_topmenu, dol_hide_leftmenu, dol_optimize_smallscreen, dol_no_mouse_hover - $dol_hide_topmenu=GETPOST('dol_hide_topmenu','int'); - $dol_hide_leftmenu=GETPOST('dol_hide_leftmenu','int'); - $dol_optimize_smallscreen=GETPOST('dol_optimize_smallscreen','int'); - $dol_no_mouse_hover=GETPOST('dol_no_mouse_hover','int'); - $dol_use_jmobile=GETPOST('dol_use_jmobile','int'); - - // Include login page template - include $template_dir.'login.tpl.php'; - - - $_SESSION["dol_loginmesg"] = ''; } /** From 1d33b6ccbb64f3fbeb3ef1270b1ceeb6e239b915 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 17 Jan 2019 16:01:32 +0100 Subject: [PATCH 011/115] FIX broken external authentication module feature and avoid warning --- htdocs/cashdesk/class/Facturation.class.php | 3 +-- htdocs/cashdesk/index.php | 29 +++++++++++++++++++++ htdocs/cashdesk/tpl/liste_articles.tpl.php | 3 +-- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/htdocs/cashdesk/class/Facturation.class.php b/htdocs/cashdesk/class/Facturation.class.php index a0e992e9da9..e76f6c3a142 100644 --- a/htdocs/cashdesk/class/Facturation.class.php +++ b/htdocs/cashdesk/class/Facturation.class.php @@ -211,8 +211,7 @@ class Facturation $total_localtax1 = 0; $total_localtax2 = 0; - $tab=array(); - $tab = $_SESSION['poscart']; + $tab = (! empty($_SESSION['poscart'])?$_SESSION['poscart']:array()); $tab_size=count($tab); for($i=0;$i < $tab_size;$i++) diff --git a/htdocs/cashdesk/index.php b/htdocs/cashdesk/index.php index 24b94562915..c09521585e6 100644 --- a/htdocs/cashdesk/index.php +++ b/htdocs/cashdesk/index.php @@ -41,6 +41,8 @@ if ( $_SESSION['uid'] > 0 ) $usertxt=GETPOST('user','',1); $err=GETPOST("err"); +// Instantiate hooks of thirdparty module only if not already define +$hookmanager->initHooks(array('cashdeskloginpage')); /* * View @@ -51,6 +53,15 @@ $formproduct=new FormProduct($db); $arrayofcss=array('/cashdesk/css/style.css'); top_htmlhead('','',0,0,'',$arrayofcss); + +// Execute hook getLoginPageOptions (for table) +$parameters=array('entity' => GETPOST('entity','int')); +$reshook = $hookmanager->executeHooks('getLoginPageOptions',$parameters); // Note that $action and $object may have been modified by some hooks. +if (is_array($hookmanager->resArray) && ! empty($hookmanager->resArray)) { + $morelogincontent = $hookmanager->resArray; // (deprecated) For compatibility +} else { + $morelogincontent = $hookmanager->resPrint; +} ?> @@ -92,6 +103,24 @@ else + $option) + { + if ($format == 'table') { + echo ''; + echo $option; + } + } + } + else { + echo ''; + echo $morelogincontent; + } +} +?> +   diff --git a/htdocs/cashdesk/tpl/liste_articles.tpl.php b/htdocs/cashdesk/tpl/liste_articles.tpl.php index 65f48b0603c..082a1f901cd 100644 --- a/htdocs/cashdesk/tpl/liste_articles.tpl.php +++ b/htdocs/cashdesk/tpl/liste_articles.tpl.php @@ -46,8 +46,7 @@ $societe = new Societe($db); $societe->fetch($thirdpartyid); /** end add Ditto */ -$tab=array(); -$tab = $_SESSION['poscart']; +$tab = (! empty($_SESSION['poscart'])?$_SESSION['poscart']:array()); $tab_size=count($tab); if ($tab_size <= 0) print '
'.$langs->trans("NoArticle").'

'; From 191900d258997a15b52fe6dcb55dfe3f5b47b128 Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Fri, 18 Jan 2019 22:25:51 +0100 Subject: [PATCH 012/115] Update stats.class.php Fix div/0 warnings --- htdocs/core/class/stats.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/stats.class.php b/htdocs/core/class/stats.class.php index dfb070aa5b9..1433085a36a 100644 --- a/htdocs/core/class/stats.class.php +++ b/htdocs/core/class/stats.class.php @@ -384,16 +384,16 @@ abstract class Stats $row = $this->db->fetch_object($resql); $result[$i]['year'] = $row->year; $result[$i]['nb'] = $row->nb; - if($i>0 && $row->nb) $result[$i-1]['nb_diff'] = ($result[$i-1]['nb'] - $row->nb) / $row->nb * 100; + if($i>0 && $row->nb>0) $result[$i-1]['nb_diff'] = ($result[$i-1]['nb'] - $row->nb) / $row->nb * 100; $result[$i]['total'] = $row->total; - if($i>0 && $row->total) $result[$i-1]['total_diff'] = ($result[$i-1]['total'] - $row->total) / $row->total * 100; + if($i>0 && $row->total>0) $result[$i-1]['total_diff'] = ($result[$i-1]['total'] - $row->total) / $row->total * 100; $result[$i]['avg'] = $row->avg; - if($i>0 && $row->avg) $result[$i-1]['avg_diff'] = ($result[$i-1]['avg'] - $row->avg) / $row->avg * 100; + if($i>0 && $row->avg>0) $result[$i-1]['avg_diff'] = ($result[$i-1]['avg'] - $row->avg) / $row->avg * 100; // For some $sql only if (isset($row->weighted)) { $result[$i]['weighted'] = $row->weighted; - if($i>0 && $row->weighted) $result[$i-1]['avg_weighted'] = ($result[$i-1]['weighted'] - $row->weighted) / $row->weighted * 100; + if($i>0 && $row->weighted>0) $result[$i-1]['avg_weighted'] = ($result[$i-1]['weighted'] - $row->weighted) / $row->weighted * 100; } $i++; } From aaa61254accee51bd28b6ed4aa2cc9a83e6585c3 Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Fri, 18 Jan 2019 22:25:51 +0100 Subject: [PATCH 013/115] Update stats.class.php Fix div/0 warnings --- htdocs/core/class/stats.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/stats.class.php b/htdocs/core/class/stats.class.php index dfb070aa5b9..1433085a36a 100644 --- a/htdocs/core/class/stats.class.php +++ b/htdocs/core/class/stats.class.php @@ -384,16 +384,16 @@ abstract class Stats $row = $this->db->fetch_object($resql); $result[$i]['year'] = $row->year; $result[$i]['nb'] = $row->nb; - if($i>0 && $row->nb) $result[$i-1]['nb_diff'] = ($result[$i-1]['nb'] - $row->nb) / $row->nb * 100; + if($i>0 && $row->nb>0) $result[$i-1]['nb_diff'] = ($result[$i-1]['nb'] - $row->nb) / $row->nb * 100; $result[$i]['total'] = $row->total; - if($i>0 && $row->total) $result[$i-1]['total_diff'] = ($result[$i-1]['total'] - $row->total) / $row->total * 100; + if($i>0 && $row->total>0) $result[$i-1]['total_diff'] = ($result[$i-1]['total'] - $row->total) / $row->total * 100; $result[$i]['avg'] = $row->avg; - if($i>0 && $row->avg) $result[$i-1]['avg_diff'] = ($result[$i-1]['avg'] - $row->avg) / $row->avg * 100; + if($i>0 && $row->avg>0) $result[$i-1]['avg_diff'] = ($result[$i-1]['avg'] - $row->avg) / $row->avg * 100; // For some $sql only if (isset($row->weighted)) { $result[$i]['weighted'] = $row->weighted; - if($i>0 && $row->weighted) $result[$i-1]['avg_weighted'] = ($result[$i-1]['weighted'] - $row->weighted) / $row->weighted * 100; + if($i>0 && $row->weighted>0) $result[$i-1]['avg_weighted'] = ($result[$i-1]['weighted'] - $row->weighted) / $row->weighted * 100; } $i++; } From 077b9f1996645fd623623c0907978f4ef1fb9fb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 20 Jan 2019 15:23:48 +0100 Subject: [PATCH 014/115] get_codeclient return void https://github.com/frederic34/dolibarr/blob/1ac55b08002cb2a56464d0ab63881e21165f1ae7/htdocs/societe/class/societe.class.php#L2421-L2441 --- htdocs/adherents/subscription.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 225cac7c47c..a41438c4097 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -859,8 +859,16 @@ if ($rowid > 0) { $tmpcompany = new Societe($db); $tmpcompany->name=$companyname; - $customercode = $tmpcompany->get_codeclient($tmpcompany,0); - $formquestion[]=array('label' => $langs->trans("CustomerCode"), 'type' => 'text', 'name' => 'customercode', 'value' => $customercode, 'morecss' => 'minwidth300', 'moreattr' => 'maxlength="128"'); + $tmpcompany->get_codeclient($tmpcompany, 0); + $customercode = $tmpcompany->code_client; + $formquestion[]=array( + 'label' => $langs->trans("CustomerCode"), + 'type' => 'text', + 'name' => 'customercode', + 'value' => $customercode, + 'morecss' => 'minwidth300', + 'moreattr' => 'maxlength="128"', + ); } // @TODO Add other extrafields mandatory for thirdparty creation From b8683979029da4dd1b1b765c735b003b005d0cea Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Jan 2019 02:27:13 +0100 Subject: [PATCH 015/115] Fix colspan --- htdocs/accountancy/admin/account.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 8eca415bff9..146099347cc 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -276,7 +276,7 @@ if ($resql) if (! empty($arrayfields['aa.pcg_type']['checked'])) print ''; if (! empty($arrayfields['aa.pcg_subtype']['checked'])) print ''; if (! empty($arrayfields['aa.active']['checked'])) print ' '; - print ''; + print ''; $searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); print $searchpicto; print ''; From 5ab6c41dfa15610469f8dd12ee3f7c7374de09da Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Jan 2019 02:43:08 +0100 Subject: [PATCH 016/115] Fix missing multicurrency fields in export --- htdocs/core/modules/modCommande.class.php | 8 ++++++++ htdocs/core/modules/modFacture.class.php | 16 ++++++++++++++++ htdocs/core/modules/modPropale.class.php | 8 ++++++++ 3 files changed, 32 insertions(+) diff --git a/htdocs/core/modules/modCommande.class.php b/htdocs/core/modules/modCommande.class.php index 91a86e4e842..5285e0734e2 100644 --- a/htdocs/core/modules/modCommande.class.php +++ b/htdocs/core/modules/modCommande.class.php @@ -201,6 +201,14 @@ class modCommande extends DolibarrModules 'cd.tva_tx'=>"LineVATRate",'cd.qty'=>"LineQty",'cd.total_ht'=>"LineTotalHT",'cd.total_tva'=>"LineTotalVAT",'cd.total_ttc'=>"LineTotalTTC", 'p.rowid'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel' ); + if (! empty($conf->multicurrency->enabled)) + { + $this->export_fields_array[$r]['c.multicurrency_code'] = 'Currency'; + $this->export_fields_array[$r]['c.multicurrency_tx'] = 'CurrencyRate'; + $this->export_fields_array[$r]['c.multicurrency_total_ht'] = 'MulticurrencyAmountHT'; + $this->export_fields_array[$r]['c.multicurrency_total_tva'] = 'MulticurrencyAmountVAT'; + $this->export_fields_array[$r]['c.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC'; + } //$this->export_TypeFields_array[$r]=array( // 's.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label', // 'co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text", diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index 0326625b943..dc7448fc8f2 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -222,6 +222,14 @@ class modFacture extends DolibarrModules 'fd.product_type'=>"TypeOfLineServiceOrProduct", 'fd.fk_product'=>'ProductId', 'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel', 'p.accountancy_code_sell'=>'ProductAccountancySellCode' ); + if (! empty($conf->multicurrency->enabled)) + { + $this->export_fields_array[$r]['f.multicurrency_code'] = 'Currency'; + $this->export_fields_array[$r]['f.multicurrency_tx'] = 'CurrencyRate'; + $this->export_fields_array[$r]['f.multicurrency_total_ht'] = 'MulticurrencyAmountHT'; + $this->export_fields_array[$r]['f.multicurrency_total_tva'] = 'MulticurrencyAmountVAT'; + $this->export_fields_array[$r]['f.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC'; + } $this->export_TypeFields_array[$r] = array( 's.rowid'=>'Numeric', 's.nom'=>'Text', 's.code_client'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 's.tva_intra'=>'Text', @@ -284,6 +292,14 @@ class modFacture extends DolibarrModules 'p.amount'=>'AmountPayment', 'pf.amount'=>'AmountPaymentDistributedOnInvoice', 'p.datep'=>'DatePayment', 'p.num_paiement'=>'PaymentNumber', 'pt.code'=>'CodePaymentMode', 'pt.libelle'=>'LabelPaymentMode', 'p.note'=>'PaymentNote', 'p.fk_bank'=>'IdTransaction', 'ba.ref'=>'AccountRef' ); + if (! empty($conf->multicurrency->enabled)) + { + $this->export_fields_array[$r]['f.multicurrency_code'] = 'Currency'; + $this->export_fields_array[$r]['f.multicurrency_tx'] = 'CurrencyRate'; + $this->export_fields_array[$r]['f.multicurrency_total_ht'] = 'MulticurrencyAmountHT'; + $this->export_fields_array[$r]['f.multicurrency_total_tva'] = 'MulticurrencyAmountVAT'; + $this->export_fields_array[$r]['f.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC'; + } $this->export_TypeFields_array[$r] = array( 's.rowid'=>'Numeric', 's.nom'=>'Text', 's.code_client'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 's.tva_intra'=>'Text', diff --git a/htdocs/core/modules/modPropale.class.php b/htdocs/core/modules/modPropale.class.php index c0701d3bfe2..70374134154 100644 --- a/htdocs/core/modules/modPropale.class.php +++ b/htdocs/core/modules/modPropale.class.php @@ -193,6 +193,14 @@ class modPropale extends DolibarrModules 'cd.tva_tx'=>"LineVATRate",'cd.qty'=>"LineQty",'cd.total_ht'=>"LineTotalHT",'cd.total_tva'=>"LineTotalVAT",'cd.total_ttc'=>"LineTotalTTC", 'p.rowid'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel' ); + if (! empty($conf->multicurrency->enabled)) + { + $this->export_fields_array[$r]['c.multicurrency_code'] = 'Currency'; + $this->export_fields_array[$r]['c.multicurrency_tx'] = 'CurrencyRate'; + $this->export_fields_array[$r]['c.multicurrency_total_ht'] = 'MulticurrencyAmountHT'; + $this->export_fields_array[$r]['c.multicurrency_total_tva'] = 'MulticurrencyAmountVAT'; + $this->export_fields_array[$r]['c.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC'; + } //$this->export_TypeFields_array[$r]=array( // 's.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.code'=>'Text','s.phone'=>'Text', // 's.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text",'c.datec'=>"Date",'c.datep'=>"Date", From 6f553db93d0323d5725c253187f79192ce7eb448 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Jan 2019 20:47:07 +0100 Subject: [PATCH 017/115] Remove bad text --- htdocs/admin/system/filecheck.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index 309d20e0abe..14b25aedac2 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -338,7 +338,6 @@ if (! $error && $xml) $out.=''; $out.=''.$i.'' . "\n"; $out.=''.$file['filename']; - $out.=PHP_OS; if (! preg_match('/^win/i',PHP_OS)) { $htmltext=$langs->trans("YouCanDeleteFileOnServerWith", 'rm '.DOL_DOCUMENT_ROOT.'/'.$file['filename']); $out.=' '.$form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'helprm'); From 1cf786acff1dc3c31c0006e47238c349e5179fb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Lukas?= Date: Tue, 22 Jan 2019 00:09:36 +0100 Subject: [PATCH 018/115] Fix #10278 Fix #10278 --- htdocs/core/class/commonobject.class.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 676e76fe16a..d8d27a0378a 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4932,8 +4932,6 @@ abstract class CommonObject $new_array_options[$key] = price2num($this->array_options[$key]); break; case 'date': - $new_array_options[$key] = $this->db->idate($this->array_options[$key]); - break; case 'datetime': // If data is a string instead of a timestamp, we convert it if (! is_int($this->array_options[$key])) { From 84e1f92acd2eddc186c0d06b0e909863d0c0bd78 Mon Sep 17 00:00:00 2001 From: gauthier Date: Wed, 23 Jan 2019 15:09:57 +0100 Subject: [PATCH 019/115] FIX : when we add a payment on an invoice which already has payments with credit note or deposit amount, and then we get an excess received, discount amount must be $total_paiements + $total_creditnote_and_deposit - $object->total_ttc; --- htdocs/compta/facture/card.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 8541581fb49..5e736df5855 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -725,20 +725,31 @@ if (empty($reshook)) { // If we're on a standard invoice, we have to get excess received to create a discount in TTC without VAT + // Total payments $sql = 'SELECT SUM(pf.amount) as total_paiements'; $sql.= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf, '.MAIN_DB_PREFIX.'paiement as p'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as c ON p.fk_paiement = c.id'; $sql.= ' WHERE pf.fk_facture = '.$object->id; $sql.= ' AND pf.fk_paiement = p.rowid'; $sql.= ' AND p.entity IN (' . getEntity('facture').')'; - $resql = $db->query($sql); if (! $resql) dol_print_error($db); $res = $db->fetch_object($resql); $total_paiements = $res->total_paiements; - $discount->amount_ht = $discount->amount_ttc = $total_paiements - $object->total_ttc; + // Total credit note and deposit + $total_creditnote_and_deposit = 0; + $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; + $sql .= " re.description, re.fk_facture_source"; + $sql .= " FROM " . MAIN_DB_PREFIX . "societe_remise_except as re"; + $sql .= " WHERE fk_facture = " . $object->id; + $resql = $db->query($sql); + if (!empty($resql)) { + while ($obj = $db->fetch_object($resql)) $total_creditnote_and_deposit += $obj->amount_ttc; + } else dol_print_error($db); + + $discount->amount_ht = $discount->amount_ttc = $total_paiements + $total_creditnote_and_deposit - $object->total_ttc; $discount->amount_tva = 0; $discount->tva_tx = 0; From 1c51716997f2c3cb09ffa2b7feea4c770289c41f Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Wed, 23 Jan 2019 17:02:20 +0100 Subject: [PATCH 020/115] Fix missing trigger --- .../sociales/class/chargesociales.class.php | 38 +++++++++++++++---- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index 61728562d2e..3a69cdca4f7 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -282,6 +282,7 @@ class ChargeSociales extends CommonObject */ function update($user) { + $error=0; $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales"; @@ -295,17 +296,40 @@ class ChargeSociales extends CommonObject dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql=$this->db->query($sql); - if ($resql) + + if (! $resql) { + $error++; $this->errors[]="Error ".$this->db->lasterror(); + } + + if (! $error) + { + if (! $notrigger) + { + // Call trigger + $result=$this->call_trigger('SOCIALCHARGES_MODIFY',$user); + if ($result < 0) $error++; + // End call triggers + } + } + + // Commit or rollback + if ($error) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + else { $this->db->commit(); return 1; } - else - { - $this->error=$this->db->error(); - $this->db->rollback(); - return -1; - } + + } /** From 624d17c96a52d99c5c35bf40811571ae254f5ed1 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Wed, 23 Jan 2019 17:32:49 +0100 Subject: [PATCH 021/115] Fix missing no trigger arg --- htdocs/compta/sociales/class/chargesociales.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index 3a69cdca4f7..da8f7c8f250 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -280,7 +280,7 @@ class ChargeSociales extends CommonObject * @param User $user Utilisateur qui modifie * @return int <0 si erreur, >0 si ok */ - function update($user) + function update($user, $notrigger=0) { $error=0; $this->db->begin(); From 15e1d3b45685e47705d52d2c58a63fea2b3537df Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Thu, 24 Jan 2019 09:40:58 +0100 Subject: [PATCH 022/115] Fix fetch test --- .../class/fournisseur.commande.class.php | 95 ++++++++++--------- 1 file changed, 52 insertions(+), 43 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index d07c3347146..ef22d5bd8f8 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -3016,49 +3016,58 @@ class CommandeFournisseurLigne extends CommonOrderLine $result = $this->db->query($sql); if ($result) { - $objp = $this->db->fetch_object($result); - - $this->rowid = $objp->rowid; - $this->id = $objp->rowid; - $this->fk_commande = $objp->fk_commande; - $this->desc = $objp->description; - $this->qty = $objp->qty; - $this->ref_fourn = $objp->ref; - $this->ref_supplier = $objp->ref; - $this->subprice = $objp->subprice; - $this->tva_tx = $objp->tva_tx; - $this->localtax1_tx = $objp->localtax1_tx; - $this->localtax2_tx = $objp->localtax2_tx; - $this->localtax1_type = $objp->localtax1_type; - $this->localtax2_type = $objp->localtax2_type; - $this->remise = $objp->remise; - $this->remise_percent = $objp->remise_percent; - $this->fk_product = $objp->fk_product; - $this->info_bits = $objp->info_bits; - $this->total_ht = $objp->total_ht; - $this->total_tva = $objp->total_tva; - $this->total_localtax1 = $objp->total_localtax1; - $this->total_localtax2 = $objp->total_localtax2; - $this->total_ttc = $objp->total_ttc; - $this->product_type = $objp->product_type; - $this->special_code = $objp->special_code; - - $this->ref = $objp->product_ref; - $this->product_ref = $objp->product_ref; - $this->product_libelle = $objp->product_libelle; - $this->product_desc = $objp->product_desc; - - $this->date_start = $this->db->jdate($objp->date_start); - $this->date_end = $this->db->jdate($objp->date_end); - $this->fk_unit = $objp->fk_unit; - - $this->multicurrency_subprice = $objp->multicurrency_subprice; - $this->multicurrency_total_ht = $objp->multicurrency_total_ht; - $this->multicurrency_total_tva = $objp->multicurrency_total_tva; - $this->multicurrency_total_ttc = $objp->multicurrency_total_ttc; - - $this->db->free($result); - return 1; + if ($this->db->num_rows($result)) + { + $objp = $this->db->fetch_object($result); + + $this->rowid = $objp->rowid; + $this->id = $objp->rowid; + $this->fk_commande = $objp->fk_commande; + $this->desc = $objp->description; + $this->qty = $objp->qty; + $this->ref_fourn = $objp->ref; + $this->ref_supplier = $objp->ref; + $this->subprice = $objp->subprice; + $this->tva_tx = $objp->tva_tx; + $this->localtax1_tx = $objp->localtax1_tx; + $this->localtax2_tx = $objp->localtax2_tx; + $this->localtax1_type = $objp->localtax1_type; + $this->localtax2_type = $objp->localtax2_type; + $this->remise = $objp->remise; + $this->remise_percent = $objp->remise_percent; + $this->fk_product = $objp->fk_product; + $this->info_bits = $objp->info_bits; + $this->total_ht = $objp->total_ht; + $this->total_tva = $objp->total_tva; + $this->total_localtax1 = $objp->total_localtax1; + $this->total_localtax2 = $objp->total_localtax2; + $this->total_ttc = $objp->total_ttc; + $this->product_type = $objp->product_type; + $this->special_code = $objp->special_code; + + $this->ref = $objp->product_ref; + $this->product_ref = $objp->product_ref; + $this->product_libelle = $objp->product_libelle; + $this->product_desc = $objp->product_desc; + + $this->date_start = $this->db->jdate($objp->date_start); + $this->date_end = $this->db->jdate($objp->date_end); + $this->fk_unit = $objp->fk_unit; + + $this->multicurrency_subprice = $objp->multicurrency_subprice; + $this->multicurrency_total_ht = $objp->multicurrency_total_ht; + $this->multicurrency_total_tva = $objp->multicurrency_total_tva; + $this->multicurrency_total_ttc = $objp->multicurrency_total_ttc; + + $this->db->free($result); + return 1; + } + else + { + $this->error='Supplier order line with id='.$rowid.' not found'; + dol_syslog(get_class($this)."::fetch Error ".$this->error, LOG_ERR); + return 0; + } } else { From 94d3f038eb6dbe5794d56a904cf85c8794f6ee79 Mon Sep 17 00:00:00 2001 From: Xebax Date: Sun, 27 Jan 2019 13:20:33 +0100 Subject: [PATCH 023/115] FIX 'statut' is ignored when updating a user with the REST API. --- htdocs/user/class/api_users.class.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index c30cacd72c0..6c5a15cc3cc 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -212,11 +212,22 @@ class Users extends DolibarrApi foreach ($request_data as $field => $value) { - if ($field == 'id') continue; - $this->useraccount->$field = $value; + if ($field == 'id') continue; + // The status must be updated using setstatus() because it + // is not handled by the update() method. + if ($field == 'statut') { + $result = $this->useraccount->setstatus($value); + if ($result < 0) { + throw new RestException(500, 'Error when updating status of user: '.$this->useraccount->error); + } + } else { + $this->useraccount->$field = $value; + } } - if ($this->useraccount->update(DolibarrApiAccess::$user) > 0) + // If there is no error, update() returns the number of affected + // rows so if the update is a no op, the return value is zezo. + if ($this->useraccount->update(DolibarrApiAccess::$user) >= 0) { return $this->get($id); } From d59097f65c25c9b8529a402475f1ac211aaed850 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 27 Jan 2019 17:40:56 +0100 Subject: [PATCH 024/115] Fix upload of module file --- htdocs/admin/modules.php | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index ae87a19e433..7a9241fb9d4 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -141,6 +141,12 @@ if ($action=='install') setEventMessages($langs->trans("ErrorFilenameDosNotMatchDolibarrPackageRules",$original_file, 'module_*-x.y*.zip'), null, 'errors'); $error++; } + if (empty($_FILES['fileinstall']['tmp_name'])) + { + $langs->load("errors"); + setEventMessages($langs->trans("ErrorFileNotUploaded"), null, 'errors'); + $error++; + } } if (! $error) @@ -151,14 +157,14 @@ if ($action=='install') dol_mkdir($conf->admin->dir_temp.'/'.$original_file); } - $tmpdir=preg_replace('/\.zip$/','',$original_file).'.dir'; + $tmpdir=preg_replace('/\.zip$/i','',$original_file).'.dir'; if ($tmpdir) { @dol_delete_dir_recursive($conf->admin->dir_temp.'/'.$tmpdir); dol_mkdir($conf->admin->dir_temp.'/'.$tmpdir); } - $result=dol_move_uploaded_file($_FILES['fileinstall']['tmp_name'],$newfile,1,0,$_FILES['fileinstall']['error']); + $result=dol_move_uploaded_file($_FILES['fileinstall']['tmp_name'], $newfile, 1, 0, $_FILES['fileinstall']['error']); if ($result > 0) { $result=dol_uncompress($newfile,$conf->admin->dir_temp.'/'.$tmpdir); @@ -206,6 +212,7 @@ if ($action=='install') } else { + setEventMessages($langs->trans("ErrorFailToRenameFile", $_FILES['fileinstall']['tmp_name'], $newfile), null, 'errors'); $error++; } } @@ -1002,6 +1009,7 @@ if ($mode == 'deploy') print '
'; print '
'; + print ''; print ''; print ''; @@ -1027,6 +1035,20 @@ if ($mode == 'deploy') print ''; + if (! empty($conf->global->MAIN_UPLOAD_DOC)) + { + if ($user->admin) + { + $langs->load('other'); + print ' '; + print info_admin($langs->trans("ThisLimitIsDefinedInSetup",$max,$maxphp),1); + } + } + else + { + print ' ('.$langs->trans("UploadDisabled").')'; + } + print '
'; print '
'; From 9a666b265f922e28f8e23e8f895bdeca74b5a3d0 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Mon, 28 Jan 2019 11:53:19 +0100 Subject: [PATCH 025/115] Use an other test --- htdocs/fourn/class/fournisseur.commande.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index ef22d5bd8f8..a4283ee5162 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -3016,9 +3016,11 @@ class CommandeFournisseurLigne extends CommonOrderLine $result = $this->db->query($sql); if ($result) { - if ($this->db->num_rows($result)) + $objp = $this->db->fetch_object($result); + + if (!empty($objp)) { - $objp = $this->db->fetch_object($result); + $this->rowid = $objp->rowid; $this->id = $objp->rowid; From 5dbc9ddae09e2034cd1929211ae9b688a1736c30 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Mon, 28 Jan 2019 11:56:20 +0100 Subject: [PATCH 026/115] fix travis --- htdocs/compta/sociales/class/chargesociales.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index da8f7c8f250..fbba5c13e63 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -280,7 +280,7 @@ class ChargeSociales extends CommonObject * @param User $user Utilisateur qui modifie * @return int <0 si erreur, >0 si ok */ - function update($user, $notrigger=0) + function update($user,$notrigger=0) { $error=0; $this->db->begin(); From 6f12cdf23686aab9f29b0a048f74915ecb2eb1e0 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Mon, 28 Jan 2019 11:58:16 +0100 Subject: [PATCH 027/115] Fix travis --- htdocs/compta/sociales/class/chargesociales.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index fbba5c13e63..c3995a2202d 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -278,6 +278,7 @@ class ChargeSociales extends CommonObject * Met a jour une charge sociale * * @param User $user Utilisateur qui modifie + * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 si erreur, >0 si ok */ function update($user,$notrigger=0) From 4545c0f13ad30da02ab2b9ef2e8f9c157b03dcfc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Jan 2019 16:22:36 +0100 Subject: [PATCH 028/115] Fix lang format of en_ZA --- htdocs/langs/en_ZA/main.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_ZA/main.lang b/htdocs/langs/en_ZA/main.lang index 4c30b385ef8..58dfee14958 100644 --- a/htdocs/langs/en_ZA/main.lang +++ b/htdocs/langs/en_ZA/main.lang @@ -7,7 +7,7 @@ SeparatorThousand=, FormatDateShort=%Y/%m/%d FormatDateShortInput=%Y/%m/%d FormatDateShortJava=yyy/MM/dd -FormatDateShortJavaInput=yyyy/MM/yy +FormatDateShortJavaInput=yyyy/MM/dd FormatDateShortJQuery=yy/mm/yy FormatDateShortJQueryInput=yy/mm/dd FormatHourShortJQuery=HH:MI From 9dbf41d6b2728ccc6ed5a28328b2a234c2834af4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Jan 2019 16:22:53 +0100 Subject: [PATCH 029/115] Fix lang format --- htdocs/langs/en_ZA/main.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_ZA/main.lang b/htdocs/langs/en_ZA/main.lang index 58dfee14958..1f6a0b9245d 100644 --- a/htdocs/langs/en_ZA/main.lang +++ b/htdocs/langs/en_ZA/main.lang @@ -8,7 +8,7 @@ FormatDateShort=%Y/%m/%d FormatDateShortInput=%Y/%m/%d FormatDateShortJava=yyy/MM/dd FormatDateShortJavaInput=yyyy/MM/dd -FormatDateShortJQuery=yy/mm/yy +FormatDateShortJQuery=yy/mm/dd FormatDateShortJQueryInput=yy/mm/dd FormatHourShortJQuery=HH:MI FormatHourShort=%H:%M From 9d1a02b0d7feb3f067f64cbb1a57d6e57325221a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 28 Jan 2019 16:25:37 +0100 Subject: [PATCH 030/115] Fix language --- htdocs/langs/en_ZA/main.lang | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_ZA/main.lang b/htdocs/langs/en_ZA/main.lang index 4c30b385ef8..1f6a0b9245d 100644 --- a/htdocs/langs/en_ZA/main.lang +++ b/htdocs/langs/en_ZA/main.lang @@ -7,8 +7,8 @@ SeparatorThousand=, FormatDateShort=%Y/%m/%d FormatDateShortInput=%Y/%m/%d FormatDateShortJava=yyy/MM/dd -FormatDateShortJavaInput=yyyy/MM/yy -FormatDateShortJQuery=yy/mm/yy +FormatDateShortJavaInput=yyyy/MM/dd +FormatDateShortJQuery=yy/mm/dd FormatDateShortJQueryInput=yy/mm/dd FormatHourShortJQuery=HH:MI FormatHourShort=%H:%M From b24f5fda68f3f6800a68fce44676db8dcb59d910 Mon Sep 17 00:00:00 2001 From: Xebax Date: Tue, 29 Jan 2019 08:47:46 +0100 Subject: [PATCH 031/115] FIX Fix PHP warning "count(): Parameter must be an array..." --- htdocs/api/class/api.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index 2d18568bf2d..b9e7f2075ef 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -251,7 +251,7 @@ class DolibarrApi //$tmp=preg_replace_all('/'.$regexstring.'/', '', $sqlfilters); $tmp=$sqlfilters; $ok=0; - $i=0; $nb=count($tmp); + $i=0; $nb=strlen($tmp); $counter=0; while ($i < $nb) { From eca1a2cd6472efa4b6ffae90e91263da8536e0db Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Tue, 29 Jan 2019 11:08:13 +0100 Subject: [PATCH 032/115] Update societe.class.php --- htdocs/societe/class/societe.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index a240c83b89f..18a4dbda8f2 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -3798,6 +3798,7 @@ class Societe extends CommonObject $sql .= " WHERE fk_soc = ". $this->id; $sql .= " AND paye = 0"; $sql .= " AND fk_statut <> 0"; // Not a draft + $sql .= " AND entity IN (".getEntity('invoice').")"; //$sql .= " AND (fk_statut <> 3 OR close_code <> 'abandon')"; // Not abandonned for undefined reason $sql .= " AND fk_statut <> 3"; // Not abandonned $sql .= " AND fk_statut <> 2"; // Not clasified as paid From 508fb5c9cb82234a6523a35560d3c10cce473091 Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Tue, 29 Jan 2019 11:13:11 +0100 Subject: [PATCH 033/115] =?UTF-8?q?Prise=20en=20charge=20des=20Travaux=20s?= =?UTF-8?q?uppl=C3=A9mentaires?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Corrige la filtration lors des situations client afin de prendre en compte la possibilité d'ajouter des travaux en cours de chantier. --- htdocs/core/tpl/objectline_view.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 313a4ee4def..ac2de384ddc 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -283,7 +283,7 @@ $domData .= ' data-product_type="'.$line->product_type.'"'; situation_counter == 1 || !$this->situation_cycle_ref) && empty($disableremove)) { + if (($line->fk_prev_id == NULL ) && empty($disableremove)) { //La suppression n'est autorisée que si il n'y a pas de ligne dans une précédente situation print 'id . '">'; print img_delete(); print ''; From 30548d977fc46ccb6dee6952e5523e2438a01745 Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Tue, 29 Jan 2019 11:19:11 +0100 Subject: [PATCH 034/115] =?UTF-8?q?Prise=20en=20charge=20des=20Travaux=20s?= =?UTF-8?q?uppl=C3=A9mentaires?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Corrige la filtration pour permettre l'ajout de ligne lors de la présence de travaux supplémentaires en cours de chantier. --- htdocs/compta/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 9ad79393499..bec4097935f 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4540,7 +4540,7 @@ else if ($id > 0 || ! empty($ref)) $ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1); // Form to add new line - if ($object->statut == 0 && $user->rights->facture->creer && $action != 'valid' && $action != 'editline' && ($object->is_first() || !$object->situation_cycle_ref)) + if ($object->statut == 0 && $usercancreate && $action != 'valid' && $action != 'editline') { if ($action != 'editline' && $action != 'selectlines') { From dd0f6b38290a6660b2a68b0bd1960cd882c1d110 Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Tue, 29 Jan 2019 11:30:14 +0100 Subject: [PATCH 035/115] =?UTF-8?q?Edition=20Ligne=20Travaux=20Suppl=C3=A9?= =?UTF-8?q?mentaires?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Correction pour permettre l'édition si la ligne n'existe pas dans une précédente situation. Permet l'édition d'une ligne si elle a été ajouté dans la situation actuelle. --- htdocs/core/tpl/objectline_edit.tpl.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index d3dc9807c5a..62387001de5 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -99,7 +99,7 @@ $coldisplay=-1; // We remove first td } // Do not allow editing during a situation cycle - if (empty($this->situation_cycle_ref) || $this->situation_counter == 1) + if ($line->fk_prev_id == NULL ) { // editeur wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; @@ -137,7 +137,7 @@ $coldisplay=-1; // We remove first td } $coldisplay++; - if ($this->situation_counter == 1 || !$this->situation_cycle_ref) { + if ($line->fk_prev_id == NULL ) { print '' . $form->load_tva('tva_tx', $line->tva_tx.($line->vat_src_code?(' ('.$line->vat_src_code.')'):''), $seller, $buyer, 0, $line->info_bits, $line->product_type, false, 1) . ''; } else { print '%'; @@ -145,7 +145,7 @@ $coldisplay=-1; // We remove first td $coldisplay++; print 'situation_counter > 1) print ' readonly'; + if ($line->fk_prev_id != NULL ) print ' readonly'; print '>'; if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { @@ -156,7 +156,7 @@ $coldisplay=-1; // We remove first td { $coldisplay++; print 'situation_counter > 1) print ' readonly'; + if ($line->fk_prev_id != NULL ) print ' readonly'; print '>'; } ?> @@ -167,7 +167,7 @@ $coldisplay=-1; // We remove first td // must also not be output for most entities (proposal, intervention, ...) //if($line->qty > $line->stock) print img_picto($langs->trans("StockTooLow"),"warning", 'style="vertical-align: bottom;"')." "; print 'situation_counter > 1) print ' readonly'; + if ($line->fk_prev_id != NULL ) print ' readonly'; print '>'; } else { ?>   @@ -186,7 +186,7 @@ $coldisplay=-1; // We remove first td info_bits & 2) != 2) { print 'situation_counter > 1) print ' readonly'; + if ($line->fk_prev_id != NULL ) print ' readonly'; print '>%'; } else { ?>   From f9b86225454e6a15f141fdec5c264fc45d0ae476 Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Tue, 29 Jan 2019 11:33:22 +0100 Subject: [PATCH 036/115] Prise en charge de Multicompany MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Correction pour éviter que les factures appartenant à d'autres entités n'apparaissent dans celle qui est consultée sur le moment. --- htdocs/fourn/recap-fourn.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/fourn/recap-fourn.php b/htdocs/fourn/recap-fourn.php index e680c18074e..577ffc6a99a 100644 --- a/htdocs/fourn/recap-fourn.php +++ b/htdocs/fourn/recap-fourn.php @@ -1,6 +1,7 @@ * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2019 Pierre Ardoin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -76,6 +77,7 @@ if ($socid > 0) $sql.= " u.login, u.rowid as userid"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture_fourn as f,".MAIN_DB_PREFIX."user as u"; $sql.= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$societe->id; + $sql.= " AND f.entity IN (".getEntity("facture_fourn").")"; // Reconaissance de l'entité attribuée à cette facture pour Multicompany $sql.= " AND f.fk_user_valid = u.rowid"; $sql.= " ORDER BY f.datef DESC"; From e75170137e5ded0c3bd1145c2b87ac71aac12ab1 Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Tue, 29 Jan 2019 11:42:44 +0100 Subject: [PATCH 037/115] =?UTF-8?q?Correction=20de=20la=20filtration=20de?= =?UTF-8?q?=20l'entit=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Corrige pour que la marge réalisée sur d'autres entités n'apparaisse pas sur celle sur laquelle l'utilisateur est connecté. --- htdocs/margin/tabs/productMargins.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/margin/tabs/productMargins.php b/htdocs/margin/tabs/productMargins.php index e6c51e2217d..3b826501614 100644 --- a/htdocs/margin/tabs/productMargins.php +++ b/htdocs/margin/tabs/productMargins.php @@ -147,7 +147,7 @@ if ($id > 0 || ! empty($ref)) if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE f.fk_soc = s.rowid"; $sql.= " AND f.fk_statut > 0"; - $sql.= " AND s.entity = ".$conf->entity; + $sql.= " AND f.entity IN (".getEntity('invoice').")"; $sql.= " AND d.fk_facture = f.rowid"; $sql.= " AND d.fk_product =".$object->id; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; From b6df02e795664a188d3f9981f49d7707b8594386 Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Tue, 29 Jan 2019 11:47:39 +0100 Subject: [PATCH 038/115] Correction oubli date de livraison Corrige l'oubli de la substitution de la date de livraison pour les commandes et demande de prix fournisseurs --- htdocs/core/lib/functions.lib.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 90167504f3f..792da337aac 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5993,6 +5993,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob $substitutionarray['__REF__'] = $object->ref; $substitutionarray['__REFCLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : '')); $substitutionarray['__REFSUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : ''); + $substitutionarray['__SUPPLIER_ORDER_DATE_DELIVERY__'] = (isset($object->date_livraison) ? dol_print_date($object->date_livraison, 'day', 0, $outputlangs): ''); // TODO Use this ? $msgishtml = 0; From 39b696af026dffc11362fc02ddae7436e861daa7 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 29 Jan 2019 12:01:40 +0100 Subject: [PATCH 039/115] FIX multicompany compatibility --- htdocs/comm/card.php | 2 +- htdocs/fourn/class/fournisseur.product.class.php | 3 ++- htdocs/societe/class/societe.class.php | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 2cf3c120af6..fc2c027713a 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -387,7 +387,7 @@ if ($object->id > 0) print ''.img_edit($langs->trans("Modify")).''; } print ''; - print ''.($object->remise_percent?''.$object->remise_percent.'%':'').''; + print ''.($object->remise_percent?''.price2num($object->remise_percent).'%':'').''; print ''; // Absolute discounts (Discounts-Drawbacks-Rebates) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 5c50597195a..781eaa3cd1e 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -653,11 +653,12 @@ class ProductFournisseur extends Product $sql.= " ,pfp.multicurrency_price, pfp.multicurrency_unitprice, pfp.multicurrency_tx, pfp.fk_multicurrency, pfp.multicurrency_code"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql.= " WHERE s.entity IN (".getEntity('societe').")"; + $sql.= " AND pfp.entity = ".$conf->entity; // only current entity $sql.= " AND pfp.fk_product = ".$prodid; $sql.= " AND pfp.fk_soc = s.rowid"; $sql.= " AND s.status = 1"; // only enabled society if ($qty > 0) $sql.= " AND pfp.quantity <= ".$qty; - if ($socid > 0) $sql.= ' AND pfp.fk_soc = '.$socid; + if ($socid > 0) $sql.= ' AND pfp.fk_soc = '.$socid; dol_syslog(get_class($this)."::find_min_price_product_fournisseur", LOG_DEBUG); diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index fcdf4e9741a..1b86c04bbc8 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1162,7 +1162,7 @@ class Societe extends CommonObject $sql .= ', s.fk_forme_juridique as forme_juridique_code'; $sql .= ', s.webservices_url, s.webservices_key'; $sql .= ', s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.parent, s.barcode'; - $sql .= ', s.fk_departement, s.fk_pays as country_id, s.fk_stcomm, s.remise_client, s.remise_supplier, s.mode_reglement, s.cond_reglement, s.fk_account, s.tva_assuj'; + $sql .= ', s.fk_departement, s.fk_pays as country_id, s.fk_stcomm, s.remise_supplier, s.mode_reglement, s.cond_reglement, s.fk_account, s.tva_assuj'; $sql .= ', s.mode_reglement_supplier, s.cond_reglement_supplier, s.localtax1_assuj, s.localtax1_value, s.localtax2_assuj, s.localtax2_value, s.fk_prospectlevel, s.default_lang, s.logo'; $sql .= ', s.fk_shipping_method'; $sql .= ', s.outstanding_limit, s.import_key, s.canvas, s.fk_incoterms, s.location_incoterms'; @@ -1175,6 +1175,7 @@ class Societe extends CommonObject $sql .= ', st.libelle as stcomm'; $sql .= ', te.code as typent_code'; $sql .= ', i.libelle as libelle_incoterms'; + $sql .= ', sr.remise_client'; $sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_effectif as e ON s.fk_effectif = e.id'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid'; @@ -1183,6 +1184,7 @@ class Societe extends CommonObject $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as te ON s.fk_typent = te.id'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON s.fk_incoterms = i.rowid'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_remise as sr ON sr.fk_soc = s.rowid AND sr.rowid = (SELECT MAX(rowid) FROM '.MAIN_DB_PREFIX.'societe_remise WHERE entity = '.$conf->entity.')'; $sql .= ' WHERE s.entity IN ('.getEntity($this->element).')'; if ($rowid) $sql .= ' AND s.rowid = '.$rowid; From 9539bea68ad112ad1c717e44aef843a618cb7a13 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 29 Jan 2019 12:17:51 +0100 Subject: [PATCH 040/115] FIX bad sql request --- htdocs/societe/class/societe.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 1b86c04bbc8..e4f5a32783c 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1184,7 +1184,7 @@ class Societe extends CommonObject $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_typent as te ON s.fk_typent = te.id'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON s.fk_incoterms = i.rowid'; - $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_remise as sr ON sr.fk_soc = s.rowid AND sr.rowid = (SELECT MAX(rowid) FROM '.MAIN_DB_PREFIX.'societe_remise WHERE entity = '.$conf->entity.')'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_remise as sr ON sr.rowid = (SELECT MAX(rowid) FROM '.MAIN_DB_PREFIX.'societe_remise WHERE fk_soc = s.rowid AND entity = '.$conf->entity.')'; $sql .= ' WHERE s.entity IN ('.getEntity($this->element).')'; if ($rowid) $sql .= ' AND s.rowid = '.$rowid; From 5ea1cf077502d05f7f89fd20a24113579a8726f5 Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Tue, 29 Jan 2019 14:25:34 +0100 Subject: [PATCH 041/115] Update objectline_edit.tpl.php --- htdocs/core/tpl/objectline_edit.tpl.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 62387001de5..00fc4f8e885 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -99,7 +99,7 @@ $coldisplay=-1; // We remove first td } // Do not allow editing during a situation cycle - if ($line->fk_prev_id == NULL ) + if ($line->fk_prev_id == null ) { // editeur wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; @@ -137,7 +137,7 @@ $coldisplay=-1; // We remove first td } $coldisplay++; - if ($line->fk_prev_id == NULL ) { + if ($line->fk_prev_id == null ) { print '' . $form->load_tva('tva_tx', $line->tva_tx.($line->vat_src_code?(' ('.$line->vat_src_code.')'):''), $seller, $buyer, 0, $line->info_bits, $line->product_type, false, 1) . ''; } else { print '%'; @@ -145,7 +145,7 @@ $coldisplay=-1; // We remove first td $coldisplay++; print 'fk_prev_id != NULL ) print ' readonly'; + if ($line->fk_prev_id != null ) print ' readonly'; print '>'; if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf->currency) { @@ -156,7 +156,7 @@ $coldisplay=-1; // We remove first td { $coldisplay++; print 'fk_prev_id != NULL ) print ' readonly'; + if ($line->fk_prev_id != null ) print ' readonly'; print '>'; } ?> @@ -167,7 +167,7 @@ $coldisplay=-1; // We remove first td // must also not be output for most entities (proposal, intervention, ...) //if($line->qty > $line->stock) print img_picto($langs->trans("StockTooLow"),"warning", 'style="vertical-align: bottom;"')." "; print 'fk_prev_id != NULL ) print ' readonly'; + if ($line->fk_prev_id != null ) print ' readonly'; print '>'; } else { ?>   @@ -186,7 +186,7 @@ $coldisplay=-1; // We remove first td info_bits & 2) != 2) { print 'fk_prev_id != NULL ) print ' readonly'; + if ($line->fk_prev_id != null ) print ' readonly'; print '>%'; } else { ?>   From 80cfe86508535e74b407fa118de6def4c69f8343 Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Tue, 29 Jan 2019 14:26:14 +0100 Subject: [PATCH 042/115] Update objectline_view.tpl.php --- htdocs/core/tpl/objectline_view.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index ac2de384ddc..e8ede7c59e7 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -283,7 +283,7 @@ $domData .= ' data-product_type="'.$line->product_type.'"'; fk_prev_id == NULL ) && empty($disableremove)) { //La suppression n'est autorisée que si il n'y a pas de ligne dans une précédente situation + if (($line->fk_prev_id == null ) && empty($disableremove)) { //La suppression n'est autorisée que si il n'y a pas de ligne dans une précédente situation print 'id . '">'; print img_delete(); print ''; From c6755b3cf1196c812f6095ef0dafa943f61eae47 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 29 Jan 2019 15:59:41 +0100 Subject: [PATCH 043/115] Fix formatting of number in quantity field --- htdocs/core/tpl/objectline_view.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 313a4ee4def..603412daf15 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -209,7 +209,7 @@ $domData .= ' data-product_type="'.$line->product_type.'"'; // for example always visible on invoice but must be visible only if stock module on and stock decrease option is on invoice validation and status is not validated // must also not be output for most entities (proposal, intervention, ...) //if($line->qty > $line->stock) print img_picto($langs->trans("StockTooLow"),"warning", 'style="vertical-align: bottom;"')." "; - echo $line->qty; + echo price($line->qty, 0, '', 0, 0); // Yes, it is a quantity, not a price, but we just want the formating role of function price } else echo ' '; ?> From 3477cf6bd3fc7c92425020a5e95beb53f906acce Mon Sep 17 00:00:00 2001 From: gauthier Date: Tue, 29 Jan 2019 18:01:28 +0100 Subject: [PATCH 044/115] FIX : must fetch member in current entity --- htdocs/user/class/user.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index ef2b828f6e5..42770041a5b 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1483,9 +1483,9 @@ class User extends CommonObject // This user is linked with a member, so we also update member information // if this is an update. $adh=new Adherent($this->db); - $result=$adh->fetch($this->fk_member); + $result=$adh->fetch('',$this->fk_member); - if ($result >= 0) + if ($result > 0) { $adh->firstname=$this->firstname; $adh->lastname=$this->lastname; @@ -1520,7 +1520,7 @@ class User extends CommonObject $error++; } } - else + elseif(!empty($adh->error) || !empty($adh->errors)) { $this->error=$adh->error; $this->errors=$adh->errors; From 99892c13b0eda7b26747701f14567e9ae0c79e72 Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Tue, 29 Jan 2019 23:26:08 +0100 Subject: [PATCH 045/115] FIX : Erreur dans le Total Corrige l'erreur de calcul dans le total des produits et services --- htdocs/product/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/index.php b/htdocs/product/index.php index 9f11813fdee..bfd6f6ad18f 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -184,7 +184,7 @@ else if ($type == '1') else { print $statProducts.$statServices; - $total=round($prodser[1][0])+round($prodser[1][1])+round($prodser[1][2])+round($prodser[0][0])+round($prodser[0][1])+round($prodser[0][2]); + $total=round($prodser[0][0])+round($prodser[0][1])+round($prodser[0][2])+round($prodser[0][3])+round($prodser[1][0])+round($prodser[1][1])+round($prodser[1][2])+round($prodser[1][3]); //Calcul du Total des Produits et Services } print ''.$langs->trans("Total").''; print $total; From 412940b5ca801747636a7941afcb9b063a2eab65 Mon Sep 17 00:00:00 2001 From: gauthier Date: Wed, 30 Jan 2019 10:19:13 +0100 Subject: [PATCH 046/115] FIX : $conf->fournisseur->commande->enabled doesn't exist, we must use $conf->fournisseur->enabled --- .../triggers/interface_20_modWorkflow_WorkflowManager.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index 94aaaeaa542..e478e265652 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -175,7 +175,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers dol_syslog( "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id ); // First classify billed the order to allow the proposal classify process - if (! empty($conf->fournisseur->commande->enabled) && ! empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER)) + if (! empty($conf->fournisseur->enabled) && ! empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER)) { $object->fetchObjectLinked('','order_supplier',$object->id,$object->element); if (! empty($object->linkedObjects)) From 94909292162a303223760a79da5a7d31c91e0ee0 Mon Sep 17 00:00:00 2001 From: gauthier Date: Wed, 30 Jan 2019 10:49:32 +0100 Subject: [PATCH 047/115] FIX : $conf->fournisseur->commande->enabled doesn't exist, we must use $conf->fournisseur->enabled --- .../triggers/interface_20_modWorkflow_WorkflowManager.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index 3c9880ef4ec..6ebbd24ac58 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -175,7 +175,7 @@ class InterfaceWorkflowManager extends DolibarrTriggers dol_syslog( "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id ); // First classify billed the order to allow the proposal classify process - if (! empty($conf->fournisseur->commande->enabled) && ! empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER)) + if (! empty($conf->fournisseur->enabled) && ! empty($conf->global->WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER)) { $object->fetchObjectLinked('','order_supplier',$object->id,$object->element); if (! empty($object->linkedObjects)) From 869159c09f41f5b585bdb93bd292f9518f000eb4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 30 Jan 2019 15:31:18 +0100 Subject: [PATCH 048/115] Fix regression in look and feel (if empty, we do not sho value) --- htdocs/comm/card.php | 2 +- htdocs/societe/class/societe.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index fc2c027713a..2cf3c120af6 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -387,7 +387,7 @@ if ($object->id > 0) print ''.img_edit($langs->trans("Modify")).''; } print ''; - print ''.($object->remise_percent?''.price2num($object->remise_percent).'%':'').''; + print ''.($object->remise_percent?''.$object->remise_percent.'%':'').''; print ''; // Absolute discounts (Discounts-Drawbacks-Rebates) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index e4f5a32783c..a78aaf83a9d 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1296,7 +1296,7 @@ class Societe extends CommonObject $this->prefix_comm = $obj->prefix_comm; - $this->remise_percent = $obj->remise_client; + $this->remise_percent = price2num($obj->remise_client); // 0.000000 must be 0 $this->remise_supplier_percent = $obj->remise_supplier; $this->mode_reglement_id = $obj->mode_reglement; $this->cond_reglement_id = $obj->cond_reglement; From 0c4e5a6487ec97d894df50bff72154462d0e486f Mon Sep 17 00:00:00 2001 From: gauthier Date: Thu, 31 Jan 2019 09:30:07 +0100 Subject: [PATCH 049/115] FIX : better test --- htdocs/user/class/user.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 42770041a5b..5a154be7478 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1483,9 +1483,9 @@ class User extends CommonObject // This user is linked with a member, so we also update member information // if this is an update. $adh=new Adherent($this->db); - $result=$adh->fetch('',$this->fk_member); + $result=$adh->fetch($this->fk_member); - if ($result > 0) + if ($result > 0 && $adh->entity == $conf->entity) { $adh->firstname=$this->firstname; $adh->lastname=$this->lastname; From 5e46a359e073a4eca38753579f3fd924723ede35 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 31 Jan 2019 10:16:49 +0100 Subject: [PATCH 050/115] FIX XSS --- htdocs/document.php | 2 +- htdocs/viewimage.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/document.php b/htdocs/document.php index 725d079a9f6..d912c9a2d55 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -77,7 +77,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $encoding = ''; $action=GETPOST('action','alpha'); -$original_file=GETPOST('file','alpha'); // Do not use urldecode here ($_GET are already decoded by PHP). +$original_file=GETPOST('file','alphanohtml'); // Do not use urldecode here ($_GET are already decoded by PHP). $hashp=GETPOST('hashp','aZ09'); $modulepart=GETPOST('modulepart','alpha'); $urlsource=GETPOST('urlsource','alpha'); diff --git a/htdocs/viewimage.php b/htdocs/viewimage.php index ae2a538ca04..17d5026c0bf 100644 --- a/htdocs/viewimage.php +++ b/htdocs/viewimage.php @@ -79,7 +79,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $action=GETPOST('action','alpha'); -$original_file=GETPOST('file','alpha'); // Do not use urldecode here ($_GET are already decoded by PHP). +$original_file=GETPOST('file','alphanohtml'); // Do not use urldecode here ($_GET are already decoded by PHP). $hashp=GETPOST('hashp','aZ09'); $modulepart=GETPOST('modulepart','alpha'); $urlsource=GETPOST('urlsource','alpha'); From 484b4371c137bb57303451a44de2aa61a6a50cfe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 31 Jan 2019 10:16:49 +0100 Subject: [PATCH 051/115] FIX XSS Conflicts: htdocs/viewimage.php --- htdocs/document.php | 2 +- htdocs/viewimage.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/document.php b/htdocs/document.php index 1c722e4cb55..ee8b9e9c096 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -81,7 +81,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $encoding = ''; $action=GETPOST('action','alpha'); -$original_file=GETPOST('file','alpha'); // Do not use urldecode here ($_GET are already decoded by PHP). +$original_file=GETPOST('file','alphanohtml'); // Do not use urldecode here ($_GET are already decoded by PHP). $hashp=GETPOST('hashp','aZ09'); $modulepart=GETPOST('modulepart','alpha'); $urlsource=GETPOST('urlsource','alpha'); diff --git a/htdocs/viewimage.php b/htdocs/viewimage.php index 7493ef6bee9..1053cc530c9 100644 --- a/htdocs/viewimage.php +++ b/htdocs/viewimage.php @@ -62,7 +62,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $action=GETPOST('action','alpha'); -$original_file=GETPOST("file",'alpha'); +$original_file=GETPOST('file','alphanohtml'); // Do not use urldecode here ($_GET are already decoded by PHP). $modulepart=GETPOST('modulepart','alpha'); $urlsource=GETPOST("urlsource",'alpha'); $entity=GETPOST('entity','int')?GETPOST('entity','int'):$conf->entity; From 09ba059c2198c0c59dcaa305283793fba3ae0de0 Mon Sep 17 00:00:00 2001 From: gauthier Date: Thu, 31 Jan 2019 11:03:06 +0100 Subject: [PATCH 052/115] FIX : need an order by in case we found other invoice with same number but not same date --- htdocs/core/modules/facture/mod_facture_mars.php | 1 + htdocs/core/modules/facture/mod_facture_terre.php | 1 + 2 files changed, 2 insertions(+) diff --git a/htdocs/core/modules/facture/mod_facture_mars.php b/htdocs/core/modules/facture/mod_facture_mars.php index 831dce5d3e4..08edc1b6b90 100644 --- a/htdocs/core/modules/facture/mod_facture_mars.php +++ b/htdocs/core/modules/facture/mod_facture_mars.php @@ -178,6 +178,7 @@ class mod_facture_mars extends ModeleNumRefFactures $sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " WHERE facnumber LIKE '".$prefix."____-".$num."'"; $sql.= " AND entity IN (".getEntity('invoicenumber').")"; + $sql.= " ORDER BY ref DESC"; dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); $resql=$db->query($sql); diff --git a/htdocs/core/modules/facture/mod_facture_terre.php b/htdocs/core/modules/facture/mod_facture_terre.php index 174d8314784..61a2f04c891 100644 --- a/htdocs/core/modules/facture/mod_facture_terre.php +++ b/htdocs/core/modules/facture/mod_facture_terre.php @@ -194,6 +194,7 @@ class mod_facture_terre extends ModeleNumRefFactures $sql.= " FROM ".MAIN_DB_PREFIX."facture"; $sql.= " WHERE facnumber LIKE '".$prefix."____-".$num."'"; $sql.= " AND entity IN (".getEntity('invoicenumber').")"; + $sql.= " ORDER BY ref DESC"; dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG); $resql=$db->query($sql); From bfc7265cbc7ce819277ae5f6d3e2ff842c83974c Mon Sep 17 00:00:00 2001 From: gauthier Date: Thu, 31 Jan 2019 11:53:10 +0100 Subject: [PATCH 053/115] FIX : better test on fetch --- htdocs/adherents/class/adherent.class.php | 4 ++-- htdocs/user/class/user.class.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index c7807bc6b00..0b3a4dd45d4 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -578,7 +578,7 @@ class Adherent extends CommonObject $lthirdparty=new Societe($this->db); $result=$lthirdparty->fetch($this->fk_soc); - if ($result >= 0) + if ($result > 0) { $lthirdparty->address=$this->address; $lthirdparty->zip=$this->zip; @@ -600,7 +600,7 @@ class Adherent extends CommonObject $error++; } } - else + elseif(!empty($lthirdparty->error)) { $this->error=$lthirdparty->error; $error++; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index 5a154be7478..e305439e34a 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1485,7 +1485,7 @@ class User extends CommonObject $adh=new Adherent($this->db); $result=$adh->fetch($this->fk_member); - if ($result > 0 && $adh->entity == $conf->entity) + if ($result > 0) { $adh->firstname=$this->firstname; $adh->lastname=$this->lastname; From caa937660d4b26b7e6e04407e92610da34095c50 Mon Sep 17 00:00:00 2001 From: gauthier Date: Thu, 31 Jan 2019 12:43:39 +0100 Subject: [PATCH 054/115] FIX : wrong test enabled --- htdocs/supplier_proposal/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index 8c2bfb8090a..7a56d73afff 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -1725,7 +1725,7 @@ if ($action == 'create') } // Create an order - if (! empty($conf->commande->enabled) && $object->statut == SupplierProposal::STATUS_SIGNED) { + if (! empty($conf->fournisseur->enabled) && $object->statut == SupplierProposal::STATUS_SIGNED) { if ($user->rights->fournisseur->commande->creer) { print ''; } From 14dea537003e631bbc5dd1beaa7088d58dfc6fca Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 31 Jan 2019 15:51:02 +0100 Subject: [PATCH 055/115] FIX Missing field in import/export of users --- htdocs/core/modules/modUser.class.php | 61 ++++++++++++++++++++------- 1 file changed, 45 insertions(+), 16 deletions(-) diff --git a/htdocs/core/modules/modUser.class.php b/htdocs/core/modules/modUser.class.php index 355089a09e1..b37fb900d29 100644 --- a/htdocs/core/modules/modUser.class.php +++ b/htdocs/core/modules/modUser.class.php @@ -216,23 +216,43 @@ class modUser extends DolibarrModules $r++; $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]='Liste des utilisateurs Dolibarr et attributs'; + $this->export_label[$r]='List of users and attributes'; $this->export_permission[$r]=array(array("user","user","export")); $this->export_fields_array[$r]=array( - 'u.rowid'=>"Id",'u.login'=>"Login",'u.lastname'=>"Lastname",'u.firstname'=>"Firstname",'u.accountancy_code'=>"UserAccountancyCode", - 'u.office_phone'=>'Phone','u.office_fax'=>'Fax','u.email'=>'EMail','u.datec'=>"DateCreation",'u.tms'=>"DateLastModification", - 'u.admin'=>"Administrator",'u.statut'=>'Status','u.note'=>"Note",'u.datelastlogin'=>'LastConnexion','u.datepreviouslogin'=>'PreviousConnexion', + 'u.rowid'=>"Id",'u.login'=>"Login",'u.lastname'=>"Lastname",'u.firstname'=>"Firstname",'u.employee'=>"Employee",'u.job'=>"PostOrFunction",'u.gender'=>"Gender", + 'u.accountancy_code'=>"UserAccountancyCode", + 'u.address'=>"Address",'u.zip'=>"Zip",'u.town'=>"Town", + 'u.office_phone'=>'Phone','u.user_mobile'=>"Mobile",'u.office_fax'=>'Fax', + 'u.email'=>"Email",'u.note'=>"Note",'u.signature'=>'Signature', + 'u.fk_user'=>'Supervisor','u.thm'=>'THM','u.tjm'=>'TJM','u.weeklyhours'=>'WeeklyHours', + 'u.dateemployment'=>'DateEmployment','u.salary'=>'Salary','u.color'=>'Color','u.api_key'=>'ApiKey', + 'u.birth'=>'BirthdayDate', + 'u.datec'=>"DateCreation",'u.tms'=>"DateLastModification", + 'u.admin'=>"Administrator",'u.statut'=>'Status','u.datelastlogin'=>'LastConnexion','u.datepreviouslogin'=>'PreviousConnexion', 'u.fk_socpeople'=>"IdContact",'u.fk_soc'=>"IdCompany",'u.fk_member'=>"MemberId" ); $this->export_TypeFields_array[$r]=array( - 'u.login'=>"Text",'u.lastname'=>"Text",'u.firstname'=>"Text",'u.accountancy_code'=>'Text','u.office_phone'=>'Text','u.office_fax'=>'Text', + 'u.login'=>"Text",'u.lastname'=>"Text",'u.firstname'=>"Text",'u.employee'=>'Boolean','u.job'=>'Text', + 'u.accountancy_code'=>'Text', + 'u.address'=>"Text",'u.zip'=>"Text",'u.town'=>"Text", + 'u.office_phone'=>'Text','u.user_mobile'=>'Text','u.office_fax'=>'Text', 'u.email'=>'Text','u.datec'=>"Date",'u.tms'=>"Date",'u.admin'=>"Boolean",'u.statut'=>'Status','u.note'=>"Text",'u.datelastlogin'=>'Date', - 'u.datepreviouslogin'=>'Date','u.fk_soc'=>"List:societe:nom:rowid",'u.fk_member'=>"List:adherent:firstname" + 'u.fk_user'=>"List:user:login", + 'u.birth'=>'Date', + 'u.datepreviouslogin'=>'Date','u.fk_soc'=>"List:societe:nom:rowid",'u.fk_member'=>"List:adherent:firstname" ); $this->export_entities_array[$r]=array( - 'u.rowid'=>"user",'u.login'=>"user",'u.lastname'=>"user",'u.firstname'=>"user",'u.accountancy_code'=>'user','u.office_phone'=>'user', - 'u.office_fax'=>'user','u.email'=>'user','u.datec'=>"user",'u.tms'=>"user",'u.admin'=>"user",'u.statut'=>'user','u.note'=>"user", - 'u.datelastlogin'=>'user','u.datepreviouslogin'=>'user','u.fk_socpeople'=>"contact",'u.fk_soc'=>"company",'u.fk_member'=>"member" + 'u.rowid'=>"user",'u.login'=>"user",'u.lastname'=>"user",'u.firstname'=>"user",'u.employee'=>'user','u.job'=>'user','u.gender'=>'user', + 'u.accountancy_code'=>'user', + 'u.address'=>"user",'u.zip'=>"user",'u.town'=>"user", + 'u.office_phone'=>'user','u.user_mobile'=>'user','u.office_fax'=>'user', + 'u.email'=>'user','u.note'=>"user",'u.signature'=>'user', + 'u.fk_user'=>'user','u.thm'=>'user','u.tjm'=>'user','u.weeklyhours'=>'user', + 'u.dateemployment'=>'user','u.salary'=>'user','u.color'=>'user','u.api_key'=>'user', + 'u.birth'=>'user', + 'u.datec'=>"user",'u.tms'=>"user", + 'u.admin'=>"user",'u.statut'=>'user','u.datelastlogin'=>'user','u.datepreviouslogin'=>'user', + 'u.fk_socpeople'=>"contact",'u.fk_soc'=>"company",'u.fk_member'=>"member" ); if (empty($conf->adherent->enabled)) { @@ -255,11 +275,17 @@ class modUser extends DolibarrModules $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon $this->import_tables_array[$r]=array('u'=>MAIN_DB_PREFIX.'user','extra'=>MAIN_DB_PREFIX.'user_extrafields'); // List of tables to insert into (insert done in same order) $this->import_fields_array[$r]=array( - 'u.lastname'=>"Name*",'u.firstname'=>"Firstname",'u.employee'=>"Employee*",'u.job'=>"Job",'u.gender'=>"Gender",'u.login'=>"Login*", + 'u.login'=>"Login*",'u.lastname'=>"Name*",'u.firstname'=>"Firstname",'u.employee'=>"Employee*",'u.job'=>"PostOrFunction",'u.gender'=>"Gender", + 'u.accountancy_code'=>"UserAccountancyCode", 'u.pass_crypted'=>"Password",'u.admin'=>"Administrator",'u.fk_soc'=>"Company*",'u.address'=>"Address",'u.zip'=>"Zip",'u.town'=>"Town", - 'u.fk_state'=>"StateId",'u.fk_country'=>"CountryCode",'u.office_phone'=>"Phone",'u.user_mobile'=>"Mobile",'u.office_fax'=>"Fax", - 'u.email'=>"Email",'u.note'=>"Note",'u.signature'=>'Signature','u.fk_user'=>'Supervisor','u.thm'=>'THM','u.tjm'=>'TJM', - 'u.dateemployment'=>'DateEmployment','u.salary'=>'Salary','u.color'=>'Color','u.api_key'=>'ApiKey','u.datec'=>"DateCreation" + 'u.fk_state'=>"StateId",'u.fk_country'=>"CountryCode", + 'u.office_phone'=>"Phone",'u.user_mobile'=>"Mobile",'u.office_fax'=>"Fax", + 'u.email'=>"Email",'u.note'=>"Note",'u.signature'=>'Signature', + 'u.fk_user'=>'Supervisor','u.thm'=>'THM','u.tjm'=>'TJM','u.weeklyhours'=>'WeeklyHours', + 'u.dateemployment'=>'DateEmployment','u.salary'=>'Salary','u.color'=>'Color','u.api_key'=>'ApiKey', + 'u.birth'=>'BirthdayDate', + 'u.datec'=>"DateCreation", + 'u.statut'=>'Status' ); // Add extra fields $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'user' AND entity IN (0,".$conf->entity.")"; @@ -283,13 +309,16 @@ class modUser extends DolibarrModules //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t'); $this->import_regex_array[$r]=array( 'u.employee'=>'^[0|1]', - 'u.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$' + 'u.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$', + 'u.dateemployment'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', + 'u.birth'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$' ); $this->import_examplevalues_array[$r]=array( - 'u.lastname'=>"Doe",'u.firstname'=>'John','u.login'=>'jdoe','u.employee'=>'0 or 1','u.status'=>"0 (closed) or 1 (active)", + 'u.lastname'=>"Doe",'u.firstname'=>'John','u.login'=>'jdoe','u.employee'=>'0 or 1', 'u.fk_soc'=>'0 (internal user) or company name (external user)','u.datec'=>dol_print_date(dol_now(),'%Y-%m-%d'),'u.address'=>"61 jump street", 'u.zip'=>"123456",'u.town'=>"Big town",'u.fk_country'=>'US, FR, DE...','u.office_phone'=>"0101010101",'u.office_fax'=>"0101010102", - 'u.email'=>"test@mycompany.com",'u.salary'=>"10000",'u.note'=>"This is an example of note for record",'u.datec'=>"2015-01-01 or 2015-01-01 12:30:00" + 'u.email'=>"test@mycompany.com",'u.salary'=>"10000",'u.note'=>"This is an example of note for record",'u.datec'=>"2015-01-01 or 2015-01-01 12:30:00", + 'u.statut'=>"0 (closed) or 1 (active)", ); $this->import_updatekeys_array[$r]=array('u.lastname'=>'Lastname','u.firstname'=>'Firstname','u.login'=>'Login'); From 2d6f5ca8abad4d5b67d68c86407bfa1e1f3824c0 Mon Sep 17 00:00:00 2001 From: Pierre Ardoin <32256817+mapiolca@users.noreply.github.com> Date: Thu, 31 Jan 2019 20:22:56 +0100 Subject: [PATCH 056/115] #Fix : Error in Total Products/Services Its correct an error in the total of stat Products/Services total. --- htdocs/product/index.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/product/index.php b/htdocs/product/index.php index bfd6f6ad18f..04c001c8bc2 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2014-2016 Charlie BENKE * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2019 Pierre Ardoin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -174,12 +175,12 @@ $total=0; if ($type == '0') { print $statProducts; - $total=round($prodser[0][0])+round($prodser[0][1])+round($prodser[0][2]); + $total=round($prodser[0][0])+round($prodser[0][1])+round($prodser[0][2])+round($prodser[0][3]); } else if ($type == '1') { print $statServices; - $total=round($prodser[1][0])+round($prodser[1][1])+round($prodser[1][2]); + $total=round($prodser[1][0])+round($prodser[1][1])+round($prodser[1][2])+round($prodser[1][3]); } else { From f7bed44441dc1e9f61c085fa9b658b53f903b01e Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Thu, 31 Jan 2019 21:39:02 +0100 Subject: [PATCH 057/115] FIX : quick search for supplier orders --- htdocs/fourn/commande/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index f018b9574d1..d26c950d4fe 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -55,7 +55,7 @@ $search_deliveryyear=GETPOST("search_deliveryyear","int"); $search_deliverymonth=GETPOST("search_deliverymonth","int"); $search_deliveryday=GETPOST("search_deliveryday","int"); -$sall=GETPOST('search_all', 'alphanohtml'); +$sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); $search_product_category=GETPOST('search_product_category','int'); $search_ref=GETPOST('search_ref'); $search_refsupp=GETPOST('search_refsupp'); From 75845a990f6d33f74d39173faca5428cbc08e7f9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Feb 2019 22:55:28 +0100 Subject: [PATCH 058/115] FIX Missing province in export of invoice --- htdocs/core/modules/modFacture.class.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index dc7448fc8f2..9951f4b2d31 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -209,7 +209,8 @@ class modFacture extends DolibarrModules $this->export_icon[$r] = 'invoice'; $this->export_permission[$r] = array(array("facture", "facture", "export", "other")); $this->export_fields_array[$r] = array( - 's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.code_client'=>'CustomerCode', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'c.code'=>'CountryCode', 's.phone'=>'Phone', + 's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.code_client'=>'CustomerCode', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'c.code'=>'CountryCode', 'cd.nom'=>'State', + 's.phone'=>'Phone', 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.code_compta'=>'CustomerAccountancyCode', 's.code_compta_fournisseur'=>'SupplierAccountancyCode', 's.tva_intra'=>'VATIntra', 'f.rowid'=>"InvoiceId", 'f.facnumber'=>"InvoiceRef", 'f.ref_client'=>'RefCustomer', @@ -231,7 +232,7 @@ class modFacture extends DolibarrModules $this->export_fields_array[$r]['f.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC'; } $this->export_TypeFields_array[$r] = array( - 's.rowid'=>'Numeric', 's.nom'=>'Text', 's.code_client'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', + 's.rowid'=>'Numeric', 's.nom'=>'Text', 's.code_client'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 'cd.nom'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 's.tva_intra'=>'Text', 'f.rowid'=>'Numeric', 'f.facnumber'=>"Text", 'f.ref_client'=>'Text', 'f.type'=>"Numeric", 'f.datec'=>"Date", 'f.datef'=>"Date", 'f.date_lim_reglement'=>"Date", 'f.total'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.tva'=>"Numeric", 'none.rest'=>"NumericCompute", 'f.paye'=>"Boolean", 'f.fk_statut'=>'Numeric', @@ -261,7 +262,8 @@ class modFacture extends DolibarrModules $this->export_sql_start[$r] = 'SELECT DISTINCT '; $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'societe as s'; if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; - $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c on s.fk_pays = c.rowid,'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c on s.fk_pays = c.rowid'; + $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as cd on s.fk_departement = cd.rowid,'; $this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'facture as f'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON f.fk_projet = pj.rowid'; $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as uc ON f.fk_user_author = uc.rowid'; @@ -281,7 +283,8 @@ class modFacture extends DolibarrModules $this->export_icon[$r] = 'invoice'; $this->export_permission[$r] = array(array("facture", "facture", "export")); $this->export_fields_array[$r] = array( - 's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.code_client'=>'CustomerCode', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'c.code'=>'CountryCode', 's.phone'=>'Phone', + 's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.code_client'=>'CustomerCode', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'c.code'=>'CountryCode', 'cd.nom'=>'State', + 's.phone'=>'Phone', 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.code_compta'=>'CustomerAccountancyCode', 's.code_compta_fournisseur'=>'SupplierAccountancyCode', 's.tva_intra'=>'VATIntra', 'f.rowid'=>"InvoiceId", 'f.facnumber'=>"InvoiceRef", 'f.ref_client'=>'RefCustomer', @@ -301,7 +304,7 @@ class modFacture extends DolibarrModules $this->export_fields_array[$r]['f.multicurrency_total_ttc'] = 'MulticurrencyAmountTTC'; } $this->export_TypeFields_array[$r] = array( - 's.rowid'=>'Numeric', 's.nom'=>'Text', 's.code_client'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', + 's.rowid'=>'Numeric', 's.nom'=>'Text', 's.code_client'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'c.code'=>'Text', 'cd.nom'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 's.tva_intra'=>'Text', 'f.rowid'=>"Numeric", 'f.facnumber'=>"Text", 'f.ref_client'=>'Text', 'f.type'=>"Numeric", 'f.datec'=>"Date", 'f.datef'=>"Date", 'f.date_lim_reglement'=>"Date", 'f.total'=>"Numeric", 'f.total_ttc'=>"Numeric", 'f.tva'=>"Numeric", 'none.rest'=>'NumericCompute', 'f.paye'=>"Boolean", 'f.fk_statut'=>'Status', @@ -323,7 +326,8 @@ class modFacture extends DolibarrModules $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s'; if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c on s.fk_pays = c.rowid,'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c on s.fk_pays = c.rowid'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as cd on s.fk_departement = cd.rowid,'; $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'facture as f'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'projet as pj ON f.fk_projet = pj.rowid'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'user as uc ON f.fk_user_author = uc.rowid'; From bb3225809be41560e257b5b9a0d0f2a47db9444d Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 2 Feb 2019 18:43:25 +0100 Subject: [PATCH 059/115] Fix warehouse fetch was not checking parameters. Fixes #10414 --- htdocs/product/stock/class/entrepot.class.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 039918ea66c..add121b902e 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -308,6 +308,16 @@ class Entrepot extends CommonObject { global $conf; + dol_syslog(get_class($this)."::fetch id=".$id." ref=".$ref); + + // Check parameters + if (! $id && ! $ref) + { + $this->error='ErrorWrongParameters'; + dol_syslog(get_class($this)."::fetch ".$this->error); + return -1; + } + $sql = "SELECT rowid, fk_parent, ref as label, description, statut, lieu, address, zip, town, fk_pays as country_id"; $sql .= " FROM ".MAIN_DB_PREFIX."entrepot"; if ($id) @@ -320,7 +330,6 @@ class Entrepot extends CommonObject if ($ref) $sql.= " AND ref = '".$this->db->escape($ref)."'"; } - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $result = $this->db->query($sql); if ($result) { From 62d677118dc70d6cc7517bbd458b1094e5807167 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 3 Feb 2019 19:24:18 +0100 Subject: [PATCH 060/115] Update adherent.class.php --- htdocs/adherents/class/adherent.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 0b3a4dd45d4..ac3e6890cf4 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -600,7 +600,7 @@ class Adherent extends CommonObject $error++; } } - elseif(!empty($lthirdparty->error)) + elseif ($result < 0) { $this->error=$lthirdparty->error; $error++; @@ -689,7 +689,6 @@ class Adherent extends CommonObject $this->db->rollback(); return -1; } - } /** From bd2c7092a47737f0a38859ed9bf9cd27e6b68e42 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 3 Feb 2019 19:25:11 +0100 Subject: [PATCH 061/115] Update user.class.php --- htdocs/user/class/user.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index e305439e34a..1b414795c24 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1520,7 +1520,7 @@ class User extends CommonObject $error++; } } - elseif(!empty($adh->error) || !empty($adh->errors)) + elseif ($result < 0) { $this->error=$adh->error; $this->errors=$adh->errors; From 72f78ecf3b170e0d95e6e5acdfa27ce49d7193f5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 3 Feb 2019 20:02:05 +0100 Subject: [PATCH 062/115] FIX #10460 compatibility with MariaDB 10.4 --- htdocs/comm/action/class/actioncomm.class.php | 3 +-- htdocs/core/boxes/box_actions.php | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index be8ad550b39..07ebcef2f8d 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1020,8 +1020,7 @@ class ActionComm extends CommonObject $this->nb=array(); $sql = "SELECT count(a.id) as nb"; } - $sql.= " FROM (".MAIN_DB_PREFIX."actioncomm as a"; - $sql.= ")"; + $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a"; if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; $sql.= " WHERE 1 = 1"; diff --git a/htdocs/core/boxes/box_actions.php b/htdocs/core/boxes/box_actions.php index f6d9d03dccf..565634ec95b 100644 --- a/htdocs/core/boxes/box_actions.php +++ b/htdocs/core/boxes/box_actions.php @@ -85,8 +85,7 @@ class box_actions extends ModeleBoxes $sql.= ", s.nom as name"; $sql.= ", s.rowid as socid"; $sql.= ", s.code_client"; - $sql.= " FROM (".MAIN_DB_PREFIX."c_actioncomm AS ta, "; - $sql.= MAIN_DB_PREFIX."actioncomm AS a)"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm AS ta, ".MAIN_DB_PREFIX."actioncomm AS a"; if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; $sql.= " WHERE a.fk_action = ta.id"; From cdfeeafab98e6e518379d36bc55e0860fd3b92aa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 3 Feb 2019 21:12:05 +0100 Subject: [PATCH 063/115] FIX #10381 --- htdocs/compta/localtax/index.php | 6 +++--- htdocs/compta/tva/index.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/localtax/index.php b/htdocs/compta/localtax/index.php index c62034ee65c..0c96f728fd6 100644 --- a/htdocs/compta/localtax/index.php +++ b/htdocs/compta/localtax/index.php @@ -120,7 +120,7 @@ function pt($db, $sql, $date) if ($obj->mode == 'claimed' && ! empty($previousmode)) { print ''; - print ''.$obj->dm."\n"; + print ''.$previousmonth."\n"; print ''.price($amountclaimed)."\n"; print ''.price($amountpaid)."\n"; print "\n"; @@ -270,7 +270,7 @@ $mend = $tmp['mon']; $total=0; $subtotalcoll=0; $subtotalpaye=0; $subtotal=0; $i=0; $mcursor=0; -while ((($y < $yend) || ($y == $yend && $m < $mend)) && $mcursor < 1000) // $mcursor is to avoid too large loop +while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mcursor is to avoid too large loop { //$m = $conf->global->SOCIETE_FISCAL_MONTH_START + ($mcursor % 12); if ($m == 13) $y++; @@ -535,7 +535,7 @@ while ((($y < $yend) || ($y == $yend && $m < $mend)) && $mcursor < 1000) // $mcu if ($i > 2) { print ''; - print ''.$langs->trans("SubTotal").':'; + print ''.$langs->trans("SubTotal").':'; print ''.price(price2num($subtotalcoll,'MT')).''; print ''.price(price2num($subtotalpaye,'MT')).''; print ''.price(price2num($subtotal,'MT')).''; diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index 5c346ca9ced..6b0c2875d42 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -504,7 +504,7 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mc if ($i > 2) { print ''; - print ''.$langs->trans("SubTotal").':'; + print ''.$langs->trans("SubTotal").':'; print ''.price(price2num($subtotalcoll,'MT')).''; print ''.price(price2num($subtotalpaye,'MT')).''; print ''.price(price2num($subtotal,'MT')).''; From 4a19cba257b20552b0e41849b323e09fd0f7b110 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 5 Feb 2019 06:34:05 +0100 Subject: [PATCH 064/115] FIX [URGENT] broken feature, "$usercancreate" is for Dolibarr 9 --- htdocs/compta/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 4881e42abf1..73b2bfdb314 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -4551,7 +4551,7 @@ else if ($id > 0 || ! empty($ref)) $ret = $object->printObjectLines($action, $mysoc, $soc, $lineid, 1); // Form to add new line - if ($object->statut == 0 && $usercancreate && $action != 'valid' && $action != 'editline') + if ($object->statut == 0 && $user->rights->facture->creer && $action != 'valid' && $action != 'editline') { if ($action != 'editline' && $action != 'selectlines') { From 730a2a90fffb43bf47acd605a3ac4e584608a3a8 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Tue, 5 Feb 2019 09:43:14 +0100 Subject: [PATCH 065/115] FIX supplier invoice product stats total ht is line total not invoice total --- htdocs/product/stats/facture_fournisseur.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/product/stats/facture_fournisseur.php b/htdocs/product/stats/facture_fournisseur.php index 6bd722220ba..a31d94ada69 100644 --- a/htdocs/product/stats/facture_fournisseur.php +++ b/htdocs/product/stats/facture_fournisseur.php @@ -126,7 +126,7 @@ if ($id > 0 || ! empty($ref)) if ($user->rights->fournisseur->facture->lire) { - $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client, d.rowid, d.total_ht as total_ht,"; + $sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client, d.rowid, d.total_ht as line_total_ht,"; $sql .= " f.rowid as facid, f.ref, f.ref_supplier, f.datef, f.libelle, f.total_ht, f.total_ttc, f.total_tva, f.paye, f.fk_statut as statut, d.qty"; if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user "; @@ -205,7 +205,7 @@ if ($id > 0 || ! empty($ref)) print_liste_field_titre("SupplierCode", $_SERVER["PHP_SELF"], "s.code_client", "", $option, '', $sortfield, $sortorder); print_liste_field_titre("DateInvoice", $_SERVER["PHP_SELF"], "f.datef", "", $option, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("Qty", $_SERVER["PHP_SELF"], "d.qty", "", $option, 'align="center"', $sortfield, $sortorder); - print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "f.total_ht", "", $option, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("AmountHT", $_SERVER["PHP_SELF"], "d.total_ht", "", $option, 'align="right"', $sortfield, $sortorder); print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "f.paye,f.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder); print "\n"; @@ -215,7 +215,7 @@ if ($id > 0 || ! empty($ref)) { $objp = $db->fetch_object($result); - $total_ht+=$objp->total_ht; + $total_ht+=$objp->line_total_ht; $total_qty+=$objp->qty; $supplierinvoicestatic->id = $objp->facid; @@ -237,7 +237,7 @@ if ($id > 0 || ! empty($ref)) print ''; print dol_print_date($db->jdate($objp->datef), 'dayhour') . ""; print '' . $objp->qty . "\n"; - print '' . price($objp->total_ht) . "\n"; + print '' . price($objp->line_total_ht) . "\n"; print '' . $supplierinvoicestatic->LibStatut($objp->paye, $objp->statut, 5) . ''; print "\n"; $i++; From da0c863f459387d0f2dcbd7d79a3f62c70d002f6 Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Tue, 5 Feb 2019 10:30:38 +0100 Subject: [PATCH 066/115] FIX supplier invoice payment total dont care about deposit or credit --- htdocs/fourn/facture/paiement.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 74593cb8675..8a87d4903a1 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -602,7 +602,10 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''.price($objp->total_ttc).''; - print ''.price($objp->am).''; + print ''.price($objp->am); + if ($creditnotes) print '+'.price($creditnotes); + if ($deposits) print '+'.price($deposits); + print ''; print ''.price($remaintopay).''; @@ -657,6 +660,8 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie $total+=$objp->total_ht; $total_ttc+=$objp->total_ttc; $totalrecu+=$objp->am; + $totalrecucreditnote+=$creditnotes; + $totalrecudeposits+=$deposits; $i++; } if ($i > 1) @@ -669,8 +674,11 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie if (!empty($conf->multicurrency->enabled)) print ' '; if (!empty($conf->multicurrency->enabled)) print ' '; print ''.price($total_ttc).''; - print ''.price($totalrecu).''; - print ''.price($total_ttc - $totalrecu).''; + print ''.price($totalrecu); + if ($totalrecucreditnote) print '+'.price($totalrecucreditnote); + if ($totalrecudeposits) print '+'.price($totalrecudeposits); + print ''; + print ''.price(price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits,'MT')).''; print ''; // Autofilled if (!empty($conf->multicurrency->enabled)) print ''; print "\n"; From 64739098ae31d8277a145784fa45863f7f65baf7 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Tue, 5 Feb 2019 11:58:49 +0100 Subject: [PATCH 067/115] FIX: expedition: reset status on rollback + replace hardcoded status with const --- htdocs/expedition/class/expedition.class.php | 21 +++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index b4e4e0c8614..d7960d6ff52 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -538,7 +538,7 @@ class Expedition extends CommonObject $this->db->free($result); - if ($this->statut == 0) $this->brouillon = 1; + if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1; // Tracking url $this->GetUrlTrackingStatus($obj->tracking_number); @@ -783,7 +783,7 @@ class Expedition extends CommonObject if (! $error) { $this->ref = $numref; - $this->statut = 1; + $this->statut = self::STATUS_VALIDATED; } if (! $error) @@ -816,7 +816,7 @@ class Expedition extends CommonObject if ($conf->livraison_bon->enabled) { - if ($this->statut == 1 || $this->statut == 2) + if ($this->statut == self::STATUS_VALIDATED || $this->statut == self::STATUS_CLOSED) { // Expedition validee include_once DOL_DOCUMENT_ROOT.'/livraison/class/livraison.class.php'; @@ -1111,7 +1111,7 @@ class Expedition extends CommonObject $this->db->begin(); // Stock control - if ($conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_SHIPMENT && $this->statut > 0) + if ($conf->stock->enabled && $conf->global->STOCK_CALCULATE_ON_SHIPMENT && $this->statut > self::STATUS_DRAFT) { require_once(DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php"); @@ -1663,7 +1663,7 @@ class Expedition extends CommonObject $this->id=0; $this->ref = 'SPECIMEN'; $this->specimen=1; - $this->statut = 1; + $this->statut = self::STATUS_VALIDATED; $this->livraison_id = 0; $this->date = $now; $this->date_creation = $now; @@ -2037,6 +2037,7 @@ class Expedition extends CommonObject } else { + $this->statut = self::STATUS_VALIDATED; $this->db->rollback(); return -1; } @@ -2060,7 +2061,7 @@ class Expedition extends CommonObject $resql=$this->db->query($sql); if ($resql) { - $this->statut=2; + $this->statut=self::STATUS_CLOSED; $this->billed=1; // Call trigger @@ -2080,6 +2081,8 @@ class Expedition extends CommonObject } else { + $this->statut=self::STATUS_VALIDATED; + $this->billed=0; $this->db->rollback(); return -1; } @@ -2104,13 +2107,15 @@ class Expedition extends CommonObject $this->db->begin(); + $oldbilled=$this->billed; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'expedition SET fk_statut=1'; $sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0'; $resql=$this->db->query($sql); if ($resql) { - $this->statut=1; + $this->statut=self::STATUS_VALIDATED; $this->billed=0; // If stock increment is done on closing @@ -2208,6 +2213,8 @@ class Expedition extends CommonObject } else { + $this->statut=self::STATUS_CLOSED; + $this->billed=$oldbilled; $this->db->rollback(); return -1; } From 428efa922797502740342eac001a70e53a20c5db Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Tue, 5 Feb 2019 12:02:49 +0100 Subject: [PATCH 068/115] FIX: line edit template: keep fk_parent_line --- htdocs/core/tpl/objectline_edit.tpl.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/core/tpl/objectline_edit.tpl.php b/htdocs/core/tpl/objectline_edit.tpl.php index 41d419694e8..b5d2f035695 100644 --- a/htdocs/core/tpl/objectline_edit.tpl.php +++ b/htdocs/core/tpl/objectline_edit.tpl.php @@ -69,9 +69,13 @@ $coldisplay=-1; // We remove first td + fk_product > 0) { ?> + fk_parent_line > 0) echo img_picto('', 'rightarrow'); + ?> product_type==1) echo img_object($langs->trans('ShowService'),'service'); From 95cc9faf7e0978228627a6331b78db1e9e0cd65b Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 6 Feb 2019 09:01:24 +0100 Subject: [PATCH 069/115] fix php warning --- htdocs/core/class/commondocgenerator.class.php | 12 ++++++++---- htdocs/imports/import.php | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 18e2817f040..214c47fc20d 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -340,6 +340,8 @@ abstract class CommonDocGenerator global $conf; $sumpayed=$sumdeposit=$sumcreditnote=''; + $already_payed_all=0; + $remain_to_pay=0; if ($object->element == 'facture') { $invoice_source=new Facture($this->db); @@ -350,6 +352,8 @@ abstract class CommonDocGenerator $sumpayed = $object->getSommePaiement(); $sumdeposit = $object->getSumDepositsUsed(); $sumcreditnote = $object->getSumCreditNotesUsed(); + $already_payed_all=$sumpayed + $sumdeposit + $sumcreditnote; + $remain_to_pay=$sumpayed - $sumdeposit - $sumcreditnote; } $date = ($object->element == 'contrat' ? $object->date_contrat : $object->date); @@ -411,12 +415,12 @@ abstract class CommonDocGenerator $array_key.'_already_creditnote_locale'=>price($sumcreditnote, 0, $outputlangs), $array_key.'_already_creditnote'=>price2num($sumcreditnote), - $array_key.'_already_payed_all_locale'=>price(price2num($sumpayed + $sumdeposit + $sumcreditnote, 'MT'), 0, $outputlangs), - $array_key.'_already_payed_all'=> price2num(($sumpayed + $sumdeposit + $sumcreditnote), 'MT'), + $array_key.'_already_payed_all_locale'=>price(price2num($already_payed_all, 'MT'), 0, $outputlangs), + $array_key.'_already_payed_all'=> price2num($already_payed_all, 'MT'), // Remain to pay with all know infrmation (except open direct debit requests) - $array_key.'_remain_to_pay_locale'=>price(price2num($object->total_ttc - $sumpayed - $sumdeposit - $sumcreditnote, 'MT'), 0, $outputlangs), - $array_key.'_remain_to_pay'=>price2num($object->total_ttc - $sumpayed - $sumdeposit - $sumcreditnote, 'MT') + $array_key.'_remain_to_pay_locale'=>price(price2num($object->total_ttc - $remain_to_pay, 'MT'), 0, $outputlangs), + $array_key.'_remain_to_pay'=>price2num($object->total_ttc - $remain_to_pay, 'MT') ); if (method_exists($object, 'getTotalDiscount')) { diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index c57a4207782..b1caff18022 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -1332,7 +1332,7 @@ if ($step == 5 && $datatoimport) } print '   '.$langs->trans("Modify").''; } else { - if (count($objimport->array_import_updatekeys[0])) + if (is_array($objimport->array_import_updatekeys[0]) && count($objimport->array_import_updatekeys[0])) { print $form->multiselectarray('updatekeys', $objimport->array_import_updatekeys[0], $updatekeys, 0, 0, '', 1, '80%'); print $form->textwithpicto("", $langs->trans("SelectPrimaryColumnsForUpdateAttempt")); From 29e4fce45084965b5d3d036be84761d121ad3e8c Mon Sep 17 00:00:00 2001 From: gauthier Date: Wed, 6 Feb 2019 12:35:23 +0100 Subject: [PATCH 070/115] FIX : can't add lines on invoices --- htdocs/compta/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 4881e42abf1..0aaac3f8f2e 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -108,7 +108,7 @@ if ($id > 0 || ! empty($ref)) { // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('invoicecard','globalcard')); -$permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php +$usercancreate = $permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php $permissiondellink=$user->rights->facture->creer; // Used by the include of actions_dellink.inc.php $permissiontoedit = $user->rights->facture->creer; // Used by the include of actions_lineupdonw.inc.php From 4624f1b1b84d036b6eac7ca9e747217affef2555 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Wed, 6 Feb 2019 17:19:16 +0100 Subject: [PATCH 071/115] FIX positive values creating diff on addline rounding --- htdocs/fourn/class/fournisseur.facture.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 086f154184d..a006b5391b1 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1665,9 +1665,9 @@ class FactureFournisseur extends CommonInvoice $this->line->rang=$rang; $this->line->info_bits=$info_bits; $this->line->total_ht= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ht):$total_ht); // For credit note and if qty is negative, total is negative - $this->line->total_tva= $total_tva; - $this->line->total_localtax1=$total_localtax1; - $this->line->total_localtax2=$total_localtax2; + $this->line->total_tva= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_tva):$total_tva); + $this->line->total_localtax1=(($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_localtax1):$total_localtax1); + $this->line->total_localtax2=(($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_localtax2):$total_localtax2); $this->line->total_ttc= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ttc):$total_ttc); $this->line->special_code=$this->special_code; $this->line->fk_parent_line=$this->fk_parent_line; @@ -1837,11 +1837,11 @@ class FactureFournisseur extends CommonInvoice $line->localtax2_tx = $txlocaltax2; $line->localtax1_type = $localtaxes_type[0]; $line->localtax2_type = $localtaxes_type[2]; - $line->total_ht = $total_ht; - $line->total_tva = $total_tva; + $line->total_ht = (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ht):$total_ht); + $line->total_tva = (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_tva):$total_tva); $line->total_localtax1 = $total_localtax1; $line->total_localtax2 = $total_localtax2; - $line->total_ttc = $total_ttc; + $line->total_ttc = (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ttc):$total_ttc); $line->fk_product = $idproduct; $line->product_type = $product_type; $line->info_bits = $info_bits; From 8e6a567b091795e9641ea6b234b4a43aaaa93d56 Mon Sep 17 00:00:00 2001 From: atm-ph Date: Thu, 7 Feb 2019 12:36:22 +0100 Subject: [PATCH 072/115] Fix display payment table on multiple pages --- .../modules/facture/doc/pdf_crabe.modules.php | 82 ++++++++++++++----- 1 file changed, 60 insertions(+), 22 deletions(-) diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 4c0724d393d..91d20d4830b 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -706,7 +706,7 @@ class pdf_crabe extends ModelePDFFactures // Affiche zone versements if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS)) { - $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs); + $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs, $heightforfooter); } // Pied de page @@ -751,15 +751,17 @@ class pdf_crabe extends ModelePDFFactures * @param Object $object Object invoice * @param int $posy Position y in PDF * @param Translate $outputlangs Object langs for output + * @param int $heightforfooter height for footer * @return int <0 if KO, >0 if OK */ - function _tableau_versements(&$pdf, $object, $posy, $outputlangs) + function _tableau_versements(&$pdf, $object, $posy, $outputlangs, $heightforfooter) { global $conf; $sign=1; if ($object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; + $current_page = $pdf->getPage(); $tab3_posx = 120; $tab3_top = $posy + 8; $tab3_width = 80; @@ -771,26 +773,7 @@ class pdf_crabe extends ModelePDFFactures $default_font_size = pdf_getPDFFontSize($outputlangs); - $title=$outputlangs->transnoentities("PaymentsAlreadyDone"); - if ($object->type == 2) $title=$outputlangs->transnoentities("PaymentsBackAlreadyDone"); - - $pdf->SetFont('','', $default_font_size - 3); - $pdf->SetXY($tab3_posx, $tab3_top - 4); - $pdf->MultiCell(60, 3, $title, 0, 'L', 0); - - $pdf->line($tab3_posx, $tab3_top, $tab3_posx+$tab3_width, $tab3_top); - - $pdf->SetFont('','', $default_font_size - 4); - $pdf->SetXY($tab3_posx, $tab3_top); - $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Payment"), 0, 'L', 0); - $pdf->SetXY($tab3_posx+21, $tab3_top); - $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Amount"), 0, 'L', 0); - $pdf->SetXY($tab3_posx+40, $tab3_top); - $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Type"), 0, 'L', 0); - $pdf->SetXY($tab3_posx+58, $tab3_top); - $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Num"), 0, 'L', 0); - - $pdf->line($tab3_posx, $tab3_top-1+$tab3_height, $tab3_posx+$tab3_width, $tab3_top-1+$tab3_height); + $this->_tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top, $tab3_width, $tab3_height); $y=0; @@ -812,6 +795,17 @@ class pdf_crabe extends ModelePDFFactures while ($i < $num) { $y+=3; + if ($tab3_top+$y >= $this->page_hauteur-$heightforfooter) + { + $y=0; + $current_page++; + $pdf->AddPage('','',true); + if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + $pdf->setPage($current_page); + $this->_tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top+$y-3, $tab3_width, $tab3_height); + } + $obj = $this->db->fetch_object($resql); if ($obj->type == 2) $text=$outputlangs->transnoentities("CreditNote"); @@ -858,6 +852,17 @@ class pdf_crabe extends ModelePDFFactures $i=0; while ($i < $num) { $y+=3; + if ($tab3_top+$y >= $this->page_hauteur-$heightforfooter) + { + $y=0; + $current_page++; + $pdf->AddPage('','',true); + if (! empty($tplidx)) $pdf->useTemplate($tplidx); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + $pdf->setPage($current_page); + $this->_tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top+$y-3, $tab3_width, $tab3_height); + } + $row = $this->db->fetch_object($resql); $pdf->SetXY($tab3_posx, $tab3_top+$y); @@ -884,6 +889,39 @@ class pdf_crabe extends ModelePDFFactures } + /** + * @param PDF $pdf Object PDF + * @param Facture $object Object invoice + * @param Translate $outputlangs Object langs for output + * @param int $default_font_size Font size + * @param int $tab3_posx pos x + * @param int $tab3_top pos y + * @param int $tab3_width width + * @param int $tab3_height height + */ + function _tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top, $tab3_width, $tab3_height) + { + $title=$outputlangs->transnoentities("PaymentsAlreadyDone"); + if ($object->type == 2) $title=$outputlangs->transnoentities("PaymentsBackAlreadyDone"); + + $pdf->SetFont('','', $default_font_size - 3); + $pdf->SetXY($tab3_posx, $tab3_top - 4); + $pdf->MultiCell(60, 3, $title, 0, 'L', 0); + + $pdf->line($tab3_posx, $tab3_top, $tab3_posx+$tab3_width, $tab3_top); + + $pdf->SetFont('','', $default_font_size - 4); + $pdf->SetXY($tab3_posx, $tab3_top); + $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Payment"), 0, 'L', 0); + $pdf->SetXY($tab3_posx+21, $tab3_top); + $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Amount"), 0, 'L', 0); + $pdf->SetXY($tab3_posx+40, $tab3_top); + $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Type"), 0, 'L', 0); + $pdf->SetXY($tab3_posx+58, $tab3_top); + $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Num"), 0, 'L', 0); + + $pdf->line($tab3_posx, $tab3_top-1+$tab3_height, $tab3_posx+$tab3_width, $tab3_top-1+$tab3_height); + } /** * Show miscellaneous information (payment mode, payment term, ...) From 9d0e0c2798127d3324a61bf148dd2490200b3121 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Thu, 7 Feb 2019 15:17:52 +0100 Subject: [PATCH 073/115] FIX add fk_unit on addline action --- htdocs/supplier_proposal/card.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/supplier_proposal/card.php b/htdocs/supplier_proposal/card.php index e47dc48d6ca..7b1bf417b40 100644 --- a/htdocs/supplier_proposal/card.php +++ b/htdocs/supplier_proposal/card.php @@ -634,6 +634,8 @@ if (empty($reshook)) $ref_supplier = $productsupplier->ref_supplier; + $fk_unit = $productsupplier->fk_unit; + $tva_tx = get_default_tva($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice','alpha')); $tva_npr = get_default_npr($object->thirdparty, $mysoc, $productsupplier->id, GETPOST('idprodfournprice','alpha')); if (empty($tva_tx)) $tva_npr=0; From ec7ef265b7a0230ea6b993139def74937d1fdc7a Mon Sep 17 00:00:00 2001 From: atm-ph Date: Thu, 7 Feb 2019 17:47:17 +0100 Subject: [PATCH 074/115] Fix psql search insensitive accent --- htdocs/core/db/pgsql.class.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 8e57b29109e..392e0998d6b 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -152,6 +152,7 @@ class DoliDBPgsql extends DoliDB */ static function convertSQLFromMysql($line,$type='auto',$unescapeslashquot=false) { + global $conf; // Removed empty line if this is a comment line for SVN tagging if (preg_match('/^--\s\$Id/i',$line)) { return ''; @@ -311,7 +312,14 @@ class DoliDBPgsql extends DoliDB } // To have postgresql case sensitive - $line=str_replace(' LIKE \'',' ILIKE \'',$line); + $count_like=0; + $line=str_replace(' LIKE \'',' ILIKE \'',$line,$count_like); + if (!empty($conf->global->PSQL_USE_UNACCENT) && $count_like > 0) + { + // @see https://docs.postgresql.fr/11/unaccent.html : 'unaccent()' function must be installed before + $line=preg_replace('/\s+(\(?\s*)([a-zA-Z0-9\-\_\.]+) ILIKE /', ' \1unaccent(\2) ILIKE ', $line); + } + $line=str_replace(' LIKE BINARY \'',' LIKE \'',$line); // Replace INSERT IGNORE into INSERT From 51515a487ed72eabd7a5fbbade31a0a7d50d80b9 Mon Sep 17 00:00:00 2001 From: atm-ph Date: Thu, 7 Feb 2019 17:58:25 +0100 Subject: [PATCH 075/115] Fix search unaccent from left menu search box --- htdocs/core/db/pgsql.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 392e0998d6b..3d365142a0a 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -317,7 +317,7 @@ class DoliDBPgsql extends DoliDB if (!empty($conf->global->PSQL_USE_UNACCENT) && $count_like > 0) { // @see https://docs.postgresql.fr/11/unaccent.html : 'unaccent()' function must be installed before - $line=preg_replace('/\s+(\(?\s*)([a-zA-Z0-9\-\_\.]+) ILIKE /', ' \1unaccent(\2) ILIKE ', $line); + $line=preg_replace('/\s+(\(+\s*)([a-zA-Z0-9\-\_\.]+) ILIKE /', ' \1unaccent(\2) ILIKE ', $line); } $line=str_replace(' LIKE BINARY \'',' LIKE \'',$line); From 8abebb091c16343c66de43b7fa6668d093bb38ba Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Feb 2019 09:33:01 +0100 Subject: [PATCH 076/115] Var no more used --- htdocs/compta/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 0a0e2ad7cd5..73b2bfdb314 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -108,7 +108,7 @@ if ($id > 0 || ! empty($ref)) { // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('invoicecard','globalcard')); -$usercancreate = $permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php +$permissionnote = $user->rights->facture->creer; // Used by the include of actions_setnotes.inc.php $permissiondellink=$user->rights->facture->creer; // Used by the include of actions_dellink.inc.php $permissiontoedit = $user->rights->facture->creer; // Used by the include of actions_lineupdonw.inc.php From 43fbcf7081cd5a2dcb51153ce47c0e926053f31e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Feb 2019 10:28:59 +0100 Subject: [PATCH 077/115] Prepare 8.0.5 --- 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 36e3ba38b58..3981de21751 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','8.0.4'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c +if (! defined('DOL_VERSION')) define('DOL_VERSION','8.0.5'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c if (! defined('EURO')) define('EURO',chr(128)); From 2dc4edb68c5b7995a3423abddde313b4a99d18ac Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 11 Feb 2019 11:36:12 +0100 Subject: [PATCH 078/115] FIX: Accountancy - Add transaction with multicompany use all the time 1st entity --- htdocs/accountancy/class/bookkeeping.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 0ad91a30f56..10ec82a4f3b 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -195,7 +195,7 @@ class BookKeeping extends CommonObject // First check if line not yet already in bookkeeping. // Note that we must include doc_type - fk_doc - numero_compte - label to be sure to have unicity of line (we may have several lines - // with same doc_type, fk_odc, numero_compte for 1 invoice line when using localtaxes with same account) + // with same doc_type, fk_doc, numero_compte for 1 invoice line when using localtaxes with same account) // WARNING: This is not reliable, label may have been modified. This is just a small protection. // The page to make journalization make the test on couple doc_type - fk_doc only. $sql = "SELECT count(*) as nb"; @@ -1618,11 +1618,11 @@ class BookKeeping extends CommonObject $error++; } $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element.'(doc_date, doc_type,'; - $sql .= ' doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,'; + $sql .= ' doc_ref, fk_doc, fk_docdet, entity, thirdparty_code, subledger_account, subledger_label,'; $sql .= ' numero_compte, label_compte, label_operation, debit, credit,'; $sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, piece_num)'; $sql .= 'SELECT doc_date, doc_type,'; - $sql .= ' doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,'; + $sql .= ' doc_ref, fk_doc, fk_docdet, entity, thirdparty_code, subledger_account, subledger_label,'; $sql .= ' numero_compte, label_compte, label_operation, debit, credit,'; $sql .= ' montant, sens, fk_user_author, import_key, code_journal, journal_label, '.$next_piecenum.''; $sql .= ' FROM '.MAIN_DB_PREFIX . $this->table_element.'_tmp WHERE piece_num = '.$piece_num; From aa4c5ae839ff60961e47fb463febfb9e26c24121 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 14 Feb 2019 10:12:15 +0100 Subject: [PATCH 079/115] FIX missing access security checking with multicompany --- htdocs/core/lib/security.lib.php | 4 ++-- htdocs/product/stock/card.php | 2 +- htdocs/product/stock/info.php | 2 +- htdocs/product/stock/mouvement.php | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index d12ee339909..65a4a5bdc93 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -451,12 +451,12 @@ function checkUserAccessToObject($user, $featuresarray, $objectid=0, $tableandsh if ($feature == 'project') $feature='projet'; if ($feature == 'task') $feature='projet_task'; - $check = array('adherent','banque','don','user','usergroup','product','produit','service','produit|service','categorie','resource'); // Test on entity only (Objects with no link to company) + $check = array('adherent','banque','don','user','usergroup','product','produit','service','produit|service','stock','categorie','resource'); // Test on entity only (Objects with no link to company) $checksoc = array('societe'); // Test for societe object $checkother = array('contact','agenda'); // Test on entity and link to third party. Allowed if link is empty (Ex: contacts...). $checkproject = array('projet','project'); // Test for project object $checktask = array('projet_task'); - $nocheck = array('barcode','stock'); // No test + $nocheck = array('barcode'); // No test $checkdefault = 'all other not already defined'; // Test on entity and link to third party. Not allowed if link is empty (Ex: invoice, orders...). // If dbtablename not defined, we use same name for table than module name diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 41e70a6fbf9..01529d33f35 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -52,7 +52,7 @@ if (! $sortorder) $sortorder="DESC"; $backtopage=GETPOST('backtopage','alpha'); // Security check -$result=restrictedArea($user,'stock'); +$result=restrictedArea($user,'stock', $id, 'entrepot&stock'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('warehousecard','globalcard')); diff --git a/htdocs/product/stock/info.php b/htdocs/product/stock/info.php index 4653a56495d..c8897412e04 100644 --- a/htdocs/product/stock/info.php +++ b/htdocs/product/stock/info.php @@ -33,7 +33,7 @@ $id = GETPOST('id','int'); $ref = GETPOST('ref','alpha'); // Security check -$result=restrictedArea($user,'stock'); +$result=restrictedArea($user,'stock', $id, 'entrepot&stock'); /* diff --git a/htdocs/product/stock/mouvement.php b/htdocs/product/stock/mouvement.php index 410396a152b..21aa103fafb 100644 --- a/htdocs/product/stock/mouvement.php +++ b/htdocs/product/stock/mouvement.php @@ -46,9 +46,6 @@ if (! empty($conf->projet->enabled)) $langs->loadLangs(array('products', 'stocks')); if (! empty($conf->productbatch->enabled)) $langs->load("productbatch"); -// Security check -$result=restrictedArea($user,'stock'); - $id=GETPOST('id','int'); $ref = GETPOST('ref','alpha'); $msid=GETPOST('msid','int'); @@ -57,6 +54,9 @@ $action=GETPOST('action','aZ09'); $cancel=GETPOST('cancel','alpha'); $contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'movementlist'; +// Security check +$result=restrictedArea($user,'stock', $id, 'entrepot&stock'); + $idproduct = GETPOST('idproduct','int'); $year = GETPOST("year"); $month = GETPOST("month"); From 359318392fdcace0fc4ef6b6f589b12e0a0e9448 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 14 Feb 2019 10:47:07 +0100 Subject: [PATCH 080/115] FIX missing entity filter in function "build_filterField()" (export) --- htdocs/core/modules/modAdherent.class.php | 2 +- htdocs/core/modules/modCommande.class.php | 2 +- htdocs/core/modules/modProjet.class.php | 6 +++--- htdocs/core/modules/modSociete.class.php | 2 +- htdocs/core/modules/modStock.class.php | 18 +++++++++--------- htdocs/exports/class/export.class.php | 7 ++++++- 6 files changed, 21 insertions(+), 16 deletions(-) diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index c425ce9bd5d..3acd162bb03 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -279,7 +279,7 @@ class modAdherent extends DolibarrModules 'a.civility'=>"Text",'a.lastname'=>"Text",'a.firstname'=>"Text",'a.login'=>"Text",'a.morphy'=>'Text','a.societe'=>'Text','a.address'=>"Text", 'a.zip'=>"Text",'a.town'=>"Text",'d.nom'=>"Text",'co.code'=>'Text','co.label'=>"Text",'a.phone'=>"Text",'a.phone_perso'=>"Text",'a.phone_mobile'=>"Text", 'a.email'=>"Text",'a.birth'=>"Date",'a.statut'=>"Status",'a.note_public'=>"Text",'a.note_private'=>"Text",'a.datec'=>'Date','a.datevalid'=>'Date', - 'a.tms'=>'Date','a.datefin'=>'Date','ta.rowid'=>'List:adherent_type:libelle','ta.libelle'=>'Text','c.rowid'=>'Numeric','c.dateadh'=>'Date','c.subscription'=>'Numeric' + 'a.tms'=>'Date','a.datefin'=>'Date','ta.rowid'=>'List:adherent_type:libelle::member_type','ta.libelle'=>'Text','c.rowid'=>'Numeric','c.dateadh'=>'Date','c.subscription'=>'Numeric' ); $this->export_entities_array[$r]=array( 'a.rowid'=>'member','a.civility'=>"member",'a.lastname'=>"member",'a.firstname'=>"member",'a.login'=>"member",'a.morphy'=>'member', diff --git a/htdocs/core/modules/modCommande.class.php b/htdocs/core/modules/modCommande.class.php index 5285e0734e2..b366fc1c6b2 100644 --- a/htdocs/core/modules/modCommande.class.php +++ b/htdocs/core/modules/modCommande.class.php @@ -223,7 +223,7 @@ class modCommande extends DolibarrModules 'c.date_commande'=>"Date",'c.date_livraison'=>"Date",'c.amount_ht'=>"Numeric",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric", 'c.total_ttc'=>"Numeric",'c.facture'=>"Boolean",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date','pj.ref'=>'Text', 'cd.description'=>"Text",'cd.product_type'=>'Boolean','cd.tva_tx'=>"Numeric",'cd.qty'=>"Numeric",'cd.total_ht'=>"Numeric",'cd.total_tva'=>"Numeric", - 'cd.total_ttc'=>"Numeric",'p.rowid'=>'List:product:ref','p.ref'=>'Text','p.label'=>'Text','d.nom'=>'Text' + 'cd.total_ttc'=>"Numeric",'p.rowid'=>'List:product:ref::product','p.ref'=>'Text','p.label'=>'Text','d.nom'=>'Text' ); $this->export_entities_array[$r]=array( 's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','d.nom'=>'company','co.label'=>'company', diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php index 8757909d1d5..220827843a9 100644 --- a/htdocs/core/modules/modProjet.class.php +++ b/htdocs/core/modules/modProjet.class.php @@ -216,9 +216,9 @@ class modProjet extends DolibarrModules $this->export_permission[$r]=array(array("projet","export")); $this->export_dependencies_array[$r]=array('projecttask'=>'pt.rowid', 'task_time'=>'ptt.rowid'); - $this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','s.fk_pays'=>'List:c_country:label', + $this->export_TypeFields_array[$r]=array('s.rowid'=>"List:societe:nom::thirdparty",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','s.fk_pays'=>'List:c_country:label', 's.phone'=>'Text','s.email'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text', - 'p.rowid'=>"List:projet:ref",'p.ref'=>"Text",'p.title'=>"Text",'p.datec'=>"Date",'p.dateo'=>"Date",'p.datee'=>"Date",'p.fk_statut'=>'Status','cls.code'=>"Text",'p.opp_percent'=>'Numeric','p.opp_amount'=>'Numeric','p.description'=>"Text",'p.entity'=>'Numeric', + 'p.rowid'=>"List:projet:ref::project",'p.ref'=>"Text",'p.title'=>"Text",'p.datec'=>"Date",'p.dateo'=>"Date",'p.datee'=>"Date",'p.fk_statut'=>'Status','cls.code'=>"Text",'p.opp_percent'=>'Numeric','p.opp_amount'=>'Numeric','p.description'=>"Text",'p.entity'=>'Numeric', 'pt.rowid'=>'Text','pt.label'=>'Text','pt.dateo'=>"Date",'pt.datee'=>"Date",'pt.duration_effective'=>"Duree",'pt.planned_workload'=>"Numeric",'pt.progress'=>"Numeric",'pt.description'=>"Text", 'ptt.rowid'=>'Numeric','ptt.task_date'=>'Date','ptt.task_duration'=>"Duree",'ptt.fk_user'=>"List:user:CONCAT(lastname,' ',firstname)",'ptt.note'=>"Text"); $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','s.fk_pays'=>'company', @@ -359,7 +359,7 @@ class modProjet extends DolibarrModules $sql[] ="INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('beluga','project',".$conf->entity.")"; $sql[] ="DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = 'baleine' AND type = 'project' AND entity = ".$conf->entity; $sql[] ="INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('baleine','project',".$conf->entity.")"; - + return $this->_init($sql,$options); } diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 34f4dca8510..b41326a8e1d 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -336,7 +336,7 @@ class modSociete extends DolibarrModules $this->export_TypeFields_array[$r]=array( 'c.civility'=>"List:c_civility:label:code",'c.lastname'=>'Text','c.firstname'=>'Text','c.poste'=>'Text','c.datec'=>"Date",'c.priv'=>"Boolean", 'c.address'=>"Text",'c.zip'=>"Text",'c.town'=>"Text",'d.nom'=>'Text','co.label'=>"List:c_country:label:rowid",'co.code'=>"Text",'c.phone'=>"Text", - 'c.fax'=>"Text",'c.email'=>"Text",'s.rowid'=>"List:societe:nom",'s.nom'=>"Text",'s.status'=>"Status",'s.code_client'=>"Text",'s.code_fournisseur'=>"Text", + 'c.fax'=>"Text",'c.email'=>"Text",'s.rowid'=>"List:societe:nom::thirdparty",'s.nom'=>"Text",'s.status'=>"Status",'s.code_client'=>"Text",'s.code_fournisseur'=>"Text", 's.client'=>"Text",'s.fournisseur'=>"Text" ); $this->export_entities_array[$r]=array( diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index ff767dd3658..8f884c46646 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -72,9 +72,9 @@ class modStock extends DolibarrModules // Constants $this->const = array(); $r=0; - + $this->const[$r] = array('STOCK_ALLOW_NEGATIVE_TRANSFER','chaine','1','',1); - + $r++; $this->const[$r][0] = "STOCK_ADDON_PDF"; $this->const[$r][1] = "chaine"; @@ -197,7 +197,7 @@ class modStock extends DolibarrModules 'p.tms'=>'DateModification','p.pmp'=>'PMPValue','p.cost_price'=>'CostPrice' ); $this->export_TypeFields_array[$r]=array( - 'e.rowid'=>'List:entrepot:ref','e.ref'=>'Text','e.lieu'=>'Text','e.address'=>'Text','e.zip'=>'Text','e.town'=>'Text','p.rowid'=>"List:product:label", + 'e.rowid'=>'List:entrepot:ref::stock','e.ref'=>'Text','e.lieu'=>'Text','e.address'=>'Text','e.zip'=>'Text','e.town'=>'Text','p.rowid'=>"List:product:label::product", 'p.ref'=>"Text",'p.fk_product_type'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.note'=>"Text",'p.price'=>"Numeric",'p.tva_tx'=>'Numeric', 'p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date','p.pmp'=>'Numeric','p.cost_price'=>'Numeric', 'ps.reel'=>'Numeric' @@ -236,8 +236,8 @@ class modStock extends DolibarrModules 'p.tms'=>'DateModification','pb.rowid'=>'Id','pb.batch'=>'Batch','pb.qty'=>'Qty','pl.eatby'=>'EatByDate','pl.sellby'=>'SellByDate' ); $this->export_TypeFields_array[$r]=array( - 'e.rowid'=>'List:entrepot:ref','e.ref'=>'Text','e.lieu'=>'Text','e.description'=>'Text','e.address'=>'Text','e.zip'=>'Text','e.town'=>'Text', - 'p.rowid'=>"List:product:label",'p.ref'=>"Text",'p.fk_product_type'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.note'=>"Text", + 'e.rowid'=>'List:entrepot:ref::stock','e.ref'=>'Text','e.lieu'=>'Text','e.description'=>'Text','e.address'=>'Text','e.zip'=>'Text','e.town'=>'Text', + 'p.rowid'=>"List:product:label::product",'p.ref'=>"Text",'p.fk_product_type'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.note'=>"Text", 'p.price'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date', 'pb.batch'=>'Text','pb.qty'=>'Numeric','pl.eatby'=>'Date','pl.sellby'=>'Date' ); @@ -274,8 +274,8 @@ class modStock extends DolibarrModules 'sm.inventorycode'=>'InventoryCode' ); $this->export_TypeFields_array[$r]=array( - 'e.rowid'=>'List:entrepot:ref','e.ref'=>'Text','e.description'=>'Text','e.lieu'=>'Text','e.address'=>'Text','e.zip'=>'Text','e.town'=>'Text', - 'p.rowid'=>"List:product:label",'p.ref'=>"Text",'p.fk_product_type'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.note'=>"Text", + 'e.rowid'=>'List:entrepot:ref::stock','e.ref'=>'Text','e.description'=>'Text','e.lieu'=>'Text','e.address'=>'Text','e.zip'=>'Text','e.town'=>'Text', + 'p.rowid'=>"List:product:label::product",'p.ref'=>"Text",'p.fk_product_type'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.note'=>"Text", 'p.price'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date', 'sm.rowid'=>'Numeric','sm.value'=>'Numeric','sm.datem'=>'Date','sm.batch'=>'Text','sm.label'=>'Text','sm.inventorycode'=>'Text' ); @@ -347,8 +347,8 @@ class modStock extends DolibarrModules ); } - - + + /** * Function called when module is enabled. * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php index 050318944d6..02abe88600a 100644 --- a/htdocs/exports/class/export.class.php +++ b/htdocs/exports/class/export.class.php @@ -411,7 +411,9 @@ class Export // 1 : Nom de la table // 2 : Nom du champ contenant le libelle // 3 : Name of field with key (if it is not "rowid"). Used this field as key for combo list. - if (count($InfoFieldList)==4) + // 4 : Name of element for getEntity(). + + if (! empty($InfoFieldList[3])) $keyList=$InfoFieldList[3]; else $keyList='rowid'; @@ -419,6 +421,9 @@ class Export if ($InfoFieldList[1] == 'c_stcomm') $sql = 'SELECT id as id, '.$keyList.' as rowid, '.$InfoFieldList[2].' as label'.(empty($InfoFieldList[3])?'':', '.$InfoFieldList[3].' as code'); if ($InfoFieldList[1] == 'c_country') $sql = 'SELECT '.$keyList.' as rowid, '.$InfoFieldList[2].' as label, code as code'; $sql.= ' FROM '.MAIN_DB_PREFIX .$InfoFieldList[1]; + if (! empty($InfoFieldList[4])) { + $sql.= ' WHERE entity IN ('.getEntity($InfoFieldList[4]).')'; + } $resql = $this->db->query($sql); if ($resql) From d2ee00d4bb70d1682a5fe9098bf2247448c3e2d4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Feb 2019 15:21:01 +0100 Subject: [PATCH 081/115] Update security.lib.php Avoid regression on test of restrictArea --- htdocs/core/lib/security.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 65a4a5bdc93..d12ee339909 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -451,12 +451,12 @@ function checkUserAccessToObject($user, $featuresarray, $objectid=0, $tableandsh if ($feature == 'project') $feature='projet'; if ($feature == 'task') $feature='projet_task'; - $check = array('adherent','banque','don','user','usergroup','product','produit','service','produit|service','stock','categorie','resource'); // Test on entity only (Objects with no link to company) + $check = array('adherent','banque','don','user','usergroup','product','produit','service','produit|service','categorie','resource'); // Test on entity only (Objects with no link to company) $checksoc = array('societe'); // Test for societe object $checkother = array('contact','agenda'); // Test on entity and link to third party. Allowed if link is empty (Ex: contacts...). $checkproject = array('projet','project'); // Test for project object $checktask = array('projet_task'); - $nocheck = array('barcode'); // No test + $nocheck = array('barcode','stock'); // No test $checkdefault = 'all other not already defined'; // Test on entity and link to third party. Not allowed if link is empty (Ex: invoice, orders...). // If dbtablename not defined, we use same name for table than module name From 173d28cf5aeaeb74e9feecebfa5a0523f34c33bb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Feb 2019 15:22:22 +0100 Subject: [PATCH 082/115] Update mouvement.php Avoid regression on restrictArea --- htdocs/product/stock/mouvement.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/product/stock/mouvement.php b/htdocs/product/stock/mouvement.php index 21aa103fafb..331d39efccb 100644 --- a/htdocs/product/stock/mouvement.php +++ b/htdocs/product/stock/mouvement.php @@ -55,7 +55,8 @@ $cancel=GETPOST('cancel','alpha'); $contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'movementlist'; // Security check -$result=restrictedArea($user,'stock', $id, 'entrepot&stock'); +//$result=restrictedArea($user,'stock', $id, 'entrepot&stock'); +$result=restrictedArea($user,'stock'); $idproduct = GETPOST('idproduct','int'); $year = GETPOST("year"); From 4ac086ab70acb8813f9c1dfb2f4530898e54dc16 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Feb 2019 15:23:07 +0100 Subject: [PATCH 083/115] Update info.php --- htdocs/product/stock/info.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/product/stock/info.php b/htdocs/product/stock/info.php index c8897412e04..77e06d76eb1 100644 --- a/htdocs/product/stock/info.php +++ b/htdocs/product/stock/info.php @@ -33,7 +33,8 @@ $id = GETPOST('id','int'); $ref = GETPOST('ref','alpha'); // Security check -$result=restrictedArea($user,'stock', $id, 'entrepot&stock'); +//$result=restrictedArea($user,'stock', $id, 'entrepot&stock'); +$result=restrictedArea($user,'stock'); /* From 2c2052d11310e49205bfa9d3f78080612441cc6b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 14 Feb 2019 15:23:34 +0100 Subject: [PATCH 084/115] Update card.php Avoid regression on restrictArea --- htdocs/product/stock/card.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 01529d33f35..5dca091c56b 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -52,7 +52,8 @@ if (! $sortorder) $sortorder="DESC"; $backtopage=GETPOST('backtopage','alpha'); // Security check -$result=restrictedArea($user,'stock', $id, 'entrepot&stock'); +//$result=restrictedArea($user,'stock', $id, 'entrepot&stock'); +$result=restrictedArea($user,'stock'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('warehousecard','globalcard')); From 45d05da6ed7d563b44c8b0e77c3e2d5c5a918d6a Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 14 Feb 2019 16:14:19 +0100 Subject: [PATCH 085/115] FIX missing $ismultientitymanaged for previous/next ref --- htdocs/product/stock/class/entrepot.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index add121b902e..850c652c59f 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -36,6 +36,7 @@ class Entrepot extends CommonObject public $element='stock'; public $table_element='entrepot'; public $picto='stock'; + public $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe /** * Warehouse closed, inactive @@ -716,7 +717,7 @@ class Entrepot extends CommonObject return $TChildWarehouses; } - + /** * Create object on disk * From 70f1a9d13d63d7e6392fd1392d5a718a6557c6d5 Mon Sep 17 00:00:00 2001 From: gauthier Date: Fri, 15 Feb 2019 11:26:29 +0100 Subject: [PATCH 086/115] FIX : we want to be able to reopen fourn credit note --- htdocs/fourn/facture/card.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index bbec3ea6ed6..c6f6d560f34 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -3014,8 +3014,13 @@ else print ''; } + $discount = new DiscountAbsolute($db); + $result = $discount->fetch(0, 0, $object->id); + // Reopen a standard paid invoice - if (($object->type == FactureFournisseur::TYPE_STANDARD || $object->type == FactureFournisseur::TYPE_REPLACEMENT) && ($object->statut == 2 || $object->statut == 3)) // A paid invoice (partially or completely) + if (($object->type == FactureFournisseur::TYPE_STANDARD || $object->type == FactureFournisseur::TYPE_REPLACEMENT + || ($object->type == FactureFournisseur::TYPE_CREDIT_NOTE && empty($discount->id))) + && ($object->statut == 2 || $object->statut == 3)) // A paid invoice (partially or completely) { if (! $facidnext && $object->close_code != 'replaced' && $user->rights->fournisseur->facture->creer) // Not replaced by another invoice { From b017213131e278ab1603d0e1a78402bed704e100 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 17 Feb 2019 20:59:39 +0100 Subject: [PATCH 087/115] selectMulticurrency avoid malformed empty value --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 58df0ad4e22..c451a83a4fb 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4517,7 +4517,7 @@ class Form $out=''; $out.= ''; print ''; - print ''; } else { - print ''; + print ''; print ''; } } @@ -692,7 +695,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie //$test= price(price2num($objp->total_ttc - $paiement - $creditnotes - $deposits)); // Amount - print ''; + print ''; // Add remind amount $namef = 'amount_'.$objp->facid; @@ -702,12 +705,12 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie { if (!empty($conf->use_javascript_ajax)) print img_picto("Auto fill",'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".($sign * $remaintopay)."'"); + print ''; print ''; - print ''; } else { - print ''; + print ''; print ''; } print ""; diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 539c70f591b..65574f31591 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -292,6 +292,7 @@ class Paiement extends CommonObject if ($invoice->type == Facture::TYPE_DEPOSIT) { $amount_ht = $amount_tva = $amount_ttc = array(); + $multicurrency_amount_ht = $multicurrency_amount_tva = $multicurrency_amount_ttc = array(); // Insert one discount by VAT rate category $discount = new DiscountAbsolute($this->db); @@ -310,6 +311,9 @@ class Paiement extends CommonObject $amount_ht[$line->tva_tx] += $line->total_ht; $amount_tva[$line->tva_tx] += $line->total_tva; $amount_ttc[$line->tva_tx] += $line->total_ttc; + $multicurrency_amount_ht[$line->tva_tx] += $line->multicurrency_total_ht; + $multicurrency_amount_tva[$line->tva_tx] += $line->multicurrency_total_tva; + $multicurrency_amount_ttc[$line->tva_tx] += $line->multicurrency_total_ttc; $i++; } } @@ -318,6 +322,9 @@ class Paiement extends CommonObject $discount->amount_ht = abs($amount_ht[$tva_tx]); $discount->amount_tva = abs($amount_tva[$tva_tx]); $discount->amount_ttc = abs($amount_ttc[$tva_tx]); + $discount->multicurrency_amount_ht = abs($multicurrency_amount_ht[$tva_tx]); + $discount->multicurrency_amount_tva = abs($multicurrency_amount_tva[$tva_tx]); + $discount->multicurrency_amount_ttc = abs($multicurrency_amount_ttc[$tva_tx]); $discount->tva_tx = abs($tva_tx); $result = $discount->create($user); @@ -995,7 +1002,7 @@ class Paiement extends CommonObject /** * get the right way of payment * - * @return string 'dolibarr' if standard comportment or paid in dolibarr currency, 'customer' if payment received from multicurrency inputs + * @return string 'dolibarr' if standard comportment or paid in main currency, 'customer' if payment received from multicurrency inputs */ function getWay() { diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index e3098911418..cfe7ac24dea 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -33,10 +33,14 @@ class DiscountAbsolute public $id; // Id discount public $fk_soc; - public $discount_type; // 0 => customer discount, 1 => supplier discount - public $amount_ht; // + + public $discount_type; // 0 => customer discount, 1 => supplier discount + public $amount_ht; // public $amount_tva; // public $amount_ttc; // + public $multicurrency_amount_ht; + public $multicurrency_amount_tva; + public $multicurrency_amount_ttc; public $tva_tx; // Vat rate public $fk_user; // Id utilisateur qui accorde la remise public $description; // Description libre From 58d82eb4779d9adcd15397034ad1b71b18d7356c Mon Sep 17 00:00:00 2001 From: gauthier Date: Thu, 21 Feb 2019 11:08:55 +0100 Subject: [PATCH 089/115] FIX : function sendEmailsReminder isn't completely developed, then MAIN_FEATURES_LEVEL must be 2 to "use" it --- htdocs/admin/agenda_reminder.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/agenda_reminder.php b/htdocs/admin/agenda_reminder.php index fac49dcfcde..3ea0e397c92 100644 --- a/htdocs/admin/agenda_reminder.php +++ b/htdocs/admin/agenda_reminder.php @@ -194,7 +194,7 @@ print ''."\n"; // AGENDA REMINDER EMAIL -if ($conf->global->MAIN_FEATURES_LEVEL > 0) +if ($conf->global->MAIN_FEATURES_LEVEL == 2) { print ''."\n"; print ''.$langs->trans('AGENDA_REMINDER_EMAIL', $langs->transnoentities("Module2300Name")).''."\n"; @@ -211,7 +211,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL > 0) } // AGENDA REMINDER BROWSER -if ($conf->global->MAIN_FEATURES_LEVEL > 0) +if ($conf->global->MAIN_FEATURES_LEVEL == 2) { print ''."\n"; print ''.$langs->trans('AGENDA_REMINDER_BROWSER').''."\n"; From c38b0c4dbec7414a21f94f8457aa3495b3d1261f Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Fri, 22 Feb 2019 12:17:34 +0100 Subject: [PATCH 090/115] FIX fk_default_warehouse missing in group by --- htdocs/fourn/commande/dispatch.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 761cce030f7..77fd4b1aa69 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -499,7 +499,7 @@ if ($id > 0 || ! empty($ref)) { $sql .= " WHERE l.fk_commande = " . $object->id; if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql .= " AND l.product_type = 0"; - $sql .= " GROUP BY p.ref, p.label, p.tobatch, l.rowid, l.fk_product, l.subprice, l.remise_percent"; // Calculation of amount dispatched is done per fk_product so we must group by fk_product + $sql .= " GROUP BY p.ref, p.label, p.tobatch, l.rowid, l.fk_product, l.subprice, l.remise_percent, p.fk_default_warehouse"; // Calculation of amount dispatched is done per fk_product so we must group by fk_product $sql .= " ORDER BY p.ref, p.label"; $resql = $db->query($sql); From 0ea7bf3b0b6ee6c7419d3a1fe306987ac78628a7 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 24 Feb 2019 08:21:56 +0100 Subject: [PATCH 091/115] FIX could not create several superadmin in transversal mode --- htdocs/user/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 6db383ed515..adcf094e7a4 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -855,7 +855,7 @@ if ($action == 'create' || $action == 'adduserldap') print ''; print $form->selectyesno('admin',GETPOST('admin'),1); - if (! empty($conf->multicompany->enabled) && ! $user->entity && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) + if (! empty($conf->multicompany->enabled) && ! $user->entity) { if (! empty($conf->use_javascript_ajax)) { @@ -1992,7 +1992,7 @@ else { print $form->selectyesno('admin',$object->admin,1); - if (! empty($conf->multicompany->enabled) && ! $user->entity && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) + if (! empty($conf->multicompany->enabled) && ! $user->entity) { if ($conf->use_javascript_ajax) { From 435b416f939b7d906abb246c711acca8a8d25914 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 24 Feb 2019 11:50:06 +0100 Subject: [PATCH 092/115] fix #10656 --- htdocs/fourn/facture/list.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 98a6956a809..4d2c81dbbfa 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -387,6 +387,7 @@ if (! $search_all) $sql.= " f.total_ht, f.total_ttc, f.total_tva, f.paye, f.fk_statut, f.libelle, f.datec, f.tms,"; $sql.= " f.localtax1, f.localtax2,"; $sql.= ' s.rowid, s.nom, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,'; + $sql .= ' p.title,'; $sql.= " typent.code,"; $sql.= " state.code_departement, state.nom,"; $sql.= ' country.code,'; From ca2eba866c641d799f378a834ef99ccd652f9179 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 24 Feb 2019 11:56:17 +0100 Subject: [PATCH 093/115] Update list.php --- htdocs/fourn/facture/list.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 4d2c81dbbfa..4b208a99af7 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -387,11 +387,10 @@ if (! $search_all) $sql.= " f.total_ht, f.total_ttc, f.total_tva, f.paye, f.fk_statut, f.libelle, f.datec, f.tms,"; $sql.= " f.localtax1, f.localtax2,"; $sql.= ' s.rowid, s.nom, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,'; - $sql .= ' p.title,'; $sql.= " typent.code,"; $sql.= " state.code_departement, state.nom,"; $sql.= ' country.code,'; - $sql.= " p.rowid, p.ref"; + $sql.= " p.rowid, p.ref, p.title"; foreach ($extrafields->attribute_label as $key => $val) //prevent error with sql_mode=only_full_group_by { From 2ad91213b2dd5c2bcd136b51f8a281f688df6378 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 24 Feb 2019 12:09:57 +0100 Subject: [PATCH 094/115] Update combinations.php --- htdocs/variants/combinations.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index 04f53e55d21..8c8f669c0e0 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -1,6 +1,7 @@ * Copyright (C) 2017 Laurent Destailleur + * Copyright (C) 2019 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,9 +31,9 @@ $langs->load("other"); $var = false; $id = GETPOST('id', 'int'); $valueid = GETPOST('valueid', 'int'); -$ref = GETPOST('ref'); -$weight_impact = (float) GETPOST('weight_impact'); -$price_impact = (float) GETPOST('price_impact'); +$ref = GETPOST('ref', 'alpha'); +$weight_impact = GETPOST('weight_impact', 'alpha'); +$price_impact = GETPOST('price_impact', 'alpha'); $price_impact_percent = (bool) GETPOST('price_impact_percent'); $form = new Form($db); From 2f300ae63ffa4e7adb3547da9f205db7a676a4b1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 24 Feb 2019 20:26:54 +0100 Subject: [PATCH 095/115] Standardize code with customer invoices --- .../fourn/class/fournisseur.facture.class.php | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index a006b5391b1..5cc47d5201a 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1646,29 +1646,33 @@ class FactureFournisseur extends CommonInvoice $this->line->fk_facture_fourn=$this->id; //$this->line->label=$label; // deprecated $this->line->desc=$desc; - $this->line->qty= ($this->type==self::TYPE_CREDIT_NOTE?abs($qty):$qty); // For credit note, quantity is always positive and unit price negative $this->line->ref_supplier=$ref_supplier; + $this->line->qty= ($this->type==self::TYPE_CREDIT_NOTE?abs($qty):$qty); // For credit note, quantity is always positive and unit price negative + $this->line->subprice= ($this->type==self::TYPE_CREDIT_NOTE?-abs($pu_ht):$pu_ht); // For credit note, unit price always negative, always positive otherwise + $this->line->vat_src_code=$vat_src_code; $this->line->tva_tx=$txtva; $this->line->localtax1_tx=($total_localtax1?$localtaxes_type[1]:0); $this->line->localtax2_tx=($total_localtax2?$localtaxes_type[3]:0); $this->line->localtax1_type = $localtaxes_type[0]; $this->line->localtax2_type = $localtaxes_type[2]; - $this->line->fk_product=$fk_product; - $this->line->product_type=$type; - $this->line->remise_percent=$remise_percent; - $this->line->subprice= ($this->type==self::TYPE_CREDIT_NOTE?-abs($pu_ht):$pu_ht); // For credit note, unit price always negative, always positive otherwise - $this->line->date_start=$date_start; - $this->line->date_end=$date_end; - $this->line->ventil=$ventil; - $this->line->rang=$rang; - $this->line->info_bits=$info_bits; + $this->line->total_ht= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ht):$total_ht); // For credit note and if qty is negative, total is negative $this->line->total_tva= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_tva):$total_tva); $this->line->total_localtax1=(($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_localtax1):$total_localtax1); $this->line->total_localtax2=(($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_localtax2):$total_localtax2); $this->line->total_ttc= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ttc):$total_ttc); + + $this->line->fk_product=$fk_product; + $this->line->product_type=$type; + $this->line->remise_percent=$remise_percent; + $this->line->date_start=$date_start; + $this->line->date_end=$date_end; + $this->line->ventil=$ventil; + $this->line->rang=$rang; + $this->line->info_bits=$info_bits; + $this->line->special_code=$this->special_code; $this->line->fk_parent_line=$this->fk_parent_line; $this->line->origin=$this->origin; From 49e03b009f72660f90235c464b346c387186ea72 Mon Sep 17 00:00:00 2001 From: gauthier Date: Wed, 27 Feb 2019 14:50:01 +0100 Subject: [PATCH 096/115] FIX : if empty error message, we just see "error" displayed --- htdocs/core/modules/mailings/xinputfile.modules.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/mailings/xinputfile.modules.php b/htdocs/core/modules/mailings/xinputfile.modules.php index 152322c2899..a026d4b53cf 100644 --- a/htdocs/core/modules/mailings/xinputfile.modules.php +++ b/htdocs/core/modules/mailings/xinputfile.modules.php @@ -179,7 +179,8 @@ class mailing_xinputfile extends MailingTargets { $i++; $langs->load("errors"); - $this->error = $langs->trans("ErrorFoundBadEmailInFile",$i,$cpt,$email); + $msg = $langs->trans("ErrorFoundBadEmailInFile",$i,$cpt,$email); + if(!empty($msg)) $this->error = $msg; } } } From 1237a6d3e9909d1b9b39c373d991c800f09621a0 Mon Sep 17 00:00:00 2001 From: gauthier Date: Wed, 27 Feb 2019 14:58:10 +0100 Subject: [PATCH 097/115] FIX : same thing here --- htdocs/core/modules/mailings/modules_mailings.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/mailings/modules_mailings.php b/htdocs/core/modules/mailings/modules_mailings.php index 1a97f3502b7..9fb14fe1f1d 100644 --- a/htdocs/core/modules/mailings/modules_mailings.php +++ b/htdocs/core/modules/mailings/modules_mailings.php @@ -188,8 +188,8 @@ class MailingTargets // This can't be abstract as it is used for some method if ($this->db->errno() != 'DB_ERROR_RECORD_ALREADY_EXISTS') { // Si erreur autre que doublon - dol_syslog($this->db->error()); - $this->error=$this->db->error(); + dol_syslog($this->db->error().' : '.$targetarray['email']); + $this->error=$this->db->error().' : '.$targetarray['email']; $this->db->rollback(); return -1; } From 4ebf4780c2d684a5c1672e7baf766f28367e757e Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Thu, 28 Feb 2019 09:09:06 +0100 Subject: [PATCH 098/115] fix relative discount for prospect and supplier --- htdocs/comm/remise.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/remise.php b/htdocs/comm/remise.php index 6f3287b8831..7cc675b1816 100644 --- a/htdocs/comm/remise.php +++ b/htdocs/comm/remise.php @@ -165,11 +165,15 @@ if ($socid > 0) print ''; - if($isCustomer && $isSupplier) { + if($isCustomer || $isSupplier) { // Discount type - print ''; - print ''; } From 85d46a5270198d12bb6e7a458ab71a9dcc47ff1e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Feb 2019 11:24:07 +0100 Subject: [PATCH 099/115] Update xinputfile.modules.php --- htdocs/core/modules/mailings/xinputfile.modules.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/mailings/xinputfile.modules.php b/htdocs/core/modules/mailings/xinputfile.modules.php index a026d4b53cf..e636c4885c7 100644 --- a/htdocs/core/modules/mailings/xinputfile.modules.php +++ b/htdocs/core/modules/mailings/xinputfile.modules.php @@ -180,7 +180,8 @@ class mailing_xinputfile extends MailingTargets $i++; $langs->load("errors"); $msg = $langs->trans("ErrorFoundBadEmailInFile",$i,$cpt,$email); - if(!empty($msg)) $this->error = $msg; + if (!empty($msg)) $this->error = $msg; + else $this->error = 'ErrorFoundBadEmailInFile '.$i.' '.$cpt.' '.$email; // We experience case where $langs->trans return an empty string. } } } From cefaeb583ff12ad09c836fcbf6b39d01209e901b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Feb 2019 11:24:43 +0100 Subject: [PATCH 100/115] Update xinputfile.modules.php --- htdocs/core/modules/mailings/xinputfile.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/mailings/xinputfile.modules.php b/htdocs/core/modules/mailings/xinputfile.modules.php index e636c4885c7..1453f247d28 100644 --- a/htdocs/core/modules/mailings/xinputfile.modules.php +++ b/htdocs/core/modules/mailings/xinputfile.modules.php @@ -179,7 +179,7 @@ class mailing_xinputfile extends MailingTargets { $i++; $langs->load("errors"); - $msg = $langs->trans("ErrorFoundBadEmailInFile",$i,$cpt,$email); + $msg = $langs->trans("ErrorFoundBadEmailInFile", $i, $cpt, $email); if (!empty($msg)) $this->error = $msg; else $this->error = 'ErrorFoundBadEmailInFile '.$i.' '.$cpt.' '.$email; // We experience case where $langs->trans return an empty string. } From 855aaaffd8f2a6df7e93019b6fa2ad68ca777a0e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 28 Feb 2019 11:44:10 +0100 Subject: [PATCH 101/115] Better fix for type of discount --- htdocs/comm/card.php | 63 +++++++++++++++++++++++------------------- htdocs/comm/remise.php | 31 +++++++++++---------- 2 files changed, 51 insertions(+), 43 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 2cf3c120af6..be60c4fa574 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -377,38 +377,43 @@ if ($object->id > 0) print ''; } - // Relative discounts (Discounts-Drawbacks-Rebates) - print ''; - print ''; + $isCustomer = ($object->client == 1 || $object->client == 3); - // Absolute discounts (Discounts-Drawbacks-Rebates) - print ''; - print ''; - print ''; // Max outstanding bill if ($object->client) diff --git a/htdocs/comm/remise.php b/htdocs/comm/remise.php index 7cc675b1816..13e4f13ec3d 100644 --- a/htdocs/comm/remise.php +++ b/htdocs/comm/remise.php @@ -106,7 +106,7 @@ if ($socid > 0) $head = societe_prepare_head($object); - $isCustomer = $object->client == 1 || $object->client == 3; + $isCustomer = ($object->client == 1 || $object->client == 3); $isSupplier = $object->fournisseur == 1; print ''; @@ -122,7 +122,7 @@ if ($socid > 0) print '
'; - if(! $isCustomer && ! $isSupplier) { + if (! $isCustomer && ! $isSupplier) { print '

'.$langs->trans('ThirdpartyIsNeitherCustomerNorClientSoCannotHaveDiscounts').'

'; dol_fiche_end(); @@ -136,13 +136,13 @@ if ($socid > 0) print '
'.$langs->trans('DiscountType').' '; - print ' '; + print '
'.$langs->trans('DiscountType').''; + if ($isCustomer) { + print ' '; + } + if ($isSupplier) { + print ' '; + } print '
'; - print '
'; - print $langs->trans("CustomerRelativeDiscountShort"); - print ''; - if ($user->rights->societe->creer && !$user->societe_id > 0) - { - print ''.img_edit($langs->trans("Modify")).''; - } - print '
'; - print '
'.($object->remise_percent?''.$object->remise_percent.'%':'').'
'; - print ''; - print ''; + print ''; + + // Absolute discounts (Discounts-Drawbacks-Rebates) + print ''; + print ''; + print ''; } - print '
'; - print $langs->trans("CustomerAbsoluteDiscountShort"); - print ''; - if ($user->rights->societe->creer && !$user->societe_id > 0) + // Relative discounts (Discounts-Drawbacks-Rebates) + if ($isCustomer) { - print ''.img_edit($langs->trans("Modify")).''; + print '
'; + print '
'; + print $langs->trans("CustomerRelativeDiscountShort"); + print ''; + if ($user->rights->societe->creer && !$user->societe_id > 0) + { + print ''.img_edit($langs->trans("Modify")).''; + } + print '
'; + print '
'.($object->remise_percent?''.$object->remise_percent.'%':'').'
'; + print ''; + print '
'; + print $langs->trans("CustomerAbsoluteDiscountShort"); + print ''; + if ($user->rights->societe->creer && !$user->societe_id > 0) + { + print ''.img_edit($langs->trans("Modify")).''; + } + print '
'; + print '
'; + $amount_discount=$object->getAvailableDiscounts(); + if ($amount_discount < 0) dol_print_error($db,$object->error); + if ($amount_discount > 0) print ''.price($amount_discount,1,$langs,1,-1,-1,$conf->currency).''; + //else print $langs->trans("DiscountNone"); + print '
'; - print '
'; - $amount_discount=$object->getAvailableDiscounts(); - if ($amount_discount < 0) dol_print_error($db,$object->error); - if ($amount_discount > 0) print ''.price($amount_discount,1,$langs,1,-1,-1,$conf->currency).''; - //else print $langs->trans("DiscountNone"); - print '
'; - if($isCustomer) { + if ($isCustomer) { // Customer discount print '"; } - if($isSupplier) { + if ($isSupplier) { // Supplier discount print '"; @@ -155,24 +155,27 @@ if ($socid > 0) print '
'; - if($isCustomer && ! $isSupplier) { - print ''; - } - - if(! $isCustomer && $isSupplier) { - print ''; - } + /*if (! ($isCustomer && $isSupplier)) + { + if ($isCustomer && ! $isSupplier) { + print ''; + } + if (! $isCustomer && $isSupplier) { + print ''; + } + }*/ print '
'; print $langs->trans("CustomerRelativeDiscount").''.price2num($object->remise_percent)."%
'; print $langs->trans("SupplierRelativeDiscount").''.price2num($object->remise_supplier_percent)."%
'; - if($isCustomer || $isSupplier) { + if ($isCustomer || $isSupplier) + { // Discount type print ''; } From 786c1140267c6c6977f7c636a7c15b035fa2876c Mon Sep 17 00:00:00 2001 From: gauthier Date: Thu, 28 Feb 2019 16:13:45 +0100 Subject: [PATCH 102/115] FIX : project_title for display of getNomUrl() --- htdocs/fourn/commande/list.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index d26c950d4fe..0c0a9d6583b 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -482,7 +482,7 @@ $sql.= " typent.code as typent_code,"; $sql.= " state.code_departement as state_code, state.nom as state_name,"; $sql.= " cf.rowid, cf.ref, cf.ref_supplier, cf.fk_statut, cf.billed, cf.total_ht, cf.tva as total_tva, cf.total_ttc, cf.fk_user_author, cf.date_commande as date_commande, cf.date_livraison as date_delivery,"; $sql.= ' cf.date_creation as date_creation, cf.tms as date_update,'; -$sql.= " p.rowid as project_id, p.ref as project_ref,"; +$sql.= " p.rowid as project_id, p.ref as project_ref, p.title as project_title,"; $sql.= " u.firstname, u.lastname, u.photo, u.login"; // Add fields from extrafields foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : ''); @@ -988,6 +988,7 @@ if ($resql) { $projectstatic->id=$obj->project_id; $projectstatic->ref=$obj->project_ref; + $projectstatic->title=$obj->project_title; print ''; From b96ac794e9f69b1d22690ea4df34c895db7beee7 Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio Date: Thu, 28 Feb 2019 16:15:32 +0100 Subject: [PATCH 103/115] FIX: actioncomm export: ORDER BY clause is in wrong export property + event type filter does not work --- htdocs/core/modules/modAgenda.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modAgenda.class.php b/htdocs/core/modules/modAgenda.class.php index 6c8fda578f2..75630b4895a 100644 --- a/htdocs/core/modules/modAgenda.class.php +++ b/htdocs/core/modules/modAgenda.class.php @@ -395,7 +395,7 @@ class modAgenda extends DolibarrModules $this->export_TypeFields_array[$r]=array('ac.ref_ext'=>"Text",'ac.datec'=>"Date",'ac.datep'=>"Date", 'ac.datep2'=>"Date",'ac.label'=>"Text",'ac.note'=>"Text",'ac.percent'=>"Numeric", 'ac.durationp'=>"Duree", - 'cac.libelle'=>"List:c_actioncomm:libelle:id", + 'cac.libelle'=>"List:c_actioncomm:libelle:libelle", 's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text', 'co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.idprof5'=>'Text','s.idprof6'=>'Text', 's.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text'); @@ -417,7 +417,7 @@ class modAgenda extends DolibarrModules $this->export_sql_end[$r] .=' WHERE ac.entity IN ('.getEntity('agenda').')'; if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND (sc.fk_user = '.(empty($user)?0:$user->id).' OR ac.fk_soc IS NULL)'; if (empty($user->rights->agenda->allactions->read)) $this->export_sql_end[$r] .=' AND acr.fk_element = '.(empty($user)?0:$user->id); - $this->export_sql_end[$r] .=' ORDER BY ac.datep'; + $this->export_sql_order[$r] .=' ORDER BY ac.datep'; } From 3037e4a15730bd5f632f9902df631786123e64bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 2 Mar 2019 20:49:53 +0100 Subject: [PATCH 104/115] Update DolibarrModules.class.php --- htdocs/core/modules/DolibarrModules.class.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 0140f850e34..9b9ed4f7a60 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -895,6 +895,8 @@ class DolibarrModules // Can not be abstract, because we need to insta { global $conf; + $err = 0; + $sql = "SELECT tms FROM ".MAIN_DB_PREFIX."const"; $sql.= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($this->const_name)."'"; $sql.= " AND entity IN (0, ".$conf->entity.")"; @@ -921,6 +923,8 @@ class DolibarrModules // Can not be abstract, because we need to insta { global $conf; + $err = 0; + $sql = "SELECT tms, note FROM ".MAIN_DB_PREFIX."const"; $sql.= " WHERE ".$this->db->decrypt('name')." = '".$this->db->escape($this->const_name)."'"; $sql.= " AND entity IN (0, ".$conf->entity.")"; From 526bd1d02e28995e5485769f80df60c282c2515d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 3 Mar 2019 17:36:43 +0100 Subject: [PATCH 105/115] Fix number format --- htdocs/product/stock/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 5dca091c56b..cdbc49da21e 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -509,7 +509,7 @@ else print ''; print ''; $totalunit+=$objp->value; From dada8c8ff57ce95538bda83a0074b585dbe5ad1c Mon Sep 17 00:00:00 2001 From: gauthier Date: Mon, 4 Mar 2019 17:23:29 +0100 Subject: [PATCH 106/115] FIX : wrong redirect link on holiday refuse --- htdocs/holiday/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index be61223d704..b69f6fb185b 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -568,7 +568,7 @@ if ($action == 'confirm_refuse') } } else { - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'&error=NoMotifRefuse'); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id.'&error=NoMotifRefuse'); exit; } } From 54b9681257171e9c15215290f71295bb09384344 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Mar 2019 20:15:31 +0100 Subject: [PATCH 107/115] More log to help debug --- htdocs/core/login/functions_dolibarr.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/core/login/functions_dolibarr.php b/htdocs/core/login/functions_dolibarr.php index 25d5f2dc30c..eede3bf2ee6 100644 --- a/htdocs/core/login/functions_dolibarr.php +++ b/htdocs/core/login/functions_dolibarr.php @@ -80,7 +80,7 @@ function check_user_password_dolibarr($usertotest,$passwordtotest,$entitytotest= if (! empty($conf->global->DATABASE_PWD_ENCRYPTED)) $cryptType=$conf->global->DATABASE_PWD_ENCRYPTED; // By default, we used MD5 - if (! in_array($cryptType,array('md5'))) $cryptType='md5'; + if (! in_array($cryptType, array('md5'))) $cryptType='md5'; // Check crypted password according to crypt algorithm if ($cryptType == 'md5') { @@ -109,8 +109,9 @@ function check_user_password_dolibarr($usertotest,$passwordtotest,$entitytotest= } else { - dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ko bad password for '".$usertotest."'"); - sleep(2); // Anti brut force protection + dol_syslog("functions_dolibarr::check_user_password_dolibarr Authentification ko bad password for '".$usertotest."', cryptType=".$cryptType); + //dol_syslog("passclear=".$passclear." passtyped=".$passtyped." passcrypted=".$passcrypted); + sleep(2); // Anti brut force protection $langs->load('main'); $langs->load('errors'); $_SESSION["dol_loginmesg"]=$langs->trans("ErrorBadLoginPassword"); From 1bbf6737ecbf48948cb2c70f52a0ab513d2e3455 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 5 Mar 2019 15:27:31 +0100 Subject: [PATCH 108/115] add session newtoken --- htdocs/exports/export.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index ec11f9c1771..6888f638a27 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -761,6 +761,7 @@ if ($step == 3 && $datatoexport) // un formulaire en plus pour recuperer les filtres print ''; + print ''; print '
'.$langs->trans('DiscountType').''; if ($isCustomer) { - print ' '; + print ' '; } if ($isSupplier) { - print ' '; + print ' '; } print '
'; if ($obj->project_id > 0) print $projectstatic->getNomUrl(1); print ''.$objp->produit.''; - $valtoshow=price2num($objp->value, 'MS'); + $valtoshow=price(price2num($objp->value, 'MS'), 0, '', 0, 0); // TODO replace with a qty() function print empty($valtoshow)?'0':$valtoshow; print '
'; print ''; print ''; From 0ff29051802d477a47071e75d5ebba9744b48f99 Mon Sep 17 00:00:00 2001 From: gauthier Date: Wed, 6 Mar 2019 12:10:24 +0100 Subject: [PATCH 109/115] FIX : we need to keep originline special_code --- htdocs/fourn/class/fournisseur.facture.class.php | 4 ++-- htdocs/fourn/facture/card.php | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 309230a4dcc..b0351252c0b 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1386,7 +1386,7 @@ class FactureFournisseur extends CommonInvoice * * FIXME Add field ref (that should be named ref_supplier) and label into update. For example can be filled when product line created from order. */ - public function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0, $rang=-1, $notrigger=false, $array_options=0, $fk_unit=null, $origin_id=0, $pu_ht_devise=0, $ref_supplier='') + public function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0, $rang=-1, $notrigger=false, $array_options=0, $fk_unit=null, $origin_id=0, $pu_ht_devise=0, $ref_supplier='', $special_code='') { dol_syslog(get_class($this)."::addline $desc,$pu,$qty,$txtva,$fk_product,$remise_percent,$date_start,$date_end,$ventil,$info_bits,$price_base_type,$type,$fk_unit", LOG_DEBUG); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; @@ -1481,7 +1481,7 @@ class FactureFournisseur extends CommonInvoice $this->line->total_localtax1=$total_localtax1; $this->line->total_localtax2=$total_localtax2; $this->line->total_ttc= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ttc):$total_ttc); - $this->line->special_code=$this->special_code; + $this->line->special_code=!empty($special_code) ? $special_code : $this->special_code; $this->line->fk_parent_line=$this->fk_parent_line; $this->line->origin=$this->origin; $this->line->origin_id=$origin_id; diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index cc9164b753f..3e7df0b27f3 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -716,7 +716,10 @@ if (empty($reshook)) 0, $lines[$i]->array_options, $lines[$i]->fk_unit, - $lines[$i]->id + $lines[$i]->id, + 0, + '', + $lines[$i]->special_code ); if ($result < 0) From 96b8da0d6247fd0d12f77f71ba664e2dc485dee2 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Wed, 6 Mar 2019 22:04:01 +0100 Subject: [PATCH 110/115] fix supllier discount --- htdocs/core/tpl/objectline_create.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 61818d4deb9..d598c18a33e 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -268,7 +268,7 @@ else { } else { - $ajaxoptions = array(); + $ajaxoptions = array('update' => array('remise_percent' => 'discount')); $alsoproductwithnosupplierprice=1; } From e3fb228a4d148265945c5a0008019f9534b18221 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Mar 2019 12:28:19 +0100 Subject: [PATCH 111/115] Update fournisseur.facture.class.php --- htdocs/fourn/class/fournisseur.facture.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index b0351252c0b..4642c0bf753 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1481,7 +1481,7 @@ class FactureFournisseur extends CommonInvoice $this->line->total_localtax1=$total_localtax1; $this->line->total_localtax2=$total_localtax2; $this->line->total_ttc= (($this->type==self::TYPE_CREDIT_NOTE||$qty<0)?-abs($total_ttc):$total_ttc); - $this->line->special_code=!empty($special_code) ? $special_code : $this->special_code; + $this->line->special_code=((string) $special_code != '' ? $special_code : $this->special_code); $this->line->fk_parent_line=$this->fk_parent_line; $this->line->origin=$this->origin; $this->line->origin_id=$origin_id; From 0349f9bfaae2331f818d3c97f7a13aa15af88457 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Mar 2019 13:26:25 +0100 Subject: [PATCH 112/115] Update objectline_create.tpl.php --- htdocs/core/tpl/objectline_create.tpl.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index d598c18a33e..73d06b3e0aa 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -260,15 +260,17 @@ else { if ($senderissupplier != 2) { $ajaxoptions=array( - 'update' => array('qty'=>'qty','remise_percent' => 'discount','idprod' => 'idprod'), // html id tags that will be edited with which ajax json response key - 'option_disabled' => 'idthatdoesnotexists', // html id to disable once select is done - 'warning' => $langs->trans("NoPriceDefinedForThisSupplier") // translation of an error saved into var 'warning' (for exemple shown we select a disabled option into combo) + 'update' => array('qty'=>'qty','remise_percent' => 'discount','idprod' => 'idprod'), // html id tags that will be edited with each ajax json response key + 'option_disabled' => 'idthatdoesnotexists', // html id to disable once select is done + 'warning' => $langs->trans("NoPriceDefinedForThisSupplier") // translation of an error saved into var 'warning' (for exemple shown we select a disabled option into combo) ); $alsoproductwithnosupplierprice=0; } else { - $ajaxoptions = array('update' => array('remise_percent' => 'discount')); + $ajaxoptions = array( + 'update' => array('remise_percent' => 'discount') // html id tags that will be edited with each ajax json response key + ); $alsoproductwithnosupplierprice=1; } From 9a9fd15077dfe3eacac754f537ffeda956601747 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Mar 2019 14:10:33 +0100 Subject: [PATCH 113/115] Fix doxygen --- htdocs/fourn/class/fournisseur.facture.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index d08e8efd919..3a27690e7ac 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1501,6 +1501,7 @@ class FactureFournisseur extends CommonInvoice * @param int $origin_id id origin document * @param double $pu_ht_devise Amount in currency * @param string $ref_supplier Supplier ref + * @param string $special_code Special code * @return int >0 if OK, <0 if KO */ public function addline($desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0, $rang=-1, $notrigger=false, $array_options=0, $fk_unit=null, $origin_id=0, $pu_ht_devise=0, $ref_supplier='', $special_code='') From 233bd4374a3849b6cd575ecc36b78528bbd5caba Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Mar 2019 19:52:26 +0100 Subject: [PATCH 114/115] Fix phpcs --- htdocs/fourn/class/fournisseur.facture.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 4642c0bf753..46c50a75256 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1382,6 +1382,7 @@ class FactureFournisseur extends CommonInvoice * @param int $origin_id id origin document * @param double $pu_ht_devise Amount in currency * @param string $ref_supplier Supplier ref + * @param string $special_code Special code * @return int >0 if OK, <0 if KO * * FIXME Add field ref (that should be named ref_supplier) and label into update. For example can be filled when product line created from order. From 4022d5f5296746526ea5b6d332764bf6b9884fa2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Mar 2019 23:58:04 +0100 Subject: [PATCH 115/115] FIX Can not create contract with numbering module without autogen rule --- htdocs/contrat/class/contrat.class.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index dc94d57809f..2b9de7fc9e2 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -892,6 +892,7 @@ class Contrat extends CommonObject $sql.= ", ".(!empty($this->ref_ext)?("'".$this->db->escape($this->ref_ext)."'"):"NULL"); $sql.= ")"; $resql=$this->db->query($sql); + if ($resql) { $error=0; @@ -908,9 +909,8 @@ class Contrat extends CommonObject if ($result > 0) { $modCodeContract = new $module(); - - if (!empty($modCodeContract->code_auto)) { - // Mise a jour ref + if (! empty($modCodeContract->code_auto)) { + // Force the ref to a draft value if numbering module is an automatic numbering $sql = 'UPDATE '.MAIN_DB_PREFIX."contrat SET ref='(PROV".$this->id.")' WHERE rowid=".$this->id; if ($this->db->query($sql)) { @@ -919,9 +919,6 @@ class Contrat extends CommonObject $this->ref="(PROV".$this->id.")"; } } - } else { - $error++; - $this->error='Failed to get PROV number'; } } @@ -1389,7 +1386,7 @@ class Contrat extends CommonObject if (empty($remise_percent)) $remise_percent=0; $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->societe, $mysoc); - + // Clean vat code $vat_src_code=''; if (preg_match('/\((.*)\)/', $txtva, $reg)) @@ -1397,7 +1394,7 @@ class Contrat extends CommonObject $vat_src_code = $reg[1]; $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } - + // Calcul du total TTC et de la TVA pour la ligne a partir de // qty, pu, remise_percent et txtva // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
'.$langs->trans("Entities").'