';
print $langs->trans("InitialMessage");
print ' | ';
if ($user->rights->ticket->manage) {
@@ -208,25 +208,14 @@
$msg = GETPOST('message_initial', 'alpha') ? GETPOST('message_initial', 'alpha') : $object->message;
include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$uselocalbrowser = true;
- $ckeditorenabledforticket = $conf->global->FCKEDITOR_ENABLE_TICKET;
- $doleditor = new DolEditor('message_initial', $msg, '100%', 250, 'dolibarr_details', 'In', true, $uselocalbrowser, $ckeditorenabledforticket, ROWS_9, '95%');
+ $doleditor = new DolEditor('message_initial', $msg, '100%', 250, 'dolibarr_details', 'In', true, $uselocalbrowser, $conf->global->FCKEDITOR_ENABLE_TICKET, ROWS_4, '95%');
$doleditor->Create();
} else {
// Deal with format differences (text / HTML)
if (dol_textishtml($object->message)) {
- print ' ';
print $object->message;
- print ' ';
- /*print '';
- print $langs->trans("More").'...';
- print ' ';*/
} else {
- print '';
print dol_nl2br($object->message);
- print ' ';
- /*print '';
- print $langs->trans("More").'...';
- print ' ';*/
}
//print '' . $object->message . ' ';
@@ -234,7 +223,7 @@
if (!empty($user->rights->ticket->manage) && $action == 'edit_message_init') {
print '';
print ' ';
- print ' ';
+ print ' ';
print ' ';
}
print ' | ';
@@ -264,7 +253,7 @@
$ret = $this->dao->loadCacheMsgsTicket();
if ($ret < 0) dol_print_error($this->dao->db);
- $action = GETPOST('action', 'aZ09');
+ $action = GETPOST('action', 'alpha');
$this->viewTicketOriginalMessage($user, $action, $object);
@@ -404,16 +393,17 @@
if (!in_array($status, $exclude_status)) {
print '';
- if ($status == 1) {
+ if ($status == 1)
+ {
$urlforbutton = $_SERVER['PHP_SELF'].'?track_id='.$object->track_id.'&action=mark_ticket_read'; // To set as read, we use a dedicated action
- } else {
- $urlforbutton = $_SERVER['PHP_SELF'].'?track_id='.$object->track_id.'&action=set_status&token='.newToken().'&new_status='.$status;
}
-
- print '
';
- print $object->LibStatut($status, 3, 1).' ';
- //print img_picto($langs->trans($object->statuts_short[$status]), 'statut'.$status.'.png@ticket', '', false, 0, 0, '', 'valignmiddle').' ';
- print $langs->trans($object->statuts_short[$status]);
+ else
+ {
+ $urlforbutton = $_SERVER['PHP_SELF'].'?track_id='.$object->track_id.'&action=set_status&new_status='.$status;
+ }
+
+ print '';
+ print img_picto($langs->trans($object->statuts_short[$status]), 'statut'.$status.'.png@ticket').' '.$langs->trans($object->statuts_short[$status]);
print '';
print '
';
}
--- /tmp/dsg/dolibarr/htdocs/ticket/class/github_api_tickets.class.php
+++ /tmp/dsg/dolibarr/htdocs/ticket/class/client_api_tickets.class.php
@@ -29,544 +29,543 @@
*/
class Tickets extends DolibarrApi
{
- /**
- * @var array $FIELDS Mandatory fields, checked when create and update object
- */
- public static $FIELDS = array(
- 'subject',
- 'message'
- );
-
- /**
- * @var array $FIELDS_MESSAGES Mandatory fields, checked when create and update object
- */
- public static $FIELDS_MESSAGES = array(
- 'track_id',
- 'message'
- );
-
- /**
- * @var Ticket $ticket {@type Ticket}
- */
- public $ticket;
-
- /**
- * Constructor
- */
- public function __construct()
- {
- global $db;
- $this->db = $db;
- $this->ticket = new Ticket($this->db);
- }
-
- /**
- * Get properties of a Ticket object.
- *
- * Return an array with ticket informations
- *
- * @param int $id ID of ticket
- * @return array|mixed Data without useless information
- *
- * @throws RestException 401
- * @throws RestException 403
- * @throws RestException 404
- */
- public function get($id)
- {
- return $this->getCommon($id, '', '');
- }
-
- /**
- * Get properties of a Ticket object from track id
- *
- * Return an array with ticket informations
- *
- * @param string $track_id Tracking ID of ticket
- * @return array|mixed Data without useless information
- *
- * @url GET track_id/{track_id}
- *
- * @throws RestException 401
- * @throws RestException 403
- * @throws RestException 404
- */
- public function getByTrackId($track_id)
- {
- return $this->getCommon(0, $track_id, '');
- }
-
- /**
- * Get properties of a Ticket object from ref
- *
- * Return an array with ticket informations
- *
- * @param string $ref Reference for ticket
- * @return array|mixed Data without useless information
- *
- * @url GET ref/{ref}
- *
- * @throws RestException 401
- * @throws RestException 403
- * @throws RestException 404
- */
- public function getByRef($ref)
- {
- try {
- return $this->getCommon(0, '', $ref);
- } catch (Exception $e)
- {
- throw $e;
- }
- }
-
- /**
- * Get properties of a Ticket object
- * Return an array with ticket informations
- *
- * @param int $id ID of ticket
- * @param string $track_id Tracking ID of ticket
- * @param string $ref Reference for ticket
- * @return array|mixed Data without useless information
- */
- private function getCommon($id = 0, $track_id = '', $ref = '')
- {
- if (!DolibarrApiAccess::$user->rights->ticket->read) {
- throw new RestException(403);
- }
-
- // Check parameters
- if (($id < 0) && !$track_id && !$ref) {
- throw new RestException(401, 'Wrong parameters');
- }
- if ($id == 0) {
- $result = $this->ticket->initAsSpecimen();
- } else {
- $result = $this->ticket->fetch($id, $ref, $track_id);
- }
- if (!$result) {
- throw new RestException(404, 'Ticket not found');
- }
-
- // String for user assigned
- if ($this->ticket->fk_user_assign > 0) {
- $userStatic = new User($this->db);
- $userStatic->fetch($this->ticket->fk_user_assign);
- $this->ticket->fk_user_assign_string = $userStatic->firstname.' '.$userStatic->lastname;
- }
-
- // Messages of ticket
- $messages = array();
- $this->ticket->loadCacheMsgsTicket();
- if (is_array($this->ticket->cache_msgs_ticket) && count($this->ticket->cache_msgs_ticket) > 0) {
- $num = count($this->ticket->cache_msgs_ticket);
- $i = 0;
- while ($i < $num) {
- if ($this->ticket->cache_msgs_ticket[$i]['fk_user_author'] > 0) {
- $user_action = new User($this->db);
- $user_action->fetch($this->ticket->cache_msgs_ticket[$i]['fk_user_author']);
- }
-
- // Now define messages
- $messages[] = array(
- 'id' => $this->ticket->cache_msgs_ticket[$i]['id'],
- 'fk_user_action' => $this->ticket->cache_msgs_ticket[$i]['fk_user_author'],
- 'fk_user_action_socid' => $user_action->socid,
- 'fk_user_action_string' => dolGetFirstLastname($user_action->firstname, $user_action->lastname),
- 'message' => $this->ticket->cache_msgs_ticket[$i]['message'],
- 'datec' => $this->ticket->cache_msgs_ticket[$i]['datec'],
- 'private' => $this->ticket->cache_msgs_ticket[$i]['private']
- );
- $i++;
- }
- $this->ticket->messages = $messages;
- }
-
- // History
- $history = array();
- $this->ticket->loadCacheLogsTicket();
- if (is_array($this->ticket->cache_logs_ticket) && count($this->ticket->cache_logs_ticket) > 0) {
- $num = count($this->ticket->cache_logs_ticket);
- $i = 0;
- while ($i < $num) {
- if ($this->ticket->cache_logs_ticket[$i]['fk_user_create'] > 0) {
- $user_action = new User($this->db);
- $user_action->fetch($this->ticket->cache_logs_ticket[$i]['fk_user_create']);
- }
-
- // Now define messages
- $history[] = array(
- 'id' => $this->ticket->cache_logs_ticket[$i]['id'],
- 'fk_user_author' => $this->ticket->cache_msgs_ticket[$i]['fk_user_author'],
- 'fk_user_action' => $this->ticket->cache_logs_ticket[$i]['fk_user_create'],
- 'fk_user_action_string' => dolGetFirstLastname($user_action->firstname, $user_action->lastname),
- 'message' => $this->ticket->cache_logs_ticket[$i]['message'],
- 'datec' => $this->ticket->cache_logs_ticket[$i]['datec'],
- );
- $i++;
- }
- $this->ticket->history = $history;
- }
-
- if (!DolibarrApi::_checkAccessToResource('ticket', $this->ticket->id)) {
- throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
- }
- return $this->_cleanObjectDatas($this->ticket);
- }
-
- /**
- * List tickets
- *
- * Get a list of tickets
- *
- * @param int $socid Filter list with thirdparty ID
- * @param string $sortfield Sort field
- * @param string $sortorder Sort order
- * @param int $limit Limit for list
- * @param int $page Page number
- * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101') and (t.fk_statut:=:1)"
- *
- * @return array Array of ticket objects
- *
- */
- public function index($socid = 0, $sortfield = "t.rowid", $sortorder = "ASC", $limit = 100, $page = 0, $sqlfilters = '')
- {
- global $db, $conf;
-
- $obj_ret = array();
-
- if (!$socid && DolibarrApiAccess::$user->socid) {
- $socid = DolibarrApiAccess::$user->socid;
- }
-
- // If the internal user must only see his customers, force searching by him
- if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) {
- $search_sale = DolibarrApiAccess::$user->id;
- }
-
- $sql = "SELECT t.rowid";
- if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) {
- $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
- }
- $sql .= " FROM ".MAIN_DB_PREFIX."ticket as t";
-
- if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) {
- $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
- }
-
- $sql .= ' WHERE t.entity IN ('.getEntity('ticket', 1).')';
- if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) {
- $sql .= " AND t.fk_soc = sc.fk_soc";
- }
- if ($socid > 0) {
- $sql .= " AND t.fk_soc = ".$socid;
- }
- if ($search_sale > 0) {
- $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
- }
-
- // Insert sale filter
- if ($search_sale > 0) {
- $sql .= " AND sc.fk_user = ".$search_sale;
- }
- // Add sql filters
- if ($sqlfilters) {
- if (!DolibarrApi::_checkFilters($sqlfilters)) {
- throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
- }
- $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
- $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
- }
-
- $sql .= $this->db->order($sortfield, $sortorder);
-
- if ($limit) {
- if ($page < 0) {
- $page = 0;
- }
- $offset = $limit * $page;
-
- $sql .= $this->db->plimit($limit, $offset);
- }
-
- $result = $this->db->query($sql);
- if ($result) {
- $num = $this->db->num_rows($result);
- $i = 0;
- while ($i < $num) {
- $obj = $this->db->fetch_object($result);
- $ticket_static = new Ticket($this->db);
- if ($ticket_static->fetch($obj->rowid)) {
- if ($ticket_static->fk_user_assign > 0) {
- $userStatic = new User($this->db);
- $userStatic->fetch($ticket_static->fk_user_assign);
- $ticket_static->fk_user_assign_string = $userStatic->firstname.' '.$userStatic->lastname;
- }
- $obj_ret[] = $this->_cleanObjectDatas($ticket_static);
- }
- $i++;
- }
- } else {
- throw new RestException(503, 'Error when retrieve ticket list');
- }
- if (!count($obj_ret)) {
- throw new RestException(404, 'No ticket found');
- }
- return $obj_ret;
- }
-
- /**
- * Create ticket object
- *
- * @param array $request_data Request datas
- * @return int ID of ticket
- */
- public function post($request_data = null)
- {
- $ticketstatic = new Ticket($this->db);
- if (!DolibarrApiAccess::$user->rights->ticket->write) {
- throw new RestException(401);
- }
- // Check mandatory fields
- $result = $this->_validate($request_data);
-
- foreach ($request_data as $field => $value) {
- $this->ticket->$field = $value;
- }
- if (empty($this->ticket->ref)) {
- $this->ticket->ref = $ticketstatic->getDefaultRef();
- }
- if (empty($this->ticket->track_id)) {
- $this->ticket->track_id = generate_random_id(16);
- }
-
- if ($this->ticket->create(DolibarrApiAccess::$user) < 0) {
- throw new RestException(500, "Error creating ticket", array_merge(array($this->ticket->error), $this->ticket->errors));
- }
-
- return $this->ticket->id;
- }
-
- /**
- * Create ticket object
- *
- * @param array $request_data Request datas
- * @return int ID of ticket
- *
- */
- public function postNewMessage($request_data = null)
- {
- $ticketstatic = new Ticket($this->db);
- if (!DolibarrApiAccess::$user->rights->ticket->write) {
- throw new RestException(401);
- }
- // Check mandatory fields
- $result = $this->_validateMessage($request_data);
-
- foreach ($request_data as $field => $value) {
- $this->ticket->$field = $value;
- }
- $ticketMessageText = $this->ticket->message;
- $result = $this->ticket->fetch('', '', $this->ticket->track_id);
- if (!$result) {
- throw new RestException(404, 'Ticket not found');
- }
- $this->ticket->message = $ticketMessageText;
- if (!$this->ticket->createTicketMessage(DolibarrApiAccess::$user)) {
- throw new RestException(500);
- }
- return $this->ticket->id;
- }
-
- /**
- * Update ticket
- *
- * @param int $id Id of ticket to update
- * @param array $request_data Datas
- * @return int
- *
- */
- public function put($id, $request_data = null)
- {
- if (!DolibarrApiAccess::$user->rights->ticket->write) {
- throw new RestException(401);
- }
-
- $result = $this->ticket->fetch($id);
- if (!$result) {
- throw new RestException(404, 'Ticket not found');
- }
-
- if (!DolibarrApi::_checkAccessToResource('ticket', $this->ticket->id)) {
- throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
- }
-
- foreach ($request_data as $field => $value) {
- $this->ticket->$field = $value;
- }
-
- if ($this->ticket->update($id, DolibarrApiAccess::$user)) {
- return $this->get($id);
- }
-
- return false;
- }
-
- /**
- * Delete ticket
- *
- * @param int $id Ticket ID
- * @return array
- *
- */
- public function delete($id)
- {
- if (!DolibarrApiAccess::$user->rights->ticket->delete) {
- throw new RestException(401);
- }
- $result = $this->ticket->fetch($id);
- if (!$result) {
- throw new RestException(404, 'Ticket not found');
- }
-
- if (!DolibarrApi::_checkAccessToResource('ticket', $this->ticket->id)) {
- throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
- }
-
- if (!$this->ticket->delete($id)) {
- throw new RestException(500);
- }
-
- return array(
- 'success' => array(
- 'code' => 200,
- 'message' => 'Ticket deleted'
- )
- );
- }
-
- /**
- * Validate fields before create or update object
- *
- * @param array $data Data to validate
- * @return array
- *
- * @throws RestException
- */
- private function _validate($data)
- {
- $ticket = array();
- foreach (Tickets::$FIELDS as $field) {
- if (!isset($data[$field])) {
- throw new RestException(400, "$field field missing");
- }
- $ticket[$field] = $data[$field];
- }
- return $ticket;
- }
-
- /**
- * Validate fields before create or update object message
- *
- * @param array $data Data to validate
- * @return array
- *
- * @throws RestException
- */
- private function _validateMessage($data)
- {
- $ticket = array();
- foreach (Tickets::$FIELDS_MESSAGES as $field) {
- if (!isset($data[$field])) {
- throw new RestException(400, "$field field missing");
- }
- $ticket[$field] = $data[$field];
- }
- return $ticket;
- }
-
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
- /**
- * Clean sensible object datas
- *
- * @param Object $object Object to clean
- * @return Object Object with cleaned properties
- *
- * @todo use an array for properties to clean
- *
- */
- protected function _cleanObjectDatas($object)
- {
- // phpcs:enable
- $object = parent::_cleanObjectDatas($object);
-
- // Other attributes to clean
- $attr2clean = array(
- "contact",
- "contact_id",
- "ref_previous",
- "ref_next",
- "ref_ext",
- "table_element_line",
- "statut",
- "country",
- "country_id",
- "country_code",
- "barcode_type",
- "barcode_type_code",
- "barcode_type_label",
- "barcode_type_coder",
- "mode_reglement_id",
- "cond_reglement_id",
- "cond_reglement",
- "fk_delivery_address",
- "shipping_method_id",
- "modelpdf",
- "fk_account",
- "note_public",
- "note_private",
- "note",
- "total_ht",
- "total_tva",
- "total_localtax1",
- "total_localtax2",
- "total_ttc",
- "fk_incoterms",
- "label_incoterms",
- "location_incoterms",
- "name",
- "lastname",
- "firstname",
- "civility_id",
- "canvas",
- "cache_msgs_ticket",
- "cache_logs_ticket",
- "cache_types_tickets",
- "cache_category_tickets",
- "regeximgext",
- "statuts_short",
- "statuts"
- );
- foreach ($attr2clean as $toclean) {
- unset($object->$toclean);
- }
-
- // If object has lines, remove $db property
- if (isset($object->lines) && count($object->lines) > 0) {
- $nboflines = count($object->lines);
- for ($i = 0; $i < $nboflines; $i++) {
- $this->_cleanObjectDatas($object->lines[$i]);
- }
- }
-
- // If object has linked objects, remove $db property
- if (isset($object->linkedObjects) && count($object->linkedObjects) > 0) {
- foreach ($object->linkedObjects as $type_object => $linked_object) {
- foreach ($linked_object as $object2clean) {
- $this->_cleanObjectDatas($object2clean);
- }
- }
- }
- return $object;
- }
+ /**
+ * @var array $FIELDS Mandatory fields, checked when create and update object
+ */
+ public static $FIELDS = array(
+ 'subject',
+ 'message'
+ );
+
+ /**
+ * @var array $FIELDS_MESSAGES Mandatory fields, checked when create and update object
+ */
+ public static $FIELDS_MESSAGES = array(
+ 'track_id',
+ 'message'
+ );
+
+ /**
+ * @var Ticket $ticket {@type Ticket}
+ */
+ public $ticket;
+
+ /**
+ * Constructor
+ */
+ public function __construct()
+ {
+ global $db;
+ $this->db = $db;
+ $this->ticket = new Ticket($this->db);
+ }
+
+ /**
+ * Get properties of a Ticket object.
+ *
+ * Return an array with ticket informations
+ *
+ * @param int $id ID of ticket
+ * @return array|mixed Data without useless information
+ *
+ * @throws RestException 401
+ * @throws RestException 403
+ * @throws RestException 404
+ */
+ public function get($id)
+ {
+ return $this->getCommon($id, '', '');
+ }
+
+ /**
+ * Get properties of a Ticket object from track id
+ *
+ * Return an array with ticket informations
+ *
+ * @param string $track_id Tracking ID of ticket
+ * @return array|mixed Data without useless information
+ *
+ * @url GET track_id/{track_id}
+ *
+ * @throws RestException 401
+ * @throws RestException 403
+ * @throws RestException 404
+ */
+ public function getByTrackId($track_id)
+ {
+ return $this->getCommon(0, $track_id, '');
+ }
+
+ /**
+ * Get properties of a Ticket object from ref
+ *
+ * Return an array with ticket informations
+ *
+ * @param string $ref Reference for ticket
+ * @return array|mixed Data without useless information
+ *
+ * @url GET ref/{ref}
+ *
+ * @throws RestException 401
+ * @throws RestException 403
+ * @throws RestException 404
+ */
+ public function getByRef($ref)
+ {
+ try {
+ return $this->getCommon(0, '', $ref);
+ }
+ catch (Exception $e)
+ {
+ throw $e;
+ }
+ }
+
+ /**
+ * Get properties of a Ticket object
+ * Return an array with ticket informations
+ *
+ * @param int $id ID of ticket
+ * @param string $track_id Tracking ID of ticket
+ * @param string $ref Reference for ticket
+ * @return array|mixed Data without useless information
+ */
+ private function getCommon($id = 0, $track_id = '', $ref = '')
+ {
+ if (!DolibarrApiAccess::$user->rights->ticket->read) {
+ throw new RestException(403);
+ }
+
+ // Check parameters
+ if (!$id && !$track_id && !$ref) {
+ throw new RestException(401, 'Wrong parameters');
+ }
+
+ $result = $this->ticket->fetch($id, $ref, $track_id);
+ if (!$result) {
+ throw new RestException(404, 'Ticket not found');
+ }
+
+ // String for user assigned
+ if ($this->ticket->fk_user_assign > 0) {
+ $userStatic = new User($this->db);
+ $userStatic->fetch($this->ticket->fk_user_assign);
+ $this->ticket->fk_user_assign_string = $userStatic->firstname.' '.$userStatic->lastname;
+ }
+
+ // Messages of ticket
+ $messages = array();
+ $this->ticket->loadCacheMsgsTicket();
+ if (is_array($this->ticket->cache_msgs_ticket) && count($this->ticket->cache_msgs_ticket) > 0) {
+ $num = count($this->ticket->cache_msgs_ticket);
+ $i = 0;
+ while ($i < $num) {
+ if ($this->ticket->cache_msgs_ticket[$i]['fk_user_author'] > 0) {
+ $user_action = new User($this->db);
+ $user_action->fetch($this->ticket->cache_msgs_ticket[$i]['fk_user_author']);
+ }
+
+ // Now define messages
+ $messages[] = array(
+ 'id' => $this->ticket->cache_msgs_ticket[$i]['id'],
+ 'fk_user_action' => $this->ticket->cache_msgs_ticket[$i]['fk_user_author'],
+ 'fk_user_action_socid' => $user_action->socid,
+ 'fk_user_action_string' => dolGetFirstLastname($user_action->firstname, $user_action->lastname),
+ 'message' => $this->ticket->cache_msgs_ticket[$i]['message'],
+ 'datec' => $this->ticket->cache_msgs_ticket[$i]['datec'],
+ 'private' => $this->ticket->cache_msgs_ticket[$i]['private']
+ );
+ $i++;
+ }
+ $this->ticket->messages = $messages;
+ }
+
+ // History
+ $history = array();
+ $this->ticket->loadCacheLogsTicket();
+ if (is_array($this->ticket->cache_logs_ticket) && count($this->ticket->cache_logs_ticket) > 0) {
+ $num = count($this->ticket->cache_logs_ticket);
+ $i = 0;
+ while ($i < $num) {
+ if ($this->ticket->cache_logs_ticket[$i]['fk_user_create'] > 0) {
+ $user_action = new User($this->db);
+ $user_action->fetch($this->ticket->cache_logs_ticket[$i]['fk_user_create']);
+ }
+
+ // Now define messages
+ $history[] = array(
+ 'id' => $this->ticket->cache_logs_ticket[$i]['id'],
+ 'fk_user_author' => $this->ticket->cache_msgs_ticket[$i]['fk_user_author'],
+ 'fk_user_action' => $this->ticket->cache_logs_ticket[$i]['fk_user_create'],
+ 'fk_user_action_string' => dolGetFirstLastname($user_action->firstname, $user_action->lastname),
+ 'message' => $this->ticket->cache_logs_ticket[$i]['message'],
+ 'datec' => $this->ticket->cache_logs_ticket[$i]['datec'],
+ );
+ $i++;
+ }
+ $this->ticket->history = $history;
+ }
+
+
+ if (!DolibarrApi::_checkAccessToResource('ticket', $this->ticket->id)) {
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ }
+ return $this->_cleanObjectDatas($this->ticket);
+ }
+
+ /**
+ * List tickets
+ *
+ * Get a list of tickets
+ *
+ * @param int $socid Filter list with thirdparty ID
+ * @param string $sortfield Sort field
+ * @param string $sortorder Sort order
+ * @param int $limit Limit for list
+ * @param int $page Page number
+ * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101') and (t.fk_statut:=:1)"
+ *
+ * @return array Array of ticket objects
+ *
+ */
+ public function index($socid = 0, $sortfield = "t.rowid", $sortorder = "ASC", $limit = 100, $page = 0, $sqlfilters = '')
+ {
+ global $db, $conf;
+
+ $obj_ret = array();
+
+ if (!$socid && DolibarrApiAccess::$user->socid) {
+ $socid = DolibarrApiAccess::$user->socid;
+ }
+
+ // If the internal user must only see his customers, force searching by him
+ if (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) {
+ $search_sale = DolibarrApiAccess::$user->id;
+ }
+
+ $sql = "SELECT t.rowid";
+ if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) {
+ $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
+ }
+ $sql .= " FROM ".MAIN_DB_PREFIX."ticket as t";
+
+ if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) {
+ $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
+ }
+
+ $sql .= ' WHERE t.entity IN ('.getEntity('ticket', 1).')';
+ if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) {
+ $sql .= " AND t.fk_soc = sc.fk_soc";
+ }
+ if ($socid > 0) {
+ $sql .= " AND t.fk_soc = ".$socid;
+ }
+ if ($search_sale > 0) {
+ $sql .= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale
+ }
+
+ // Insert sale filter
+ if ($search_sale > 0) {
+ $sql .= " AND sc.fk_user = ".$search_sale;
+ }
+ // Add sql filters
+ if ($sqlfilters) {
+ if (!DolibarrApi::_checkFilters($sqlfilters)) {
+ throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
+ }
+ $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
+ $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
+ }
+
+ $sql .= $db->order($sortfield, $sortorder);
+
+ if ($limit) {
+ if ($page < 0) {
+ $page = 0;
+ }
+ $offset = $limit * $page;
+
+ $sql .= $this->db->plimit($limit, $offset);
+ }
+
+ $result = $db->query($sql);
+ if ($result) {
+ $num = $db->num_rows($result);
+ $i = 0;
+ while ($i < $num) {
+ $obj = $db->fetch_object($result);
+ $ticket_static = new Ticket($db);
+ if ($ticket_static->fetch($obj->rowid)) {
+ if ($ticket_static->fk_user_assign > 0) {
+ $userStatic = new User($this->db);
+ $userStatic->fetch($ticket_static->fk_user_assign);
+ $ticket_static->fk_user_assign_string = $userStatic->firstname.' '.$userStatic->lastname;
+ }
+ $obj_ret[] = $this->_cleanObjectDatas($ticket_static);
+ }
+ $i++;
+ }
+ } else {
+ throw new RestException(503, 'Error when retrieve ticket list');
+ }
+ if (!count($obj_ret)) {
+ throw new RestException(404, 'No ticket found');
+ }
+ return $obj_ret;
+ }
+
+ /**
+ * Create ticket object
+ *
+ * @param array $request_data Request datas
+ * @return int ID of ticket
+ */
+ public function post($request_data = null)
+ {
+ $ticketstatic = new Ticket($this->db);
+ if (!DolibarrApiAccess::$user->rights->ticket->write) {
+ throw new RestException(401);
+ }
+ // Check mandatory fields
+ $result = $this->_validate($request_data);
+
+ foreach ($request_data as $field => $value) {
+ $this->ticket->$field = $value;
+ }
+ if (empty($this->ticket->ref)) {
+ $this->ticket->ref = $ticketstatic->getDefaultRef();
+ }
+ if (empty($this->ticket->track_id)) {
+ $this->ticket->track_id = generate_random_id(16);
+ }
+
+ if ($this->ticket->create(DolibarrApiAccess::$user) < 0) {
+ throw new RestException(500, "Error creating ticket", array_merge(array($this->ticket->error), $this->ticket->errors));
+ }
+
+ return $this->ticket->id;
+ }
+
+ /**
+ * Create ticket object
+ *
+ * @param array $request_data Request datas
+ * @return int ID of ticket
+ *
+ */
+ public function postNewMessage($request_data = null)
+ {
+ $ticketstatic = new Ticket($this->db);
+ if (!DolibarrApiAccess::$user->rights->ticket->write) {
+ throw new RestException(401);
+ }
+ // Check mandatory fields
+ $result = $this->_validateMessage($request_data);
+
+ foreach ($request_data as $field => $value) {
+ $this->ticket->$field = $value;
+ }
+ $ticketMessageText = $this->ticket->message;
+ $result = $this->ticket->fetch('', '', $this->ticket->track_id);
+ if (!$result) {
+ throw new RestException(404, 'Ticket not found');
+ }
+ $this->ticket->message = $ticketMessageText;
+ if (!$this->ticket->createTicketMessage(DolibarrApiAccess::$user)) {
+ throw new RestException(500);
+ }
+ return $this->ticket->id;
+ }
+
+ /**
+ * Update ticket
+ *
+ * @param int $id Id of ticket to update
+ * @param array $request_data Datas
+ * @return int
+ *
+ */
+ public function put($id, $request_data = null)
+ {
+ if (!DolibarrApiAccess::$user->rights->ticket->write) {
+ throw new RestException(401);
+ }
+
+ $result = $this->ticket->fetch($id);
+ if (!$result) {
+ throw new RestException(404, 'Ticket not found');
+ }
+
+ if (!DolibarrApi::_checkAccessToResource('ticket', $this->ticket->id)) {
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ }
+
+ foreach ($request_data as $field => $value) {
+ $this->ticket->$field = $value;
+ }
+
+ if ($this->ticket->update($id, DolibarrApiAccess::$user)) {
+ return $this->get($id);
+ }
+
+ return false;
+ }
+
+ /**
+ * Delete ticket
+ *
+ * @param int $id Ticket ID
+ * @return array
+ *
+ */
+ public function delete($id)
+ {
+ if (!DolibarrApiAccess::$user->rights->ticket->delete) {
+ throw new RestException(401);
+ }
+ $result = $this->ticket->fetch($id);
+ if (!$result) {
+ throw new RestException(404, 'Ticket not found');
+ }
+
+ if (!DolibarrApi::_checkAccessToResource('ticket', $this->ticket->id)) {
+ throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
+ }
+
+ if (!$this->ticket->delete($id)) {
+ throw new RestException(500);
+ }
+
+ return array(
+ 'success' => array(
+ 'code' => 200,
+ 'message' => 'Ticket deleted'
+ )
+ );
+ }
+
+ /**
+ * Validate fields before create or update object
+ *
+ * @param array $data Data to validate
+ * @return array
+ *
+ * @throws RestException
+ */
+ private function _validate($data)
+ {
+ $ticket = array();
+ foreach (Tickets::$FIELDS as $field) {
+ if (!isset($data[$field])) {
+ throw new RestException(400, "$field field missing");
+ }
+ $ticket[$field] = $data[$field];
+ }
+ return $ticket;
+ }
+
+ /**
+ * Validate fields before create or update object message
+ *
+ * @param array $data Data to validate
+ * @return array
+ *
+ * @throws RestException
+ */
+ private function _validateMessage($data)
+ {
+ $ticket = array();
+ foreach (Tickets::$FIELDS_MESSAGES as $field) {
+ if (!isset($data[$field])) {
+ throw new RestException(400, "$field field missing");
+ }
+ $ticket[$field] = $data[$field];
+ }
+ return $ticket;
+ }
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
+ /**
+ * Clean sensible object datas
+ *
+ * @param object $object Object to clean
+ * @return array Array of cleaned object properties
+ *
+ * @todo use an array for properties to clean
+ *
+ */
+ protected function _cleanObjectDatas($object)
+ {
+ // phpcs:enable
+ $object = parent::_cleanObjectDatas($object);
+
+ // Other attributes to clean
+ $attr2clean = array(
+ "contact",
+ "contact_id",
+ "ref_previous",
+ "ref_next",
+ "ref_ext",
+ "table_element_line",
+ "statut",
+ "country",
+ "country_id",
+ "country_code",
+ "barcode_type",
+ "barcode_type_code",
+ "barcode_type_label",
+ "barcode_type_coder",
+ "mode_reglement_id",
+ "cond_reglement_id",
+ "cond_reglement",
+ "fk_delivery_address",
+ "shipping_method_id",
+ "modelpdf",
+ "fk_account",
+ "note_public",
+ "note_private",
+ "note",
+ "total_ht",
+ "total_tva",
+ "total_localtax1",
+ "total_localtax2",
+ "total_ttc",
+ "fk_incoterms",
+ "label_incoterms",
+ "location_incoterms",
+ "name",
+ "lastname",
+ "firstname",
+ "civility_id",
+ "canvas",
+ "cache_msgs_ticket",
+ "cache_logs_ticket",
+ "cache_types_tickets",
+ "cache_category_tickets",
+ "regeximgext",
+ "statuts_short",
+ "statuts"
+ );
+ foreach ($attr2clean as $toclean) {
+ unset($object->$toclean);
+ }
+
+ // If object has lines, remove $db property
+ if (isset($object->lines) && count($object->lines) > 0) {
+ $nboflines = count($object->lines);
+ for ($i = 0; $i < $nboflines; $i++) {
+ $this->_cleanObjectDatas($object->lines[$i]);
+ }
+ }
+
+ // If object has linked objects, remove $db property
+ if (isset($object->linkedObjects) && count($object->linkedObjects) > 0) {
+ foreach ($object->linkedObjects as $type_object => $linked_object) {
+ foreach ($linked_object as $object2clean) {
+ $this->_cleanObjectDatas($object2clean);
+ }
+ }
+ }
+ return $object;
+ }
}
--- /tmp/dsg/dolibarr/htdocs/ticket/class/github_ticket.class.php
+++ /tmp/dsg/dolibarr/htdocs/ticket/class/client_ticket.class.php
@@ -1,8 +1,7 @@
* Copyright (C) 2016 Christophe Battarel
- * Copyright (C) 2019-2020 Frédéric France
- * Copyright (C) 2020 Laurent Destailleur
+ * Copyright (C) 2019 Frédéric France
*
* 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
@@ -108,13 +107,8 @@
/**
* @var int Ticket statut
- * @deprecated
- */
- public $fk_statut;
-
- /**
- * @var int Ticket status
- */
+ */
+ public $fk_statut; // deprecated
public $status;
/**
@@ -148,27 +142,7 @@
public $severity_code;
/**
- * Type label
- */
- public $type_label;
-
- /**
- * Category label
- */
- public $category_label;
-
- /**
- * Severity label
- */
- public $severity_label;
-
- /**
- * Email from user
- */
- public $email_from;
-
- /**
- * @var int Creation date
+ * @var int Création date
*/
public $datec = '';
@@ -193,21 +167,43 @@
public $cache_category_tickets;
/**
- * @var int Notify thirdparty at create
+ * @var int Notify tiers at create
*/
public $notify_tiers_at_create;
- /**
- * @var string msgid
- */
- public $email_msgid;
-
public $lines;
/**
* @var string Regex pour les images
*/
public $regeximgext = '\.jpg|\.jpeg|\.bmp|\.gif|\.png|\.tiff';
+
+ public $fields = array(
+ 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'position'=>1, 'visible'=>-2, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id"),
+ 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>5, 'notnull'=>1, 'index'=>1),
+ 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'visible'=>1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object", 'css'=>''),
+ 'track_id' => array('type'=>'varchar(255)', 'label'=>'TicketTrackId', 'visible'=>-2, 'enabled'=>1, 'position'=>11, 'notnull'=>-1, 'searchall'=>1, 'help'=>"Help text"),
+ 'fk_user_create' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Author', 'visible'=>1, 'enabled'=>1, 'position'=>15, 'notnull'=>1, 'css'=>'tdoverflowmax150 maxwidth150onsmartphone'),
+ 'origin_email' => array('type'=>'mail', 'label'=>'OriginEmail', 'visible'=>-2, 'enabled'=>1, 'position'=>16, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object", 'css'=>'tdoverflowmax150'),
+ 'subject' => array('type'=>'varchar(255)', 'label'=>'Subject', 'visible'=>1, 'enabled'=>1, 'position'=>18, 'notnull'=>-1, 'searchall'=>1, 'help'=>"", 'css'=>'maxwidth75', 'autofocusoncreate'=>1),
+ 'type_code' => array('type'=>'varchar(32)', 'label'=>'Type', 'visible'=>1, 'enabled'=>1, 'position'=>20, 'notnull'=>-1, 'searchall'=>1, 'help'=>"", 'css'=>'maxwidth100'),
+ 'category_code' => array('type'=>'varchar(32)', 'label'=>'TicketGroup', 'visible'=>-1, 'enabled'=>1, 'position'=>21, 'notnull'=>-1, 'help'=>"", 'css'=>'maxwidth100'),
+ 'severity_code' => array('type'=>'varchar(32)', 'label'=>'Severity', 'visible'=>1, 'enabled'=>1, 'position'=>22, 'notnull'=>-1, 'help'=>"", 'css'=>'maxwidth100'),
+ 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>"LinkToThirparty", 'css'=>'tdoverflowmax150 maxwidth150onsmartphone'),
+ 'notify_tiers_at_create' => array('type'=>'integer', 'label'=>'NotifyThirdparty', 'visible'=>-1, 'enabled'=>0, 'position'=>51, 'notnull'=>1, 'index'=>1),
+ 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php', 'label'=>'Project', 'visible'=>-1, 'enabled'=>1, 'position'=>52, 'notnull'=>-1, 'index'=>1, 'help'=>"LinkToProject"),
+ 'timing' => array('type'=>'varchar(20)', 'label'=>'Timing', 'visible'=>-1, 'enabled'=>1, 'position'=>42, 'notnull'=>-1, 'help'=>""),
+ 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>1, 'enabled'=>1, 'position'=>500, 'notnull'=>1),
+ 'date_read' => array('type'=>'datetime', 'label'=>'TicketReadOn', 'visible'=>1, 'enabled'=>1, 'position'=>501, 'notnull'=>1),
+ 'fk_user_assign' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'AssignedTo', 'visible'=>1, 'enabled'=>1, 'position'=>505, 'notnull'=>1),
+ 'date_close' => array('type'=>'datetime', 'label'=>'TicketCloseOn', 'visible'=>-1, 'enabled'=>1, 'position'=>510, 'notnull'=>1),
+ 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-1, 'enabled'=>1, 'position'=>520, 'notnull'=>1),
+ 'message' => array('type'=>'text', 'label'=>'Message', 'visible'=>-2, 'enabled'=>1, 'position'=>540, 'notnull'=>-1,),
+ 'progress' => array('type'=>'varchar(100)', 'label'=>'Progression', 'visible'=>-1, 'enabled'=>1, 'position'=>540, 'notnull'=>-1, 'css'=>'right', 'help'=>"", 'isameasure'=>1),
+ 'resolution' => array('type'=>'integer', 'label'=>'Resolution', 'visible'=>-1, 'enabled'=>1, 'position'=>550, 'notnull'=>1),
+ 'fk_statut' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>600, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array(0 => 'Unread', 1 => 'Read', 3 => 'Answered', 4 => 'Assigned', 5 => 'InProgress', 6 => 'Waiting', 8 => 'Closed', 9 => 'Deleted')),
+ 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>900),
+ );
/**
* Status
@@ -217,69 +213,12 @@
const STATUS_ASSIGNED = 2;
const STATUS_IN_PROGRESS = 3;
const STATUS_NEED_MORE_INFO = 5;
- const STATUS_WAITING = 7; // on hold
+ const STATUS_WAITING = 7;
const STATUS_CLOSED = 8;
const STATUS_CANCELED = 9;
/**
- * 'type' field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'sellist:TableName:LabelFieldName[:KeyFieldName[:KeyFieldParent[:Filter]]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'text:none', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password')
- * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)"
- * 'label' the translation key.
- * 'picto' is code of a picto to show before value in forms
- * 'enabled' is a condition when the field must be managed (Example: 1 or '$conf->global->MY_SETUP_PARAM)
- * 'position' is the sort order of field.
- * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0).
- * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). 5=Visible on list and view only (not create/not update). Using a negative value means field is not shown by default on list but can be selected for viewing)
- * 'noteditable' says if field is not editable (1 or 0)
- * 'default' is a default value for creation (can still be overwrote by the Setup of Default Values if field is editable in creation form). Note: If default is set to '(PROV)' and field is 'ref', the default value will be set to '(PROVid)' where id is rowid when a new record is created.
- * 'index' if we want an index in database.
- * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...).
- * 'searchall' is 1 if we want to search in this field when making a search from the quick search button.
- * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8).
- * 'css' and 'cssview' and 'csslist' is the CSS style to use on field. 'css' is used in creation and update. 'cssview' is used in view mode. 'csslist' is used for columns in lists. For example: 'maxwidth200', 'wordbreak', 'tdoverflowmax200'
- * 'help' is a 'TranslationString' to use to show a tooltip on field. You can also use 'TranslationString:keyfortooltiponlick' for a tooltip on click.
- * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record
- * 'disabled' is 1 if we want to have the field locked by a 'disabled' attribute. In most cases, this is never set into the definition of $fields into class, but is set dynamically by some part of code.
- * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel")
- * 'autofocusoncreate' to have field having the focus on a create form. Only 1 field should have this property set to 1.
- * 'comment' is not used. You can store here any text of your choice. It is not used by application.
- *
- * Note: To have value dynamic, you can set value to 0 in definition and edit the value on the fly into the constructor.
- */
-
- // BEGIN MODULEBUILDER PROPERTIES
- public $fields = array(
- 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'position'=>1, 'visible'=>-2, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id"),
- 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>5, 'notnull'=>1, 'index'=>1),
- 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'visible'=>1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object", 'css'=>''),
- 'track_id' => array('type'=>'varchar(255)', 'label'=>'TicketTrackId', 'visible'=>-2, 'enabled'=>1, 'position'=>11, 'notnull'=>-1, 'searchall'=>1, 'help'=>"Help text"),
- 'fk_user_create' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Author', 'visible'=>1, 'enabled'=>1, 'position'=>15, 'notnull'=>1, 'css'=>'tdoverflowmax125 maxwidth150onsmartphone'),
- 'origin_email' => array('type'=>'mail', 'label'=>'OriginEmail', 'visible'=>-2, 'enabled'=>1, 'position'=>16, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object", 'css'=>'tdoverflowmax150'),
- 'subject' => array('type'=>'varchar(255)', 'label'=>'Subject', 'visible'=>1, 'enabled'=>1, 'position'=>18, 'notnull'=>-1, 'searchall'=>1, 'help'=>"", 'css'=>'maxwidth200 tdoverflowmax200', 'autofocusoncreate'=>1),
- 'type_code' => array('type'=>'varchar(32)', 'label'=>'Type', 'visible'=>1, 'enabled'=>1, 'position'=>20, 'notnull'=>-1, 'help'=>"", 'css'=>'maxwidth125 tdoverflowmax50'),
- 'category_code' => array('type'=>'varchar(32)', 'label'=>'TicketCategory', 'visible'=>-1, 'enabled'=>1, 'position'=>21, 'notnull'=>-1, 'help'=>"", 'css'=>'maxwidth100'),
- 'severity_code' => array('type'=>'varchar(32)', 'label'=>'Severity', 'visible'=>1, 'enabled'=>1, 'position'=>22, 'notnull'=>-1, 'help'=>"", 'css'=>'maxwidth100'),
- 'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>'$conf->societe->enabled', 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>"LinkToThirparty", 'css'=>'tdoverflowmax150 maxwidth150onsmartphone'),
- 'notify_tiers_at_create' => array('type'=>'integer', 'label'=>'NotifyThirdparty', 'visible'=>-1, 'enabled'=>0, 'position'=>51, 'notnull'=>1, 'index'=>1),
- 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php', 'label'=>'Project', 'visible'=>-1, 'enabled'=>1, 'position'=>52, 'notnull'=>-1, 'index'=>1, 'help'=>"LinkToProject"),
- 'timing' => array('type'=>'varchar(20)', 'label'=>'Timing', 'visible'=>-1, 'enabled'=>1, 'position'=>42, 'notnull'=>-1, 'help'=>""),
- 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>1, 'enabled'=>1, 'position'=>500, 'notnull'=>1),
- 'date_read' => array('type'=>'datetime', 'label'=>'TicketReadOn', 'visible'=>-1, 'enabled'=>1, 'position'=>501, 'notnull'=>1),
- 'fk_user_assign' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'AssignedTo', 'visible'=>1, 'enabled'=>1, 'position'=>505, 'notnull'=>1, 'css'=>'tdoverflowmax125'),
- 'date_close' => array('type'=>'datetime', 'label'=>'TicketCloseOn', 'visible'=>-1, 'enabled'=>1, 'position'=>510, 'notnull'=>1),
- 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-1, 'enabled'=>1, 'position'=>520, 'notnull'=>1),
- 'message' => array('type'=>'text', 'label'=>'Message', 'visible'=>-2, 'enabled'=>1, 'position'=>540, 'notnull'=>-1,),
- 'email_msgid' => array('type'=>'varchar(255)', 'label'=>'EmailMsgID', 'visible'=>-2, 'enabled'=>1, 'position'=>540, 'notnull'=>-1, 'help'=>'EmailMsgIDDesc'),
- 'progress' => array('type'=>'varchar(100)', 'label'=>'Progression', 'visible'=>-1, 'enabled'=>1, 'position'=>540, 'notnull'=>-1, 'css'=>'right', 'help'=>"", 'isameasure'=>1),
- 'resolution' => array('type'=>'integer', 'label'=>'Resolution', 'visible'=>-1, 'enabled'=>1, 'position'=>550, 'notnull'=>1),
- 'fk_statut' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>600, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array(0 => 'Unread', 1 => 'Read', 3 => 'Answered', 4 => 'Assigned', 5 => 'InProgress', 6 => 'Waiting', 8 => 'Closed', 9 => 'Deleted')),
- 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>900),
- );
- // END MODULEBUILDER PROPERTIES
-
-
- /**
* Constructor
*
* @param DoliDb $db Database handler
@@ -288,26 +227,8 @@
{
$this->db = $db;
- $this->statuts_short = array(
- self::STATUS_NOT_READ => 'Unread',
- self::STATUS_READ => 'Read',
- self::STATUS_ASSIGNED => 'Assigned',
- self::STATUS_IN_PROGRESS => 'InProgress',
- self::STATUS_WAITING => 'OnHold',
- self::STATUS_NEED_MORE_INFO => 'NeedMoreInformation',
- self::STATUS_CLOSED => 'Closed',
- self::STATUS_CANCELED => 'Canceled'
- );
- $this->statuts = array(
- self::STATUS_NOT_READ => 'Unread',
- self::STATUS_READ => 'Read',
- self::STATUS_ASSIGNED => 'Assigned',
- self::STATUS_IN_PROGRESS => 'InProgress',
- self::STATUS_WAITING => 'OnHold',
- self::STATUS_NEED_MORE_INFO => 'NeedMoreInformation',
- self::STATUS_CLOSED => 'Closed',
- self::STATUS_CANCELED => 'Canceled'
- );
+ $this->statuts_short = array(self::STATUS_NOT_READ => 'Unread', self::STATUS_READ => 'Read', self::STATUS_ASSIGNED => 'Assigned', self::STATUS_IN_PROGRESS => 'InProgress', self::STATUS_NEED_MORE_INFO => 'NeedMoreInformation', self::STATUS_WAITING => 'Suspended', self::STATUS_CLOSED => 'Closed', self::STATUS_CANCELED => 'Canceled');
+ $this->statuts = array(self::STATUS_NOT_READ => 'Unread', self::STATUS_READ => 'Read', self::STATUS_ASSIGNED => 'Assigned', self::STATUS_IN_PROGRESS => 'InProgress', self::STATUS_NEED_MORE_INFO => 'NeedMoreInformation', self::STATUS_WAITING => 'Suspended', self::STATUS_CLOSED => 'Closed', self::STATUS_CANCELED => 'Canceled');
}
/**
@@ -426,7 +347,6 @@
$sql .= "origin_email,";
$sql .= "fk_user_create,";
$sql .= "fk_user_assign,";
- $sql .= "email_msgid,";
$sql .= "subject,";
$sql .= "message,";
$sql .= "fk_statut,";
@@ -449,7 +369,6 @@
$sql .= " ".(!isset($this->origin_email) ? 'NULL' : "'".$this->db->escape($this->origin_email)."'").",";
$sql .= " ".($this->fk_user_create > 0 ? $this->fk_user_create : ($user->id > 0 ? $user->id : 'NULL')).",";
$sql .= " ".($this->fk_user_assign > 0 ? $this->fk_user_assign : 'NULL').",";
- $sql .= " ".(empty($this->email_msgid) ? 'NULL' : "'".$this->db->escape($this->email_msgid)."'").",";
$sql .= " ".(!isset($this->subject) ? 'NULL' : "'".$this->db->escape($this->subject)."'").",";
$sql .= " ".(!isset($this->message) ? 'NULL' : "'".$this->db->escape($this->message)."'").",";
$sql .= " ".(!isset($this->fk_statut) ? '0' : "'".$this->db->escape($this->fk_statut)."'").",";
@@ -518,18 +437,17 @@
/**
* Load object in memory from the database
*
- * @param int $id Id object
- * @param string $ref Ref
- * @param string $track_id Track id, a hash like ref
- * @param string $email_msgid Email msgid
- * @return int <0 if KO, >0 if OK
- */
- public function fetch($id = '', $ref = '', $track_id = '', $email_msgid = '')
+ * @param int $id Id object
+ * @param string $ref Ref
+ * @param string $track_id Track id, a hash like ref
+ * @return int <0 if KO, >0 if OK
+ */
+ public function fetch($id = '', $ref = '', $track_id = '')
{
global $langs;
// Check parameters
- if (!$id && !$track_id && !$ref && !$email_msgid) {
+ if (!$id && !$track_id && !$ref) {
$this->error = 'ErrorWrongParameters';
dol_print_error(get_class($this)."::fetch ".$this->error);
return -1;
@@ -537,7 +455,6 @@
$sql = "SELECT";
$sql .= " t.rowid,";
- $sql .= " t.entity,";
$sql .= " t.ref,";
$sql .= " t.track_id,";
$sql .= " t.fk_soc,";
@@ -545,7 +462,6 @@
$sql .= " t.origin_email,";
$sql .= " t.fk_user_create,";
$sql .= " t.fk_user_assign,";
- $sql .= " t.email_msgid,";
$sql .= " t.subject,";
$sql .= " t.message,";
$sql .= " t.fk_statut as status,";
@@ -569,12 +485,10 @@
$sql .= " WHERE t.rowid = ".$this->db->escape($id);
} else {
$sql .= " WHERE t.entity IN (".getEntity($this->element, 1).")";
- if (!empty($ref)) {
+ if ($track_id) {
+ $sql .= " AND t.track_id = '".$this->db->escape($track_id)."'";
+ } elseif ($ref) {
$sql .= " AND t.ref = '".$this->db->escape($ref)."'";
- } elseif ($track_id) {
- $sql .= " AND t.track_id = '".$this->db->escape($track_id)."'";
- } else {
- $sql .= " AND t.email_msgid = '".$this->db->escape($email_msgid)."'";
}
}
@@ -594,12 +508,11 @@
$this->origin_email = $obj->origin_email;
$this->fk_user_create = $obj->fk_user_create;
$this->fk_user_assign = $obj->fk_user_assign;
- $this->email_msgid = $obj->email_msgid;
$this->subject = $obj->subject;
$this->message = $obj->message;
$this->status = $obj->status;
- $this->fk_statut = $this->status; // For backward compatibility
+ $this->fk_statut = $this->status; // For backward compatibility
$this->resolution = $obj->resolution;
$this->progress = $obj->progress;
@@ -632,7 +545,9 @@
$this->db->free($resql);
return 1;
- } else {
+ }
+ else
+ {
return 0;
}
} else {
@@ -711,7 +626,7 @@
if (!empty($filter)) {
foreach ($filter as $key => $value) {
if (strpos($key, 'date')) { // To allow $filter['YEAR(s.dated)']=>$year
- $sql .= ' AND '.$key." = '".$this->db->escape($value)."'";
+ $sql .= ' AND '.$key.' = \''.$value.'\'';
} elseif (($key == 't.fk_user_assign') || ($key == 't.type_code') || ($key == 't.category_code') || ($key == 't.severity_code') || ($key == 't.fk_soc')) {
$sql .= " AND ".$key." = '".$this->db->escape($value)."'";
} elseif ($key == 't.fk_statut') {
@@ -1080,12 +995,12 @@
* Initialise object with example values
* Id must be 0 if object instance is a specimen
*
- * @return int
+ * @return void
*/
public function initAsSpecimen()
{
$this->id = 0;
- $this->entity = 1;
+
$this->ref = 'TI0501-001';
$this->track_id = 'XXXXaaaa';
$this->origin_email = 'email@email.com';
@@ -1094,7 +1009,7 @@
$this->fk_user_assign = 1;
$this->subject = 'Subject of ticket';
$this->message = 'Message of ticket';
- $this->status = 0;
+ $this->fk_statut = 0;
$this->resolution = '1';
$this->progress = '10';
$this->timing = '30';
@@ -1105,7 +1020,6 @@
$this->date_read = '';
$this->date_close = '';
$this->tms = '';
- return 1;
}
/**
@@ -1245,8 +1159,8 @@
/**
* Return status label of object
*
- * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
- * @return string Label
+ * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
+ * @return string Label
*/
public function getLibStatut($mode = 0)
{
@@ -1260,10 +1174,9 @@
*
* @param string $status Id status
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
- * @param int $notooltip 1=No tooltip
* @return string Label
*/
- public function LibStatut($status, $mode = 0, $notooltip = 0)
+ public function LibStatut($status, $mode = 0)
{
// phpcs:enable
global $langs;
@@ -1273,33 +1186,36 @@
if ($status == self::STATUS_NOT_READ) {
$statusType = 'status0';
- } elseif ($status == self::STATUS_READ) {
+ }
+ elseif ($status == self::STATUS_READ) {
$statusType = 'status1';
- } elseif ($status == self::STATUS_ASSIGNED) {
- $statusType = 'status2';
- } elseif ($status == self::STATUS_IN_PROGRESS) {
+ }
+ elseif ($status == self::STATUS_ASSIGNED) {
+ $statusType = 'status3';
+ }
+ elseif ($status == self::STATUS_IN_PROGRESS) {
$statusType = 'status4';
- } elseif ($status == self::STATUS_WAITING) {
- $statusType = 'status7';
- } elseif ($status == self::STATUS_NEED_MORE_INFO) {
+ }
+ elseif ($status == self::STATUS_WAITING) {
$statusType = 'status3';
- } elseif ($status == self::STATUS_CANCELED) {
+ }
+ elseif ($status == self::STATUS_NEED_MORE_INFO) {
$statusType = 'status9';
- } elseif ($status == self::STATUS_CLOSED) {
+ }
+ elseif ($status == self::STATUS_CANCELED) {
+ $statusType = 'status9';
+ }
+ elseif ($status == self::STATUS_CLOSED) {
$statusType = 'status6';
- } else {
+ }
+ else {
$labelStatus = $langs->trans('Unknown');
$labelStatusShort = $langs->trans('Unknown');
$statusType = 'status0';
$mode = 0;
}
- $params = array();
- if ($notooltip) {
- $params = array('tooltip' => 'no');
- }
-
- return dolGetStatus($langs->trans($labelStatus), $langs->trans($labelStatusShort), '', $statusType, $mode, '', $params);
+ return dolGetStatus($langs->trans($labelStatus), $langs->trans($labelStatusShort), '', $statusType, $mode);
}
@@ -1322,9 +1238,9 @@
if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
$result = '';
-
- $label = img_picto('', $this->picto).' '.$langs->trans("Ticket").'';
- $label .= ' '.$this->getLibStatut(4);
+ $companylink = '';
+
+ $label = ''.$langs->trans("Ticket").'';
$label .= '
';
$label .= ''.$langs->trans('Ref').': '.$this->ref.'
';
$label .= ''.$langs->trans('TicketTrackId').': '.$this->track_id.'
';
@@ -1350,7 +1266,8 @@
}
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
- } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
+ }
+ else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
$linkstart = '';
@@ -1440,7 +1357,9 @@
if ($id_assign_user > 0)
{
$sql .= " SET fk_user_assign=".$id_assign_user.", fk_statut = ".Ticket::STATUS_ASSIGNED;
- } else {
+ }
+ else
+ {
$sql .= " SET fk_user_assign=null, fk_statut = ".Ticket::STATUS_READ;
}
$sql .= " WHERE rowid = ".$this->id;
@@ -1522,7 +1441,7 @@
$message .= $langs->transnoentities('TicketNotificationRecipient').' : '.$recipient."\n";
$message .= "\n";
$message .= '* '.$langs->transnoentities('TicketNotificationLogMessage').' *'."\n";
- $message .= dol_html_entity_decode($log_message, ENT_QUOTES | ENT_HTML5)."\n";
+ $message .= dol_html_entity_decode($log_message, ENT_QUOTES)."\n";
if ($info_sendto['source'] == 'internal') {
$url_internal_ticket = dol_buildpath('/ticket/card.php', 2).'?track_id='.$this->track_id;
@@ -1550,8 +1469,6 @@
$conf->global->MAIN_MAIL_AUTOCOPY_TO = '';
}
include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
- $sendtocc = '';
- $deliveryreceipt = 0;
$mailfile = new CMailFile($subject, $info_sendto['email'], $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, 0);
if ($mailfile->error || $mailfile->errors) {
setEventMessages($mailfile->error, $mailfile->errors, 'errors');
@@ -1757,27 +1674,24 @@
$error = 0;
// Valid and close fichinter linked
- if (!empty($conf->ficheinter->enabled) && !empty($conf->global->WORKFLOW_TICKET_CLOSE_INTERVENTION)) {
- dol_syslog("We have closed the ticket, so we close all linked interventions");
- $this->fetchObjectLinked($this->id, $this->element, null, 'fichinter');
- if ($this->linkedObjectsIds)
- {
- foreach ($this->linkedObjectsIds['fichinter'] as $fichinter_id) {
- $fichinter = new Fichinter($this->db);
- $fichinter->fetch($fichinter_id);
- if ($fichinter->statut == 0) {
- $result = $fichinter->setValid($user);
- if (!$result) {
- $this->errors[] = $fichinter->error;
- $error++;
- }
+ $this->fetchObjectLinked($this->id, $this->element, null, 'fichinter');
+ if ($this->linkedObjectsIds)
+ {
+ foreach ($this->linkedObjectsIds['fichinter'] as $fichinter_id) {
+ $fichinter = new Fichinter($this->db);
+ $fichinter->fetch($fichinter_id);
+ if ($fichinter->statut == 0) {
+ $result = $fichinter->setValid($user);
+ if (!$result) {
+ $this->errors[] = $fichinter->error;
+ $error++;
}
- if ($fichinter->statut < 3) {
- $result = $fichinter->setStatut(3);
- if (!$result) {
- $this->errors[] = $fichinter->error;
- $error++;
- }
+ }
+ if ($fichinter->statut < 3) {
+ $result = $fichinter->setStatut(3);
+ if (!$result) {
+ $this->errors[] = $fichinter->error;
+ $error++;
}
}
}
@@ -2299,7 +2213,7 @@
$sql .= " AND tc.active=1";
if ($status >= 0) {
- $sql .= " AND ec.statut = ".((int) $status);
+ $sql .= " AND ec.statut = '".$status."'";
}
$sql .= " ORDER BY t.lastname ASC";
@@ -2495,15 +2409,14 @@
/**
- * Add new message on a ticket (private/public area). Can also send it be email if GETPOST('send_email', 'int') is set.
+ * Add new message on a ticket (private area). Can also send it be email if GETPOST('send_email', 'int') is set.
*
* @param User $user User for action
* @param string $action Action string
* @param int $private 1=Message is private. TODO Implement this. What does this means ?
- * @param int $public_area 1=Is the public area
* @return int
*/
- public function newMessage($user, &$action, $private = 1, $public_area = 0)
+ public function newMessage($user, &$action, $private = 1)
{
global $mysoc, $conf, $langs;
@@ -2530,7 +2443,7 @@
if (!$error) {
$object->subject = GETPOST('subject', 'alphanohtml');
- $object->message = GETPOST("message", "restricthtml");
+ $object->message = GETPOST("message", "none");
$object->private = GETPOST("private_message", "alpha");
$send_email = GETPOST('send_email', 'int');
@@ -2556,231 +2469,140 @@
//var_dump($_SESSION); var_dump($listofpaths);exit;
/*
- * Public area
- */
- if (!empty($public_area)) {
- /*
- * Send emails to assigned users (public area notification)
- */
- if (!empty($conf->global->TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_ENABLED)) {
- $assigned_user_dont_have_email = '';
- $sendto = array();
- if ($this->fk_user_assign > 0) {
- $assigned_user = new User($this->db);
- $assigned_user->fetch($this->fk_user_assign);
- if (!empty($assigned_user->email)) {
- $sendto[] = $assigned_user->getFullName($langs)." <".$assigned_user->email.">";
- } else {
- $assigned_user_dont_have_email = $assigned_user->getFullName($langs);
+ * Send emails to internal users (linked contacts)
+ */
+ if ($send_email > 0) {
+ // Retrieve internal contact datas
+ $internal_contacts = $object->getInfosTicketInternalContact();
+
+ $sendto = array();
+ if (is_array($internal_contacts) && count($internal_contacts) > 0) {
+ // altairis: set default subject
+ $label_title = empty($conf->global->MAIN_APPLICATION_TITLE) ? $mysoc->name : $conf->global->MAIN_APPLICATION_TITLE;
+ $subject = GETPOST('subject', 'nohtml') ? GETPOST('subject', 'nohtml') : '['.$label_title.'- ticket #'.$object->track_id.'] '.$langs->trans('TicketNewMessage');
+
+ $message_intro = $langs->trans('TicketNotificationEmailBody', "#".$object->id);
+ $message_signature = GETPOST('mail_signature') ? GETPOST('mail_signature') : $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE;
+
+ $message = $langs->trans('TicketMessageMailIntroText');
+ $message .= "\n\n";
+ $message .= GETPOST('message', 'restricthtml');
+
+ // Coordonnées client
+ $message .= "\n\n";
+ $message .= "==============================================\n";
+ $message .= !empty($object->thirdparty->name) ? $langs->trans('Thirdparty')." : ".$object->thirdparty->name : '';
+ $message .= !empty($object->thirdparty->town) ? "\n".$langs->trans('Town')." : ".$object->thirdparty->town : '';
+ $message .= !empty($object->thirdparty->phone) ? "\n".$langs->trans('Phone')." : ".$object->thirdparty->phone : '';
+
+ // Build array to display recipient list
+ foreach ($internal_contacts as $key => $info_sendto) {
+ // altairis: avoid duplicate notifications
+ if ($info_sendto['id'] == $user->id) {
+ continue;
+ }
+
+ if ($info_sendto['email'] != '') {
+ if (!empty($info_sendto['email'])) $sendto[] = trim($info_sendto['firstname']." ".$info_sendto['lastname'])." <".$info_sendto['email'].">";
+
+ //Contact type
+ $recipient = dolGetFirstLastname($info_sendto['firstname'], $info_sendto['lastname'], '-1').' ('.strtolower($info_sendto['libelle']).')';
+ $message .= (!empty($recipient) ? $langs->trans('TicketNotificationRecipient').' : '.$recipient."\n" : '');
}
}
- if (empty($sendto)) {
- if (!empty($conf->global->TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_DEFAULT_EMAIL)) {
- $sendto[] = $conf->global->TICKET_PUBLIC_NOTIFICATION_NEW_MESSAGE_DEFAULT_EMAIL;
- } elseif (!empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO)) {
- $sendto[] = $conf->global->TICKET_NOTIFICATION_EMAIL_TO;
- }
+ $message .= "\n";
+ // URL ticket
+ $url_internal_ticket = dol_buildpath('/ticket/card.php', 2).'?track_id='.$object->track_id;
+
+ // altairis: make html link on url
+ $message .= "\n".$langs->trans('TicketNotificationEmailBodyInfosTrackUrlinternal').' : '.$object->track_id.''."\n";
+
+ // Add global email address recipient
+ if ($conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS && !in_array($conf->global->TICKET_NOTIFICATION_EMAIL_TO, $sendto)) {
+ if (!empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO)) $sendto[] = $conf->global->TICKET_NOTIFICATION_EMAIL_TO;
}
- // Add global email address recipient
- if (!empty($conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS) &&
- !empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO) && !in_array($conf->global->TICKET_NOTIFICATION_EMAIL_TO, $sendto)
- ) {
- $sendto[] = $conf->global->TICKET_NOTIFICATION_EMAIL_TO;
- }
-
+ // altairis: dont try to send email if no recipient
if (!empty($sendto)) {
- $label_title = empty($conf->global->MAIN_APPLICATION_TITLE) ? $mysoc->name : $conf->global->MAIN_APPLICATION_TITLE;
- $subject = '['.$label_title.'- ticket #'.$object->track_id.'] '.$langs->trans('TicketNewMessage');
-
- // Message send
- $message = $langs->trans('TicketMessageMailIntroText');
- $message .= '
';
- $messagePost = GETPOST('message', 'restricthtml');
- if (!dol_textishtml($messagePost)) {
- $messagePost = dol_nl2br($messagePost);
- }
- $message .= $messagePost;
-
- // Customer company infos
- $message .= '
';
- $message .= "==============================================";
- $message .= !empty($object->thirdparty->name) ? '
'.$langs->trans('Thirdparty')." : ".$object->thirdparty->name : '';
- $message .= !empty($object->thirdparty->town) ? '
'.$langs->trans('Town')." : ".$object->thirdparty->town : '';
- $message .= !empty($object->thirdparty->phone) ? '
'.$langs->trans('Phone')." : ".$object->thirdparty->phone : '';
-
- // Email send to
- $message .= '
';
- if (!empty($assigned_user_dont_have_email)) {
- $message .= '
'.$langs->trans('NoEMail').' : '.$assigned_user_dont_have_email;
- }
- foreach ($sendto as $val) {
- $message .= '
'.$langs->trans('TicketNotificationRecipient').' : '.$val;
- }
-
- // URL ticket
- $url_internal_ticket = dol_buildpath('/ticket/card.php', 2).'?track_id='.$object->track_id;
- $message .= '
';
- $message .= $langs->trans('TicketNotificationEmailBodyInfosTrackUrlinternal').' : '.$object->track_id.'';
-
$this->sendTicketMessageByEmail($subject, $message, '', $sendto, $listofpaths, $listofmimes, $listofnames);
}
}
- }
- /*
- * Private area
- */
- else {
+
/*
- * Send emails to internal users (linked contacts)
- */
- if ($send_email > 0) {
- // Retrieve internal contact datas
- $internal_contacts = $object->getInfosTicketInternalContact();
+ * Send emails for externals users if not private (linked contacts)
+ */
+ if (empty($object->private)) {
+ // Retrieve email of all contacts (external)
+ $external_contacts = $object->getInfosTicketExternalContact();
+
+ // If no contact, get email from thirdparty
+ if (is_array($external_contacts) && count($external_contacts) === 0) {
+ if (!empty($object->fk_soc)) {
+ $object->fetch_thirdparty($object->fk_soc);
+ $array_company = array(array('firstname' => '', 'lastname' => $object->thirdparty->name, 'email' => $object->thirdparty->email, 'libelle' => $langs->transnoentities('Customer'), 'socid' => $object->thirdparty->id));
+ $external_contacts = array_merge($external_contacts, $array_company);
+ } elseif (empty($object->fk_soc) && !empty($object->origin_email)) {
+ $array_external = array(array('firstname' => '', 'lastname' => $object->origin_email, 'email' => $object->thirdparty->email, 'libelle' => $langs->transnoentities('Customer'), 'socid' => $object->thirdparty->id));
+ $external_contacts = array_merge($external_contacts, $array_external);
+ }
+ }
$sendto = array();
- if (is_array($internal_contacts) && count($internal_contacts) > 0) {
- // altairis: set default subject
+ if (is_array($external_contacts) && count($external_contacts) > 0) {
+ // altairis: get default subject for email to external contacts
$label_title = empty($conf->global->MAIN_APPLICATION_TITLE) ? $mysoc->name : $conf->global->MAIN_APPLICATION_TITLE;
- $subject = GETPOST('subject', 'nohtml') ? GETPOST('subject', 'nohtml') : '['.$label_title.'- ticket #'.$object->track_id.'] '.$langs->trans('TicketNewMessage');
-
- $message_intro = $langs->trans('TicketNotificationEmailBody', "#".$object->id);
+ $subject = GETPOST('subject') ? GETPOST('subject') : '['.$label_title.'- ticket #'.$object->track_id.'] '.$langs->trans('TicketNewMessage');
+
+ $message_intro = GETPOST('mail_intro') ? GETPOST('mail_intro') : $conf->global->TICKET_MESSAGE_MAIL_INTRO;
$message_signature = GETPOST('mail_signature') ? GETPOST('mail_signature') : $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE;
- $message = $langs->trans('TicketMessageMailIntroText');
- $message .= '
';
- $messagePost = GETPOST('message', 'restricthtml');
- if (!dol_textishtml($messagePost)) {
- $messagePost = dol_nl2br($messagePost);
- }
- $message .= $messagePost;
-
- // Coordonnées client
- $message .= '
';
- $message .= "==============================================
";
- $message .= !empty($object->thirdparty->name) ? $langs->trans('Thirdparty')." : ".$object->thirdparty->name : '';
- $message .= !empty($object->thirdparty->town) ? '
'.$langs->trans('Town')." : ".$object->thirdparty->town : '';
- $message .= !empty($object->thirdparty->phone) ? '
'.$langs->trans('Phone')." : ".$object->thirdparty->phone : '';
-
- // Build array to display recipient list
- foreach ($internal_contacts as $key => $info_sendto) {
- // altairis: avoid duplicate notifications
- if ($info_sendto['id'] == $user->id) {
+ // We put intro after
+ $message = GETPOST('message');
+ $message .= "\n\n";
+
+ foreach ($external_contacts as $key => $info_sendto) {
+ // altairis: avoid duplicate emails to external contacts
+ if ($info_sendto['id'] == $user->contactid) {
continue;
}
- if ($info_sendto['email'] != '') {
+ if ($info_sendto['email'] != '' && $info_sendto['email'] != $object->origin_email) {
if (!empty($info_sendto['email'])) $sendto[] = trim($info_sendto['firstname']." ".$info_sendto['lastname'])." <".$info_sendto['email'].">";
- //Contact type
$recipient = dolGetFirstLastname($info_sendto['firstname'], $info_sendto['lastname'], '-1').' ('.strtolower($info_sendto['libelle']).')';
- $message .= (!empty($recipient) ? $langs->trans('TicketNotificationRecipient').' : '.$recipient.'
' : '');
+ $message .= (!empty($recipient) ? $langs->trans('TicketNotificationRecipient').' : '.$recipient."\n" : '');
}
}
- $message .= '
';
- // URL ticket
- $url_internal_ticket = dol_buildpath('/ticket/card.php', 2).'?track_id='.$object->track_id;
-
- // altairis: make html link on url
- $message .= '
'.$langs->trans('TicketNotificationEmailBodyInfosTrackUrlinternal').' : '.$object->track_id.'
';
-
- // Add global email address recipient
+
+ // If public interface is not enable, use link to internal page into mail
+ $url_public_ticket = (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE) ?
+ (!empty($conf->global->TICKET_URL_PUBLIC_INTERFACE) ? $conf->global->TICKET_URL_PUBLIC_INTERFACE.'/view.php' : dol_buildpath('/public/ticket/view.php', 2)) : dol_buildpath('/ticket/card.php', 2)).'?track_id='.$object->track_id;
+ $message .= "\n".$langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer').' : '.$object->track_id.''."\n";
+
+ // Build final message
+ $message = $message_intro.$message;
+
+ // Add signature
+ $message .= '
'.$message_signature;
+
+ if (!empty($object->origin_email)) {
+ $sendto[] = $object->origin_email;
+ }
+
+ if ($object->fk_soc > 0 && !in_array($object->origin_email, $sendto)) {
+ $object->socid = $object->fk_soc;
+ $object->fetch_thirdparty();
+ if (!empty($object->thirdparty->email)) $sendto[] = $object->thirdparty->email;
+ }
+
+ // altairis: Add global email address reciepient
if ($conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS && !in_array($conf->global->TICKET_NOTIFICATION_EMAIL_TO, $sendto)) {
if (!empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO)) $sendto[] = $conf->global->TICKET_NOTIFICATION_EMAIL_TO;
}
- // altairis: dont try to send email if no recipient
+ // altairis: dont try to send email when no recipient
if (!empty($sendto)) {
$this->sendTicketMessageByEmail($subject, $message, '', $sendto, $listofpaths, $listofmimes, $listofnames);
- }
- }
-
- /*
- * Send emails for externals users if not private (linked contacts)
- */
- if (empty($object->private)) {
- // Retrieve email of all contacts (external)
- $external_contacts = $object->getInfosTicketExternalContact();
-
- // If no contact, get email from thirdparty
- if (is_array($external_contacts) && count($external_contacts) === 0) {
- if (!empty($object->fk_soc)) {
- $object->fetch_thirdparty($object->fk_soc);
- $array_company = array(array('firstname' => '', 'lastname' => $object->thirdparty->name, 'email' => $object->thirdparty->email, 'libelle' => $langs->transnoentities('Customer'), 'socid' => $object->thirdparty->id));
- $external_contacts = array_merge($external_contacts, $array_company);
- } elseif (empty($object->fk_soc) && !empty($object->origin_email)) {
- $array_external = array(array('firstname' => '', 'lastname' => $object->origin_email, 'email' => $object->thirdparty->email, 'libelle' => $langs->transnoentities('Customer'), 'socid' => $object->thirdparty->id));
- $external_contacts = array_merge($external_contacts, $array_external);
- }
- }
-
- $sendto = array();
- if (is_array($external_contacts) && count($external_contacts) > 0) {
- // altairis: get default subject for email to external contacts
- $label_title = empty($conf->global->MAIN_APPLICATION_TITLE) ? $mysoc->name : $conf->global->MAIN_APPLICATION_TITLE;
- $subject = GETPOST('subject') ? GETPOST('subject') : '['.$label_title.'- ticket #'.$object->track_id.'] '.$langs->trans('TicketNewMessage');
-
- $message_intro = GETPOST('mail_intro') ? GETPOST('mail_intro', 'restricthtml') : $conf->global->TICKET_MESSAGE_MAIL_INTRO;
- $message_signature = GETPOST('mail_signature') ? GETPOST('mail_signature', 'restricthtml') : $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE;
- if (!dol_textishtml($message_intro)) {
- $message_intro = dol_nl2br($message_intro);
- }
- if (!dol_textishtml($message_signature)) {
- $message_signature = dol_nl2br($message_signature);
- }
-
- // We put intro after
- $messagePost = GETPOST('message', 'restricthtml');
- if (!dol_textishtml($messagePost)) {
- $messagePost = dol_nl2br($messagePost);
- }
- $message = $messagePost;
- $message .= '
';
-
- foreach ($external_contacts as $key => $info_sendto) {
- // altairis: avoid duplicate emails to external contacts
- if ($info_sendto['id'] == $user->contact_id) {
- continue;
- }
-
- if ($info_sendto['email'] != '' && $info_sendto['email'] != $object->origin_email) {
- if (!empty($info_sendto['email'])) $sendto[] = trim($info_sendto['firstname']." ".$info_sendto['lastname'])." <".$info_sendto['email'].">";
-
- $recipient = dolGetFirstLastname($info_sendto['firstname'], $info_sendto['lastname'], '-1').' ('.strtolower($info_sendto['libelle']).')';
- $message .= (!empty($recipient) ? $langs->trans('TicketNotificationRecipient').' : '.$recipient.'
' : '');
- }
- }
-
- // If public interface is not enable, use link to internal page into mail
- $url_public_ticket = (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE) ?
- (!empty($conf->global->TICKET_URL_PUBLIC_INTERFACE) ? $conf->global->TICKET_URL_PUBLIC_INTERFACE.'/view.php' : dol_buildpath('/public/ticket/view.php', 2)) : dol_buildpath('/ticket/card.php', 2)).'?track_id='.$object->track_id;
- $message .= '
'.$langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer').' : '.$object->track_id.'
';
-
- // Build final message
- $message = $message_intro.'
'.$message;
-
- // Add signature
- $message .= '
'.$message_signature;
-
- if (!empty($object->origin_email)) {
- $sendto[] = $object->origin_email;
- }
-
- if ($object->fk_soc > 0 && !in_array($object->origin_email, $sendto)) {
- $object->socid = $object->fk_soc;
- $object->fetch_thirdparty();
- if (!empty($object->thirdparty->email)) $sendto[] = $object->thirdparty->email;
- }
-
- // altairis: Add global email address reciepient
- if ($conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS && !in_array($conf->global->TICKET_NOTIFICATION_EMAIL_TO, $sendto)) {
- if (!empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO)) $sendto[] = $conf->global->TICKET_NOTIFICATION_EMAIL_TO;
- }
-
- // altairis: dont try to send email when no recipient
- if (!empty($sendto)) {
- $this->sendTicketMessageByEmail($subject, $message, '', $sendto, $listofpaths, $listofmimes, $listofnames);
- }
}
}
}
@@ -2849,6 +2671,8 @@
$filename = $mimefilename_list;
$mimetype = $mimetype_list;
+ $message_to_send = dol_nl2br($message);
+
// Envoi du mail
if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) {
$old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO;
@@ -2856,7 +2680,7 @@
}
include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$trackid = "tic".$this->id;
- $mailfile = new CMailFile($subject, $receiver, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1, '', '', $trackid, '', 'ticket');
+ $mailfile = new CMailFile($subject, $receiver, $from, $message_to_send, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1, '', '', $trackid);
if ($mailfile->error) {
setEventMessages($mailfile->error, null, 'errors');
} else {
@@ -2947,7 +2771,9 @@
}
}
return $response;
- } else {
+ }
+ else
+ {
$this->error = $this->db->lasterror();
return -1;
}
@@ -2988,26 +2814,13 @@
}
$this->db->free($resql);
return 1;
- } else {
+ }
+ else
+ {
dol_print_error($this->db);
$this->error = $this->db->lasterror();
return -1;
}
- }
-
- /**
- * Function used to replace a thirdparty id with another one.
- *
- * @param DoliDB $db Database handler
- * @param int $origin_id Old thirdparty id
- * @param int $dest_id New thirdparty id
- * @return bool
- */
- public static function replaceThirdparty($db, $origin_id, $dest_id)
- {
- $tables = array('ticket');
-
- return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
}
}
--- /tmp/dsg/dolibarr/htdocs/ticket/class/github_ticketstats.class.php
+++ /tmp/dsg/dolibarr/htdocs/ticket/class/client_ticketstats.class.php
@@ -29,136 +29,136 @@
*/
class TicketStats extends Stats
{
- /**
- * @var string Name of table without prefix where object is stored
- */
- public $table_element;
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
+ public $table_element;
- public $socid;
- public $userid;
+ public $socid;
+ public $userid;
- public $from;
- public $field;
- public $where;
+ public $from;
+ public $field;
+ public $where;
- /**
- * Constructor
- *
- * @param DoliDB $db Database handler
- * @param int $socid Id third party
- * @param mixed $userid Id user for filter or array of user ids
- * @return void
- */
- public function __construct($db, $socid = 0, $userid = 0)
- {
- global $conf;
+ /**
+ * Constructor
+ *
+ * @param DoliDB $db Database handler
+ * @param int $socid Id third party
+ * @param mixed $userid Id user for filter or array of user ids
+ * @return void
+ */
+ public function __construct($db, $socid = 0, $userid = 0)
+ {
+ global $conf;
- $this->db = $db;
- $this->socid = $socid;
- $this->userid = $userid;
+ $this->db = $db;
+ $this->socid = $socid;
+ $this->userid = $userid;
- $object = new Ticket($this->db);
- $this->from = MAIN_DB_PREFIX.$object->table_element;
- $this->field = 'timing';
+ $object = new Ticket($this->db);
+ $this->from = MAIN_DB_PREFIX.$object->table_element;
+ $this->field = 'timing';
- $this->where = " fk_statut > 0";
- $this->where .= " AND entity = ".$conf->entity;
- if ($this->socid > 0) {
- $this->where .= " AND fk_soc = ".$this->socid;
- }
- if (is_array($this->userid) && count($this->userid) > 0) {
- $this->where .= ' AND fk_user_create IN ('.join(',', $this->userid).')';
- } elseif ($this->userid > 0) {
- $this->where .= ' AND fk_user_create = '.$this->userid;
- }
- }
+ $this->where = " fk_statut > 0";
+ $this->where .= " AND entity = ".$conf->entity;
+ if ($this->socid > 0) {
+ $this->where .= " AND fk_soc = ".$this->socid;
+ }
+ if (is_array($this->userid) && count($this->userid) > 0) {
+ $this->where .= ' AND fk_user_create IN ('.join(',', $this->userid).')';
+ } elseif ($this->userid > 0) {
+ $this->where .= ' AND fk_user_create = '.$this->userid;
+ }
+ }
- /**
- * Renvoie le nombre de tickets par annee
- *
- * @return array Array of values
- */
- public function getNbByYear()
- {
- $sql = "SELECT YEAR(datec) as dm, count(*)";
- $sql .= " FROM ".$this->from;
- $sql .= " GROUP BY dm DESC";
- $sql .= " WHERE ".$this->where;
+ /**
+ * Renvoie le nombre de tickets par annee
+ *
+ * @return array Array of values
+ */
+ public function getNbByYear()
+ {
+ $sql = "SELECT YEAR(datec) as dm, count(*)";
+ $sql .= " FROM ".$this->from;
+ $sql .= " GROUP BY dm DESC";
+ $sql .= " WHERE ".$this->where;
- return $this->_getNbByYear($sql);
- }
+ return $this->_getNbByYear($sql);
+ }
- /**
- * Renvoie le nombre de facture par mois pour une annee donnee
- *
- * @param string $year Year to scan
- * @return array Array of values
- */
- public function getNbByMonth($year)
- {
- $sql = "SELECT MONTH(datec) as dm, count(*)";
- $sql .= " FROM ".$this->from;
- $sql .= " WHERE YEAR(datec) = ".$year;
- $sql .= " AND ".$this->where;
- $sql .= " GROUP BY dm";
- $sql .= $this->db->order('dm', 'DESC');
+ /**
+ * Renvoie le nombre de facture par mois pour une annee donnee
+ *
+ * @param string $year Year to scan
+ * @return array Array of values
+ */
+ public function getNbByMonth($year)
+ {
+ $sql = "SELECT MONTH(datec) as dm, count(*)";
+ $sql .= " FROM ".$this->from;
+ $sql .= " WHERE YEAR(datec) = ".$year;
+ $sql .= " AND ".$this->where;
+ $sql .= " GROUP BY dm";
+ $sql .= $this->db->order('dm', 'DESC');
- $res = $this->_getNbByMonth($year, $sql);
- //var_dump($res);print '
';
- return $res;
- }
+ $res = $this->_getNbByMonth($year, $sql);
+ //var_dump($res);print '
';
+ return $res;
+ }
- /**
- * Renvoie le montant de facture par mois pour une annee donnee
- *
- * @param int $year Year to scan
- * @return array Array of values
- */
- public function getAmountByMonth($year)
- {
- $sql = "SELECT date_format(datec,'%m') as dm, sum(".$this->field.")";
- $sql .= " FROM ".$this->from;
- $sql .= " WHERE date_format(datec,'%Y') = '".$this->db->escape($year)."'";
- $sql .= " AND ".$this->where;
- $sql .= " GROUP BY dm";
- $sql .= $this->db->order('dm', 'DESC');
+ /**
+ * Renvoie le montant de facture par mois pour une annee donnee
+ *
+ * @param int $year Year to scan
+ * @return array Array of values
+ */
+ public function getAmountByMonth($year)
+ {
+ $sql = "SELECT date_format(datec,'%m') as dm, sum(".$this->field.")";
+ $sql .= " FROM ".$this->from;
+ $sql .= " WHERE date_format(datec,'%Y') = '".$year."'";
+ $sql .= " AND ".$this->where;
+ $sql .= " GROUP BY dm";
+ $sql .= $this->db->order('dm', 'DESC');
- $res = $this->_getAmountByMonth($year, $sql);
- //var_dump($res);print '
';
- return $res;
- }
+ $res = $this->_getAmountByMonth($year, $sql);
+ //var_dump($res);print '
';
+ return $res;
+ }
- /**
- * Return average amount
- *
- * @param int $year Year to scan
- * @return array Array of values
- */
- public function getAverageByMonth($year)
- {
- $sql = "SELECT date_format(datec,'%m') as dm, avg(".$this->field.")";
- $sql .= " FROM ".$this->from;
- $sql .= " WHERE date_format(datec,'%Y') = '".$this->db->escape($year)."'";
- $sql .= " AND ".$this->where;
- $sql .= " GROUP BY dm";
- $sql .= $this->db->order('dm', 'DESC');
+ /**
+ * Return average amount
+ *
+ * @param int $year Year to scan
+ * @return array Array of values
+ */
+ public function getAverageByMonth($year)
+ {
+ $sql = "SELECT date_format(datec,'%m') as dm, avg(".$this->field.")";
+ $sql .= " FROM ".$this->from;
+ $sql .= " WHERE date_format(datec,'%Y') = '".$year."'";
+ $sql .= " AND ".$this->where;
+ $sql .= " GROUP BY dm";
+ $sql .= $this->db->order('dm', 'DESC');
- return $this->_getAverageByMonth($year, $sql);
- }
+ return $this->_getAverageByMonth($year, $sql);
+ }
- /**
- * Return nb, total and average
- *
- * @return array Array of values
- */
- public function getAllByYear()
- {
- $sql = "SELECT date_format(datec,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg";
- $sql .= " FROM ".$this->from;
- $sql .= " WHERE ".$this->where;
- $sql .= " GROUP BY year";
- $sql .= $this->db->order('year', 'DESC');
+ /**
+ * Return nb, total and average
+ *
+ * @return array Array of values
+ */
+ public function getAllByYear()
+ {
+ $sql = "SELECT date_format(datec,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg";
+ $sql .= " FROM ".$this->from;
+ $sql .= " WHERE ".$this->where;
+ $sql .= " GROUP BY year";
+ $sql .= $this->db->order('year', 'DESC');
- return $this->_getAllByYear($sql);
- }
+ return $this->_getAllByYear($sql);
+ }
}
--- /tmp/dsg/dolibarr/htdocs/ticket/class/github_utils_diff.class.php
+++ /tmp/dsg/dolibarr/htdocs/ticket/class/client_utils_diff.class.php
@@ -22,17 +22,17 @@
/**
* Returns the diff for two strings. The return value is an array, each of
- * whose values is an array containing two values: a line (or character, if
- * $compareCharacters is true), and one of the constants DIFF::UNMODIFIED (the
- * line or character is in both strings), DIFF::DELETED (the line or character
- * is only in the first string), and DIFF::INSERTED (the line or character is
- * only in the second string). The parameters are:
- *
- * @param string $string1 First string
- * @param string $string2 Second string
- * @param string $compareCharacters true to compare characters, and false to compare lines; this optional parameter defaults to false
- * @return array Array of diff
- */
+ * whose values is an array containing two values: a line (or character, if
+ * $compareCharacters is true), and one of the constants DIFF::UNMODIFIED (the
+ * line or character is in both strings), DIFF::DELETED (the line or character
+ * is only in the first string), and DIFF::INSERTED (the line or character is
+ * only in the second string). The parameters are:
+ *
+ * @param string $string1 First string
+ * @param string $string2 Second string
+ * @param string $compareCharacters true to compare characters, and false to compare lines; this optional parameter defaults to false
+ * @return array Array of diff
+ */
public static function compare($string1, $string2, $compareCharacters = false)
{
// initialise the sequences and comparison start and end positions
@@ -89,12 +89,12 @@
/**
* Returns the diff for two files. The parameters are:
- *
- * @param string $file1 Path to the first file
- * @param string $file2 Path to the second file
- * @param boolean $compareCharacters true to compare characters, and false to compare lines; this optional parameter defaults to false
- * @return array Array of diff
- */
+ *
+ * @param string $file1 Path to the first file
+ * @param string $file2 Path to the second file
+ * @param boolean $compareCharacters true to compare characters, and false to compare lines; this optional parameter defaults to false
+ * @return array Array of diff
+ */
public static function compareFiles(
$file1,
$file2,
@@ -111,14 +111,14 @@
/**
* Returns the table of longest common subsequence lengths for the specified sequences. The parameters are:
- *
- * @param string $sequence1 the first sequence
- * @param string $sequence2 the second sequence
- * @param string $start the starting index
- * @param string $end1 the ending index for the first sequence
- * @param string $end2 the ending index for the second sequence
- * @return array array of diff
- */
+ *
+ * @param string $sequence1 the first sequence
+ * @param string $sequence2 the second sequence
+ * @param string $start the starting index
+ * @param string $end1 the ending index for the first sequence
+ * @param string $end2 the ending index for the second sequence
+ * @return array array of diff
+ */
private static function computeTable($sequence1, $sequence2, $start, $end1, $end2)
{
// determine the lengths to be compared
@@ -152,14 +152,14 @@
/**
* Returns the partial diff for the specificed sequences, in reverse order.
* The parameters are:
- *
- * @param string $table the table returned by the computeTable function
- * @param string $sequence1 the first sequence
- * @param string $sequence2 the second sequence
- * @param string $start the starting index
- * @return array array of diff
- */
- private static function generatePartialDiff($table, $sequence1, $sequence2, $start)
+ *
+ * @param string $table the table returned by the computeTable function
+ * @param string $sequence1 the first sequence
+ * @param string $sequence2 the second sequence
+ * @param string $start the starting index
+ * @return array array of diff
+ */
+ private static function generatePartialDiff($table, $sequence1, $sequence2, $start)
{
// initialise the diff
$diff = array();
@@ -197,13 +197,13 @@
/**
* Returns a diff as a string, where unmodified lines are prefixed by ' ',
- * deletions are prefixed by '- ', and insertions are prefixed by '+ '. The
- * parameters are:
- *
- * @param array $diff the diff array
- * @param string $separator the separator between lines; this optional parameter defaults to "\n"
- * @return string String
- */
+ * deletions are prefixed by '- ', and insertions are prefixed by '+ '. The
+ * parameters are:
+ *
+ * @param array $diff the diff array
+ * @param string $separator the separator between lines; this optional parameter defaults to "\n"
+ * @return string String
+ */
public static function toString($diff, $separator = "\n")
{
// initialise the string
@@ -234,13 +234,13 @@
/**
* Returns a diff as an HTML string, where unmodified lines are contained
- * within 'span' elements, deletions are contained within 'del' elements, and
- * insertions are contained within 'ins' elements. The parameters are:
- *
- * @param string $diff the diff array
- * @param string $separator the separator between lines; this optional parameter defaults to '
'
- * @return string HTML string
- */
+ * within 'span' elements, deletions are contained within 'del' elements, and
+ * insertions are contained within 'ins' elements. The parameters are:
+ *
+ * @param string $diff the diff array
+ * @param string $separator the separator between lines; this optional parameter defaults to '
'
+ * @return string HTML string
+ */
public static function toHTML($diff, $separator = '
')
{
// initialise the HTML
@@ -275,12 +275,12 @@
/**
* Returns a diff as an HTML table. The parameters are:
- *
- * @param string $diff the diff array
- * @param string $indentation indentation to add to every line of the generated HTML; this optional parameter defaults to ''
- * @param string $separator the separator between lines; this optional parameter defaults to '
'
- * @return string HTML string
- */
+ *
+ * @param string $diff the diff array
+ * @param string $indentation indentation to add to every line of the generated HTML; this optional parameter defaults to ''
+ * @param string $separator the separator between lines; this optional parameter defaults to '
'
+ * @return string HTML string
+ */
public static function toTable($diff, $indentation = '', $separator = '
')
{
// initialise the HTML
@@ -364,15 +364,15 @@
/**
* Returns the content of the cell, for use in the toTable function. The
- * parameters are:
- *
- * @param string $diff the diff array
- * @param string $indentation indentation to add to every line of the generated HTML
- * @param string $separator the separator between lines
- * @param string $index the current index, passes by reference
- * @param string $type the type of line
- * @return string HTML string
- */
+ * parameters are:
+ *
+ * @param string $diff the diff array
+ * @param string $indentation indentation to add to every line of the generated HTML
+ * @param string $separator the separator between lines
+ * @param string $index the current index, passes by reference
+ * @param string $type the type of line
+ * @return string HTML string
+ */
private static function getCellContent($diff, $indentation, $separator, &$index, $type)
{
// initialise the HTML