mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
New display style for list of events of user
This commit is contained in:
parent
1d00d90872
commit
ae692ccffd
|
|
@ -1722,3 +1722,603 @@ function show_actions_done_user($conf, $langs, $db, $filterobj, $objcon = '', $n
|
|||
print $out;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show html area with actions in messaging format.
|
||||
* Note: Global parameter $param must be defined.
|
||||
*
|
||||
* @param Conf $conf Object conf
|
||||
* @param Translate $langs Object langs
|
||||
* @param DoliDB $db Object db
|
||||
* @param mixed $filterobj Filter on object Adherent|Societe|Project|Product|CommandeFournisseur|Dolresource|Ticket|... to list events linked to an object
|
||||
* @param Contact $objcon Filter on object contact to filter events on a contact
|
||||
* @param int $noprint Return string but does not output it
|
||||
* @param string $actioncode Filter on actioncode
|
||||
* @param string $donetodo Filter on event 'done' or 'todo' or ''=nofilter (all).
|
||||
* @param array $filters Filter on other fields
|
||||
* @param string $sortfield Sort field
|
||||
* @param string $sortorder Sort order
|
||||
* @return string|void Return html part or void if noprint is 1
|
||||
*/
|
||||
function show_actions_messaging_user($conf, $langs, $db, $filterobj, $objcon = '', $noprint = 0, $actioncode = '', $donetodo = 'done', $filters = array(), $sortfield = 'a.datep,a.id', $sortorder = 'DESC')
|
||||
{
|
||||
global $user, $conf;
|
||||
global $form;
|
||||
|
||||
global $param, $massactionbutton;
|
||||
|
||||
dol_include_once('/comm/action/class/actioncomm.class.php');
|
||||
|
||||
// Check parameters
|
||||
if (!is_object($filterobj) && !is_object($objcon)) {
|
||||
dol_print_error('', 'BadParameter');
|
||||
}
|
||||
|
||||
$histo = array();
|
||||
$numaction = 0;
|
||||
$now = dol_now();
|
||||
|
||||
$sortfield_list = explode(',', $sortfield);
|
||||
$sortfield_label_list = array('a.id' => 'id', 'a.datep' => 'dp', 'a.percent' => 'percent');
|
||||
$sortfield_new_list = array();
|
||||
foreach ($sortfield_list as $sortfield_value) {
|
||||
$sortfield_new_list[] = $sortfield_label_list[trim($sortfield_value)];
|
||||
}
|
||||
$sortfield_new = implode(',', $sortfield_new_list);
|
||||
|
||||
if (isModEnabled('agenda')) {
|
||||
// Search histo on actioncomm
|
||||
if (is_object($objcon) && $objcon->id > 0) {
|
||||
$sql = "SELECT DISTINCT a.id, a.label as label,";
|
||||
} else {
|
||||
$sql = "SELECT a.id, a.label as label,";
|
||||
}
|
||||
$sql .= " a.datep as dp,";
|
||||
$sql .= " a.note as message,";
|
||||
$sql .= " a.datep2 as dp2,";
|
||||
$sql .= " a.percent as percent, 'action' as type,";
|
||||
$sql .= " a.fk_element, a.elementtype,";
|
||||
$sql .= " a.email_from as msg_from,";
|
||||
$sql .= " c.code as acode, c.libelle as alabel, c.picto as apicto,";
|
||||
$sql .= " u.rowid as user_id, u.login as user_login, u.photo as user_photo, u.firstname as user_firstname, u.lastname as user_lastname";
|
||||
if (is_object($filterobj) && get_class($filterobj) == 'Societe') {
|
||||
$sql .= ", sp.lastname, sp.firstname";
|
||||
} elseif (is_object($filterobj) && get_class($filterobj) == 'Adherent') {
|
||||
$sql .= ", m.lastname, m.firstname";
|
||||
} elseif (is_object($filterobj) && get_class($filterobj) == 'CommandeFournisseur') {
|
||||
$sql .= ", o.ref";
|
||||
} elseif (is_object($filterobj) && get_class($filterobj) == 'Product') {
|
||||
$sql .= ", o.ref";
|
||||
} elseif (is_object($filterobj) && get_class($filterobj) == 'Ticket') {
|
||||
$sql .= ", o.ref";
|
||||
} elseif (is_object($filterobj) && get_class($filterobj) == 'BOM') {
|
||||
$sql .= ", o.ref";
|
||||
} elseif (is_object($filterobj) && get_class($filterobj) == 'Contrat') {
|
||||
$sql .= ", o.ref";
|
||||
}
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_action";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action = c.id";
|
||||
|
||||
$sql .= " WHERE a.entity IN (".getEntity('agenda').")";
|
||||
$sql .= " AND u.rowid = ". ((int) $filterobj->id);
|
||||
|
||||
// Condition on actioncode
|
||||
if (!empty($actioncode)) {
|
||||
if (!getDolGlobalString('AGENDA_USE_EVENT_TYPE')) {
|
||||
if ($actioncode == 'AC_NON_AUTO') {
|
||||
$sql .= " AND c.type != 'systemauto'";
|
||||
} elseif ($actioncode == 'AC_ALL_AUTO') {
|
||||
$sql .= " AND c.type = 'systemauto'";
|
||||
} else {
|
||||
if ($actioncode == 'AC_OTH') {
|
||||
$sql .= " AND c.type != 'systemauto'";
|
||||
} elseif ($actioncode == 'AC_OTH_AUTO') {
|
||||
$sql .= " AND c.type = 'systemauto'";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($actioncode == 'AC_NON_AUTO') {
|
||||
$sql .= " AND c.type != 'systemauto'";
|
||||
} elseif ($actioncode == 'AC_ALL_AUTO') {
|
||||
$sql .= " AND c.type = 'systemauto'";
|
||||
} else {
|
||||
$sql .= " AND c.code = '".$db->escape($actioncode)."'";
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($donetodo == 'todo') {
|
||||
$sql .= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))";
|
||||
} elseif ($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']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!empty($sql) && !empty($sql2)) {
|
||||
$sql = $sql." UNION ".$sql2;
|
||||
} elseif (empty($sql) && !empty($sql2)) {
|
||||
$sql = $sql2;
|
||||
}
|
||||
|
||||
// TODO Add limit in nb of results
|
||||
if ($sql) { // May not be defined if module Agenda is not enabled and mailing module disabled too
|
||||
$sql .= $db->order($sortfield_new, $sortorder);
|
||||
dol_syslog("function.lib::show_actions_messaging", LOG_DEBUG);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$i = 0;
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
while ($i < $num) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
if ($obj->type == 'action') {
|
||||
$contactaction = new ActionComm($db);
|
||||
$contactaction->id = $obj->id;
|
||||
$result = $contactaction->fetchResources();
|
||||
if ($result < 0) {
|
||||
dol_print_error($db);
|
||||
setEventMessage("actions.lib::show_actions_messaging Error fetch resource", 'errors');
|
||||
}
|
||||
|
||||
//if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))";
|
||||
//elseif ($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->dp > $now)) {
|
||||
$tododone = 'todo';
|
||||
}
|
||||
|
||||
$histo[$numaction] = array(
|
||||
'type'=>$obj->type,
|
||||
'tododone'=>$tododone,
|
||||
'id'=>$obj->id,
|
||||
'datestart'=>$db->jdate($obj->dp),
|
||||
'dateend'=>$db->jdate($obj->dp2),
|
||||
'note'=>$obj->label,
|
||||
'message'=>$obj->message,
|
||||
'percent'=>$obj->percent,
|
||||
|
||||
'userid'=>$obj->user_id,
|
||||
'login'=>$obj->user_login,
|
||||
'userfirstname'=>$obj->user_firstname,
|
||||
'userlastname'=>$obj->user_lastname,
|
||||
'userphoto'=>$obj->user_photo,
|
||||
'msg_from'=>$obj->msg_from,
|
||||
|
||||
'contact_id'=>$obj->fk_contact,
|
||||
'socpeopleassigned' => $contactaction->socpeopleassigned,
|
||||
'lastname' => (empty($obj->lastname) ? '' : $obj->lastname),
|
||||
'firstname' => (empty($obj->firstname) ? '' : $obj->firstname),
|
||||
'fk_element'=>$obj->fk_element,
|
||||
'elementtype'=>$obj->elementtype,
|
||||
// Type of event
|
||||
'acode'=>$obj->acode,
|
||||
'alabel'=>$obj->alabel,
|
||||
'libelle'=>$obj->alabel, // deprecated
|
||||
'apicto'=>$obj->apicto
|
||||
);
|
||||
} else {
|
||||
$histo[$numaction] = array(
|
||||
'type'=>$obj->type,
|
||||
'tododone'=>'done',
|
||||
'id'=>$obj->id,
|
||||
'datestart'=>$db->jdate($obj->dp),
|
||||
'dateend'=>$db->jdate($obj->dp2),
|
||||
'note'=>$obj->label,
|
||||
'message'=>$obj->message,
|
||||
'percent'=>$obj->percent,
|
||||
'acode'=>$obj->acode,
|
||||
|
||||
'userid'=>$obj->user_id,
|
||||
'login'=>$obj->user_login,
|
||||
'userfirstname'=>$obj->user_firstname,
|
||||
'userlastname'=>$obj->user_lastname,
|
||||
'userphoto'=>$obj->user_photo
|
||||
);
|
||||
}
|
||||
|
||||
$numaction++;
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
// Set $out to show events
|
||||
$out = '';
|
||||
|
||||
if (!isModEnabled('agenda')) {
|
||||
$langs->loadLangs(array("admin", "errors"));
|
||||
$out = info_admin($langs->trans("WarningModuleXDisabledSoYouMayMissEventHere", $langs->transnoentitiesnoconv("Module2400Name")), 0, 0, 'warning');
|
||||
}
|
||||
|
||||
if (isModEnabled('agenda') || (isModEnabled('mailing') && !empty($objcon->email))) {
|
||||
$delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
||||
|
||||
$formactions = new FormActions($db);
|
||||
|
||||
$actionstatic = new ActionComm($db);
|
||||
$userstatic = new User($db);
|
||||
$contactstatic = new Contact($db);
|
||||
$userGetNomUrlCache = array();
|
||||
$contactGetNomUrlCache = array();
|
||||
|
||||
$out .= '<div class="filters-container" >';
|
||||
$out .= '<form name="listactionsfilter" class="listactionsfilter" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||
$out .= '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
|
||||
if ($objcon && get_class($objcon) == 'User' &&
|
||||
(is_null($filterobj) || get_class($filterobj) == 'User')) {
|
||||
$out .= '<input type="hidden" name="id" value="'.$objcon->id.'" />';
|
||||
} else {
|
||||
$out .= '<input type="hidden" name="id" value="'.$filterobj->id.'" />';
|
||||
}
|
||||
if ($filterobj && get_class($filterobj) == 'User') {
|
||||
$out .= '<input type="hidden" name="userid" value="'.$filterobj->id.'" />';
|
||||
}
|
||||
|
||||
$out .= "\n";
|
||||
|
||||
$out .= '<div class="div-table-responsive-no-min">';
|
||||
$out .= '<table class="noborder borderbottom centpercent">';
|
||||
|
||||
$out .= '<tr class="liste_titre">';
|
||||
|
||||
// Action column
|
||||
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
|
||||
$out .= '<th class="liste_titre width50 middle">';
|
||||
$searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1);
|
||||
$out .= $searchpicto;
|
||||
$out .= '</th>';
|
||||
}
|
||||
|
||||
$out .= getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', '', $param, '', $sortfield, $sortorder, '')."\n";
|
||||
|
||||
$out .= '<th class="liste_titre"><strong class="hideonsmartphone">'.$langs->trans("Search").' : </strong></th>';
|
||||
if ($donetodo) {
|
||||
$out .= '<th class="liste_titre"></th>';
|
||||
}
|
||||
$out .= '<th class="liste_titre">';
|
||||
$out .= '<span class="fas fa-square inline-block fawidth30" style=" color: #ddd;" title="'.$langs->trans("ActionType").'"></span>';
|
||||
//$out .= img_picto($langs->trans("Type"), 'type');
|
||||
$out .= $formactions->select_type_actions($actioncode, "actioncode", '', !getDolGlobalString('AGENDA_USE_EVENT_TYPE') ? 1 : -1, 0, 0, 1, 'minwidth200imp');
|
||||
$out .= '</th>';
|
||||
$out .= '<th class="liste_titre maxwidth100onsmartphone">';
|
||||
$out .= '<input type="text" class="maxwidth100onsmartphone" name="search_agenda_label" value="'.$filters['search_agenda_label'].'" placeholder="'.$langs->trans("Label").'">';
|
||||
$out .= '</th>';
|
||||
|
||||
// Action column
|
||||
if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
|
||||
$out .= '<th class="liste_titre width50 middle">';
|
||||
$searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1);
|
||||
$out .= $searchpicto;
|
||||
$out .= '</th>';
|
||||
}
|
||||
|
||||
$out .= '</tr>';
|
||||
|
||||
|
||||
$out .= '</table>';
|
||||
|
||||
$out .= '</form>';
|
||||
$out .= '</div>';
|
||||
|
||||
$out .= "\n";
|
||||
|
||||
$out .= '<ul class="timeline">';
|
||||
|
||||
if ($donetodo) {
|
||||
$tmp = '';
|
||||
if (get_class($filterobj) == 'User') {
|
||||
$tmp .= '<a href="'.DOL_URL_ROOT.'/comm/action/list.php?mode=show_list&socid='.$filterobj->id.'&status=done">';
|
||||
}
|
||||
$tmp .= ($donetodo != 'done' ? $langs->trans("ActionsToDoShort") : '');
|
||||
$tmp .= ($donetodo != 'done' && $donetodo != 'todo' ? ' / ' : '');
|
||||
$tmp .= ($donetodo != 'todo' ? $langs->trans("ActionsDoneShort") : '');
|
||||
//$out.=$langs->trans("ActionsToDoShort").' / '.$langs->trans("ActionsDoneShort");
|
||||
if (get_class($filterobj) == 'User') {
|
||||
$tmp .= '</a>';
|
||||
}
|
||||
$out .= getTitleFieldOfList($tmp);
|
||||
}
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php';
|
||||
$caction = new CActionComm($db);
|
||||
$arraylist = $caction->liste_array(1, 'code', '', (!getDolGlobalString('AGENDA_USE_EVENT_TYPE') ? 1 : 0), '', 1);
|
||||
|
||||
$actualCycleDate = false;
|
||||
|
||||
// Loop on each event to show it
|
||||
foreach ($histo as $key => $value) {
|
||||
$actionstatic->fetch($histo[$key]['id']); // TODO Do we need this, we already have a lot of data of line into $histo
|
||||
|
||||
$actionstatic->type_picto = $histo[$key]['apicto'];
|
||||
$actionstatic->type_code = $histo[$key]['acode'];
|
||||
|
||||
$labeltype = $actionstatic->type_code;
|
||||
if (!getDolGlobalString('AGENDA_USE_EVENT_TYPE') && empty($arraylist[$labeltype])) {
|
||||
$labeltype = 'AC_OTH';
|
||||
}
|
||||
if (!empty($actionstatic->code) && preg_match('/^TICKET_MSG/', $actionstatic->code)) {
|
||||
$labeltype = $langs->trans("Message");
|
||||
} else {
|
||||
if (!empty($arraylist[$labeltype])) {
|
||||
$labeltype = $arraylist[$labeltype];
|
||||
}
|
||||
if ($actionstatic->type_code == 'AC_OTH_AUTO' && ($actionstatic->type_code != $actionstatic->code) && $labeltype && !empty($arraylist[$actionstatic->code])) {
|
||||
$labeltype .= ' - '.$arraylist[$actionstatic->code]; // Use code in priority on type_code
|
||||
}
|
||||
}
|
||||
|
||||
$url = DOL_URL_ROOT.'/comm/action/card.php?id='.$histo[$key]['id'];
|
||||
|
||||
$tmpa = dol_getdate($histo[$key]['datestart'], false);
|
||||
|
||||
if (isset($tmpa['year']) && isset($tmpa['yday']) && $actualCycleDate !== $tmpa['year'].'-'.$tmpa['yday']) {
|
||||
$actualCycleDate = $tmpa['year'].'-'.$tmpa['yday'];
|
||||
$out .= '<!-- timeline time label -->';
|
||||
$out .= '<li class="time-label">';
|
||||
$out .= '<span class="timeline-badge-date">';
|
||||
$out .= dol_print_date($histo[$key]['datestart'], 'daytext', 'tzuserrel', $langs);
|
||||
$out .= '</span>';
|
||||
$out .= '</li>';
|
||||
$out .= '<!-- /.timeline-label -->';
|
||||
}
|
||||
|
||||
|
||||
$out .= '<!-- timeline item -->'."\n";
|
||||
$out .= '<li class="timeline-code-'.strtolower($actionstatic->code).'">';
|
||||
|
||||
//$timelineicon = getTimelineIcon($actionstatic, $histo, $key);
|
||||
$typeicon = $actionstatic->getTypePicto('pictofixedwidth timeline-icon-not-applicble', $labeltype);
|
||||
//$out .= $timelineicon;
|
||||
//var_dump($timelineicon);
|
||||
$out .= $typeicon;
|
||||
|
||||
$out .= '<div class="timeline-item">'."\n";
|
||||
|
||||
$out .= '<span class="time timeline-header-action2">';
|
||||
|
||||
if (isset($histo[$key]['type']) && $histo[$key]['type'] == 'mailing') {
|
||||
$out .= '<a class="paddingleft paddingright timeline-btn2 editfielda" href="'.DOL_URL_ROOT.'/comm/mailing/card.php?id='.$histo[$key]['id'].'">'.img_object($langs->trans("ShowEMailing"), "email").' ';
|
||||
$out .= $histo[$key]['id'];
|
||||
$out .= '</a> ';
|
||||
} else {
|
||||
$out .= $actionstatic->getNomUrl(1, -1, 'valignmiddle').' ';
|
||||
}
|
||||
|
||||
if ($user->hasRight('agenda', 'allactions', 'create') ||
|
||||
(($actionstatic->authorid == $user->id || $actionstatic->userownerid == $user->id) && $user->hasRight('agenda', 'myactions', 'create'))) {
|
||||
$out .= '<a class="paddingleft paddingright timeline-btn2 editfielda" href="'.DOL_MAIN_URL_ROOT.'/comm/action/card.php?action=edit&token='.newToken().'&id='.$actionstatic->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?'.$param).'">';
|
||||
//$out .= '<i class="fa fa-pencil" title="'.$langs->trans("Modify").'" ></i>';
|
||||
$out .= img_picto($langs->trans("Modify"), 'edit', 'class="edita"');
|
||||
$out .= '</a>';
|
||||
}
|
||||
|
||||
$out .= '</span>';
|
||||
|
||||
// Date
|
||||
$out .= '<span class="time"><i class="fa fa-clock-o valignmiddle"></i> <span class="valignmiddle">';
|
||||
$out .= dol_print_date($histo[$key]['datestart'], 'dayhour', 'tzuserrel');
|
||||
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', 'tzuserrel');
|
||||
} else {
|
||||
$out .= '-'.dol_print_date($histo[$key]['dateend'], 'dayhour', 'tzuserrel');
|
||||
}
|
||||
}
|
||||
$late = 0;
|
||||
if ($histo[$key]['percent'] == 0 && $histo[$key]['datestart'] && $histo[$key]['datestart'] < ($now - $delay_warning)) {
|
||||
$late = 1;
|
||||
}
|
||||
if ($histo[$key]['percent'] == 0 && !$histo[$key]['datestart'] && $histo[$key]['dateend'] && $histo[$key]['datestart'] < ($now - $delay_warning)) {
|
||||
$late = 1;
|
||||
}
|
||||
if ($histo[$key]['percent'] > 0 && $histo[$key]['percent'] < 100 && $histo[$key]['dateend'] && $histo[$key]['dateend'] < ($now - $delay_warning)) {
|
||||
$late = 1;
|
||||
}
|
||||
if ($histo[$key]['percent'] > 0 && $histo[$key]['percent'] < 100 && !$histo[$key]['dateend'] && $histo[$key]['datestart'] && $histo[$key]['datestart'] < ($now - $delay_warning)) {
|
||||
$late = 1;
|
||||
}
|
||||
if ($late) {
|
||||
$out .= img_warning($langs->trans("Late")).' ';
|
||||
}
|
||||
$out .= "</span></span>\n";
|
||||
|
||||
// Ref
|
||||
$out .= '<h3 class="timeline-header">';
|
||||
|
||||
// Author of event
|
||||
$out .= '<div class="messaging-author inline-block tdoverflowmax150 valignmiddle marginrightonly">';
|
||||
if ($histo[$key]['userid'] > 0) {
|
||||
if (!isset($userGetNomUrlCache[$histo[$key]['userid']])) { // is in cache ?
|
||||
$userstatic->fetch($histo[$key]['userid']);
|
||||
$userGetNomUrlCache[$histo[$key]['userid']] = $userstatic->getNomUrl(-1, '', 0, 0, 16, 0, 'firstelselast', '');
|
||||
}
|
||||
$out .= $userGetNomUrlCache[$histo[$key]['userid']];
|
||||
} elseif (!empty($histo[$key]['msg_from']) && $actionstatic->code == 'TICKET_MSG') {
|
||||
if (!isset($contactGetNomUrlCache[$histo[$key]['msg_from']])) {
|
||||
if ($contactstatic->fetch(0, null, '', $histo[$key]['msg_from']) > 0) {
|
||||
$contactGetNomUrlCache[$histo[$key]['msg_from']] = $contactstatic->getNomUrl(-1, '', 16);
|
||||
} else {
|
||||
$contactGetNomUrlCache[$histo[$key]['msg_from']] = $histo[$key]['msg_from'];
|
||||
}
|
||||
}
|
||||
$out .= $contactGetNomUrlCache[$histo[$key]['msg_from']];
|
||||
}
|
||||
$out .= '</div>';
|
||||
|
||||
// Title
|
||||
$out .= ' <div class="messaging-title inline-block">';
|
||||
//$out .= $actionstatic->getTypePicto();
|
||||
if (empty($conf->dol_optimize_smallscreen) && $actionstatic->type_code != 'AC_OTH_AUTO') {
|
||||
$out .= $labeltype.' - ';
|
||||
}
|
||||
|
||||
$libelle = '';
|
||||
if (preg_match('/^TICKET_MSG/', $actionstatic->code)) {
|
||||
$out .= $langs->trans('TicketNewMessage');
|
||||
} elseif (preg_match('/^TICKET_MSG_PRIVATE/', $actionstatic->code)) {
|
||||
$out .= $langs->trans('TicketNewMessage').' <em>('.$langs->trans('Private').')</em>';
|
||||
} elseif (isset($histo[$key]['type'])) {
|
||||
if ($histo[$key]['type'] == 'action') {
|
||||
$transcode = $langs->transnoentitiesnoconv("Action".$histo[$key]['acode']);
|
||||
$libelle = ($transcode != "Action".$histo[$key]['acode'] ? $transcode : $histo[$key]['alabel']);
|
||||
$libelle = $histo[$key]['note'];
|
||||
$actionstatic->id = $histo[$key]['id'];
|
||||
$out .= dol_escape_htmltag(dol_trunc($libelle, 120));
|
||||
} elseif ($histo[$key]['type'] == 'mailing') {
|
||||
$out .= '<a href="'.DOL_URL_ROOT.'/comm/mailing/card.php?id='.$histo[$key]['id'].'">'.img_object($langs->trans("ShowEMailing"), "email").' ';
|
||||
$transcode = $langs->transnoentitiesnoconv("Action".$histo[$key]['acode']);
|
||||
$libelle = ($transcode != "Action".$histo[$key]['acode'] ? $transcode : 'Send mass mailing');
|
||||
$out .= dol_escape_htmltag(dol_trunc($libelle, 120));
|
||||
} else {
|
||||
$libelle .= $histo[$key]['note'];
|
||||
$out .= dol_escape_htmltag(dol_trunc($libelle, 120));
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($histo[$key]['elementtype']) && !empty($histo[$key]['fk_element'])) {
|
||||
if (isset($conf->cache['elementlinkcache'][$histo[$key]['elementtype']]) && isset($conf->cache['elementlinkcache'][$histo[$key]['elementtype']][$histo[$key]['fk_element']])) {
|
||||
$link = $conf->cache['elementlinkcache'][$histo[$key]['elementtype']][$histo[$key]['fk_element']];
|
||||
} else {
|
||||
if (!isset($conf->cache['elementlinkcache'][$histo[$key]['elementtype']])) {
|
||||
$conf->cache['elementlinkcache'][$histo[$key]['elementtype']] = array();
|
||||
}
|
||||
$link = dolGetElementUrl($histo[$key]['fk_element'], $histo[$key]['elementtype'], 1);
|
||||
$conf->cache['elementlinkcache'][$histo[$key]['elementtype']][$histo[$key]['fk_element']] = $link;
|
||||
}
|
||||
if ($link) {
|
||||
$out .= ' - '.$link;
|
||||
}
|
||||
}
|
||||
|
||||
$out .= '</div>';
|
||||
|
||||
$out .= '</h3>';
|
||||
|
||||
// Message
|
||||
if (!empty($histo[$key]['message'] && $histo[$key]['message'] != $libelle)
|
||||
&& $actionstatic->code != 'AC_TICKET_CREATE'
|
||||
&& $actionstatic->code != 'AC_TICKET_MODIFY'
|
||||
) {
|
||||
$out .= '<div class="timeline-body classfortooltip" title="'.dol_escape_htmltag(dol_htmlwithnojs(dol_string_onlythesehtmltags(dol_htmlentitiesbr($histo[$key]['message']), 1, 1, 1)), 1, 1).'">';
|
||||
$out .= dolGetFirstLineOfText($histo[$key]['message'], 3);
|
||||
$out .= '</div>';
|
||||
}
|
||||
|
||||
// Timeline footer
|
||||
$footer = '';
|
||||
|
||||
// Contact for this action
|
||||
if (isset($histo[$key]['socpeopleassigned']) && is_array($histo[$key]['socpeopleassigned']) && count($histo[$key]['socpeopleassigned']) > 0) {
|
||||
$contactList = '';
|
||||
foreach ($histo[$key]['socpeopleassigned'] as $cid => $Tab) {
|
||||
if (empty($conf->cache['contact'][$histo[$key]['contact_id']])) {
|
||||
$contact = new Contact($db);
|
||||
$contact->fetch($cid);
|
||||
$conf->cache['contact'][$histo[$key]['contact_id']] = $contact;
|
||||
} else {
|
||||
$contact = $conf->cache['contact'][$histo[$key]['contact_id']];
|
||||
}
|
||||
|
||||
if ($contact) {
|
||||
$contactList .= !empty($contactList) ? ', ' : '';
|
||||
$contactList .= $contact->getNomUrl(1);
|
||||
if (isset($histo[$key]['acode']) && $histo[$key]['acode'] == 'AC_TEL') {
|
||||
if (!empty($contact->phone_pro)) {
|
||||
$contactList .= '('.dol_print_phone($contact->phone_pro).')';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$footer .= $langs->trans('ActionOnContact').' : '.$contactList;
|
||||
} elseif (empty($objcon->id) && isset($histo[$key]['contact_id']) && $histo[$key]['contact_id'] > 0) {
|
||||
if (empty($conf->cache['contact'][$histo[$key]['contact_id']])) {
|
||||
$contact = new Contact($db);
|
||||
$result = $contact->fetch($histo[$key]['contact_id']);
|
||||
$conf->cache['contact'][$histo[$key]['contact_id']] = $contact;
|
||||
} else {
|
||||
$contact = $conf->cache['contact'][$histo[$key]['contact_id']];
|
||||
}
|
||||
|
||||
if ($result > 0) {
|
||||
$footer .= $contact->getNomUrl(1);
|
||||
if (isset($histo[$key]['acode']) && $histo[$key]['acode'] == 'AC_TEL') {
|
||||
if (!empty($contact->phone_pro)) {
|
||||
$footer .= '('.dol_print_phone($contact->phone_pro).')';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$documents = getActionCommEcmList($actionstatic);
|
||||
if (!empty($documents)) {
|
||||
$footer .= '<div class="timeline-documents-container">';
|
||||
foreach ($documents as $doc) {
|
||||
$footer .= '<span id="document_'.$doc->id.'" class="timeline-documents" ';
|
||||
$footer .= ' data-id="'.$doc->id.'" ';
|
||||
$footer .= ' data-path="'.$doc->filepath.'"';
|
||||
$footer .= ' data-filename="'.dol_escape_htmltag($doc->filename).'" ';
|
||||
$footer .= '>';
|
||||
|
||||
$filePath = DOL_DATA_ROOT.'/'.$doc->filepath.'/'.$doc->filename;
|
||||
$mime = dol_mimetype($filePath);
|
||||
$file = $actionstatic->id.'/'.$doc->filename;
|
||||
$thumb = $actionstatic->id.'/thumbs/'.substr($doc->filename, 0, strrpos($doc->filename, '.')).'_mini'.substr($doc->filename, strrpos($doc->filename, '.'));
|
||||
$doclink = dol_buildpath('document.php', 1).'?modulepart=actions&attachment=0&file='.urlencode($file).'&entity='.$conf->entity;
|
||||
$viewlink = dol_buildpath('viewimage.php', 1).'?modulepart=actions&file='.urlencode($thumb).'&entity='.$conf->entity;
|
||||
|
||||
$mimeAttr = ' mime="'.$mime.'" ';
|
||||
$class = '';
|
||||
if (in_array($mime, array('image/png', 'image/jpeg', 'application/pdf'))) {
|
||||
$class .= ' documentpreview';
|
||||
}
|
||||
|
||||
$footer .= '<a href="'.$doclink.'" class="btn-link '.$class.'" target="_blank" rel="noopener noreferrer" '.$mimeAttr.' >';
|
||||
$footer .= img_mime($filePath).' '.$doc->filename;
|
||||
$footer .= '</a>';
|
||||
|
||||
$footer .= '</span>';
|
||||
}
|
||||
$footer .= '</div>';
|
||||
}
|
||||
|
||||
if (!empty($footer)) {
|
||||
$out .= '<div class="timeline-footer">'.$footer.'</div>';
|
||||
}
|
||||
|
||||
$out .= '</div>'."\n"; // end timeline-item
|
||||
|
||||
$out .= '</li>';
|
||||
$out .= '<!-- END timeline item -->';
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
$out .= "</ul>\n";
|
||||
|
||||
if (empty($histo)) {
|
||||
$out .= '<span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($noprint) {
|
||||
return $out;
|
||||
} else {
|
||||
print $out;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ if ((!empty($objUser->id) || !empty($objcon->id)) && $permok) {
|
|||
|
||||
$morehtmlright = '';
|
||||
|
||||
$messagingUrl = DOL_URL_ROOT.'/societe/messaging.php?userid='.$object->id;
|
||||
$messagingUrl = DOL_URL_ROOT.'/user/messaging.php?userid='.$object->id;
|
||||
$morehtmlright .= dolGetButtonTitle($langs->trans('ShowAsConversation'), '', 'fa fa-comments imgforviewmode', $messagingUrl, '', 1);
|
||||
$messagingUrl = DOL_URL_ROOT.'/user/info.php?id='.$object->id;
|
||||
$morehtmlright .= dolGetButtonTitle($langs->trans('MessageListViewType'), '', 'fa fa-bars imgforviewmode', $messagingUrl, '', 2);
|
||||
|
|
|
|||
230
htdocs/user/messaging.php
Normal file
230
htdocs/user/messaging.php
Normal file
|
|
@ -0,0 +1,230 @@
|
|||
<?php
|
||||
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2005 Brice Davoleau <brice.davoleau@gmail.com>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2006-2019 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
|
||||
* Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/societe/messaging.php
|
||||
* \ingroup societe
|
||||
* \brief Page of third party events
|
||||
*/
|
||||
|
||||
// Load Dolibarr environment
|
||||
require '../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('agenda', 'bills', 'companies', 'orders', 'propal'));
|
||||
|
||||
$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'useragenda';
|
||||
|
||||
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' : getDolGlobalString('AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT'));
|
||||
}
|
||||
|
||||
$search_rowid = GETPOST('search_rowid');
|
||||
$search_agenda_label = GETPOST('search_agenda_label');
|
||||
|
||||
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
|
||||
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
||||
$sortorder = GETPOST('sortorder', 'aZ09comma');
|
||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||
if (empty($page) || $page == -1) {
|
||||
$page = 0;
|
||||
} // If $page is not defined, or '' or -1
|
||||
$offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (!$sortfield) {
|
||||
$sortfield = 'a.datep,a.id';
|
||||
}
|
||||
if (!$sortorder) {
|
||||
$sortorder = 'DESC,DESC';
|
||||
}
|
||||
|
||||
// Initialize technical objects
|
||||
$object = new User($db);
|
||||
if ($id > 0 || !empty($ref)) {
|
||||
$result = $object->fetch($id, $ref, '', 1);
|
||||
$object->getrights();
|
||||
}
|
||||
|
||||
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
||||
$hookmanager->initHooks(array('agendathirdparty', 'globalcard'));
|
||||
|
||||
// Security check
|
||||
$userid = GETPOST('userid', 'int');
|
||||
if ($user->id) {
|
||||
$userId = $user->id;
|
||||
}
|
||||
|
||||
$result = $object->fetch($userid);
|
||||
if ($result <= 0) {
|
||||
accessforbidden('User not found');
|
||||
}
|
||||
|
||||
$result = restrictedArea($user, 'user', $userId, '&user');
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 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');
|
||||
}
|
||||
|
||||
if (empty($reshook)) {
|
||||
// Cancel
|
||||
if (GETPOST('cancel', 'alpha') && !empty($backtopage)) {
|
||||
header("Location: ".$backtopage);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Purge search criteria
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
|
||||
$actioncode = '';
|
||||
$search_agenda_label = '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
$person_name = !empty($object->firstname) ? $object->lastname.", ".$object->firstname : $object->lastname;
|
||||
$title = $person_name." - ".$langs->trans('Info');
|
||||
$help_url = '';
|
||||
llxHeader('', $title, $help_url);
|
||||
|
||||
$head = user_prepare_head($object);
|
||||
|
||||
$title = $langs->trans("User");
|
||||
print dol_get_fiche_head($head, 'info', $title, -1, 'user');
|
||||
|
||||
|
||||
$linkback = '';
|
||||
|
||||
if ($user->hasRight('user', 'user', 'lire') || $user->admin) {
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/user/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
|
||||
}
|
||||
|
||||
$morehtmlref = '<a href="'.DOL_URL_ROOT.'/user/vcard.php?id='.$object->id.'&output=file&file='.urlencode(dol_sanitizeFileName($object->getFullName($langs).'.vcf')).'" class="refid" rel="noopener">';
|
||||
$morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
|
||||
$morehtmlref .= '</a>';
|
||||
|
||||
$urltovirtualcard = '/user/virtualcard.php?id='.((int) $object->id);
|
||||
$morehtmlref .= dolButtonToOpenUrlInDialogPopup('publicvirtualcard', $langs->transnoentitiesnoconv("PublicVirtualCardUrl").' - '.$object->getFullName($langs), img_picto($langs->trans("PublicVirtualCardUrl"), 'card', 'class="valignmiddle marginleftonly paddingrightonly"'), $urltovirtualcard, '', 'nohover');
|
||||
|
||||
dol_banner_tab($object, 'id', $linkback, $user->hasRight('user', 'user', 'lire') || $user->admin, 'rowid', 'ref', $morehtmlref);
|
||||
|
||||
|
||||
$object->info($userid);
|
||||
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
print '<br>';
|
||||
|
||||
dol_print_object_info($object);
|
||||
|
||||
print '</div>';
|
||||
|
||||
|
||||
print dol_get_fiche_end();
|
||||
|
||||
$objUser = $object;
|
||||
$objcon = new stdClass();
|
||||
|
||||
$out = '';
|
||||
$permok = $user->hasRight('agenda', 'myactions', 'create');
|
||||
if ((!empty($objUser->id) || !empty($objcon->id)) && $permok) {
|
||||
if (is_object($objUser) && get_class($objUser) == 'User') {
|
||||
$out .= '&originid='.$objUser->id.($objUser->id > 0 ? '&userid='.$objUser->id : '').'&backtopage='.urlencode($_SERVER['PHP_SELF'].($objUser->id > 0 ? '?userid='.$objUser->id : ''));
|
||||
}
|
||||
$out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '');
|
||||
$out .= '&datep='.dol_print_date(dol_now(), 'dayhourlog', 'tzuserrel');
|
||||
}
|
||||
|
||||
$morehtmlright = '';
|
||||
|
||||
$messagingUrl = DOL_URL_ROOT.'/user/messaging.php?userid='.$object->id;
|
||||
$morehtmlright .= dolGetButtonTitle($langs->trans('ShowAsConversation'), '', 'fa fa-comments imgforviewmode', $messagingUrl, '', 1);
|
||||
$messagingUrl = DOL_URL_ROOT.'/user/info.php?id='.$object->id;
|
||||
$morehtmlright .= dolGetButtonTitle($langs->trans('MessageListViewType'), '', 'fa fa-bars imgforviewmode', $messagingUrl, '', 2);
|
||||
|
||||
if (isModEnabled('agenda')) {
|
||||
if ($user->hasRight('agenda', 'myactions', 'create') || $user->hasRight('agenda', 'allactions', 'create')) {
|
||||
$morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out);
|
||||
}
|
||||
}
|
||||
|
||||
if (isModEnabled('agenda') && ($user->hasRight('agenda', 'myactions', 'read') || $user->hasRight('agenda', 'allaactions', 'read'))) {
|
||||
print '<br>';
|
||||
$param = '&userid='.urlencode($userid);
|
||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
|
||||
$param .= '&contextpage='.urlencode($contextpage);
|
||||
}
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) {
|
||||
$param .= '&limit='.((int) $limit);
|
||||
}
|
||||
|
||||
|
||||
// Try to know count of actioncomm from cache
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
|
||||
$cachekey = 'count_events_user_'.$object->id;
|
||||
$nbEvent = dol_getcache($cachekey);
|
||||
|
||||
$titlelist = $langs->trans("ActionsOnCompany").(is_numeric($nbEvent) ? '<span class="opacitymedium colorblack paddingleft">('.$nbEvent.')</span>' : '');
|
||||
if (!empty($conf->dol_optimize_smallscreen)) {
|
||||
$titlelist = $langs->trans("Actions").(is_numeric($nbEvent) ? '<span class="opacitymedium colorblack paddingleft">('.$nbEvent.')</span>' : '');
|
||||
}
|
||||
|
||||
print_barre_liste($titlelist, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 0);
|
||||
|
||||
// List of all actions
|
||||
$filters = array();
|
||||
$filters['search_agenda_label'] = $search_agenda_label;
|
||||
$filters['search_rowid'] = $search_rowid;
|
||||
|
||||
show_actions_messaging_user($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);
|
||||
}
|
||||
|
||||
//End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
Loading…
Reference in New Issue
Block a user