NEW Can add filter actiontype and notactiontype on event ical export

This commit is contained in:
Laurent Destailleur 2018-02-28 20:06:28 +01:00
parent 7d42ceab20
commit f545d2a134
4 changed files with 19 additions and 12 deletions

View File

@ -173,11 +173,12 @@ $message.='<br>';
$message.='<br>';
print $message;
$message=$langs->trans("AgendaUrlOptions1",$user->login,$user->login).'<br>';
$message =$langs->trans("AgendaUrlOptions1",$user->login,$user->login).'<br>';
$message.=$langs->trans("AgendaUrlOptions3",$user->login,$user->login).'<br>';
$message.=$langs->trans("AgendaUrlOptionsNotAdmin",$user->login,$user->login).'<br>';
$message.=$langs->trans("AgendaUrlOptions4",$user->login,$user->login).'<br>';
$message.=$langs->trans("AgendaUrlOptionsProject",$user->login,$user->login);
$message.=$langs->trans("AgendaUrlOptionsProject",$user->login,$user->login).'<br>';
$message.=$langs->trans("AgendaUrlOptionsNotAutoEvent",'systemauto','systemauto').'<br>';
print info_admin($message);

View File

@ -1329,7 +1329,7 @@ class ActionComm extends CommonObject
* @param string $type 'event' or 'journal'
* @param int $cachedelay Do not rebuild file if date older than cachedelay seconds
* @param string $filename Force filename
* @param array $filters Array of filters
* @param array $filters Array of filters. Exemple array('notolderthan'=>99, 'year'=>..., 'idfrom'=>..., 'notactiontype'=>'systemauto', 'project'=>123, ...)
* @return int <0 if error, nb of events in new file if ok
*/
function build_exportfile($format,$type,$cachedelay,$filename,$filters)
@ -1410,7 +1410,9 @@ class ActionComm extends CommonObject
if ($key == 'idfrom') $sql.=" AND a.id >= ".(is_numeric($value)?$value:0);
if ($key == 'idto') $sql.=" AND a.id <= ".(is_numeric($value)?$value:0);
if ($key == 'project') $sql.=" AND a.fk_project=".(is_numeric($value)?$value:0);
// We must filter on assignement table
if ($key == 'actiontype') $sql.=" AND c.type = '".$this->db->escape($value)."'";
if ($key == 'notactiontype') $sql.=" AND c.type <> '".$this->db->escape($value)."'";
// We must filter on assignement table
if ($key == 'logint') $sql.= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
if ($key == 'logina')
{

View File

@ -98,6 +98,7 @@ AgendaUrlOptions3=<b>logina=%s</b> to restrict output to actions owned by a user
AgendaUrlOptionsNotAdmin=<b>logina=!%s</b> to restrict output to actions not owned by user <b>%s</b>.
AgendaUrlOptions4=<b>logint=%s</b> to restrict output to actions assigned to user <b>%s</b> (owner and others).
AgendaUrlOptionsProject=<b>project=__PROJECT_ID__</b> to restrict output to actions linked to project <b>__PROJECT_ID__</b>.
AgendaUrlOptionsNotAutoEvent=<b>notactiontype=systemauto</b> to exclude automatic event.
AgendaShowBirthdayEvents=Show birthdays of contacts
AgendaHideBirthdayEvents=Hide birthdays of contacts
Busy=Busy

View File

@ -69,14 +69,16 @@ if (GETPOST("format",'alpha')) $format=GETPOST("format",'apha');
if (GETPOST("type",'apha')) $type=GETPOST("type",'alpha');
$filters=array();
if (GETPOST("year",'int')) $filters['year']=GETPOST("year",'int');
if (GETPOST("id",'int')) $filters['id']=GETPOST("id",'int');
if (GETPOST("idfrom",'int')) $filters['idfrom']=GETPOST("idfrom",'int');
if (GETPOST("idto",'int')) $filters['idto']=GETPOST("idto",'int');
if (GETPOST("project",'apha')) $filters['project']=GETPOST("project",'apha');
if (GETPOST("logina",'apha')) $filters['logina']=GETPOST("logina",'apha');
if (GETPOST("logint",'apha')) $filters['logint']=GETPOST("logint",'apha');
if (GETPOST("notolderthan",'int')) $filters['notolderthan']=GETPOST("notolderthan","int");
if (GETPOST("year",'int')) $filters['year']=GETPOST("year",'int');
if (GETPOST("id",'int')) $filters['id']=GETPOST("id",'int');
if (GETPOST("idfrom",'int')) $filters['idfrom']=GETPOST("idfrom",'int');
if (GETPOST("idto",'int')) $filters['idto']=GETPOST("idto",'int');
if (GETPOST("project",'apha')) $filters['project']=GETPOST("project",'apha');
if (GETPOST("logina",'apha')) $filters['logina']=GETPOST("logina",'apha');
if (GETPOST("logint",'apha')) $filters['logint']=GETPOST("logint",'apha');
if (GETPOST("notactiontype",'apha')) $filters['notactiontype']=GETPOST("notactiontype",'apha');
if (GETPOST("actiontype",'apha')) $filters['actiontype']=GETPOST("actiontype",'apha');
if (GETPOST("notolderthan",'int')) $filters['notolderthan']=GETPOST("notolderthan","int");
else $filters['notolderthan']=$conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY;
// Check config
@ -116,6 +118,7 @@ foreach ($filters as $key => $value)
if ($key == 'project') $filename.='-project'.$value;
if ($key == 'logina') $filename.='-logina'.$value; // Author
if ($key == 'logint') $filename.='-logint'.$value; // Assigned to
if ($key == 'notactiontype') $filename.='-notactiontype'.$value;
}
// Add extension
if ($format == 'vcal') { $shortfilename.='.vcs'; $filename.='.vcs'; }