From f95bd2f4396f9f159c1e872b96a16f7a84ebd92c Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 17 May 2021 11:40:36 +0200 Subject: [PATCH 01/22] fixw that --- htdocs/core/modules/propale/doc/pdf_cyan.modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 7c9f4e6fe77..8ce23e6f9ad 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -424,7 +424,7 @@ class pdf_cyan extends ModelePDFPropales $salereparray = $object->thirdparty->getSalesRepresentatives($user); $salerepobj = new User($this->db); $salerepobj->fetch($salereparray[0]['id']); - if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature); + if (!empty($salerepobj->signature)) $notetoshow .= dol_concatdesc($notetoshow, $salerepobj->signature); } } From 6f3d19b7b63c3fb62997dc64f8a32b16065501de Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 17 May 2021 15:12:25 +0200 Subject: [PATCH 02/22] dol_concatdesc better than concat operator --- htdocs/core/modules/propale/doc/pdf_cyan.modules.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 8ce23e6f9ad..2b40dffa30e 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -424,7 +424,7 @@ class pdf_cyan extends ModelePDFPropales $salereparray = $object->thirdparty->getSalesRepresentatives($user); $salerepobj = new User($this->db); $salerepobj->fetch($salereparray[0]['id']); - if (!empty($salerepobj->signature)) $notetoshow .= dol_concatdesc($notetoshow, $salerepobj->signature); + if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature); } } @@ -438,9 +438,11 @@ class pdf_cyan extends ModelePDFPropales { $tmpuser = new User($this->db); $tmpuser->fetch($object->user_author_id); - $notetoshow .= $langs->trans("CaseFollowedBy").' '.$tmpuser->getFullName($langs); - if ($tmpuser->email) $notetoshow .= ', Mail: '.$tmpuser->email; - if ($tmpuser->office_phone) $notetoshow .= ', Tel: '.$tmpuser->office_phone; + $creator_info = $langs->trans("CaseFollowedBy").' '.$tmpuser->getFullName($langs); + if ($tmpuser->email) $creator_info .= ', Mail: '.$tmpuser->email; + if ($tmpuser->office_phone) $creator_info .= ', Tel: '.$tmpuser->office_phone; + + $notetoshow = dol_concatdesc($notetoshow, $creator_info); } $tab_height = $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter; From 60176f7f5ed78b0e43a2240cb286722280c1bde7 Mon Sep 17 00:00:00 2001 From: piernov Date: Mon, 24 May 2021 18:01:27 +0200 Subject: [PATCH 03/22] Fix add/del user to group modifies LDAP group Adding or removing a user from a group modifies the user object on Dolibarr's side. In LDAP however, members of a group are stored in the group itself. Therefore group must be updated after adding/removing a user from it. Update group in LDAP with new list of users at the end of USER_MODIFY trigger. --- ...interface_50_modLdap_Ldapsynchro.class.php | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php b/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php index d0b91bcbe37..d92f4c3ecc4 100644 --- a/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php +++ b/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php @@ -126,6 +126,52 @@ class InterfaceLdapsynchro extends DolibarrTriggers $newparent = $object->_load_ldap_dn($info, 1); $result = $ldap->update($dn, $info, $user, $olddn, $newrdn, $newparent); + + if ($result > 0 && !empty($object->context['newgroupid'])) { // We are in context of adding a new group to user + $usergroup = new Usergroup($this->db); + + $usergroup->fetch($object->context['newgroupid']); + + $oldinfo = $usergroup->_load_ldap_info(); + $olddn = $usergroup->_load_ldap_dn($oldinfo); + + // Verify if entry exist + $container = $usergroup->_load_ldap_dn($oldinfo, 1); + $search = "(".$usergroup->_load_ldap_dn($oldinfo, 2).")"; + $records = $ldap->search($container, $search); + if (count($records) && $records['count'] == 0) + { + $olddn = ''; + } + + $info = $usergroup->_load_ldap_info(); // Contains all members, included the new one (insert already done before trigger call) + $dn = $usergroup->_load_ldap_dn($info); + + $result = $ldap->update($dn, $info, $user, $olddn); + } + + if ($result > 0 && !empty($object->context['oldgroupid'])) { // We are in context of removing a group from user + $usergroup = new Usergroup($this->db); + + $usergroup->fetch($object->context['oldgroupid']); + + $oldinfo = $usergroup->_load_ldap_info(); + $olddn = $usergroup->_load_ldap_dn($oldinfo); + + // Verify if entry exist + $container = $usergroup->_load_ldap_dn($oldinfo, 1); + $search = "(".$usergroup->_load_ldap_dn($oldinfo, 2).")"; + $records = $ldap->search($container, $search); + if (count($records) && $records['count'] == 0) + { + $olddn = ''; + } + + $info = $usergroup->_load_ldap_info(); // Contains all members, except the old one (remove already done before trigger call) + $dn = $usergroup->_load_ldap_dn($info); + + $result = $ldap->update($dn, $info, $user, $olddn); + } } if ($result < 0) $this->error = "ErrorLDAP ".$ldap->error; From bad90240bc8b6fda2ecf88489af2ae4ec22f0cc9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 25 May 2021 21:39:50 +0200 Subject: [PATCH 04/22] Update pdf_cyan.modules.php --- htdocs/core/modules/propale/doc/pdf_cyan.modules.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 2b40dffa30e..4d2d159ec02 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -434,13 +434,12 @@ class pdf_cyan extends ModelePDFPropales $notetoshow = dol_concatdesc($notetoshow, $extranote); } - if (!empty($conf->global->MAIN_ADD_CREATOR_IN_NOTE) && $object->user_author_id > 0) - { + if (!empty($conf->global->MAIN_ADD_CREATOR_IN_NOTE) && $object->user_author_id > 0) { $tmpuser = new User($this->db); $tmpuser->fetch($object->user_author_id); $creator_info = $langs->trans("CaseFollowedBy").' '.$tmpuser->getFullName($langs); - if ($tmpuser->email) $creator_info .= ', Mail: '.$tmpuser->email; - if ($tmpuser->office_phone) $creator_info .= ', Tel: '.$tmpuser->office_phone; + if ($tmpuser->email) $creator_info .= ', '.$langs->trans("EMail").': '.$tmpuser->email; + if ($tmpuser->office_phone) $creator_info .= ', '.$langs->trans("Phone").': '.$tmpuser->office_phone; $notetoshow = dol_concatdesc($notetoshow, $creator_info); } From 1d5b8cbb19f82a4c6192ee1c66bd677f5ce2a9bc Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Wed, 26 May 2021 14:59:28 +0200 Subject: [PATCH 05/22] Fix Quadra accountancy export for due date --- htdocs/accountancy/class/accountancyexport.class.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 114d0edf35a..0459c20a380 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -498,9 +498,8 @@ class AccountancyExport $Tab['contrepartie'] = str_repeat(' ', 8); // elarifr: date format must be fixed format : 6 char ddmmyy = %d%m%yand not defined by user / dolibarr setting - if (!empty($data->date_echeance)) - //$Tab['date_echeance'] = dol_print_date($data->date_echeance, $conf->global->ACCOUNTING_EXPORT_DATE); - $Tab['date_echeance'] = dol_print_date($data->date_echeance, '%d%m%y'); // elarifr: format must be ddmmyy + if (!empty($data->date_lim_reglement)) + $Tab['date_echeance'] = dol_print_date($data->date_lim_reglement, '%d%m%y'); // elarifr: format must be ddmmyy else $Tab['date_echeance'] = '000000'; From b3a6bcd34f6b66a69b8614eadb4d1b9b8c90da0c Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Wed, 26 May 2021 15:01:31 +0200 Subject: [PATCH 06/22] Fix Winfic accountancy export for due date --- htdocs/accountancy/class/accountancyexport.class.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 6fd3518689d..358d0e282c8 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -617,9 +617,8 @@ class AccountancyExport $Tab['code_stat'] = str_repeat(' ', 4); - if (!empty($data->date_echeance)) - //$Tab['date_echeance'] = dol_print_date($data->date_echeance, $conf->global->ACCOUNTING_EXPORT_DATE); - $Tab['date_echeance'] = dol_print_date($data->date_echeance, '%d%m%Y'); + if (!empty($data->date_lim_reglement)) + $Tab['date_echeance'] = dol_print_date($data->date_lim_reglement, '%d%m%Y'); else $Tab['date_echeance'] = dol_print_date($data->doc_date, '%d%m%Y'); From 421681cda4c9ed77c8fefcaece3f18681a1fe01f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 26 May 2021 15:22:49 +0200 Subject: [PATCH 07/22] FIX Navigation in list of holiday Conflicts: htdocs/holiday/view_log.php --- htdocs/holiday/view_log.php | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/htdocs/holiday/view_log.php b/htdocs/holiday/view_log.php index 2f2e223c87c..86562ef5f96 100644 --- a/htdocs/holiday/view_log.php +++ b/htdocs/holiday/view_log.php @@ -323,7 +323,7 @@ if (!empty($arrayfields['cpl.fk_type']['checked'])) { // Filter: Previous balance if (!empty($arrayfields['cpl.prev_solde']['checked'])) { - print ''; + print ''; print ''; print ''; } @@ -335,7 +335,7 @@ if (!empty($arrayfields['variation']['checked'])) { // Filter: New Balance if (!empty($arrayfields['cpl.new_solde']['checked'])) { - print ''; + print ''; print ''; print ''; } @@ -360,13 +360,20 @@ if (!empty($arrayfields['cpl.new_solde']['checked'])) print_liste_field_titre($a print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print ''; -// TODO: $i = 0; -$i = 1; -while ($i < min($num, $limit)) -{ - //TODO: $obj = $db->fetch_object($resql); +$j = 0; +while ($j < ($page * $limit)) { $obj = next($object->logs); + $j++; +} + +$i = 0; +while ($i < min($num, $limit)) { + //TODO: $obj = $db->fetch_object($resql); + $obj = current($object->logs); + if (empty($obj)) { + break; + } $holidaylogstatic->id = $obj['rowid']; $holidaylogstatic->date = $obj['date_action']; @@ -444,6 +451,7 @@ while ($i < min($num, $limit)) print ''; $i++; + next($object->logs); } if ($log_holiday == '2') { From 9c83bdff519aa2a6ce88ad98083efcbb79c6b184 Mon Sep 17 00:00:00 2001 From: Adrien Raze Date: Wed, 26 May 2021 17:02:34 +0200 Subject: [PATCH 08/22] FIX : Add parameters (object and action) for user list DoActions hook --- htdocs/user/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/list.php b/htdocs/user/list.php index 1f59656dcbd..e2b4fd3889d 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -154,7 +154,7 @@ if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction = ''; } $parameters = array(); -$reshook = $hookmanager->executeHooks('doActions', $parameters); // Note that $action and $object may have been modified by some hooks +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) From 81a94f5642b22507a07b82085412854b57d4f1d8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 28 May 2021 18:04:45 +0200 Subject: [PATCH 09/22] FIX option MAIN_GENERATE_SUPPLIER_PROPOSAL_WITH_PICTURE --- .../doc/pdf_aurore.modules.php | 2 +- htdocs/product/class/product.class.php | 32 +++++++++++-------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index e9e2179823b..3da4d72746b 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -239,7 +239,7 @@ class pdf_aurore extends ModelePDFSupplierProposal $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/"; $dir = $conf->product->dir_output.'/'.$pdir; } else { - $pdir = get_exdir(0, 2, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; + $pdir = get_exdir(0, 0, 0, 0, $objphoto, 'product'); $dir = $conf->product->dir_output.'/'.$pdir; } diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 685180e4659..1e60a0f63d3 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -5208,11 +5208,11 @@ class Product extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Retourne tableau de toutes les photos du produit + * Return an array with all photos of product found on disk. There is no sorting criteria. * - * @param string $dir Repertoire a scanner - * @param int $nbmax Nombre maximum de photos (0=pas de max) - * @return array Tableau de photos + * @param string $dir Directory to scan + * @param int $nbmax Number maxium of photos (0=no maximum) + * @return array Array of photos */ public function liste_photos($dir, $nbmax = 0) { @@ -5226,16 +5226,17 @@ class Product extends CommonObject $dir_osencoded = dol_osencode($dir); $handle = @opendir($dir_osencoded); if (is_resource($handle)) { - while (($file = readdir($handle)) !== false) - { - if (!utf8_check($file)) { $file = utf8_encode($file); // readdir returns ISO + while (($file = readdir($handle)) !== false) { + if (!utf8_check($file)) { + $file = utf8_encode($file); // readdir returns ISO } if (dol_is_file($dir.$file) && image_format_supported($file) >= 0) { $nbphoto++; - // On determine nom du fichier vignette + // We forge name of thumb. $photo = $file; $photo_vignette = ''; + $regs = array(); if (preg_match('/('.$this->regeximgext.')$/i', $photo, $regs)) { $photo_vignette = preg_replace('/'.$regs[0].'/i', '', $photo).'_small'.$regs[0]; } @@ -5245,14 +5246,17 @@ class Product extends CommonObject // Objet $obj = array(); $obj['photo'] = $photo; - if ($photo_vignette && dol_is_file($dirthumb.$photo_vignette)) { $obj['photo_vignette'] = 'thumbs/'.$photo_vignette; - } else { $obj['photo_vignette'] = ""; + if ($photo_vignette && dol_is_file($dirthumb.$photo_vignette)) { + $obj['photo_vignette'] = 'thumbs/'.$photo_vignette; + } else { + $obj['photo_vignette'] = ""; } $tabobj[$nbphoto - 1] = $obj; - // On continue ou on arrete de boucler ? - if ($nbmax && $nbphoto >= $nbmax) { break; + // Do we have to continue with next photo ? + if ($nbmax && $nbphoto >= $nbmax) { + break; } } } @@ -5265,9 +5269,9 @@ class Product extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Efface la photo du produit et sa vignette + * Delete a photo and its thumbs * - * @param string $file Chemin de l'image + * @param string $file Path to image file * @return void */ public function delete_photo($file) From ab4941a558ff55ce00aabbc7bab1807216abd0c1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 29 May 2021 02:22:30 +0200 Subject: [PATCH 10/22] Fix not visible button when missing permission --- htdocs/fichinter/card.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 0b919c3eb4b..84c4fd61c62 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -1606,8 +1606,9 @@ if ($action == 'create') // Validate if ($object->statut == Fichinter::STATUS_DRAFT && (count($object->lines) > 0 || !empty($conf->global->FICHINTER_DISABLE_DETAILS))) { if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->creer) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->ficheinter_advance->validate)) { - print ''; + print ''; + } else { + print '
'.$langs->trans("Validate").'
'; } } @@ -1640,7 +1641,7 @@ if ($action == 'create') } } - // create intervention model + // Create intervention model if ($conf->global->MAIN_FEATURES_LEVEL >= 1 && $object->statut == Fichinter::STATUS_DRAFT && $user->rights->ficheinter->creer && (count($object->lines) > 0)) { print '
'; print ''.$langs->trans("ChangeIntoRepeatableIntervention").''; From e1de510c389396730d4aef03ccecd780b226f3c3 Mon Sep 17 00:00:00 2001 From: TuxGasy Date: Mon, 31 May 2021 11:06:52 +0200 Subject: [PATCH 11/22] Do a strict comparison when check if stock is enough --- htdocs/product/stock/class/mouvementstock.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 2429a4c09c5..ec2dfbc257e 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -355,7 +355,7 @@ class MouvementStock extends CommonObject $qtyisnotenough = 0; foreach ($product->stock_warehouse[$entrepot_id]->detail_batch as $batchcursor => $prodbatch) { - if ($batch != $batchcursor) continue; + if ($batch !== $batchcursor) continue; // Do a strict comparison because $batchcursar can be an integer $foundforbatch = 1; if ($prodbatch->qty < abs($qty)) $qtyisnotenough = $prodbatch->qty; break; From 90ae16372c7d2cc0a6d8939b224230b267909744 Mon Sep 17 00:00:00 2001 From: Pierre Payet Date: Mon, 31 May 2021 12:11:16 +0200 Subject: [PATCH 12/22] add missing hooks in societe list.php --- htdocs/societe/list.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 0df74bc166e..fe55d05dda4 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -429,6 +429,10 @@ $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."c_stcomm as st ON s.fk_stcomm = st.id"; // We'll need this table joined to the select in order to filter by sale if ($search_sale == -2) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; elseif ($search_sale || (!$user->rights->societe->client->voir && !$socid)) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +// Add table from hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; $sql .= " WHERE s.entity IN (".getEntity('societe').")"; if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($search_sale && $search_sale != -2) $sql .= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale @@ -490,6 +494,11 @@ if (empty($reshook)) { } $sql .= $hookmanager->resPrint; +// Add GroupBy from hooks +$parameters = array('all' => $all, 'fieldstosearchall' => $fieldstosearchall); +$reshook = $hookmanager->executeHooks('printFieldListGroupBy', $parameters, $object); // Note that $action and $object may have been modified by hook +$sql .= $hookmanager->resPrint; + $sql .= $db->order($sortfield, $sortorder); // Count total nb of records From c91b9d613afc5c72f27b59e554b53a75ed3cc299 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 1 Jun 2021 15:30:17 +0200 Subject: [PATCH 13/22] FIX: order supplier stats by category now display figures --- htdocs/commande/class/commandestats.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/commande/class/commandestats.class.php b/htdocs/commande/class/commandestats.class.php index cbb93b940de..7d98c5be996 100644 --- a/htdocs/commande/class/commandestats.class.php +++ b/htdocs/commande/class/commandestats.class.php @@ -78,6 +78,7 @@ class CommandeStats extends Stats $this->field = 'total_ht'; $this->field_line = 'total_ht'; $this->where .= " c.fk_statut > 0"; // Not draft and not cancelled + $this->categ_link=MAIN_DB_PREFIX.'categorie_societe'; } elseif ($mode == 'supplier') { @@ -87,6 +88,7 @@ class CommandeStats extends Stats $this->field = 'total_ht'; $this->field_line = 'total_ht'; $this->where .= " c.fk_statut > 2"; // Only approved & ordered + $this->categ_link=MAIN_DB_PREFIX.'categorie_fournisseur'; } //$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity; $this->where .= ' AND c.entity IN ('.getEntity('commande').')'; @@ -106,7 +108,7 @@ class CommandeStats extends Stats if ($categid) { - $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cats ON cats.fk_soc = c.fk_soc'; + $this->join .= ' LEFT JOIN '.$this->categ_link.' as cats ON cats.fk_soc = c.fk_soc'; $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as cat ON cat.rowid = cats.fk_categorie'; $this->where .= ' AND cat.rowid = '.$categid; } From 5a260865dc32c90c573c3b2889bbfee0e50d555b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 2 Jun 2021 04:15:21 +0200 Subject: [PATCH 14/22] FIX Creation of reception (missing extrafields). Lose data if error. Conflicts: htdocs/reception/card.php --- htdocs/reception/card.php | 105 ++++++++++++++++++++++---------------- 1 file changed, 60 insertions(+), 45 deletions(-) diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 18aa08b0d85..8b49f143176 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -62,7 +62,7 @@ if (!empty($conf->incoterm->enabled)) $langs->load('incoterm'); if (!empty($conf->productbatch->enabled)) $langs->load('productbatch'); $origin = GETPOST('origin', 'alpha') ?GETPOST('origin', 'alpha') : 'reception'; // Example: commande, propal -$origin_id = GETPOST('id', 'int') ?GETPOST('id', 'int') : ''; +$origin_id = GETPOST('id', 'int') ? GETPOST('id', 'int') : ''; $id = $origin_id; if (empty($origin_id)) $origin_id = GETPOST('origin_id', 'int'); // Id of order or propal if (empty($origin_id)) $origin_id = GETPOST('object_id', 'int'); // Id of order or propal @@ -87,7 +87,7 @@ $action = GETPOST('action', 'alpha'); if (GETPOST('modelselected')) { $action = 'presend'; } -$confirm = GETPOST('confirm', 'alpha'); +$confirm = GETPOST('confirm', 'alpha'); $cancel = GETPOST('cancel', 'alpha'); //PDF @@ -707,14 +707,13 @@ if ($action == 'create') if ($origin == 'supplierorder')$classname = 'CommandeFournisseur'; else $classname = ucfirst($origin); - $object = new $classname($db); - if ($object->fetch($origin_id)) // This include the fetch_lines - { + $objectsrc = new $classname($db); + if ($objectsrc->fetch($origin_id)) { // This include the fetch_lines $soc = new Societe($db); - $soc->fetch($object->socid); + $soc->fetch($objectsrc->socid); $author = new User($db); - $author->fetch($object->user_author_id); + $author->fetch($objectsrc->user_author_id); if (!empty($conf->stock->enabled)) $entrepot = new Entrepot($db); @@ -722,10 +721,8 @@ if ($action == 'create') print ''; print ''; print ''; - print ''; - print ''; - if (GETPOST('entrepot_id', 'int')) - { + print ''; + if (GETPOST('entrepot_id', 'int')) { print ''; } @@ -735,13 +732,11 @@ if ($action == 'create') // Ref print ''; - if ($origin == 'supplierorder' && !empty($conf->fournisseur->enabled)) - { - print $langs->trans("RefOrder").''.img_object($langs->trans("ShowOrder"), 'order').' '.$object->ref; + if ($origin == 'supplierorder' && ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled))) { + print $langs->trans("RefOrder").''.img_object($langs->trans("ShowOrder"), 'order').' '.$objectsrc->ref; } - if ($origin == 'propal' && !empty($conf->propal->enabled)) - { - print $langs->trans("RefProposal").''.img_object($langs->trans("ShowProposal"), 'propal').' '.$object->ref; + if ($origin == 'propal' && !empty($conf->propal->enabled)) { + print $langs->trans("RefProposal").''.img_object($langs->trans("ShowProposal"), 'propal').' '.$objectsrc->ref; } print ''; print "\n"; @@ -751,7 +746,7 @@ if ($action == 'create') if ($origin == 'supplier_order') print $langs->trans('SupplierOrder'); else print $langs->trans('RefSupplier'); print ''; - print ''; + print ''; print ''; print ''; @@ -764,8 +759,12 @@ if ($action == 'create') if (!empty($conf->projet->enabled)) { $projectid = GETPOST('projectid', 'int') ?GETPOST('projectid', 'int') : 0; - if (empty($projectid) && !empty($object->fk_project)) $projectid = $object->fk_project; - if ($origin == 'project') $projectid = ($originid ? $originid : 0); + if (empty($projectid) && !empty($objectsrc->fk_project)) { + $projectid = $objectsrc->fk_project; + } + if ($origin == 'project') { + $projectid = ($originid ? $originid : 0); + } $langs->load("projects"); print ''; @@ -779,7 +778,7 @@ if ($action == 'create') // Date delivery planned print ''.$langs->trans("DateDeliveryPlanned").''; print ''; - $date_delivery = ($date_delivery ? $date_delivery : $object->delivery_date); // $date_delivery comes from GETPOST + $date_delivery = ($date_delivery ? $date_delivery : $objectsrc->delivery_date); // $date_delivery comes from GETPOST print $form->selectDate($date_delivery ? $date_delivery : -1, 'date_delivery', 1, 1, 1); print "\n"; print ''; @@ -787,16 +786,15 @@ if ($action == 'create') // Note Public print ''.$langs->trans("NotePublic").''; print ''; - $doleditor = new DolEditor('note_public', $object->note_public, '', 60, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + $doleditor = new DolEditor('note_public', $objectsrc->note_public, '', 60, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%'); print $doleditor->Create(1); print ""; // Note Private - if ($object->note_private && !$user->socid) - { + if ($objectsrc->note_private && !$user->socid) { print ''.$langs->trans("NotePrivate").''; print ''; - $doleditor = new DolEditor('note_private', $object->note_private, '', 60, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); + $doleditor = new DolEditor('note_private', $objectsrc->note_private, '', 60, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3, '90%'); print $doleditor->Create(1); print ""; } @@ -837,15 +835,15 @@ if ($action == 'create') // Other attributes $parameters = array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"', 'cols' => '3', 'socid'=>$socid); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $recept, $action); // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $recept, $action); // Note that $action and $objectsrc may have been modified by hook print $hookmanager->resPrint; - // Here $object can be of an object Order + // Here $object can be of an object Reception $extrafields->fetch_name_optionals_label($object->table_element); if (empty($reshook) && !empty($extrafields->attributes[$object->table_element]['label'])) { // copy from order - if ($object->fetch_optionals() > 0) { - $recept->array_options = array_merge($recept->array_options, $object->array_options); + if ($objectsrc->fetch_optionals() > 0) { + $recept->array_options = array_merge($recept->array_options, $objectsrc->array_options); } print $object->showOptionals($extrafields, 'edit', $parameters); } @@ -854,9 +852,9 @@ if ($action == 'create') if (!empty($conf->incoterm->enabled)) { print ''; - print ''; + print ''; print ''; - print $form->select_incoterms((!empty($object->fk_incoterms) ? $object->fk_incoterms : ''), (!empty($object->location_incoterms) ? $object->location_incoterms : '')); + print $form->select_incoterms((!empty($objectsrc->fk_incoterms) ? $objectsrc->fk_incoterms : ''), (!empty($objectsrc->location_incoterms) ? $objectsrc->location_incoterms : '')); print ''; } @@ -876,15 +874,15 @@ if ($action == 'create') print dol_get_fiche_end(); - // Reception lines $numAsked = 0; $dispatchLines = array(); - foreach ($_POST as $key => $value) - { + foreach ($_POST as $key => $value) { + // If create form is coming from the button "Create Reception" of previous page + // without batch module enabled - if (preg_match('/^product_([0-9]+)_([0-9]+)$/i', $key, $reg)) - { + $reg = array(); + if (preg_match('/^product_([0-9]+)_([0-9]+)$/i', $key, $reg)) { $numAsked++; // $numline=$reg[2] + 1; // line of product @@ -915,6 +913,25 @@ if ($action == 'create') $fk_commandefourndet = 'fk_commandefourndet_'.$reg[1].'_'.$reg[2]; $dispatchLines[$numAsked] = array('prod' => GETPOST($prod, 'int'), 'qty' =>GETPOST($qty), 'ent' =>GETPOST($ent, 'int'), 'pu' =>GETPOST($pu), 'comment' =>GETPOST('comment'), 'fk_commandefourndet' => GETPOST($fk_commandefourndet, 'int'), 'DLC'=> $dDLC, 'DLUO'=> $dDLUO, 'lot'=> GETPOST($lot, 'alpha')); } + + // If create form is coming from same page post was sent but an error occured + if (preg_match('/^productid([0-9]+)$/i', $key, $reg)) { + $numAsked++; + + // eat-by date dispatch + // $numline=$reg[2] + 1; // line of product + $numline = $numAsked; + $prod = 'productid'.$reg[1]; + $comment = 'comment'.$reg[1]; + $qty = 'qtyl'.$reg[1]; + $ent = 'entl'.$reg[1]; + $pu = 'pul'.$reg[1]; + $lot = 'batch'.$reg[1]; + $dDLUO = dol_mktime(12, 0, 0, GETPOST('dluo'.$reg[1].'month', 'int'), GETPOST('dluo'.$reg[1].'day', 'int'), GETPOST('dluo'.$reg[1].'year', 'int')); + $dDLC = dol_mktime(12, 0, 0, GETPOST('dlc'.$reg[1].'month', 'int'), GETPOST('dlc'.$reg[1].'day', 'int'), GETPOST('dlc'.$reg[1].'year', 'int')); + $fk_commandefourndet = 'fk_commandefournisseurdet'.$reg[1]; + $dispatchLines[$numAsked] = array('prod' => GETPOST($prod, 'int'), 'qty' =>GETPOST($qty), 'ent' =>GETPOST($ent, 'int'), 'pu' =>GETPOST($pu), 'comment' =>GETPOST($comment), 'fk_commandefourndet' => GETPOST($fk_commandefourndet, 'int'), 'DLC'=> $dDLC, 'DLUO'=> $dDLUO, 'lot'=> GETPOST($lot, 'alpha')); + } } @@ -944,7 +961,7 @@ if ($action == 'create') print ''; // Load receptions already done for same order - $object->loadReceptions(); + $objectsrc->loadReceptions(); if ($numAsked) { @@ -980,14 +997,13 @@ if ($action == 'create') while ($indiceAsked <= $numAsked) { $product = new Product($db); - foreach ($object->lines as $supplierLine) { + foreach ($objectsrc->lines as $supplierLine) { if ($dispatchLines[$indiceAsked]['fk_commandefourndet'] == $supplierLine->id) { $line = $supplierLine; break; } } - // Show product and description $type = $line->product_type ? $line->product_type : $line->fk_product_type; // Try to enhance type detection using date_start and date_end for free lines where type @@ -995,7 +1011,7 @@ if ($action == 'create') if (!empty($line->date_start)) $type = 1; if (!empty($line->date_end)) $type = 1; - print ''."\n"; + print ''."\n"; print ''."\n"; @@ -1008,6 +1024,7 @@ if ($action == 'create') print ''; $qtyProdCom = $line->qty; // Qty already received print ''; From 33a4c98dc3b2ecc134fdda48a0ed15a3f1d7a69c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 2 Jun 2021 04:33:35 +0200 Subject: [PATCH 15/22] Fix popup --- htdocs/reception/card.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 8b49f143176..8a4d5edc611 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -1027,10 +1027,7 @@ if ($action == 'create') print ''; // Show product and description - $product_static->type = $line->fk_product_type; - $product_static->id = $line->fk_product; - $product_static->ref = $line->ref; - $product_static->status_batch = $line->product_tobatch; + $product_static = $product; $text = $product_static->getNomUrl(1); $text .= ' - '.(!empty($line->label) ? $line->label : $line->product_label); From f875bcfe09be360570096a8b610396a4574a3b09 Mon Sep 17 00:00:00 2001 From: atm-greg Date: Wed, 2 Jun 2021 10:30:48 +0200 Subject: [PATCH 16/22] update ->nom field if different from ->name --- htdocs/user/class/usergroup.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index 20ac35b370f..b271eec5754 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -675,7 +675,7 @@ class UserGroup extends CommonObject { global $user, $conf; - if (empty($this->nom) && !empty($this->name)) { + if ((empty($this->nom) || $this->nom != $this->name) && !empty($this->name)) { $this->nom = $this->name; } From 3aca9bdb9e62973d0f3217589c5d6d8384cb7f48 Mon Sep 17 00:00:00 2001 From: ATM john Date: Wed, 2 Jun 2021 12:02:27 +0200 Subject: [PATCH 17/22] Fix warehouse id --- htdocs/expedition/card.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 264089ac48a..a4597fee291 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -2211,7 +2211,8 @@ if ($action == 'create') // only show lot numbers from src warehouse when shipping from multiple warehouses $line->fetch($detail_batch->fk_expeditiondet); } - print ''; + $entrepot_id = !empty($detail_batch->entrepot_id)?$detail_batch->entrepot_id:$lines[$i]->entrepot_id; + print ''; print ''; } // add a 0 qty lot row to be able to add a lot From 1468761073884ccc039a2fdbc25e01051712343b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 2 Jun 2021 16:29:38 +0200 Subject: [PATCH 18/22] Fix select --- htdocs/holiday/month_report.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/htdocs/holiday/month_report.php b/htdocs/holiday/month_report.php index b83d957b27f..922c313840b 100644 --- a/htdocs/holiday/month_report.php +++ b/htdocs/holiday/month_report.php @@ -138,13 +138,21 @@ $sql .= " FROM ".MAIN_DB_PREFIX."holiday cp"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user u ON cp.fk_user = u.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_holiday_types ct ON cp.fk_type = ct.rowid"; $sql .= " WHERE cp.rowid > 0"; -$sql .= " AND cp.statut = 3"; // 3 = Approved +$sql .= " AND cp.statut = ".Holiday::STATUS_APPROVED; $sql .= " AND (date_format(cp.date_debut, '%Y-%m') = '".$db->escape($year_month)."' OR date_format(cp.date_fin, '%Y-%m') = '".$db->escape($year_month)."')"; -if (!empty($search_ref)) $sql .= natural_search('cp.ref', $search_ref); -if (!empty($search_employee)) $sql .= " AND cp.fk_user = '".$db->escape($search_employee)."'"; -if (!empty($search_type)) $sql .= ' AND cp.fk_type IN ('.$db->escape($search_type).')'; -if (!empty($search_description)) $sql .= natural_search('cp.description', $search_description); +if (!empty($search_ref)) { + $sql .= natural_search('cp.ref', $search_ref); +} +if (!empty($search_employee) && $search_employee > 0) { + $sql .= " AND cp.fk_user = ".((int) $search_employee); +} +if (!empty($search_type) && $search_type != '-1') { + $sql .= ' AND cp.fk_type IN ('.$db->escape($search_type).')'; +} +if (!empty($search_description)) { + $sql .= natural_search('cp.description', $search_description); +} $sql .= $db->order($sortfield, $sortorder); From 38423ba2600303665faf18626f2a89c0f6e93504 Mon Sep 17 00:00:00 2001 From: ATM john Date: Wed, 2 Jun 2021 16:31:31 +0200 Subject: [PATCH 19/22] Fix wrong hook context --- htdocs/product/stock/stockatdate.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/stock/stockatdate.php b/htdocs/product/stock/stockatdate.php index 91159984a35..8d355e5c1dc 100644 --- a/htdocs/product/stock/stockatdate.php +++ b/htdocs/product/stock/stockatdate.php @@ -45,7 +45,7 @@ if ($user->socid) { $result = restrictedArea($user, 'produit|service'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('stockreplenishlist')); +$hookmanager->initHooks(array('stockatdate')); //checks if a product has been ordered From 093705a1b552d18450c968001e4eafa4d65c127e Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Thu, 3 Jun 2021 11:32:41 +0200 Subject: [PATCH 20/22] FIX : field name is search_status and not search_statut --- htdocs/holiday/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index cb8da24052b..cbd9b76e45e 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -106,7 +106,7 @@ $search_month_end = GETPOST('search_month_end', 'int'); $search_year_end = GETPOST('search_year_end', 'int'); $search_employee = GETPOST('search_employee', 'int'); $search_valideur = GETPOST('search_valideur', 'int'); -$search_status = GETPOST('search_statut', 'int'); +$search_status = GETPOST('search_status', 'int'); $search_type = GETPOST('search_type', 'int'); // Initialize technical objects From c534b7fcce8808189b9ef108aa69f9697e584a08 Mon Sep 17 00:00:00 2001 From: Inovea Conseil Date: Thu, 3 Jun 2021 14:36:47 +0200 Subject: [PATCH 21/22] FIX delete object actionComm --- htdocs/core/actions_massactions.inc.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 99f1271ff0b..3cbcd30af7f 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1,6 +1,6 @@ - * Copyright (C) 2018 Nicolas ZABOURI + * Copyright (C) 2018-2021 Nicolas ZABOURI * Copyright (C) 2018 Juanjo Menent * Copyright (C) 2019 Ferran Marcet * Copyright (C) 2019-2021 Frédéric France @@ -1241,8 +1241,13 @@ if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == ' } if (in_array($objecttmp->element, array('societe', 'member'))) $result = $objecttmp->delete($objecttmp->id, $user, 1); - else $result = $objecttmp->delete($user); - + else { + if (get_class($objecttmp) === "ActionComm") { + $result = $objecttmp->delete(); + } else { + $result = $objecttmp->delete($user); + } + } if ($result <= 0) { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); From 174c6f8a455da035abceef8b7a31fefc59f9ba60 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 4 Jun 2021 10:33:13 +0200 Subject: [PATCH 22/22] Update mouvementstock.class.php --- htdocs/product/stock/class/mouvementstock.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index ec2dfbc257e..ecdfdacbf44 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -355,7 +355,9 @@ class MouvementStock extends CommonObject $qtyisnotenough = 0; foreach ($product->stock_warehouse[$entrepot_id]->detail_batch as $batchcursor => $prodbatch) { - if ($batch !== $batchcursor) continue; // Do a strict comparison because $batchcursar can be an integer + if ((string) $batch != (string) $batchcursor) { // Lot '59' must be different than lot '59c' + continue; + } $foundforbatch = 1; if ($prodbatch->qty < abs($qty)) $qtyisnotenough = $prodbatch->qty; break;
'; print ''; // ancre pour retourner sur la ligne + print ''; // Show product and description $product_static->type = $line->fk_product_type; @@ -1049,17 +1066,15 @@ if ($action == 'create') // Qty print ''.$line->qty; - print 'id.'\' />'; - print ''; + print ''; + print ''; print ''; print ''; - - - $quantityDelivered = $object->receptions[$line->id]; + $quantityDelivered = $objectsrc->receptions[$line->id]; print $quantityDelivered; print ''; print ''.$formproduct->selectLotStock($detail_batch->fk_origin_stock, 'batchl'.$detail_batch->fk_expeditiondet.'_'.$detail_batch->fk_origin_stock, '', 1, 0, $lines[$i]->fk_product, $line->entrepot_id).''.$formproduct->selectLotStock($detail_batch->fk_origin_stock, 'batchl'.$detail_batch->fk_expeditiondet.'_'.$detail_batch->fk_origin_stock, '', 1, 0, $lines[$i]->fk_product, $entrepot_id).'