diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 60b3083d0f7..f4c610a0613 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -852,12 +852,13 @@ if ($id > 0) { $result1=$object->fetch($id); $result2=$object->fetch_thirdparty(); + $result2=$object->fetch_projet(); $result3=$object->fetch_contact(); $result4=$object->fetch_userassigned(); $result5=$object->fetch_optionals($id,$extralabels); + + if ($listUserAssignedUpdated || $donotclearsession) { - if($listUserAssignedUpdated || $donotclearsession) { - $datep=dol_mktime($fulldayevent?'00':$aphour, $fulldayevent?'00':$apmin, 0, $_POST["apmonth"], $_POST["apday"], $_POST["apyear"]); $datef=dol_mktime($fulldayevent?'23':$p2hour, $fulldayevent?'59':$p2min, $fulldayevent?'59':'0', $_POST["p2month"], $_POST["p2day"], $_POST["p2year"]); @@ -1100,8 +1101,10 @@ if ($id > 0) print ''.$langs->trans("ActionOnCompany").''; print ''; print '
'; - $events=array(); + $events=array(); // 'method'=parameter action of url, 'url'=url to call that return new list of contacts $events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php?showempty=1',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); + // TODO Refresh also list of project if $conf->global->PROJECT_ALLOW_TO_LINK_FROM_OTHER_COMPANY not defined with list linked to socid ? + // FIXME If we change company, we may get a project that does not match print $form->select_company($object->socid, 'socid', '', 'SelectThirdParty', 1, 0, $events, 0); print '
'; print ''; @@ -1122,8 +1125,8 @@ if ($id > 0) $langs->load("projects"); - print ''.$langs->trans("Project").''; - $numprojet=$formproject->select_projects($object->socid, $object->fk_project, 'projectid'); + print ''.$langs->trans("Project").''; + $numprojet=$formproject->select_projects(($object->socid > 0 ? $object->socid : -1), $object->fk_project, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0); if ($numprojet==0) { print '   '.$langs->trans("AddProject").''; @@ -1132,7 +1135,7 @@ if ($id > 0) } // Priority - print ''.$langs->trans("Priority").''; + print ''.$langs->trans("Priority").''; print ''; print ''; @@ -1141,11 +1144,11 @@ if ($id > 0) { include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; print ''.$langs->trans("LinkedObject").''; - print ''.dolGetElementUrl($object->fk_element,$object->elementtype,1).''; + print ''.dolGetElementUrl($object->fk_element,$object->elementtype,1).''; } // Description - print ''.$langs->trans("Description").''; + print ''.$langs->trans("Description").''; // Editeur wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $doleditor=new DolEditor('note',$object->note,'',200,'dolibarr_notes','In',true,true,$conf->fckeditor->enabled,ROWS_5,90); @@ -1153,7 +1156,7 @@ if ($id > 0) print ''; // Other attributes - $parameters=array('colspan'=>' colspan="3"', 'colspanvalue'=>'3', 'id'=>$object->id); + $parameters=array('id'=>$object->id); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook if (empty($reshook) && ! empty($extrafields->attribute_label)) { diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index b190047bac7..3ab4e7dd898 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1078,7 +1078,7 @@ class ActionComm extends CommonObject else if ($mode == 6) { if ($percent==-1 && ! $hidenastatus) return $langs->trans('StatusNotApplicable').' '.img_picto($langs->trans('StatusNotApplicable'),'statut9'); - else if ($percent==0) return $langs->trans('StatusActionToDo').'0% '.img_picto($langs->trans('StatusActionToDo'),'statut1'); + else if ($percent==0) return $langs->trans('StatusActionToDo').' (0%) '.img_picto($langs->trans('StatusActionToDo'),'statut1'); else if ($percent > 0 && $percent < 100) return $langs->trans('StatusActionInProcess').' ('.$percent.'%) '.img_picto($langs->trans('StatusActionInProcess').' - '.$percent.'%','statut3'); else if ($percent >= 100) return $langs->trans('StatusActionDone').' (100%) '.img_picto($langs->trans('StatusActionDone'),'statut6'); } diff --git a/htdocs/comm/action/listactions.php b/htdocs/comm/action/listactions.php index b927244821e..9be7461f395 100644 --- a/htdocs/comm/action/listactions.php +++ b/htdocs/comm/action/listactions.php @@ -309,7 +309,8 @@ if ($resql) $i = 0; print ''; print ''; - print_liste_field_titre($langs->trans("Action"),$_SERVER["PHP_SELF"],"a.label",$param,"","",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"a.id",$param,"","",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Title"),$_SERVER["PHP_SELF"],"a.label",$param,"","",$sortfield,$sortorder); if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"c.libelle",$param,"","",$sortfield,$sortorder); print_liste_field_titre($langs->trans("DateStart"),$_SERVER["PHP_SELF"],"a.datep",$param,'','align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("DateEnd"),$_SERVER["PHP_SELF"],"a.datep2",$param,'','align="center"',$sortfield,$sortorder); @@ -322,6 +323,7 @@ if ($resql) print ''; print ''; + print ''; if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) { print ''; @@ -367,15 +369,22 @@ if ($resql) $var=!$var; + $actionstatic->id=$obj->id; + $actionstatic->ref=$obj->id; + $actionstatic->type_code=$obj->type_code; + $actionstatic->type_label=$obj->type_label; + $actionstatic->label=$obj->label; + print ""; // Action (type) print ''; + + // Action (type) + print ''; if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index 7194f1f5da6..ba9aa961002 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -182,14 +182,17 @@ class FormActions print load_fiche_titre($title,'',''); - $total = 0; $var=true; + $page=0; $param=''; $sortfield='a.datep'; + + $total = 0; $var=true; print '
'; - $actionstatic->id=$obj->id; - $actionstatic->type_code=$obj->type_code; - $actionstatic->type_label=$obj->type_label; - $actionstatic->label=$obj->label; - print $actionstatic->getNomUrl(1,36); + print $actionstatic->getNomUrl(1,-1); + print ''; + print $actionstatic->label; print '
'; print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print_liste_field_titre($langs->trans('Ref'), $_SERVER["PHP_SELF"], '', $page, $param, ''); + print_liste_field_titre($langs->trans('Action'), $_SERVER["PHP_SELF"], '', $page, $param, ''); + print_liste_field_titre($langs->trans('Type'), $_SERVER["PHP_SELF"], '', $page, $param, ''); + print_liste_field_titre($langs->trans('Date'), $_SERVER["PHP_SELF"], '', $page, $param, ''); + print_liste_field_titre($langs->trans('By'), $_SERVER["PHP_SELF"], '', $page, $param, ''); + print_liste_field_titre('', $_SERVER["PHP_SELF"], '', $page, $param, 'align="right"'); print ''; print "\n"; @@ -199,11 +202,12 @@ class FormActions { $ref=$action->getNomUrl(1,-1); $label=$action->getNomUrl(0,38); - + $var=!$var; print ''; print ''; print ''; + print ''; print '
'.$langs->trans('Ref').''.$langs->trans('Action').''.$langs->trans('Date').''.$langs->trans('By').''.$langs->trans('Status').'
'.$ref.''.$label.''.$action->type.''.dol_print_date($action->datep,'dayhour'); if ($action->datef) { @@ -243,15 +247,16 @@ class FormActions /** * Output html select list of type of event * - * @param string $selected Type pre-selected (can be 'manual', 'auto' or 'AC_xxx') - * @param string $htmlname Name of select field - * @param string $excludetype A type to exclude ('systemauto', 'system', '') - * @param integer $onlyautoornot 1=Group all type AC_XXX into 1 line AC_MANUAL. 0=Keep details of type - * @param int $hideinfohelp 1=Do not show info help, 0=Show, -1=Show+Add info to tell how to set default value - * @param int $multiselect 1=Allow multiselect of action type - * @return void + * @param array|string $selected Type pre-selected (can be 'manual', 'auto' or 'AC_xxx'). Can be an array too. + * @param string $htmlname Name of select field + * @param string $excludetype A type to exclude ('systemauto', 'system', '') + * @param integer $onlyautoornot 1=Group all type AC_XXX into 1 line AC_MANUAL. 0=Keep details of type + * @param int $hideinfohelp 1=Do not show info help, 0=Show, -1=Show+Add info to tell how to set default value + * @param int $multiselect 1=Allow multiselect of action type + * @param int $nooutput 1=No output + * @return string */ - function select_type_actions($selected='',$htmlname='actioncode',$excludetype='',$onlyautoornot=0, $hideinfohelp=0, $multiselect=0) + function select_type_actions($selected='',$htmlname='actioncode',$excludetype='',$onlyautoornot=0, $hideinfohelp=0, $multiselect=0, $nooutput=0) { global $langs,$user,$form,$conf; @@ -271,20 +276,26 @@ class FormActions if (! empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) unset($arraylist['AC_OTH_AUTO']); + $out=''; + if (! empty($multiselect)) { - if(!is_array($selected) && !empty($selected)) $selected = explode(',', $selected); - print $form->multiselectarray($htmlname, $arraylist, $selected, 0, 0, 'centpercent', 0, 0); + if (!is_array($selected) && !empty($selected)) $selected = explode(',', $selected); + $out.=$form->multiselectarray($htmlname, $arraylist, $selected, 0, 0, 'centpercent', 0, 0); } else { - print $form->selectarray($htmlname, $arraylist, $selected); + $out.=$form->selectarray($htmlname, $arraylist, $selected); } if ($user->admin && empty($onlyautoornot) && $hideinfohelp <= 0) { - print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup").($hideinfohelp == -1 ? ". ".$langs->trans("YouCanSetDefaultValueInModuleSetup") : ''),1); + $out.=info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup").($hideinfohelp == -1 ? ". ".$langs->trans("YouCanSetDefaultValueInModuleSetup") : ''),1); } + + if ($nooutput) return $out; + else print $out; + return ''; } } diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index f1ec7edae73..742bc1a0231 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -44,7 +44,7 @@ class FormProjets } /** - * Output a combo list with projects qualified for a third party + * Output a combo list with projects qualified for a third party / user * * @param int $socid Id third party (-1=all, 0=only projects not linked to a third party, id=projects not linked or linked to third party id) * @param int $selected Id project preselected @@ -58,9 +58,10 @@ class FormProjets * @param int $mode 0 for HTML mode and 1 for JSON mode * @param string $filterkey Key to filter * @param int $nooutput No print output. Return it only. + * @param int $forceaddid Force to add project id in list, event if not qualified * @return string Return html content */ - function select_projects($socid=-1, $selected='', $htmlname='projectid', $maxlength=16, $option_only=0, $show_empty=1, $discard_closed=0, $forcefocus=0, $disabled=0, $mode = 0, $filterkey = '', $nooutput=0) + function select_projects($socid=-1, $selected='', $htmlname='projectid', $maxlength=16, $option_only=0, $show_empty=1, $discard_closed=0, $forcefocus=0, $disabled=0, $mode = 0, $filterkey = '', $nooutput=0, $forceaddid=0) { global $langs,$conf,$form; @@ -122,9 +123,10 @@ class FormProjets * @param int $mode 0 for HTML mode and 1 for array return (to be used by json_encode for example) * @param string $filterkey Key to filter * @param int $nooutput No print output. Return it only. + * @param int $forceaddid Force to add project id in list, event if not qualified * @return int Nb of project if OK, <0 if KO */ - function select_projects_list($socid=-1, $selected='', $htmlname='projectid', $maxlength=24, $option_only=0, $show_empty=1, $discard_closed=0, $forcefocus=0, $disabled=0, $mode=0, $filterkey = '', $nooutput=0) + function select_projects_list($socid=-1, $selected='', $htmlname='projectid', $maxlength=24, $option_only=0, $show_empty=1, $discard_closed=0, $forcefocus=0, $disabled=0, $mode=0, $filterkey = '', $nooutput=0, $forceaddid=0) { global $user,$conf,$langs; @@ -143,6 +145,7 @@ class FormProjets $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1); } + // Search all projects $sql = 'SELECT p.rowid, p.ref, p.title, p.fk_soc, p.fk_statut, p.public'; $sql.= ' FROM '.MAIN_DB_PREFIX .'projet as p'; diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 8cec7459bd5..b4205a5d997 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -930,177 +930,17 @@ function show_addresses($conf,$langs,$db,$object,$backtopage='') * @param Conf $conf Object conf * @param Translate $langs Object langs * @param DoliDB $db Object db - * @param Adherent|Societe $object Object third party or member + * @param Adherent|Societe $filterobj 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,$actioncode='') +function show_actions_todo($conf,$langs,$db,$filterobj,$objcon='',$noprint=0,$actioncode='') { global $bc,$user,$conf; - // Check parameters - if (! is_object($object)) dol_print_error('','BadParameter'); - - $now=dol_now('tzuser'); - $out=''; - - if (! empty($conf->agenda->enabled)) - { - require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; - $actionstatic=new ActionComm($db); - $userstatic=new User($db); - $contactstatic = new Contact($db); - - $out.="\n"; - $out.=''; - $out.=''; - if($conf->global->AGENDA_USE_EVENT_TYPE) $out.=''; - - if($conf->global->AGENDA_USE_EVENT_TYPE) { - $out.=''; - $out.=''; - $out.=''; - - $sql = "SELECT a.id, a.label,"; - $sql.= " a.datep as dp,"; - $sql.= " a.datep2 as dp2,"; - $sql.= " a.percent,"; - $sql.= " a.fk_user_author, a.fk_contact,"; - $sql.= " a.fk_element, a.elementtype,"; - $sql.= " c.code as acode, c.libelle,"; - $sql.= " u.login, u.rowid"; - if (get_class($object) == 'Societe') $sql.= ", sp.lastname, sp.firstname"; - if (get_class($object) == 'Adherent') $sql.= ", m.lastname, m.firstname"; - $sql.= " FROM ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."actioncomm as a"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action = c.id"; - if (get_class($object) == 'Societe') $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; - if (get_class($object) == 'Adherent') $sql.= ", ".MAIN_DB_PREFIX."adherent as m"; - $sql.= " WHERE u.rowid = a.fk_user_author"; - $sql.= " AND a.entity IN (".getEntity('agenda', 1).")"; - if (get_class($object) == 'Adherent') - { - $sql.= " AND a.fk_element = m.rowid AND a.elementtype = 'member'"; - if (! empty($object->id)) $sql.= " AND a.fk_element = ".$object->id; - } - 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"; - - dol_syslog("company.lib::show_actions_todo", LOG_DEBUG); - $result=$db->query($sql); - if ($result) - { - $i = 0 ; - $num = $db->num_rows($result); - $var=true; - - if ($num) - { - while ($i < $num) - { - $var = !$var; - - $obj = $db->fetch_object($result); - $actionstatic->fetch($obj->id); - $datep=$db->jdate($obj->dp); - $datep2=$db->jdate($obj->dp2); - - $out.=""; - - // Date - $out.='\n"; - - // Picto warning - $out.=''; - - $actionstatic->type_code=$obj->acode; - $transcode=$langs->trans("Action".$obj->acode); - $libelle=($transcode!="Action".$obj->acode?$transcode:$obj->libelle); - //$actionstatic->libelle=$libelle; - $actionstatic->libelle=$obj->label; - $actionstatic->id=$obj->id; - //$out.=''; - - // Title of event - //$out.=''; - $out.=''; - - if($conf->global->AGENDA_USE_EVENT_TYPE) { - $out.= ''; - } - // Contact pour cette action - if (empty($objcon->id) && $obj->fk_contact > 0) - { - $contactstatic->lastname=$obj->lastname; - $contactstatic->firstname=$obj->firstname; - $contactstatic->id=$obj->fk_contact; - $out.=''; - } - else - { - $out.=''; - } - - $out.=''; - - // Statut - $out.=''; - - $out.="\n"; - $i++; - } - } - else - { - // Aucun action a faire - - } - $db->free($result); - } - else - { - dol_print_error($db); - } - $out.="
'; - else $out.=''; - if (get_class($object) == 'Societe') $out.=''; - $out.=$langs->trans("ActionsToDoShort"); - if (get_class($object) == 'Societe') $out.=''; - $out.=''; - $out.=$langs->trans("Type"); - $out.=''; - } else { - $out.=''; - } - - $out.='
'; - $out.=dol_print_date($datep,'dayhour'); - if ($datep2 && $datep2 != $datep) - { - $tmpa=dol_getdate($datep,true); - $tmpb=dol_getdate($datep2,true); - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $out.='-'.dol_print_date($datep2,'hour'); - else $out.='-'.dol_print_date($datep2,'dayhour'); - } - $out.="'; - if ($obj->percent >= 0 && $datep && $datep < ($now - ($conf->global->MAIN_DELAY_ACTIONS_TODO *60*60*24)) ) $out.=' '.img_warning($langs->trans("Late")); - else $out.=' '; - $out.=''.$actionstatic->getNomUrl(1,16).''.dol_trunc($obj->label,40).''.$actionstatic->getNomUrl(1,120).''; - $out.=$actionstatic->type; - $out.=''.$contactstatic->getNomUrl(1,'',10).' '; - //$userstatic->id=$obj->fk_user_author; - //$userstatic->login=$obj->login; - //$out.=$userstatic->getLoginUrl(1); - $userstatic->fetch($obj->fk_user_author); - $out.=$userstatic->getNomUrl(1); - $out.=''.$actionstatic->LibStatut($obj->percent,3).'
\n"; - - $out.="
\n"; - } + $out = show_actions_done($conf,$langs,$db,$filterobj,$objcon,1,$actioncode, 'todo'); if ($noprint) return $out; else print $out; @@ -1112,19 +952,21 @@ function show_actions_todo($conf,$langs,$db,$object,$objcon='',$noprint=0,$actio * @param Conf $conf Object conf * @param Translate $langs Object langs * @param DoliDB $db Object db - * @param Adherent|Societe $object Object third party or member + * @param Adherent|Societe $filterobj Object third party or member * @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. * @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, $actioncode='') +function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=0, $actioncode='', $donetodo='done') { global $bc,$user,$conf; + global $form; // Check parameters - if (! is_object($object)) dol_print_error('','BadParameter'); + if (! is_object($filterobj)) dol_print_error('','BadParameter'); $out=''; $histo=array(); @@ -1142,20 +984,22 @@ function show_actions_done($conf, $langs, $db, $object, $objcon='', $noprint=0, $sql.= " a.fk_user_author, a.fk_contact,"; $sql.= " c.code as acode, c.libelle,"; $sql.= " u.login, u.rowid as user_id"; - if (get_class($object) == 'Societe') $sql.= ", sp.lastname, sp.firstname"; - if (get_class($object) == 'Adherent') $sql.= ", m.lastname, m.firstname"; + if (get_class($filterobj) == 'Societe') $sql.= ", sp.lastname, sp.firstname"; + if (get_class($filterobj) == 'Adherent') $sql.= ", m.lastname, m.firstname"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."actioncomm as a"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action = c.id"; - if (get_class($object) == 'Societe') $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; - if (get_class($object) == 'Adherent') $sql.= ", ".MAIN_DB_PREFIX."adherent as m"; + if (get_class($filterobj) == 'Societe') $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; + if (get_class($filterobj) == 'Adherent') $sql.= ", ".MAIN_DB_PREFIX."adherent as m"; $sql.= " WHERE u.rowid = a.fk_user_author"; $sql.= " AND a.entity IN (".getEntity('agenda', 1).")"; - if (get_class($object) == 'Societe' && $object->id) $sql.= " AND a.fk_soc = ".$object->id; - 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 (get_class($filterobj) == 'Societe' && $filterobj->id) $sql.= " AND a.fk_soc = ".$filterobj->id; + if (get_class($filterobj) == 'Project' && $filterobj->id) $sql.= " AND a.fk_project = ".$filterobj->id; + if (get_class($filterobj) == 'Adherent') $sql.= " AND a.fk_element = m.rowid AND a.elementtype = 'member'"; + if (get_class($filterobj) == 'Adherent' && $filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->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)."'))"; + 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)."'))"; $sql.= " ORDER BY a.datep DESC, a.id DESC"; dol_syslog("company.lib::show_actions_done", LOG_DEBUG); @@ -1168,23 +1012,31 @@ function show_actions_done($conf, $langs, $db, $object, $objcon='', $noprint=0, while ($i < $num) { $obj = $db->fetch_object($resql); + + //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)."'))"; + $tododone=''; + if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && $obj->datep > $now)) $tododone='todo'; + $histo[$numaction]=array( - 'type'=>'action', - 'id'=>$obj->id, - 'datestart'=>$db->jdate($obj->dp), - 'dateend'=>$db->jdate($obj->dp2), - 'note'=>$obj->label, - 'percent'=>$obj->percent, - 'acode'=>$obj->acode, - 'libelle'=>$obj->libelle, - 'userid'=>$obj->user_id, - 'login'=>$obj->login, - 'contact_id'=>$obj->fk_contact, - 'lastname'=>$obj->lastname, - 'firstname'=>$obj->firstname, - 'fk_element'=>$obj->fk_element, - 'elementtype'=>$obj->elementtype + 'type'=>'action', + 'tododone'=>$tododone, + 'id'=>$obj->id, + 'datestart'=>$db->jdate($obj->dp), + 'dateend'=>$db->jdate($obj->dp2), + 'note'=>$obj->label, + 'percent'=>$obj->percent, + 'acode'=>$obj->acode, + 'libelle'=>$obj->libelle, + 'userid'=>$obj->user_id, + 'login'=>$obj->login, + 'contact_id'=>$obj->fk_contact, + 'lastname'=>$obj->lastname, + 'firstname'=>$obj->firstname, + 'fk_element'=>$obj->fk_element, + 'elementtype'=>$obj->elementtype ); + $numaction++; $i++; } @@ -1199,7 +1051,7 @@ function show_actions_done($conf, $langs, $db, $object, $objcon='', $noprint=0, { $langs->load("mails"); - // Recherche histo sur mailing + // Add also event from emailings. TODO This should be replaced by an automatic event $sql = "SELECT m.rowid as id, mc.date_envoi as da, m.titre as note, '100' as percentage,"; $sql.= " 'AC_EMAILING' as acode,"; $sql.= " u.rowid as user_id, u.login"; // User that valid action @@ -1222,6 +1074,7 @@ function show_actions_done($conf, $langs, $db, $object, $objcon='', $noprint=0, $obj = $db->fetch_object($resql); $histo[$numaction]=array( 'type'=>'mailing', + 'tododone'=>'done', 'id'=>$obj->id, 'datestart'=>$db->jdate($obj->da), 'dateend'=>$db->jdate($obj->da), @@ -1258,49 +1111,79 @@ function show_actions_done($conf, $langs, $db, $object, $objcon='', $noprint=0, $orderstatic=new Commande($db); $facturestatic=new Facture($db); + $out.='
'; + $out.=''; + if (get_class($filterobj) == 'Societe') $out.=''; + $out.="\n"; $out.=''; $out.=''; - if($conf->global->AGENDA_USE_EVENT_TYPE) $out.=''; - - if($conf->global->AGENDA_USE_EVENT_TYPE) { - $out.=''; - $out.=''; } - - $out.=''; - $out.=''; + $out.=''; + $out.=''; + $out.=''; + $out.=''; + $out.=''; + $out.=''; + $out.=''; + $out.=''; + $out.=''; + $out.=''; + + $out.=''; + if ($donetodo) + { + $out.=''; + } + $out.=''; + $out.=''; + $out.=''; + $out.=''; + $out.=''; + $out.=''; + $out.=''; + $out.=''; + // Action column + $out.=''; + $out.=''; + foreach ($histo as $key=>$value) { $var=!$var; - $out.=""; $actionstatic->fetch($histo[$key]['id']); - // Champ date - $out.='"; + + // done or todo + if ($donetodo) { - $tmpa=dol_getdate($histo[$key]['datestart'],true); - $tmpb=dol_getdate($histo[$key]['dateend'],true); - if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $out.='-'.dol_print_date($histo[$key]['dateend'],'hour'); - else $out.='-'.dol_print_date($histo[$key]['dateend'],'dayhour'); + $out.=''; } - $out.="\n"; - - // Picto - $out.=''; - - // Action + + // Ref + $out.=''; + + // Title $out.=''; + // Date + $out.='\n"; + if($conf->global->AGENDA_USE_EVENT_TYPE) { $out.=''; // Statut - $out.=''; + $out.=''; + // Actions + $out.=''; + $out.="\n"; $i++; } @@ -1405,6 +1303,8 @@ function show_actions_done($conf, $langs, $db, $object, $objcon='', $noprint=0, //$out.="
\n"; } + $out.=''; + if ($noprint) return $out; else print $out; } diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 925dba1fd67..2657e061414 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -111,8 +111,13 @@ function project_prepare_head($object) } $head[$h][0] = DOL_URL_ROOT.'/projet/info.php?id='.$object->id; - $head[$h][1] = $langs->trans("Info"); - $head[$h][2] = 'info'; + $head[$h][1].= $langs->trans("Events"); + if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) + { + $head[$h][1].= '/'; + $head[$h][1].= $langs->trans("Agenda"); + } + $head[$h][2] = 'agenda'; $h++; complete_head_from_modules($conf,$langs,$object,$head,$h,'project','remove'); diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 9fa2db53a25..5eb129f9152 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -1094,13 +1094,6 @@ else print '
'; - if (!empty($object->id)) - { - // List of actions on element - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; - $formactions=new FormActions($db); - $somethingshown=$formactions->showactions($object,'project',$socid); - } print '
'; } diff --git a/htdocs/projet/info.php b/htdocs/projet/info.php index c2e45560f74..6c8593789ca 100644 --- a/htdocs/projet/info.php +++ b/htdocs/projet/info.php @@ -27,16 +27,42 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; -if (!$user->rights->projet->lire) accessforbidden(); - $langs->load("projects"); +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)); +} + // Security check $socid=0; $id = GETPOST("id",'int'); if ($user->societe_id) $socid=$user->societe_id; $result=restrictedArea($user,'projet',$id,''); +if (!$user->rights->projet->lire) accessforbidden(); + + + +/* + * Actions + */ + +$parameters=array('id'=>$socid); +$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +// Purge search criteria +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +{ + $actioncode=''; +} + /* @@ -48,22 +74,70 @@ if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/',$c $help_url="EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; llxHeader("",$title,$help_url); -$projet = new Project($db); -$projet->fetch($id); -$projet->info($id); -$soc = new Societe($db); -$soc->fetch($projet->socid); +$object = new Project($db); +$object->fetch($id); +$object->info($id); -$head = project_prepare_head($projet); +$head = project_prepare_head($object); -dol_fiche_head($head, 'info', $langs->trans("Project"), 0, ($object->public?'projectpub':'project')); +dol_fiche_head($head, 'agenda', $langs->trans("Project"), 0, ($object->public?'projectpub':'project')); print '
'; - else $out.=''; - if (get_class($object) == 'Societe') $out.=''; - $out.=$langs->trans("ActionsDoneShort"); - if (get_class($object) == 'Societe') $out.=''; - $out.=''; - $out.=$langs->trans("Type"); - $out.=''; - } else { - $out.=''; + if ($donetodo) + { + $out.=''; + if (get_class($filterobj) == 'Societe') $out.=''; + $out.=$langs->trans("ActionsToDoShort").' / '.$langs->trans("ActionsDoneShort"); + if (get_class($filterobj) == 'Societe') $out.=''; + $out.='
'.$langs->trans("Ref").''.$langs->trans("Label").''.$langs->trans("Date").''.$langs->trans("Type").''.$langs->trans("By").''.$langs->trans("Status").'
'; + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + $formactions=new FormActions($db); + $out.=$formactions->select_type_actions($actioncode, "actioncode", '', 0, 0, 0, 1); + } + $out.=''; + $searchpitco=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); + $out.=$searchpitco; + $out.='
'; - $out.=dol_print_date($histo[$key]['datestart'],'dayhour'); - if ($histo[$key]['dateend'] && $histo[$key]['dateend'] != $histo[$key]['datestart']) + + $out.="
'; + $out.=' '; + $out.=$actionstatic->getNomUrl(1, -1); + $out.=''; if (isset($histo[$key]['type']) && $histo[$key]['type']=='action') { @@ -1308,9 +1191,9 @@ function show_actions_done($conf, $langs, $db, $object, $objcon='', $noprint=0, $transcode=$langs->trans("Action".$histo[$key]['acode']); $libelle=($transcode!="Action".$histo[$key]['acode']?$transcode:$histo[$key]['libelle']); //$actionstatic->libelle=$libelle; - $actionstatic->libelle=$histo[$key]['note']; + $libelle=$histo[$key]['note']; $actionstatic->id=$histo[$key]['id']; - $out.=$actionstatic->getNomUrl(1,120); + $out.=dol_trunc($libelle,120); } if (isset($histo[$key]['type']) && $histo[$key]['type']=='mailing') { @@ -1321,6 +1204,18 @@ function show_actions_done($conf, $langs, $db, $object, $objcon='', $noprint=0, } $out.=''; + $out.=dol_print_date($histo[$key]['datestart'],'dayhour'); + if ($histo[$key]['dateend'] && $histo[$key]['dateend'] != $histo[$key]['datestart']) + { + $tmpa=dol_getdate($histo[$key]['datestart'],true); + $tmpb=dol_getdate($histo[$key]['dateend'],true); + if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year']) $out.='-'.dol_print_date($histo[$key]['dateend'],'hour'); + else $out.='-'.dol_print_date($histo[$key]['dateend'],'dayhour'); + } + $out.="'; $out.=$actionstatic->type; @@ -1396,8 +1291,11 @@ function show_actions_done($conf, $langs, $db, $object, $objcon='', $noprint=0, $out.=''.$actionstatic->LibStatut($histo[$key]['percent'],3).''.$actionstatic->LibStatut($histo[$key]['percent'],3).'
'; -dol_print_object_info($projet); + +dol_print_object_info($object, 1); + print '
'; +dol_fiche_end(); + + +// Actions buttons + +$out=''; +$permok=$user->rights->agenda->myactions->create; +if ($permok) +{ + $out.='&projectid='.$object->id; +} + + +print '
'; + +if (! empty($conf->agenda->enabled)) +{ + if (! empty($user->rights->agenda->myactions->create) || ! empty($user->rights->agenda->allactions->create)) + { + print ''.$langs->trans("AddAction").''; + } + else + { + print ''.$langs->trans("AddAction").''; + } +} + print '
'; + +if (!empty($object->id)) +{ + print load_fiche_titre($langs->trans("ActionsOnProject"),'',''); + + // List of actions on element + /*include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; + $formactions=new FormActions($db); + $somethingshown=$formactions->showactions($object,'project',0);*/ + + // List of todo actions + //show_actions_todo($conf,$langs,$db,$object,null,0,$actioncode); + + // List of done actions + //show_actions_done($conf,$langs,$db,$object,null,0,$actioncode); + + // List of all actions + show_actions_done($conf,$langs,$db,$object,null,0,$actioncode, ''); +} + + llxFooter(); $db->close(); diff --git a/htdocs/societe/agenda.php b/htdocs/societe/agenda.php index 4a46a5ed934..0f7c3a553b6 100644 --- a/htdocs/societe/agenda.php +++ b/htdocs/societe/agenda.php @@ -34,6 +34,16 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $langs->load("companies"); +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)); +} + // Security check $socid = GETPOST('socid','int'); if ($user->societe_id) $socid=$user->societe_id; @@ -51,6 +61,12 @@ $parameters=array('id'=>$socid); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +// Purge search criteria +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +{ + $actioncode=''; +} + /* @@ -128,10 +144,8 @@ if ($socid) - /* - * Barre d'action - */ - + // Actions buttons + $objthirdparty=$object; $objcon=new stdClass(); @@ -147,6 +161,7 @@ if ($socid) //$out.=""; } + print '
'; if (! empty($conf->agenda->enabled)) @@ -165,39 +180,16 @@ if ($socid) if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) { - - $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,$actioncode); - + //show_actions_todo($conf,$langs,$db,$object,null,0,$actioncode); + // List of done actions - show_actions_done($conf,$langs,$db,$object,null,0,$actioncode); + //show_actions_done($conf,$langs,$db,$object,null,0,$actioncode); + + // List of all actions + show_actions_done($conf,$langs,$db,$object,null,0,$actioncode, ''); } }