From ab2709f684e8a3ed95167ca1f3cc8552c343f0bc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@destailleur.fr> Date: Sun, 21 Apr 2013 12:26:44 +0200 Subject: [PATCH] Filter on agenda event are autoselected on "manual event". --- htdocs/comm/action/class/cactioncomm.class.php | 2 +- htdocs/comm/action/index.php | 6 +++--- htdocs/core/class/html.formactions.class.php | 9 ++++++--- htdocs/core/lib/agenda.lib.php | 6 +++--- htdocs/langs/en_US/agenda.lang | 1 + htdocs/langs/fr_FR/agenda.lang | 1 + 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/htdocs/comm/action/class/cactioncomm.class.php b/htdocs/comm/action/class/cactioncomm.class.php index c686db153c4..e9fe439e75c 100644 --- a/htdocs/comm/action/class/cactioncomm.class.php +++ b/htdocs/comm/action/class/cactioncomm.class.php @@ -132,7 +132,7 @@ class CActionComm $qualified=1; // $obj->type can be system, systemauto, module, moduleauto, xxx, xxxauto - if ($qualified && $onlyautoornot && preg_match('/^system/',$obj->type) && ! preg_match('/^AC_OTH/',$obj->code)) $qualified=0; // We discard detailed system events. We keep only the 2 generic lines (AC_OTH and AC_OTHER) + if ($qualified && $onlyautoornot && preg_match('/^system/',$obj->type) && ! preg_match('/^AC_OTH/',$obj->code)) $qualified=0; // We discard detailed system events. We keep only the 2 generic lines (AC_OTH and AC_OTH_AUTO) if ($qualified && $obj->module) { diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 49a84a28d22..813c2578374 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -1,7 +1,7 @@ <?php /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> * Copyright (C) 2003 Eric Seigne <erics@rycks.com> - * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net> + * Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es> * @@ -72,11 +72,11 @@ $year=GETPOST("year","int")?GETPOST("year","int"):date("Y"); $month=GETPOST("month","int")?GETPOST("month","int"):date("m"); $week=GETPOST("week","int")?GETPOST("week","int"):date("W"); $day=GETPOST("day","int")?GETPOST("day","int"):0; -$actioncode=GETPOST("actioncode","alpha",3); $pid=GETPOST("projectid","int",3); $status=GETPOST("status"); $type=GETPOST("type"); $maxprint=(isset($_GET["maxprint"])?GETPOST("maxprint"):$conf->global->AGENDA_MAX_EVENTS_DAY_VIEW); +$actioncode=GETPOST("actioncode","alpha",3)?GETPOST("actioncode","alpha",3):(GETPOST("actioncode")=="0"?'':(empty($conf->global->AGENDA_USE_EVENT_TYPE)?'AC_OTH':'')); if (GETPOST('viewcal')) { $action='show_month'; $day=''; @@ -271,7 +271,7 @@ $param.='&year='.$year.'&month='.$month.($day?'&day='.$day:''); $head = calendars_prepare_head(''); dol_fiche_head($head, 'card', $langs->trans('Events'), 0, $picto); -print_actions_filter($form,$canedit,$status,$year,$month,$day,$showbirthday,$filtera,$filtert,$filterd,$pid,$socid,$listofextcals); +print_actions_filter($form,$canedit,$status,$year,$month,$day,$showbirthday,$filtera,$filtert,$filterd,$pid,$socid,$listofextcals,$actioncode); dol_fiche_end(); $link=''; diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index 827a65ed51f..b7477c203f5 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -209,10 +209,10 @@ class FormActions /** * Output list of type of event * - * @param string $selected Type pre-selectionne + * @param string $selected Type pre-selected (can be 'manual', 'auto' or 'AC_xxx' * @param string $htmlname Nom champ formulaire * @param string $excludetype Type to exclude - * @param string $onlyautoornot Group list by auto events or not + * @param string $onlyautoornot Group list by auto events or not: We keep only the 2 generic lines (AC_OTH and AC_OTH_AUTO) * @return void */ function select_type_actions($selected='',$htmlname='actioncode',$excludetype='',$onlyautoornot=0) @@ -224,11 +224,14 @@ class FormActions $caction=new CActionComm($this->db); $form=new Form($this->db); - // Suggest a list with manual event or all auto events + // Suggest a list with manual events or all auto events $arraylist=$caction->liste_array(1, 'code', $excludetype, $onlyautoornot); array_unshift($arraylist,' '); // Add empty line at start //asort($arraylist); + if ($selected == 'manual') $selected='AC_OTH'; + if ($selected == 'auto') $selected='AC_OTH_AUTO'; + print $form->selectarray($htmlname, $arraylist, $selected); if ($user->admin && empty($onlyautoornot)) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); } diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index 531ea49eb96..9b7f37b6fee 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -40,9 +40,10 @@ * @param int $pid Product id * @param int $socid Third party id * @param array $showextcals Array with list of external calendars, or -1 to show no legend + * @param string $actioncode Preselected value of actioncode for filter on type * @return void */ -function print_actions_filter($form,$canedit,$status,$year,$month,$day,$showbirthday,$filtera,$filtert,$filterd,$pid,$socid,$showextcals=array()) +function print_actions_filter($form,$canedit,$status,$year,$month,$day,$showbirthday,$filtera,$filtert,$filterd,$pid,$socid,$showextcals=array(),$actioncode='') { global $conf,$user,$langs,$db; @@ -94,8 +95,7 @@ function print_actions_filter($form,$canedit,$status,$year,$month,$day,$showbirt print $langs->trans("Type"); print ' </td><td nowrap="nowrap">'; - // print $formactions->select_type_actions(GETPOST('actioncode'), "actioncode"); - print $formactions->select_type_actions(GETPOST('actioncode')?GETPOST('actioncode'):'manual', "actioncode", '', (empty($conf->global->AGENDA_USE_EVENT_TYPE)?1:0)); + print $formactions->select_type_actions($actioncode, "actioncode", '', (empty($conf->global->AGENDA_USE_EVENT_TYPE)?1:0)); print '</td></tr>'; } diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index 7bd84be4cd1..3d0aadefec2 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -67,6 +67,7 @@ AgendaUrlOptions4=<b>logint=%s</b> to restrict output to actions assigned to use AgendaUrlOptions5=<b>logind=%s</b> to restrict output to actions done by user <b>%s</b>. AgendaShowBirthdayEvents=Show birthday's contacts AgendaHideBirthdayEvents=Hide birthday's contacts +Busy=Busy # External Sites ical ExportCal=Export calendar diff --git a/htdocs/langs/fr_FR/agenda.lang b/htdocs/langs/fr_FR/agenda.lang index cf8216b617b..6c41e3e95c2 100644 --- a/htdocs/langs/fr_FR/agenda.lang +++ b/htdocs/langs/fr_FR/agenda.lang @@ -67,6 +67,7 @@ AgendaUrlOptions4=<b>logint=%s</b> pour limiter l'export aux actions affectées AgendaUrlOptions5=<b>logind=%s</b> pour limiter l'export aux actions réalisées par l'utilisateur <b>%s</b>. AgendaShowBirthdayEvents=Afficher anniversaires contacts AgendaHideBirthdayEvents=Cacher anniversaires contacts +Busy=Occupé # External Sites ical ExportCal=Export calendrier -- GitLab