--- /tmp/dsg/dolibarr/htdocs/ticket/github_agenda.php +++ /tmp/dsg/dolibarr/htdocs/ticket/client_agenda.php @@ -41,8 +41,8 @@ $action = GETPOST('action', 'aZ09'); $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST("sortfield", "aZ09comma"); -$sortorder = GETPOST("sortorder", 'aZ09comma'); +$sortfield = GETPOST("sortfield", "alpha"); +$sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); $page = is_numeric($page) ? $page : 0; $page = $page == -1 ? 0 : $page; @@ -56,7 +56,9 @@ { $actioncode = GETPOST('actioncode', 'array', 3); 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)); } $search_agenda_label = GETPOST('search_agenda_label'); @@ -131,24 +133,24 @@ llxHeader('', $title, $help_url); if ($socid > 0) { - $object->fetch_thirdparty(); - $head = societe_prepare_head($object->thirdparty); - - print dol_get_fiche_head($head, 'ticket', $langs->trans("ThirdParty"), 0, 'company'); - - dol_banner_tab($object->thirdparty, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom'); - - print dol_get_fiche_end(); + $object->fetch_thirdparty(); + $head = societe_prepare_head($object->thirdparty); + + dol_fiche_head($head, 'ticket', $langs->trans("ThirdParty"), 0, 'company'); + + dol_banner_tab($object->thirdparty, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom'); + + dol_fiche_end(); } if (!$user->socid && $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY) { - $object->next_prev_filter = "te.fk_user_assign = '".$user->id."'"; + $object->next_prev_filter = "te.fk_user_assign = '".$user->id."'"; } elseif ($user->socid > 0) { - $object->next_prev_filter = "te.fk_soc = '".$user->socid."'"; + $object->next_prev_filter = "te.fk_soc = '".$user->socid."'"; } $head = ticket_prepare_head($object); -print dol_get_fiche_head($head, 'tabTicketLogs', $langs->trans("Ticket"), 0, 'ticket'); +dol_fiche_head($head, 'tabTicketLogs', $langs->trans("Ticket"), 0, 'ticket'); $morehtmlref = '
'; $morehtmlref .= $object->subject; @@ -220,7 +222,7 @@ dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); -print dol_get_fiche_end(); +dol_fiche_end(); print '
'; @@ -231,23 +233,22 @@ if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; - $morehtmlright = ''; + $morehtmlright = ''; $messagingUrl = DOL_URL_ROOT.'/ticket/messaging.php?track_id='.$object->track_id; - $morehtmlright .= dolGetButtonTitle($langs->trans('ShowAsConversation'), '', 'fa fa-comments imgforviewmode', $messagingUrl, '', 1); - $messagingUrl = DOL_URL_ROOT.'/ticket/agenda.php?track_id='.$object->track_id; - $morehtmlright .= dolGetButtonTitle($langs->trans('MessageListViewType'), '', 'fa fa-list-alt imgforviewmode', $messagingUrl, '', 1, array('morecss'=>'btnTitleSelected')); - - // Show link to add a message (if read and not closed) - $btnstatus = $object->fk_statut < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage"; - $url = 'card.php?track_id='.$object->track_id.'&action=presend_addmessage&mode=init'; - $morehtmlright .= dolGetButtonTitle($langs->trans('TicketAddMessage'), '', 'fa fa-comment-dots', $url, 'add-new-ticket-title-button', $btnstatus); + $morehtmlright .= dolGetButtonTitle($langs->trans('ShowAsConversation'), '', 'fa fa-comments imgforviewmode', $messagingUrl, '', 1); + + // Show link to add a message (if read and not closed) + $btnstatus = $object->fk_statut < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage"; + $url = 'card.php?track_id='.$object->track_id.'&action=presend_addmessage&mode=init'; + $morehtmlright .= dolGetButtonTitle($langs->trans('TicketAddMessage'), '', 'fa fa-comment-dots', $url, 'add-new-ticket-title-button', $btnstatus); // Show link to add event (if read and not closed) $btnstatus = $object->fk_statut < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage"; $url = dol_buildpath('/comm/action/card.php', 1).'?action=create&datep='.date('YmdHi').'&origin=ticket&originid='.$object->id.'&projectid='.$object->fk_project.'&backtopage='.urlencode($_SERVER["PHP_SELF"]); $morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', $url, 'add-new-ticket-even-button', $btnstatus); + print_barre_liste($langs->trans("ActionsOnTicket"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 1); // List of all actions --- /tmp/dsg/dolibarr/htdocs/ticket/github_card.php +++ /tmp/dsg/dolibarr/htdocs/ticket/client_card.php @@ -55,14 +55,14 @@ $notifyTiers = GETPOST("notify_tiers_at_create", 'alpha'); -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); if (GETPOST('actioncode', 'array')) { - $actioncode = GETPOST('actioncode', 'array', 3); - if (!count($actioncode)) $actioncode = '0'; + $actioncode = GETPOST('actioncode', 'array', 3); + if (!count($actioncode)) $actioncode = '0'; } else { - $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_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)); } $search_agenda_label = GETPOST('search_agenda_label'); @@ -78,7 +78,7 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Initialize array of search criterias -$search_all = GETPOST("search_all", 'alpha'); +$search_all = trim(GETPOST("search_all", 'alpha')); $search = array(); foreach ($object->fields as $key => $val) { @@ -127,7 +127,6 @@ $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'); -$error = 0; if (empty($reshook)) { // 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{ @@ -138,7 +137,7 @@ if ($cancel) { if (!empty($backtopage)) { - header("Location: ".$backtopage); + header("Location: " . $backtopage); exit; } @@ -158,8 +157,6 @@ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Message")), null, 'errors'); $action = 'create'; } - $ret = $extrafields->setOptionalsFromPost(null, $object); - if ($ret < 0) $error++; if (!$error) { $db->begin(); @@ -170,21 +167,19 @@ $object->message = GETPOST("message", 'restricthtml'); $object->type_code = GETPOST("type_code", 'alpha'); - $object->type_label = $langs->trans($langs->getLabelFromKey($db, $object->type_code, 'c_ticket_type', 'code', 'label')); $object->category_code = GETPOST("category_code", 'alpha'); - $object->category_label = $langs->trans($langs->getLabelFromKey($db, $object->category_code, 'c_ticket_category', 'code', 'label')); $object->severity_code = GETPOST("severity_code", 'alpha'); - $object->severity_label = $langs->trans($langs->getLabelFromKey($db, $object->severity_code, 'c_ticket_severity', 'code', 'label')); - $object->email_from = $user->email; $notifyTiers = GETPOST("notify_tiers_at_create", 'alpha'); $object->notify_tiers_at_create = empty($notifyTiers) ? 0 : 1; $object->fk_project = GETPOST('projectid', 'int'); + + $ret = $extrafields->setOptionalsFromPost(null, $object); $id = $object->create($user); if ($id <= 0) { $error++; - setEventMessages($object->error, $object->errors, 'errors'); + setEventMessage($object->error, $object->errors, 'errors'); $action = 'create'; } @@ -194,8 +189,7 @@ $type_contact = GETPOST("type", 'alpha'); if ($contactid > 0 && $type_contact) { - $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); - $result = $object->add_contact($contactid, $typeid, 'external'); + $result = $object->add_contact($contactid, GETPOST("type"), 'external'); } // altairis: link ticket to project @@ -232,7 +226,7 @@ $fichinter->fk_project = GETPOST('projectid', 'int'); $fichinter->fk_contrat = $contractid; $fichinter->author = $user->id; - $fichinter->model_pdf = 'soleil'; + $fichinter->modelpdf = 'soleil'; $fichinter->origin = $object->element; $fichinter->origin_id = $object->id; @@ -259,10 +253,10 @@ if (!empty($backtopage)) { $url = $backtopage; } else { - $url = 'card.php?track_id='.$object->track_id; - } - - header("Location: ".$url); + $url = 'card.php?track_id=' . $object->track_id; + } + + header("Location: " . $url); exit; } else { $db->rollback(); @@ -273,55 +267,53 @@ } } - if ($action == 'update' && $user->rights->ticket->write && $object->fk_statut < Ticket::STATUS_CLOSED) { + if ($action == 'edit' && $user->rights->ticket->write) { $error = 0; - $ret = $object->fetch(GETPOST('id', 'int'), GETPOST('ref', 'alpha'), GETPOST('track_id', 'alpha')); + if ($object->fetch(GETPOST('id', 'int')) < 0) { + $error++; + array_push($object->errors, $langs->trans("ErrorTicketIsNotValid")); + $_GET["action"] = $_POST["action"] = ''; + } + } + + if (GETPOST('update', 'alpha') && GETPOST('id', 'int') && $user->rights->ticket->write) { + $error = 0; + + $ret = $object->fetch(GETPOST('id', 'int')); if ($ret < 0) { $error++; - array_push($object->errors, $langs->trans('ErrorTicketIsNotValid')); - } - - // check fields - if (!$error) { - if (!GETPOST('subject', 'alpha')) { - $error++; - array_push($object->errors, $langs->trans('ErrorFieldRequired', $langs->transnoentities('Subject'))); - } - $ret = $extrafields->setOptionalsFromPost(null, $object); - if ($ret < 0) $error++; + array_push($object->errors, $langs->trans("ErrorTicketIsNotValid")); + $action = ''; + } elseif (!GETPOST("label")) { + $error++; + array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label"))); + $action = 'edit'; + } elseif (!GETPOST("subject", 'alphanohtml')) { + $error++; + array_push($object->errors, $langs->trans("ErrorFieldRequired", $langs->transnoentities("Subject"))); + $action = 'edit'; } if (!$error) { $db->begin(); - $object->subject = GETPOST('subject', 'alpha'); - $object->type_code = GETPOST('type_code', 'alpha'); - $object->category_code = GETPOST('category_code', 'alpha'); - $object->severity_code = GETPOST('severity_code', 'alpha'); - + $object->label = GETPOST("label", 'alphanohtml'); + $object->description = GETPOST("description", 'restricthtml'); + + //... $ret = $object->update($user); - if ($ret <= 0) $error++; - - if ($error) { + if ($ret <= 0) { + $error++; + setEventMessage($object->error, $object->errors, 'errors'); + $action = 'edit'; + } + + if (!$error && $ret > 0) { + $db->commit(); + } else { $db->rollback(); - } else { - $db->commit(); - } - } - - if ($error) { - setEventMessages($object->error, $object->errors, 'errors'); - $action = 'edit'; - } else { - if (!empty($backtopage)) { - $url = $backtopage; - } else { - $url = 'card.php?track_id='.$object->track_id; - } - - header('Location: '.$url); - exit(); + } } } @@ -332,7 +324,7 @@ if ($object->markAsRead($user) > 0) { setEventMessages($langs->trans('TicketMarkedAsRead'), null, 'mesgs'); - header("Location: card.php?track_id=".$object->track_id."&action=view"); + header("Location: card.php?track_id=" . $object->track_id . "&action=view"); exit; } else { setEventMessages($object->error, $object->errors, 'errors'); @@ -383,7 +375,7 @@ setEventMessages($langs->trans('TicketAssigned'), null, 'mesgs'); - header("Location: card.php?track_id=".$object->track_id."&action=view"); + header("Location: card.php?track_id=" . $object->track_id . "&action=view"); exit; } else { array_push($object->errors, $object->error); @@ -399,10 +391,10 @@ if (!empty($backtopage)) { $url = $backtopage; } else { - $url = 'card.php?action=view&track_id='.$object->track_id; - } - - header("Location: ".$url); + $url = 'card.php?action=view&track_id=' . $object->track_id; + } + + header("Location: " . $url); exit; } else { setEventMessages($object->error, null, 'errors'); @@ -416,8 +408,8 @@ if ($object->close($user)) { setEventMessages($langs->trans('TicketMarkedAsClosed'), null, 'mesgs'); - $url = 'card.php?action=view&track_id='.GETPOST('track_id', 'alpha'); - header("Location: ".$url); + $url = 'card.php?action=view&track_id=' . GETPOST('track_id', 'alpha'); + header("Location: " . $url); } else { $action = ''; setEventMessages($object->error, $object->errors, 'errors'); @@ -432,10 +424,10 @@ // Log action in ticket logs table $log_action = $langs->trans('TicketLogClosedBy', $_SESSION['email_customer']); - setEventMessages('
'.$langs->trans('TicketMarkedAsClosed').'
', null, 'mesgs'); - - $url = 'card.php?action=view_ticket&track_id='.GETPOST('track_id', 'alpha'); - header("Location: ".$url); + setEventMessages('
' . $langs->trans('TicketMarkedAsClosed') . '
', null, 'mesgs'); + + $url = 'card.php?action=view_ticket&track_id=' . GETPOST('track_id', 'alpha'); + header("Location: " . $url); } else { setEventMessages($object->error, $object->errors, 'errors'); $action = ''; @@ -445,12 +437,12 @@ if ($action == 'confirm_delete_ticket' && GETPOST('confirm', 'alpha') == "yes" && $user->rights->ticket->delete) { if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { if ($object->delete($user) > 0) { - setEventMessages('
'.$langs->trans('TicketDeletedSuccess').'
', null, 'mesgs'); - Header("Location: ".DOL_URL_ROOT."/ticket/list.php"); + setEventMessages('
' . $langs->trans('TicketDeletedSuccess') . '
', null, 'mesgs'); + Header("Location: " . DOL_URL_ROOT . "/ticket/list.php"); exit; } else { $langs->load("errors"); - $mesg = '
'.$langs->trans($object->error).'
'; + $mesg = '
' . $langs->trans($object->error) . '
'; $action = ''; } } @@ -460,8 +452,8 @@ if ($action == 'set_thirdparty' && $user->rights->societe->creer) { if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { $result = $object->setCustomer(GETPOST('editcustomer', 'int')); - $url = 'card.php?action=view&track_id='.GETPOST('track_id', 'alpha'); - header("Location: ".$url); + $url = 'card.php?action=view&track_id=' . GETPOST('track_id', 'alpha'); + header("Location: " . $url); exit(); } } @@ -470,8 +462,8 @@ if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { $result = $object->setProgression(GETPOST('progress', 'alpha')); - $url = 'card.php?action=view&track_id='.$object->track_id; - header("Location: ".$url); + $url = 'card.php?action=view&track_id=' . $object->track_id; + header("Location: " . $url); exit(); } } @@ -479,22 +471,19 @@ if ($action == 'setsubject') { if ($object->fetch(GETPOST('id', 'int'))) { if ($action == 'setsubject') { - $object->subject = GETPOST('subject', 'alphanohtml'); + $object->subject = trim(GETPOST('subject', 'alphanohtml')); } if ($action == 'setsubject' && empty($object->subject)) { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Subject")), null, 'errors'); - } - - if (!$error) { + $mesg .= ($mesg ? '
' : '') . $langs->trans("ErrorFieldRequired", $langs->transnoentities("Subject")); + } + + if (!$mesg) { if ($object->update($user) >= 0) { - header("Location: ".$_SERVER['PHP_SELF']."?track_id=".$object->track_id); + header("Location: " . $_SERVER['PHP_SELF'] . "?track_id=" . $object->track_id); exit; - } else { - $error++; - setEventMessages($object->error, $object->errors, 'errors'); - } + } + $mesg = $object->error; } } } @@ -508,12 +497,9 @@ // Log action in ticket logs table $log_action = $langs->trans('TicketLogReopen'); - $url = 'card.php?action=view&track_id='.$object->track_id; - header("Location: ".$url); + $url = 'card.php?action=view&track_id=' . $object->track_id; + header("Location: " . $url); exit(); - } else { - $error++; - setEventMessages($object->error, $object->errors, 'errors'); } } } @@ -521,16 +507,16 @@ elseif ($action == 'classin' && $user->rights->ticket->write) { if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { $object->setProject(GETPOST('projectid', 'int')); - $url = 'card.php?action=view&track_id='.$object->track_id; - header("Location: ".$url); + $url = 'card.php?action=view&track_id=' . $object->track_id; + header("Location: " . $url); exit(); } } // Categorisation dans contrat elseif ($action == 'setcontract' && $user->rights->ticket->write) { if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) { $object->setContract(GETPOST('contractid', 'int')); - $url = 'card.php?action=view&track_id='.$object->track_id; - header("Location: ".$url); + $url = 'card.php?action=view&track_id=' . $object->track_id; + header("Location: " . $url); exit(); } } elseif ($action == "set_message" && $user->rights->ticket->manage) { @@ -543,16 +529,13 @@ $object->message = $fieldtomodify; $ret = $object->update($user); if ($ret > 0) { - $log_action = $langs->trans('TicketInitialMessageModified')." \n"; + $log_action = $langs->trans('TicketInitialMessageModified') . " \n"; // include the Diff class dol_include_once('/ticket/class/utils_diff.class.php'); // output the result of comparing two files as plain text $log_action .= Diff::toString(Diff::compare(strip_tags($oldvalue_message), strip_tags($object->message))); setEventMessages($langs->trans('TicketMessageSuccesfullyUpdated'), null, 'mesgs'); - } else { - $error++; - setEventMessages($object->error, $object->errors, 'errors'); } } @@ -567,12 +550,9 @@ // Log action in ticket logs table $log_action = $langs->trans('TicketLogStatusChanged', $langs->transnoentities($object->statuts_short[$old_status]), $langs->transnoentities($object->statuts_short[$new_status])); - $url = 'card.php?action=view&track_id='.$object->track_id; - header("Location: ".$url); + $url = 'card.php?action=view&track_id=' . $object->track_id; + header("Location: " . $url); exit(); - } else { - $error++; - setEventMessages($object->error, $object->errors, 'errors'); } } } @@ -580,21 +560,17 @@ // Action to update one extrafield if ($action == "update_extras" && !empty($permissiontoadd)) { $object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')); - - $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'restricthtml')); - if ($ret < 0) $error++; - - if (!$error) { - $result = $object->insertExtraFields(empty($triggermodname) ? '' : $triggermodname, $user); - if ($result < 0) { $error++; } - } - - if ($error) { + $attributekey = GETPOST('attribute', 'alpha'); + $attributekeylong = 'options_' . $attributekey; + $object->array_options['options_' . $attributekey] = GETPOST($attributekeylong, ' alpha'); + + $result = $object->insertExtraFields(empty($triggermodname) ? '' : $triggermodname, $user); + if ($result > 0) { + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); + $action = 'view'; + } else { setEventMessages($object->error, $object->errors, 'errors'); $action = 'edit_extras'; - } else { - setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); - $action = 'view'; } } @@ -610,33 +586,29 @@ $log_action = $langs->trans('TicketLogPropertyChanged', $oldvalue_label, $newvalue_label); setEventMessages($langs->trans('TicketUpdated'), null, 'mesgs'); - } else { - $error++; - setEventMessages($object->error, $object->errors, 'errors'); } $action = 'view'; } $permissiondellink = $user->rights->ticket->write; - include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once + include DOL_DOCUMENT_ROOT . '/core/actions_dellink.inc.php'; // Must be include, not include_once // Actions to build doc $upload_dir = $conf->ticket->dir_output; $permissiontoadd = $user->rights->ticket->write; - include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; + include DOL_DOCUMENT_ROOT . '/core/actions_builddoc.inc.php'; // Actions to send emails $triggersendname = 'TICKET_SENTBYMAIL'; $paramname = 'id'; $autocopy = 'MAIN_MAIL_AUTOCOPY_TICKET_TO'; // used to know the automatic BCC to add - $trackid = 'tic'.$object->id; - include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; + $trackid = 'tic' . $object->id; + 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 if (GETPOSTISSET('actionbis') && $action == 'presend') $action = 'presend_addmessage'; } - /* * View @@ -662,71 +634,20 @@ $formticket->withfromcontactid = $contactid ? $contactid : ''; $formticket->withtitletopic = 1; $formticket->withnotifytiersatcreate = ($notifyTiers ? 1 : 0); - $formticket->withusercreate = 0; + $formticket->withusercreate = 1; $formticket->withref = 1; $formticket->fk_user_create = $user->id; $formticket->withfile = 2; $formticket->withextrafields = 1; $formticket->param = array('origin' => GETPOST('origin'), 'originid' => GETPOST('originid')); + if (empty($defaultref)) { + $defaultref = ''; + } $formticket->showForm(1, 'create'); -} elseif ($action == 'edit' && $user->rights->ticket->write && $object->fk_statut < Ticket::STATUS_CLOSED) { - $formticket = new FormTicket($db); - - $head = ticket_prepare_head($object); - - print '
'; - print ''; - print ''; - print ''; - - print dol_get_fiche_head($head, 'card', $langs->trans('Ticket'), 0, 'ticket'); - - print '
'; - print ''; - - // Type - print ''; - - // Severity - print ''; - - // Group - print ''; - - // Subject - print ''; - - // Other attributes - $parameters = array('colspan' => ' colspan="3"', 'colspanvalue' => '3'); - $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit'); - } - - print '
'; - $formticket->selectTypesTickets((GETPOST('type_code') ? GETPOST('type_code') : $object->type_code), 'type_code', '', '2'); - print '
'; - $formticket->selectSeveritiesTickets((GETPOST('severity_code') ? GETPOST('severity_code') : $object->severity_code), 'severity_code', '', '2'); - print '
'; - $formticket->selectGroupTickets((GETPOST('category_code') ? GETPOST('category_code') : $object->category_code), 'category_code', '', '2'); - print '
'; - print ''; - print '
'; - print '
'; - - print dol_get_fiche_end(); - - print '
'; - print ''; - print '     '; - print ''; - print '
'; - - print '
'; } -elseif (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'dellink' || $action == 'presend' || $action == 'presend_addmessage' || $action == 'close' || $action == 'delete' || $action == 'editcustomer' || $action == 'progression' || $action == 'reopen' + +if (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') { if ($res > 0) @@ -771,7 +692,7 @@ //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete; $head = project_prepare_head($projectstat); - print dol_get_fiche_head($head, 'ticket', $langs->trans("Project"), 0, ($projectstat->public ? 'projectpub' : 'project')); + dol_fiche_head($head, 'ticket', $langs->trans("Project"), 0, ($projectstat->public ? 'projectpub' : 'project')); /* * Projet synthese pour rappel @@ -827,11 +748,11 @@ $object->fetch_thirdparty(); $head = societe_prepare_head($object->thirdparty); - print dol_get_fiche_head($head, 'ticket', $langs->trans("ThirdParty"), 0, 'company'); + dol_fiche_head($head, 'ticket', $langs->trans("ThirdParty"), 0, 'company'); dol_banner_tab($object->thirdparty, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom'); - print dol_get_fiche_end(); + dol_fiche_end(); } if (!$user->socid && $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY) { @@ -842,7 +763,7 @@ $head = ticket_prepare_head($object); - print dol_get_fiche_head($head, 'tabTicket', $langs->trans("Ticket"), -1, 'ticket'); + dol_fiche_head($head, 'tabTicket', $langs->trans("Ticket"), -1, 'ticket'); $morehtmlref = '
'; $morehtmlref .= $object->subject; @@ -861,7 +782,8 @@ } // Thirdparty - if (!empty($conf->societe->enabled)) { + if (!empty($conf->societe->enabled)) + { $morehtmlref .= '
'.$langs->trans('ThirdParty').' '; if ($action != 'editcustomer' && $object->fk_statut < 8 && !$user->socid && $user->rights->ticket->write) { $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('Edit'), 0).' : '; @@ -874,10 +796,12 @@ } // Project - if (!empty($conf->projet->enabled)) { + if (!empty($conf->projet->enabled)) + { $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project').' '; - if ($user->rights->ticket->write) { + if ($user->rights->ticket->write) + { if ($action != 'classify') $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).''; $morehtmlref .= ' : '; @@ -938,14 +862,14 @@ // Creation date print ''.$langs->trans("DateCreation").''; - print dol_print_date($object->datec, 'dayhour', 'tzuser'); + print dol_print_date($object->datec, 'dayhour'); print ' - '.$langs->trans("TimeElapsedSince").': '.convertSecondToTime(roundUpToNextMultiple($now - $object->datec, 60)).''; print ''; // Read date print ''.$langs->trans("TicketReadOn").''; if (!empty($object->date_read)) { - print dol_print_date($object->date_read, 'dayhour', 'tzuser'); + print dol_print_date($object->date_read, 'dayhour'); print ' - '.$langs->trans("TicketTimeToRead").': '.convertSecondToTime(roundUpToNextMultiple($object->date_read - $object->datec, 60)).''; print ' - '.$langs->trans("TimeElapsedSince").': '.convertSecondToTime(roundUpToNextMultiple($now - $object->date_read, 60)).''; } @@ -954,7 +878,7 @@ // Close date print ''.$langs->trans("TicketCloseOn").''; if (!empty($object->date_close)) { - print dol_print_date($object->date_close, 'dayhour', 'tzuser'); + print dol_print_date($object->date_close, 'dayhour'); } print ''; @@ -962,7 +886,7 @@ print ''; print ''; } print '
'; print $langs->trans("AssignedTo"); - if ($object->fk_statut < $object::STATUS_CLOSED && GETPOST('set', 'alpha') != "assign_ticket" && $user->rights->ticket->manage) { + if ($object->fk_statut < 8 && GETPOST('set', 'alpha') != "assign_ticket" && $user->rights->ticket->manage) { print ''.img_edit($langs->trans('Modify'), '').'
'; @@ -970,6 +894,8 @@ if ($object->fk_user_assign > 0) { $userstat->fetch($object->fk_user_assign); print $userstat->getNomUrl(1); + } else { + print $langs->trans('None'); } // Show user list to assignate one if status is "read" @@ -990,7 +916,7 @@ print ''; - if ($action != 'progression' && $object->fk_statut < $object::STATUS_CLOSED && !$user->socid) { + if ($action != 'progression' && $object->fk_statut < 8 && !$user->socid) { print ''; } print '
'; print $langs->trans('Progression').''; print ''.img_edit($langs->trans('Modify')).'
'; @@ -1049,10 +975,11 @@ print '
'; print ''; print ''; + print ''; print ''; print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table - print ''; + print '
'; print ''; print ''; // Group - print ''; // Severity print ''; } print '
'; print $langs->trans('Properties'); @@ -1060,9 +987,10 @@ print ''; if (GETPOST('set', 'alpha') == 'properties' && $user->rights->ticket->write) { print ''; - } else { + } + else { // Button to edit Properties - if ($object->fk_statut < $object::STATUS_NEED_MORE_INFO && $user->rights->ticket->write) { + if ($object->fk_statut < 5 && $user->rights->ticket->write) { print ''.img_edit($langs->trans('Modify')).''; } } @@ -1097,15 +1025,15 @@ } else { // Type print '
'.$langs->trans("Type").''; - print $langs->getLabelFromKey($db, 'TicketTypeShort'.$object->type_code, 'c_ticket_type', 'code', 'label', $object->type_code); + print $langs->getLabelFromKey($db, $object->type_code, 'c_ticket_type', 'code', 'label'); print '
'.$langs->trans("TicketCategory").''; - print $langs->getLabelFromKey($db, 'TicketCategoryShort'.$object->category_code, 'c_ticket_category', 'code', 'label', $object->category_code); + print '
'.$langs->trans("TicketGroup").''; + print $langs->getLabelFromKey($db, $object->category_code, 'c_ticket_category', 'code', 'label'); print '
'.$langs->trans("TicketSeverity").''; - print $langs->getLabelFromKey($db, 'TicketSeverityShort'.$object->severity_code, 'c_ticket_severity', 'code', 'label', $object->severity_code); + print $langs->getLabelFromKey($db, $object->severity_code, 'c_ticket_severity', 'code', 'label'); print '
'; // End table actions @@ -1115,7 +1043,7 @@ // Display navbar with links to change ticket status print ''; - if (!$user->socid && $user->rights->ticket->write && $object->fk_statut < $object::STATUS_CLOSED && GETPOST('set') !== 'properties') { + if (!$user->socid && $user->rights->ticket->write && $object->fk_statut < 8 && GETPOST('set') !== 'properties') { $actionobject->viewStatusActions($object); } @@ -1237,7 +1165,7 @@ print '
'; print '
'; - print dol_get_fiche_end(); + dol_fiche_end(); // Buttons for actions @@ -1251,7 +1179,7 @@ { // Show link to add a message (if read and not closed) if ($object->fk_statut < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage") { - print '
'.$langs->trans('TicketAddMessage').'
'; + print '
'.$langs->trans('TicketAddMessage').'
'; } // Link to create an intervention @@ -1263,10 +1191,6 @@ print '
'.$langs->trans('TicketAddIntervention').'
'; } - if ($user->rights->ticket->write && $object->fk_statut < Ticket::STATUS_CLOSED) { - print '
'.$langs->trans('Modify').'
'; - } - // Close ticket if statut is read if ($object->fk_statut > 0 && $object->fk_statut < Ticket::STATUS_CLOSED && $user->rights->ticket->write) { print '
'.$langs->trans('CloseTicket').'
'; @@ -1279,12 +1203,14 @@ // Delete ticket if ($user->rights->ticket->delete && !$user->socid) { - print '
'.$langs->trans('Delete').'
'; + print '
'.$langs->trans('Delete').'
'; } } print ''."\n"; - } else { - //print '
'; + } + else + { + print '
'; } // Select mail models is same action as presend @@ -1308,7 +1234,7 @@ $object->fetch_thirdparty(); $substitutionarray['__THIRDPARTY_NAME__'] = $object->thirdparty->name; } - $substitutionarray['__USER_SIGNATURE__'] = $user->signature; + $substitutionarray['__SIGNATURE__'] = $user->signature; $substitutionarray['__TICKET_TRACKID__'] = $object->track_id; $substitutionarray['__TICKET_REF__'] = $object->ref; $substitutionarray['__TICKET_SUBJECT__'] = $object->subject; @@ -1333,7 +1259,6 @@ $morehtmlright .= $form->textwithpicto(''.$langs->trans("TicketMessageSubstitutionReplacedByGenericValues").'', $help, 1, 'helpclickable', '', 0, 3, 'helpsubstitution'); print '
'; - print load_fiche_titre($langs->trans('TicketAddMessage'), $morehtmlright, 'messages@ticket'); print '
'; @@ -1373,7 +1298,7 @@ } // 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; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; @@ -1382,17 +1307,17 @@ $morehtmlright = ''; - $messagingUrl = DOL_URL_ROOT.'/ticket/agenda.php?track_id='.$object->track_id; + $messagingUrl = DOL_URL_ROOT . '/ticket/agenda.php?track_id=' . $object->track_id; $morehtmlright .= dolGetButtonTitle($langs->trans('MessageListViewType'), '', 'fal fa-list-alt imgforviewmode', $messagingUrl, '', 1); // Show link to add a message (if read and not closed) $btnstatus = $object->fk_statut < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage" && $action != "add_message"; - $url = 'card.php?track_id='.$object->track_id.'&action=presend_addmessage&mode=init'; + $url = 'card.php?track_id=' . $object->track_id . '&action=presend_addmessage&mode=init'; $morehtmlright .= dolGetButtonTitle($langs->trans('TicketAddMessage'), '', 'fal fa-comment-dots', $url, 'add-new-ticket-title-button', $btnstatus); // Show link to add event (if read and not closed) - $btnstatus = $object->fk_statut < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage" && $action != "add_message"; ; - $url = dol_buildpath('/comm/action/card.php', 1).'?action=create&datep='.date('YmdHi').'&origin=ticket&originid='.$object->id.'&projectid='.$object->fk_project.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?track_id='.$object->track_id); + $btnstatus = $object->fk_statut < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage" && $action != "add_message";; + $url = dol_buildpath('/comm/action/card.php', 1) . '?action=create&datep=' . date('YmdHi') . '&origin=ticket&originid=' . $object->id . '&projectid=' . $object->fk_project . '&backtopage=' . urlencode($_SERVER["PHP_SELF"] . '?track_id=' . $object->track_id); $morehtmlright .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fal fa-plus-circle', $url, 'add-new-ticket-even-button', $btnstatus); print_barre_liste($langs->trans("ActionsOnTicket"), 0, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', 0, -1, '', 0, $morehtmlright, '', 0, 1, 1); @@ -1426,7 +1351,7 @@ $morehtmlcenter .= dolGetButtonTitle($langs->trans('FullList'), '', 'fa fa-list-alt imgforviewmode', DOL_URL_ROOT.'/ticket/agenda.php?id='.$object->id); // List of actions on element - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; $formactions = new FormActions($db); $somethingshown = $formactions->showactions($object, 'ticket', $socid, 1, 'listactions', $MAXEVENT, '', $morehtmlcenter); --- /tmp/dsg/dolibarr/htdocs/ticket/github_contact.php +++ /tmp/dsg/dolibarr/htdocs/ticket/client_contact.php @@ -52,8 +52,8 @@ // Protection if external user if ($user->socid > 0) { - $socid = $user->socid; - accessforbidden(); + $socid = $user->socid; + accessforbidden(); } // Store current page url @@ -67,46 +67,45 @@ */ if ($action == 'addcontact' && $user->rights->ticket->write) { - $result = $object->fetch($id, '', $track_id); - - if ($result > 0 && ($id > 0 || (!empty($track_id)))) { - $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); - $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); - $result = $object->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); - } - - if ($result >= 0) { - Header("Location: ".$url_page_current."?id=".$object->id); - exit; - } else { - if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - $langs->load("errors"); - setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); - } else { - setEventMessages($object->error, $object->errors, 'errors'); - } - } + $result = $object->fetch($id, '', $track_id); + + if ($result > 0 && ($id > 0 || (!empty($track_id)))) { + $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); + $result = $object->add_contact($contactid, $type, $source); + } + + if ($result >= 0) { + Header("Location: ".$url_page_current."?id=".$object->id); + exit; + } else { + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { + $langs->load("errors"); + setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } + } } // bascule du statut d'un contact if ($action == 'swapstatut' && $user->rights->ticket->write) { - if ($object->fetch($id, '', $track_id)) { - $result = $object->swapContactStatus($ligne); - } else { - dol_print_error($db, $object->error); - } + if ($object->fetch($id, '', $track_id)) { + $result = $object->swapContactStatus($ligne); + } else { + dol_print_error($db, $object->error); + } } // Efface un contact if ($action == 'deletecontact' && $user->rights->ticket->write) { - if ($object->fetch($id, '', $track_id)) { - $result = $object->delete_contact($lineid); - - if ($result >= 0) { - Header("Location: ".$url_page_current."?id=".$object->id); - exit; - } - } + if ($object->fetch($id, '', $track_id)) { + $result = $object->delete_contact($lineid); + + if ($result >= 0) { + Header("Location: ".$url_page_current."?id=".$object->id); + exit; + } + } } @@ -125,112 +124,112 @@ if ($id > 0 || !empty($track_id) || !empty($ref)) { if ($object->fetch($id, $ref, $track_id) > 0) - { - if ($socid > 0) { - $object->fetch_thirdparty(); - $head = societe_prepare_head($object->thirdparty); - print dol_get_fiche_head($head, 'ticket', $langs->trans("ThirdParty"), 0, 'company'); - dol_banner_tab($object->thirdparty, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom'); - print dol_get_fiche_end(); - } - - if (!$user->socid && $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY) { - $object->next_prev_filter = "te.fk_user_assign = '".$user->id."'"; - } elseif ($user->socid > 0) { - $object->next_prev_filter = "te.fk_soc = '".$user->socid."'"; - } - - $head = ticket_prepare_head($object); - - print dol_get_fiche_head($head, 'contact', $langs->trans("Ticket"), -1, 'ticket'); - - $morehtmlref = '
'; - $morehtmlref .= $object->subject; - // Author - if ($object->fk_user_create > 0) { - $morehtmlref .= '
'.$langs->trans("CreatedBy").' : '; - - $langs->load("users"); - $fuser = new User($db); - $fuser->fetch($object->fk_user_create); - $morehtmlref .= $fuser->getNomUrl(0); - } - if (!empty($object->origin_email)) { - $morehtmlref .= '
'.$langs->trans("CreatedBy").' : '; - $morehtmlref .= $object->origin_email.' ('.$langs->trans("TicketEmailOriginIssuer").')'; - } - - // Thirdparty - if (!empty($conf->societe->enabled)) - { - $morehtmlref .= '
'.$langs->trans('ThirdParty'); - /*if ($action != 'editcustomer' && $object->fk_statut < 8 && !$user->socid && $user->rights->ticket->write) { + { + if ($socid > 0) { + $object->fetch_thirdparty(); + $head = societe_prepare_head($object->thirdparty); + dol_fiche_head($head, 'ticket', $langs->trans("ThirdParty"), 0, 'company'); + dol_banner_tab($object->thirdparty, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom'); + dol_fiche_end(); + } + + if (!$user->socid && $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY) { + $object->next_prev_filter = "te.fk_user_assign = '".$user->id."'"; + } elseif ($user->socid > 0) { + $object->next_prev_filter = "te.fk_soc = '".$user->socid."'"; + } + + $head = ticket_prepare_head($object); + + dol_fiche_head($head, 'contact', $langs->trans("Ticket"), -1, 'ticket'); + + $morehtmlref = '
'; + $morehtmlref .= $object->subject; + // Author + if ($object->fk_user_create > 0) { + $morehtmlref .= '
'.$langs->trans("CreatedBy").' : '; + + $langs->load("users"); + $fuser = new User($db); + $fuser->fetch($object->fk_user_create); + $morehtmlref .= $fuser->getNomUrl(0); + } + if (!empty($object->origin_email)) { + $morehtmlref .= '
'.$langs->trans("CreatedBy").' : '; + $morehtmlref .= $object->origin_email.' ('.$langs->trans("TicketEmailOriginIssuer").')'; + } + + // Thirdparty + if (!empty($conf->societe->enabled)) + { + $morehtmlref .= '
'.$langs->trans('ThirdParty'); + /*if ($action != 'editcustomer' && $object->fk_statut < 8 && !$user->socid && $user->rights->ticket->write) { $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('Edit'), 1) . ''; }*/ - $morehtmlref .= ' : '; - if ($action == 'editcustomer') { - $morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, $object->socid, 'editcustomer', '', 1, 0, 0, array(), 1); - } else { - $morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, $object->socid, 'none', '', 1, 0, 0, array(), 1); - } - } - - // Project - if (!empty($conf->projet->enabled)) - { - $langs->load("projects"); - $morehtmlref .= '
'.$langs->trans('Project').' '; - if ($user->rights->ticket->write) - { - if ($action != 'classify') { - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; + $morehtmlref .= ' : '; + if ($action == 'editcustomer') { + $morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, $object->socid, 'editcustomer', '', 1, 0, 0, array(), 1); + } else { + $morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, $object->socid, 'none', '', 1, 0, 0, array(), 1); + } + } + + // Project + if (!empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($user->rights->ticket->write) + { + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; $morehtmlref .= ' : '; } - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; - $morehtmlref .= ''; - } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= $proj->getNomUrl(1); - } else { - $morehtmlref .= ''; - } - } - } - - $morehtmlref .= '
'; - - $linkback = ''.$langs->trans("BackToList").' '; - - dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', 'ref', $morehtmlref, $param, 0, '', '', 1, ''); - - print dol_get_fiche_end(); - - //print '
'; - - $permission = $user->rights->ticket->write; - - // Contacts lines (modules that overwrite templates must declare this into descriptor) - $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl')); - foreach ($dirtpls as $reldir) { - $res = @include dol_buildpath($reldir.'/contacts.tpl.php'); - if ($res) { - break; - } - } - } else { - print "ErrorRecordNotFound"; - } + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= $proj->getNomUrl(1); + } else { + $morehtmlref .= ''; + } + } + } + + $morehtmlref .= '
'; + + $linkback = ''.$langs->trans("BackToList").' '; + + dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', 'ref', $morehtmlref, $param, 0, '', '', 1, ''); + + dol_fiche_end(); + + //print '
'; + + $permission = $user->rights->ticket->write; + + // Contacts lines (modules that overwrite templates must declare this into descriptor) + $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl')); + foreach ($dirtpls as $reldir) { + $res = @include dol_buildpath($reldir.'/contacts.tpl.php'); + if ($res) { + break; + } + } + } else { + print "ErrorRecordNotFound"; + } } // End of page --- /tmp/dsg/dolibarr/htdocs/ticket/github_document.php +++ /tmp/dsg/dolibarr/htdocs/ticket/client_document.php @@ -44,7 +44,7 @@ // Security check if (!$user->rights->ticket->read) { - accessforbidden(); + accessforbidden(); } // Get parameters @@ -65,7 +65,7 @@ if ($result < 0) { setEventMessages($object->error, $object->errors, 'errors'); } else { - $upload_dir = $conf->ticket->dir_output."/".dol_sanitizeFileName($object->ref); + $upload_dir = $conf->ticket->dir_output."/".dol_sanitizeFileName($object->ref); } @@ -91,112 +91,114 @@ /* * Show tabs */ - if ($socid > 0) { - $object->fetch_thirdparty(); - $head = societe_prepare_head($object->thirdparty); - print dol_get_fiche_head($head, 'ticket', $langs->trans("ThirdParty"), 0, 'company'); - dol_banner_tab($object->thirdparty, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom'); - print dol_get_fiche_end(); - } - - if (!$user->socid && $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY) { - $object->next_prev_filter = "te.fk_user_assign = '".$user->id."'"; - } elseif ($user->socid > 0) { - $object->next_prev_filter = "te.fk_soc = '".$user->socid."'"; - } - - $head = ticket_prepare_head($object); - - print dol_get_fiche_head($head, 'tabTicketDocument', $langs->trans("Ticket"), 0, 'ticket'); - - $morehtmlref = '
'; - $morehtmlref .= $object->subject; - // Author - if ($object->fk_user_create > 0) { - $morehtmlref .= '
'.$langs->trans("CreatedBy").' : '; - - $langs->load("users"); - $fuser = new User($db); - $fuser->fetch($object->fk_user_create); - $morehtmlref .= $fuser->getNomUrl(0); - } - if (!empty($object->origin_email)) { - $morehtmlref .= '
'.$langs->trans("CreatedBy").' : '; - $morehtmlref .= $object->origin_email.' ('.$langs->trans("TicketEmailOriginIssuer").')'; - } - - // Thirdparty - if (!empty($conf->societe->enabled)) - { - $morehtmlref .= '
'.$langs->trans('ThirdParty'); - /*if ($action != 'editcustomer' && $object->fk_statut < 8 && !$user->socid && $user->rights->ticket->write) { + if ($socid > 0) { + $object->fetch_thirdparty(); + $head = societe_prepare_head($object->thirdparty); + dol_fiche_head($head, 'ticket', $langs->trans("ThirdParty"), 0, 'company'); + dol_banner_tab($object->thirdparty, 'socid', '', ($user->socid ? 0 : 1), 'rowid', 'nom'); + dol_fiche_end(); + } + + if (!$user->socid && $conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY) { + $object->next_prev_filter = "te.fk_user_assign = '".$user->id."'"; + } elseif ($user->socid > 0) { + $object->next_prev_filter = "te.fk_soc = '".$user->socid."'"; + } + + $head = ticket_prepare_head($object); + + dol_fiche_head($head, 'tabTicketDocument', $langs->trans("Ticket"), 0, 'ticket'); + + $morehtmlref = '
'; + $morehtmlref .= $object->subject; + // Author + if ($object->fk_user_create > 0) { + $morehtmlref .= '
'.$langs->trans("CreatedBy").' : '; + + $langs->load("users"); + $fuser = new User($db); + $fuser->fetch($object->fk_user_create); + $morehtmlref .= $fuser->getNomUrl(0); + } + if (!empty($object->origin_email)) { + $morehtmlref .= '
'.$langs->trans("CreatedBy").' : '; + $morehtmlref .= $object->origin_email.' ('.$langs->trans("TicketEmailOriginIssuer").')'; + } + + // Thirdparty + if (!empty($conf->societe->enabled)) + { + $morehtmlref .= '
'.$langs->trans('ThirdParty'); + /*if ($action != 'editcustomer' && $object->fk_statut < 8 && !$user->socid && $user->rights->ticket->write) { $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('Edit'), 1) . ''; }*/ - $morehtmlref .= ' : '; - if ($action == 'editcustomer') { - $morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, $object->socid, 'editcustomer', '', 1, 0, 0, array(), 1); - } else { - $morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, $object->socid, 'none', '', 1, 0, 0, array(), 1); - } - } - - // Project - if (!empty($conf->projet->enabled)) - { - $langs->load("projects"); - $morehtmlref .= '
'.$langs->trans('Project').' '; - if ($user->rights->ticket->write) - { - if ($action != 'classify') { - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; + $morehtmlref .= ' : '; + if ($action == 'editcustomer') { + $morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, $object->socid, 'editcustomer', '', 1, 0, 0, array(), 1); + } else { + $morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, $object->socid, 'none', '', 1, 0, 0, array(), 1); + } + } + + // Project + if (!empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref .= '
'.$langs->trans('Project').' '; + if ($user->rights->ticket->write) + { + if ($action != 'classify') { + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; $morehtmlref .= ' : '; } - if ($action == 'classify') { - //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); - $morehtmlref .= '
'; - $morehtmlref .= ''; - $morehtmlref .= ''; - $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); - $morehtmlref .= ''; - $morehtmlref .= '
'; - } else { - $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); - } - } else { - if (!empty($object->fk_project)) { - $proj = new Project($db); - $proj->fetch($object->fk_project); - $morehtmlref .= $proj->getNomUrl(1); - } else { - $morehtmlref .= ''; - } - } - } - - $morehtmlref .= '
'; - - $linkback = ''.$langs->trans("BackToList").' '; - - dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); - - print dol_get_fiche_end(); - - // Build file list - $filearray = dol_dir_list($upload_dir, "files", 0, '', '\.meta$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1); - $totalsize = 0; - foreach ($filearray as $key => $file) { - $totalsize += $file['size']; - } - - //$object->ref = $object->track_id; // For compatibility we use track ID for directory - $modulepart = 'ticket'; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref .= '
'; + $morehtmlref .= ''; + $morehtmlref .= ''; + $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref .= ''; + $morehtmlref .= '
'; + } else { + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (!empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= $proj->getNomUrl(1); + } else { + $morehtmlref .= ''; + } + } + } + + $morehtmlref .= '
'; + + $linkback = ''.$langs->trans("BackToList").' '; + + dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); + + dol_fiche_end(); + + // Build file list + $filearray = dol_dir_list($upload_dir, "files", 0, '', '\.meta$', $sortfield, (strtolower($sortorder) == 'desc' ? SORT_DESC : SORT_ASC), 1); + $totalsize = 0; + foreach ($filearray as $key => $file) { + $totalsize += $file['size']; + } + + //$object->ref = $object->track_id; // For compatibility we use track ID for directory + $modulepart = 'ticket'; $permission = $user->rights->ticket->write; $permtoedit = $user->rights->ticket->write; $param = '&id='.$object->id; include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php'; -} else { - accessforbidden('', 0, 1); +} +else +{ + accessforbidden('', 0, 1); } // End of page --- /tmp/dsg/dolibarr/htdocs/ticket/github_index.php +++ /tmp/dsg/dolibarr/htdocs/ticket/client_index.php @@ -45,7 +45,7 @@ $action = GETPOST('action', 'aZ09'); if ($user->socid) { - $socid = $user->socid; + $socid = $user->socid; } // Security check @@ -90,22 +90,22 @@ $param_showtot = 'DOLUSERCOOKIE_ticket_by_status_showtot'; $autosetarray = preg_split("/[,;:]+/", GETPOST('DOL_AUTOSET_COOKIE')); if (in_array('DOLUSERCOOKIE_ticket_by_status', $autosetarray)) { - $endyear = GETPOST($param_year, 'int'); - $shownb = GETPOST($param_shownb, 'alpha'); - $showtot = GETPOST($param_showtot, 'alpha'); + $endyear = GETPOST($param_year, 'int'); + $shownb = GETPOST($param_shownb, 'alpha'); + $showtot = GETPOST($param_showtot, 'alpha'); } else { - $tmparray = json_decode($_COOKIE['DOLUSERCOOKIE_ticket_by_status'], true); - $endyear = $tmparray['year']; - $shownb = $tmparray['shownb']; - $showtot = $tmparray['showtot']; + $tmparray = json_decode($_COOKIE['DOLUSERCOOKIE_ticket_by_status'], true); + $endyear = $tmparray['year']; + $shownb = $tmparray['shownb']; + $showtot = $tmparray['showtot']; } if (empty($shownb) && empty($showtot)) { - $showtot = 1; + $showtot = 1; } $nowarray = dol_getdate(dol_now(), true); if (empty($endyear)) { - $endyear = $nowarray['year']; + $endyear = $nowarray['year']; } $startyear = $endyear - 1; @@ -118,92 +118,92 @@ * Statistics area */ $tick = array( - 'unread' => 0, - 'read' => 0, - 'answered' => 0, - 'assigned' => 0, - 'inprogress' => 0, - 'waiting' => 0, - 'closed' => 0, - 'deleted' => 0, + 'unread' => 0, + 'read' => 0, + 'answered' => 0, + 'assigned' => 0, + 'inprogress' => 0, + 'waiting' => 0, + 'closed' => 0, + 'deleted' => 0, ); $sql = "SELECT t.fk_statut, COUNT(t.fk_statut) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."ticket as t"; if (!$user->rights->societe->client->voir && !$socid) { - $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= ' WHERE t.entity IN ('.getEntity('ticket').')'; $sql .= dolSqlDateFilter('datec', 0, 0, $endyear); if (!$user->rights->societe->client->voir && !$socid) { - $sql .= " AND t.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; + $sql .= " AND t.fk_soc = sc.fk_soc AND sc.fk_user = ".$user->id; } // External users restriction if ($user->socid > 0) { - $sql .= " AND t.fk_soc= ".((int) $user->socid); + $sql .= " AND t.fk_soc='".$user->socid."'"; } else { - // For internals users, - if (!empty($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY) && !$user->rights->ticket->manage) { - $sql .= " AND t.fk_user_assign = ".$user->id; - } + // For internals users, + if (!empty($conf->global->TICKET_LIMIT_VIEW_ASSIGNED_ONLY) && !$user->rights->ticket->manage) { + $sql .= " AND t.fk_user_assign=".$user->id; + } } $sql .= " GROUP BY t.fk_statut"; $result = $db->query($sql); if ($result) { - while ($objp = $db->fetch_object($result)) { - $found = 0; - if ($objp->fk_statut == Ticket::STATUS_NOT_READ) { - $tick['unread'] = $objp->nb; - } - if ($objp->fk_statut == Ticket::STATUS_READ) { - $tick['read'] = $objp->nb; - } - if ($objp->fk_statut == Ticket::STATUS_NEED_MORE_INFO) { - $tick['needmoreinfo'] = $objp->nb; - } - if ($objp->fk_statut == Ticket::STATUS_ASSIGNED) { - $tick['assigned'] = $objp->nb; - } - if ($objp->fk_statut == Ticket::STATUS_IN_PROGRESS) { - $tick['inprogress'] = $objp->nb; - } - if ($objp->fk_statut == Ticket::STATUS_WAITING) { - $tick['waiting'] = $objp->nb; - } - if ($objp->fk_statut == Ticket::STATUS_CLOSED) { - $tick['closed'] = $objp->nb; - } - if ($objp->fk_statut == Ticket::STATUS_CANCELED) { - $tick['canceled'] = $objp->nb; - } - } - - include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; - - $dataseries = array(); - $colorseries = array(); - - $dataseries[] = array('label' => $langs->transnoentitiesnoconv($tickesupstatic->statuts_short[Ticket::STATUS_NOT_READ]), 'data' => round($tick['unread'])); - $colorseries[Ticket::STATUS_NOT_READ] = '-'.$badgeStatus0; - $dataseries[] = array('label' => $langs->transnoentitiesnoconv($tickesupstatic->statuts_short[Ticket::STATUS_READ]), 'data' => round($tick['read'])); - $colorseries[Ticket::STATUS_READ] = $badgeStatus1; - $dataseries[] = array('label' => $langs->transnoentitiesnoconv($tickesupstatic->statuts_short[Ticket::STATUS_ASSIGNED]), 'data' => round($tick['assigned'])); - $colorseries[Ticket::STATUS_ASSIGNED] = $badgeStatus3; - $dataseries[] = array('label' => $langs->transnoentitiesnoconv($tickesupstatic->statuts_short[Ticket::STATUS_IN_PROGRESS]), 'data' => round($tick['inprogress'])); - $colorseries[Ticket::STATUS_IN_PROGRESS] = $badgeStatus4; - $dataseries[] = array('label' => $langs->transnoentitiesnoconv($tickesupstatic->statuts_short[Ticket::STATUS_WAITING]), 'data' => round($tick['waiting'])); - $colorseries[Ticket::STATUS_WAITING] = '-'.$badgeStatus4; - $dataseries[] = array('label' => $langs->transnoentitiesnoconv($tickesupstatic->statuts_short[Ticket::STATUS_NEED_MORE_INFO]), 'data' => round($tick['needmoreinfo'])); - $colorseries[Ticket::STATUS_NEED_MORE_INFO] = '-'.$badgeStatus3; - $dataseries[] = array('label' => $langs->transnoentitiesnoconv($tickesupstatic->statuts_short[Ticket::STATUS_CANCELED]), 'data' => round($tick['canceled'])); - $colorseries[Ticket::STATUS_CANCELED] = $badgeStatus9; - $dataseries[] = array('label' => $langs->transnoentitiesnoconv($tickesupstatic->statuts_short[Ticket::STATUS_CLOSED]), 'data' => round($tick['closed'])); - $colorseries[Ticket::STATUS_CLOSED] = $badgeStatus6; + while ($objp = $db->fetch_object($result)) { + $found = 0; + if ($objp->fk_statut == Ticket::STATUS_NOT_READ) { + $tick['unread'] = $objp->nb; + } + if ($objp->fk_statut == Ticket::STATUS_READ) { + $tick['read'] = $objp->nb; + } + if ($objp->fk_statut == Ticket::STATUS_NEED_MORE_INFO) { + $tick['needmoreinfo'] = $objp->nb; + } + if ($objp->fk_statut == Ticket::STATUS_ASSIGNED) { + $tick['assigned'] = $objp->nb; + } + if ($objp->fk_statut == Ticket::STATUS_IN_PROGRESS) { + $tick['inprogress'] = $objp->nb; + } + if ($objp->fk_statut == Ticket::STATUS_WAITING) { + $tick['waiting'] = $objp->nb; + } + if ($objp->fk_statut == Ticket::STATUS_CLOSED) { + $tick['closed'] = $objp->nb; + } + if ($objp->fk_statut == Ticket::STATUS_CANCELED) { + $tick['canceled'] = $objp->nb; + } + } + + include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php'; + + $dataseries = array(); + $colorseries = array(); + + $dataseries[] = array('label' => $langs->trans("Unread"), 'data' => round($tick['unread'])); + $colorseries[Ticket::STATUS_NOT_READ] = '-'.$badgeStatus0; + $dataseries[] = array('label' => $langs->trans("Read"), 'data' => round($tick['read'])); + $colorseries[Ticket::STATUS_READ] = $badgeStatus1; + $dataseries[] = array('label' => $langs->trans("Assigned"), 'data' => round($tick['assigned'])); + $colorseries[Ticket::STATUS_ASSIGNED] = $badgeStatus3; + $dataseries[] = array('label' => $langs->trans("InProgress"), 'data' => round($tick['inprogress'])); + $colorseries[Ticket::STATUS_IN_PROGRESS] = $badgeStatus4; + $dataseries[] = array('label' => $langs->trans("Suspended"), 'data' => round($tick['waiting'])); + $colorseries[Ticket::STATUS_WAITING] = '-'.$badgeStatus3; + $dataseries[] = array('label' => $langs->trans("NeedMoreInformation"), 'data' => round($tick['needmoreinfo'])); + $colorseries[Ticket::STATUS_NEED_MORE_INFO] = $badgeStatus9; + $dataseries[] = array('label' => $langs->trans("Canceled"), 'data' => round($tick['canceled'])); + $colorseries[Ticket::STATUS_CANCELED] = $badgeStatus9; + $dataseries[] = array('label' => $langs->trans("Closed"), 'data' => round($tick['closed'])); + $colorseries[Ticket::STATUS_CLOSED] = $badgeStatus6; } else { - dol_print_error($db); + dol_print_error($db); } $stringtoshow = '