From 05e20b8f30bbab98344d37fea524cbc4c858b529 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Thu, 20 Sep 2012 00:42:51 +0200 Subject: [PATCH] New: Can exclude some type of events --- htdocs/comm/action/class/cactioncomm.class.php | 17 ++++++++--------- htdocs/comm/action/fiche.php | 2 +- htdocs/core/class/html.formactions.class.php | 9 +++++---- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/htdocs/comm/action/class/cactioncomm.class.php b/htdocs/comm/action/class/cactioncomm.class.php index ba9f8658784..f4ad2f6f078 100644 --- a/htdocs/comm/action/class/cactioncomm.class.php +++ b/htdocs/comm/action/class/cactioncomm.class.php @@ -96,13 +96,14 @@ class CActionComm } /** - * Return list of event types + * Return list of event types * - * @param int $active 1 or 0 to filter on event state active or not ('' by default = no filter) - * @param string $idorcode 'id' or 'code' - * @return array Array of all event types if OK, <0 if KO + * @param int $active 1 or 0 to filter on event state active or not ('' by default = no filter) + * @param string $idorcode 'id' or 'code' + * @param string $excludetype Type to exclude + * @return array Array of all event types if OK, <0 if KO */ - function liste_array($active='',$idorcode='id') + function liste_array($active='',$idorcode='id',$excludetype='') { global $langs,$conf; $langs->load("commercial"); @@ -112,10 +113,8 @@ class CActionComm $sql = "SELECT id, code, libelle, module"; $sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm"; - if ($active != '') - { - $sql.=" WHERE active=".$active; - } + if ($active != '') $sql.=" WHERE active=".$active; + if (! empty($excludetype)) $sql.=($active != ''?" AND":" WHERE")." type <> '".$excludetype."'"; $sql.= " ORDER BY module, position"; dol_syslog(get_class($this)."::liste_array sql=".$sql); diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php index 6cdb7a77580..be4f27a141c 100644 --- a/htdocs/comm/action/fiche.php +++ b/htdocs/comm/action/fiche.php @@ -450,7 +450,7 @@ if ($action == 'create') } else { - $htmlactions->select_type_actions($actioncomm->type_code, "actioncode"); + $htmlactions->select_type_actions($actioncomm->type_code, "actioncode","systemauto"); } print '</td></tr>'; diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index 9435cebb1a4..09213bdd0b9 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -191,11 +191,12 @@ class FormActions /** * Output list of type of event * - * @param string $selected Type pre-selectionne - * @param string $htmlname Nom champ formulaire + * @param string $selected Type pre-selectionne + * @param string $htmlname Nom champ formulaire + * @param string $excludetype Type to exclude * @return void */ - function select_type_actions($selected='',$htmlname='actioncode') + function select_type_actions($selected='',$htmlname='actioncode',$excludetype='') { global $langs,$user; @@ -204,7 +205,7 @@ class FormActions $caction=new CActionComm($this->db); $form=new Form($this->db); - $arraylist=$caction->liste_array(1,'code'); + $arraylist=$caction->liste_array(1, 'code', $excludetype); array_unshift($arraylist,' '); // Add empty line at start //asort($arraylist); -- GitLab