diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index c2dbdd46ed6..7b1c81af59c 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -670,7 +670,7 @@ if ($action == 'create') } // Title - print 'global->AGENDA_USE_EVENT_TYPE)?' class="fieldrequired titlefieldcreate"':'').'>'.$langs->trans("Title").''; + print 'global->AGENDA_USE_EVENT_TYPE)?' class="fieldrequired titlefieldcreate"':'').'>'.$langs->trans("Label").''; // Full day print ''.$langs->trans("EventOnFullDay").''; diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 84e75e06cbd..6dd3cbb4f84 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -860,9 +860,10 @@ class ActionComm extends CommonObject * @param string $filter Other filter * @param string $sortfield Sort on this field * @param string $sortorder ASC or DESC + * @param string $limit Limit number of answers * @return array or string Error string if KO, array with actions if OK */ - static function getActions($db, $socid=0, $fk_element=0, $elementtype='', $filter='', $sortfield='', $sortorder='') + static function getActions($db, $socid=0, $fk_element=0, $elementtype='', $filter='', $sortfield='datep', $sortorder='DESC', $limit=0) { global $conf, $langs; @@ -879,6 +880,7 @@ class ActionComm extends CommonObject } if (! empty($filter)) $sql.= $filter; if ($sortorder && $sortfield) $sql.=$db->order($sortfield, $sortorder); + if ($limit) $sql.=$db->plimit($limit); dol_syslog(get_class()."::getActions", LOG_DEBUG); $resql=$db->query($sql); diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index 7b312ea784a..785ada1429c 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -155,16 +155,18 @@ class FormActions * @param int $socid socid of user * @param int $forceshowtitle Show title even if there is no actions to show * @param string $morecss More css on table + * @param int $max Max number of record + * @param string $moreparambacktopage More param for the backtopage * @return int <0 if KO, >=0 if OK */ - function showactions($object,$typeelement,$socid=0,$forceshowtitle=0,$morecss='listactions') + function showactions($object, $typeelement, $socid=0, $forceshowtitle=0, $morecss='listactions', $max=0, $moreparambacktopage='') { global $langs,$conf,$user; global $bc; require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; - $listofactions=ActionComm::getActions($this->db, $socid, $object->id, $typeelement); + $listofactions=ActionComm::getActions($this->db, $socid, $object->id, $typeelement, '', '', '', ($max?($max+1):0)); if (! is_array($listofactions)) dol_print_error($this->db,'FailedToGetActions'); $num = count($listofactions); @@ -177,12 +179,15 @@ class FormActions elseif ($typeelement == 'supplier_proposal') $title=$langs->trans('ActionsOnSupplierProposal'); elseif ($typeelement == 'order') $title=$langs->trans('ActionsOnOrder'); elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order') $title=$langs->trans('ActionsOnOrder'); - elseif ($typeelement == 'project') $title=$langs->trans('ActionsOnProject'); elseif ($typeelement == 'shipping') $title=$langs->trans('ActionsOnShipping'); elseif ($typeelement == 'fichinter') $title=$langs->trans('ActionsOnFicheInter'); - else $title=$langs->trans("Actions"); + elseif ($typeelement == 'project') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); + elseif ($typeelement == 'task') $title=$langs->trans('LatestLinkedEvents', $max?$max:''); + else $title=$langs->trans("Actions"); - $buttontoaddnewevent = ''; + $urlbacktopage=$_SERVER['PHP_SELF'].'?id='.$object->id.($moreparambacktopage?'&'.$moreparambacktopage:''); + + $buttontoaddnewevent = ''; $buttontoaddnewevent.= $langs->trans("AddEvent"); $buttontoaddnewevent.= ''; print load_fiche_titre($title, $buttontoaddnewevent, ''); @@ -197,7 +202,7 @@ class FormActions print_liste_field_titre('Ref', $_SERVER["PHP_SELF"], '', $page, $param, ''); print_liste_field_titre('Action', $_SERVER["PHP_SELF"], '', $page, $param, ''); print_liste_field_titre('Type', $_SERVER["PHP_SELF"], '', $page, $param, ''); - print_liste_field_titre('Date', $_SERVER["PHP_SELF"], '', $page, $param, ''); + print_liste_field_titre('Date', $_SERVER["PHP_SELF"], '', $page, $param, 'align="center"'); print_liste_field_titre('By', $_SERVER["PHP_SELF"], '', $page, $param, ''); print_liste_field_titre('', $_SERVER["PHP_SELF"], '', $page, $param, 'align="right"'); print ''; @@ -205,8 +210,11 @@ class FormActions $userstatic = new User($this->db); + $cursorevent = 0; foreach($listofactions as $action) { + if ($max && $cursorevent >= $max) break; + $ref=$action->getNomUrl(1,-1); $label=$action->getNomUrl(0,38); @@ -226,7 +234,7 @@ class FormActions } print $action->type; print ''; - print ''.dol_print_date($action->datep,'dayhour'); + print ''.dol_print_date($action->datep,'dayhour'); if ($action->datef) { $tmpa=dol_getdate($action->datep); @@ -254,7 +262,15 @@ class FormActions } print ''; print ''; + + $cursorevent++; } + + if ($max && $num > $max) + { + print ''.$langs->trans("More").'...'; + } + print ''; print ''; } diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 181e8a7fe11..54bf70981b7 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -1780,6 +1780,11 @@ function dolGetElementUrl($objectid,$objecttype,$withpicto=0,$option='') $module='ficheinter'; $subelement='fichinter'; } + if ($objecttype == 'task') { + $classpath = 'projet/class'; + $module='projet'; + $subelement='task'; + } //print "objecttype=".$objecttype." module=".$module." subelement=".$subelement; @@ -2212,3 +2217,4 @@ function getModuleDirForApiClass($module) return $moduledirforclass; } + diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 751a5fa1361..4e09fef4d43 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -747,6 +747,9 @@ class InterfaceActionsAuto extends DolibarrTriggers // Set societeforaction. if ($object->socid > 0) $societeforaction->fetch($object->socid); + $projectid = isset($object->fk_project)?$object->fk_project:0; + if ($object->element == 'project') $projectid = $object->id; + // Insertion action require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; $actioncomm = new ActionComm($this->db); @@ -754,7 +757,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $actioncomm->code = 'AC_'.$action; $actioncomm->label = $object->actionmsg2; $actioncomm->note = $object->actionmsg; // TODO Replace with $actioncomm->email_msgid ? $object->email_content : $object->actionmsg - $actioncomm->fk_project = isset($object->fk_project)?$object->fk_project:0; + $actioncomm->fk_project = $projectid; $actioncomm->datep = $now; $actioncomm->datef = $now; $actioncomm->durationp = 0; diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index a314f59b6b5..02f3f80982e 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -406,6 +406,7 @@ ActionRunningNotStarted=To start ActionRunningShort=In progress ActionDoneShort=Finished ActionUncomplete=Uncomplete +LatestLinkedEvents=Latest %s linked events CompanyFoundation=Company/Organisation ContactsForCompany=Contacts for this third party ContactsAddressesForCompany=Contacts/addresses for this third party diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index b8528e9863c..849ea5cd47d 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -1198,6 +1198,10 @@ elseif ($object->id > 0) print '
'; + // 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, 1, '', 10); print '
'; } diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index a04a4573aea..1b43940029f 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -588,6 +588,11 @@ if ($id > 0 || ! empty($ref)) print '
'; + // List of actions on element + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; + $formactions = new FormActions($db); + $somethingshown = $formactions->showactions($object, 'task', $socid, 1, '', 10, 'withproject='.$withproject); + print '
'; } }