diff --git a/htdocs/core/lib/ticket.lib.php b/htdocs/core/lib/ticket.lib.php index 381cbbc4705..04d0c4b9304 100644 --- a/htdocs/core/lib/ticket.lib.php +++ b/htdocs/core/lib/ticket.lib.php @@ -103,6 +103,24 @@ function ticket_prepare_head($object) $h++; } + // Notes + if (!getDolGlobalString('MAIN_DISABLE_NOTES_TAB')) { + $nbNote = 0; + if (!empty($object->note_private)) { + $nbNote++; + } + if (!empty($object->note_public)) { + $nbNote++; + } + $head[$h][0] = DOL_URL_ROOT.'/ticket/note.php?id='.$object->id; + $head[$h][1] = $langs->trans('Notes'); + if ($nbNote > 0) { + $head[$h][1] .= ''.$nbNote.''; + } + $head[$h][2] = 'note'; + $h++; + } + complete_head_from_modules($conf, $langs, $object, $head, $h, 'ticket', 'add', 'core'); // Attached files diff --git a/htdocs/install/mysql/migration/22.0.0-23.0.0.sql b/htdocs/install/mysql/migration/22.0.0-23.0.0.sql index 6f0b8ab2869..35f8eb31a37 100644 --- a/htdocs/install/mysql/migration/22.0.0-23.0.0.sql +++ b/htdocs/install/mysql/migration/22.0.0-23.0.0.sql @@ -40,6 +40,12 @@ ALTER TABLE llx_opensurvey_user_studs ADD COLUMN tms timestamp DEFAULT CURRENT_T -- V23 migration + +ALTER TABLE llx_ticket ADD COLUMN note_public text after resolution; +ALTER TABLE llx_ticket ADD COLUMN note_private text after resolution; +ALTER TABLE llx_ticket ADD COLUMN fk_user_modif integer after resolution; + + CREATE TABLE llx_paiement_extrafields ( rowid integer AUTO_INCREMENT PRIMARY KEY, tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, diff --git a/htdocs/install/mysql/tables/llx_ticket-ticket.sql b/htdocs/install/mysql/tables/llx_ticket-ticket.sql index 7614bcc1ad7..c4c5dd167b4 100644 --- a/htdocs/install/mysql/tables/llx_ticket-ticket.sql +++ b/htdocs/install/mysql/tables/llx_ticket-ticket.sql @@ -1,6 +1,6 @@ -- SQL definition for module ticket -- Copyright (C) 2013 Jean-François FERRY --- Copyright (C) 2023 Charlene Benke +-- Copyright (C) 2023-2025 Charlene Benke -- -- This program is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -32,6 +32,9 @@ CREATE TABLE llx_ticket subject varchar(255), message mediumtext, fk_statut integer, + note_public text, + note_private text, + fk_user_modif integer, resolution integer, progress integer DEFAULT 0, -- progression 0 - 100 or null timing varchar(20), diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 44e0a29429f..81fccd92019 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -110,7 +110,7 @@ class Ticket extends CommonObject public $message; /** - * @var string Private message + * @var string If message is private */ public $private; @@ -311,6 +311,8 @@ class Ticket extends CommonObject 'fk_user_assign' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'AssignedTo', 'visible' => 1, 'enabled' => 1, 'position' => 507, 'notnull' => 1, 'csslist' => 'tdoverflowmax100 maxwidth150onsmartphone'), 'date_close' => array('type' => 'datetime', 'label' => 'TicketCloseOn', 'visible' => -1, 'enabled' => 1, 'position' => 510, 'notnull' => 1), 'message' => array('type' => 'html', 'label' => 'Message', 'visible' => -2, 'enabled' => 1, 'position' => 540, 'notnull' => -1,), + 'note_private' => array('type' => 'html', 'label' => 'NotePrivate', 'enabled' => 1, 'visible' => 0, 'position' => 110), + 'note_public' => array('type' => 'html', 'label' => 'NotePublic', 'enabled' => 1, 'visible' => 0, 'position' => 115), 'email_msgid' => array('type' => 'varchar(255)', 'label' => 'EmailMsgID', 'visible' => -2, 'enabled' => 1, 'position' => 540, 'notnull' => -1, 'help' => 'EmailMsgIDDesc', 'csslist' => 'tdoverflowmax100'), 'email_date' => array('type' => 'datetime', 'label' => 'EmailDate', 'visible' => -2, 'enabled' => 1, 'position' => 541), 'progress' => array('type' => 'integer', 'label' => 'Progression', 'visible' => -1, 'enabled' => 1, 'position' => 540, 'notnull' => -1, 'css' => 'right', 'help' => "", 'isameasure' => 1, 'csslist' => 'width50'), @@ -520,6 +522,8 @@ class Ticket extends CommonObject $sql .= "email_date,"; $sql .= "subject,"; $sql .= "message,"; + $sql .= "note_private,"; + $sql .= "note_public,"; $sql .= "fk_statut,"; $sql .= "resolution,"; $sql .= "progress,"; @@ -549,6 +553,8 @@ class Ticket extends CommonObject $sql .= " ".(!isDolTms($this->email_date) ? 'NULL' : "'".$this->db->idate($this->email_date)."'").","; $sql .= " ".(!isset($this->subject) ? 'NULL' : "'".$this->db->escape($this->subject)."'").","; $sql .= " ".(!isset($this->message) ? 'NULL' : "'".$this->db->escape($this->message)."'").","; + $sql .= " ".(!isset($this->note_private) ? 'NULL' : "'".$this->db->escape($this->note_private)."'").","; + $sql .= " ".(!isset($this->note_public) ? 'NULL' : "'".$this->db->escape($this->note_public)."'").","; $sql .= " ".(!isset($this->status) ? '0' : ((int) $this->status)).","; $sql .= " ".(!isset($this->resolution) ? 'NULL' : ((int) $this->resolution)).","; $sql .= " ".(!isset($this->progress) ? '0' : ((int) $this->progress)).","; @@ -676,6 +682,8 @@ class Ticket extends CommonObject $sql .= " t.email_date,"; $sql .= " t.subject,"; $sql .= " t.message,"; + $sql .= " t.note_private,"; + $sql .= " t.note_public,"; $sql .= " t.fk_statut as status,"; $sql .= " t.resolution,"; $sql .= " t.progress,"; @@ -733,6 +741,8 @@ class Ticket extends CommonObject $this->email_date = $this->db->jdate($obj->email_date); $this->subject = $obj->subject; $this->message = $obj->message; + $this->note_private = $obj->note_private; + $this->note_public = $obj->note_public; $this->model_pdf = $obj->model_pdf; $this->extraparams = !empty($obj->extraparams) ? (array) json_decode($obj->extraparams, true) : array(); $this->ip = $obj->ip; @@ -812,6 +822,8 @@ class Ticket extends CommonObject $sql .= " t.fk_user_assign, ua.lastname as user_assign_lastname, ua.firstname as user_assign_firstname,"; $sql .= " t.subject,"; $sql .= " t.message,"; + $sql .= " t.note_private,"; + $sql .= " t.note_public,"; $sql .= " t.fk_statut as status,"; $sql .= " t.resolution,"; $sql .= " t.progress,"; @@ -933,6 +945,8 @@ class Ticket extends CommonObject $line->subject = $obj->subject; $line->message = $obj->message; + $line->note_private = $obj->note_private; + $line->note_public = $obj->note_public; $line->fk_statut = $obj->status; $line->status = $obj->status; $line->resolution = $obj->resolution; @@ -1086,6 +1100,8 @@ class Ticket extends CommonObject $sql .= " fk_user_assign=".(isset($this->fk_user_assign) ? (int) $this->fk_user_assign : "null").","; $sql .= " subject=".(isset($this->subject) ? "'".$this->db->escape($this->subject)."'" : "null").","; $sql .= " message=".(isset($this->message) ? "'".$this->db->escape($this->message)."'" : "null").","; + $sql .= " note_private=".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").","; + $sql .= " note_public=".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null").","; $sql .= " fk_statut=".(isset($this->status) ? (int) $this->status : "0").","; $sql .= " resolution=".(isset($this->resolution) ? (int) $this->resolution : "null").","; $sql .= " progress=".(isset($this->progress) ? "'".$this->db->escape((string) $this->progress)."'" : "null").","; diff --git a/htdocs/ticket/note.php b/htdocs/ticket/note.php new file mode 100644 index 00000000000..618a01c8033 --- /dev/null +++ b/htdocs/ticket/note.php @@ -0,0 +1,170 @@ + + * Copyright (C) 2011-2012 Juanjo Menent + * Copyright (C) 2013 Florian Henry + * Copyright (C) 2017 Ferran Marcet + * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 MDW + * Copyright (C) 2025 Charlene Benke + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/ticket/note.php + * \ingroup ticket + * \brief Fiche d'information sur une ticket + */ + +// Load Dolibarr environment +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/ticket.lib.php'; +if (isModEnabled('project')) { + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +} + +/** + * @var Conf $conf + * @var DoliDB $db + * @var HookManager $hookmanager + * @var Translate $langs + * @var User $user + */ + +// Load translation files required by the page +$langs->loadLangs(array('companies', 'ticket')); + +$id = GETPOSTINT('id'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action', 'aZ09'); + +// Security check +if ($user->socid) { + $socid = $user->socid; +} +$hookmanager->initHooks(array('ticketnote')); +$result = restrictedArea($user, 'ticket', $id, 'ticket'); + +$object = new Ticket($db); +$object->fetch($id, $ref); + +$permissiontoadd = $user->hasRight('ticket', 'write'); +$permissionnote = $user->hasRight('ticket', 'write'); // Used by the include of actions_setnotes.inc.php + +// Store current page url +$url_page_current = DOL_URL_ROOT.'/ticket/document.php'; + + +/* + * Actions + */ + +$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} +if (empty($reshook)) { + include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be 'include', not 'include_once' +} + + +/* + * View + */ + +llxHeader('', $langs->trans("Ticket"), '', '', 0, 0, '', '', '', 'mod-ticket page-card_note'); + +$form = new Form($db); + +if ($id > 0 || !empty($ref)) { + $object->fetch_thirdparty(); + + $head = ticket_prepare_head($object); + print dol_get_fiche_head($head, 'note', $langs->trans('TicketCard'), -1, 'ticket'); + + // Ticket card + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref = '
'; + $morehtmlref .= $object->subject; + // Author + if ($object->fk_user_create > 0) { + $morehtmlref .= '
'; + //$morehtmlref .= ''.$langs->trans("CreatedBy").' '; + + $fuser = new User($db); + $fuser->fetch($object->fk_user_create); + $morehtmlref .= $fuser->getNomUrl(-1); + } elseif (!empty($object->email_msgid)) { + $morehtmlref .= '
'; + //$morehtmlref .= ''.$langs->trans("CreatedBy").' '; + $morehtmlref .= img_picto('', 'email', 'class="paddingrightonly"'); + $morehtmlref .= dol_escape_htmltag($object->origin_email).' ('.$form->textwithpicto($langs->trans("CreatedByEmailCollector"), $langs->trans("EmailMsgID").': '.$object->email_msgid).')'; + } elseif (!empty($object->origin_email)) { + $morehtmlref .= '
'; + //$morehtmlref .= ''.$langs->trans("CreatedBy").' '; + $morehtmlref .= img_picto('', 'email', 'class="paddingrightonly"'); + $morehtmlref .= dol_escape_htmltag($object->origin_email).' ('.$langs->trans("CreatedByPublicPortal").')'; + } + + // Thirdparty + if (isModEnabled("societe")) { + $morehtmlref .= '
'; + $morehtmlref .= img_picto($langs->trans("ThirdParty"), 'company', 'class="pictofixedwidth"'); + if ($action != 'editcustomer' && $permissiontoadd) { + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetThirdParty'), 0).' '; + } + $morehtmlref .= $form->form_thirdparty($url_page_current.'?track_id='.$object->track_id, (string) $object->socid, $action == 'editcustomer' ? 'editcustomer' : 'none', '', 1, 0, 0, array(), 1); + } + + // Project + if (isModEnabled('project')) { + $langs->load("projects"); + if (0) { // @phpstan-ignore-line + $morehtmlref .= '
'; + $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"'); + if ($action != 'classify') { + $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' '; + } + $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, (string) $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300'); + } else { + if (!empty($object->fk_project)) { + $morehtmlref .= '
'; + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref .= $proj->getNomUrl(1); + if ($proj->title) { + $morehtmlref .= ' - '.dol_escape_htmltag($proj->title).''; + } + } + } + } + $morehtmlref .= '
'; + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + print '
'; + print '
'; + + $cssclass = "titlefield"; + include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; + + print '
'; + + print dol_get_fiche_end(); +} + +llxFooter(); +$db->close();