NEW add private and public note on ticket (#35303)

* Update copyright and add note fields in SQL

* Add note_public and note_private columns to llx_ticket

* Implement notes tab in ticket details

* Add fk_user_modif column to llx_ticket table

* Add fk_user_modif column to llx_ticket table

* Add files via upload

* Add private and public note fields to ticket class

* Update ticket.class.php

* Update ticket.class.php

* Update note.php

* Update note.php

* Update note.php

---------

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
Charlène Benke 2025-09-15 16:17:28 +02:00 committed by GitHub
parent 924e024db3
commit 175eea301f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 215 additions and 2 deletions

View file

@ -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] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
}
$head[$h][2] = 'note';
$h++;
}
complete_head_from_modules($conf, $langs, $object, $head, $h, 'ticket', 'add', 'core');
// Attached files

View file

@ -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,

View file

@ -1,6 +1,6 @@
-- SQL definition for module ticket
-- Copyright (C) 2013 Jean-François FERRY <hello@librethic.io>
-- Copyright (C) 2023 Charlene Benke <charlene@patas-monkey.com>
-- Copyright (C) 2023-2025 Charlene Benke <charlene@patas-monkey.com>
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
@ -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),

View file

@ -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").",";

170
htdocs/ticket/note.php Normal file
View file

@ -0,0 +1,170 @@
<?php
/* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2025 Charlene Benke <charlene@patas-monkey.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/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 = '<a href="'.DOL_URL_ROOT.'/ticket/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
$morehtmlref = '<div class="refidno">';
$morehtmlref .= $object->subject;
// Author
if ($object->fk_user_create > 0) {
$morehtmlref .= '<br>';
//$morehtmlref .= '<span class="opacitymedium">'.$langs->trans("CreatedBy").'</span> ';
$fuser = new User($db);
$fuser->fetch($object->fk_user_create);
$morehtmlref .= $fuser->getNomUrl(-1);
} elseif (!empty($object->email_msgid)) {
$morehtmlref .= '<br>';
//$morehtmlref .= '<span class="opacitymedium">'.$langs->trans("CreatedBy").'</span> ';
$morehtmlref .= img_picto('', 'email', 'class="paddingrightonly"');
$morehtmlref .= dol_escape_htmltag($object->origin_email).' <small class="hideonsmartphone opacitymedium">('.$form->textwithpicto($langs->trans("CreatedByEmailCollector"), $langs->trans("EmailMsgID").': '.$object->email_msgid).')</small>';
} elseif (!empty($object->origin_email)) {
$morehtmlref .= '<br>';
//$morehtmlref .= '<span class="opacitymedium">'.$langs->trans("CreatedBy").'</span> ';
$morehtmlref .= img_picto('', 'email', 'class="paddingrightonly"');
$morehtmlref .= dol_escape_htmltag($object->origin_email).' <small class="hideonsmartphone opacitymedium">('.$langs->trans("CreatedByPublicPortal").')</small>';
}
// Thirdparty
if (isModEnabled("societe")) {
$morehtmlref .= '<br>';
$morehtmlref .= img_picto($langs->trans("ThirdParty"), 'company', 'class="pictofixedwidth"');
if ($action != 'editcustomer' && $permissiontoadd) {
$morehtmlref .= '<a class="editfielda" href="'.$url_page_current.'?action=editcustomer&token='.newToken().'&track_id='.$object->track_id.'">'.img_edit($langs->transnoentitiesnoconv('SetThirdParty'), 0).'</a> ';
}
$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 .= '<br>';
$morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
if ($action != 'classify') {
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
}
$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 .= '<br>';
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref .= $proj->getNomUrl(1);
if ($proj->title) {
$morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
}
}
}
}
$morehtmlref .= '</div>';
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
$cssclass = "titlefield";
include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
print '</div>';
print dol_get_fiche_end();
}
llxFooter();
$db->close();