code syntax ticket directory

This commit is contained in:
Frédéric FRANCE 2021-02-26 13:27:00 +01:00
parent 0d7a2c1d81
commit 4c1004ea5d
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1
13 changed files with 745 additions and 566 deletions

View File

@ -46,16 +46,21 @@ $sortorder = GETPOST("sortorder", 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
$page = is_numeric($page) ? $page : 0; $page = is_numeric($page) ? $page : 0;
$page = $page == -1 ? 0 : $page; $page = $page == -1 ? 0 : $page;
if (!$sortfield) $sortfield = "a.datep,a.id"; if (!$sortfield) {
if (!$sortorder) $sortorder = "DESC"; $sortfield = "a.datep,a.id";
}
if (!$sortorder) {
$sortorder = "DESC";
}
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (GETPOST('actioncode', 'array')) if (GETPOST('actioncode', 'array')) {
{
$actioncode = GETPOST('actioncode', 'array', 3); $actioncode = GETPOST('actioncode', 'array', 3);
if (!count($actioncode)) $actioncode = '0'; if (!count($actioncode)) {
$actioncode = '0';
}
} else { } else {
$actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
} }
@ -83,8 +88,7 @@ if (!$user->rights->ticket->read) {
accessforbidden(); accessforbidden();
} }
// restrict access for externals users // restrict access for externals users
if ($user->socid > 0 && ($object->fk_soc != $user->socid)) if ($user->socid > 0 && ($object->fk_soc != $user->socid)) {
{
accessforbidden(); accessforbidden();
} }
// or for unauthorized internals users // or for unauthorized internals users
@ -100,17 +104,17 @@ if (!$user->socid && ($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY && $object-
$parameters = array('id'=>$socid); $parameters = array('id'=>$socid);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $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 ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) if (empty($reshook)) {
{
// Set view style // Set view style
$_SESSION['ticket-view-type'] = "list"; $_SESSION['ticket-view-type'] = "list";
} }
// Purge search criteria // Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers
{
$actioncode = ''; $actioncode = '';
$search_agenda_label = ''; $search_agenda_label = '';
} }
@ -126,7 +130,9 @@ $userstat = new User($db);
$formticket = new FormTicket($db); $formticket = new FormTicket($db);
$title = $langs->trans("Ticket").' - '.$object->ref.' '.$object->name; $title = $langs->trans("Ticket").' - '.$object->ref.' '.$object->name;
if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/ticketnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->ref.' '.$object->name.' - '.$langs->trans("Info"); if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/ticketnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
$title = $object->ref.' '.$object->name.' - '.$langs->trans("Info");
}
$help_url = 'FR:DocumentationModuleTicket'; $help_url = 'FR:DocumentationModuleTicket';
llxHeader('', $title, $help_url); llxHeader('', $title, $help_url);
@ -167,8 +173,7 @@ if (!empty($object->origin_email)) {
} }
// Thirdparty // Thirdparty
if (!empty($conf->societe->enabled)) if (!empty($conf->societe->enabled)) {
{
$morehtmlref .= '<br>'.$langs->trans('ThirdParty'); $morehtmlref .= '<br>'.$langs->trans('ThirdParty');
/*if ($action != 'editcustomer' && $object->fk_statut < 8 && !$user->socid && $user->rights->ticket->write) { /*if ($action != 'editcustomer' && $object->fk_statut < 8 && !$user->socid && $user->rights->ticket->write) {
$morehtmlref.='<a class="editfielda" href="' . $url_page_current . '?action=editcustomer&amp;track_id=' . $object->track_id . '">' . img_edit($langs->transnoentitiesnoconv('Edit'), 1) . '</a>'; $morehtmlref.='<a class="editfielda" href="' . $url_page_current . '?action=editcustomer&amp;track_id=' . $object->track_id . '">' . img_edit($langs->transnoentitiesnoconv('Edit'), 1) . '</a>';
@ -182,12 +187,10 @@ if (!empty($conf->societe->enabled))
} }
// Project // Project
if (!empty($conf->projet->enabled)) if (!empty($conf->projet->enabled)) {
{
$langs->load("projects"); $langs->load("projects");
$morehtmlref .= '<br>'.$langs->trans('Project'); $morehtmlref .= '<br>'.$langs->trans('Project');
if ($user->rights->ticket->write) if ($user->rights->ticket->write) {
{
if ($action != 'classify') { if ($action != 'classify') {
//$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a>'; //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a>';
$morehtmlref .= ' : '; $morehtmlref .= ' : ';
@ -225,11 +228,14 @@ print dol_get_fiche_end();
print '<br>'; print '<br>';
if (!empty($object->id)) if (!empty($object->id)) {
{
$param = '&id='.$object->id; $param = '&id='.$object->id;
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; $param .= '&contextpage='.$contextpage;
}
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.$limit;
}
$morehtmlright = ''; $morehtmlright = '';

View File

@ -60,7 +60,9 @@ $sortorder = GETPOST('sortorder', 'aZ09comma');
if (GETPOST('actioncode', 'array')) { if (GETPOST('actioncode', 'array')) {
$actioncode = GETPOST('actioncode', 'array', 3); $actioncode = GETPOST('actioncode', 'array', 3);
if (!count($actioncode)) $actioncode = '0'; if (!count($actioncode)) {
$actioncode = '0';
}
} else { } else {
$actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
} }
@ -80,12 +82,15 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen
// Initialize array of search criterias // Initialize array of search criterias
$search_all = GETPOST("search_all", 'alpha'); $search_all = GETPOST("search_all", 'alpha');
$search = array(); $search = array();
foreach ($object->fields as $key => $val) foreach ($object->fields as $key => $val) {
{ if (GETPOST('search_'.$key, 'alpha')) {
if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); $search[$key] = GETPOST('search_'.$key, 'alpha');
}
} }
if (empty($action) && empty($id) && empty($ref)) $action = 'view'; if (empty($action) && empty($id) && empty($ref)) {
$action = 'view';
}
//Select mail models is same action as add_message //Select mail models is same action as add_message
if (GETPOST('modelselected', 'alpha')) { if (GETPOST('modelselected', 'alpha')) {
@ -96,8 +101,7 @@ if (GETPOST('modelselected', 'alpha')) {
//include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals //include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
if ($id || $track_id || $ref) { if ($id || $track_id || $ref) {
$res = $object->fetch($id, $ref, $track_id); $res = $object->fetch($id, $ref, $track_id);
if ($res >= 0) if ($res >= 0) {
{
$id = $object->id; $id = $object->id;
$track_id = $object->track_id; $track_id = $object->track_id;
} }
@ -125,13 +129,14 @@ $now = dol_now();
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $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 ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
$error = 0; $error = 0;
if (empty($reshook)) { if (empty($reshook)) {
// Purge search criteria // Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers{ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers{
{
$actioncode = ''; $actioncode = '';
$search_agenda_label = ''; $search_agenda_label = '';
} }
@ -159,7 +164,9 @@ if (empty($reshook)) {
$action = 'create'; $action = 'create';
} }
$ret = $extrafields->setOptionalsFromPost(null, $object); $ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) $error++; if ($ret < 0) {
$error++;
}
if (!$error) { if (!$error) {
$db->begin(); $db->begin();
@ -289,7 +296,9 @@ if (empty($reshook)) {
array_push($object->errors, $langs->trans('ErrorFieldRequired', $langs->transnoentities('Subject'))); array_push($object->errors, $langs->trans('ErrorFieldRequired', $langs->transnoentities('Subject')));
} }
$ret = $extrafields->setOptionalsFromPost(null, $object); $ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) $error++; if ($ret < 0) {
$error++;
}
} }
if (!$error) { if (!$error) {
@ -301,7 +310,9 @@ if (empty($reshook)) {
$object->severity_code = GETPOST('severity_code', 'alpha'); $object->severity_code = GETPOST('severity_code', 'alpha');
$ret = $object->update($user); $ret = $object->update($user);
if ($ret <= 0) $error++; if ($ret <= 0) {
$error++;
}
if ($error) { if ($error) {
$db->rollback(); $db->rollback();
@ -354,11 +365,12 @@ if (empty($reshook)) {
if (!$error) { if (!$error) {
$ret = $object->assignUser($user, $usertoassign); $ret = $object->assignUser($user, $usertoassign);
if ($ret < 0) $error++; if ($ret < 0) {
$error++;
}
} }
if (!$error) // Update list of contacts if (!$error) { // Update list of contacts
{
// Si déjà un user assigné on le supprime des contacts // Si déjà un user assigné on le supprime des contacts
if ($useroriginassign > 0) { if ($useroriginassign > 0) {
$internal_contacts = $object->listeContact(-1, 'internal'); $internal_contacts = $object->listeContact(-1, 'internal');
@ -373,7 +385,9 @@ if (empty($reshook)) {
} }
} }
if ($usertoassign > 0) $object->add_contact($usertoassign, "SUPPORTTEC", 'internal', $notrigger = 0); if ($usertoassign > 0) {
$object->add_contact($usertoassign, "SUPPORTTEC", 'internal', $notrigger = 0);
}
} }
if (!$error) { if (!$error) {
@ -517,16 +531,16 @@ if (empty($reshook)) {
} }
} }
} }
} // Categorisation dans projet } elseif ($action == 'classin' && $user->rights->ticket->write) {
elseif ($action == 'classin' && $user->rights->ticket->write) { // Categorisation dans projet
if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
$object->setProject(GETPOST('projectid', 'int')); $object->setProject(GETPOST('projectid', 'int'));
$url = 'card.php?action=view&track_id='.$object->track_id; $url = 'card.php?action=view&track_id='.$object->track_id;
header("Location: ".$url); header("Location: ".$url);
exit(); exit();
} }
} // Categorisation dans contrat } elseif ($action == 'setcontract' && $user->rights->ticket->write) {
elseif ($action == 'setcontract' && $user->rights->ticket->write) { // Categorisation dans contrat
if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
$object->setContract(GETPOST('contractid', 'int')); $object->setContract(GETPOST('contractid', 'int'));
$url = 'card.php?action=view&track_id='.$object->track_id; $url = 'card.php?action=view&track_id='.$object->track_id;
@ -557,8 +571,8 @@ if (empty($reshook)) {
} }
$action = 'view'; $action = 'view';
} // Reopen ticket } elseif ($action == 'confirm_set_status' && $user->rights->ticket->write && !GETPOST('cancel')) {
elseif ($action == 'confirm_set_status' && $user->rights->ticket->write && !GETPOST('cancel')) { // Reopen ticket
if ($object->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) { if ($object->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) {
$new_status = GETPOST('new_status', 'int'); $new_status = GETPOST('new_status', 'int');
$old_status = $object->fk_statut; $old_status = $object->fk_statut;
@ -582,11 +596,15 @@ if (empty($reshook)) {
$object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')); $object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha'));
$ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml')); $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml'));
if ($ret < 0) $error++; if ($ret < 0) {
$error++;
}
if (!$error) { if (!$error) {
$result = $object->insertExtraFields(empty($triggermodname) ? '' : $triggermodname, $user); $result = $object->insertExtraFields(empty($triggermodname) ? '' : $triggermodname, $user);
if ($result < 0) { $error++; } if ($result < 0) {
$error++;
}
} }
if ($error) { if ($error) {
@ -634,7 +652,9 @@ if (empty($reshook)) {
include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
// Set $action to correct value for the case we used presend action to add a message // Set $action to correct value for the case we used presend action to add a message
if (GETPOSTISSET('actionbis') && $action == 'presend') $action = 'presend_addmessage'; if (GETPOSTISSET('actionbis') && $action == 'presend') {
$action = 'presend_addmessage';
}
} }
@ -645,15 +665,16 @@ if (empty($reshook)) {
$userstat = new User($db); $userstat = new User($db);
$form = new Form($db); $form = new Form($db);
$formticket = new FormTicket($db); $formticket = new FormTicket($db);
if (!empty($conf->projet->enabled)) $formproject = new FormProjets($db); if (!empty($conf->projet->enabled)) {
$formproject = new FormProjets($db);
}
$help_url = 'FR:DocumentationModuleTicket'; $help_url = 'FR:DocumentationModuleTicket';
$page_title = $actionobject->getTitle($action); $page_title = $actionobject->getTitle($action);
llxHeader('', $page_title, $help_url); llxHeader('', $page_title, $help_url);
if ($action == 'create' || $action == 'presend') if ($action == 'create' || $action == 'presend') {
{
$formticket = new FormTicket($db); $formticket = new FormTicket($db);
print load_fiche_titre($langs->trans('NewTicket'), '', 'ticket'); print load_fiche_titre($langs->trans('NewTicket'), '', 'ticket');
@ -725,12 +746,9 @@ if ($action == 'create' || $action == 'presend')
print '</div>'; print '</div>';
print '</form>'; print '</form>';
} } elseif (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'dellink' || $action == 'presend' || $action == 'presend_addmessage' || $action == 'close' || $action == 'delete' || $action == 'editcustomer' || $action == 'progression' || $action == 'reopen'
elseif (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'dellink' || $action == 'presend' || $action == 'presend_addmessage' || $action == 'close' || $action == 'delete' || $action == 'editcustomer' || $action == 'progression' || $action == 'reopen' || $action == 'editsubject' || $action == 'edit_extras' || $action == 'update_extras' || $action == 'edit_extrafields' || $action == 'set_extrafields' || $action == 'classify' || $action == 'sel_contract' || $action == 'edit_message_init' || $action == 'set_status' || $action == 'dellink') {
|| $action == 'editsubject' || $action == 'edit_extras' || $action == 'update_extras' || $action == 'edit_extrafields' || $action == 'set_extrafields' || $action == 'classify' || $action == 'sel_contract' || $action == 'edit_message_init' || $action == 'set_status' || $action == 'dellink') if ($res > 0) {
{
if ($res > 0)
{
// or for unauthorized internals users // or for unauthorized internals users
if (!$user->socid && ($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY && $object->fk_user_assign != $user->id) && !$user->rights->ticket->manage) { if (!$user->socid && ($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY && $object->fk_user_assign != $user->id) && !$user->rights->ticket->manage) {
accessforbidden('', 0, 1); accessforbidden('', 0, 1);
@ -774,8 +792,8 @@ elseif (empty($action) || $action == 'view' || $action == 'addlink' || $action =
print dol_get_fiche_head($head, 'ticket', $langs->trans("Project"), 0, ($projectstat->public ? 'projectpub' : 'project')); print dol_get_fiche_head($head, 'ticket', $langs->trans("Project"), 0, ($projectstat->public ? 'projectpub' : 'project'));
/* /*
* Projet synthese pour rappel * Projet synthese pour rappel
*/ */
print '<table class="border centpercent">'; print '<table class="border centpercent">';
$linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>'; $linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
@ -878,19 +896,20 @@ elseif (empty($action) || $action == 'view' || $action == 'addlink' || $action =
$langs->load("projects"); $langs->load("projects");
$morehtmlref .= '<br>'.$langs->trans('Project').' '; $morehtmlref .= '<br>'.$langs->trans('Project').' ';
if ($user->rights->ticket->write) { if ($user->rights->ticket->write) {
if ($action != 'classify') if ($action != 'classify') {
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a>'; $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&amp;id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a>';
$morehtmlref .= ' : '; }
if ($action == 'classify') { $morehtmlref .= ' : ';
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); if ($action == 'classify') {
$morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">'; //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref .= '<input type="hidden" name="action" value="classin">'; $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">'; $morehtmlref .= '<input type="hidden" name="action" value="classin">';
$morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1, 0, 'maxwidth500'); $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
$morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1, 0, 'maxwidth500');
$morehtmlref .= '</form>'; $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
} else { $morehtmlref .= '</form>';
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); } else {
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
} }
} else { } else {
if (!empty($object->fk_project)) { if (!empty($object->fk_project)) {
@ -1010,8 +1029,7 @@ elseif (empty($action) || $action == 'view' || $action == 'addlink' || $action =
print '</tr>'; print '</tr>';
// Timing (Duration sum of linked fichinter) // Timing (Duration sum of linked fichinter)
if ($conf->fichinter->enabled) if ($conf->fichinter->enabled) {
{
$object->fetchObjectLinked(); $object->fetchObjectLinked();
$num = count($object->linkedObjects); $num = count($object->linkedObjects);
$timing = 0; $timing = 0;
@ -1120,8 +1138,7 @@ elseif (empty($action) || $action == 'view' || $action == 'addlink' || $action =
} }
if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) if (!empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) {
{
print load_fiche_titre($langs->trans('Contacts'), '', 'title_companies.png'); print load_fiche_titre($langs->trans('Contacts'), '', 'title_companies.png');
print '<div class="div-table-responsive-no-min">'; print '<div class="div-table-responsive-no-min">';
@ -1245,10 +1262,11 @@ elseif (empty($action) || $action == 'view' || $action == 'addlink' || $action =
print '<div class="tabsAction">'."\n"; print '<div class="tabsAction">'."\n";
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) if (empty($reshook)) {
{
// Show link to add a message (if read and not closed) // Show link to add a message (if read and not closed)
if ($object->fk_statut < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage") { if ($object->fk_statut < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage") {
print '<div class="inline-block divButAction"><a class="butAction reposition" href="card.php?track_id='.$object->track_id.'&action=presend_addmessage&mode=init">'.$langs->trans('TicketAddMessage').'</a></div>'; print '<div class="inline-block divButAction"><a class="butAction reposition" href="card.php?track_id='.$object->track_id.'&action=presend_addmessage&mode=init">'.$langs->trans('TicketAddMessage').'</a></div>';
@ -1292,11 +1310,12 @@ elseif (empty($action) || $action == 'view' || $action == 'addlink' || $action =
$action = 'presend'; $action = 'presend';
} }
// Set $action to correct value for the case we used presend action to add a message // Set $action to correct value for the case we used presend action to add a message
if (GETPOSTISSET('actionbis') && $action == 'presend') $action = 'presend_addmessage'; if (GETPOSTISSET('actionbis') && $action == 'presend') {
$action = 'presend_addmessage';
}
// add a message // add a message
if ($action == 'presend' || $action == 'presend_addmessage') if ($action == 'presend' || $action == 'presend_addmessage') {
{
$action = 'add_message'; // action to use to post the message $action = 'add_message'; // action to use to post the message
$modelmail = 'ticket_send'; $modelmail = 'ticket_send';
@ -1375,10 +1394,18 @@ elseif (empty($action) || $action == 'view' || $action == 'addlink' || $action =
// Show messages on card (Note: this is a duplicate of the view Events/Agenda but on the main tab) // Show messages on card (Note: this is a duplicate of the view Events/Agenda but on the main tab)
if (!empty($conf->global->TICKET_SHOW_MESSAGES_ON_CARD)) { if (!empty($conf->global->TICKET_SHOW_MESSAGES_ON_CARD)) {
$param = '&id='.$object->id; $param = '&id='.$object->id;
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; $param .= '&contextpage='.$contextpage;
if ($actioncode) $param .= '&actioncode='.urlencode($actioncode); }
if ($search_agenda_label) $param .= '&search_agenda_label='.urlencode($search_agenda_label); if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.$limit;
}
if ($actioncode) {
$param .= '&actioncode='.urlencode($actioncode);
}
if ($search_agenda_label) {
$param .= '&search_agenda_label='.urlencode($search_agenda_label);
}
$morehtmlright = ''; $morehtmlright = '';

View File

@ -262,14 +262,15 @@ class ActionsTicket
// Load logs in cache // Load logs in cache
$ret = $this->dao->loadCacheMsgsTicket(); $ret = $this->dao->loadCacheMsgsTicket();
if ($ret < 0) dol_print_error($this->dao->db); if ($ret < 0) {
dol_print_error($this->dao->db);
}
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$this->viewTicketOriginalMessage($user, $action, $object); $this->viewTicketOriginalMessage($user, $action, $object);
if (is_array($this->dao->cache_msgs_ticket) && count($this->dao->cache_msgs_ticket) > 0) if (is_array($this->dao->cache_msgs_ticket) && count($this->dao->cache_msgs_ticket) > 0) {
{
print '<table class="border" style="width:100%;">'; print '<table class="border" style="width:100%;">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';

View File

@ -114,8 +114,7 @@ class Tickets extends DolibarrApi
{ {
try { try {
return $this->getCommon(0, '', $ref); return $this->getCommon(0, '', $ref);
} catch (Exception $e) } catch (Exception $e) {
{
throw $e; throw $e;
} }
} }

View File

@ -410,7 +410,9 @@ class Ticket extends CommonObject
// Clean parameters // Clean parameters
$this->datec = dol_now(); $this->datec = dol_now();
if (empty($this->track_id)) $this->track_id = generate_random_id(16); if (empty($this->track_id)) {
$this->track_id = generate_random_id(16);
}
// Check more parameters // Check more parameters
// If error, this->errors[] is filled // If error, this->errors[] is filled
@ -581,8 +583,7 @@ class Ticket extends CommonObject
dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
if ($this->db->num_rows($resql)) if ($this->db->num_rows($resql)) {
{
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid; $this->id = $obj->rowid;
@ -991,7 +992,9 @@ class Ticket extends CommonObject
if (!$error) { if (!$error) {
// Delete linked object // Delete linked object
$res = $this->deleteObjectLinked(); $res = $this->deleteObjectLinked();
if ($res < 0) $error++; if ($res < 0) {
$error++;
}
} }
// Removed extrafields // Removed extrafields
@ -1319,7 +1322,9 @@ class Ticket extends CommonObject
global $dolibarr_main_authentication, $dolibarr_main_demo; global $dolibarr_main_authentication, $dolibarr_main_demo;
global $menumanager; global $menumanager;
if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips if (!empty($conf->dol_no_mouse_hover)) {
$notooltip = 1; // Force disable tooltips
}
$result = ''; $result = '';
@ -1332,33 +1337,40 @@ class Ticket extends CommonObject
$url = dol_buildpath('/ticket/card.php', 1).'?id='.$this->id; $url = dol_buildpath('/ticket/card.php', 1).'?id='.$this->id;
if ($option != 'nolink') if ($option != 'nolink') {
{
// Add param to save lastsearch_values or not // Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1'; $add_save_lastsearch_values = 1;
}
if ($add_save_lastsearch_values) {
$url .= '&save_lastsearch_values=1';
}
} }
$linkclose = ''; $linkclose = '';
if (empty($notooltip)) if (empty($notooltip)) {
{ if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
$label = $langs->trans("ShowTicket"); $label = $langs->trans("ShowTicket");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
} }
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
} else $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); } else {
$linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
}
$linkstart = '<a href="'.$url.'"'; $linkstart = '<a href="'.$url.'"';
$linkstart .= $linkclose.'>'; $linkstart .= $linkclose.'>';
$linkend = '</a>'; $linkend = '</a>';
$result .= $linkstart; $result .= $linkstart;
if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); if ($withpicto) {
if ($withpicto != 2) $result .= $this->ref; $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
}
if ($withpicto != 2) {
$result .= $this->ref;
}
$result .= $linkend; $result .= $linkend;
//if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
@ -1437,8 +1449,7 @@ class Ticket extends CommonObject
$this->oldcopy = dol_clone($this); $this->oldcopy = dol_clone($this);
$sql = "UPDATE ".MAIN_DB_PREFIX."ticket"; $sql = "UPDATE ".MAIN_DB_PREFIX."ticket";
if ($id_assign_user > 0) if ($id_assign_user > 0) {
{
$sql .= " SET fk_user_assign=".$id_assign_user.", fk_statut = ".Ticket::STATUS_ASSIGNED; $sql .= " SET fk_user_assign=".$id_assign_user.", fk_statut = ".Ticket::STATUS_ASSIGNED;
} else { } else {
$sql .= " SET fk_user_assign=null, fk_statut = ".Ticket::STATUS_READ; $sql .= " SET fk_user_assign=null, fk_statut = ".Ticket::STATUS_READ;
@ -1447,8 +1458,7 @@ class Ticket extends CommonObject
dol_syslog(get_class($this)."::assignUser sql=".$sql); dol_syslog(get_class($this)."::assignUser sql=".$sql);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql) {
{
$this->fk_user_assign = $id_assign_user; // May be used by trigger $this->fk_user_assign = $id_assign_user; // May be used by trigger
if (!$notrigger) { if (!$notrigger) {
@ -1588,29 +1598,29 @@ class Ticket extends CommonObject
// TODO Read the table llx_actioncomm // TODO Read the table llx_actioncomm
/* /*
$sql = "SELECT rowid, fk_user_create, datec, message"; $sql = "SELECT rowid, fk_user_create, datec, message";
$sql .= " FROM " . MAIN_DB_PREFIX . "ticket_logs"; $sql .= " FROM " . MAIN_DB_PREFIX . "ticket_logs";
$sql .= " WHERE fk_track_id ='" . $this->db->escape($this->track_id) . "'"; $sql .= " WHERE fk_track_id ='" . $this->db->escape($this->track_id) . "'";
$sql .= " ORDER BY datec DESC"; $sql .= " ORDER BY datec DESC";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
$i = 0; $i = 0;
while ($i < $num) { while ($i < $num) {
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$this->cache_logs_ticket[$i]['id'] = $obj->rowid; $this->cache_logs_ticket[$i]['id'] = $obj->rowid;
$this->cache_logs_ticket[$i]['fk_user_create'] = $obj->fk_user_create; $this->cache_logs_ticket[$i]['fk_user_create'] = $obj->fk_user_create;
$this->cache_logs_ticket[$i]['datec'] = $this->db->jdate($obj->datec); $this->cache_logs_ticket[$i]['datec'] = $this->db->jdate($obj->datec);
$this->cache_logs_ticket[$i]['message'] = $obj->message; $this->cache_logs_ticket[$i]['message'] = $obj->message;
$i++; $i++;
} }
return $num; return $num;
} else { } else {
$this->error = "Error " . $this->db->lasterror(); $this->error = "Error " . $this->db->lasterror();
dol_syslog(get_class($this) . "::loadCacheLogsTicket " . $this->error, LOG_ERR); dol_syslog(get_class($this) . "::loadCacheLogsTicket " . $this->error, LOG_ERR);
return -1; return -1;
}*/ }*/
return 0; return 0;
} }
@ -1669,14 +1679,12 @@ class Ticket extends CommonObject
$actioncomm->attachedfiles = $attachedfiles; $actioncomm->attachedfiles = $attachedfiles;
} }
if (!empty($mimefilename_list) && is_array($mimefilename_list)) if (!empty($mimefilename_list) && is_array($mimefilename_list)) {
{
$actioncomm->note_private = dol_concatdesc($actioncomm->note_private, "\n".$langs->transnoentities("AttachedFiles").': '.join(';', $mimefilename_list)); $actioncomm->note_private = dol_concatdesc($actioncomm->note_private, "\n".$langs->transnoentities("AttachedFiles").': '.join(';', $mimefilename_list));
} }
$actionid = $actioncomm->create($user); $actionid = $actioncomm->create($user);
if ($actionid <= 0) if ($actionid <= 0) {
{
$error++; $error++;
$this->error = $actioncomm->error; $this->error = $actioncomm->error;
$this->errors = $actioncomm->errors; $this->errors = $actioncomm->errors;
@ -1760,8 +1768,7 @@ class Ticket extends CommonObject
if (!empty($conf->ficheinter->enabled) && !empty($conf->global->WORKFLOW_TICKET_CLOSE_INTERVENTION)) { if (!empty($conf->ficheinter->enabled) && !empty($conf->global->WORKFLOW_TICKET_CLOSE_INTERVENTION)) {
dol_syslog("We have closed the ticket, so we close all linked interventions"); dol_syslog("We have closed the ticket, so we close all linked interventions");
$this->fetchObjectLinked($this->id, $this->element, null, 'fichinter'); $this->fetchObjectLinked($this->id, $this->element, null, 'fichinter');
if ($this->linkedObjectsIds) if ($this->linkedObjectsIds) {
{
foreach ($this->linkedObjectsIds['fichinter'] as $fichinter_id) { foreach ($this->linkedObjectsIds['fichinter'] as $fichinter_id) {
$fichinter = new Fichinter($this->db); $fichinter = new Fichinter($this->db);
$fichinter->fetch($fichinter_id); $fichinter->fetch($fichinter_id);
@ -2148,8 +2155,7 @@ class Ticket extends CommonObject
$sendto = $obj->firstname." ".$obj->lastname." <".$obj->email.">"; $sendto = $obj->firstname." ".$obj->lastname." <".$obj->email.">";
$actiondefid = $obj->adid; $actiondefid = $obj->adid;
if (dol_strlen($sendto)) if (dol_strlen($sendto)) {
{
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$application = ($conf->global->MAIN_APPLICATION_TITLE ? $conf->global->MAIN_APPLICATION_TITLE : 'Dolibarr ERP/CRM'); $application = ($conf->global->MAIN_APPLICATION_TITLE ? $conf->global->MAIN_APPLICATION_TITLE : 'Dolibarr ERP/CRM');
@ -2465,8 +2471,7 @@ class Ticket extends CommonObject
foreach ($filename as $i => $val) { foreach ($filename as $i => $val) {
$destfile = $destdir.'/'.$filename[$i]; $destfile = $destdir.'/'.$filename[$i];
// If destination file already exists, we add a suffix to avoid to overwrite // If destination file already exists, we add a suffix to avoid to overwrite
if (is_file($destfile)) if (is_file($destfile)) {
{
$pathinfo = pathinfo($filename[$i]); $pathinfo = pathinfo($filename[$i]);
$now = dol_now(); $now = dol_now();
$destfile = $destdir.'/'.$pathinfo['filename'].' - '.dol_print_date($now, 'dayhourlog').'.'.$pathinfo['extension']; $destfile = $destdir.'/'.$pathinfo['filename'].' - '.dol_print_date($now, 'dayhourlog').'.'.$pathinfo['extension'];
@ -2626,11 +2631,10 @@ class Ticket extends CommonObject
$this->sendTicketMessageByEmail($subject, $message, '', $sendto, $listofpaths, $listofmimes, $listofnames); $this->sendTicketMessageByEmail($subject, $message, '', $sendto, $listofpaths, $listofmimes, $listofnames);
} }
} }
} } else {
/* /*
* Private area * Private area
*/ */
else {
/* /*
* Send emails to internal users (linked contacts) * Send emails to internal users (linked contacts)
*/ */
@ -2670,7 +2674,9 @@ class Ticket extends CommonObject
} }
if ($info_sendto['email'] != '') { if ($info_sendto['email'] != '') {
if (!empty($info_sendto['email'])) $sendto[] = trim($info_sendto['firstname']." ".$info_sendto['lastname'])." <".$info_sendto['email'].">"; if (!empty($info_sendto['email'])) {
$sendto[] = trim($info_sendto['firstname']." ".$info_sendto['lastname'])." <".$info_sendto['email'].">";
}
//Contact type //Contact type
$recipient = dolGetFirstLastname($info_sendto['firstname'], $info_sendto['lastname'], '-1').' ('.strtolower($info_sendto['libelle']).')'; $recipient = dolGetFirstLastname($info_sendto['firstname'], $info_sendto['lastname'], '-1').' ('.strtolower($info_sendto['libelle']).')';
@ -2686,7 +2692,9 @@ class Ticket extends CommonObject
// Add global email address recipient // Add global email address recipient
if ($conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS && !in_array($conf->global->TICKET_NOTIFICATION_EMAIL_TO, $sendto)) { if ($conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS && !in_array($conf->global->TICKET_NOTIFICATION_EMAIL_TO, $sendto)) {
if (!empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO)) $sendto[] = $conf->global->TICKET_NOTIFICATION_EMAIL_TO; if (!empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO)) {
$sendto[] = $conf->global->TICKET_NOTIFICATION_EMAIL_TO;
}
} }
// altairis: dont try to send email if no recipient // altairis: dont try to send email if no recipient
@ -2744,7 +2752,9 @@ class Ticket extends CommonObject
} }
if ($info_sendto['email'] != '' && $info_sendto['email'] != $object->origin_email) { if ($info_sendto['email'] != '' && $info_sendto['email'] != $object->origin_email) {
if (!empty($info_sendto['email'])) $sendto[] = trim($info_sendto['firstname']." ".$info_sendto['lastname'])." <".$info_sendto['email'].">"; if (!empty($info_sendto['email'])) {
$sendto[] = trim($info_sendto['firstname']." ".$info_sendto['lastname'])." <".$info_sendto['email'].">";
}
$recipient = dolGetFirstLastname($info_sendto['firstname'], $info_sendto['lastname'], '-1').' ('.strtolower($info_sendto['libelle']).')'; $recipient = dolGetFirstLastname($info_sendto['firstname'], $info_sendto['lastname'], '-1').' ('.strtolower($info_sendto['libelle']).')';
$message .= (!empty($recipient) ? $langs->trans('TicketNotificationRecipient').' : '.$recipient.'<br>' : ''); $message .= (!empty($recipient) ? $langs->trans('TicketNotificationRecipient').' : '.$recipient.'<br>' : '');
@ -2769,12 +2779,16 @@ class Ticket extends CommonObject
if ($object->fk_soc > 0 && !in_array($object->origin_email, $sendto)) { if ($object->fk_soc > 0 && !in_array($object->origin_email, $sendto)) {
$object->socid = $object->fk_soc; $object->socid = $object->fk_soc;
$object->fetch_thirdparty(); $object->fetch_thirdparty();
if (!empty($object->thirdparty->email)) $sendto[] = $object->thirdparty->email; if (!empty($object->thirdparty->email)) {
$sendto[] = $object->thirdparty->email;
}
} }
// altairis: Add global email address reciepient // altairis: Add global email address reciepient
if ($conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS && !in_array($conf->global->TICKET_NOTIFICATION_EMAIL_TO, $sendto)) { if ($conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS && !in_array($conf->global->TICKET_NOTIFICATION_EMAIL_TO, $sendto)) {
if (!empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO)) $sendto[] = $conf->global->TICKET_NOTIFICATION_EMAIL_TO; if (!empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO)) {
$sendto[] = $conf->global->TICKET_NOTIFICATION_EMAIL_TO;
}
} }
// altairis: dont try to send email when no recipient // altairis: dont try to send email when no recipient
@ -2787,8 +2801,7 @@ class Ticket extends CommonObject
} }
// Set status to "answered" if not set yet, but only if internal user // Set status to "answered" if not set yet, but only if internal user
if ($object->fk_statut < 3 && !$user->socid) if ($object->fk_statut < 3 && !$user->socid) {
{
$object->setStatut(3); $object->setStatut(3);
} }
@ -2842,8 +2855,7 @@ class Ticket extends CommonObject
$from = $conf->global->TICKET_NOTIFICATION_EMAIL_FROM; $from = $conf->global->TICKET_NOTIFICATION_EMAIL_FROM;
if (is_array($array_receiver) && count($array_receiver) > 0) { if (is_array($array_receiver) && count($array_receiver) > 0) {
foreach ($array_receiver as $key => $receiver) foreach ($array_receiver as $key => $receiver) {
{
$deliveryreceipt = 0; $deliveryreceipt = 0;
$filepath = $filename_list; $filepath = $filename_list;
$filename = $mimefilename_list; $filename = $mimefilename_list;
@ -2903,19 +2915,21 @@ class Ticket extends CommonObject
$sql = "SELECT p.rowid, p.ref, p.datec as datec"; $sql = "SELECT p.rowid, p.ref, p.datec as datec";
$sql .= " FROM ".MAIN_DB_PREFIX."ticket as p"; $sql .= " FROM ".MAIN_DB_PREFIX."ticket as p";
if (!$user->rights->societe->client->voir && !$user->socid) if (!$user->rights->societe->client->voir && !$user->socid) {
{
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON p.fk_soc = sc.fk_soc"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON p.fk_soc = sc.fk_soc";
$sql .= " WHERE sc.fk_user = ".$user->id; $sql .= " WHERE sc.fk_user = ".$user->id;
$clause = " AND"; $clause = " AND";
} }
$sql .= $clause." p.entity IN (".getEntity('ticket').")"; $sql .= $clause." p.entity IN (".getEntity('ticket').")";
if ($mode == 'opened') $sql .= " AND p.fk_statut NOT IN (".Ticket::STATUS_CLOSED.", ".Ticket::STATUS_CANCELED.")"; if ($mode == 'opened') {
if ($user->socid) $sql .= " AND p.fk_soc = ".$user->socid; $sql .= " AND p.fk_statut NOT IN (".Ticket::STATUS_CLOSED.", ".Ticket::STATUS_CANCELED.")";
}
if ($user->socid) {
$sql .= " AND p.fk_soc = ".$user->socid;
}
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql) {
{
$label = $labelShort = ''; $label = $labelShort = '';
$status = ''; $status = '';
if ($mode == 'opened') { if ($mode == 'opened') {
@ -2934,14 +2948,11 @@ class Ticket extends CommonObject
$response->img = img_object('', "ticket"); $response->img = img_object('', "ticket");
// This assignment in condition is not a bug. It allows walking the results. // This assignment in condition is not a bug. It allows walking the results.
while ($obj = $this->db->fetch_object($resql)) while ($obj = $this->db->fetch_object($resql)) {
{
$response->nbtodo++; $response->nbtodo++;
if ($mode == 'opened') if ($mode == 'opened') {
{
$datelimit = $this->db->jdate($obj->datefin); $datelimit = $this->db->jdate($obj->datefin);
if ($datelimit < ($now - $delay_warning)) if ($datelimit < ($now - $delay_warning)) {
{
//$response->nbtodolate++; //$response->nbtodolate++;
} }
} }
@ -2970,8 +2981,7 @@ class Ticket extends CommonObject
$sql = "SELECT count(p.rowid) as nb"; $sql = "SELECT count(p.rowid) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."ticket as p"; $sql .= " FROM ".MAIN_DB_PREFIX."ticket as p";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON p.fk_soc = s.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON p.fk_soc = s.rowid";
if (!$user->rights->societe->client->voir && !$user->socid) if (!$user->rights->societe->client->voir && !$user->socid) {
{
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON s.rowid = sc.fk_soc";
$sql .= " WHERE sc.fk_user = ".$user->id; $sql .= " WHERE sc.fk_user = ".$user->id;
$clause = "AND"; $clause = "AND";
@ -2979,11 +2989,9 @@ class Ticket extends CommonObject
$sql .= " ".$clause." p.entity IN (".getEntity('ticket').")"; $sql .= " ".$clause." p.entity IN (".getEntity('ticket').")";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql) {
{
// This assignment in condition is not a bug. It allows walking the results. // This assignment in condition is not a bug. It allows walking the results.
while ($obj = $this->db->fetch_object($resql)) while ($obj = $this->db->fetch_object($resql)) {
{
$this->nb["ticket"] = $obj->nb; $this->nb["ticket"] = $obj->nb;
} }
$this->db->free($resql); $this->db->free($resql);

View File

@ -78,8 +78,7 @@ class Diff
} }
$end2 = ($compareCharacters ? strlen($sequence1) : count($sequence1)); $end2 = ($compareCharacters ? strlen($sequence1) : count($sequence1));
for ($index = $end1 + 1; $index < $end2; $index++) for ($index = $end1 + 1; $index < $end2; $index++) {
{
$diff[] = array($sequence1[$index], self::UNMODIFIED); $diff[] = array($sequence1[$index], self::UNMODIFIED);
} }
@ -313,12 +312,12 @@ class Diff
self::DELETED self::DELETED
); );
$rightCell = self::getCellContent( $rightCell = self::getCellContent(
$diff, $diff,
$indentation, $indentation,
$separator, $separator,
$index, $index,
self::INSERTED self::INSERTED
); );
break; break;
// display the inserted content on the right // display the inserted content on the right

View File

@ -124,8 +124,7 @@ $contactstatic = new Contact($db);
$userstatic = new User($db); $userstatic = new User($db);
if ($id > 0 || !empty($track_id) || !empty($ref)) { if ($id > 0 || !empty($track_id) || !empty($ref)) {
if ($object->fetch($id, $ref, $track_id) > 0) if ($object->fetch($id, $ref, $track_id) > 0) {
{
if ($socid > 0) { if ($socid > 0) {
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$head = societe_prepare_head($object->thirdparty); $head = societe_prepare_head($object->thirdparty);
@ -161,12 +160,11 @@ if ($id > 0 || !empty($track_id) || !empty($ref)) {
} }
// Thirdparty // Thirdparty
if (!empty($conf->societe->enabled)) if (!empty($conf->societe->enabled)) {
{
$morehtmlref .= '<br>'.$langs->trans('ThirdParty'); $morehtmlref .= '<br>'.$langs->trans('ThirdParty');
/*if ($action != 'editcustomer' && $object->fk_statut < 8 && !$user->socid && $user->rights->ticket->write) { /*if ($action != 'editcustomer' && $object->fk_statut < 8 && !$user->socid && $user->rights->ticket->write) {
$morehtmlref.='<a class="editfielda" href="' . $url_page_current . '?action=editcustomer&amp;track_id=' . $object->track_id . '">' . img_edit($langs->transnoentitiesnoconv('Edit'), 1) . '</a>'; $morehtmlref.='<a class="editfielda" href="' . $url_page_current . '?action=editcustomer&amp;track_id=' . $object->track_id . '">' . img_edit($langs->transnoentitiesnoconv('Edit'), 1) . '</a>';
}*/ }*/
$morehtmlref .= ' : '; $morehtmlref .= ' : ';
if ($action == 'editcustomer') { if ($action == 'editcustomer') {
$morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, $object->socid, 'editcustomer', '', 1, 0, 0, array(), 1); $morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, $object->socid, 'editcustomer', '', 1, 0, 0, array(), 1);
@ -176,12 +174,10 @@ if ($id > 0 || !empty($track_id) || !empty($ref)) {
} }
// Project // Project
if (!empty($conf->projet->enabled)) if (!empty($conf->projet->enabled)) {
{
$langs->load("projects"); $langs->load("projects");
$morehtmlref .= '<br>'.$langs->trans('Project').' '; $morehtmlref .= '<br>'.$langs->trans('Project').' ';
if ($user->rights->ticket->write) if ($user->rights->ticket->write) {
{
if ($action != 'classify') { if ($action != 'classify') {
//$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a>'; //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a>';
$morehtmlref .= ' : '; $morehtmlref .= ' : ';

View File

@ -22,14 +22,26 @@
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled because need to load personalized language //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled because need to load personalized language
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled to increase speed. Language code is found on url. //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Not disabled to increase speed. Language code is found on url.
if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); if (!defined('NOREQUIRESOC')) {
define('NOREQUIRESOC', '1');
}
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled because need to do translations //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled because need to do translations
if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1); if (!defined('NOCSRFCHECK')) {
if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); define('NOCSRFCHECK', 1);
if (!defined('NOLOGIN')) define('NOLOGIN', 1); // File must be accessed by logon page so without login }
if (!defined('NOTOKENRENEWAL')) {
define('NOTOKENRENEWAL', 1);
}
if (!defined('NOLOGIN')) {
define('NOLOGIN', 1); // File must be accessed by logon page so without login
}
//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1); // We need top menu content //if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1); // We need top menu content
if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1); if (!defined('NOREQUIREHTML')) {
if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); define('NOREQUIREHTML', 1);
}
if (!defined('NOREQUIREAJAX')) {
define('NOREQUIREAJAX', '1');
}
session_cache_limiter('public'); session_cache_limiter('public');
@ -39,13 +51,16 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
// Define css type // Define css type
top_httphead('text/css'); top_httphead('text/css');
// Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access. // Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access.
if (empty($dolibarr_nocache)) header('Cache-Control: max-age=3600, public, must-revalidate'); if (empty($dolibarr_nocache)) {
else header('Cache-Control: no-cache'); header('Cache-Control: max-age=3600, public, must-revalidate');
} else {
header('Cache-Control: no-cache');
}
?> ?>
html { html {
min-height: 100%; height: 100%; min-height: 100%; height: 100%;
} }
html { html {
@ -58,49 +73,49 @@ if (!empty($conf->global->TICKET_SHOW_MODULE_LOGO)) {
div.ticketform { div.ticketform {
font-family: arial; font-family: arial;
position: static; position: static;
padding: 2em 1em; padding: 2em 1em;
overflow-x: auto; overflow-x: auto;
border: 2px solid rgb(153, 153, 153); border: 2px solid rgb(153, 153, 153);
background-color: rgb(255, 255, 255); background-color: rgb(255, 255, 255);
box-shadow: 2px 2px 2px rgb(245, 245, 245); box-shadow: 2px 2px 2px rgb(245, 245, 245);
border-radius: 10px 10px 10px 10px; border-radius: 10px 10px 10px 10px;
margin: 1.5em; margin: 1.5em;
background : #ffffff; background : #ffffff;
text-align: center; text-align: center;
} }
div.ticketform .index_create, .index_display { div.ticketform .index_create, .index_display {
display: inline-block; display: inline-block;
width: 200px; width: 200px;
height: 45px; height: 45px;
text-align: center; text-align: center;
vertical-align: middle; vertical-align: middle;
margin: 20px; margin: 20px;
text-transform: uppercase; text-transform: uppercase;
} }
#form_create_ticket, #form_view_ticket #form_create_ticket, #form_view_ticket
{ {
margin-left: 10px; margin-left: 10px;
margin-right: 10px; margin-right: 10px;
padding-left:1em; padding-left:1em;
padding-right:1em; padding-right:1em;
padding-top:1.5em; padding-top:1.5em;
padding-bottom:12px; padding-bottom:12px;
border: 1px solid #C0C0C0; border: 1px solid #C0C0C0;
background-color: #E0E0E0; background-color: #E0E0E0;
-moz-box-shadow: 4px 4px 4px #DDD; -moz-box-shadow: 4px 4px 4px #DDD;
-webkit-box-shadow: 4px 4px 4px #DDD; -webkit-box-shadow: 4px 4px 4px #DDD;
box-shadow: 4px 4px 4px #DDD; box-shadow: 4px 4px 4px #DDD;
border-radius: 8px; border-radius: 8px;
border:solid 1px rgba(168,168,168,.4); border:solid 1px rgba(168,168,168,.4);
border-top:solid 1px f8f8f8; border-top:solid 1px f8f8f8;
background-color: #f8f8f8; background-color: #f8f8f8;
} }
#form_create_ticket input.text, #form_create_ticket textarea { width:450px;} #form_create_ticket input.text, #form_create_ticket textarea { width:450px;}

View File

@ -52,12 +52,18 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (!$sortorder) $sortorder = "ASC"; if (!$sortorder) {
if (!$sortfield) $sortfield = "position_name"; $sortorder = "ASC";
}
if (!$sortfield) {
$sortfield = "position_name";
}
$object = new Ticket($db); $object = new Ticket($db);
$result = $object->fetch($id, $ref, $track_id); $result = $object->fetch($id, $ref, $track_id);
@ -86,8 +92,7 @@ $form = new Form($db);
$help_url = ''; $help_url = '';
llxHeader('', $langs->trans("TicketDocumentsLinked").' - '.$langs->trans("Files"), $help_url); llxHeader('', $langs->trans("TicketDocumentsLinked").' - '.$langs->trans("Files"), $help_url);
if ($object->id) if ($object->id) {
{
/* /*
* Show tabs * Show tabs
*/ */
@ -126,12 +131,11 @@ if ($object->id)
} }
// Thirdparty // Thirdparty
if (!empty($conf->societe->enabled)) if (!empty($conf->societe->enabled)) {
{
$morehtmlref .= '<br>'.$langs->trans('ThirdParty'); $morehtmlref .= '<br>'.$langs->trans('ThirdParty');
/*if ($action != 'editcustomer' && $object->fk_statut < 8 && !$user->socid && $user->rights->ticket->write) { /*if ($action != 'editcustomer' && $object->fk_statut < 8 && !$user->socid && $user->rights->ticket->write) {
$morehtmlref.='<a class="editfielda" href="' . $url_page_current . '?action=editcustomer&amp;track_id=' . $object->track_id . '">' . img_edit($langs->transnoentitiesnoconv('Edit'), 1) . '</a>'; $morehtmlref.='<a class="editfielda" href="' . $url_page_current . '?action=editcustomer&amp;track_id=' . $object->track_id . '">' . img_edit($langs->transnoentitiesnoconv('Edit'), 1) . '</a>';
}*/ }*/
$morehtmlref .= ' : '; $morehtmlref .= ' : ';
if ($action == 'editcustomer') { if ($action == 'editcustomer') {
$morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, $object->socid, 'editcustomer', '', 1, 0, 0, array(), 1); $morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, $object->socid, 'editcustomer', '', 1, 0, 0, array(), 1);
@ -141,12 +145,10 @@ if ($object->id)
} }
// Project // Project
if (!empty($conf->projet->enabled)) if (!empty($conf->projet->enabled)) {
{
$langs->load("projects"); $langs->load("projects");
$morehtmlref .= '<br>'.$langs->trans('Project').' '; $morehtmlref .= '<br>'.$langs->trans('Project').' ';
if ($user->rights->ticket->write) if ($user->rights->ticket->write) {
{
if ($action != 'classify') { if ($action != 'classify') {
//$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a>'; //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a>';
$morehtmlref .= ' : '; $morehtmlref .= ' : ';
@ -190,11 +192,11 @@ if ($object->id)
//$object->ref = $object->track_id; // For compatibility we use track ID for directory //$object->ref = $object->track_id; // For compatibility we use track ID for directory
$modulepart = 'ticket'; $modulepart = 'ticket';
$permission = $user->rights->ticket->write; $permission = $user->rights->ticket->write;
$permtoedit = $user->rights->ticket->write; $permtoedit = $user->rights->ticket->write;
$param = '&id='.$object->id; $param = '&id='.$object->id;
include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
} else { } else {
accessforbidden('', 0, 1); accessforbidden('', 0, 1);
} }

View File

@ -72,7 +72,9 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma'); $sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) {
$page = 0;
} // If $page is not defined, or '' or -1 or if we click on clear filters
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
@ -81,32 +83,44 @@ $pagenext = $page + 1;
$object = new Ticket($db); $object = new Ticket($db);
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
$diroutputmassaction = $conf->ticket->dir_output.'/temp/massgeneration/'.$user->id; $diroutputmassaction = $conf->ticket->dir_output.'/temp/massgeneration/'.$user->id;
if ($socid > 0) $hookmanager->initHooks(array('thirdpartyticket')); if ($socid > 0) {
elseif ($projectid > 0) $hookmanager->initHooks(array('projectticket')); $hookmanager->initHooks(array('thirdpartyticket'));
else $hookmanager->initHooks(array('ticketlist')); } elseif ($projectid > 0) {
$hookmanager->initHooks(array('projectticket'));
} else {
$hookmanager->initHooks(array('ticketlist'));
}
// Fetch optionals attributes and labels // Fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element); $extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
// Default sort order (if not yet defined by previous GETPOST) // Default sort order (if not yet defined by previous GETPOST)
if (!$sortfield) $sortfield = "t.datec"; if (!$sortfield) {
if (!$sortorder) $sortorder = "DESC"; $sortfield = "t.datec";
}
if (!$sortorder) {
$sortorder = "DESC";
}
if (GETPOST('search_fk_status', 'alpha') == 'non_closed') $_GET['search_fk_statut'][] = 'openall'; // For backward compatibility if (GETPOST('search_fk_status', 'alpha') == 'non_closed') {
$_GET['search_fk_statut'][] = 'openall'; // For backward compatibility
}
// Initialize array of search criterias // Initialize array of search criterias
$search_all = trim(GETPOSTISSET("search_all") ?GETPOSTISSET("search_all", 'alpha') : GETPOST('sall')); $search_all = trim(GETPOSTISSET("search_all") ?GETPOSTISSET("search_all", 'alpha') : GETPOST('sall'));
$search = array(); $search = array();
foreach ($object->fields as $key => $val) foreach ($object->fields as $key => $val) {
{ if (GETPOST('search_'.$key, 'alpha')) {
if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha'); $search[$key] = GETPOST('search_'.$key, 'alpha');
}
} }
// List of fields to search into when doing a "search in all" // List of fields to search into when doing a "search in all"
$fieldstosearchall = array(); $fieldstosearchall = array();
foreach ($object->fields as $key => $val) foreach ($object->fields as $key => $val) {
{ if ($val['searchall']) {
if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; $fieldstosearchall['t.'.$key] = $val['label'];
}
} }
$fieldstosearchall['s.name_alias'] = "AliasNameShort"; $fieldstosearchall['s.name_alias'] = "AliasNameShort";
$fieldstosearchall['s.zip'] = "Zip"; $fieldstosearchall['s.zip'] = "Zip";
@ -114,10 +128,11 @@ $fieldstosearchall['s.town'] = "Town";
// Definition of fields for list // Definition of fields for list
$arrayfields = array(); $arrayfields = array();
foreach ($object->fields as $key => $val) foreach ($object->fields as $key => $val) {
{
// If $val['visible']==0, then we never show the field // If $val['visible']==0, then we never show the field
if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); if (!empty($val['visible'])) {
$arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']);
}
} }
// Extra fields // Extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
@ -136,8 +151,7 @@ if (!$user->rights->ticket->read) {
// Store current page url // Store current page url
$url_page_current = dol_buildpath('/ticket/list.php', 1); $url_page_current = dol_buildpath('/ticket/list.php', 1);
if ($project_ref) if ($project_ref) {
{
$tmpproject = new Project($db); $tmpproject = new Project($db);
$tmpproject->fetch(0, $project_ref); $tmpproject->fetch(0, $project_ref);
$projectid = $tmpproject->id; $projectid = $tmpproject->id;
@ -155,25 +169,32 @@ $error = 0;
* Actions * Actions
*/ */
if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } if (GETPOST('cancel', 'alpha')) {
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } $action = 'list'; $massaction = '';
}
if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
$massaction = '';
}
$parameters = array(); $parameters = array();
if ($socid > 0) $parameters['socid'] = $socid; if ($socid > 0) {
if ($projectid > 0) $parameters['projectid'] = $projectid; $parameters['socid'] = $socid;
}
if ($projectid > 0) {
$parameters['projectid'] = $projectid;
}
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $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 ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) if (empty($reshook)) {
{
// Selection of new fields // Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria // 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 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
{ foreach ($object->fields as $key => $val) {
foreach ($object->fields as $key => $val)
{
$search[$key] = ''; $search[$key] = '';
} }
$toselect = ''; $toselect = '';
@ -186,8 +207,7 @@ if (empty($reshook))
$search_dateclose_end = ''; $search_dateclose_end = '';
} }
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
|| GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
{
$massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
} }
@ -198,26 +218,23 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
// Close records // Close records
if (!$error && $massaction == 'close' && $permissiontoadd) if (!$error && $massaction == 'close' && $permissiontoadd) {
{
$objecttmp = new $objectclass($db); $objecttmp = new $objectclass($db);
if (!$error) if (!$error) {
{
$db->begin(); $db->begin();
$nbok = 0; $nbok = 0;
foreach ($toselect as $toselectid) foreach ($toselect as $toselectid) {
{
$result = $objecttmp->fetch($toselectid); $result = $objecttmp->fetch($toselectid);
if ($result > 0) if ($result > 0) {
{
$result = $objecttmp->close($user); $result = $objecttmp->close($user);
if ($result < 0) if ($result < 0) {
{
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
$error++; $error++;
break; break;
} else $nbok++; } else {
$nbok++;
}
} else { } else {
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
$error++; $error++;
@ -225,10 +242,12 @@ if (empty($reshook))
} }
} }
if (!$error) if (!$error) {
{ if ($nbok > 1) {
if ($nbok > 1) setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
else setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); } else {
setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
}
$db->commit(); $db->commit();
} else { } else {
$db->rollback(); $db->rollback();
@ -238,27 +257,24 @@ if (empty($reshook))
} }
// Reopen records // Reopen records
if (!$error && $massaction == 'reopen' && $permissiontoadd) if (!$error && $massaction == 'reopen' && $permissiontoadd) {
{
$objecttmp = new $objectclass($db); $objecttmp = new $objectclass($db);
if (!$error) if (!$error) {
{
$db->begin(); $db->begin();
$nbok = 0; $nbok = 0;
foreach ($toselect as $toselectid) foreach ($toselect as $toselectid) {
{
$result = $objecttmp->fetch($toselectid); $result = $objecttmp->fetch($toselectid);
if ($result > 0) if ($result > 0) {
{
if ($objecttmp->status == Ticket::STATUS_CLOSED || $objecttmp->status == Ticket::STATUS_CANCELED) { if ($objecttmp->status == Ticket::STATUS_CLOSED || $objecttmp->status == Ticket::STATUS_CANCELED) {
$result = $objecttmp->setStatut(Ticket::STATUS_ASSIGNED); $result = $objecttmp->setStatut(Ticket::STATUS_ASSIGNED);
if ($result < 0) if ($result < 0) {
{
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
$error++; $error++;
break; break;
} else $nbok++; } else {
$nbok++;
}
} else { } else {
$langs->load("errors"); $langs->load("errors");
setEventMessages($langs->trans("ErrorObjectMustHaveStatusClosedToBeReOpened", $objecttmp->ref), null, 'errors'); setEventMessages($langs->trans("ErrorObjectMustHaveStatusClosedToBeReOpened", $objecttmp->ref), null, 'errors');
@ -272,10 +288,12 @@ if (empty($reshook))
} }
} }
if (!$error) if (!$error) {
{ if ($nbok > 1) {
if ($nbok > 1) setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
else setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs'); } else {
setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
}
$db->commit(); $db->commit();
} else { } else {
$db->rollback(); $db->rollback();
@ -307,34 +325,37 @@ $title = $langs->trans('TicketList');
// Build and execute select // Build and execute select
// -------------------------------------------------------------------- // --------------------------------------------------------------------
$sql = 'SELECT '; $sql = 'SELECT ';
foreach ($object->fields as $key => $val) foreach ($object->fields as $key => $val) {
{
$sql .= 't.'.$key.', '; $sql .= 't.'.$key.', ';
} }
// Add fields from extrafields // Add fields from extrafields
if (!empty($extrafields->attributes[$object->table_element]['label'])) if (!empty($extrafields->attributes[$object->table_element]['label'])) {
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
$sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : '');
}
}
// Add fields from hooks // Add fields from hooks
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint; $sql .= $hookmanager->resPrint;
$sql = preg_replace('/, $/', '', $sql); $sql = preg_replace('/, $/', '', $sql);
$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
}
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON (t.fk_soc = s.rowid)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON (t.fk_soc = s.rowid)";
$sql .= " WHERE t.entity IN (".getEntity($object->element).")"; $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
if ($socid > 0) if ($socid > 0) {
{
$sql .= " AND t.fk_soc = ".$socid; $sql .= " AND t.fk_soc = ".$socid;
} }
foreach ($search as $key => $val) foreach ($search as $key => $val) {
{ if ($key == 'fk_statut' && !empty($search['fk_statut'])) {
if ($key == 'fk_statut' && !empty($search['fk_statut']))
{
$newarrayofstatus = array(); $newarrayofstatus = array();
foreach ($search['fk_statut'] as $key2 => $val2) { foreach ($search['fk_statut'] as $key2 => $val2) {
if (in_array($val2, array('openall', 'closeall'))) continue; if (in_array($val2, array('openall', 'closeall'))) {
continue;
}
$newarrayofstatus[] = $val2; $newarrayofstatus[] = $val2;
} }
if ($search['fk_statut'] == 'openall' || in_array('openall', $search['fk_statut'])) { if ($search['fk_statut'] == 'openall' || in_array('openall', $search['fk_statut'])) {
@ -349,31 +370,54 @@ foreach ($search as $key => $val)
$newarrayofstatus[] = Ticket::STATUS_CLOSED; $newarrayofstatus[] = Ticket::STATUS_CLOSED;
$newarrayofstatus[] = Ticket::STATUS_CANCELED; $newarrayofstatus[] = Ticket::STATUS_CANCELED;
} }
if (count($newarrayofstatus)) $sql .= natural_search($key, join(',', $newarrayofstatus), 2); if (count($newarrayofstatus)) {
$sql .= natural_search($key, join(',', $newarrayofstatus), 2);
}
continue; continue;
} }
if ($key == 'fk_user_assign' || $key == 'fk_user_create' || $key == 'fk_project') if ($key == 'fk_user_assign' || $key == 'fk_user_create' || $key == 'fk_project') {
{ if ($search[$key] > 0) {
if ($search[$key] > 0) $sql .= natural_search($key, $search[$key], 2); $sql .= natural_search($key, $search[$key], 2);
}
continue; continue;
} }
$mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
if ($search[$key] != '') $sql .= natural_search($key, $search[$key], $mode_search); if ($search[$key] != '') {
$sql .= natural_search($key, $search[$key], $mode_search);
}
}
if ($search_all) {
$sql .= natural_search(array_keys($fieldstosearchall), $search_all);
}
if ($search_societe) {
$sql .= natural_search('s.nom', $search_societe);
} }
if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
if ($search_societe) $sql .= natural_search('s.nom', $search_societe);
//if ($search_fk_project) $sql .= natural_search('fk_project', $search_fk_project, 2); //if ($search_fk_project) $sql .= natural_search('fk_project', $search_fk_project, 2);
if ($search_date_start) $sql .= " AND t.datec >= '".$db->idate($search_date_start)."'"; if ($search_date_start) {
if ($search_date_end) $sql .= " AND t.datec <= '".$db->idate($search_date_end)."'"; $sql .= " AND t.datec >= '".$db->idate($search_date_start)."'";
if ($search_dateread_start) $sql .= " AND t.date_read >= '".$db->idate($search_dateread_start)."'"; }
if ($search_dateread_end) $sql .= " AND t.date_read <= '".$db->idate($search_dateread_end)."'"; if ($search_date_end) {
if ($search_dateclose_start) $sql .= " AND t.date_close >= '".$db->idate($search_dateclose_start)."'"; $sql .= " AND t.datec <= '".$db->idate($search_date_end)."'";
if ($search_dateclose_end) $sql .= " AND t.date_close <= '".$db->idate($search_dateclose_end)."'"; }
if ($search_dateread_start) {
$sql .= " AND t.date_read >= '".$db->idate($search_dateread_start)."'";
}
if ($search_dateread_end) {
$sql .= " AND t.date_read <= '".$db->idate($search_dateread_end)."'";
}
if ($search_dateclose_start) {
$sql .= " AND t.date_close >= '".$db->idate($search_dateclose_start)."'";
}
if ($search_dateclose_end) {
$sql .= " AND t.date_close <= '".$db->idate($search_dateclose_end)."'";
}
if (!$user->socid && ($mode == "mine" || (!$user->admin && $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY))) { if (!$user->socid && ($mode == "mine" || (!$user->admin && $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY))) {
$sql .= " AND (t.fk_user_assign = ".$user->id; $sql .= " AND (t.fk_user_assign = ".$user->id;
if (empty($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY)) $sql .= " OR t.fk_user_create = ".$user->id; if (empty($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY)) {
$sql .= " OR t.fk_user_create = ".$user->id;
}
$sql .= ")"; $sql .= ")";
} }
@ -388,26 +432,22 @@ $sql .= $db->order($sortfield, $sortorder);
// Count total nb of records // Count total nb of records
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
{
$resql = $db->query($sql); $resql = $db->query($sql);
$nbtotalofrecords = $db->num_rows($resql); $nbtotalofrecords = $db->num_rows($resql);
if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
{
$page = 0; $page = 0;
$offset = 0; $offset = 0;
} }
} }
// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) {
{
$num = $nbtotalofrecords; $num = $nbtotalofrecords;
} else { } else {
$sql .= $db->plimit($limit + 1, $offset); $sql .= $db->plimit($limit + 1, $offset);
$resql = $db->query($sql); $resql = $db->query($sql);
if (!$resql) if (!$resql) {
{
dol_print_error($db); dol_print_error($db);
exit; exit;
} }
@ -416,8 +456,7 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords)
} }
// Direct jump if only one record found // Direct jump if only one record found
if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$id = $obj->rowid; $id = $obj->rowid;
header("Location: ".DOL_URL_ROOT.'/ticket/card.php?id='.$id); header("Location: ".DOL_URL_ROOT.'/ticket/card.php?id='.$id);
@ -449,30 +488,30 @@ if ($socid && !$projectid && !$project_ref && $user->rights->societe->lire) {
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent tableforfield">'; print '<table class="border centpercent tableforfield">';
// Customer code // Customer code
if ($socstat->client && !empty($socstat->code_client)) { if ($socstat->client && !empty($socstat->code_client)) {
print '<tr><td class="titlefield">'; print '<tr><td class="titlefield">';
print $langs->trans('CustomerCode').'</td><td>'; print $langs->trans('CustomerCode').'</td><td>';
print $socstat->code_client; print $socstat->code_client;
$tmpcheck = $socstat->check_codeclient(); $tmpcheck = $socstat->check_codeclient();
if ($tmpcheck != 0 && $tmpcheck != -5) { if ($tmpcheck != 0 && $tmpcheck != -5) {
print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>'; print ' <font class="error">('.$langs->trans("WrongCustomerCode").')</font>';
} }
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
// Supplier code // Supplier code
if ($socstat->fournisseur && !empty($socstat->code_fournisseur)) { if ($socstat->fournisseur && !empty($socstat->code_fournisseur)) {
print '<tr><td class="titlefield">'; print '<tr><td class="titlefield">';
print $langs->trans('SupplierCode').'</td><td>'; print $langs->trans('SupplierCode').'</td><td>';
print $socstat->code_fournisseur; print $socstat->code_fournisseur;
$tmpcheck = $socstat->check_codefournisseur(); $tmpcheck = $socstat->check_codefournisseur();
if ($tmpcheck != 0 && $tmpcheck != -5) { if ($tmpcheck != 0 && $tmpcheck != -5) {
print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>'; print ' <font class="error">('.$langs->trans("WrongSupplierCode").')</font>';
} }
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
print '</table>'; print '</table>';
print '</div>'; print '</div>';
@ -506,15 +545,13 @@ if ($projectid > 0 || $project_ref) {
// Title // Title
$morehtmlref .= $object->title; $morehtmlref .= $object->title;
// Thirdparty // Thirdparty
if ($object->thirdparty->id > 0) if ($object->thirdparty->id > 0) {
{
$morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project'); $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'project');
} }
$morehtmlref .= '</div>'; $morehtmlref .= '</div>';
// Define a complementary filter for search of next/prev ref. // Define a complementary filter for search of next/prev ref.
if (!$user->rights->projet->all->lire) if (!$user->rights->projet->all->lire) {
{
$objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0); $objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
$object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")"; $object->next_prev_filter = " rowid in (".(count($objectsListId) ?join(',', array_keys($objectsListId)) : '0').")";
} }
@ -549,39 +586,75 @@ if ($projectid > 0 || $project_ref) {
$arrayofselected = is_array($toselect) ? $toselect : array(); $arrayofselected = is_array($toselect) ? $toselect : array();
$param = ''; $param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); $param .= '&contextpage='.urlencode($contextpage);
foreach ($search as $key => $val) }
{ if ($limit > 0 && $limit != $conf->liste_limit) {
if (is_array($search[$key]) && count($search[$key])) foreach ($search[$key] as $skey) $param .= '&search_'.$key.'[]='.urlencode($skey); $param .= '&limit='.urlencode($limit);
else $param .= '&search_'.$key.'='.urlencode($search[$key]); }
foreach ($search as $key => $val) {
if (is_array($search[$key]) && count($search[$key])) {
foreach ($search[$key] as $skey) {
$param .= '&search_'.$key.'[]='.urlencode($skey);
}
} else {
$param .= '&search_'.$key.'='.urlencode($search[$key]);
}
}
if ($optioncss != '') {
$param .= '&optioncss='.urlencode($optioncss);
} }
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
// Add $param from extra fields // Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
if ($socid) $param .= '&socid='.urlencode($socid); if ($socid) {
if ($projectid) $param .= '&projectid='.urlencode($projectid); $param .= '&socid='.urlencode($socid);
}
if ($projectid) {
$param .= '&projectid='.urlencode($projectid);
}
if ($search_date_start) $param .= '&search_date_start='.urlencode($search_date_start); if ($search_date_start) {
if ($search_date_end) $param .= '&search_date_end='.urlencode($search_date_end); $param .= '&search_date_start='.urlencode($search_date_start);
if ($search_dateread_start) $param .= '&search_dateread_start='.urlencode($search_dateread_start); }
if ($search_dateread_end) $param .= '&search_dateread_end='.urlencode($search_dateread_end); if ($search_date_end) {
if ($search_dateclose_start) $param .= '&search_dateclose_start='.urlencode($search_dateclose_start); $param .= '&search_date_end='.urlencode($search_date_end);
if ($search_dateclose_end) $param .= '&search_dateclose_end='.urlencode($search_dateclose_end); }
if ($search_dateread_start) {
$param .= '&search_dateread_start='.urlencode($search_dateread_start);
}
if ($search_dateread_end) {
$param .= '&search_dateread_end='.urlencode($search_dateread_end);
}
if ($search_dateclose_start) {
$param .= '&search_dateclose_start='.urlencode($search_dateclose_start);
}
if ($search_dateclose_end) {
$param .= '&search_dateclose_end='.urlencode($search_dateclose_end);
}
// List of mass actions available // List of mass actions available
$arrayofmassactions = array( $arrayofmassactions = array(
//'presend'=>$langs->trans("SendByMail"), //'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"), //'builddoc'=>$langs->trans("PDFMerge"),
); );
if ($user->rights->ticket->write) $arrayofmassactions['close'] = $langs->trans("Close"); if ($user->rights->ticket->write) {
if ($user->rights->ticket->write) $arrayofmassactions['reopen'] = $langs->trans("ReOpen"); $arrayofmassactions['close'] = $langs->trans("Close");
if ($user->rights->ticket->delete) $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete"); }
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); if ($user->rights->ticket->write) {
$arrayofmassactions['reopen'] = $langs->trans("ReOpen");
}
if ($user->rights->ticket->delete) {
$arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
}
if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
$arrayofmassactions = array();
}
$massactionbutton = $form->selectMassAction('', $arrayofmassactions); $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">'; if ($optioncss != '') {
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
}
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">'; print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">'; print '<input type="hidden" name="action" value="list">';
@ -589,15 +662,23 @@ print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">'; print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">'; print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
print '<input type="hidden" name="mode" value="'.$mode.'" >'; print '<input type="hidden" name="mode" value="'.$mode.'" >';
if ($socid) print '<input type="hidden" name="socid" value="'.$socid.'" >'; if ($socid) {
if ($projectid) print '<input type="hidden" name="projectid" value="'.$projectid.'" >'; print '<input type="hidden" name="socid" value="'.$socid.'" >';
}
if ($projectid) {
print '<input type="hidden" name="projectid" value="'.$projectid.'" >';
}
$url = DOL_URL_ROOT.'/ticket/card.php?action=create'.($socid ? '&socid='.$socid : '').($projectid ? '&origin=projet_project&originid='.$projectid : ''); $url = DOL_URL_ROOT.'/ticket/card.php?action=create'.($socid ? '&socid='.$socid : '').($projectid ? '&origin=projet_project&originid='.$projectid : '');
if (!empty($socid)) $url .= '&socid='.$socid; if (!empty($socid)) {
$url .= '&socid='.$socid;
}
$newcardbutton = dolGetButtonTitle($langs->trans('NewTicket'), '', 'fa fa-plus-circle', $url, '', $user->rights->ticket->write); $newcardbutton = dolGetButtonTitle($langs->trans('NewTicket'), '', 'fa fa-plus-circle', $url, '', $user->rights->ticket->write);
$picto = 'ticket'; $picto = 'ticket';
if ($socid > 0) $picto = ''; if ($socid > 0) {
$picto = '';
}
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $picto, 0, $newcardbutton, '', $limit, 0, 0, 1); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $picto, 0, $newcardbutton, '', $limit, 0, 0, 1);
@ -611,9 +692,10 @@ $objecttmp = new Ticket($db);
$trackid = 'tic'.$object->id; $trackid = 'tic'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
if ($search_all) if ($search_all) {
{ foreach ($fieldstosearchall as $key => $val) {
foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); $fieldstosearchall[$key] = $langs->trans($val);
}
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>'; print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
} }
@ -624,11 +706,13 @@ $moreforfilter.= '</div>';*/
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; if (empty($reshook)) {
else $moreforfilter = $hookmanager->resPrint; $moreforfilter .= $hookmanager->resPrint;
} else {
$moreforfilter = $hookmanager->resPrint;
}
if (!empty($moreforfilter)) if (!empty($moreforfilter)) {
{
print '<div class="liste_titre liste_titre_bydiv centpercent">'; print '<div class="liste_titre liste_titre_bydiv centpercent">';
print $moreforfilter; print $moreforfilter;
print '</div>'; print '</div>';
@ -645,13 +729,17 @@ print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" :
// Fields title search // Fields title search
// -------------------------------------------------------------------- // --------------------------------------------------------------------
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
foreach ($object->fields as $key => $val) foreach ($object->fields as $key => $val) {
{
$cssforfield = (empty($val['css']) ? '' : $val['css']); $cssforfield = (empty($val['css']) ? '' : $val['css']);
if ($key == 'fk_statut') $cssforfield .= ($cssforfield ? ' ' : '').'center'; if ($key == 'fk_statut') {
elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; $cssforfield .= ($cssforfield ? ' ' : '').'center';
elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; $cssforfield .= ($cssforfield ? ' ' : '').'center';
} elseif (in_array($val['type'], array('timestamp'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
} elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') {
$cssforfield .= ($cssforfield ? ' ' : '').'right';
}
if (!empty($arrayfields['t.'.$key]['checked'])) { if (!empty($arrayfields['t.'.$key]['checked'])) {
if ($key == 'type_code') { if ($key == 'type_code') {
print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">'; print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
@ -672,23 +760,26 @@ foreach ($object->fields as $key => $val)
} elseif ($key == 'fk_statut') { } elseif ($key == 'fk_statut') {
$arrayofstatus = array(); $arrayofstatus = array();
$arrayofstatus['openall'] = '-- '.$langs->trans('OpenAll').' --'; $arrayofstatus['openall'] = '-- '.$langs->trans('OpenAll').' --';
foreach ($object->statuts_short as $key2 => $val2) foreach ($object->statuts_short as $key2 => $val2) {
{ if ($key2 == Ticket::STATUS_CLOSED) {
if ($key2 == Ticket::STATUS_CLOSED) $arrayofstatus['closeall'] = '-- '.$langs->trans('ClosedAll').' --'; $arrayofstatus['closeall'] = '-- '.$langs->trans('ClosedAll').' --';
}
$arrayofstatus[$key2] = $val2; $arrayofstatus[$key2] = $val2;
} }
print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">'; print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
//var_dump($arrayofstatus);var_dump($search['fk_statut']);var_dump(array_values($search[$key])); //var_dump($arrayofstatus);var_dump($search['fk_statut']);var_dump(array_values($search[$key]));
$selectedarray = null; $selectedarray = null;
if ($search[$key]) $selectedarray = array_values($search[$key]); if ($search[$key]) {
$selectedarray = array_values($search[$key]);
}
print Form::multiselectarray('search_fk_statut', $arrayofstatus, $selectedarray, 0, 0, 'minwidth150', 1, 0, '', '', ''); print Form::multiselectarray('search_fk_statut', $arrayofstatus, $selectedarray, 0, 0, 'minwidth150', 1, 0, '', '', '');
print '</td>'; print '</td>';
} elseif ($key == "fk_soc") { } elseif ($key == "fk_soc") {
print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'"><input type="text" class="flat maxwidth75" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>'; print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'"><input type="text" class="flat maxwidth75" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>';
} elseif ($key == "datec" || $key == 'date_read' || $key == 'date_close'){ } elseif ($key == "datec" || $key == 'date_read' || $key == 'date_close') {
print '<td class="liste_titre center">'; print '<td class="liste_titre center">';
print '<div class="nowrap">'; print '<div class="nowrap">';
switch ($key){ switch ($key) {
case 'datec': case 'datec':
print $form->selectDate($search_date_start ?: -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); print $form->selectDate($search_date_start ?: -1, 'search_date_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
break; break;
@ -700,7 +791,7 @@ foreach ($object->fields as $key => $val)
} }
print '</div>'; print '</div>';
print '<div class="nowrap">'; print '<div class="nowrap">';
switch ($key){ switch ($key) {
case 'datec': case 'datec':
print $form->selectDate($search_date_end ?: -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); print $form->selectDate($search_date_end ?: -1, 'search_date_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
break; break;
@ -712,13 +803,15 @@ foreach ($object->fields as $key => $val)
} }
print '</div>'; print '</div>';
print '</td>'; print '</td>';
} } else {
else {
print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">'; print '<td class="liste_titre'.($cssforfield ? ' '.$cssforfield : '').'">';
if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
elseif (strpos($val['type'], 'integer:') === 0) { print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
} elseif (strpos($val['type'], 'integer:') === 0) {
print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1);
} elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">'; } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) {
print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">';
}
print '</td>'; print '</td>';
} }
} }
@ -741,15 +834,18 @@ print '</tr>'."\n";
// Fields title label // Fields title label
// -------------------------------------------------------------------- // --------------------------------------------------------------------
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
foreach ($object->fields as $key => $val) foreach ($object->fields as $key => $val) {
{
$cssforfield = (empty($val['css']) ? '' : $val['css']); $cssforfield = (empty($val['css']) ? '' : $val['css']);
if ($key == 'fk_statut' || $key == 'severity_code') $cssforfield .= ($cssforfield ? ' ' : '').'center'; if ($key == 'fk_statut' || $key == 'severity_code') {
elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; $cssforfield .= ($cssforfield ? ' ' : '').'center';
elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; $cssforfield .= ($cssforfield ? ' ' : '').'center';
if (!empty($arrayfields['t.'.$key]['checked'])) } elseif (in_array($val['type'], array('timestamp'))) {
{ $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
} elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') {
$cssforfield .= ($cssforfield ? ' ' : '').'right';
}
if (!empty($arrayfields['t.'.$key]['checked'])) {
print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, '', $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, '', $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n";
} }
} }
@ -765,11 +861,11 @@ print '</tr>'."\n";
// Detect if we need a fetch on each output line // Detect if we need a fetch on each output line
$needToFetchEachLine = 0; $needToFetchEachLine = 0;
if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
{ foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) if (preg_match('/\$object/', $val)) {
{ $needToFetchEachLine++; // There is at least one compute field that use $object
if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object }
} }
} }
@ -779,70 +875,83 @@ if (is_array($extrafields->attributes[$object->table_element]['computed']) && co
$i = 0; $i = 0;
$totalarray = array(); $totalarray = array();
$cacheofoutputfield = array(); $cacheofoutputfield = array();
while ($i < min($num, $limit)) while ($i < min($num, $limit)) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if (empty($obj)) break; // Should not happen if (empty($obj)) {
break; // Should not happen
}
// Store properties in $object // Store properties in $object
$object->id = $obj->rowid; $object->id = $obj->rowid;
foreach ($object->fields as $key => $val) foreach ($object->fields as $key => $val) {
{ if (property_exists($obj, $key)) {
if (property_exists($obj, $key)) $object->$key = $obj->$key; $object->$key = $obj->$key;
}
} }
$langs->load("ticket"); $langs->load("ticket");
// Show here line of result // Show here line of result
print '<tr class="oddeven">'; print '<tr class="oddeven">';
foreach ($object->fields as $key => $val) foreach ($object->fields as $key => $val) {
{
$cssforfield = ''; $cssforfield = '';
if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; $cssforfield .= ($cssforfield ? ' ' : '').'center';
if (in_array($key, array('ref', 'fk_project'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowraponall'; }
if ($key == 'fk_statut' || $key == 'severity_code') $cssforfield .= ($cssforfield ? ' ' : '').'center'; if (in_array($val['type'], array('timestamp'))) {
if (!empty($arrayfields['t.'.$key]['checked'])) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
{ }
if (in_array($key, array('ref', 'fk_project'))) {
$cssforfield .= ($cssforfield ? ' ' : '').'nowraponall';
}
if ($key == 'fk_statut' || $key == 'severity_code') {
$cssforfield .= ($cssforfield ? ' ' : '').'center';
}
if (!empty($arrayfields['t.'.$key]['checked'])) {
print '<td'; print '<td';
if ($cssforfield || $val['css']) print ' class="'; if ($cssforfield || $val['css']) {
print ' class="';
}
print $cssforfield; print $cssforfield;
if ($cssforfield && $val['css']) print ' '; if ($cssforfield && $val['css']) {
print ' ';
}
print $val['css']; print $val['css'];
if ($cssforfield || $val['css']) print '"'; if ($cssforfield || $val['css']) {
print '"';
}
print '>'; print '>';
if ($key == 'fk_statut') print $object->getLibStatut(5); if ($key == 'fk_statut') {
elseif ($key == 'subject') { print $object->getLibStatut(5);
} elseif ($key == 'subject') {
$s = $obj->subject; $s = $obj->subject;
print '<span title="'.$s.'">'; print '<span title="'.$s.'">';
print $s; print $s;
print '</span>'; print '</span>';
} } elseif ($key == 'type_code') {
elseif ($key == 'type_code') {
$s = $langs->getLabelFromKey($db, 'TicketTypeShort'.$object->type_code, 'c_ticket_type', 'code', 'label', $object->type_code); $s = $langs->getLabelFromKey($db, 'TicketTypeShort'.$object->type_code, 'c_ticket_type', 'code', 'label', $object->type_code);
print '<span title="'.$s.'">'; print '<span title="'.$s.'">';
print $s; print $s;
print '</span>'; print '</span>';
} } elseif ($key == 'category_code') {
elseif ($key == 'category_code') {
$s = $langs->getLabelFromKey($db, 'TicketCategoryShort'.$object->category_code, 'c_ticket_category', 'code', 'label', $object->category_code); $s = $langs->getLabelFromKey($db, 'TicketCategoryShort'.$object->category_code, 'c_ticket_category', 'code', 'label', $object->category_code);
print '<span title="'.$s.'">'; print '<span title="'.$s.'">';
print $s; print $s;
print '</span>'; print '</span>';
} } elseif ($key == 'severity_code') {
elseif ($key == 'severity_code') {
$s = $langs->getLabelFromKey($db, 'TicketSeverityShort'.$object->severity_code, 'c_ticket_severity', 'code', 'label', $object->severity_code); $s = $langs->getLabelFromKey($db, 'TicketSeverityShort'.$object->severity_code, 'c_ticket_severity', 'code', 'label', $object->severity_code);
print '<span title="'.$s.'">'; print '<span title="'.$s.'">';
print $s; print $s;
print '</span>'; print '</span>';
} } elseif ($key == 'tms') {
elseif ($key == 'tms') print dol_print_date($db->jdate($obj->$key), 'dayhour', 'tzuser'); print dol_print_date($db->jdate($obj->$key), 'dayhour', 'tzuser');
elseif ($key == 'fk_user_create') { } elseif ($key == 'fk_user_create') {
if ($object->fk_user_create > 0) { if ($object->fk_user_create > 0) {
$user_create->fetch($object->fk_user_create); $user_create->fetch($object->fk_user_create);
print $user_create->getNomUrl(-1); print $user_create->getNomUrl(-1);
} }
} elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) print $object->showOutputField($val, $key, $db->jdate($obj->$key), ''); } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
else { // Example: key=fk_soc, obj->key=123 val=array('type'=>'integer', ... print $object->showOutputField($val, $key, $db->jdate($obj->$key), '');
} else { // Example: key=fk_soc, obj->key=123 val=array('type'=>'integer', ...
$tmp = explode(':', $val['type']); $tmp = explode(':', $val['type']);
if ($tmp[0] == 'integer' && !empty($tmp[1]) && class_exists($tmp[1])) { if ($tmp[0] == 'integer' && !empty($tmp[1]) && class_exists($tmp[1])) {
// It is a type of an foreign field. We will try to reduce the number of fetch that the showOutputField is making. // It is a type of an foreign field. We will try to reduce the number of fetch that the showOutputField is making.
@ -860,10 +969,13 @@ while ($i < min($num, $limit))
} }
print '</td>'; print '</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
if (!empty($val['isameasure'])) $totalarray['nbfield']++;
{ }
if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; if (!empty($val['isameasure'])) {
if (!$i) {
$totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
}
$totalarray['val']['t.'.$key] += $obj->$key; $totalarray['val']['t.'.$key] += $obj->$key;
} }
} }
@ -876,14 +988,17 @@ while ($i < min($num, $limit))
print $hookmanager->resPrint; print $hookmanager->resPrint;
// Action column // Action column
print '<td class="nowrap center">'; print '<td class="nowrap center">';
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{
$selected = 0; $selected = 0;
if (in_array($obj->rowid, $arrayofselected)) $selected = 1; if (in_array($obj->rowid, $arrayofselected)) {
$selected = 1;
}
print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>'; print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
} }
print '</td>'; print '</td>';
if (!$i) $totalarray['nbfield']++; if (!$i) {
$totalarray['nbfield']++;
}
print '</tr>'; print '</tr>';
@ -895,10 +1010,13 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
// If no record found // If no record found
if ($num == 0) if ($num == 0) {
{
$colspan = 1; $colspan = 1;
foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } foreach ($arrayfields as $key => $val) {
if (!empty($val['checked'])) {
$colspan++;
}
}
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
} }
@ -916,10 +1034,11 @@ print '</form>'."\n";
if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
{
$hidegeneratedfilelistifempty = 1; $hidegeneratedfilelistifempty = 1;
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) {
$hidegeneratedfilelistifempty = 0;
}
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
$formfile = new FormFile($db); $formfile = new FormFile($db);

View File

@ -46,16 +46,21 @@ $sortorder = GETPOST("sortorder", 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
$page = is_numeric($page) ? $page : 0; $page = is_numeric($page) ? $page : 0;
$page = $page == -1 ? 0 : $page; $page = $page == -1 ? 0 : $page;
if (!$sortfield) $sortfield = "a.datep,a.id"; if (!$sortfield) {
if (!$sortorder) $sortorder = "desc"; $sortfield = "a.datep,a.id";
}
if (!$sortorder) {
$sortorder = "desc";
}
$offset = $limit * $page; $offset = $limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (GETPOST('actioncode', 'array')) if (GETPOST('actioncode', 'array')) {
{
$actioncode = GETPOST('actioncode', 'array', 3); $actioncode = GETPOST('actioncode', 'array', 3);
if (!count($actioncode)) $actioncode = '0'; if (!count($actioncode)) {
$actioncode = '0';
}
} else { } else {
$actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
} }
@ -82,8 +87,7 @@ if (!$user->rights->ticket->read) {
accessforbidden(); accessforbidden();
} }
// restrict access for externals users // restrict access for externals users
if ($user->socid > 0 && ($object->fk_soc != $user->socid)) if ($user->socid > 0 && ($object->fk_soc != $user->socid)) {
{
accessforbidden(); accessforbidden();
} }
// or for unauthorized internals users // or for unauthorized internals users
@ -99,17 +103,17 @@ if (!$user->socid && ($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY && $object-
$parameters = array('id'=>$socid); $parameters = array('id'=>$socid);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $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 ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}
if (empty($reshook)) if (empty($reshook)) {
{
// Set view style // Set view style
$_SESSION['ticket-view-type'] = "messaging"; $_SESSION['ticket-view-type'] = "messaging";
} }
// Purge search criteria // Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers
{
$actioncode = ''; $actioncode = '';
$search_agenda_label = ''; $search_agenda_label = '';
} }
@ -125,7 +129,9 @@ $userstat = new User($db);
$formticket = new FormTicket($db); $formticket = new FormTicket($db);
$title = $langs->trans("Ticket").' - '.$object->ref.' '.$object->name; $title = $langs->trans("Ticket").' - '.$object->ref.' '.$object->name;
if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/ticketnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) $title = $object->ref.' '.$object->name.' - '.$langs->trans("Info"); if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/ticketnameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
$title = $object->ref.' '.$object->name.' - '.$langs->trans("Info");
}
$help_url = 'FR:DocumentationModuleTicket'; $help_url = 'FR:DocumentationModuleTicket';
llxHeader('', $title, $help_url); llxHeader('', $title, $help_url);
@ -166,8 +172,7 @@ if (!empty($object->origin_email)) {
} }
// Thirdparty // Thirdparty
if (!empty($conf->societe->enabled)) if (!empty($conf->societe->enabled)) {
{
$morehtmlref .= '<br>'.$langs->trans('ThirdParty'); $morehtmlref .= '<br>'.$langs->trans('ThirdParty');
/*if ($action != 'editcustomer' && $object->fk_statut < 8 && !$user->socid && $user->rights->ticket->write) { /*if ($action != 'editcustomer' && $object->fk_statut < 8 && !$user->socid && $user->rights->ticket->write) {
$morehtmlref.='<a class="editfielda" href="' . $url_page_current . '?action=editcustomer&amp;track_id=' . $object->track_id . '">' . img_edit($langs->transnoentitiesnoconv('Edit'), 1) . '</a>'; $morehtmlref.='<a class="editfielda" href="' . $url_page_current . '?action=editcustomer&amp;track_id=' . $object->track_id . '">' . img_edit($langs->transnoentitiesnoconv('Edit'), 1) . '</a>';
@ -181,12 +186,10 @@ if (!empty($conf->societe->enabled))
} }
// Project // Project
if (!empty($conf->projet->enabled)) if (!empty($conf->projet->enabled)) {
{
$langs->load("projects"); $langs->load("projects");
$morehtmlref .= '<br>'.$langs->trans('Project'); $morehtmlref .= '<br>'.$langs->trans('Project');
if ($user->rights->ticket->write) if ($user->rights->ticket->write) {
{
if ($action != 'classify') { if ($action != 'classify') {
//$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a>'; //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a>';
$morehtmlref .= ' : '; $morehtmlref .= ' : ';
@ -224,11 +227,14 @@ print dol_get_fiche_end();
print '<br>'; print '<br>';
if (!empty($object->id)) if (!empty($object->id)) {
{
$param = '&id='.$object->id; $param = '&id='.$object->id;
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; $param .= '&contextpage='.$contextpage;
}
if ($limit > 0 && $limit != $conf->liste_limit) {
$param .= '&limit='.$limit;
}
$morehtmlright = ''; $morehtmlright = '';

View File

@ -30,15 +30,16 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
$WIDTH = DolGraph::getDefaultGraphSizeForStats('width'); $WIDTH = DolGraph::getDefaultGraphSizeForStats('width');
$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height'); $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height');
if (!$user->rights->ticket->read) accessforbidden(); if (!$user->rights->ticket->read) {
accessforbidden();
}
$object_status = GETPOST('object_status', 'intcomma'); $object_status = GETPOST('object_status', 'intcomma');
$userid = GETPOST('userid', 'int'); $userid = GETPOST('userid', 'int');
$socid = GETPOST('socid', 'int'); $socid = GETPOST('socid', 'int');
// Security check // Security check
if ($user->socid > 0) if ($user->socid > 0) {
{
$action = ''; $action = '';
$socid = $user->socid; $socid = $user->socid;
} }
@ -70,7 +71,9 @@ print load_fiche_titre($title, '', 'ticket');
dol_mkdir($dir); dol_mkdir($dir);
$stats = new TicketStats($db, $socid, ($userid > 0 ? $userid : 0)); $stats = new TicketStats($db, $socid, ($userid > 0 ? $userid : 0));
if ($object_status != '' && $object_status >= -1) $stats->where .= ' AND fk_statut IN ('.$db->sanitize($db->escape($object_status)).')'; if ($object_status != '' && $object_status >= -1) {
$stats->where .= ' AND fk_statut IN ('.$db->sanitize($db->escape($object_status)).')';
}
// Build graphic number of object // Build graphic number of object
@ -80,8 +83,7 @@ $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
// $data = array(array('Lib',val1,val2,val3),...) // $data = array(array('Lib',val1,val2,val3),...)
if (!$user->rights->societe->client->voir || $user->socid) if (!$user->rights->societe->client->voir || $user->socid) {
{
$filenamenb = $dir.'/ticketsnbinyear-'.$user->id.'-'.$year.'.png'; $filenamenb = $dir.'/ticketsnbinyear-'.$user->id.'-'.$year.'.png';
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=ticketstats&file=ticketsnbinyear-'.$user->id.'-'.$year.'.png'; $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=ticketstats&file=ticketsnbinyear-'.$user->id.'-'.$year.'.png';
} else { } else {
@ -91,12 +93,10 @@ if (!$user->rights->societe->client->voir || $user->socid)
$px1 = new DolGraph(); $px1 = new DolGraph();
$mesg = $px1->isGraphKo(); $mesg = $px1->isGraphKo();
if (!$mesg) if (!$mesg) {
{
$px1->SetData($data); $px1->SetData($data);
$i = $startyear; $legend = array(); $i = $startyear; $legend = array();
while ($i <= $endyear) while ($i <= $endyear) {
{
$legend[] = $i; $legend[] = $i;
$i++; $i++;
} }
@ -119,8 +119,7 @@ $data = $stats->getAmountByMonthWithPrevYear($endyear, $startyear);
//var_dump($data); //var_dump($data);
// $data = array(array('Lib',val1,val2,val3),...) // $data = array(array('Lib',val1,val2,val3),...)
if (!$user->rights->societe->client->voir || $user->socid) if (!$user->rights->societe->client->voir || $user->socid) {
{
$filenameamount = $dir.'/ticketsamountinyear-'.$user->id.'-'.$year.'.png'; $filenameamount = $dir.'/ticketsamountinyear-'.$user->id.'-'.$year.'.png';
$fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=ticketstats&file=ticketsamountinyear-'.$user->id.'-'.$year.'.png'; $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=ticketstats&file=ticketsamountinyear-'.$user->id.'-'.$year.'.png';
} else { } else {
@ -130,12 +129,10 @@ if (!$user->rights->societe->client->voir || $user->socid)
$px2 = new DolGraph(); $px2 = new DolGraph();
$mesg = $px2->isGraphKo(); $mesg = $px2->isGraphKo();
if (!$mesg) if (!$mesg) {
{
$px2->SetData($data); $px2->SetData($data);
$i = $startyear; $legend = array(); $i = $startyear; $legend = array();
while ($i <= $endyear) while ($i <= $endyear) {
{
$legend[] = $i; $legend[] = $i;
$i++; $i++;
} }
@ -156,8 +153,7 @@ if (!$mesg)
$data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear); $data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear);
if (!$user->rights->societe->client->voir || $user->socid) if (!$user->rights->societe->client->voir || $user->socid) {
{
$filename_avg = $dir.'/ticketsaverage-'.$user->id.'-'.$year.'.png'; $filename_avg = $dir.'/ticketsaverage-'.$user->id.'-'.$year.'.png';
$fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=ticketstats&file=ticketsaverage-'.$user->id.'-'.$year.'.png'; $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=ticketstats&file=ticketsaverage-'.$user->id.'-'.$year.'.png';
} else { } else {
@ -167,12 +163,10 @@ if (!$user->rights->societe->client->voir || $user->socid)
$px3 = new DolGraph(); $px3 = new DolGraph();
$mesg = $px3->isGraphKo(); $mesg = $px3->isGraphKo();
if (!$mesg) if (!$mesg) {
{
$px3->SetData($data); $px3->SetData($data);
$i = $startyear; $legend = array(); $i = $startyear; $legend = array();
while ($i <= $endyear) while ($i <= $endyear) {
{
$legend[] = $i; $legend[] = $i;
$i++; $i++;
} }
@ -200,7 +194,9 @@ foreach ($data as $val) {
$arrayyears[$val['year']] = $val['year']; $arrayyears[$val['year']] = $val['year'];
} }
} }
if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear; if (!count($arrayyears)) {
$arrayyears[$nowyear] = $nowyear;
}
$h = 0; $h = 0;
$head = array(); $head = array();
@ -239,8 +235,12 @@ print $form->selectarray('object_status', $liststatus, GETPOST('object_status',
print '</td></tr>'; print '</td></tr>';
// Year // Year
print '<tr><td class="left">'.$langs->trans("Year").'</td><td class="left">'; print '<tr><td class="left">'.$langs->trans("Year").'</td><td class="left">';
if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year; if (!in_array($year, $arrayyears)) {
if (!in_array($nowyear, $arrayyears)) $arrayyears[$nowyear] = $nowyear; $arrayyears[$year] = $year;
}
if (!in_array($nowyear, $arrayyears)) {
$arrayyears[$nowyear] = $nowyear;
}
arsort($arrayyears); arsort($arrayyears);
print $form->selectarray('year', $arrayyears, $year, 0); print $form->selectarray('year', $arrayyears, $year, 0);
print '</td></tr>'; print '</td></tr>';
@ -263,11 +263,9 @@ print '<td class="right">%</td>';
print '</tr>'; print '</tr>';
$oldyear = 0; $oldyear = 0;
foreach ($data as $val) foreach ($data as $val) {
{
$year = $val['year']; $year = $val['year'];
while (!empty($year) && $oldyear > $year + 1) while (!empty($year) && $oldyear > $year + 1) { // If we have empty year
{ // If we have empty year
$oldyear--; $oldyear--;
print '<tr class="oddeven" height="24">'; print '<tr class="oddeven" height="24">';
@ -303,7 +301,9 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
// Show graphs // Show graphs
print '<table class="border centpercent"><tr class="pair nohover"><td class="center">'; print '<table class="border centpercent"><tr class="pair nohover"><td class="center">';
if ($mesg) { print $mesg; } else { if ($mesg) {
print $mesg;
} else {
print $px1->show(); print $px1->show();
print "<br>\n"; print "<br>\n";
//print $px2->show(); //print $px2->show();

View File

@ -16,8 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
// Protection to avoid direct call of template // Protection to avoid direct call of template
if (empty($conf) || !is_object($conf)) if (empty($conf) || !is_object($conf)) {
{
print "Error, template page can't be called as URL"; print "Error, template page can't be called as URL";
exit; exit;
} }
@ -38,52 +37,54 @@ $linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'datec', 'desc', 0, 0, 1
$total = 0; $total = 0;
$ilink = 0; $ilink = 0;
foreach ($linkedObjectBlock as $key => $objectlink) foreach ($linkedObjectBlock as $key => $objectlink) {
{
$ilink++; $ilink++;
$trclass = 'oddeven'; $trclass = 'oddeven';
if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total'; if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) {
$trclass .= ' liste_sub_total';
}
?> ?>
<tr class="<?php echo $trclass; ?>" > <tr class="<?php echo $trclass; ?>" >
<td class="linkedcol-element" ><?php echo $langs->trans("Ticket"); ?> <td class="linkedcol-element" ><?php echo $langs->trans("Ticket"); ?>
<?php if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) print '<a class="objectlinked_importbtn" href="'.$objectlink->getNomUrl(0, '', 0, 1).'&amp;action=selectlines" data-element="'.$objectlink->element.'" data-id="'.$objectlink->id.'" > <i class="fa fa-indent"></i> </a'; ?> <?php if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) {
</td> print '<a class="objectlinked_importbtn" href="'.$objectlink->getNomUrl(0, '', 0, 1).'&amp;action=selectlines" data-element="'.$objectlink->element.'" data-id="'.$objectlink->id.'" > <i class="fa fa-indent"></i> </a';
<td class="linkedcol-name nowraponall" ><?php echo $objectlink->getNomUrl(1); ?></td> } ?>
<td class="linkedcol-ref center"><?php echo $objectlink->ref_client; ?></td> </td>
<td class="linkedcol-date center"><?php echo dol_print_date($objectlink->datec, 'day'); ?></td> <td class="linkedcol-name nowraponall" ><?php echo $objectlink->getNomUrl(1); ?></td>
<?php <td class="linkedcol-ref center"><?php echo $objectlink->ref_client; ?></td>
<td class="linkedcol-date center"><?php echo dol_print_date($objectlink->datec, 'day'); ?></td>
<?php
//$objectlink->socid = $objectlink->fk_soc; //$objectlink->socid = $objectlink->fk_soc;
//$objectlink->fetch_thirdparty(); //$objectlink->fetch_thirdparty();
?> ?>
<td class="linkedcol-amount right"><?php //echo $objectlink->thirdparty->getNomUrl(1); ?></td> <td class="linkedcol-amount right"><?php //echo $objectlink->thirdparty->getNomUrl(1); ?></td>
<td class="linkedcol-statut right"><?php echo $objectlink->getLibStatut(3); ?></td> <td class="linkedcol-statut right"><?php echo $objectlink->getLibStatut(3); ?></td>
<td class="linkedcol-action right"> <td class="linkedcol-action right">
<?php <?php
// For now, shipments must stay linked to order, so link is not deletable // For now, shipments must stay linked to order, so link is not deletable
if ($object->element != 'shipping') { if ($object->element != 'shipping') {
?> ?>
<a class="reposition" href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a> <a class="reposition" href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a>
<?php <?php
} }
?> ?>
</td> </td>
</tr> </tr>
<?php <?php
} }
if (count($linkedObjectBlock) > 1) if (count($linkedObjectBlock) > 1) {
{
?> ?>
<tr class="liste_total <?php echo (empty($noMoreLinkedObjectBlockAfter) ? 'liste_sub_total' : ''); ?>"> <tr class="liste_total <?php echo (empty($noMoreLinkedObjectBlockAfter) ? 'liste_sub_total' : ''); ?>">
<td><?php echo $langs->trans("Total"); ?></td> <td><?php echo $langs->trans("Total"); ?></td>
<td></td> <td></td>
<td class="center"></td> <td class="center"></td>
<td class="center"></td> <td class="center"></td>
<td class="right"><?php echo price($total); ?></td> <td class="right"><?php echo price($total); ?></td>
<td class="right"></td> <td class="right"></td>
<td class="right"></td> <td class="right"></td>
</tr> </tr>
<?php <?php
} }
print "<!-- END PHP TEMPLATE -->\n"; print "<!-- END PHP TEMPLATE -->\n";