From 74d495c192e0e4c0342de67f975d531cb68c14e4 Mon Sep 17 00:00:00 2001 From: Alexis Algoud Date: Thu, 8 Sep 2016 10:26:38 +0200 Subject: [PATCH] NEW filter actiontype on thirdparty tab --- htdocs/core/lib/company.lib.php | 7 +++++-- htdocs/societe/agenda.php | 36 +++++++++++++++++++++++++++------ 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 2ef445bcac3..f21d9c5fb98 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -902,9 +902,10 @@ function show_addresses($conf,$langs,$db,$object,$backtopage='') * @param Adherent|Societe $object Object third party or member * @param Contact $objcon Object contact * @param int $noprint Return string but does not output it + * @param int $actioncode Filter on actioncode * @return mixed Return html part or void if noprint is 1 */ -function show_actions_todo($conf,$langs,$db,$object,$objcon='',$noprint=0) +function show_actions_todo($conf,$langs,$db,$object,$objcon='',$noprint=0,$actioncode='') { global $bc,$user,$conf; @@ -966,6 +967,7 @@ function show_actions_todo($conf,$langs,$db,$object,$objcon='',$noprint=0) } if (get_class($object) == 'Societe' && $object->id) $sql.= " AND a.fk_soc = ".$object->id; if (! empty($objcon->id)) $sql.= " AND a.fk_contact = ".$objcon->id; + if (! empty($actioncode)) $sql.= " AND c.code='".$actioncode."' "; $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; $sql.= " ORDER BY a.datep DESC, a.id DESC"; @@ -1085,7 +1087,7 @@ function show_actions_todo($conf,$langs,$db,$object,$objcon='',$noprint=0) * @return mixed Return html part or void if noprint is 1 * TODO change function to be able to list event linked to an object. */ -function show_actions_done($conf,$langs,$db,$object,$objcon='',$noprint=0) +function show_actions_done($conf,$langs,$db,$object,$objcon='',$noprint=0,$actioncode='') { global $bc,$user,$conf; @@ -1120,6 +1122,7 @@ function show_actions_done($conf,$langs,$db,$object,$objcon='',$noprint=0) if (get_class($object) == 'Adherent') $sql.= " AND a.fk_element = m.rowid AND a.elementtype = 'member'"; if (get_class($object) == 'Adherent' && $object->id) $sql.= " AND a.fk_element = ".$object->id; if (is_object($objcon) && $objcon->id) $sql.= " AND a.fk_contact = ".$objcon->id; + if (!empty($actioncode)) $sql.= " AND c.code='".$actioncode."' "; $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; $sql.= " ORDER BY a.datep DESC, a.id DESC"; diff --git a/htdocs/societe/agenda.php b/htdocs/societe/agenda.php index 4547c7d75da..7dd3751ad64 100644 --- a/htdocs/societe/agenda.php +++ b/htdocs/societe/agenda.php @@ -162,15 +162,39 @@ if ($socid) if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) { - print '
'; - - print load_fiche_titre($langs->trans("ActionsOnCompany"),'',''); - + + $actioncode = ''; + if(!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { + + if (GETPOST('actioncode','array')) + { + $actioncode=GETPOST('actioncode','array',3); + if (! count($actioncode)) $actioncode='0'; + } + else + { + $actioncode=GETPOST("actioncode","alpha",3)?GETPOST("actioncode","alpha",3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE)); + } + + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + $formactions=new FormActions($db); + + print '
'; + print ''; + $formactions->select_type_actions($actioncode, "actioncode", '', 0, 0, 0); + print ''; + print '

' ; + + + } + + print load_fiche_titre($langs->trans("ActionsOnCompany"),'',''); + // List of todo actions - show_actions_todo($conf,$langs,$db,$object,null,0,1); + show_actions_todo($conf,$langs,$db,$object,null,0,$actioncode); // List of done actions - show_actions_done($conf,$langs,$db,$object); + show_actions_done($conf,$langs,$db,$object,null,0,$actioncode); } }