diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index 8d0b6e14b2b..ff037f67aa1 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -144,6 +144,8 @@ if (GETPOST('addoperation','alpha')) $emailcollectoroperation->actionparam = GETPOST('operationparam', 'none'); $emailcollectoroperation->fk_emailcollector = $object->id; $emailcollectoroperation->status = 1; + $emailcollectoroperation->position = 50; + $result = $emailcollectoroperation->create($user); if ($result > 0) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 1c42945fbe7..d703e57204f 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -334,7 +334,16 @@ class ActionComm extends CommonObject $sql.= "fk_element,"; $sql.= "elementtype,"; $sql.= "entity,"; - $sql.= "extraparams"; + $sql.= "extraparams,"; + // Fields emails + $sql.= "email_msgid,"; + $sql.= "email_from,"; + $sql.= "email_sender,"; + $sql.= "email_to,"; + $sql.= "email_tocc,"; + $sql.= "email_tobcc,"; + $sql.= "email_subject,"; + $sql.= "errors_to"; $sql.= ") VALUES ("; $sql.= "'".$this->db->idate($now)."', "; $sql.= (strval($this->datep)!=''?"'".$this->db->idate($this->datep)."'":"null").", "; @@ -354,7 +363,16 @@ class ActionComm extends CommonObject $sql.= (! empty($this->fk_element)?$this->fk_element:"null").", "; $sql.= (! empty($this->elementtype)?"'".$this->db->escape($this->elementtype)."'":"null").", "; $sql.= $conf->entity.","; - $sql.= (! empty($this->extraparams)?"'".$this->db->escape($this->extraparams)."'":"null"); + $sql.= (! empty($this->extraparams)?"'".$this->db->escape($this->extraparams)."'":"null").", "; + // Fields emails + $sql.= (! empty($this->email_msgid)?"'".$this->db->escape($this->email_msgid)."'":"null").", "; + $sql.= (! empty($this->email_from)?"'".$this->db->escape($this->email_from)."'":"null").", "; + $sql.= (! empty($this->email_sender)?"'".$this->db->escape($this->email_sender)."'":"null").", "; + $sql.= (! empty($this->email_to)?"'".$this->db->escape($this->email_to)."'":"null").", "; + $sql.= (! empty($this->email_tocc)?"'".$this->db->escape($this->email_tocc)."'":"null").", "; + $sql.= (! empty($this->email_tobcc)?"'".$this->db->escape($this->email_tobcc)."'":"null").", "; + $sql.= (! empty($this->email_subject)?"'".$this->db->escape($this->email_subject)."'":"null").", "; + $sql.= (! empty($this->errors_to)?"'".$this->db->escape($this->errors_to)."'":"null"); $sql.= ")"; dol_syslog(get_class($this)."::add", LOG_DEBUG); @@ -1691,7 +1709,7 @@ class ActionComm extends CommonObject $this->output = $langs->trans('EventRemindersByEmailNotEnabled', $langs->transnoentitiesnoconv("Agenda")); return 0; } - + $now = dol_now(); dol_syslog(__METHOD__, LOG_DEBUG); diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 144a2159deb..a411bf0c0a1 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -44,9 +44,9 @@ if (! isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MA if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5; $MAXAGENDA=$conf->global->AGENDA_EXT_NB; -$filter = GETPOST("filter",'alpha',3); -$filtert = GETPOST("filtert","int",3); -$usergroup = GETPOST("usergroup","int",3); +$filter = GETPOST("search_filter",'alpha',3)?GETPOST("search_filter",'alpha',3):GETPOST("filter",'alpha',3); +$filtert = GETPOST("search_filtert","int",3)?GETPOST("search_filtert","int",3):GETPOST("filtert","int",3); +$usergroup = GETPOST("search_usergroup","int",3)?GETPOST("search_usergroup","int",3):GETPOST("usergroup","int",3); $showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1; // If not choice done on calendar owner (like on left menu link "Agenda"), we filter on user. @@ -65,7 +65,7 @@ if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="a.datec"; // Security check -$socid = GETPOST("socid","int"); +$socid = GETPOST("search_socid","int")?GETPOST("search_socid","int"):GETPOST("socid","int"); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'agenda', 0, '', 'myactions'); if ($socid < 0) $socid=''; @@ -79,32 +79,32 @@ if (! $user->rights->agenda->allactions->read || $filter =='mine') // If no per } $action=GETPOST('action','alpha'); -$resourceid=GETPOST("resourceid","int"); +$resourceid=GETPOST("search_resourceid","int"); $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"):date("d"); -$pid=GETPOST("projectid","int",3); -$status=GETPOST("status",'aZ09'); // status may be 0, 50, 100, 'todo' -$type=GETPOST("type",'az09'); +$pid=GETPOST("search_projectid","int",3)?GETPOST("search_projectid","int",3):GETPOST("projectid","int",3); +$status=GETPOST("search_status",'aZ09')?GETPOST("search_status",'aZ09'):GETPOST("status",'aZ09'); // status may be 0, 50, 100, 'todo' +$type=GETPOST("search_type",'az09')?GETPOST("search_type",'az09'):GETPOST("type",'az09'); $maxprint=(isset($_GET["maxprint"])?GETPOST("maxprint"):$conf->global->AGENDA_MAX_EVENTS_DAY_VIEW); // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) -if (GETPOST('actioncode','array')) +if (GETPOST('search_actioncode','array')) { - $actioncode=GETPOST('actioncode','array',3); + $actioncode=GETPOST('search_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)); + $actioncode=GETPOST("search_actioncode","alpha",3)?GETPOST("search_actioncode","alpha",3):(GETPOST("search_actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE)); } if ($actioncode == '' && empty($actioncodearray)) $actioncode=(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE); -if ($status == '' && ! isset($_GET['status']) && ! isset($_POST['status'])) $status=(empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS)?'':$conf->global->AGENDA_DEFAULT_FILTER_STATUS); +if ($status == '' && ! GETPOSTISSET('search_status')) $status=(empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS)?'':$conf->global->AGENDA_DEFAULT_FILTER_STATUS); $defaultview = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); $defaultview = (empty($user->conf->AGENDA_DEFAULT_VIEW) ? $defaultview : $user->conf->AGENDA_DEFAULT_VIEW); -if (empty($action) && ! isset($_GET['action']) && ! isset($_POST['action'])) $action=$defaultview; +if (empty($action) && ! GETPOSTISSET('action','alpha')) $action=$defaultview; if ($action == 'default') // When action is default, we want a calendar view and not the list { $action = (($defaultview != 'show_list') ? $defaultview : 'show_month'); @@ -301,21 +301,22 @@ if ($status == 'done') $title=$langs->trans("DoneActions"); if ($status == 'todo') $title=$langs->trans("ToDoActions"); $param=''; -if ($actioncode || isset($_GET['actioncode']) || isset($_POST['actioncode'])) { +if ($actioncode || isset($_GET['search_actioncode']) || isset($_POST['search_actioncode'])) { if(is_array($actioncode)) { - foreach($actioncode as $str_action) $param.="&actioncode[]=".$str_action; - } else $param.="&actioncode=".$actioncode; + foreach($actioncode as $str_action) $param.="&search_actioncode[]=".urlencode($str_action); + } else $param.="&search_actioncode=".urlencode($actioncode); } -if ($resourceid > 0) $param.="&resourceid=".$resourceid; -if ($status || isset($_GET['status']) || isset($_POST['status'])) $param.="&status=".$status; -if ($filter) $param.="&filter=".$filter; -if ($filtert) $param.="&filtert=".$filtert; -if ($socid) $param.="&socid=".$socid; -if ($showbirthday) $param.="&showbirthday=1"; -if ($pid) $param.="&projectid=".$pid; -if ($type) $param.="&type=".$type; -if ($action == 'show_day' || $action == 'show_week' || $action == 'show_month') $param.='&action='.$action; -$param.="&maxprint=".$maxprint; +if ($resourceid > 0) $param.="&search_resourceid=".urlencode($resourceid); +if ($status || isset($_GET['status']) || isset($_POST['status'])) $param.="&search_status=".urlencode($status); +if ($filter) $param.="&search_filter=".urlencode($filter); +if ($filtert) $param.="&search_filtert=".urlencode($filtert); +if ($usergroup) $param.="&search_usergroup=".urlencode($usergroup); +if ($socid) $param.="&search_socid=".urlencode($socid); +if ($showbirthday) $param.="&search_showbirthday=1"; +if ($pid) $param.="&search_projectid=".urlencode($pid); +if ($type) $param.="&search_type=".urlencode($type); +if ($action == 'show_day' || $action == 'show_week' || $action == 'show_month') $param.='&action='.urlencode($action); +$param.="&maxprint=".urlencode($maxprint); // Show navigation bar if (empty($action) || $action=='show_month') diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 63a6a78ee8c..2186a19bf04 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -41,23 +41,23 @@ $langs->loadLangs(array("users","companies","agenda","commercial")); $action=GETPOST('action','alpha'); $contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'actioncommlist'; // To manage different context of search -$resourceid=GETPOST("resourceid","int"); +$resourceid=GETPOST("search_resourceid","int")?GETPOST("search_resourceid","int"):GETPOST("resourceid","int"); +$pid=GETPOST("search_projectid",'int',3)?GETPOST("search_projectid",'int',3):GETPOST("projectid",'int',3); +$status=GETPOST("search_status",'alpha')?GETPOST("search_status",'alpha'):GETPOST("status",'alpha'); +$type=GETPOST('search_type','alphanohtml')?GETPOST('search_type','alphanohtml'):GETPOST('type','alphanohtml'); +$optioncss = GETPOST('optioncss','alpha'); $year=GETPOST("year",'int'); $month=GETPOST("month",'int'); $day=GETPOST("day",'int'); -$pid=GETPOST("projectid",'int',3); -$status=GETPOST("status",'alpha'); -$type=GETPOST('type','alphanohtml'); -$optioncss = GETPOST('optioncss','alpha'); // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) -if (GETPOST('actioncode','array')) +if (GETPOST('search_actioncode','array')) { - $actioncode=GETPOST('actioncode','array',3); + $actioncode=GETPOST('search_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)); + $actioncode=GETPOST("search_actioncode","alpha",3)?GETPOST("search_actioncode","alpha",3):(GETPOST("search_actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE)); } if ($actioncode == '' && empty($actioncodearray)) $actioncode=(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE); $search_id=GETPOST('search_id','alpha'); @@ -69,10 +69,10 @@ $dateend=dol_mktime(0, 0, 0, GETPOST('dateendmonth','int'), GETPOST('dateendday' if ($status == '' && ! isset($_GET['status']) && ! isset($_POST['status'])) $status=(empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS)?'':$conf->global->AGENDA_DEFAULT_FILTER_STATUS); if (empty($action) && ! isset($_GET['action']) && ! isset($_POST['action'])) $action=(empty($conf->global->AGENDA_DEFAULT_VIEW)?'show_month':$conf->global->AGENDA_DEFAULT_VIEW); -$filter = GETPOST("filter",'alpha',3); -$filtert = GETPOST("filtert","int",3); -$usergroup = GETPOST("usergroup","int",3); -$showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1; +$filter = GETPOST("search_filter",'alpha',3)?GETPOST("search_filter",'alpha',3):GETPOST("filter",'alpha',3); +$filtert = GETPOST("search_filtert","int",3)?GETPOST("search_filtert","int",3):GETPOST("filtert","int",3); +$usergroup = GETPOST("search_usergroup","int",3)?GETPOST("search_usergroup","int",3):GETPOST("usergroup","int",3); +$showbirthday = empty($conf->use_javascript_ajax)?(GETPOST("search_showbirthday","int")?GETPOST("search_showbirthday","int"):GETPOST("showbirthday","int")):1; // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new ActionComm($db); @@ -108,7 +108,7 @@ if (! $sortfield) } // Security check -$socid = GETPOST("socid",'int'); +$socid = GETPOST("search_socid",'int')?GETPOST("search_socid",'int'):GETPOST("socid",'int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'agenda', 0, '', 'myactions'); if ($socid < 0) $socid=''; @@ -132,7 +132,8 @@ $arrayfields=array( 'a.fk_contact'=>array('label'=>"Contact", 'checked'=>1), 'a.fk_element'=>array('label'=>"LinkedObject", 'checked'=>0, 'enabled'=>(! empty($conf->global->AGENDA_SHOW_LINKED_OBJECT))), 'a.percent'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000), - + 'a.datec'=>array('label'=>'DateCreation', 'checked'=>0), + 'a.tms'=>array('label'=>'DateModification', 'checked'=>0) ); // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) @@ -207,19 +208,18 @@ if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&con if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); if ($actioncode != '') { if(is_array($actioncode)) { - foreach($actioncode as $str_action) $param.="&actioncode[]=".urlencode($str_action); - } else $param.="&actioncode=".urlencode($actioncode); + foreach($actioncode as $str_action) $param.="&search_actioncode[]=".urlencode($str_action); + } else $param.="&search_actioncode=".urlencode($actioncode); } -if ($resourceid > 0) $param.="&resourceid=".urlencode($resourceid); -if ($status != '' && $status > -1) $param.="&status=".urlencode($status); -if ($filter) $param.="&filter=".urlencode($filter); -if ($filtert) $param.="&filtert=".urlencode($filtert); -if ($socid) $param.="&socid=".urlencode($socid); -if ($showbirthday) $param.="&showbirthday=1"; -if ($pid) $param.="&projectid=".urlencode($pid); -if ($type) $param.="&type=".urlencode($type); -if ($usergroup) $param.="&usergroup=".urlencode($usergroup); -if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); +if ($resourceid > 0) $param.="&search_resourceid=".urlencode($resourceid); +if ($status != '' && $status > -1) $param.="&search_status=".urlencode($status); +if ($filter) $param.="&search_filter=".urlencode($filter); +if ($filtert) $param.="&search_filtert=".urlencode($filtert); +if ($socid) $param.="&search_socid=".urlencode($socid); +if ($showbirthday) $param.="&search_showbirthday=1"; +if ($pid) $param.="&search_projectid=".urlencode($pid); +if ($type) $param.="&search_type=".urlencode($type); +if ($usergroup) $param.="&search_usergroup=".urlencode($usergroup); if ($search_id != '') $param.='&search_title='.urlencode($search_id); if ($search_title != '') $param.='&search_title='.urlencode($search_title); if (GETPOST('datestartday','int')) $param.='&datestartday='.GETPOST('datestartday','int'); @@ -228,6 +228,7 @@ if (GETPOST('datestartyear','int')) $param.='&datestartyear='.GETPOST('datestart if (GETPOST('dateendday','int')) $param.='&dateendday='.GETPOST('dateendday','int'); if (GETPOST('dateendmonth','int')) $param.='&dateendmonth='.GETPOST('dateendmonth','int'); if (GETPOST('dateendyear','int')) $param.='&dateendyear='.GETPOST('dateendyear','int'); +if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -237,7 +238,7 @@ $sql.= " s.nom as societe, s.rowid as socid, s.client,"; $sql.= " a.id, a.label, a.datep as dp, a.datep2 as dp2,"; $sql.= ' a.fk_user_author,a.fk_user_action,'; $sql.= " a.fk_contact, a.note, a.percent as percent,"; -$sql.= " a.fk_element, a.elementtype,"; +$sql.= " a.fk_element, a.elementtype, a.datec, a.tms as datem,"; $sql.= " c.code as type_code, c.libelle as type_label,"; $sql.= " sp.lastname, sp.firstname, sp.email, sp.phone, sp.address, sp.phone as phone_pro, sp.phone_mobile, sp.phone_perso, sp.fk_pays as country_id"; // Add fields from extrafields @@ -364,10 +365,10 @@ if ($resql) //if ($actioncode) $nav.=''; //if ($resourceid) $nav.=''; - if ($filter) $nav.=''; + if ($filter) $nav.=''; //if ($filtert) $nav.=''; //if ($socid) $nav.=''; - if ($showbirthday) $nav.=''; + if ($showbirthday) $nav.=''; //if ($pid) $nav.=''; //if ($usergroup) $nav.=''; print $nav; @@ -461,8 +462,9 @@ if ($resql) $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - - if (! empty($arrayfields['a.percent']['checked'])) { + if (! empty($arrayfields['a.datec']['checked'])) print ''; + if (! empty($arrayfields['a.tms']['checked'])) print ''; + if (! empty($arrayfields['a.percent']['checked'])) { print ''; print $formactions->form_select_status_action('formaction',$status,1,'status',1,2); print ajax_combobox('selectstatus'); @@ -494,6 +496,10 @@ if ($resql) $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; + + if (! empty($arrayfields['a.datec']['checked'])) print_liste_field_titre($arrayfields['a.datec']['label'], $_SERVER["PHP_SELF"],"a.datec,a.id",$param,"",'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['a.tms']['checked'])) print_liste_field_titre($arrayfields['a.tms']['label'], $_SERVER["PHP_SELF"],"a.tms,a.id",$param,"",'align="center"',$sortfield,$sortorder); + if (! empty($arrayfields['a.percent']['checked']))print_liste_field_titre("Status",$_SERVER["PHP_SELF"],"a.percent",$param,"",'align="center"',$sortfield,$sortorder); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; @@ -652,6 +658,15 @@ if ($resql) $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; + // Date creation + if (! empty($arrayfields['a.datec']['checked'])) { + // Status/Percent + print ''.dol_print_date($obj->datec, 'dayhour').''; + } + // Date update + if (! empty($arrayfields['a.tms']['checked'])) { + print ''.dol_print_date($obj->datem, 'dayhour').''; + } if (! empty($arrayfields['a.percent']['checked'])) { // Status/Percent $datep=$db->jdate($obj->datep); diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 19a7e33d23d..af141f76ae9 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -41,9 +41,9 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; if (! isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW=3; -$filter = GETPOST("filter",'alpha',3); -$filtert = GETPOST("filtert","int",3); -$usergroup = GETPOST("usergroup","int",3); +$filter = GETPOST("search_filter",'alpha',3)?GETPOST("search_filter",'alpha',3):GETPOST("filter",'alpha',3); +$filtert = GETPOST("search_filtert","int",3)?GETPOST("search_filtert","int",3):GETPOST("filtert","int",3); +$usergroup = GETPOST("search_usergroup","int",3)?GETPOST("search_usergroup","int",3):GETPOST("usergroup","int",3); //if (! ($usergroup > 0) && ! ($filtert > 0)) $filtert = $user->id; //$showbirthday = empty($conf->use_javascript_ajax)?GETPOST("showbirthday","int"):1; $showbirthday = 0; @@ -64,7 +64,7 @@ if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="a.datec"; // Security check -$socid = GETPOST("socid","int"); +$socid = GETPOST("search_socid","int")?GETPOST("search_socid","int"):GETPOST("socid","int"); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'agenda', 0, '', 'myactions'); if ($socid < 0) $socid=''; @@ -79,24 +79,24 @@ if (! $user->rights->agenda->allactions->read || $filter =='mine') // If no per //$action=GETPOST('action','alpha'); $action='show_peruser'; //We use 'show_week' mode -$resourceid=GETPOST("resourceid","int"); +$resourceid=GETPOST("search_resourceid","int")?GETPOST("search_resourceid","int"):GETPOST("resourceid","int"); $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"):date("d"); -$pid=GETPOST("projectid","int",3); -$status=GETPOST("status",'alpha'); -$type=GETPOST("type",'alpha'); +$pid=GETPOST("search_projectid","int",3)?GETPOST("search_projectid","int",3):GETPOST("projectid","int",3); +$status=GETPOST("search_status",'alpha')?GETPOST("search_status",'alpha'):GETPOST("status",'alpha'); +$type=GETPOST("search_type",'alpha')?GETPOST("search_type",'alpha'):GETPOST("type",'alpha'); $maxprint=((GETPOST("maxprint",'int')!='')?GETPOST("maxprint",'int'):$conf->global->AGENDA_MAX_EVENTS_DAY_VIEW); // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) -if (GETPOST('actioncode','array')) +if (GETPOST('search_actioncode','array')) { - $actioncode=GETPOST('actioncode','array',3); + $actioncode=GETPOST('search_actioncode','array',3); if (! count($actioncode)) $actioncode='0'; } else { - $actioncode=GETPOST("actioncode","alpha",3)?GETPOST("actioncode","alpha",3):(GETPOST("actioncode","alpha")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE)); + $actioncode=GETPOST("search_actioncode","alpha",3)?GETPOST("search_actioncode","alpha",3):(GETPOST("search_actioncode","alpha")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE)); } if ($actioncode == '' && empty($actioncodearray)) $actioncode=(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE); @@ -201,25 +201,25 @@ if ($status == 'done') $title=$langs->trans("DoneActions"); if ($status == 'todo') $title=$langs->trans("ToDoActions"); $param=''; -if ($actioncode || isset($_GET['actioncode']) || isset($_POST['actioncode'])) { +if ($actioncode || isset($_GET['search_actioncode']) || isset($_POST['search_actioncode'])) { if(is_array($actioncode)) { - foreach($actioncode as $str_action) $param.="&actioncode[]=".urlencode($str_action); - } else $param.="&actioncode=".urlencode($actioncode); + foreach($actioncode as $str_action) $param.="&search_actioncode[]=".urlencode($str_action); + } else $param.="&search_actioncode=".urlencode($actioncode); } -if ($resourceid > 0) $param.="&resourceid=".urlencode($resourceid); -if ($status || isset($_GET['status']) || isset($_POST['status'])) $param.="&status=".urlencode($status); -if ($filter) $param.="&filter=".urlencode($filter); -if ($filtert) $param.="&filtert=".urlencode($filtert); -if ($usergroup) $param.="&usergroup=".urlencode($usergroup); -if ($socid) $param.="&socid=".urlencode($socid); -if ($showbirthday) $param.="&showbirthday=1"; -if ($pid) $param.="&projectid=".urlencode($pid); -if ($type) $param.="&type=".urlencode($type); +if ($resourceid > 0) $param.="&search_resourceid=".urlencode($resourceid); +if ($status || isset($_GET['status']) || isset($_POST['status'])) $param.="&search_status=".urlencode($status); +if ($filter) $param.="&search_filter=".urlencode($filter); +if ($filtert) $param.="&search_filtert=".urlencode($filtert); +if ($usergroup) $param.="&search_usergroup=".urlencode($usergroup); +if ($socid) $param.="&search_socid=".urlencode($socid); +if ($showbirthday) $param.="&search_showbirthday=1"; +if ($pid) $param.="&search_projectid=".urlencode($pid); +if ($type) $param.="&search_type=".urlencode($type); if ($action == 'show_day' || $action == 'show_week' || $action == 'show_month' || $action != 'show_peruser') $param.='&action='.urlencode($action); if ($begin_h != '') $param.='&begin_h='.urlencode($begin_h); -if ($end_h != '') $param.='&end_h='.urlencode($end_h); +if ($end_h != '') $param.='&end_h='.urlencode($end_h); if ($begin_d != '') $param.='&begin_d='.urlencode($begin_d); -if ($end_d != '') $param.='&end_d='.urlencode($end_d); +if ($end_d != '') $param.='&end_d='.urlencode($end_d); $param.="&maxprint=".urlencode($maxprint); diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index 23d5fcf30dc..6dab036193d 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -64,7 +64,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh print ''; print ''; print ''; - print ''; + print ''; print '
'; @@ -79,7 +79,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh print ''; print $langs->trans("ActionsToDoBy").'   '; print ''; - print $form->select_dolusers($filtert, 'filtert', 1, '', ! $canedit, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); + print $form->select_dolusers($filtert, 'search_filtert', 1, '', ! $canedit, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); if (empty($conf->dol_optimize_smallscreen)) print '   '.$langs->trans("or") . ' '.$langs->trans("ToUserOfGroup").'   '; print $form->select_dolgroups($usergroupid, 'usergroup', 1, '', ! $canedit); print ''; @@ -94,7 +94,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh print ''; print $langs->trans("Resource"); print '  '; - print $formresource->select_resource_list($resourceid, "resourceid", '', 1, 0, 0, null, '', 2); + print $formresource->select_resource_list($resourceid, "search_resourceid", '', 1, 0, 0, null, '', 2); print ''; } @@ -108,7 +108,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh { $multiselect=(!empty($conf->global->AGENDA_USE_EVENT_TYPE)); } - print $formactions->select_type_actions($actioncode, "actioncode", $excludetype, (empty($conf->global->AGENDA_USE_EVENT_TYPE)?1:-1), 0, $multiselect); + print $formactions->select_type_actions($actioncode, "search_actioncode", $excludetype, (empty($conf->global->AGENDA_USE_EVENT_TYPE)?1:-1), 0, $multiselect); print ''; } @@ -118,7 +118,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh print ''; print $langs->trans("ThirdParty").'   '; print ''; - print $form->select_company($socid, 'socid', '', 'SelectThirdParty', 0, 0, null, 0); + print $form->select_company($socid, 'search_socid', '', 'SelectThirdParty', 0, 0, null, 0); print ''; } @@ -131,7 +131,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh print ''; print $langs->trans("Project").'   '; print ''; - print $formproject->select_projects($socid?$socid:-1, $pid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 1, 0, 'maxwidth500'); + print $formproject->select_projects($socid?$socid:-1, $pid, 'search_projectid', 0, 0, 1, 0, 0, 0, 0, '', 1, 0, 'maxwidth500'); print ''; } @@ -142,7 +142,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh print ''; print $langs->trans("Status"); print '  '; - $formactions->form_select_status_action('formaction', $status, 1, 'status', 1, 2, 'minwidth100'); + $formactions->form_select_status_action('formaction', $status, 1, 'search_status', 1, 2, 'minwidth100'); print ''; } diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index df064e030da..b45d32ced19 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -749,14 +749,14 @@ class EmailCollector extends CommonObject $regforregex=array(); if (preg_match('/^REGEX:([a-zA-Z0-9]+):(.*):([^:])$/', $valueforproperty, $regforregex)) { - $sourcefield=$regforregex[0]; - $regexstring=$regforregex[1]; - //$transofrmationstring=$regforregex[2]; + $sourcefield=$regforregex[1]; + $regexstring=$regforregex[2]; + //$transofrmationstring=$regforregex[3]; } elseif (preg_match('/^REGEX:([a-zA-Z0-9]+):(.*)$/', $valueforproperty, $regforregex)) { - $sourcefield=$regforregex[0]; - $regexstring=$regforregex[1]; + $sourcefield=$regforregex[1]; + $regexstring=$regforregex[2]; } if (! empty($sourcefield) && ! empty($regexstring)) @@ -768,7 +768,7 @@ class EmailCollector extends CommonObject if (preg_match('/'.preg_quote($regexstring, '/').'/', $sourcestring, $regforval)) { // Overwrite param $tmpproperty - $object->$tmpproperty = $regforval[0]; + $object->$tmpproperty = $regforval[1]; } else { @@ -777,7 +777,7 @@ class EmailCollector extends CommonObject } elseif (preg_match('/^VALUE:(.*)$/', $valueforproperty, $reg)) { - $object->$tmpproperty = $reg[0]; + $object->$tmpproperty = $reg[1]; } else { @@ -806,7 +806,7 @@ class EmailCollector extends CommonObject dol_syslog("EmailCollector::doCollectOneCollector start", LOG_DEBUG); - $langs->loadLangs(array("project", "companies", "errors")); + $langs->loadLangs(array("project", "companies", "mails", "errors")); $error = 0; $this->output = ''; @@ -942,20 +942,122 @@ class EmailCollector extends CommonObject //$message = imap_body($connection, $imapemail, 0); $overview = imap_fetch_overview($connection, $imapemail, 0); $structure = imap_fetchstructure($connection, $imapemail, 0); + $partplain = $parthtml = -1; // Loop to get part html and plain - foreach($structure->parts as $key => $part) - { - if ($part->subtype == 'HTML') $parthtml=$key; - if ($part->subtype == 'PLAIN') $partplain=$key; + /* + 0 multipart/mixed + 1 multipart/alternative + 1.1 text/plain + 1.2 text/html + 2 message/rfc822 + 2 multipart/mixed + 2.1 multipart/alternative + 2.1.1 text/plain + 2.1.2 text/html + 2.2 message/rfc822 + 2.2 multipart/alternative + 2.2.1 text/plain + 2.2.2 text/html + */ + /** + * create_part_array + * + * @param Object $structure Structure + * @param string $prefix prefix + * @return string[]|unknown[] array + */ + function create_part_array($structure, $prefix="") { + //print_r($structure); + if (sizeof($structure->parts) > 0) { // There some sub parts + foreach ($structure->parts as $count => $part) { + add_part_to_array($part, $prefix.($count+1), $part_array); + } + }else{ // Email does not have a seperate mime attachment for text + $part_array[] = array('part_number' => $prefix.'1', 'part_object' => $obj); + } + return $part_array; + } + /** + * Sub function for create_part_array(). Only called by create_part_array() and itself. + * + * @param Object $obj Structure + * @param string $partno Part no + * @param array $part_array array + */ + function add_part_to_array($obj, $partno, & $part_array) { + $part_array[] = array('part_number' => $partno, 'part_object' => $obj); + if ($obj->type == 2) { // Check to see if the part is an attached email message, as in the RFC-822 type + //print_r($obj); + if(array_key_exists('parts',$obj)) { // Check to see if the email has parts + foreach ($obj->parts as $count => $part) { + // Iterate here again to compensate for the broken way that imap_fetchbody() handles attachments + if (sizeof($part->parts) > 0) { + foreach ($part->parts as $count2 => $part2) { + add_part_to_array($part2, $partno.".".($count2+1), $part_array); + } + }else{ // Attached email does not have a seperate mime attachment for text + $part_array[] = array('part_number' => $partno.'.'.($count+1), 'part_object' => $obj); + } + } + }else{ // Not sure if this is possible + $part_array[] = array('part_number' => $partno.'.1', 'part_object' => $obj); + } + }else{ // If there are more sub-parts, expand them out. + if(array_key_exists('parts',$obj)) { + foreach ($obj->parts as $count => $p) { + add_part_to_array($p, $partno.".".($count+1), $part_array); + } + } + } } - $messagetext = imap_fetchbody($connection, $imapemail, ($parthtml >= 0 ? $parthtml : ($partplain >= 0 ? $partplain : 0))); + $result = create_part_array($structure, ''); + //var_dump($result);exit; + foreach($result as $key => $part) + { + if ($part['part_object']->subtype == 'HTML') $parthtml=$part['part_number']; + if ($part['part_object']->subtype == 'PLAIN') $partplain=$part['part_number']; + } + + /* OLD CODE to get parthtml and partplain + if (sizeof($structure->parts) > 0) { // There some sub parts + foreach($structure->parts as $key => $part) + { + if ($part->subtype == 'HTML') $parthtml=($key+1); // For example: $parthtml = 1 or 2 + if ($part->subtype == 'PLAIN') $partplain=($key+1); + if ($part->subtype == 'ALTERNATIVE') + { + if (sizeof($part->parts) > 0) + { + foreach($part->parts as $key2 => $part2) + { + if ($part2->subtype == 'HTML') $parthtml=($key+1).'.'.($key2+1); // For example: $parthtml = 1.1 or 1.2 + if ($part2->subtype == 'PLAIN') $partplain=($key+1).'.'.($key2+1); + } + } + else + { + $partplain=($key+1).'.1'; + } + } + } + } + else + { + $partplain=1; + }*/ + + //var_dump($structure); + //var_dump($parthtml);var_dump($partplain); + + $messagetext = imap_fetchbody($connection, $imapemail, ($parthtml != '-1' ? $parthtml : ($partplain != '-1' ? $partplain : 0)), FT_PEEK); //var_dump($overview); //var_dump($header); //var_dump($message); - //var_dump($messagetext); + //var_dump($structure->parts[0]->parts); + //var_dump($messagetext);exit; $fromstring=$overview[0]->from; $sender=$overview[0]->sender; $to=$overview[0]->to; @@ -969,8 +1071,8 @@ class EmailCollector extends CommonObject $reg=array(); if (preg_match('/^(.*)<(.*)>$/', $fromstring, $reg)) { - $from=$reg[1]; - $fromtext=$reg[0]; + $from=$reg[2]; + $fromtext=$reg[1]; } else { @@ -987,7 +1089,7 @@ class EmailCollector extends CommonObject $reg=array(); if (! empty($headers['References']) && preg_match('/dolibarr-([a-z]+)([0-9]+)@'.preg_quote($host,'/').'/', $headers['References'], $reg)) { - $trackid = $reg[0].$reg[1]; + $trackid = $reg[1].$reg[2]; $objectid = 0; $objectemail = null; @@ -1129,10 +1231,11 @@ class EmailCollector extends CommonObject $sourcefield=''; $regexstring=''; $regforregex=array(); + if (preg_match('/^REGEX:([a-zA-Z0-9]+):(.*)$/', $valueforproperty, $regforregex)) { - $sourcefield=$regforregex[0]; - $regexstring=$regforregex[1]; + $sourcefield=$regforregex[1]; + $regexstring=$regforregex[2]; } if (! empty($sourcefield) && ! empty($regexstring)) @@ -1141,19 +1244,20 @@ class EmailCollector extends CommonObject elseif (strtolower($sourcefield) == 'subject') $sourcestring=$subject; $regforval=array(); - if (preg_match('/'.preg_quote($regexstring, '/').'/', $sourcestring, $regforval)) + if (preg_match('/'.$regexstring.'/', $sourcestring, $regforval)) // Do not use preg_quote here, string is already a regex syntax, for example string is 'Name:\s([^\s]*)' { // Overwrite param $tmpproperty - $nametouseforthirdparty = $regforval[0]; + $nametouseforthirdparty = $regforval[1]; } else { // Nothing can be done for this param } + //var_dump($sourcestring); var_dump($regexstring);var_dump($nametouseforthirdparty);exit; } elseif (preg_match('/^VALUE:(.*)$/', $valueforproperty, $reg)) { - $nametouseforthirdparty = $reg[0]; + $nametouseforthirdparty = $reg[1]; } else { @@ -1178,6 +1282,8 @@ class EmailCollector extends CommonObject { if ($operation['type'] == 'loadandcreatethirdparty') { + dol_syslog("Third party with name ".$nametouseforthirdparty." was not found. We try to create it."); + // Create thirdparty $thirdpartystatic->name = $nametouseforthirdparty; @@ -1199,6 +1305,10 @@ class EmailCollector extends CommonObject } } } + else + { + dol_syslog("Third party with name ".$nametouseforthirdparty." was not found"); + } } } } @@ -1213,7 +1323,7 @@ class EmailCollector extends CommonObject $actioncomm->type_code = 'AC_OTH_AUTO'; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) $actioncomm->code = 'AC_'.$actioncode; - $actioncomm->label = $langs->trans("EmailReceived").' - '.$langs->trans("From").' '.$from; + $actioncomm->label = $langs->trans("ActionAC_EMAIL_IN").' - '.$langs->trans("MailFrom").' '.$from; $actioncomm->note = $messagetext; $actioncomm->fk_project = $projectstatic->id; $actioncomm->datep = $date; @@ -1233,12 +1343,14 @@ class EmailCollector extends CommonObject $actioncomm->email_subject = $subject; $actioncomm->errors_to = ''; - $actioncomm->fk_element = $fk_element_id; - $actioncomm->elementtype = $fk_element_type; + if (! in_array($fk_element_type, array('societe','contact','project','user'))) + { + $actioncomm->fk_element = $fk_element_id; + $actioncomm->elementtype = $fk_element_type; + } //$actioncomm->extraparams = $extraparams; - // Overwrite values with values extracted from source email $errorforthisaction = $this->overwritePropertiesOfObject($actioncommn, $operation['actionparam'], $messagetext, $subject); @@ -1263,7 +1375,7 @@ class EmailCollector extends CommonObject $projecttocreate = new Project($this->db); if ($thirdpartystatic->id > 0) { - $projecttocreate->fk_soc = $thirdpartystatic->id; + $projecttocreate->socid = $thirdpartystatic->id; if ($thirdpartyfoundby) $note_private .= ' - Third party found from '.$thirdpartyfoundby; } if ($contactstatic->id > 0) diff --git a/htdocs/emailcollector/class/emailcollectoraction.class.php b/htdocs/emailcollector/class/emailcollectoraction.class.php index 8764a90251d..a1d8940d3f6 100644 --- a/htdocs/emailcollector/class/emailcollectoraction.class.php +++ b/htdocs/emailcollector/class/emailcollectoraction.class.php @@ -105,6 +105,7 @@ class EmailCollectorAction extends CommonObject public $tms; public $fk_user_creat; public $fk_user_modif; + public $position; public $import_key; public $status; // END MODULEBUILDER PROPERTIES diff --git a/htdocs/langs/en_US/commercial.lang b/htdocs/langs/en_US/commercial.lang index 0a0deb99a1f..96b8abbb937 100644 --- a/htdocs/langs/en_US/commercial.lang +++ b/htdocs/langs/en_US/commercial.lang @@ -52,6 +52,7 @@ ActionAC_TEL=Phone call ActionAC_FAX=Send fax ActionAC_PROP=Send proposal by mail ActionAC_EMAIL=Send Email +ActionAC_EMAIL_IN=Reception of Email ActionAC_RDV=Meetings ActionAC_INT=Intervention on site ActionAC_FAC=Send customer invoice by mail