From 26d3ea222799159229fbd022e633b81a49a444e2 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 23 Dec 2020 23:32:50 +0100 Subject: [PATCH 01/13] on going --- htdocs/adherents/class/adherent.class.php | 32 +----------- htdocs/contact/class/contact.class.php | 32 +----------- htdocs/contact/list.php | 2 + htdocs/core/actions_massactions.inc.php | 62 +++++++++++++++++++++++ htdocs/core/class/commonobject.class.php | 48 +++++++++++++----- htdocs/core/tpl/massactions_pre.tpl.php | 36 +++++++++++++ htdocs/langs/en_US/main.lang | 5 +- htdocs/product/class/product.class.php | 33 +----------- htdocs/societe/class/societe.class.php | 42 +-------------- htdocs/societe/list.php | 2 + htdocs/user/class/user.class.php | 35 +------------ htdocs/user/list.php | 1 + 12 files changed, 149 insertions(+), 181 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 5df6db52f3d..b26d45c34e2 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2585,38 +2585,8 @@ class Adherent extends CommonObject */ public function setCategories($categories) { - // Handle single category - if (!is_array($categories)) { - $categories = array($categories); - } - - // Get current categories require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $c = new Categorie($this->db); - $existing = $c->containing($this->id, Categorie::TYPE_MEMBER, 'id'); - - // Diff - if (is_array($existing)) { - $to_del = array_diff($existing, $categories); - $to_add = array_diff($categories, $existing); - } else { - $to_del = array(); // Nothing to delete - $to_add = $categories; - } - - // Process - foreach ($to_del as $del) { - if ($c->fetch($del) > 0) { - $c->del_type($this, Categorie::TYPE_MEMBER); - } - } - foreach ($to_add as $add) { - if ($c->fetch($add) > 0) { - $c->add_type($this, Categorie::TYPE_MEMBER); - } - } - - return; + return parent::setCategoriesCommon($categories, Categorie::TYPE_MEMBER); } /** diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 367a2e7cd62..8fe4943d267 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1579,38 +1579,8 @@ class Contact extends CommonObject */ public function setCategories($categories) { - // Handle single category - if (!is_array($categories)) { - $categories = array($categories); - } - - // Get current categories require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $c = new Categorie($this->db); - $existing = $c->containing($this->id, Categorie::TYPE_CONTACT, 'id'); - - // Diff - if (is_array($existing)) { - $to_del = array_diff($existing, $categories); - $to_add = array_diff($categories, $existing); - } else { - $to_del = array(); // Nothing to delete - $to_add = $categories; - } - - // Process - foreach ($to_del as $del) { - if ($c->fetch($del) > 0) { - $c->del_type($this, Categorie::TYPE_CONTACT); - } - } - foreach ($to_add as $add) { - if ($c->fetch($add) > 0) { - $c->add_type($this, Categorie::TYPE_CONTACT); - } - } - - return; + return parent::setCategoriesCommon($categories, Categorie::TYPE_CONTACT); } /** diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 00c74544d17..ecde0faf245 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -277,6 +277,7 @@ if (empty($reshook)) $objectlabel = 'Contact'; $permissiontoread = $user->rights->societe->lire; $permissiontodelete = $user->rights->societe->supprimer; + $permissiontoadd = $user->rights->societe->creer; $uploaddir = $conf->societe->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; @@ -525,6 +526,7 @@ $arrayofmassactions = array( ); //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); if ($user->rights->societe->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +if ($user->rights->societe->creer) $arrayofmassactions['preaffecttag'] = ''.$langs->trans("AffectTag"); if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); $massactionbutton = $form->selectMassAction('', $arrayofmassactions); diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 356eb36a04b..7331a9f40a5 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1291,6 +1291,68 @@ if (!$error && $massaction == 'generate_doc' && $permissiontoread) } } +if (!$error && ($action == 'affecttag' && $confirm == 'yes') && $permissiontoadd) { + + $db->begin(); + + $affecttag_type=GETPOST('affecttag_type','alpha'); + if (!empty($affecttag_type)) { + $affecttag_type_array=explode(',',$affecttag_type); + } else { + setEventMessage('CategTypeNotFound','errors'); + } + if (!empty($affecttag_type_array)) { + //check if tag type submited exists into Tag Map categorie class + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $categ = new Categorie($db); + $to_affecttag_type_array=array(); + $categ_type_array=$categ->getMapList(); + foreach($categ_type_array as $categdef) { + + if (in_array($categdef['code'], $affecttag_type_array)) { + $to_affecttag_type_array[] = $categdef['code']; + } + } + + //For each valid categ type set common categ + $nbok = 0; + if (!empty($to_affecttag_type_array)) { + foreach ($to_affecttag_type_array as $categ_type) { + $contcats = GETPOST('contcats_' . $categ_type, 'array'); +var_dump($toselect);exit; + foreach ($toselect as $toselectid) { + $result = $object->fetch($toselectid); + var_dump($contcats);exit; + if ($result > 0) { + + $result = $object->setCategoriesCommon($contcats, $categ_type, false); + if ($result > 0) { + $nbok++; + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } + + } else { + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + break; + } + } + } + } + } + + if (!$error) + { + if ($nbok > 1) setEventMessages($langs->trans("RecordsModified", $nbok), null); + else setEventMessages($langs->trans("RecordsModified", $nbok), null); + $db->commit(); + $toselect=array(); + } else { + $db->rollback(); + } +} + $parameters['toselect'] = $toselect; $parameters['uploaddir'] = $uploaddir; $parameters['massaction'] = $massaction; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index bfdea016ea6..f97f583fc87 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -8377,18 +8377,26 @@ abstract class CommonObject /** * Sets object to given categories. * - * Deletes object from existing categories not supplied. * Adds it to non existing supplied categories. + * Deletes object from existing categories not supplied (if remove_existing==true). * Existing categories are left untouch. * - * @param int[]|int $categories Category ID or array of Categories IDs - * @param string $type_categ Category type ('customer', 'supplier', 'website_page', ...) + * @param int[]|int $categories Category ID or array of Categories IDs + * @param string $type_categ Category type ('customer', 'supplier', 'website_page', ...) definied into const class Categorie type + * @param boolean $remove_existing True: Remove existings categories from Object if not supplies by $categories, False: let them * @return int <0 if KO, >0 if OK */ - public function setCategoriesCommon($categories, $type_categ) + public function setCategoriesCommon($categories, $type_categ='', $remove_existing=true) { + dol_syslog(get_class($this)."::setCategoriesCommon Oject Id:".$this->id.' type_categ:'.$type_categ.' nb tag add:'.count($categories), LOG_DEBUG); + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + if (empty($type_categ)) { + dol_syslog(__METHOD__.': Type '.$type_categ.'is an unknown category type. Done nothing.', LOG_ERR); + return -1; + } + // Handle single category if (!is_array($categories)) { $categories = array($categories); @@ -8397,22 +8405,36 @@ abstract class CommonObject // Get current categories $c = new Categorie($this->db); $existing = $c->containing($this->id, $type_categ, 'id'); - - // Diff - if (is_array($existing)) { - $to_del = array_diff($existing, $categories); - $to_add = array_diff($categories, $existing); + if ($remove_existing) { + // Diff + if (is_array($existing)) { + $to_del = array_diff($existing, $categories); + $to_add = array_diff($categories, $existing); + } else { + $to_del = array(); // Nothing to delete + $to_add = $categories; + } } else { $to_del = array(); // Nothing to delete - $to_add = $categories; + $to_add = array_diff($categories, $existing); } $error = 0; + $ok=0; // Process foreach ($to_del as $del) { if ($c->fetch($del) > 0) { - $c->del_type($this, $type_categ); + $result=$c->del_type($this, $type_categ); + if ($result < 0) + { + $error++; + $this->error = $c->error; + $this->errors = $c->errors; + break; + } else { + $ok+=$result; + } } } foreach ($to_add as $add) { @@ -8425,11 +8447,13 @@ abstract class CommonObject $this->error = $c->error; $this->errors = $c->errors; break; + } else { + $ok+=$result; } } } - return $error ? -1 : 1; + return $error ? -1 * $error : $ok; } /** diff --git a/htdocs/core/tpl/massactions_pre.tpl.php b/htdocs/core/tpl/massactions_pre.tpl.php index 21070467f57..a5ce87ae932 100644 --- a/htdocs/core/tpl/massactions_pre.tpl.php +++ b/htdocs/core/tpl/massactions_pre.tpl.php @@ -37,6 +37,42 @@ if ($massaction == 'predelete') print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassDeletion"), $langs->trans("ConfirmMassDeletionQuestion", count($toselect)), "delete", null, '', 0, 200, 500, 1); } +if ($massaction == 'preaffecttag') +{ + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + $categ = new Categorie($db); + $categ_types=array(); + $categ_type_array=$categ->getMapList(); + foreach($categ_type_array as $categdef) { + if (isset($object) && $categdef['obj_table']==$object->table_element) { + if (!array_key_exists($categdef['code'],$categ_types)) $categ_types[$categdef['code']] = array('code'=>$categdef['code'],'label'=>$langs->trans($categdef['obj_class'])); + } + if (isset($objecttmp) && $categdef['obj_table']==$objecttmp->table_element) { + if (!array_key_exists($categdef['code'],$categ_types)) $categ_types[$categdef['code']] = array('code'=>$categdef['code'],'label'=>$langs->trans($categdef['obj_class'])); + } + } + + $formquestion = array(); + if (!empty($categ_types)) { + foreach($categ_types as $categ_type) { + $cate_arbo = $form->select_all_categories($categ_type['code'], null, 'parent', null, null, 1); + $formquestion[]= + array('type' => 'other', + 'name' => 'affecttag_'.$categ_type['code'], + 'label' => $langs->trans("Tag").' '.$categ_type['label'], + 'value' => $form->multiselectarray('contcats_'.$categ_type['code'], $cate_arbo, GETPOST('contcats_'.$categ_type['code'], 'array'), null, null, null, null, '60%')); + } + $formquestion[]= + array('type' => 'other', + 'name' => 'affecttag_type', + 'label' => '', + 'value' => ''); + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmAffectTag"), $langs->trans("ConfirmAffectTagQuestion", count($toselect)), "affecttag", $formquestion, 1, 0, 200, 500, 1); + } else { + setEventMessage('CategTypeNotFound'); + } +} + if ($massaction == 'presend') { $langs->load("mails"); diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 7075df90783..07aafadd636 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1112,4 +1112,7 @@ UpToDate=Up-to-date OutOfDate=Out-of-date EventReminder=Event Reminder UpdateForAllLines=Update for all lines -OnHold=On hold \ No newline at end of file +OnHold=On hold +ConfirmAffectTag=Bulk Tag Affect +ConfirmAffectTagQuestion=Are you sure you want to affect tags to the %s selected record(s)? +CategTypeNotFound=No tag type found for type of records diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index c40ffd4e0a9..4e94380a54f 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -5497,38 +5497,9 @@ class Product extends CommonObject */ public function setCategories($categories) { - // Handle single category - if (!is_array($categories)) { - $categories = array($categories); - } - // Get current categories - include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $c = new Categorie($this->db); - $existing = $c->containing($this->id, Categorie::TYPE_PRODUCT, 'id'); - - // Diff - if (is_array($existing)) { - $to_del = array_diff($existing, $categories); - $to_add = array_diff($categories, $existing); - } else { - $to_del = array(); // Nothing to delete - $to_add = $categories; - } - - // Process - foreach ($to_del as $del) { - if ($c->fetch($del) > 0) { - $c->del_type($this, Categorie::TYPE_PRODUCT); - } - } - foreach ($to_add as $add) { - if ($c->fetch($add) > 0) { - $c->add_type($this, Categorie::TYPE_PRODUCT); - } - } - - return; + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + return parent::setCategoriesCommon($categories, Categorie::TYPE_PRODUCT); } /** diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 0aeb64aa427..70f561acf2a 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -4266,47 +4266,7 @@ class Societe extends CommonObject return -1; } - // Handle single category - if (!is_array($categories)) { - $categories = array($categories); - } - - // Get current categories - $c = new Categorie($this->db); - $existing = $c->containing($this->id, $type_categ, 'id'); - - // Diff - if (is_array($existing)) { - $to_del = array_diff($existing, $categories); - $to_add = array_diff($categories, $existing); - } else { - $to_del = array(); // Nothing to delete - $to_add = $categories; - } - - $error = 0; - - // Process - foreach ($to_del as $del) { - if ($c->fetch($del) > 0) { - $c->del_type($this, $type_categ); - } - } - foreach ($to_add as $add) { - if ($c->fetch($add) > 0) - { - $result = $c->add_type($this, $type_categ); - if ($result < 0) - { - $error++; - $this->error = $c->error; - $this->errors = $c->errors; - break; - } - } - } - - return $error ? -1 : 1; + return parent::setCategoriesCommon($categories, $type_categ); } /** diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 2e24f355b37..ffdba17d24d 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -324,6 +324,7 @@ if (empty($reshook)) $objectlabel = 'ThirdParty'; $permissiontoread = $user->rights->societe->lire; $permissiontodelete = $user->rights->societe->supprimer; + $permissiontoadd = $user->rights->societe->creer; $uploaddir = $conf->societe->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; @@ -595,6 +596,7 @@ $arrayofmassactions = array( ); //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); if ($user->rights->societe->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +if ($user->rights->societe->creer) $arrayofmassactions['preaffecttag'] = ''.$langs->trans("AffectTag"); if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); $massactionbutton = $form->selectMassAction('', $arrayofmassactions); diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index eb92bd51eb9..7e0c4628250 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1159,40 +1159,7 @@ class User extends CommonObject public function setCategories($categories) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - - $type_categ = Categorie::TYPE_USER; - - // Handle single category - if (!is_array($categories)) { - $categories = array($categories); - } - - // Get current categories - $c = new Categorie($this->db); - $existing = $c->containing($this->id, $type_categ, 'id'); - - // Diff - if (is_array($existing)) { - $to_del = array_diff($existing, $categories); - $to_add = array_diff($categories, $existing); - } else { - $to_del = array(); // Nothing to delete - $to_add = $categories; - } - - // Process - foreach ($to_del as $del) { - if ($c->fetch($del) > 0) { - $c->del_type($this, $type_categ); - } - } - foreach ($to_add as $add) { - if ($c->fetch($add) > 0) { - $c->add_type($this, $type_categ); - } - } - - return; + return parent::setCategoriesCommon($categories, Categorie::TYPE_USER); } /** diff --git a/htdocs/user/list.php b/htdocs/user/list.php index e7a8a31af4e..3e486fb0c70 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -422,6 +422,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; $arrayofmassactions = array(); if ($permissiontoadd) $arrayofmassactions['disable'] = $langs->trans("DisableUser"); if ($permissiontoadd) $arrayofmassactions['reactivate'] = $langs->trans("Reactivate"); +if ($permissiontoadd) $arrayofmassactions['preaffecttag'] = ''.$langs->trans("AffectTag"); //if ($permissiontodelete) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); From 055a2b6fec88e201a10b56c67ad27526f85d4506 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Wed, 23 Dec 2020 23:44:38 +0100 Subject: [PATCH 02/13] on goung --- htdocs/contact/list.php | 2 +- htdocs/core/actions_massactions.inc.php | 5 ++--- htdocs/product/list.php | 2 ++ htdocs/user/list.php | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index ecde0faf245..7ca0e431c5a 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -267,7 +267,7 @@ if (empty($reshook)) $search_categ_thirdparty = ''; $search_categ_supplier = ''; $search_import_key = ''; - $toselect = ''; + $toselect = array(); $search_array_options = array(); $search_roles = array(); } diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 7331a9f40a5..abc244ba255 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1308,7 +1308,6 @@ if (!$error && ($action == 'affecttag' && $confirm == 'yes') && $permissiontoadd $to_affecttag_type_array=array(); $categ_type_array=$categ->getMapList(); foreach($categ_type_array as $categdef) { - if (in_array($categdef['code'], $affecttag_type_array)) { $to_affecttag_type_array[] = $categdef['code']; } @@ -1319,10 +1318,10 @@ if (!$error && ($action == 'affecttag' && $confirm == 'yes') && $permissiontoadd if (!empty($to_affecttag_type_array)) { foreach ($to_affecttag_type_array as $categ_type) { $contcats = GETPOST('contcats_' . $categ_type, 'array'); -var_dump($toselect);exit; + //var_dump($toselect);exit; foreach ($toselect as $toselectid) { $result = $object->fetch($toselectid); - var_dump($contcats);exit; + //var_dump($contcats);exit; if ($result > 0) { $result = $object->setCategoriesCommon($contcats, $categ_type, false); diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 86b8b62fc81..a6b164772ba 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -301,6 +301,7 @@ if (empty($reshook)) $permissiontoread = $user->rights->produit->lire; $permissiontodelete = $user->rights->produit->supprimer; + $permissiontoadd = $user->rights->{$rightskey}->creer; $uploaddir = $conf->product->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -533,6 +534,7 @@ if ($resql) $rightskey = 'produit'; if ($type == Product::TYPE_SERVICE) $rightskey = 'service'; if ($user->rights->{$rightskey}->supprimer) $arrayofmassactions['predelete'] = "".$langs->trans("Delete"); + if ($user->rights->{$rightskey}->creer) $arrayofmassactions['preaffecttag'] = ''.$langs->trans("AffectTag"); if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); $massactionbutton = $form->selectMassAction('', $arrayofmassactions); diff --git a/htdocs/user/list.php b/htdocs/user/list.php index 3e486fb0c70..6c43f7e7c6e 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -648,7 +648,7 @@ if (is_array($extrafields->attributes[$object->table_element]['computed']) && co // -------------------------------------------------------------------- $i = 0; $totalarray = array(); -$arrayofselected = array(); +$arrayofselected = is_array($toselect) ? $toselect : array(); while ($i < ($limit ? min($num, $limit) : $num)) { $obj = $db->fetch_object($resql); From 5ae5f3e7ac6fd072f411205d0987666cfb85003e Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 24 Dec 2020 00:32:54 +0100 Subject: [PATCH 03/13] let societe project acctioncomme website accounr --- htdocs/adherents/list.php | 2 ++ htdocs/install/mysql/migration/12.0.0-13.0.0.sql | 2 +- htdocs/langs/en_US/main.lang | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 9c9df8e25b5..ed4bf7bdb8b 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -230,6 +230,7 @@ if (empty($reshook)) { $objectlabel = 'Members'; $permissiontoread = $user->rights->adherent->lire; $permissiontodelete = $user->rights->adherent->supprimer; + $permissiontoadd = $user->rights->adherent->creer; $uploaddir = $conf->adherent->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -399,6 +400,7 @@ $arrayofmassactions = array( ); if ($user->rights->adherent->creer) $arrayofmassactions['close'] = $langs->trans("Resiliate"); if ($user->rights->adherent->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +if ($user->rights->societe->creer) $arrayofmassactions['preaffecttag'] = ''.$langs->trans("AffectTag"); if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); $massactionbutton = $form->selectMassAction('', $arrayofmassactions); diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index 309d4d4b170..b5d20b96434 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -543,7 +543,7 @@ CREATE TABLE llx_session( fk_user integer NOT NULL, remote_ip varchar(64) NULL, user_agent varchar(128) NULL -)ENGINE=innodb; +) ENGINE=innodb; INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES(1, 'github', 'Github', 'https://github.com/{socialid}', 'fa-github', 1); diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 07aafadd636..e196120c27d 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -1113,6 +1113,7 @@ OutOfDate=Out-of-date EventReminder=Event Reminder UpdateForAllLines=Update for all lines OnHold=On hold +AffectTag=Affect Tag ConfirmAffectTag=Bulk Tag Affect ConfirmAffectTagQuestion=Are you sure you want to affect tags to the %s selected record(s)? CategTypeNotFound=No tag type found for type of records From 1978e23c5e63e9af73bd78a109136bf2bb57d51b Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 24 Dec 2020 00:48:22 +0100 Subject: [PATCH 04/13] ongoing --- htdocs/projet/list.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 988f16a962a..f9190a3404c 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -218,6 +218,7 @@ if (empty($reshook)) $objectlabel = 'Project'; $permissiontoread = $user->rights->projet->lire; $permissiontodelete = $user->rights->projet->supprimer; + $permissiontoadd = $user->rights->projet->creer; $uploaddir = $conf->projet->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; @@ -454,7 +455,8 @@ $arrayofmassactions = array( ); //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); if ($user->rights->projet->creer) $arrayofmassactions['close'] = $langs->trans("Close"); -if ($user->rights->societe->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +if ($user->rights->projet->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +if ($user->rights->projet->creer) $arrayofmassactions['preaffecttag'] = ''.$langs->trans("AffectTag"); if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); $massactionbutton = $form->selectMassAction('', $arrayofmassactions); From 268618d0456ab9b4a31aa1cd314f8580cd1ee3eb Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 24 Dec 2020 00:53:10 +0100 Subject: [PATCH 05/13] project done --- htdocs/projet/class/project.class.php | 44 +-------------------------- 1 file changed, 1 insertion(+), 43 deletions(-) diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index f58886c9a3b..4fff4297854 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -2135,50 +2135,8 @@ class Project extends CommonObject */ public function setCategories($categories) { - $type_categ = Categorie::TYPE_PROJECT; - - // Handle single category - if (!is_array($categories)) { - $categories = array($categories); - } - - // Get current categories require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $c = new Categorie($this->db); - $existing = $c->containing($this->id, $type_categ, 'id'); - - // Diff - if (is_array($existing)) { - $to_del = array_diff($existing, $categories); - $to_add = array_diff($categories, $existing); - } else { - $to_del = array(); // Nothing to delete - $to_add = $categories; - } - - // Process - foreach ($to_del as $del) { - if ($c->fetch($del) > 0) { - $result = $c->del_type($this, $type_categ); - if ($result < 0) { - $this->errors = $c->errors; - $this->error = $c->error; - return -1; - } - } - } - foreach ($to_add as $add) { - if ($c->fetch($add) > 0) { - $result = $c->add_type($this, $type_categ); - if ($result < 0) { - $this->errors = $c->errors; - $this->error = $c->error; - return -1; - } - } - } - - return 1; + return parent::setCategoriesCommon($categories, Categorie::TYPE_PROJECT); } From e4bd4ce78e8a1d1b1e86e893063629f7c68af3c0 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 24 Dec 2020 00:58:21 +0100 Subject: [PATCH 06/13] stock done --- htdocs/product/stock/class/entrepot.class.php | 34 +------------------ htdocs/product/stock/list.php | 6 +++- 2 files changed, 6 insertions(+), 34 deletions(-) diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index d7a52cd1910..f975eaabc67 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -890,39 +890,7 @@ class Entrepot extends CommonObject */ public function setCategories($categories) { - $type_categ = Categorie::TYPE_WAREHOUSE; - - // Handle single category - if (!is_array($categories)) { - $categories = array($categories); - } - - // Get current categories require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $c = new Categorie($this->db); - $existing = $c->containing($this->id, $type_categ, 'id'); - - // Diff - if (is_array($existing)) { - $to_del = array_diff($existing, $categories); - $to_add = array_diff($categories, $existing); - } else { - $to_del = array(); // Nothing to delete - $to_add = $categories; - } - - // Process - foreach ($to_del as $del) { - if ($c->fetch($del) > 0) { - $c->del_type($this, $type_categ); - } - } - foreach ($to_add as $add) { - if ($c->fetch($add) > 0) { - $c->add_type($this, $type_categ); - } - } - - return; + return parent::setCategoriesCommon($categories, Categorie::TYPE_WAREHOUSE); } } diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index f2c7133618b..0ff7cf029c7 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -46,6 +46,8 @@ $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'stocklist'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') +$toselect = GETPOST('toselect', 'array'); + $search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $search_ref = GETPOST("sref", "alpha") ?GETPOST("sref", "alpha") : GETPOST("search_ref", "alpha"); @@ -160,7 +162,7 @@ if (empty($reshook)) { $search[$key] = ''; } - $toselect = ''; + $toselect = array(); $search_array_options = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') @@ -174,6 +176,7 @@ if (empty($reshook)) $objectlabel = 'Warehouse'; $permissiontoread = $user->rights->stock->lire; $permissiontodelete = $user->rights->stock->supprimer; + $permissiontoadd = $user->rights->stock->creer; $uploaddir = $conf->stock->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -344,6 +347,7 @@ $arrayofmassactions = array( ); //if ($user->rights->stock->supprimer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +if ($user->rights->stock->creer) $arrayofmassactions['preaffecttag'] = ''.$langs->trans("AffectTag"); $massactionbutton = $form->selectMassAction('', $arrayofmassactions); print '
'; From 79fe5ee34ce6085cc70ffd94a199c25e3522465a Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 24 Dec 2020 14:35:40 +0100 Subject: [PATCH 07/13] actioncomm ok --- htdocs/comm/action/list.php | 3 +++ htdocs/core/lib/agenda.lib.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 2fe47ab39f1..ee0a041aed8 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -233,6 +233,7 @@ if (empty($reshook)) $uploaddir = true; // Only users that can delete any event can remove records. $permissiontodelete = $user->rights->agenda->allactions->delete; + $permissiontoadd = $user->rights->agenda->myactions->create; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -297,6 +298,7 @@ if ($user->rights->agenda->allactions->delete) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); } if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +if ($user->rights->agenda->myactions->create) $arrayofmassactions['preaffecttag'] = ''.$langs->trans("AffectTag"); $massactionbutton = $form->selectMassAction('', $arrayofmassactions); $sql = "SELECT"; @@ -532,6 +534,7 @@ if ($resql) print $s; + $objecttmp = new ActionComm($db); include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; $moreforfilter = ''; diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index fd3ba8c6fb2..8e25deb21cb 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -64,7 +64,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh print ''; print ''; print ''; - if ($massaction != 'predelete') { // When $massaction == 'predelete', action may be already output to 'delete' by the mass action system. + if ($massaction != 'predelete' && $massaction != 'preaffecttag') { // When $massaction == 'predelete', action may be already output to 'delete' by the mass action system. print ''; } print ''; From f03574d06119f13debaff0a42bc7108ef7c6d417 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 24 Dec 2020 14:56:26 +0100 Subject: [PATCH 08/13] bank ok --- htdocs/adherents/list.php | 2 +- htdocs/comm/action/list.php | 2 +- htdocs/compta/bank/class/account.class.php | 32 +--------------------- htdocs/compta/bank/list.php | 31 +++++++++++++-------- htdocs/contact/list.php | 2 +- htdocs/product/list.php | 2 +- htdocs/product/stock/list.php | 2 +- 7 files changed, 26 insertions(+), 47 deletions(-) diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index ed4bf7bdb8b..ac9260d091e 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -401,7 +401,7 @@ $arrayofmassactions = array( if ($user->rights->adherent->creer) $arrayofmassactions['close'] = $langs->trans("Resiliate"); if ($user->rights->adherent->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); if ($user->rights->societe->creer) $arrayofmassactions['preaffecttag'] = ''.$langs->trans("AffectTag"); -if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +if (in_array($massaction, array('presend', 'predelete','preaffecttag'))) $arrayofmassactions = array(); $massactionbutton = $form->selectMassAction('', $arrayofmassactions); $newcardbutton = ''; diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index ee0a041aed8..4d863a655b4 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -297,7 +297,7 @@ if ($user->rights->agenda->allactions->delete) { $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); } -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete','preaffecttag'))) $arrayofmassactions = array(); if ($user->rights->agenda->myactions->create) $arrayofmassactions['preaffecttag'] = ''.$langs->trans("AffectTag"); $massactionbutton = $form->selectMassAction('', $arrayofmassactions); diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index b2d499c5f34..db6c950af4a 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1011,38 +1011,8 @@ class Account extends CommonObject */ public function setCategories($categories) { - // Handle single category - if (!is_array($categories)) { - $categories = array($categories); - } - - // Get current categories require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - $c = new Categorie($this->db); - $existing = $c->containing($this->id, Categorie::TYPE_ACCOUNT, 'id'); - - // Diff - if (is_array($existing)) { - $to_del = array_diff($existing, $categories); - $to_add = array_diff($categories, $existing); - } else { - $to_del = array(); // Nothing to delete - $to_add = $categories; - } - - // Process - foreach ($to_del as $del) { - if ($c->fetch($del) > 0) { - $c->del_type($this, Categorie::TYPE_ACCOUNT); - } - } - foreach ($to_add as $add) { - if ($c->fetch($add) > 0) { - $c->add_type($this, Categorie::TYPE_ACCOUNT); - } - } - - return; + return parent::setCategoriesCommon($categories, Categorie::TYPE_ACCOUNT); } /** diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index f3efea15235..1184da6d7ac 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -123,18 +123,26 @@ $parameters = array('socid'=>$socid); $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'); -include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; +if (empty($reshook)) { + include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php'; -// Purge search criteria -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers -{ - $search_ref = ''; - $search_label = ''; - $search_number = ''; - $search_status = ''; + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers + { + $search_ref = ''; + $search_label = ''; + $search_number = ''; + $search_status = ''; + } + + // Mass actions + $objectclass = 'Account'; + $objectlabel = 'FinancialAccount'; + $permissiontoadd = $user->rights->banque->modifier; + $uploaddir = $conf->banque->dir_output; + include DOL_DOCUMENT_ROOT . '/core/actions_massactions.inc.php'; } - /* * View */ @@ -235,7 +243,8 @@ $arrayofmassactions = array( // 'builddoc'=>$langs->trans("PDFMerge"), ); if ($user->rights->banque->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); -if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +if ($user->rights->banque->modifier) $arrayofmassactions['preaffecttag'] = ''.$langs->trans("AffectTag"); +if (in_array($massaction, array('presend', 'predelete','preaffecttag'))) $arrayofmassactions = array(); $massactionbutton = $form->selectMassAction('', $arrayofmassactions); $newcardbutton = dolGetButtonTitle($langs->trans('NewFinancialAccount'), '', 'fa fa-plus-circle', 'card.php?action=create', '', $user->rights->banque->configurer); @@ -251,7 +260,7 @@ print ''; print ''; print ''; -print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'bank_account', 0, $newcardbutton, '', $limit, 1); +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bank_account', 0, $newcardbutton, '', $limit, 1); $topicmail = "Information"; //$modelmail="subscription"; diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 7ca0e431c5a..8d6b11e19f0 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -527,7 +527,7 @@ $arrayofmassactions = array( //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); if ($user->rights->societe->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); if ($user->rights->societe->creer) $arrayofmassactions['preaffecttag'] = ''.$langs->trans("AffectTag"); -if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +if (in_array($massaction, array('presend', 'predelete','preaffecttag'))) $arrayofmassactions = array(); $massactionbutton = $form->selectMassAction('', $arrayofmassactions); $newcardbutton = dolGetButtonTitle($langs->trans('NewContactAddress'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/contact/card.php?action=create', '', $user->rights->societe->contact->creer); diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 3830f0bdafb..b0507a83c19 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -536,7 +536,7 @@ if ($resql) ); if ($user->rights->{$rightskey}->supprimer) $arrayofmassactions['predelete'] = "".$langs->trans("Delete"); if ($user->rights->{$rightskey}->creer) $arrayofmassactions['preaffecttag'] = ''.$langs->trans("AffectTag"); - if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); + if (in_array($massaction, array('presend', 'predelete','preaffecttag'))) $arrayofmassactions = array(); $massactionbutton = $form->selectMassAction('', $arrayofmassactions); $newcardbutton = ''; diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index 0ff7cf029c7..1470bdc2aa0 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -346,7 +346,7 @@ $arrayofmassactions = array( //'builddoc'=>$langs->trans("PDFMerge"), ); //if ($user->rights->stock->supprimer) $arrayofmassactions['predelete']=''.$langs->trans("Delete"); -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete','preaffecttag'))) $arrayofmassactions = array(); if ($user->rights->stock->creer) $arrayofmassactions['preaffecttag'] = ''.$langs->trans("AffectTag"); $massactionbutton = $form->selectMassAction('', $arrayofmassactions); From c7b4f20f6ed6227cfc88b0b5b93e755d5a6e39d3 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 24 Dec 2020 15:00:26 +0100 Subject: [PATCH 09/13] merge --- htdocs/societe/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index ffdba17d24d..f4ddb7e571f 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -597,7 +597,7 @@ $arrayofmassactions = array( //if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); if ($user->rights->societe->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); if ($user->rights->societe->creer) $arrayofmassactions['preaffecttag'] = ''.$langs->trans("AffectTag"); -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) $arrayofmassactions = array(); $massactionbutton = $form->selectMassAction('', $arrayofmassactions); $typefilter = ''; From d3bdb72cc863a035cb80b2e21ff38c0a34113ded Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 24 Dec 2020 15:03:12 +0100 Subject: [PATCH 10/13] finish --- htdocs/comm/action/list.php | 2 +- htdocs/projet/list.php | 2 +- htdocs/user/list.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 4d863a655b4..7fc58b73c9f 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -297,8 +297,8 @@ if ($user->rights->agenda->allactions->delete) { $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); } -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete','preaffecttag'))) $arrayofmassactions = array(); if ($user->rights->agenda->myactions->create) $arrayofmassactions['preaffecttag'] = ''.$langs->trans("AffectTag"); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete','preaffecttag'))) $arrayofmassactions = array(); $massactionbutton = $form->selectMassAction('', $arrayofmassactions); $sql = "SELECT"; diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index f9190a3404c..b246d88de93 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -457,7 +457,7 @@ $arrayofmassactions = array( if ($user->rights->projet->creer) $arrayofmassactions['close'] = $langs->trans("Close"); if ($user->rights->projet->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); if ($user->rights->projet->creer) $arrayofmassactions['preaffecttag'] = ''.$langs->trans("AffectTag"); -if (in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +if (in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) $arrayofmassactions = array(); $massactionbutton = $form->selectMassAction('', $arrayofmassactions); diff --git a/htdocs/user/list.php b/htdocs/user/list.php index 6c43f7e7c6e..acf0f93a1b3 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -425,7 +425,7 @@ if ($permissiontoadd) $arrayofmassactions['reactivate'] = $langs->trans("Reactiv if ($permissiontoadd) $arrayofmassactions['preaffecttag'] = ''.$langs->trans("AffectTag"); //if ($permissiontodelete) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag'))) $arrayofmassactions = array(); $massactionbutton = $form->selectMassAction('', $arrayofmassactions); print ''."\n"; From 7f1d0b9dc29710019351c048dfdf42babf59a2eb Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 24 Dec 2020 14:06:55 +0000 Subject: [PATCH 11/13] Fixing style errors. --- htdocs/core/actions_massactions.inc.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index abc244ba255..81cc4d81bd4 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1292,14 +1292,13 @@ if (!$error && $massaction == 'generate_doc' && $permissiontoread) } if (!$error && ($action == 'affecttag' && $confirm == 'yes') && $permissiontoadd) { - $db->begin(); - $affecttag_type=GETPOST('affecttag_type','alpha'); + $affecttag_type=GETPOST('affecttag_type', 'alpha'); if (!empty($affecttag_type)) { - $affecttag_type_array=explode(',',$affecttag_type); + $affecttag_type_array=explode(',', $affecttag_type); } else { - setEventMessage('CategTypeNotFound','errors'); + setEventMessage('CategTypeNotFound', 'errors'); } if (!empty($affecttag_type_array)) { //check if tag type submited exists into Tag Map categorie class @@ -1307,7 +1306,7 @@ if (!$error && ($action == 'affecttag' && $confirm == 'yes') && $permissiontoadd $categ = new Categorie($db); $to_affecttag_type_array=array(); $categ_type_array=$categ->getMapList(); - foreach($categ_type_array as $categdef) { + foreach ($categ_type_array as $categdef) { if (in_array($categdef['code'], $affecttag_type_array)) { $to_affecttag_type_array[] = $categdef['code']; } @@ -1323,14 +1322,12 @@ if (!$error && ($action == 'affecttag' && $confirm == 'yes') && $permissiontoadd $result = $object->fetch($toselectid); //var_dump($contcats);exit; if ($result > 0) { - $result = $object->setCategoriesCommon($contcats, $categ_type, false); if ($result > 0) { $nbok++; } else { setEventMessages($object->error, $object->errors, 'errors'); } - } else { setEventMessages($object->error, $object->errors, 'errors'); $error++; From 1e438b686ecf87ee4baa74f5314a94bdae0bb633 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 28 Dec 2020 21:32:46 +0100 Subject: [PATCH 12/13] fix stickler --- htdocs/core/class/commonobject.class.php | 2 +- htdocs/core/tpl/massactions_pre.tpl.php | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 95af26992cb..0a9b7838e97 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -8393,7 +8393,7 @@ abstract class CommonObject * @param boolean $remove_existing True: Remove existings categories from Object if not supplies by $categories, False: let them * @return int <0 if KO, >0 if OK */ - public function setCategoriesCommon($categories, $type_categ='', $remove_existing=true) + public function setCategoriesCommon($categories, $type_categ = '', $remove_existing = true) { dol_syslog(get_class($this)."::setCategoriesCommon Oject Id:".$this->id.' type_categ:'.$type_categ.' nb tag add:'.count($categories), LOG_DEBUG); diff --git a/htdocs/core/tpl/massactions_pre.tpl.php b/htdocs/core/tpl/massactions_pre.tpl.php index a5ce87ae932..f79abfe9c42 100644 --- a/htdocs/core/tpl/massactions_pre.tpl.php +++ b/htdocs/core/tpl/massactions_pre.tpl.php @@ -43,18 +43,18 @@ if ($massaction == 'preaffecttag') $categ = new Categorie($db); $categ_types=array(); $categ_type_array=$categ->getMapList(); - foreach($categ_type_array as $categdef) { + foreach ($categ_type_array as $categdef) { if (isset($object) && $categdef['obj_table']==$object->table_element) { - if (!array_key_exists($categdef['code'],$categ_types)) $categ_types[$categdef['code']] = array('code'=>$categdef['code'],'label'=>$langs->trans($categdef['obj_class'])); + if (!array_key_exists($categdef['code'], $categ_types)) $categ_types[$categdef['code']] = array('code'=>$categdef['code'],'label'=>$langs->trans($categdef['obj_class'])); } if (isset($objecttmp) && $categdef['obj_table']==$objecttmp->table_element) { - if (!array_key_exists($categdef['code'],$categ_types)) $categ_types[$categdef['code']] = array('code'=>$categdef['code'],'label'=>$langs->trans($categdef['obj_class'])); + if (!array_key_exists($categdef['code'], $categ_types)) $categ_types[$categdef['code']] = array('code'=>$categdef['code'],'label'=>$langs->trans($categdef['obj_class'])); } } $formquestion = array(); if (!empty($categ_types)) { - foreach($categ_types as $categ_type) { + foreach ($categ_types as $categ_type) { $cate_arbo = $form->select_all_categories($categ_type['code'], null, 'parent', null, null, 1); $formquestion[]= array('type' => 'other', @@ -66,7 +66,7 @@ if ($massaction == 'preaffecttag') array('type' => 'other', 'name' => 'affecttag_type', 'label' => '', - 'value' => ''); + 'value' => ''); print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmAffectTag"), $langs->trans("ConfirmAffectTagQuestion", count($toselect)), "affecttag", $formquestion, 1, 0, 200, 500, 1); } else { setEventMessage('CategTypeNotFound'); @@ -83,8 +83,7 @@ if ($massaction == 'presend') if (!GETPOST('cancel', 'alpha')) { - foreach ($arrayofselected as $toselectid) - { + foreach ($arrayofselected as $toselectid) { $result = $objecttmp->fetch($toselectid); if ($result > 0) { From b3dae016afd4fc8ef32aad7262b0101398ee27a0 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 28 Dec 2020 21:38:17 +0100 Subject: [PATCH 13/13] fix sticker --- htdocs/core/tpl/massactions_pre.tpl.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/htdocs/core/tpl/massactions_pre.tpl.php b/htdocs/core/tpl/massactions_pre.tpl.php index f79abfe9c42..7c6ab6deaa5 100644 --- a/htdocs/core/tpl/massactions_pre.tpl.php +++ b/htdocs/core/tpl/massactions_pre.tpl.php @@ -56,14 +56,12 @@ if ($massaction == 'preaffecttag') if (!empty($categ_types)) { foreach ($categ_types as $categ_type) { $cate_arbo = $form->select_all_categories($categ_type['code'], null, 'parent', null, null, 1); - $formquestion[]= - array('type' => 'other', + $formquestion[]=array('type' => 'other', 'name' => 'affecttag_'.$categ_type['code'], 'label' => $langs->trans("Tag").' '.$categ_type['label'], 'value' => $form->multiselectarray('contcats_'.$categ_type['code'], $cate_arbo, GETPOST('contcats_'.$categ_type['code'], 'array'), null, null, null, null, '60%')); } - $formquestion[]= - array('type' => 'other', + $formquestion[]=array('type' => 'other', 'name' => 'affecttag_type', 'label' => '', 'value' => '');