Maxi debug of module ticket
This commit is contained in:
parent
94f0634492
commit
ec34ce1e64
@ -733,40 +733,97 @@ class FormTicket
|
||||
print ajax_combobox('select'.$htmlname);
|
||||
}
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Clear list of attached files in send mail form (also stored in session)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function clear_attached_files()
|
||||
{
|
||||
// phpcs:enable
|
||||
global $conf,$user;
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
|
||||
// Set tmp user directory
|
||||
$vardir=$conf->user->dir_output."/".$user->id;
|
||||
$upload_dir = $vardir.'/temp/'; // TODO Add $keytoavoidconflict in upload_dir path
|
||||
if (is_dir($upload_dir)) dol_delete_dir_recursive($upload_dir);
|
||||
|
||||
$keytoavoidconflict = empty($this->trackid)?'':'-'.$this->trackid; // this->trackid must be defined
|
||||
unset($_SESSION["listofpaths".$keytoavoidconflict]);
|
||||
unset($_SESSION["listofnames".$keytoavoidconflict]);
|
||||
unset($_SESSION["listofmimes".$keytoavoidconflict]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form to add message on ticket
|
||||
*
|
||||
* @param string $width Width of form
|
||||
* @return void
|
||||
* @param string $width Width of form
|
||||
* @return void
|
||||
*/
|
||||
public function showMessageForm($width = '40%')
|
||||
{
|
||||
global $conf, $langs, $user, $mysoc;
|
||||
global $conf, $langs, $user, $hookmanager, $form, $mysoc;
|
||||
|
||||
$formmail = new FormMail($this->db);
|
||||
$addfileaction = 'addfile';
|
||||
|
||||
if (! is_object($form)) $form=new Form($this->db);
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('other', 'mails'));
|
||||
|
||||
$addfileaction = 'addfile';
|
||||
// Clear temp files. Must be done at beginning, before call of triggers
|
||||
if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1'))
|
||||
{
|
||||
$this->clear_attached_files();
|
||||
}
|
||||
|
||||
$form = new Form($this->db);
|
||||
$formmail = new FormMail($this->db);
|
||||
// Define output language
|
||||
$outputlangs = $langs;
|
||||
$newlang = '';
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $this->param['langsmodels'];
|
||||
if (! empty($newlang))
|
||||
{
|
||||
$outputlangs = new Translate("", $conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
$outputlangs->load('other');
|
||||
}
|
||||
|
||||
// Get message template for $this->param["models"] into c_email_templates
|
||||
$arraydefaultmessage = -1;
|
||||
if ($this->param['models'] != 'none')
|
||||
{
|
||||
$model_id=0;
|
||||
if (array_key_exists('models_id', $this->param))
|
||||
{
|
||||
$model_id=$this->param["models_id"];
|
||||
}
|
||||
|
||||
$arraydefaultmessage=$formmail->getEMailTemplate($this->db, $this->param["models"], $user, $outputlangs, $model_id); // If $model_id is empty, preselect the first one
|
||||
}
|
||||
|
||||
// Define list of attached files
|
||||
$listofpaths = array();
|
||||
$listofnames = array();
|
||||
$listofmimes = array();
|
||||
if (!empty($_SESSION["listofpaths"])) {
|
||||
$listofpaths = explode(';', $_SESSION["listofpaths"]);
|
||||
$keytoavoidconflict = empty($this->trackid)?'':'-'.$this->trackid; // this->trackid must be defined
|
||||
|
||||
if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1'))
|
||||
{
|
||||
if (! empty($arraydefaultmessage->joinfiles) && is_array($this->param['fileinit']))
|
||||
{
|
||||
foreach($this->param['fileinit'] as $file)
|
||||
{
|
||||
$this->add_attached_files($file, basename($file), dol_mimetype($file));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($_SESSION["listofnames"])) {
|
||||
$listofnames = explode(';', $_SESSION["listofnames"]);
|
||||
}
|
||||
|
||||
if (!empty($_SESSION["listofmimes"])) {
|
||||
$listofmimes = explode(';', $_SESSION["listofmimes"]);
|
||||
}
|
||||
if (! empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths=explode(';', $_SESSION["listofpaths".$keytoavoidconflict]);
|
||||
if (! empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames=explode(';', $_SESSION["listofnames".$keytoavoidconflict]);
|
||||
if (! empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes=explode(';', $_SESSION["listofmimes".$keytoavoidconflict]);
|
||||
|
||||
// Define output language
|
||||
$outputlangs = $langs;
|
||||
@ -808,6 +865,7 @@ class FormTicket
|
||||
print '<form method="post" name="ticket" enctype="multipart/form-data" action="' . $this->param["returnurl"] . '">';
|
||||
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
|
||||
print '<input type="hidden" name="action" value="' . $this->action . '">';
|
||||
print '<input type="hidden" name="actionbis" value="add_message">';
|
||||
foreach ($this->param as $key => $value) {
|
||||
print '<input type="hidden" name="' . $key . '" value="' . $value . '">';
|
||||
}
|
||||
|
||||
@ -77,7 +77,7 @@ print '</div>';
|
||||
print '</div>';
|
||||
|
||||
// End of page
|
||||
htmlPrintOnlinePaymentFooter($mysoc, $langs, 1, $suffix, $object);
|
||||
htmlPrintOnlinePaymentFooter($mysoc, $langs, 0, $suffix, $object);
|
||||
|
||||
llxFooter('', 'public');
|
||||
|
||||
|
||||
@ -706,7 +706,7 @@ if ($action == "view_ticketlist")
|
||||
print "</div>";
|
||||
|
||||
// End of page
|
||||
htmlPrintOnlinePaymentFooter($mysoc, $langs, 1, $suffix, $object);
|
||||
htmlPrintOnlinePaymentFooter($mysoc, $langs, 0, $suffix, $object);
|
||||
|
||||
llxFooter('', 'public');
|
||||
|
||||
|
||||
@ -48,8 +48,9 @@ $langs->loadLangs(array("companies","other","ticket"));
|
||||
|
||||
// Get parameters
|
||||
$track_id = GETPOST('track_id', 'alpha');
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$email = GETPOST('email', 'alpha');
|
||||
$cancel = GETPOST('cancel', 'alpha');
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$email = GETPOST('email', 'alpha');
|
||||
|
||||
if (GETPOST('btn_view_ticket')) {
|
||||
unset($_SESSION['email_customer']);
|
||||
@ -65,7 +66,17 @@ $object = new ActionsTicket($db);
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($action == "view_ticket" || $action == "add_message" || $action == "close" || $action == "confirm_public_close" || $action == "add_public_message") {
|
||||
if ($cancel)
|
||||
{
|
||||
if (! empty($backtopage))
|
||||
{
|
||||
header("Location: ".$backtopage);
|
||||
exit;
|
||||
}
|
||||
$action='view_ticket';
|
||||
}
|
||||
|
||||
if ($action == "view_ticket" || $action == "presend" || $action == "close" || $action == "confirm_public_close" || $action == "add_message") {
|
||||
$error = 0;
|
||||
$display_ticket = false;
|
||||
if (!strlen($track_id)) {
|
||||
@ -108,12 +119,33 @@ if ($action == "view_ticket" || $action == "add_message" || $action == "close" |
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($object->dao->fk_soc > 0) {
|
||||
// Check email of thirdparty of ticket
|
||||
if ($object->dao->fk_soc > 0 || $object->dao->socid > 0) {
|
||||
$object->dao->fetch_thirdparty();
|
||||
if ($email == $object->dao->thirdparty->email) {
|
||||
$display_ticket = true;
|
||||
$_SESSION['email_customer'] = $email;
|
||||
}
|
||||
}
|
||||
if ($email == $object->dao->origin_email || $email == $object->dao->thirdparty->email) {
|
||||
$display_ticket = true;
|
||||
$_SESSION['email_customer'] = $email;
|
||||
// Check if email is email of creator
|
||||
if ($object->dao->fk_user_create > 0)
|
||||
{
|
||||
$tmpuser = new User($db);
|
||||
$tmpuser->fetch($object->dao->fk_user_create);
|
||||
if ($email == $tmpuser->email) {
|
||||
$display_ticket = true;
|
||||
$_SESSION['email_customer'] = $email;
|
||||
}
|
||||
}
|
||||
// Check if email is email of creator
|
||||
if ($object->dao->fk_user_assign > 0 && $object->dao->fk_user_assign != $object->dao->fk_user_create)
|
||||
{
|
||||
$tmpuser = new User($db);
|
||||
$tmpuser->fetch($object->dao->fk_user_assign);
|
||||
if ($email == $tmpuser->email) {
|
||||
$display_ticket = true;
|
||||
$_SESSION['email_customer'] = $email;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$error++;
|
||||
@ -122,9 +154,11 @@ if ($action == "view_ticket" || $action == "add_message" || $action == "close" |
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == "add_public_message")
|
||||
if (! $error && $action == "add_message" && $display_ticket)
|
||||
{
|
||||
// TODO Add message...
|
||||
$ret = $object->dao->newMessage($user, $action, 0);
|
||||
|
||||
|
||||
|
||||
|
||||
@ -137,9 +171,9 @@ if ($action == "view_ticket" || $action == "add_message" || $action == "close" |
|
||||
|
||||
if ($error || $errors) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
if ($action == "add_public_message")
|
||||
if ($action == "add_message")
|
||||
{
|
||||
$action = 'add_message';
|
||||
$action = 'presend';
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -172,7 +206,7 @@ llxHeaderTicket($langs->trans("Tickets"), "", 0, 0, $arrayofjs, $arrayofcss);
|
||||
|
||||
print '<div style="margin: 0 auto; width:60%" class="ticketpublicarea">';
|
||||
|
||||
if ($action == "view_ticket" || $action == "add_message" || $action == "close" || $action == "confirm_public_close") {
|
||||
if ($action == "view_ticket" || $action == "presend" || $action == "close" || $action == "confirm_public_close") {
|
||||
if ($display_ticket) {
|
||||
// Confirmation close
|
||||
if ($action == 'close') {
|
||||
@ -272,22 +306,24 @@ if ($action == "view_ticket" || $action == "add_message" || $action == "close" |
|
||||
|
||||
print '<div style="clear: both; margin-top: 1.5em;"></div>';
|
||||
|
||||
if ($action == 'add_message') {
|
||||
if ($action == 'presend') {
|
||||
print load_fiche_titre($langs->trans('TicketAddMessage'), '', 'messages@ticket');
|
||||
|
||||
$formticket = new FormTicket($db);
|
||||
|
||||
$formticket->action = "add_public_message";
|
||||
$formticket->action = "add_message";
|
||||
$formticket->track_id = $object->dao->track_id;
|
||||
$formticket->id = $object->dao->id;
|
||||
|
||||
$formticket->param = array('track_id' => $object->dao->track_id, 'fk_user_create' => '-1', 'returnurl' => DOL_URL_ROOT.'/public/ticket/view.php');
|
||||
|
||||
$formticket->withfile = 2;
|
||||
$formticket->withcancel = 1;
|
||||
|
||||
$formticket->showMessageForm('100%');
|
||||
}
|
||||
|
||||
if ($action != 'add_message') {
|
||||
if ($action != 'presend') {
|
||||
print '<form method="post" id="form_view_ticket_list" name="form_view_ticket_list" enctype="multipart/form-data" action="'.DOL_URL_ROOT.'/public/ticket/list.php">';
|
||||
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
|
||||
print '<input type="hidden" name="action" value="view_ticketlist">';
|
||||
@ -302,7 +338,7 @@ if ($action == "view_ticket" || $action == "add_message" || $action == "close" |
|
||||
|
||||
if ($object->dao->fk_statut < 8) {
|
||||
// New message
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?action=add_message&track_id=' . $object->dao->track_id . '">' . $langs->trans('AddMessage') . '</a></div>';
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?action=presend&mode=init&track_id=' . $object->dao->track_id . '">' . $langs->trans('AddMessage') . '</a></div>';
|
||||
|
||||
// Close ticket
|
||||
if ($object->dao->fk_statut > 0 && $object->dao->fk_statut < 8) {
|
||||
@ -346,7 +382,7 @@ if ($action == "view_ticket" || $action == "add_message" || $action == "close" |
|
||||
print "</div>";
|
||||
|
||||
// End of page
|
||||
htmlPrintOnlinePaymentFooter($mysoc, $langs, 1, $suffix, $object);
|
||||
htmlPrintOnlinePaymentFooter($mysoc, $langs, 0, $suffix, $object);
|
||||
|
||||
llxFooter('', 'public');
|
||||
|
||||
|
||||
@ -75,7 +75,7 @@ if (empty($action) && empty($id) && empty($ref)) $action='view';
|
||||
|
||||
//Select mail models is same action as add_message
|
||||
if (GETPOST('modelselected', 'alpha')) {
|
||||
$action = 'create_message';
|
||||
$action = 'presend';
|
||||
}
|
||||
|
||||
// Load object
|
||||
@ -255,17 +255,17 @@ if (GETPOST('add', 'alpha') && $user->rights->ticket->write) {
|
||||
if ($action == 'edit' && $user->rights->ticket->write) {
|
||||
$error = 0;
|
||||
|
||||
if ($object->fetch(GETPOST('id')) < 0) {
|
||||
if ($object->fetch(GETPOST('id', 'int')) < 0) {
|
||||
$error++;
|
||||
array_push($object->errors, $langs->trans("ErrorTicketIsNotValid"));
|
||||
$_GET["action"] = $_POST["action"] = '';
|
||||
}
|
||||
}
|
||||
|
||||
if (GETPOST('update') && GETPOST('id') && $user->rights->ticket->write) {
|
||||
if (GETPOST('update', 'alpha') && GETPOST('id', 'int') && $user->rights->ticket->write) {
|
||||
$error = 0;
|
||||
|
||||
$ret = $object->fetch(GETPOST('id'));
|
||||
$ret = $object->fetch(GETPOST('id', 'int'));
|
||||
if ($ret < 0) {
|
||||
$error++;
|
||||
array_push($object->errors, $langs->trans("ErrorTicketIsNotValid"));
|
||||
@ -385,7 +385,7 @@ if ($action == "add_message" && GETPOST('btn_add_message') && $user->rights->tic
|
||||
exit;
|
||||
} else {
|
||||
setEventMessages($object->error, null, 'errors');
|
||||
$action = 'create_message';
|
||||
$action = 'presend';
|
||||
}
|
||||
}
|
||||
|
||||
@ -477,7 +477,6 @@ if ($action == 'setsubject') {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($action == 'confirm_reopen' && $user->rights->ticket->manage && !GETPOST('cancel')) {
|
||||
if ($object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')) >= 0) {
|
||||
// prevent browser refresh from reopening ticket several times
|
||||
@ -601,6 +600,8 @@ $autocopy='MAIN_MAIL_AUTOCOPY_TICKET_TO'; // used to know the automatic BCC to
|
||||
$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';
|
||||
|
||||
|
||||
/*
|
||||
@ -640,7 +641,7 @@ if ($action == 'create' || $action == 'presend')
|
||||
$formticket->showForm(1);
|
||||
}
|
||||
|
||||
if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'dellink' || $action == 'create_message' || $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)
|
||||
@ -1155,7 +1156,7 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd
|
||||
|
||||
|
||||
// Buttons for actions
|
||||
if ($action != 'presend' && $action != 'editline') {
|
||||
if ($action != 'presend' && $action != 'presend_addmessage' && $action != 'editline') {
|
||||
print '<div class="tabsAction">'."\n";
|
||||
$parameters=array();
|
||||
$reshook=$hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||
@ -1164,8 +1165,8 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd
|
||||
if (empty($reshook))
|
||||
{
|
||||
// Show link to add a message (if read and not closed)
|
||||
if ($object->fk_statut < Ticket::STATUS_CLOSED && $action != "create_message") {
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?track_id=' . $object->track_id . '&action=create_message">' . $langs->trans('TicketAddMessage') . '</a></div>';
|
||||
if ($object->fk_statut < Ticket::STATUS_CLOSED && $action != "presend" && $action != "presend_addmessage") {
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?track_id=' . $object->track_id . '&action=presend_addmessage&mode=init">' . $langs->trans('TicketAddMessage') . '</a></div>';
|
||||
}
|
||||
|
||||
// Link to create an intervention
|
||||
@ -1200,8 +1201,10 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd
|
||||
if (GETPOST('modelselected')) {
|
||||
$action = 'presend';
|
||||
}
|
||||
// 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 ($action != 'create_message')
|
||||
if ($action != 'presend' && $action != 'presend_addmessage')
|
||||
{
|
||||
print '<div class="fichecenter"><div class="fichehalfleft">';
|
||||
print '<a name="builddoc"></a>'; // ancre
|
||||
@ -1233,23 +1236,23 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd
|
||||
$substitutionarray['__THIRDPARTY_NAME__'] = $object->thirdparty->name;
|
||||
}
|
||||
$substitutionarray['__SIGNATURE__'] = $user->signature;
|
||||
$substitutionarray['__TICKETSUP_TRACKID__'] = $object->track_id;
|
||||
$substitutionarray['__TICKETSUP_REF__'] = $object->ref;
|
||||
$substitutionarray['__TICKETSUP_SUBJECT__'] = $object->subject;
|
||||
$substitutionarray['__TICKETSUP_TYPE__'] = $object->type_code;
|
||||
$substitutionarray['__TICKETSUP_SEVERITY__'] = $object->severity_code;
|
||||
$substitutionarray['__TICKETSUP_CATEGORY__'] = $object->category_code; // For backward compatibility
|
||||
$substitutionarray['__TICKETSUP_ANALYTIC_CODE__'] = $object->category_code;
|
||||
$substitutionarray['__TICKETSUP_MESSAGE__'] = $object->message;
|
||||
$substitutionarray['__TICKETSUP_PROGRESSION__'] = $object->progress;
|
||||
$substitutionarray['__TICKET_TRACKID__'] = $object->track_id;
|
||||
$substitutionarray['__TICKET_REF__'] = $object->ref;
|
||||
$substitutionarray['__TICKET_SUBJECT__'] = $object->subject;
|
||||
$substitutionarray['__TICKET_TYPE__'] = $object->type_code;
|
||||
$substitutionarray['__TICKET_SEVERITY__'] = $object->severity_code;
|
||||
$substitutionarray['__TICKET_CATEGORY__'] = $object->category_code; // For backward compatibility
|
||||
$substitutionarray['__TICKET_ANALYTIC_CODE__'] = $object->category_code;
|
||||
$substitutionarray['__TICKET_MESSAGE__'] = $object->message;
|
||||
$substitutionarray['__TICKET_PROGRESSION__'] = $object->progress;
|
||||
if ($object->fk_user_assign > 0) {
|
||||
$userstat->fetch($object->fk_user_assign);
|
||||
$substitutionarray['__TICKETSUP_USER_ASSIGN__'] = dolGetFirstLastname($userstat->firstname, $userstat->lastname);
|
||||
$substitutionarray['__TICKET_USER_ASSIGN__'] = dolGetFirstLastname($userstat->firstname, $userstat->lastname);
|
||||
}
|
||||
|
||||
if ($object->fk_user_create > 0) {
|
||||
$userstat->fetch($object->fk_user_create);
|
||||
$substitutionarray['__TICKETSUP_USER_CREATE__'] = dolGetFirstLastname($userstat->firstname, $userstat->lastname);
|
||||
$substitutionarray['__TICKET_USER_CREATE__'] = dolGetFirstLastname($userstat->firstname, $userstat->lastname);
|
||||
}
|
||||
foreach ($substitutionarray as $key => $val) {
|
||||
$help.=$key.' -> '.$langs->trans($val).'<br>';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user