| '.$langs->trans("TicketTrackId").' | ';
if (!empty($object->track_id)) {
if (empty($object->ref)) {
- $object->ref = $object->id;
+ $object->ref = (string) $object->id;
print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'track_id');
} else {
print dolPrintLabel($object->track_id);
@@ -1165,6 +1165,7 @@ if ($action == 'create' || $action == 'presend') {
if ($num) {
foreach ($object->linkedObjects as $objecttype => $objects) {
if ($objecttype == "fichinter") {
+ '@phan-var-force Fichinter[] $objects';
foreach ($objects as $fichinter) {
$foundinter++;
/** @var Fichinter $fichinter */
@@ -1297,7 +1298,7 @@ if ($action == 'create' || $action == 'presend') {
$arrayselected[] = $cat->id;
}
- print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('categories', $cate_arbo, $arrayselected, '', 0, 'maxwidth500 widthcentpercentminusx', 0, 0);
+ print img_picto('', 'category', 'class="pictofixedwidth"').$form->multiselectarray('categories', $cate_arbo, $arrayselected, 0, 0, 'maxwidth500 widthcentpercentminusx', 0, 0);
print '';
print '';
print " | ";
diff --git a/htdocs/ticket/class/api_tickets.class.php b/htdocs/ticket/class/api_tickets.class.php
index 07df43e8015..5aa7bd65f7e 100644
--- a/htdocs/ticket/class/api_tickets.class.php
+++ b/htdocs/ticket/class/api_tickets.class.php
@@ -1,6 +1,7 @@
* Copyright (C) 2024 Frédéric France
+ * Copyright (C) 2024 MDW
*
* 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
@@ -16,7 +17,7 @@
* along with this program. If not, see .
*/
- use Luracast\Restler\RestException;
+use Luracast\Restler\RestException;
require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/ticket.lib.php';
@@ -361,7 +362,7 @@ class Tickets extends DolibarrApi
$this->ticket->$field = $this->_checkValForAPI($field, $value, $this->ticket);
}
$ticketMessageText = $this->ticket->message;
- $result = $this->ticket->fetch('', '', $this->ticket->track_id);
+ $result = $this->ticket->fetch(0, '', $this->ticket->track_id);
if (!$result) {
throw new RestException(404, 'Ticket not found');
}
diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php
index acbb86ccf94..00e0a4a126a 100644
--- a/htdocs/ticket/class/ticket.class.php
+++ b/htdocs/ticket/class/ticket.class.php
@@ -105,7 +105,7 @@ class Ticket extends CommonObject
public $fk_user_assign;
/**
- * var string Ticket subject
+ * @var string Ticket subject
*/
public $subject;
@@ -212,17 +212,17 @@ class Ticket extends CommonObject
public $date_close;
/**
- * @var array cache_types_tickets
+ * @var array cache_types_tickets
*/
public $cache_types_tickets;
/**
- * @var array tickets categories
+ * @var array Cache of Ticket categories
*/
public $cache_category_tickets;
/**
- * @var array cache msgs ticket
+ * @var array cache msgs ticket
*/
public $cache_msgs_ticket;
@@ -252,7 +252,7 @@ class Ticket extends CommonObject
public $oldcopy;
/**
- * @var Ticket[] array of Tickets
+ * @var Ticket[] Array of Tickets
*/
public $lines;
@@ -482,7 +482,7 @@ class Ticket extends CommonObject
{
$test = new self($this->db);
- if ($test->fetch('', $getRef) > 0) {
+ if ($test->fetch(0, $getRef) > 0) {
if (($action == 'add') || ($action == 'update' && $this->ref != $getRef)) {
return true;
}
@@ -1385,14 +1385,14 @@ class Ticket extends CommonObject
/**
* Load into a cache array, the list of ticket categories (setup done into dictionary)
*
- * @param int $publicgroup 0=No public group, 1=Public group only, -1=All
- * @return int Number of lines loaded, 0 if already loaded, <0 if KO
+ * @param int<-1,1> $publicgroup 0=No public group, 1=Public group only, -1=All
+ * @return int Number of lines loaded, 0 if already loaded, <0 if KO
*/
public function loadCacheCategoriesTickets($publicgroup = -1)
{
global $langs;
- if ($publicgroup == -1 && !empty($this->cache_category_ticket) && count($this->cache_category_tickets)) {
+ if ($publicgroup == -1 && !empty($this->cache_category_tickets) && count($this->cache_category_tickets)) {
// Cache already loaded
return 0;
}
@@ -1757,10 +1757,10 @@ class Ticket extends CommonObject
/**
* Set an assigned user to a ticket.
*
- * @param User $user Object user
- * @param int $id_assign_user ID of user assigned
- * @param int $notrigger Disable trigger
- * @return int Return integer <0 if KO, 0=Nothing done, >0 if OK
+ * @param User $user Object user
+ * @param int $id_assign_user ID of user assigned
+ * @param int<0,1> $notrigger Disable trigger
+ * @return int Return integer <0 if KO, 0=Nothing done, >0 if OK
*/
public function assignUser($user, $id_assign_user, $notrigger = 0)
{
@@ -1813,12 +1813,12 @@ class Ticket extends CommonObject
* Add message into database
*
* @param User $user User that creates
- * @param int $notrigger 0=launch triggers after, 1=disable triggers
- * @param array $filename_list List of files to attach (full path of filename on file system)
- * @param array $mimetype_list List of MIME type of attached files
- * @param array $mimefilename_list List of attached file name in message
- * @param boolean $send_email Whether the message is sent by email
- * @param int $public_area 0=Default, 1 if we are creating the message from a public area (so we can search contact from email to add it as contact of ticket if TICKET_ASSIGN_CONTACT_TO_MESSAGE is set)
+ * @param int<0,1> $notrigger 0=launch triggers after, 1=disable triggers
+ * @param string[] $filename_list List of files to attach (full path of filename on file system)
+ * @param string[] $mimetype_list List of MIME type of attached files
+ * @param string[] $mimefilename_list List of attached file name in message
+ * @param bool $send_email Whether the message is sent by email
+ * @param int<0,1> $public_area 0=Default, 1 if we are creating the message from a public area (so we can search contact from email to add it as contact of ticket if TICKET_ASSIGN_CONTACT_TO_MESSAGE is set)
* @return int Return integer <0 if KO, >0 if OK
*/
public function createTicketMessage($user, $notrigger = 0, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array(), $send_email = false, $public_area = 0)
@@ -2070,11 +2070,11 @@ class Ticket extends CommonObject
/**
* Search and fetch thirparties by email
*
- * @param string $email Email
- * @param int $type Type of thirdparties (0=any, 1=customer, 2=prospect, 3=supplier)
- * @param array $filters Array of couple field name/value to filter the companies with the same name
- * @param string $clause Clause for filters
- * @return array|int Array of thirdparties object
+ * @param string $email Email
+ * @param int<0,3> $type Type of thirdparties (0=any, 1=customer, 2=prospect, 3=supplier)
+ * @param array $filters Array of couple field name/value to filter the companies with the same name
+ * @param string $clause Clause for filters
+ * @return Societe[]|int<-1,-1> Array of thirdparties object
*/
public function searchSocidByEmail($email, $type = 0, $filters = array(), $clause = 'AND')
{
@@ -2138,7 +2138,7 @@ class Ticket extends CommonObject
* @param string $email Email
* @param int $socid Limit to a thirdparty
* @param string $case Respect case
- * @return array|int Array of contacts object
+ * @return Contact[]|int Array of contacts object
*/
public function searchContactByEmail($email, $socid = 0, $case = '')
{
@@ -2253,7 +2253,7 @@ class Ticket extends CommonObject
/**
* Return id des contacts interne de suivi
*
- * @return array Liste des id contacts suivi ticket
+ * @return null|int[] Liste des id contacts suivi ticket
*/
public function getIdTicketInternalContact()
{
@@ -2274,7 +2274,7 @@ class Ticket extends CommonObject
/**
* Return id des contacts clients pour le suivi ticket
*
- * @return array Liste des id contacts suivi ticket
+ * @return null|int[] Liste des id contacts suivi ticket
*/
public function getIdTicketCustomerContact()
{
@@ -2285,7 +2285,7 @@ class Ticket extends CommonObject
* Retrieve information about external contacts
*
* @param int $status Status of user or company
- * @return array Array with datas : firstname, lastname, socid (-1 for internal users), email, code, libelle, status
+ * @return array|int<-1,-1> Array with data : firstname, lastname, socid (-1 for internal users), email, code, libelle, status
*/
public function getInfosTicketExternalContact($status = -1)
{
@@ -2295,7 +2295,7 @@ class Ticket extends CommonObject
/**
* Return id des contacts clients des intervenants
*
- * @return array Liste des id contacts intervenants
+ * @return null|int[] Liste des id contacts intervenants
*/
public function getIdTicketInternalInvolvedContact()
{
@@ -2305,7 +2305,7 @@ class Ticket extends CommonObject
/**
* Return id des contacts clients des intervenants
*
- * @return array Liste des id contacts intervenants
+ * @return null|int[] Liste des id contacts intervenants
*/
public function getIdTicketCustomerInvolvedContact()
{
@@ -2315,7 +2315,7 @@ class Ticket extends CommonObject
/**
* Return id of all contacts for ticket
*
- * @return array Array of contacts for tickets
+ * @return int[] Array of contacts for tickets
*/
public function getTicketAllContacts()
{
@@ -2333,7 +2333,7 @@ class Ticket extends CommonObject
/**
* Return id of all contacts for ticket
*
- * @return array Array of contacts
+ * @return int[] Array of contacts
*/
public function getTicketAllCustomerContacts()
{
@@ -2480,6 +2480,7 @@ class Ticket extends CommonObject
// Search template files
$file = '';
$classname = '';
+ $reldir = '';
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) {
$file = dol_buildpath($reldir."core/modules/ticket/".$modele.'.php', 0);
@@ -2543,7 +2544,7 @@ class Ticket extends CommonObject
* Files may be renamed during copy to avoid overwriting existing files.
*
* @param string $forcetrackid Force trackid used for $keytoavoidconflict into get_attached_files()
- * @return array|int Array with final path/name/mime of files.
+ * @return array{listofpaths:string[],listofnames:string[],listofmimes:string[]}|int<-1,-1> Array with final path/name/mime of files.
*/
public function copyFilesForTicket($forcetrackid = null)
{
@@ -2682,7 +2683,7 @@ class Ticket extends CommonObject
$object = new Ticket($this->db);
- $ret = $object->fetch('', '', GETPOST('track_id', 'alpha'));
+ $ret = $object->fetch(0, '', GETPOST('track_id', 'alpha'));
$object->socid = $object->fk_soc;
$object->fetch_thirdparty();
@@ -2751,6 +2752,8 @@ class Ticket extends CommonObject
} else {
$assigned_user_dont_have_email = $assigned_user->getFullName($langs);
}
+ } else {
+ $assigned_user = null;
}
// Build array to display recipient list
@@ -2761,7 +2764,7 @@ class Ticket extends CommonObject
}
// We check if the email address is not the assignee's address to prevent notification from being sent twice
- if (!empty($info_sendto['email']) && $assigned_user->email != $info_sendto['email']) {
+ if (!empty($info_sendto['email']) && ($assigned_user === null || $assigned_user->email != $info_sendto['email'])) {
$sendto[] = dolGetFirstLastname($info_sendto['firstname'], $info_sendto['lastname'])." <".$info_sendto['email'].">";
}
}
@@ -2816,7 +2819,7 @@ class Ticket extends CommonObject
$message .= '
';
$message .= $langs->trans('TicketNotificationEmailBodyInfosTrackUrlinternal').' : '.$object->track_id.'';
- $this->sendTicketMessageByEmail($subject, $message, '', $sendto, $listofpaths, $listofmimes, $listofnames);
+ $this->sendTicketMessageByEmail($subject, $message, 0, $sendto, $listofpaths, $listofmimes, $listofnames);
}
}
} else {
@@ -2888,7 +2891,7 @@ class Ticket extends CommonObject
// don't try to send email if no recipient
if (!empty($sendto)) {
- $this->sendTicketMessageByEmail($subject, $message, '', $sendto, $listofpaths, $listofmimes, $listofnames);
+ $this->sendTicketMessageByEmail($subject, $message, 0, $sendto, $listofpaths, $listofmimes, $listofnames);
}
}
@@ -2990,7 +2993,7 @@ class Ticket extends CommonObject
// Don't try to send email when no recipient
if (!empty($sendto)) {
- $result = $this->sendTicketMessageByEmail($subject, $message, '', $sendto, $listofpaths, $listofmimes, $listofnames);
+ $result = $this->sendTicketMessageByEmail($subject, $message, 0, $sendto, $listofpaths, $listofmimes, $listofnames);
if ($result) {
// update last_msg_sent date (for last message sent to external users)
$this->date_last_msg_sent = dol_now();
@@ -3029,13 +3032,13 @@ class Ticket extends CommonObject
/**
* Send ticket by email to linked contacts
*
- * @param string $subject Email subject
- * @param string $message Email message
- * @param int $send_internal_cc Receive a copy on internal email (getDolGlobalString('TICKET_NOTIFICATION_EMAIL_FROM')
- * @param array $array_receiver Array of receiver. Example array('name' => 'John Doe', 'email' => 'john@doe.com', etc...)
- * @param array $filename_list List of files to attach (full path of filename on file system)
- * @param array $mimetype_list List of MIME type of attached files
- * @param array $mimefilename_list List of attached file name in message
+ * @param string $subject Email subject
+ * @param string $message Email message
+ * @param int<0,1> $send_internal_cc Receive a copy on internal email (getDolGlobalString('TICKET_NOTIFICATION_EMAIL_FROM')
+ * @param array $array_receiver Array of receiver. Example array('name' => 'John Doe', 'email' => 'john@doe.com', etc...)
+ * @param string[] $filename_list List of files to attach (full path of filename on file system)
+ * @param string[] $mimetype_list List of MIME type of attached files
+ * @param string[] $mimefilename_list List of attached file name in message
* @return boolean True if mail sent to at least one receiver, false otherwise
*/
public function sendTicketMessageByEmail($subject, $message, $send_internal_cc = 0, $array_receiver = array(), $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array())
@@ -3302,13 +3305,13 @@ class Ticket extends CommonObject
/**
* Create a document onto disk according to template module.
*
- * @param string $modele Force template to use ('' to not force)
- * @param Translate $outputlangs object lang a utiliser pour traduction
- * @param int $hidedetails Hide details of lines
- * @param int $hidedesc Hide description
- * @param int $hideref Hide ref
- * @param null|array $moreparams Array to provide more information
- * @return int 0 if KO, 1 if OK
+ * @param string $modele Force template to use ('' to not force)
+ * @param Translate $outputlangs object lang a utiliser pour traduction
+ * @param int<0,1> $hidedetails Hide details of lines
+ * @param int<0,1> $hidedesc Hide description
+ * @param int<0,1> $hideref Hide ref
+ * @param ?array $moreparams Array to provide more information
+ * @return int 0 if KO, 1 if OK
*/
public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
{
diff --git a/htdocs/ticket/contact.php b/htdocs/ticket/contact.php
index 0a83c3ab454..565c6563d53 100644
--- a/htdocs/ticket/contact.php
+++ b/htdocs/ticket/contact.php
@@ -2,6 +2,7 @@
/* Copyright (C) 2011-2016 Jean-François Ferry
* Copyright (C) 2011 Regis Houssin
* Copyright (C) 2016 Christophe Battarel
+ * Copyright (C) 2024 MDW
*
* 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
@@ -104,21 +105,21 @@ if ($action == 'addcontact' && $user->hasRight('ticket', 'write')) {
$error = 0;
$codecontact = dol_getIdFromCode($db, $typeid, 'c_type_contact', 'rowid', 'code');
- if ($codecontact=='SUPPORTTEC') {
+ if ($codecontact == 'SUPPORTTEC') {
$internal_contacts = $object->listeContact(-1, 'internal', 0, 'SUPPORTTEC');
foreach ($internal_contacts as $key => $contact) {
if ($contact['id'] !== $contactid) {
//print "user à effacer : ".$useroriginassign;
$result = $object->delete_contact($contact['rowid']);
- if ($result<0) {
- $error ++;
+ if ($result < 0) {
+ $error++;
setEventMessages($object->error, $object->errors, 'errors');
}
}
}
$ret = $object->assignUser($user, $contactid);
if ($ret < 0) {
- $error ++;
+ $error++;
setEventMessages($object->error, $object->errors, 'errors');
}
}
@@ -155,10 +156,10 @@ if ($action == 'deletecontact' && $user->hasRight('ticket', 'write')) {
if ($object->fetch($id, '', $track_id)) {
$internal_contacts = $object->listeContact(-1, 'internal', 0, 'SUPPORTTEC');
foreach ($internal_contacts as $key => $contact) {
- if ($contact['rowid'] == $lineid && $object->fk_user_assign==$contact['id']) {
- $ret = $object->assignUser($user, null);
+ if ($contact['rowid'] == $lineid && $object->fk_user_assign == $contact['id']) {
+ $ret = $object->assignUser($user, 0);
if ($ret < 0) {
- $error ++;
+ $error++;
setEventMessages($object->error, $object->errors, 'errors');
}
}