From c1bf7c52f441aa51ea8d99899a1f38600d42e845 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Oct 2016 00:02:18 +0200 Subject: [PATCH] Add a line of filter in list of events related to thirdparty or projects --- htdocs/admin/agenda_other.php | 192 ++++++++++++++++---------------- htdocs/core/lib/company.lib.php | 19 ++-- htdocs/projet/info.php | 6 +- htdocs/societe/agenda.php | 6 +- 4 files changed, 118 insertions(+), 105 deletions(-) diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php index 2fe4f0a6037..9ea048c27fd 100644 --- a/htdocs/admin/agenda_other.php +++ b/htdocs/admin/agenda_other.php @@ -203,7 +203,6 @@ dol_fiche_head($head, 'other', $langs->trans("Agenda"), 0, 'action'); * Documents models for supplier orders */ -print load_fiche_titre($langs->trans("AgendaModelModule"),'',''); // Define array def of models $def = array(); @@ -230,109 +229,114 @@ else dol_print_error($db); } -print ''."\n"; -print ''."\n"; -print ''."\n"; -print ''."\n"; -print ''."\n"; -print ''."\n"; -print ''; -print ''; -print ''."\n"; - -clearstatcache(); - -$var=true; -foreach ($dirmodels as $reldir) +if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { - $dir = dol_buildpath($reldir."core/modules/action/doc/"); - - if (is_dir($dir)) + print load_fiche_titre($langs->trans("AgendaModelModule"),'',''); + + print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Status").''.$langs->trans("Default").''.$langs->trans("ShortInfo").''.$langs->trans("Preview").'
'."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''."\n"; + print ''; + print ''; + print ''."\n"; + + clearstatcache(); + + $var=true; + foreach ($dirmodels as $reldir) { - $handle=opendir($dir); - if (is_resource($handle)) + $dir = dol_buildpath($reldir."core/modules/action/doc/"); + + if (is_dir($dir)) { - while (($file = readdir($handle))!==false) + $handle=opendir($dir); + if (is_resource($handle)) { - if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file)) + while (($file = readdir($handle))!==false) { - $name = substr($file, 4, dol_strlen($file) -16); - $classname = substr($file, 0, dol_strlen($file) -12); - - require_once $dir.'/'.$file; - $module = new $classname($db, new ActionComm($db)); - - $var=!$var; - print "\n"; - print "\n"; - print "\n"; - - // Active - if (in_array($name, $def)) - { - - print '"; - } - else - { - print '"; - } - - // Default - print ''; - - // Info - $htmltooltip = ''.$langs->trans("Name").': '.$module->name; - $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); - $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; - $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; - $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo,1,1); - print ''; - print ''; - - print "\n"; + if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file)) + { + $name = substr($file, 4, dol_strlen($file) -16); + $classname = substr($file, 0, dol_strlen($file) -12); + + require_once $dir.'/'.$file; + $module = new $classname($db, new ActionComm($db)); + + $var=!$var; + print "\n"; + print "\n"; + print "\n"; + + // Active + if (in_array($name, $def)) + { + + print '"; + } + else + { + print '"; + } + + // Default + print ''; + + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); + $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo,1,1); + print ''; + print ''; + + print "\n"; + } } + closedir($handle); } - closedir($handle); } } + print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Status").''.$langs->trans("Default").''.$langs->trans("ShortInfo").''.$langs->trans("Preview").'
"; - print (empty($module->name)?$name:$module->name); - print "\n"; - require_once $dir.$file; - $module = new $classname($db,$specimenthirdparty); - if (method_exists($module,'info')) - print $module->info($langs); - else - print $module->description; - print "'."\n"; - if ($conf->global->ACTION_EVENT_ADDON_PDF != "$name") - { - print 'scandir.'&label='.urlencode($module->name).'&type=action">'; - print img_picto($langs->trans("Enabled"),'switch_on'); - print ''; - } - else - { - print img_picto($langs->trans("Enabled"),'switch_on'); - } - print "'."\n"; - print 'scandir.'&label='.urlencode($module->name).'&type=action">'.img_picto($langs->trans("Disabled"),'switch_off').''; - print "'; - if ($conf->global->ACTION_EVENT_ADDON_PDF == "$name") - { - print img_picto($langs->trans("Default"),'on'); - } - else - { - print 'scandir.'&label='.urlencode($module->name).'&type=action"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; - } - print ''; - print $form->textwithpicto('',$htmltooltip,1,0); - print ''; - print ''.img_object($langs->trans("Preview"),'order').''; - print '
"; + print (empty($module->name)?$name:$module->name); + print "\n"; + require_once $dir.$file; + $module = new $classname($db,$specimenthirdparty); + if (method_exists($module,'info')) + print $module->info($langs); + else + print $module->description; + print "'."\n"; + if ($conf->global->ACTION_EVENT_ADDON_PDF != "$name") + { + print 'scandir.'&label='.urlencode($module->name).'&type=action">'; + print img_picto($langs->trans("Enabled"),'switch_on'); + print ''; + } + else + { + print img_picto($langs->trans("Enabled"),'switch_on'); + } + print "'."\n"; + print 'scandir.'&label='.urlencode($module->name).'&type=action">'.img_picto($langs->trans("Disabled"),'switch_off').''; + print "'; + if ($conf->global->ACTION_EVENT_ADDON_PDF == "$name") + { + print img_picto($langs->trans("Default"),'on'); + } + else + { + print 'scandir.'&label='.urlencode($module->name).'&type=action"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; + } + print ''; + print $form->textwithpicto('',$htmltooltip,1,0); + print ''; + print ''.img_object($langs->trans("Preview"),'order').''; + print '

'; } -print '
'; $var=true; diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index b4205a5d997..f1c56f53a2f 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -952,15 +952,16 @@ function show_actions_todo($conf,$langs,$db,$filterobj,$objcon='',$noprint=0,$ac * @param Conf $conf Object conf * @param Translate $langs Object langs * @param DoliDB $db Object db - * @param Adherent|Societe $filterobj Object third party or member + * @param Adherent|Societe|Project $filterobj Object third party or member or project * @param Contact $objcon Object contact * @param int $noprint Return string but does not output it * @param string $actioncode Filter on actioncode - * @param string $donetodo Filter on avent 'done' or 'todo' or ''=nofilter. + * @param string $donetodo Filter on event 'done' or 'todo' or ''=nofilter. + * @param array $filters Filter on other fields * @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, $filterobj, $objcon='', $noprint=0, $actioncode='', $donetodo='done') +function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=0, $actioncode='', $donetodo='done', $filters=array()) { global $bc,$user,$conf; global $form; @@ -1000,6 +1001,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= if (!empty($actioncode)) $sql.= " AND c.code='".$actioncode."' "; if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; if ($donetodo == 'done') $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; + if (is_array($filters) && $filters['search_agenda_label']) $sql.= natural_search('a.label', $filters['search_agenda_label']); $sql.= " ORDER BY a.datep DESC, a.id DESC"; dol_syslog("company.lib::show_actions_done", LOG_DEBUG); @@ -1144,7 +1146,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= $out.=''; } $out.=''; - $out.=''; + $out.=''; $out.=''; $out.=''; if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { @@ -1216,11 +1218,10 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= } $out.="\n"; - if($conf->global->AGENDA_USE_EVENT_TYPE) { - $out.=''; - $out.=$actionstatic->type; - $out.=''; - } + $out.=''; + $out.=$actionstatic->type; + $out.=''; + // Title of event //$out.=''.dol_trunc($histo[$key]['note'], 40).''; diff --git a/htdocs/projet/info.php b/htdocs/projet/info.php index ec1e976237a..809f33ca5cb 100644 --- a/htdocs/projet/info.php +++ b/htdocs/projet/info.php @@ -38,6 +38,7 @@ 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)); } +$search_agenda_label=GETPOST('search_agenda_label'); // Security check $socid=0; @@ -61,6 +62,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers { $actioncode=''; + $search_agenda_label=''; } @@ -163,7 +165,9 @@ if (!empty($object->id)) //show_actions_done($conf,$langs,$db,$object,null,0,$actioncode); // List of all actions - show_actions_done($conf,$langs,$db,$object,null,0,$actioncode, ''); + $filters=array(); + $filters['search_agenda_label']=$search_agenda_label; + show_actions_done($conf,$langs,$db,$object,null,0,$actioncode, '', $filters); } diff --git a/htdocs/societe/agenda.php b/htdocs/societe/agenda.php index 0f7c3a553b6..5cedf2fdfaa 100644 --- a/htdocs/societe/agenda.php +++ b/htdocs/societe/agenda.php @@ -43,6 +43,7 @@ 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)); } +$search_agenda_label=GETPOST('search_agenda_label'); // Security check $socid = GETPOST('socid','int'); @@ -65,6 +66,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers { $actioncode=''; + $search_agenda_label=''; } @@ -189,7 +191,9 @@ if ($socid) //show_actions_done($conf,$langs,$db,$object,null,0,$actioncode); // List of all actions - show_actions_done($conf,$langs,$db,$object,null,0,$actioncode, ''); + $filters=array(); + $filters['search_agenda_label']=$search_agenda_label; + show_actions_done($conf,$langs,$db,$object,null,0,$actioncode, '', $filters); } }