NEW Look and feel v8: Use a different picto for delete and unlink

This commit is contained in:
Laurent Destailleur 2018-03-18 19:13:42 +01:00
parent 7b71e29fa0
commit d4ae0395ed
22 changed files with 406 additions and 391 deletions

View File

@ -53,7 +53,7 @@ foreach($linkedObjectBlock as $key => $objectlink)
echo price($objectlink->amount);
} ?></td>
<td align="right"></td>
<td align="right"><a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_delete($langs->transnoentitiesnoconv("RemoveLink")); ?></a></td>
<td align="right"><a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a></td>
</tr>
<?php
}

View File

@ -63,7 +63,7 @@ foreach($linkedObjectBlock as $key => $objectlink)
echo price($objectlink->total_ht);
} ?></td>
<td align="right"><?php echo $objectlink->getLibStatut(3); ?></td>
<td align="right"><a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_delete($langs->transnoentitiesnoconv("RemoveLink")); ?></a></td>
<td align="right"><a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a></td>
</tr>
<?php
}

View File

@ -63,7 +63,7 @@ foreach($linkedObjectBlock as $key => $objectlink)
// For now, shipments must stay linked to order, so link is not deletable
if($object->element != 'shipping') {
?>
<a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_delete($langs->transnoentitiesnoconv("RemoveLink")); ?></a>
<a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a>
<?php
}
?>

View File

@ -67,7 +67,7 @@ foreach($linkedObjectBlock as $key => $objectlink)
}
} ?></td>
<td align="right"><?php echo $objectlink->getLibStatut(3); ?></td>
<td align="right"><a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_delete($langs->transnoentitiesnoconv("RemoveLink")); ?></a></td>
<td align="right"><a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a></td>
</tr>
<?php
}

View File

@ -62,7 +62,7 @@ foreach($linkedObjectBlock as $key => $objectlink)
print $objectlink->getLibStatut(3);
?>
</td>
<td align="right"><a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_delete($langs->transnoentitiesnoconv("RemoveLink")); ?></a></td>
<td align="right"><a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a></td>
</tr>
<?php
}

View File

@ -52,10 +52,10 @@ foreach($linkedObjectBlock as $key => $objectlink)
<td></td>
<td align="center"><?php echo dol_print_date($objectlink->date_contrat,'day'); ?></td>
<td align="right"><?php
// Price of contract is not shown by default because a contract is a list of service with
// Price of contract is not shown by default because a contract is a list of service with
// start and end date that change with time andd that may be different that the period of reference for price.
// So price of a contract does often means nothing. Prices is on the different invoices done on same contract.
if ($user->rights->contrat->lire && empty($conf->global->CONTRACT_SHOW_TOTAL_OF_PRODUCT_AS_PRICE))
if ($user->rights->contrat->lire && empty($conf->global->CONTRACT_SHOW_TOTAL_OF_PRODUCT_AS_PRICE))
{
$totalcontrat = 0;
foreach ($objectlink->lines as $linecontrat) {
@ -65,7 +65,7 @@ foreach($linkedObjectBlock as $key => $objectlink)
echo price($totalcontrat);
} ?></td>
<td align="right"><?php echo $objectlink->getLibStatut(7); ?></td>
<td align="right"><a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_delete($langs->transnoentitiesnoconv("RemoveLink")); ?></a></td>
<td align="right"><a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a></td>
</tr>
<?php } ?>

View File

@ -173,12 +173,12 @@ class FormTicketsup
print "</td></tr>\n";
}
// Customer
// Customer or supplier
if ($this->withcompany) {
// altairis: force company and contact id for external user
if (empty($user->socid)) {
// Company
print '<tr><td class="titlefield">' . $langs->trans("Customer") . '</td><td>';
print '<tr><td class="titlefield">' . $langs->trans("Thirdparty") . '</td><td>';
$events = array();
$events[] = array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php', 1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled'));
print $form->select_company($this->withfromsocid, 'socid', '', 1, 1, '', $events);
@ -242,7 +242,7 @@ class FormTicketsup
// If no socid, set to first one (id=1) to avoid full contacts list
$selectedCompany = $this->withfromsocid > 0 ? $this->withfromsocid : 1;
$nbofcontacts = $form->select_contacts($selectedCompany, $this->withfromcontactid, 'contactid', 0, '', '', 0, 'minwidth200');
$formcompany->selectTypeContact($ticketstatic, '', 'type', 'external');
$formcompany->selectTypeContact($ticketstatic, '', 'type', 'external', '', 0, 'maginleftonly');
print '</td></tr>';
} else {
print '<tr><td class="titlefield"><input type="hidden" name="socid" value="' . $user->socid . '"/></td>';
@ -296,9 +296,9 @@ class FormTicketsup
print $this->selectSeveritiesTickets((GETPOST('severity_code') ? GETPOST('severity_code') : $this->severity_code), 'severity_code', '', '2');
print '</td></tr>';
// Not notify tiers at create
print '<tr><td><label for="not_notify_tiers_at_create">' . $langs->trans("TicketNotNotifyTiersAtCreate") . '</label></td><td>';
print '<input type="checkbox" id="not_notify_tiers_at_create" name="not_notify_tiers_at_create"'.($this->withnotnotifytiersatcreate?' checked="checked"':'').'>';
// Notify thirdparty at creation
print '<tr><td><label for="not_notify_tiers_at_create">' . $langs->trans("TicketNotifyTiersAtCreation") . '</label></td><td>';
print '<input type="checkbox" id="not_notify_tiers_at_create" name="not_notify_tiers_at_create"'.($this->withnotnotifytiersatcreate?'':' checked="checked"').'>';
print '</td></tr>';
// TITLE

View File

@ -3063,7 +3063,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
$pictowithoutext = preg_replace('/(\.png|\.gif|\.svg)$/', '', $picto);
//if (in_array($picto, array('switch_off', 'switch_on', 'off', 'on')))
if (in_array($pictowithoutext, array('delete', 'edit', 'off', 'on', 'resize', 'switch_off', 'switch_on', 'uparrow')))
if (in_array($pictowithoutext, array('delete', 'edit', 'off', 'on', 'resize', 'switch_off', 'switch_on', 'unlink', 'uparrow')))
{
$fakey = $pictowithoutext; $facolor=''; $fasize='';
if ($pictowithoutext == 'switch_off') { $fakey = 'fa-toggle-off'; $facolor='#999'; $fasize='2em'; }
@ -3074,6 +3074,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
elseif ($pictowithoutext == 'edit') { $fakey = 'fa-pencil'; $facolor='#444'; }
elseif ($pictowithoutext == 'resize') { $fakey = 'fa-crop'; $facolor='#444'; }
elseif ($pictowithoutext == 'uparrow') { $fakey = 'fa-mail-forward'; $facolor='#555'; }
elseif ($pictowithoutext == 'unlink') { $fakey = 'fa-chain-broken'; $facolor='#555'; }
else { $fakey = 'fa-'.$pictowithoutext; $facolor='#999'; }
if (preg_match('/class="([^"]+)"/', $moreatt, $reg)) { $morecss.=($morecss?' ':'').$reg[1]; }

View File

@ -61,7 +61,7 @@ foreach($linkedObjectBlock as $key => $objectlink)
// For now, shipments must stay linked to order, so link is not deletable
if($object->element != 'commande') {
?>
<a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_delete($langs->transnoentitiesnoconv("RemoveLink")); ?></a></td>
<a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a></td>
<?php
}
?>

View File

@ -52,7 +52,7 @@ foreach($linkedObjectBlock as $key => $objectlink)
echo price($objectlink->total_ht);
} ?></td>
<td align="right"><?php echo $objectlink->getLibStatut(3); ?></td>
<td align="right"><a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_delete($langs->transnoentitiesnoconv("RemoveLink")); ?></a></td>
<td align="right"><a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a></td>
</tr>
<?php
}

View File

@ -51,7 +51,7 @@ foreach($linkedObjectBlock as $key => $objectlink)
<td align="center"><?php echo dol_print_date($objectlink->datev,'day'); ?></td>
<td></td>
<td align="right"><?php echo $objectlink->getLibStatut(3); ?></td>
<td align="right"><a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_delete($langs->transnoentitiesnoconv("RemoveLink")); ?></a></td>
<td align="right"><a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a></td>
</tr>
<?php
}

View File

@ -57,7 +57,7 @@ foreach($linkedObjectBlock as $key => $objectlink)
echo price($objectlink->total_ht);
} ?></td>
<td align="right"><?php echo $objectlink->getLibStatut(3); ?></td>
<td align="right"><a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_delete($langs->transnoentitiesnoconv("RemoveLink")); ?></a></td>
<td align="right"><a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a></td>
</tr>
<?php
}

View File

@ -68,7 +68,7 @@ foreach($linkedObjectBlock as $key => $objectlink)
}
} ?></td>
<td align="right"><?php echo $objectlink->getLibStatut(3); ?></td>
<td align="right"><a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_delete($langs->transnoentitiesnoconv("RemoveLink")); ?></a></td>
<td align="right"><a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a></td>
</tr>
<?php
}

View File

@ -44,8 +44,8 @@ TicketSeverityShortBLOCKING=Critical/Blocking
ErrorBadEmailAddress=Field '%s' incorrect
MenuTicketsupMyAssign=My tickets
MenuTicketsupMyAssignNonClosed=My tickets non closed
MenuListNonClosed=Non closed tickets
MenuTicketsupMyAssignNonClosed=My open tickets
MenuListNonClosed=Open tickets
TypeContact_ticketsup_internal_CONTRIBUTOR=Contributor
TypeContact_ticketsup_internal_SUPPORTTEC=Assigned user
@ -123,7 +123,7 @@ TicketsActivatePublicInterfaceHelp=Public interface allow any visitors to create
TicketsAutoAssignTicket=Automatically assign the user who created the ticket
TicketsAutoAssignTicketHelp=When creating a ticket, the user can be automatically assigned to the ticket.
TicketSupNumberingModules=Tickets numbering module
TicketNotNotifyTiersAtCreate=Do not notify the company to the creation
TicketNotifyTiersAtCreation=Notify thirdparty at creation
#
# About page
@ -143,8 +143,8 @@ TicketList=List of tickets
TicketAssignedToMeInfos=This page display ticket list which are assigned to current user
NoTicketsFound=No ticket found
TicketViewAllTickets=View all tickets
TicketViewNonClosedOnly=View only non closed tickets
TicketStatByStatus=Tickets par statut
TicketViewNonClosedOnly=View only open tickets
TicketStatByStatus=Tickets by status
#
# Ticket card
@ -224,7 +224,7 @@ TicketEmailOriginIssuer=Issuer at origin of the tickets
InitialMessage=Initial Message
LinkToAContract=Link to a contract
TicketSupPleaseSelectAContract=Select a contract
UnableToCreateInterIfNoSocid=Can not create a response file without defining a thirdparty
UnableToCreateInterIfNoSocid=Can not create an intervention when no third party are defined
TicketMailExchanges=Mail exchanges
TicketInitialMessageModified=Initial message modified
TicketMessageSuccesfullyUpdated=Message successfully updated

View File

@ -81,7 +81,7 @@ class MyObject extends CommonObject
'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20),
'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>30, 'searchall'=>1, 'css'=>'minwidth200', 'help'=>'Help text'),
'amount' =>array('type'=>'double(24,8)', 'label'=>'Amount', 'enabled'=>1, 'visible'=>1, 'default'=>'null', 'position'=>40, 'searchall'=>0, 'isameasure'=>1, 'help'=>'Help text'),
'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'),
'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>0, 'help'=>'LinkToThirparty'),
'description' =>array('type'=>'text', 'label'=>'Descrption', 'enabled'=>1, 'visible'=>0, 'position'=>60),
'note_public' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>61),
'note_private' =>array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>62),

View File

@ -55,7 +55,7 @@ foreach($linkedObjectBlock as $key => $objectlink)
echo price($objectlink->total_ht);
} ?></td>
<td align="right"><?php echo $objectlink->getLibStatut(3); ?></td>
<td align="right"><a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_delete($langs->transnoentitiesnoconv("RemoveLink")); ?></a></td>
<td align="right"><a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=dellink&dellinkid='.$key; ?>"><?php echo img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink'); ?></a></td>
</tr>
<?php
}

View File

@ -23,15 +23,15 @@
*/
require '../main.inc.php';
require_once 'class/actions_ticketsup.class.php';
require_once DOL_DOCUMENT_ROOT . '/ticketsup/class/actions_ticketsup.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formticketsup.class.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/ticketsup.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
if (!empty($conf->projet->enabled)) {
include DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
include_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formprojet.class.php';
include_once DOL_DOCUMENT_ROOT . '/core/lib/project.lib.php';
}
@ -41,30 +41,23 @@ if (!empty($conf->contrat->enabled)) {
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formcontract.class.php';
}
if (!class_exists('Contact')) {
include DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
}
// Load traductions files requiredby by page
$langs->load("companies");
$langs->load("other");
$langs->load("ticketsup");
$langs->loadLangs(array("companies","other","ticketsup"));
// Get parameters
$id = GETPOST('id', 'int');
$track_id = GETPOST('track_id', 'alpha', 3);
$action = GETPOST('action', 'alpha', 3);
$ref = GETPOST('ref', 'alpha');
$projectid = GETPOST('projectid', 'int');
$action = GETPOST('action', 'alpha', 3);
// Initialize technical object to manage hooks of ticketsup. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('ticketsupcard','globalcard'));
$object = new ActionsTicketsup($db);
$object->doActions($action);
$extrafields = new ExtraFields($db);
$extralabels = $extrafields->fetch_name_optionals_label($object->dao->table_element);
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$object = new Ticketsup($db);
if (!$action) {
$action = 'view';
@ -75,14 +68,14 @@ if (GETPOST('modelselected')) {
}
// Store current page url
$url_page_current = dol_buildpath('/ticketsup/card.php', 1);
$url_page_current = DOL_URL_ROOT.'/ticketsup/card.php';
if ($action == 'view' || $action == 'add_message' || $action == 'close' || $action == 'delete' || $action == 'editcustomer' || $action == 'progression' || $action == 'reopen' || $action == 'editsubject' || $action == 'edit_extrafields' || $action == 'set_extrafields' || $action == 'classify' || $action == 'sel_contract' || $action == 'edit_message_init' || $action == 'set_status' || $action == 'dellink') {
if ($id || $track_id || $ref) {
$res = $object->fetch($id, $track_id, $ref);
}
// Security check
$result = restrictedArea($user, 'ticketsup', $object->dao->id);
$result = restrictedArea($user, 'ticketsup', $object->id);
@ -90,6 +83,9 @@ $result = restrictedArea($user, 'ticketsup', $object->dao->id);
* Actions
*/
$actionobject = new ActionsTicketsup($db);
$actionobject->doActions($action, $object);
$permissiondellink = $user->rights->ticketsup->write;
include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once
@ -105,38 +101,38 @@ $form = new Form($db);
$formticket = new FormTicketsup($db);
if ($action == 'view' || $action == 'add_message' || $action == 'close' || $action == 'delete' || $action == 'editcustomer' || $action == 'progression' || $action == 'reopen' || $action == 'editsubject' || $action == 'edit_extrafields' || $action == 'set_extrafields' || $action == 'classify' || $action == 'sel_contract' || $action == 'edit_message_init' || $action == 'set_status' || $action == 'dellink') {
$res = $object->fetch($id, $track_id, $ref);
if ($res > 0) {
// or for unauthorized internals users
if (!$user->societe_id && ($conf->global->TICKETS_LIMIT_VIEW_ASSIGNED_ONLY && $object->dao->fk_user_assign != $user->id) && !$user->rights->ticketsup->manage) {
if (!$user->societe_id && ($conf->global->TICKETS_LIMIT_VIEW_ASSIGNED_ONLY && $object->fk_user_assign != $user->id) && !$user->rights->ticketsup->manage) {
accessforbidden('', 0);
}
$help_url = 'FR:DocumentationModuleTicket';
$page_title = $object->getTitle($action);
$page_title = $actionobject->getTitle($action);
llxHeader('', $page_title, $help_url);
// Confirmation close
if ($action == 'close') {
print $form->formconfirm($url_page_current . "?track_id=" . $track_id, $langs->trans("CloseATicket"), $langs->trans("ConfirmCloseAticket"), "confirm_close", '', '', 1);
print $form->formconfirm($url_page_current . "?track_id=" . $object->track_id, $langs->trans("CloseATicket"), $langs->trans("ConfirmCloseAticket"), "confirm_close", '', '', 1);
if ($ret == 'html') {
print '<br>';
}
}
// Confirmation delete
if ($action == 'delete') {
print $form->formconfirm($url_page_current . "?track_id=" . $track_id, $langs->trans("Delete"), $langs->trans("ConfirmDeleteTicket"), "confirm_delete_ticket", '', '', 1);
print $form->formconfirm($url_page_current . "?track_id=" . $object->track_id, $langs->trans("Delete"), $langs->trans("ConfirmDeleteTicket"), "confirm_delete_ticket", '', '', 1);
}
// Confirm reopen
if ($action == 'reopen') {
print $form->formconfirm($url_page_current . '?track_id=' . $track_id, $langs->trans('ReOpen'), $langs->trans('ConfirmReOpenTicket'), 'confirm_reopen', '', '', 1);
print $form->formconfirm($url_page_current . '?track_id=' . $object->track_id, $langs->trans('ReOpen'), $langs->trans('ConfirmReOpenTicket'), 'confirm_reopen', '', '', 1);
}
// Confirmation status change
if ($action == 'set_status') {
$new_status = GETPOST('new_status');
print $form->formconfirm($url_page_current . "?track_id=" . $track_id . "&new_status=" . GETPOST('new_status'), $langs->trans("TicketChangeStatus"), $langs->trans("TicketConfirmChangeStatus", $langs->transnoentities($object->dao->statuts_short[$new_status])), "confirm_set_status", '', '', 1);
//var_dump($url_page_current . "?track_id=" . $object->track_id);
print $form->formconfirm($url_page_current . "?track_id=" . $object->track_id . "&new_status=" . GETPOST('new_status'), $langs->trans("TicketChangeStatus"), $langs->trans("TicketConfirmChangeStatus", $langs->transnoentities($object->statuts_short[$new_status])), "confirm_set_status", '', '', 1);
}
// project info
@ -205,39 +201,39 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
print "ErrorRecordNotFound";
}
} elseif ($socid > 0) {
$object->dao->fetch_thirdparty();
$head = societe_prepare_head($object->dao->thirdparty);
$object->fetch_thirdparty();
$head = societe_prepare_head($object->thirdparty);
dol_fiche_head($head, 'ticketsup', $langs->trans("ThirdParty"), 0, 'company');
dol_banner_tab($object->dao->thirdparty, 'socid', '', ($user->societe_id ? 0 : 1), 'rowid', 'nom');
dol_banner_tab($object->thirdparty, 'socid', '', ($user->societe_id ? 0 : 1), 'rowid', 'nom');
dol_fiche_end();
}
if (!$user->societe_id && $conf->global->TICKETS_LIMIT_VIEW_ASSIGNED_ONLY) {
$object->dao->next_prev_filter = "te.fk_user_assign = '" . $user->id . "'";
$object->next_prev_filter = "te.fk_user_assign = '" . $user->id . "'";
} elseif ($user->societe_id > 0) {
$object->dao->next_prev_filter = "te.fk_soc = '" . $user->societe_id . "'";
$object->next_prev_filter = "te.fk_soc = '" . $user->societe_id . "'";
}
$head = ticketsup_prepare_head($object->dao);
$head = ticketsup_prepare_head($object);
dol_fiche_head($head, 'tabTicketsup', $langs->trans("Ticket"), -1, 'ticketsup');
$object->dao->label = $object->dao->ref;
$object->label = $object->ref;
// Author
if ($object->dao->fk_user_create > 0) {
$object->dao->label .= ' - ' . $langs->trans("CreatedBy") . ' ';
if ($object->fk_user_create > 0) {
$object->label .= ' - ' . $langs->trans("CreatedBy") . ' ';
$langs->load("users");
$fuser = new User($db);
$fuser->fetch($object->dao->fk_user_create);
$object->dao->label .= $fuser->getNomUrl(0);
$fuser->fetch($object->fk_user_create);
$object->label .= $fuser->getNomUrl(0);
}
if (!empty($object->dao->origin_email)) {
$object->dao->label .= ' - ' . $langs->trans("CreatedBy") . ' ';
$object->dao->label .= $object->dao->origin_email . ' <small>(' . $langs->trans("TicketEmailOriginIssuer") . ')</small>';
if (!empty($object->origin_email)) {
$object->label .= ' - ' . $langs->trans("CreatedBy") . ' ';
$object->label .= $object->origin_email . ' <small>(' . $langs->trans("TicketEmailOriginIssuer") . ')</small>';
}
$linkback = '<a href="' . dol_buildpath('/ticketsup/list.php', 1) . '"><strong>' . $langs->trans("BackToList") . '</strong></a> ';
$object->dao->ticketsupBannerTab('ref', '', ($user->societe_id ? 0 : 1), 'ref', 'subject', '', '', '', $morehtmlleft, $linkback);
$object->ticketsupBannerTab('ref', '', ($user->societe_id ? 0 : 1), 'ref', 'subject', '', '', '', $morehtmlleft, $linkback);
print '<div class="fichecenter"><div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
@ -245,12 +241,12 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
// Track ID
print '<tr><td class="titlefield">' . $langs->trans("TicketTrackId") . '</td><td>';
if (!empty($object->dao->track_id)) {
if (empty($object->dao->ref)) {
$object->ref = $object->dao->id;
if (!empty($object->track_id)) {
if (empty($object->ref)) {
$object->ref = $object->id;
print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'track_id');
} else {
print $object->dao->track_id;
print $object->track_id;
}
} else {
print $langs->trans('None');
@ -259,51 +255,51 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
// Subject
print '<tr><td>';
print $form->editfieldkey("Subject", 'subject', $object->dao->subject, $object->dao, $user->rights->ticketsup->write && !$user->societe_id, 'string');
print $form->editfieldkey("Subject", 'subject', $object->subject, $object, $user->rights->ticketsup->write && !$user->societe_id, 'string');
print '</td><td>';
print $form->editfieldval("Subject", 'subject', $object->dao->subject, $object->dao, $user->rights->ticketsup->write && !$user->societe_id, 'string');
print $form->editfieldval("Subject", 'subject', $object->subject, $object, $user->rights->ticketsup->write && !$user->societe_id, 'string');
print '</td></tr>';
// Creation date
print '<tr><td>' . $langs->trans("DateCreation") . '</td><td>';
print dol_print_date($object->dao->datec, 'dayhour');
print dol_print_date($object->datec, 'dayhour');
print '</td></tr>';
// Read date
if (!empty($object->dao->date_read)) {
if (!empty($object->date_read)) {
print '<tr><td>' . $langs->trans("TicketReadOn") . '</td><td>';
print dol_print_date($object->dao->date_read, 'dayhour');
print dol_print_date($object->date_read, 'dayhour');
print '</td></tr>';
print '<tr><td>' . $langs->trans("TicketTimeToRead") . '</td><td>';
print '<strong>' . convertSecondToTime($object->dao->date_read - $object->dao->datec) . '</strong>';
print '<strong>' . convertSecondToTime($object->date_read - $object->datec) . '</strong>';
print '</td></tr>';
}
// Close date
if (!empty($object->dao->date_close)) {
if (!empty($object->date_close)) {
print '<tr><td>' . $langs->trans("TicketCloseOn") . '</td><td>';
print dol_print_date($object->dao->date_close, 'dayhour');
print dol_print_date($object->date_close, 'dayhour');
print '</td></tr>';
}
print '</td></tr>';
// Customer
// Thirdparty
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('Customer');
print $langs->trans('ThirdParty');
print '</td>';
if ($action != 'editcustomer' && $object->dao->fk_statut < 8 && !$user->societe_id && $user->rights->ticketsup->write) {
print '<td align="right"><a href="' . $url_page_current . '?action=editcustomer&amp;track_id=' . $object->dao->track_id . '">' . img_edit($langs->transnoentitiesnoconv('Edit'), 1) . '</a></td>';
if ($action != 'editcustomer' && $object->fk_statut < 8 && !$user->societe_id && $user->rights->ticketsup->write) {
print '<td align="right"><a href="' . $url_page_current . '?action=editcustomer&amp;track_id=' . $object->track_id . '">' . img_edit($langs->transnoentitiesnoconv('Edit'), 1) . '</a></td>';
}
print '</tr></table>';
print '</td><td colspan="3">';
if ($action == 'editcustomer') {
$form->form_thirdparty($url_page_current . '?track_id=' . $object->dao->track_id, $object->dao->fk_soc, 'editcustomer', ($object->dao->fk_soc ? 's.rowid <> ' . $object->dao->fk_soc : ''), 1);
$form->form_thirdparty($url_page_current . '?track_id=' . $object->track_id, $object->fk_soc, 'editcustomer', ($object->fk_soc ? 's.rowid <> ' . $object->fk_soc : ''), 1);
} else {
$form->form_thirdparty($url_page_current . '?track_id=' . $object->dao->track_id, $object->dao->fk_soc, 'none', 's.rowid <> ' . $object->dao->fk_soc, 1);
$form->form_thirdparty($url_page_current . '?track_id=' . $object->track_id, $object->fk_soc, 'none', 's.rowid <> ' . $object->fk_soc, 1);
}
print '</td></tr>';
@ -315,41 +311,41 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
print $langs->trans('Project');
print '</td>';
if ($action != 'classify' && $user->rights->ticketsup->write) {
print '<td align="right"><a href="' . $url_page_current . '?action=classify&amp;track_id=' . $object->dao->track_id . '">' . img_edit($langs->trans('SetProject')) . '</a></td>';
print '<td align="right"><a href="' . $url_page_current . '?action=classify&amp;track_id=' . $object->track_id . '">' . img_edit($langs->trans('SetProject')) . '</a></td>';
}
print '</tr></table>';
print '</td><td colspan="3">';
if ($action == 'classify') {
$form->form_project($url_page_current . '?track_id=' . $object->dao->track_id, $object->dao->socid, $object->dao->fk_project, 'projectid');
$form->form_project($url_page_current . '?track_id=' . $object->track_id, $object->socid, $object->fk_project, 'projectid');
} else {
$form->form_project($url_page_current . '?track_id=' . $object->dao->track_id, $object->dao->socid, $object->dao->fk_project, 'none');
$form->form_project($url_page_current . '?track_id=' . $object->track_id, $object->socid, $object->fk_project, 'none');
}
print '</td></tr>';
}
// User assigned
print '<tr><td>' . $langs->trans("UserAssignedTo") . '</td><td>';
if ($object->dao->fk_user_assign > 0) {
$userstat->fetch($object->dao->fk_user_assign);
if ($object->fk_user_assign > 0) {
$userstat->fetch($object->fk_user_assign);
print $userstat->getNomUrl(1);
} else {
print $langs->trans('None');
}
// Show user list to assignate one if status is "read"
if (GETPOST('set') == "assign_ticket" && $object->dao->fk_statut < 8 && !$user->societe_id && $user->rights->ticketsup->write) {
if (GETPOST('set') == "assign_ticket" && $object->fk_statut < 8 && !$user->societe_id && $user->rights->ticketsup->write) {
print '<form method="post" name="ticketsup" enctype="multipart/form-data" action="' . $url_page_current . '">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="assign_user">';
print '<input type="hidden" name="track_id" value="' . $object->dao->track_id . '">';
print '<input type="hidden" name="track_id" value="' . $object->track_id . '">';
print '<label for="fk_user_assign">' . $langs->trans("AssignUser") . '</label> ';
print $form->select_dolusers($user->id, 'fk_user_assign', 0);
print ' <input class="button" type="submit" name="btn_assign_user" value="' . $langs->trans("Validate") . '" />';
print '</form>';
}
if ($object->dao->fk_statut < 8 && GETPOST('set') != "assign_ticket" && $user->rights->ticketsup->manage) {
print '<a href="' . $url_page_current . '?track_id=' . $object->dao->track_id . '&action=view&set=assign_ticket">' . img_picto('', 'edit') . ' ' . $langs->trans('Modify') . '</a>';
if ($object->fk_statut < 8 && GETPOST('set') != "assign_ticket" && $user->rights->ticketsup->manage) {
print '<a href="' . $url_page_current . '?track_id=' . $object->track_id . '&action=view&set=assign_ticket">' . img_picto('', 'edit') . ' ' . $langs->trans('Modify') . '</a>';
}
print '</td></tr>';
@ -358,8 +354,8 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
print '<table class="nobordernopadding" width="100%"><tr><td class="nowrap">';
print $langs->trans('Progression') . '</td><td align="left">';
print '</td>';
if ($action != 'progression' && $object->dao->fk_statut < 8 && !$user->societe_id) {
print '<td align="right"><a href="' . $url_page_current . '?action=progression&amp;track_id=' . $object->dao->track_id . '">' . img_edit($langs->trans('Modify')) . '</a></td>';
if ($action != 'progression' && $object->fk_statut < 8 && !$user->societe_id) {
print '<td align="right"><a href="' . $url_page_current . '?action=progression&amp;track_id=' . $object->track_id . '">' . img_edit($langs->trans('Modify')) . '</a></td>';
}
print '</tr></table>';
print '</td><td colspan="5">';
@ -368,21 +364,21 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="track_id" value="' . $track_id . '">';
print '<input type="hidden" name="action" value="set_progression">';
print '<input type="text" class="flat" size="20" name="progress" value="' . $object->dao->progress . '">';
print '<input type="text" class="flat" size="20" name="progress" value="' . $object->progress . '">';
print ' <input type="submit" class="button" value="' . $langs->trans('Modify') . '">';
print '</form>';
} else {
print($object->dao->progress > 0 ? $object->dao->progress : '0') . '%';
print($object->progress > 0 ? $object->progress : '0') . '%';
}
print '</td>';
print '</tr>';
// Timing (Duration sum of linked fichinter
$object->dao->fetchObjectLinked();
$num = count($object->dao->linkedObjects);
$object->fetchObjectLinked();
$num = count($object->linkedObjects);
$timing = 0;
if ($num) {
foreach ($object->dao->linkedObjects as $objecttype => $objects) {
foreach ($object->linkedObjects as $objecttype => $objects) {
if ($objecttype = "fichinter") {
foreach ($objects as $fichinter) {
$timing += $fichinter->duration;
@ -404,28 +400,28 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
print '<form method="post" name="form_edit_extrafields" enctype="multipart/form-data" action="' . $url_page_current . '">';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="set_extrafields">';
print '<input type="hidden" name="track_id" value="' . $object->dao->track_id . '">';
print '<input type="hidden" name="track_id" value="' . $object->track_id . '">';
print $object->dao->showOptionals($extrafields, 'edit');
print $object->showOptionals($extrafields, 'edit');
print '<tr><td colspan="2" align="center">';
print ' <input class="button" type="submit" name="btn_edit_extrafields" value="' . $langs->trans("Modify") . '" />';
print ' <input class="button" type="submit" name="cancel" value="' . $langs->trans("Cancel") . '" />';
print '</tr>';
print '</form>';
} else {
print $object->dao->showOptionals($extrafields);
print $object->showOptionals($extrafields);
if ($user->rights->ticketsup->write) {
print '<tr><td colspan="2" align="center">';
print '<a href="' . $url_page_current . '?track_id=' . $object->dao->track_id . '&action=edit_extrafields">' . img_picto('', 'edit') . ' ' . $langs->trans('Edit') . '</a>';
print '<a href="' . $url_page_current . '?track_id=' . $object->track_id . '&action=edit_extrafields">' . img_picto('', 'edit') . ' ' . $langs->trans('Edit') . '</a>';
print '</tr>';
}
}
}
print '</table>';
// View Original message
$object->viewTicketOriginalMessage($user, $action);
// View Original message
$actionobject->viewTicketOriginalMessage($user, $action);
// Fin colonne gauche et début colonne droite
@ -481,7 +477,7 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
print '<td width="40%">';
print '<label for="type_code">' . $langs->trans($property['label']) . '</label> ';
print '</td><td width="50%">';
print $formticket->{$property['list_function']}($object->dao->type_code, 'update_value', '', 0);
print $formticket->{$property['list_function']}($object->type_code, 'update_value', '', 0);
print '</td><td>';
print ' <input class="button" type="submit" name="btn_update_ticket_prop" value="' . $langs->trans("Modify") . '" />';
print '</td>';
@ -494,7 +490,7 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
} else {
// Type
print '<tr><td width="40%">' . $langs->trans("Type") . '</td><td>';
print $object->dao->type_label;
print $object->type_label;
if ($user->admin && !$noadmininfo) {
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
}
@ -503,7 +499,7 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
// Category
print '<tr><td>' . $langs->trans("Category") . '</td><td>';
print $object->dao->category_label;
print $object->category_label;
if ($user->admin && !$noadmininfo) {
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
}
@ -512,7 +508,7 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
// Severity
print '<tr><td>' . $langs->trans("TicketSeverity") . '</td><td>';
print $object->dao->severity_label;
print $object->severity_label;
if ($user->admin && !$noadmininfo) {
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
}
@ -522,14 +518,16 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
print '</table>'; // End table actions
// Display navbar with links to change ticket status
if (!$user->societe_id && $user->rights->ticketsup->write && $object->dao->fk_status < 8 && GETPOST('set') !== 'properties') {
$object->viewStatusActions();
print '<!-- navbar with status -->';
if (!$user->societe_id && $user->rights->ticketsup->write && $object->fk_status < 8 && GETPOST('set') !== 'properties') {
$actionobject->viewStatusActions($object);
}
print load_fiche_titre($langs->trans('Contacts'), '', 'title_companies.png');
print '<div class="div-table-responsive-no-min">';
print '<div class="tagtable centpercent noborder allwidth">';
print '<div class="tagtr liste_titre">';
print '<div class="tagtd ">' . $langs->trans("Source") . '</div>
@ -545,7 +543,7 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
$contactstatic = new Contact($db);
$userstatic = new User($db);
foreach (array('internal', 'external') as $source) {
$tmpobject = $object->dao;
$tmpobject = $object;
$tab = $tmpobject->listeContact(-1, $source);
$num = count($tab);
$i = 0;
@ -607,7 +605,7 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
print '<div class="tagtd" align="center">';
if ($object->statut >= 0) {
echo '<a href="contact.php?track_id=' . $object->dao->track_id . '&amp;action=swapstatut&amp;ligne=' . $tab[$i]['rowid'] . '">';
echo '<a href="contact.php?track_id=' . $object->track_id . '&amp;action=swapstatut&amp;ligne=' . $tab[$i]['rowid'] . '">';
}
if ($tab[$i]['source'] == 'internal') {
@ -635,6 +633,7 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
}
print '</div><!-- contact list -->';
print '</div>';
// Contract
if ($action == 'sel_contract') {
@ -644,8 +643,8 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
$form_contract = new FormContract($db);
$form_contract->formSelectContract(
$url_page_current.'?track_id='.$object->dao->track_id,
$object->dao->fk_soc,
$url_page_current.'?track_id='.$object->track_id,
$object->fk_soc,
GETPOST('contractid'),
'contractid'
);
@ -657,53 +656,47 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
print dol_fiche_end();
/* ActionBar */
print '<div class="tabsAction">';
// Show button to mark as read
if (($object->dao->fk_statut == '0' || empty($object->dao->date_read)) && !$user->societe_id) {
print '<div class="inline-block divButAction">';
print '<a class="butAction" href="card.php?track_id=' . $object->dao->track_id . '&action=mark_ticket_read">' . img_picto('', 'mark-read@ticketsup', 'height="12px"') . ' ' . $langs->trans('MarkAsRead') . '</a>';
print '</div';
}
// Show link to add a message (if read and not closed)
if ($object->dao->fk_statut < 8 && $action != "add_message") {
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?track_id=' . $object->dao->track_id . '&action=add_message">' . $langs->trans('TicketAddMessage') . '</a></div>';
if ($object->fk_statut < 8 && $action != "add_message") {
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?track_id=' . $object->track_id . '&action=add_message">' . $langs->trans('TicketAddMessage') . '</a></div>';
}
// Link to create an intervention
// socid is needed otherwise fichinter ask it and forgot origin after form submit :\
if (!$object->dao->fk_soc && $user->rights->ficheinter->creer) {
if (!$object->fk_soc && $user->rights->ficheinter->creer) {
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="' . $langs->trans('UnableToCreateInterIfNoSocid') . '">' . $langs->trans('TicketAddIntervention') . '</a></div>';
}
if ($object->dao->fk_soc > 0 && $object->dao->fk_statut < 8 && $user->rights->ficheinter->creer) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . dol_buildpath('/fichinter/card.php', 1) . '?action=create&socid=' . $object->dao->fk_soc . '&origin=ticketsup_ticketsup&originid=' . $object->dao->id . '">' . $langs->trans('TicketAddIntervention') . '</a></div>';
if ($object->fk_soc > 0 && $object->fk_statut < 8 && $user->rights->ficheinter->creer) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . dol_buildpath('/fichinter/card.php', 1) . '?action=create&socid=' . $object->fk_soc . '&origin=ticketsup_ticketsup&originid=' . $object->id . '">' . $langs->trans('TicketAddIntervention') . '</a></div>';
}
// Button to edit Properties
if ($object->dao->fk_statut < 5 && $user->rights->ticketsup->write) {
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?track_id=' . $object->dao->track_id . '&action=view&set=properties">' . $langs->trans('TicketEditProperties') . '</a></div>';
if ($object->fk_statut < 5 && $user->rights->ticketsup->write) {
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?track_id=' . $object->track_id . '&action=view&set=properties">' . $langs->trans('TicketEditProperties') . '</a></div>';
}
// Button to link to a contract
if ($user->rights->ticketsup->write && $object->dao->fk_statut < 5 && $user->rights->contrat->creer) {
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?track_id=' . $object->dao->track_id . '&action=sel_contract">' . $langs->trans('LinkToAContract') . '</a></div>';
if ($user->rights->ticketsup->write && $object->fk_statut < 5 && $user->rights->contrat->creer) {
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?track_id=' . $object->track_id . '&action=sel_contract">' . $langs->trans('LinkToAContract') . '</a></div>';
}
// Close ticket if statut is read
if ($object->dao->fk_statut > 0 && $object->dao->fk_statut < 8 && $user->rights->ticketsup->write) {
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?track_id=' . $object->dao->track_id . '&action=close">' . $langs->trans('CloseTicket') . '</a></div>';
if ($object->fk_statut > 0 && $object->fk_statut < 8 && $user->rights->ticketsup->write) {
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?track_id=' . $object->track_id . '&action=close">' . $langs->trans('CloseTicket') . '</a></div>';
}
// Re-open ticket
if (!$user->socid && $object->dao->fk_statut == 8 && !$user->societe_id) {
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?track_id=' . $object->dao->track_id . '&action=reopen">' . $langs->trans('ReOpen') . '</a></div>';
if (!$user->socid && $object->fk_statut == 8 && !$user->societe_id) {
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?track_id=' . $object->track_id . '&action=reopen">' . $langs->trans('ReOpen') . '</a></div>';
}
// Delete ticket
if ($user->rights->ticketsup->delete && !$user->societe_id) {
print '<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?track_id=' . $object->dao->track_id . '&action=delete">' . $langs->trans('Delete') . '</a></div>';
print '<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?track_id=' . $object->track_id . '&action=delete">' . $langs->trans('Delete') . '</a></div>';
}
print '</div>';
@ -715,7 +708,7 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
// Message list
print load_fiche_titre($langs->trans('TicketMessagesList'), '', 'messages@ticketsup');
$show_private_message = ($user->societe_id ? 0 : 1);
$object->viewTicketTimelineMessages($show_private_message);
$actionobject->viewTicketTimelineMessages($show_private_message, true, $object);
print '</div><!-- fichehalfleft --> ';
@ -741,8 +734,8 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
$formticket = new FormTicketsup($db);
$formticket->action = $action;
$formticket->track_id = $object->dao->track_id;
$formticket->id = $object->dao->id;
$formticket->track_id = $object->track_id;
$formticket->id = $object->id;
$formticket->withfile = 2;
$formticket->param = array('fk_user_create' => $user->id);
@ -751,32 +744,32 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
// Tableau des parametres complementaires du post
$formticket->param['models']=$modelmail;
$formticket->param['models_id']=GETPOST('modelmailselected', 'int');
//$formticket->param['socid']=$object->dao->fk_soc;
$formticket->param['returnurl']=$_SERVER["PHP_SELF"].'?track_id='.$object->dao->track_id;
//$formticket->param['socid']=$object->fk_soc;
$formticket->param['returnurl']=$_SERVER["PHP_SELF"].'?track_id='.$object->track_id;
$formticket->withsubstit = 1;
if ($object->dao->fk_soc > 0) {
$object->dao->fetch_thirdparty();
$formticket->substit['__THIRDPARTY_NAME__'] = $object->dao->thirdparty->name;
if ($object->fk_soc > 0) {
$object->fetch_thirdparty();
$formticket->substit['__THIRDPARTY_NAME__'] = $object->thirdparty->name;
}
$formticket->substit['__SIGNATURE__'] = $user->signature;
$formticket->substit['__TICKETSUP_TRACKID__'] = $object->dao->track_id;
$formticket->substit['__TICKETSUP_REF__'] = $object->dao->ref;
$formticket->substit['__TICKETSUP_SUBJECT__'] = $object->dao->subject;
$formticket->substit['__TICKETSUP_TYPE__'] = $object->dao->type_code;
$formticket->substit['__TICKETSUP_CATEGORY__'] = $object->dao->category_code;
$formticket->substit['__TICKETSUP_SEVERITY__'] = $object->dao->severity_code;
$formticket->substit['__TICKETSUP_MESSAGE__'] = $object->dao->message;
$formticket->substit['__TICKETSUP_PROGRESSION__'] = $object->dao->progress;
if ($object->dao->fk_user_assign > 0) {
$userstat->fetch($object->dao->fk_user_assign);
$formticket->substit['__TICKETSUP_TRACKID__'] = $object->track_id;
$formticket->substit['__TICKETSUP_REF__'] = $object->ref;
$formticket->substit['__TICKETSUP_SUBJECT__'] = $object->subject;
$formticket->substit['__TICKETSUP_TYPE__'] = $object->type_code;
$formticket->substit['__TICKETSUP_CATEGORY__'] = $object->category_code;
$formticket->substit['__TICKETSUP_SEVERITY__'] = $object->severity_code;
$formticket->substit['__TICKETSUP_MESSAGE__'] = $object->message;
$formticket->substit['__TICKETSUP_PROGRESSION__'] = $object->progress;
if ($object->fk_user_assign > 0) {
$userstat->fetch($object->fk_user_assign);
$formticket->substit['__TICKETSUP_USER_ASSIGN__'] = dolGetFirstLastname($userstat->firstname, $userstat->lastname);
}
if ($object->dao->fk_user_create > 0) {
$userstat->fetch($object->dao->fk_user_create);
if ($object->fk_user_create > 0) {
$userstat->fetch($object->fk_user_create);
$formticket->substit['__TICKETSUP_USER_CREATE__'] = dolGetFirstLastname($userstat->firstname, $userstat->lastname);
}
@ -792,7 +785,7 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
*
* Put here code to view linked object
****************************************************/
$somethingshown = $form->showLinkedObjectBlock($object->dao);
$somethingshown = $form->showLinkedObjectBlock($object);
// End of page
llxFooter('');

View File

@ -79,21 +79,20 @@ class ActionsTicketsup
* doActions
*
* @param string $action Action type
* @param Ticketsup $object Object Ticketsup
* @return int 0
*/
public function doActions(&$action = '')
public function doActions(&$action = '', Ticketsup $object=null)
{
global $conf, $user, $langs, $mysoc;
$this->getInstanceDao();
/*
* Add file in email form
*/
if (GETPOST('addfile')) {
// altairis : allow files from public interface
if (GETPOST('track_id')) {
$res = $this->dao->fetch('', GETPOST('track_id','alpha'));
$res = $object->fetch('', GETPOST('track_id','alpha'));
}
////if($res > 0)
@ -101,13 +100,13 @@ class ActionsTicketsup
include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
// Set tmp directory TODO Use a dedicated directory for temp mails files
$vardir = $conf->ticketsup->dir_output . (!empty($this->dao->track_id) ? '/' . dol_sanitizeFileName($this->dao->track_id) : '');
$vardir = $conf->ticketsup->dir_output . (!empty($object->track_id) ? '/' . dol_sanitizeFileName($object->track_id) : '');
$upload_dir_tmp = $vardir . '/temp';
if (!dol_is_dir($upload_dir_tmp)) {
dol_mkdir($upload_dir_tmp);
}
dol_add_file_process($upload_dir_tmp, 0, 0, 'addedfile', dol_print_date(dol_now(), '%Y%m%d%H%M%S') . '-__file__');
$action = !empty($this->dao->track_id) ? 'add_message' : 'create_ticket';
$action = !empty($object->track_id) ? 'add_message' : 'create_ticket';
////}
}
@ -117,7 +116,7 @@ class ActionsTicketsup
if (GETPOST('removedfile')) {
// altairis : allow files from public interface
if (GETPOST('track_id')) {
$res = $this->dao->fetch('', GETPOST('track_id'));
$res = $object->fetch('', GETPOST('track_id'));
}
////if($res > 0)
@ -125,12 +124,12 @@ class ActionsTicketsup
include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
// Set tmp directory
$vardir = $conf->ticketsup->dir_output . (!empty($this->dao->track_id) ? '/' . dol_sanitizeFileName($this->dao->track_id) : '');
$vardir = $conf->ticketsup->dir_output . (!empty($object->track_id) ? '/' . dol_sanitizeFileName($object->track_id) : '');
$upload_dir_tmp = $vardir . '/temp';
// TODO Delete only files that was uploaded from email form
dol_remove_file_process($_POST['removedfile'], 0);
$action = !empty($this->dao->track_id) ? 'add_message' : 'create_ticket';
$action = !empty($object->track_id) ? 'add_message' : 'create_ticket';
////}
}
@ -150,28 +149,28 @@ class ActionsTicketsup
if (!$error) {
$this->db->begin();
$this->dao->track_id = generate_random_id(16);
$object->track_id = generate_random_id(16);
$this->dao->ref = GETPOST("ref", 'alpha');
$this->dao->fk_soc = GETPOST("socid", 'int');
$this->dao->subject = GETPOST("subject", 'alpha');
$this->dao->message = GETPOST("message");
$object->ref = GETPOST("ref", 'alpha');
$object->fk_soc = GETPOST("socid", 'int');
$object->subject = GETPOST("subject", 'alpha');
$object->message = GETPOST("message");
$this->dao->type_code = GETPOST("type_code", 'alpha');
$this->dao->category_code = GETPOST("category_code", 'alpha');
$this->dao->severity_code = GETPOST("severity_code", 'alpha');
$object->type_code = GETPOST("type_code", 'alpha');
$object->category_code = GETPOST("category_code", 'alpha');
$object->severity_code = GETPOST("severity_code", 'alpha');
$notNotifyTiers = GETPOST("not_notify_tiers_at_create", 'alpha');
$this->dao->notify_tiers_at_create = empty($notNotifyTiers) ? 1 : 0;
$object->notify_tiers_at_create = empty($notNotifyTiers) ? 1 : 0;
$extrafields = new ExtraFields($this->db);
$extralabels = $extrafields->fetch_name_optionals_label($this->dao->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $this->dao);
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
$id = $this->dao->create($user);
$id = $object->create($user);
if ($id <= 0) {
$error++;
$this->error = $this->dao->error;
$this->errors = $this->dao->errors;
$this->error = $object->error;
$this->errors = $object->errors;
$action = 'create_ticket';
}
@ -186,31 +185,31 @@ class ActionsTicketsup
$type_contact = GETPOST("type", 'alpha');
if ($contactid > 0 && $type_contact) {
$result = $this->dao->add_contact($contactid, GETPOST("type"), 'external');
$result = $object->add_contact($contactid, GETPOST("type"), 'external');
}
// altairis: link ticket to project
if (GETPOST('projectid')) {
$this->dao->setProject(GETPOST('projectid'));
$object->setProject(GETPOST('projectid'));
}
// Auto assign user
if ($conf->global->TICKETS_AUTO_ASSIGN_USER_CREATE) {
$result = $this->dao->assignUser($user, $user->id, 1);
$this->dao->add_contact($user->id, "SUPPORTTEC", 'internal');
$result = $object->assignUser($user, $user->id, 1);
$object->add_contact($user->id, "SUPPORTTEC", 'internal');
}
// Auto assign contrat
$contractid = 0;
if ($conf->global->TICKETS_AUTO_ASSIGN_CONTRACT_CREATE) {
$contrat = new Contrat($this->db);
$contrat->socid = $this->dao->fk_soc;
$contrat->socid = $object->fk_soc;
$list = $contrat->getListOfContracts();
if (is_array($list) && !empty($list)) {
if (count($list) == 1) {
$contractid = $list[0]->id;
$this->dao->setContract($contractid);
$object->setContract($contractid);
} else {
}
}
@ -219,13 +218,13 @@ class ActionsTicketsup
// Auto create fiche intervention
if ($conf->global->TICKETS_AUTO_CREATE_FICHINTER_CREATE) {
$fichinter = new Fichinter($this->db);
$fichinter->socid = $this->dao->fk_soc;
$fichinter->socid = $object->fk_soc;
$fichinter->fk_project = GETPOST('projectid', 'int');
$fichinter->fk_contrat = $contractid;
$fichinter->author = $user->id;
$fichinter->modelpdf = 'soleil';
$fichinter->origin = $this->dao->element;
$fichinter->origin_id = $this->dao->id;
$fichinter->origin = $object->element;
$fichinter->origin_id = $object->id;
// Extrafields
$extrafields = new ExtraFields($this->db);
@ -242,7 +241,7 @@ class ActionsTicketsup
if (!empty($backtopage)) {
$url = $backtopage;
} else {
$url = 'card.php?track_id=' . $this->dao->track_id;
$url = 'card.php?track_id=' . $object->track_id;
}
header("Location: " . $url);
@ -259,7 +258,7 @@ class ActionsTicketsup
if ($action == 'edit' && $user->rights->ticketsup->write) {
$error = 0;
if ($this->dao->fetch(GETPOST('id')) < 0) {
if ($object->fetch(GETPOST('id')) < 0) {
$error++;
array_push($this->errors, $langs->trans("ErrorTicketIsNotValid"));
$_GET["action"] = $_POST["action"] = '';
@ -269,7 +268,7 @@ class ActionsTicketsup
if (GETPOST('update') && GETPOST('id') && $user->rights->ticketsup->write) {
$error = 0;
$ret = $this->dao->fetch(GETPOST('id'));
$ret = $object->fetch(GETPOST('id'));
if ($ret < 0) {
$error++;
array_push($this->errors, $langs->trans("ErrorTicketIsNotValid"));
@ -287,15 +286,15 @@ class ActionsTicketsup
if (!$error) {
$this->db->begin();
$this->dao->label = GETPOST("label");
$this->dao->description = GETPOST("description");
$object->label = GETPOST("label");
$object->description = GETPOST("description");
//...
$ret = $this->dao->update(GETPOST('id'), $user);
$ret = $object->update(GETPOST('id'), $user);
if ($ret <= 0) {
$error++;
$this->errors = $this->dao->error;
$this->errors = $this->dao->errors;
$this->errors = $object->error;
$this->errors = $object->errors;
$action = 'edit';
}
@ -308,29 +307,29 @@ class ActionsTicketsup
}
if ($action == "mark_ticket_read" && $user->rights->ticketsup->write) {
$this->dao->fetch('', GETPOST("track_id"));
$object->fetch('', GETPOST("track_id"));
if ($this->dao->markAsRead($user) > 0) {
if ($object->markAsRead($user) > 0) {
// Log action in ticket logs table
$log_action = $langs->trans('TicketLogMesgReadBy', $user->getFullName($langs));
$ret = $this->dao->createTicketLog($user, $log_action);
$ret = $object->createTicketLog($user, $log_action);
if ($ret > 0) {
setEventMessages($langs->trans('TicketMarkedAsRead'), null, 'mesgs');
} else {
setEventMessages($langs->trans('TicketMarkedAsReadButLogActionNotSaved'), null, 'errors');
}
header("Location: card.php?track_id=" . $this->dao->track_id . "&action=view");
header("Location: card.php?track_id=" . $object->track_id . "&action=view");
exit;
} else {
array_push($this->errors, $this->dao->error);
array_push($this->errors, $object->error);
}
$action = 'view';
}
if ($action == "assign_user" && GETPOST('btn_assign_user') && $user->rights->ticketsup->write) {
$this->dao->fetch('', GETPOST("track_id"));
$object->fetch('', GETPOST("track_id"));
$useroriginassign = $this->dao->fk_user_assign;
$useroriginassign = $object->fk_user_assign;
$usertoassign = GETPOST('fk_user_assign');
if (!$usertoassign) {
$error++;
@ -339,38 +338,38 @@ class ActionsTicketsup
}
if (!$error) {
$ret = $this->dao->assignUser($user, $usertoassign);
$ret = $object->assignUser($user, $usertoassign);
if ($ret) {
// Si déjà un user assigné on le supprime des contacts
if ($useroriginassign > 0) {
$internal_contacts = $this->dao->listeContact(-1, 'internal');
$internal_contacts = $object->listeContact(-1, 'internal');
foreach ($internal_contacts as $key => $contact) {
if ($contact['code'] == "SUPPORTTEC" && $contact['id'] == $useroriginassign) {
}
{
//print "user à effacer : ".$useroriginassign;
$this->dao->delete_contact($contact['rowid']);
$object->delete_contact($contact['rowid']);
}
}
}
$this->dao->add_contact($usertoassign, "SUPPORTTEC", 'internal', $notrigger = 0);
$object->add_contact($usertoassign, "SUPPORTTEC", 'internal', $notrigger = 0);
}
// Log action in ticket logs table
$this->dao->fetch_user($usertoassign);
$log_action = $langs->trans('TicketLogAssignedTo', $this->dao->user->getFullName($langs));
$ret = $this->dao->createTicketLog($user, $log_action);
$object->fetch_user($usertoassign);
$log_action = $langs->trans('TicketLogAssignedTo', $object->user->getFullName($langs));
$ret = $object->createTicketLog($user, $log_action);
if ($ret > 0) {
setEventMessages($langs->trans('TicketAssigned'), null, 'mesgs');
} else {
setEventMessages($langs->trans('TicketAssignedButLogActionNotSaved'), null, 'errors');
}
header("Location: card.php?track_id=" . $this->dao->track_id . "&action=view");
header("Location: card.php?track_id=" . $object->track_id . "&action=view");
exit;
} else {
array_push($this->errors, $this->dao->error);
array_push($this->errors, $object->error);
}
$action = 'view';
}
@ -381,18 +380,18 @@ class ActionsTicketsup
$fieldtomodify = GETPOST('property') . '_code';
$fieldtomodify_label = GETPOST('property') . '_label';
$oldvalue_code = $this->dao->$fieldtomodify;
$newvalue_code = $this->dao->getValueFrom('c_ticketsup_' . GETPOST('property'), GETPOST('update_value'), 'code');
$oldvalue_code = $object->$fieldtomodify;
$newvalue_code = $object->getValueFrom('c_ticketsup_' . GETPOST('property'), GETPOST('update_value'), 'code');
$oldvalue_label = $this->dao->$fieldtomodify_label;
$newvalue_label = $this->dao->getValueFrom('c_ticketsup_' . GETPOST('property'), GETPOST('update_value'), 'label');
$oldvalue_label = $object->$fieldtomodify_label;
$newvalue_label = $object->getValueFrom('c_ticketsup_' . GETPOST('property'), GETPOST('update_value'), 'label');
$this->dao->$fieldtomodify = $newvalue_code;
$object->$fieldtomodify = $newvalue_code;
$ret = $this->dao->update($user);
$ret = $object->update($user);
if ($ret > 0) {
$log_action = $langs->trans('TicketLogPropertyChanged', $oldvalue_label, $newvalue_label);
$ret = $this->dao->createTicketLog($user, $log_action);
$ret = $object->createTicketLog($user, $log_action);
if ($ret > 0) {
setEventMessages($langs->trans('TicketUpdated'), null, 'mesgs');
}
@ -406,13 +405,13 @@ class ActionsTicketsup
if (!empty($backtopage)) {
$url = $backtopage;
} else {
$url = 'card.php?action=view&track_id=' . $this->dao->track_id;
$url = 'card.php?action=view&track_id=' . $object->track_id;
}
header("Location: " . $url);
exit;
} else {
setEventMessages($this->dao->error, null, 'errors');
setEventMessages($object->error, null, 'errors');
$action = 'add_message';
}
}
@ -423,10 +422,10 @@ class ActionsTicketsup
if ($action == "confirm_close" && GETPOST('confirm', 'alpha') == 'yes' && $user->rights->ticketsup->write) {
$this->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha'));
if ($this->dao->close()) {
if ($object->close()) {
// Log action in ticket logs table
$log_action = $langs->trans('TicketLogClosedBy', $user->getFullName($langs));
$ret = $this->dao->createTicketLog($user, $log_action);
$ret = $object->createTicketLog($user, $log_action);
if ($ret > 0) {
setEventMessages('<div class="confirm">' . $langs->trans('TicketMarkedAsClosed') . '</div>');
} else {
@ -442,10 +441,10 @@ class ActionsTicketsup
if ($action == "confirm_public_close" && GETPOST('confirm', 'alpha') == 'yes') {
$this->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha'));
if (($_SESSION['email_customer'] == $this->dao->origin_email || $_SESSION['email_customer'] == $this->dao->thirdparty->email) && $this->dao->close()) {
if (($_SESSION['email_customer'] == $object->origin_email || $_SESSION['email_customer'] == $object->thirdparty->email) && $object->close()) {
// Log action in ticket logs table
$log_action = $langs->trans('TicketLogClosedBy', $_SESSION['email_customer']);
$ret = $this->dao->createTicketLog($user, $log_action);
$ret = $object->createTicketLog($user, $log_action);
if ($ret > 0) {
setEventMessages('<div class="confirm">' . $langs->trans('TicketMarkedAsClosed') . '</div>', null, 'mesgs');
} else {
@ -461,7 +460,7 @@ class ActionsTicketsup
if ($action == 'confirm_delete_ticket' && GETPOST('confirm', 'alpha') == "yes" && $user->rights->ticketsup->delete) {
if ($this->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) {
if ($this->dao->delete($user) > 0) {
if ($object->delete($user) > 0) {
setEventMessages('<div class="confirm">' . $langs->trans('TicketDeletedSuccess') . '</div>', null, 'mesgs');
Header("Location: index.php");
exit;
@ -476,7 +475,7 @@ class ActionsTicketsup
// Set parent company
if ($action == 'set_thirdparty' && $user->rights->societe->creer) {
if ($this->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) {
$result = $this->dao->setCustomer(GETPOST('editcustomer', 'int'));
$result = $object->setCustomer(GETPOST('editcustomer', 'int'));
$url = 'card.php?action=view&track_id=' . GETPOST('track_id', 'alpha');
header("Location: " . $url);
exit();
@ -485,11 +484,11 @@ class ActionsTicketsup
if ($action == 'set_progression' && $user->rights->ticketsup->write) {
if ($this->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) {
$result = $this->dao->setProgression(GETPOST('progress'));
$result = $object->setProgression(GETPOST('progress'));
// Log action in ticket logs table
$log_action = $langs->trans('TicketLogProgressSetTo', GETPOST('progress'));
$ret = $this->dao->createTicketLog($user, $log_action);
$url = 'card.php?action=view&track_id=' . $this->dao->track_id;
$ret = $object->createTicketLog($user, $log_action);
$url = 'card.php?action=view&track_id=' . $object->track_id;
header("Location: " . $url);
exit();
}
@ -498,19 +497,19 @@ class ActionsTicketsup
if ($action == 'setsubject') {
if ($this->fetch(GETPOST('id', 'int'))) {
if ($action == 'setsubject') {
$this->dao->subject = trim(GETPOST('subject', 'alpha'));
$object->subject = trim(GETPOST('subject', 'alpha'));
}
if ($action == 'setsubject' && empty($this->dao->subject)) {
if ($action == 'setsubject' && empty($object->subject)) {
$mesg .= ($mesg ? '<br>' : '') . $langs->trans("ErrorFieldRequired", $langs->transnoentities("Subject"));
}
if (!$mesg) {
if ($this->dao->update($user) >= 0) {
header("Location: " . $_SERVER['PHP_SELF'] . "?track_id=" . $this->dao->track_id);
if ($object->update($user) >= 0) {
header("Location: " . $_SERVER['PHP_SELF'] . "?track_id=" . $object->track_id);
exit;
}
$mesg = $this->dao->error;
$mesg = $object->error;
}
}
}
@ -519,13 +518,13 @@ class ActionsTicketsup
$res = $this->fetch('', GETPOST('track_id'));
$extrafields = new ExtraFields($this->db);
$extralabels = $extrafields->fetch_name_optionals_label($this->dao->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $this->dao);
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
$ret = $this->dao->update($user);
$ret = $object->update($user);
if ($ret > 0) {
setEventMessages($langs->trans('TicketUpdated'), null, 'mesgs');
$url = 'card.php?action=view&track_id=' . $this->dao->track_id;
$url = 'card.php?action=view&track_id=' . $object->track_id;
header("Location: " . $url);
exit();
}
@ -535,13 +534,13 @@ class ActionsTicketsup
elseif ($action == 'confirm_reopen' && $user->rights->ticketsup->manage && !GETPOST('cancel')) {
if ($this->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) {
// prevent browser refresh from reopening ticket several times
if ($this->dao->fk_statut == 8) {
$res = $this->dao->setStatut(4);
if ($object->fk_statut == 8) {
$res = $object->setStatut(4);
if ($res) {
// Log action in ticket logs table
$log_action = $langs->trans('TicketLogReopen');
$ret = $this->dao->createTicketLog($user, $log_action);
$url = 'card.php?action=view&track_id=' . $this->dao->track_id;
$ret = $object->createTicketLog($user, $log_action);
$url = 'card.php?action=view&track_id=' . $object->track_id;
header("Location: " . $url);
exit();
}
@ -550,16 +549,16 @@ class ActionsTicketsup
} // Categorisation dans projet
elseif ($action == 'classin' && $user->rights->ticketsup->write) {
if ($this->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) {
$this->dao->setProject(GETPOST('projectid'));
$url = 'card.php?action=view&track_id=' . $this->dao->track_id;
$object->setProject(GETPOST('projectid'));
$url = 'card.php?action=view&track_id=' . $object->track_id;
header("Location: " . $url);
exit();
}
} // Categorisation dans contrat
elseif ($action == 'setcontract' && $user->rights->ticketsup->write) {
if ($this->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) {
$this->dao->setContract(GETPOST('contractid'));
$url = 'card.php?action=view&track_id=' . $this->dao->track_id;
$object->setContract(GETPOST('contractid'));
$url = 'card.php?action=view&track_id=' . $object->track_id;
header("Location: " . $url);
exit();
}
@ -567,19 +566,19 @@ class ActionsTicketsup
// altairis: manage cancel button
if (!GETPOST('cancel')) {
$this->fetch('', GETPOST('track_id'));
$oldvalue_message = $this->dao->message;
$oldvalue_message = $object->message;
$fieldtomodify = GETPOST('message_initial');
$this->dao->message = $fieldtomodify;
$ret = $this->dao->update($user);
$object->message = $fieldtomodify;
$ret = $object->update($user);
if ($ret > 0) {
$log_action = $langs->trans('TicketInitialMessageModified') . " \n";
// include the Diff class
dol_include_once('/ticketsup/class/utils_diff.class.php');
// output the result of comparing two files as plain text
$log_action .= Diff::toString(Diff::compare(strip_tags($oldvalue_message), strip_tags($this->dao->message)));
$log_action .= Diff::toString(Diff::compare(strip_tags($oldvalue_message), strip_tags($object->message)));
$ret = $this->dao->createTicketLog($user, $log_action);
$ret = $object->createTicketLog($user, $log_action);
if ($ret > 0) {
setEventMessages($langs->trans('TicketMessageSuccesfullyUpdated'), null, 'mesgs');
}
@ -591,13 +590,13 @@ class ActionsTicketsup
elseif ($action == 'confirm_set_status' && $user->rights->ticketsup->write && !GETPOST('cancel')) {
if ($this->fetch(GETPOST('id', 'int'), GETPOST('track_id', 'alpha')) >= 0) {
$new_status = GETPOST('new_status', 'int');
$old_status = $this->dao->fk_statut;
$res = $this->dao->setStatut($new_status);
$old_status = $object->fk_statut;
$res = $object->setStatut($new_status);
if ($res) {
// Log action in ticket logs table
$log_action = $langs->trans('TicketLogStatusChanged', $langs->transnoentities($this->dao->statuts_short[$old_status]), $langs->transnoentities($this->dao->statuts_short[$new_status]));
$ret = $this->dao->createTicketLog($user, $log_action);
$url = 'card.php?action=view&track_id=' . $this->dao->track_id;
$log_action = $langs->trans('TicketLogStatusChanged', $langs->transnoentities($object->statuts_short[$old_status]), $langs->transnoentities($object->statuts_short[$new_status]));
$ret = $object->createTicketLog($user, $log_action);
$url = 'card.php?action=view&track_id=' . $object->track_id;
header("Location: " . $url);
exit();
}
@ -624,9 +623,9 @@ class ActionsTicketsup
$contactstatic = new Contact($this->db);
$error = 0;
$ret = $this->dao->fetch('', GETPOST('track_id'));
$this->dao->socid = $this->dao->fk_soc;
$this->dao->fetch_thirdparty();
$ret = $object->fetch('', GETPOST('track_id'));
$object->socid = $object->fk_soc;
$object->fetch_thirdparty();
if ($ret < 0) {
$error++;
array_push($this->errors, $langs->trans("ErrorTicketIsNotValid"));
@ -640,15 +639,15 @@ class ActionsTicketsup
}
if (!$error) {
$this->dao->message = GETPOST("message");
$this->dao->private = GETPOST("private_message");
$object->message = GETPOST("message");
$object->private = GETPOST("private_message");
$send_email = GETPOST('send_email', 'int');
$id = $this->dao->createTicketMessage($user);
$id = $object->createTicketMessage($user);
if ($id <= 0) {
$error++;
$this->errors = $this->dao->error;
$this->errors = $this->dao->errors;
$this->errors = $object->error;
$this->errors = $object->errors;
$action = 'add_message';
}
@ -660,14 +659,14 @@ class ActionsTicketsup
*/
if ($send_email > 0) {
// Retrieve internal contact datas
$internal_contacts = $this->dao->getInfosTicketInternalContact();
$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') ? GETPOST('subject') : '[' . $label_title . '- ticket #' . $this->dao->track_id . '] ' . $langs->trans('TicketNewMessage');
$subject = GETPOST('subject') ? GETPOST('subject') : '[' . $label_title . '- ticket #' . $object->track_id . '] ' . $langs->trans('TicketNewMessage');
$message_intro = $langs->trans('TicketNotificationEmailBody', "#" . $this->dao->id);
$message_intro = $langs->trans('TicketNotificationEmailBody', "#" . $object->id);
$message_signature = GETPOST('mail_signature') ? GETPOST('mail_signature') : $conf->global->TICKETS_MESSAGE_MAIL_SIGNATURE;
$message = $langs->trans('TicketMessageMailIntroText');
@ -677,9 +676,9 @@ class ActionsTicketsup
// Coordonnées client
$message .= "\n\n";
$message .= "==============================================\n";
$message .= !empty($this->dao->thirdparty->name) ? $langs->trans('Thirdparty') . " : " . $this->dao->thirdparty->name : '';
$message .= !empty($this->dao->thirdparty->town) ? "\n" . $langs->trans('Town') . " : " . $this->dao->thirdparty->town : '';
$message .= !empty($this->dao->thirdparty->phone) ? "\n" . $langs->trans('Phone') . " : " . $this->dao->thirdparty->phone : '';
$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) {
@ -698,10 +697,10 @@ class ActionsTicketsup
}
$message .= "\n";
// URL ticket
$url_internal_ticket = dol_buildpath('/ticketsup/card.php', 2) . '?track_id=' . $this->dao->track_id;
$url_internal_ticket = dol_buildpath('/ticketsup/card.php', 2) . '?track_id=' . $object->track_id;
// altairis: make html link on url
$message .= "\n" . $langs->trans('TicketNotificationEmailBodyInfosTrackUrlinternal') . ' : ' . '<a href="' . $url_internal_ticket . '">' . $this->dao->track_id . '</a>' . "\n";
$message .= "\n" . $langs->trans('TicketNotificationEmailBodyInfosTrackUrlinternal') . ' : ' . '<a href="' . $url_internal_ticket . '">' . $object->track_id . '</a>' . "\n";
// Add global email address recipient
// altairis: use new TICKETS_NOTIFICATION_EMAIL_TO configuration variable
@ -718,18 +717,18 @@ class ActionsTicketsup
/*
* Email for externals users if not private
*/
if (empty($this->dao->private)) {
if (empty($object->private)) {
// Retrieve email of all contacts (external)
$external_contacts = $this->dao->getInfosTicketExternalContact();
$external_contacts = $object->getInfosTicketExternalContact();
// If no contact, get email from thirdparty
if (is_array($external_contacts) && count($external_contacts) === 0) {
if (!empty($this->dao->fk_soc)) {
$this->dao->fetch_thirdparty($this->dao->fk_soc);
$array_company = array(array('firstname' => '', 'lastname' => $this->dao->thirdparty->name, 'email' => $this->dao->thirdparty->email, 'libelle' => $langs->transnoentities('Customer'), 'socid' => $this->dao->thirdparty->id));
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($this->dao->fk_soc) && !empty($this->dao->origin_email)) {
$array_external = array(array('firstname' => '', 'lastname' => $this->dao->origin_email, 'email' => $this->dao->thirdparty->email, 'libelle' => $langs->transnoentities('Customer'), 'socid' => $this->dao->thirdparty->id));
} 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);
}
}
@ -738,7 +737,7 @@ class ActionsTicketsup
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 #' . $this->dao->track_id . '] ' . $langs->trans('TicketNewMessage');
$subject = GETPOST('subject') ? GETPOST('subject') : '[' . $label_title . '- ticket #' . $object->track_id . '] ' . $langs->trans('TicketNewMessage');
$message_intro = GETPOST('mail_intro') ? GETPOST('mail_intro') : $conf->global->TICKETS_MESSAGE_MAIL_INTRO;
$message_signature = GETPOST('mail_signature') ? GETPOST('mail_signature') : $conf->global->TICKETS_MESSAGE_MAIL_SIGNATURE;
@ -753,7 +752,7 @@ class ActionsTicketsup
continue;
}
if ($info_sendto['email'] != '' && $info_sendto['email'] != $this->dao->origin_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'] . ">";
$recipient = dolGetFirstLastname($info_sendto['firstname'], $info_sendto['lastname'], '-1') . ' (' . strtolower($info_sendto['libelle']) . ')';
@ -768,8 +767,8 @@ class ActionsTicketsup
dol_buildpath('/ticketsup/public/view.php', 2)
) :
dol_buildpath('/ticketsup/card.php', 2)
) . '?track_id=' . $this->dao->track_id;
$message .= "\n" . $langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer') . ' : ' . '<a href="' . $url_public_ticket . '">' . $this->dao->track_id . '</a>' . "\n";
) . '?track_id=' . $object->track_id;
$message .= "\n" . $langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer') . ' : ' . '<a href="' . $url_public_ticket . '">' . $object->track_id . '</a>' . "\n";
// Build final message
$message = $message_intro . $message;
@ -777,14 +776,14 @@ class ActionsTicketsup
// Add signature
$message .= '<br>' . $message_signature;
if (!empty($this->dao->origin_email)) {
$sendto[] = $this->dao->origin_email;
if (!empty($object->origin_email)) {
$sendto[] = $object->origin_email;
}
if ($this->dao->fk_soc > 0 && ! in_array($this->dao->origin_email, $sendto)) {
$this->dao->socid = $this->dao->fk_soc;
$this->dao->fetch_thirdparty();
if(!empty($this->dao->thirdparty->email)) $sendto[] = $this->dao->thirdparty->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
@ -803,13 +802,13 @@ class ActionsTicketsup
$this->copyFilesForTicket();
// Set status to "answered" if not set yet, only for internal users
if ($this->dao->fk_statut < 3 && !$user->societe_id) {
$this->dao->setStatut(3);
if ($object->fk_statut < 3 && !$user->societe_id) {
$object->setStatut(3);
}
return 1;
} else {
setEventMessages($this->dao->error, $this->dao->errors, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
return -1;
}
} else {
@ -830,9 +829,9 @@ class ActionsTicketsup
global $mysoc, $conf, $langs;
$error = 0;
$ret = $this->dao->fetch('', GETPOST('track_id'));
$this->dao->socid = $this->dao->fk_soc;
$this->dao->fetch_thirdparty();
$ret = $object->fetch('', GETPOST('track_id'));
$object->socid = $object->fk_soc;
$object->fetch_thirdparty();
if ($ret < 0) {
$error++;
array_push($this->errors, $langs->trans("ErrorTicketIsNotValid"));
@ -846,12 +845,12 @@ class ActionsTicketsup
}
if (!$error) {
$this->dao->message = GETPOST("message");
$id = $this->dao->createTicketMessage($user);
$object->message = GETPOST("message");
$id = $object->createTicketMessage($user);
if ($id <= 0) {
$error++;
$this->errors = $this->dao->error;
$this->errors = $this->dao->errors;
$this->errors = $object->error;
$this->errors = $object->errors;
$action = 'add_message';
}
@ -859,24 +858,24 @@ class ActionsTicketsup
setEventMessages($langs->trans('TicketMessageSuccessfullyAdded'), null, 'mesgs');
// Retrieve internal contact datas
$internal_contacts = $this->dao->getInfosTicketInternalContact();
$internal_contacts = $object->getInfosTicketInternalContact();
$sendto = array();
if (is_array($internal_contacts) && count($internal_contacts) > 0) {
$subject = '[' . $mysoc->name . '- ticket #' . $this->dao->track_id . '] ' . $langs->trans('TicketNewMessage');
$subject = '[' . $mysoc->name . '- ticket #' . $object->track_id . '] ' . $langs->trans('TicketNewMessage');
$message = $langs->trans('TicketMessageMailIntroAutoNewPublicMessage', $this->dao->subject);
$message = $langs->trans('TicketMessageMailIntroAutoNewPublicMessage', $object->subject);
$message .= "\n";
$message .= GETPOST('message');
$message .= "\n";
// Coordonnées client
if ($this->dao->thirdparty->id > 0) {
if ($object->thirdparty->id > 0) {
$message .= "\n\n";
$message .= "==============================================\n";
$message .= $langs->trans('Thirparty') . " : " . $this->dao->thirdparty->name;
$message .= !empty($this->dao->thirdparty->town) ? $langs->trans('Town') . " : " . $this->dao->thirdparty->town : '';
$message .= $langs->trans('Thirparty') . " : " . $object->thirdparty->name;
$message .= !empty($object->thirdparty->town) ? $langs->trans('Town') . " : " . $object->thirdparty->town : '';
$message .= "\n";
$message .= !empty($this->dao->thirdparty->phone) ? $langs->trans('Phone') . " : " . $this->dao->thirdparty->phone : '';
$message .= !empty($object->thirdparty->phone) ? $langs->trans('Phone') . " : " . $object->thirdparty->phone : '';
$message .= "\n";
}
@ -893,7 +892,7 @@ class ActionsTicketsup
}
// URL ticket
$url_internal_ticket = dol_buildpath('/ticketsup/card.php', 2) . '?track_id=' . $this->dao->track_id;
$url_internal_ticket = dol_buildpath('/ticketsup/card.php', 2) . '?track_id=' . $object->track_id;
$message .= "\n" . $langs->trans('TicketNotificationEmailBodyInfosTrackUrlinternal') . ' : ' . $url_internal_ticket . "\n";
$message .= "\n\n";
@ -913,12 +912,12 @@ class ActionsTicketsup
*/
// Retrieve email of all contacts external
$external_contacts = $this->dao->getInfosTicketExternalContact();
$external_contacts = $object->getInfosTicketExternalContact();
$sendto = array();
if (is_array($external_contacts) && count($external_contacts) > 0) {
$subject = '[' . $mysoc->name . '- ticket #' . $this->dao->track_id . '] ' . $langs->trans('TicketNewMessage');
$subject = '[' . $mysoc->name . '- ticket #' . $object->track_id . '] ' . $langs->trans('TicketNewMessage');
$message = $langs->trans('TicketMessageMailIntroAutoNewPublicMessage', $this->dao->subject);
$message = $langs->trans('TicketMessageMailIntroAutoNewPublicMessage', $object->subject);
$message .= "\n";
$message .= GETPOST('message');
@ -934,28 +933,28 @@ class ActionsTicketsup
$message .= (!empty($recipient) ? $langs->trans('TicketNotificationRecipient') . ' : ' . $recipient . "\n" : '');
}
$url_public_ticket = ($conf->global->TICKETS_URL_PUBLIC_INTERFACE ? $conf->global->TICKETS_URL_PUBLIC_INTERFACE . '/view.php' : dol_buildpath('/ticketsup/public/view.php', 2)) . '?track_id=' . $this->dao->track_id;
$url_public_ticket = ($conf->global->TICKETS_URL_PUBLIC_INTERFACE ? $conf->global->TICKETS_URL_PUBLIC_INTERFACE . '/view.php' : dol_buildpath('/ticketsup/public/view.php', 2)) . '?track_id=' . $object->track_id;
$message .= "\n\n" . $langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer') . ' : ' . $url_public_ticket . "\n";
// Add signature
$message .= '\n\n' . $message_signature;
if (!empty($this->dao->origin_email) && !in_array($this->dao->origin_email, $sendto)) {
$sendto[] = $this->dao->origin_email;
if (!empty($object->origin_email) && !in_array($object->origin_email, $sendto)) {
$sendto[] = $object->origin_email;
}
if ($this->dao->fk_soc > 0 && !in_array($this->dao->origin_email, $sendto)) {
$sendto[] = $this->dao->thirdparty->email;
if ($object->fk_soc > 0 && !in_array($object->origin_email, $sendto)) {
$sendto[] = $object->thirdparty->email;
}
$this->sendTicketMessageByEmail($subject, $message, '', $sendto);
}
$this->copyFilesForTicket();
$url = 'view.php?action=view_ticket&track_id=' . $this->dao->track_id;
$url = 'view.php?action=view_ticket&track_id=' . $object->track_id;
header("Location: " . $url);
exit;
} else {
setEventMessages($this->dao->error, $this->dao->errors, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
}
} else {
setEventMessages($this->error, $this->errors, 'errors');
@ -1090,19 +1089,20 @@ class ActionsTicketsup
/**
* View list of logs with timeline view
*
* @param boolean $show_user Show user who make action
* @param boolean $show_user Show user who make action
* @param Ticketsup $object Object
*/
public function viewTimelineTicketLogs($show_user = true)
public function viewTimelineTicketLogs($show_user = true, $object = true)
{
global $conf, $langs, $bc;
// Load logs in cache
$ret = $this->dao->loadCacheLogsTicket();
$ret = $object->loadCacheLogsTicket();
if (is_array($this->dao->cache_logs_ticket) && count($this->dao->cache_logs_ticket) > 0) {
if (is_array($object->cache_logs_ticket) && count($object->cache_logs_ticket) > 0) {
print '<section id="cd-timeline">';
foreach ($this->dao->cache_logs_ticket as $id => $arraylogs) {
foreach ($object->cache_logs_ticket as $id => $arraylogs) {
print '<div class="cd-timeline-block">';
print '<div class="cd-timeline-img">';
//print '<img src="img/history.png" alt="">';
@ -1263,21 +1263,22 @@ class ActionsTicketsup
/**
* View list of message for ticket with timeline display
*
* @param boolean $show_private Show private messages
* @param boolean $show_user Show user who make action
* @param boolean $show_private Show private messages
* @param boolean $show_user Show user who make action
* @param Ticketsup $object Object ticketsup
*/
public function viewTicketTimelineMessages($show_private, $show_user = true)
public function viewTicketTimelineMessages($show_private, $show_user, Ticketsup $object)
{
global $conf, $langs, $user, $bc;
// Load logs in cache
$ret = $this->dao->loadCacheMsgsTicket();
$ret = $object->loadCacheMsgsTicket();
$action = GETPOST('action');
if (is_array($this->dao->cache_msgs_ticket) && count($this->dao->cache_msgs_ticket) > 0) {
if (is_array($object->cache_msgs_ticket) && count($object->cache_msgs_ticket) > 0) {
print '<section id="cd-timeline">';
foreach ($this->dao->cache_msgs_ticket as $id => $arraymsgs) {
foreach ($object->cache_msgs_ticket as $id => $arraymsgs) {
if (!$arraymsgs['private']
|| ($arraymsgs['private'] == "1" && $show_private)
) {
@ -1460,49 +1461,43 @@ class ActionsTicketsup
/**
* Print html navbar with link to set ticket status
<<<<<<< HEAD
* $selected : 0=>'NotRead', 1=>'Read', 3=>'Answered', 4=>'Assigned', 5 => 'InProgress', 6=> 'Waiting', 8=>'Closed', 9=>'Deleted'
*
* @param Ticketsup $object Ticket sup
* @return void
=======
*
* @global type $langs
>>>>>>> branch 'develop' of git@github.com:Dolibarr/dolibarr.git
*/
public function viewStatusActions()
public function viewStatusActions(Ticketsup $object)
{
global $langs;
print '<div class="div-table-responsive-no-min">';
print '<div class="tagtable noborder ">';
print '<div class="tagtr liste_titre">';
print '<div class="tagtd">';
print '<strong>' . $langs->trans('TicketChangeStatus') . '</strong>';
print '</div>';
// Exclude status which requires specific method
$exclude_status = array(4, 9, 8);
$exclude_status = array(Ticketsup::STATUS_CLOSED, Ticketsup::STATUS_CANCELED);
// Exclude actual status
$exclude_status = array_merge($exclude_status, array(intval($this->dao->fk_statut)));
// If status is new, don't show link which allow mark ticket as read
// Specific method exists to mark a ticket as read
if ($this->dao->fk_statut == '0') {
$exclude_status = array_merge($exclude_status, array(1));
}
$exclude_status = array_merge($exclude_status, array(intval($object->fk_statut)));
// Sort results to be similar to status object list
sort($exclude_status);
//sort($exclude_status);
//print '<br><div>';
foreach ($this->dao->statuts_short as $status => $statut_label) {
foreach ($object->statuts_short as $status => $statut_label) {
if (!in_array($status, $exclude_status)) {
print '<div class="tagtd">';
print '<a class="button" href="' . $_SERVER['PHP_SELF'] . '?track_id=' . $this->dao->track_id . '&action=set_status&new_status=' . $status . '">';
print img_picto($langs->trans($this->dao->statuts_short[$status]), 'statut' . $status . '.png@ticketsup') . ' ' . $langs->trans($this->dao->statuts_short[$status]);
if ($object->fk_statut == Ticketsup::STATUS_READ || $status == Ticketsup::STATUS_READ|| empty($object->date_read)) $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&new_status=' . $status;
print '<a class="button" href="' . $urlforbutton . '">';
print img_picto($langs->trans($object->statuts_short[$status]), 'statut' . $status . '.png@ticketsup') . ' ' . $langs->trans($object->statuts_short[$status]);
print '</a>';
print '</div>';
}
}
print '</div></div><br>';
print '</div></div></div><br>';
}

View File

@ -191,9 +191,24 @@ class Ticketsup extends CommonObject
'date_read' => array('type'=>'datetime', 'label'=>'TicketReadOn', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1),
'date_close' => array('type'=>'datetime', 'label'=>'TicketCloseOn', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1),
'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-2, 'enabled'=>1, 'position'=>501, 'notnull'=>1),
'fk_statut' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>600, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array(0 => 'NotRead', 1 => 'Read', 3 => 'Answered', 4 => 'Assigned', 5 => 'InProgress', 6 => 'Waiting', 8 => 'Closed', 9 => 'Deleted'))
'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'))
);
/**
* Status
*/
const STATUS_NOT_READ = 0;
const STATUS_READ = 1;
const STATUS_ANSWERED = 3;
const STATUS_ASSIGNED = 4;
const STATUS_IN_PROGRESS = 5;
const STATUS_WAITING = 6;
const STATUS_CLOSED = 8;
const STATUS_CANCELED = 9;
/**
* Constructor
*
@ -203,8 +218,8 @@ class Ticketsup extends CommonObject
{
$this->db = $db;
$this->statuts_short = array(0 => 'NotRead', 1 => 'Read', 3 => 'Answered', 4 => 'Assigned', 5 => 'InProgress', 6 => 'Waiting', 8 => 'Closed', 9 => 'Deleted');
$this->statuts = array(0 => 'NotRead', 1 => 'Read', 3 => 'Answered', 4 => 'Assigned', 5 => 'InProgress', 6 => 'Waiting', 8 => 'Closed', 9 => 'Deleted');
$this->statuts_short = array(0 => 'Unread', 1 => 'Read', 3 => 'Answered', 4 => 'Assigned', 5 => 'InProgress', 6 => 'Waiting', 8 => 'Closed', 9 => 'Deleted');
$this->statuts = array(0 => 'Unread', 1 => 'Read', 3 => 'Answered', 4 => 'Assigned', 5 => 'InProgress', 6 => 'Waiting', 8 => 'Closed', 9 => 'Deleted');
}
/**
@ -422,7 +437,7 @@ class Ticketsup extends CommonObject
global $langs;
// Check parameters
if (!$id && !$track_id && !$ref) {
if (! $id && ! $track_id && ! $ref) {
$this->error = 'ErrorWrongParameters';
dol_print_error(get_class($this) . "::fetch " . $this->error);
return -1;

View File

@ -49,25 +49,33 @@ if (!$user->rights->ticketsup->read) {
accessforbidden();
}
$object = new ActionsTicketsup($db);
$object->doActions($action);
$extrafields = new ExtraFields($db);
$extralabels = $extrafields->fetch_name_optionals_label($object->dao->table_element);
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
if (!$action) {
$action = 'view';
$action = 'view';
}
/***************************************************
* PAGE
*
* Put here all code to build page
****************************************************/
$object = new Ticketsup($db);
$object->fetch($id, $track_id, $ref);
/*
* Actions
*/
$actionobject = new ActionsTicketsup($db);
$actionobject->doActions($action, $object);
/*
* View
*/
$help_url = 'FR:DocumentationModuleTicket';
$page_title = $object->getTitle($action);
$page_title = $actionobject->getTitle($action);
llxHeader('', $page_title, $help_url);
$userstat = new User($db);
@ -79,20 +87,20 @@ if ($action == 'view') {
if ($res > 0) {
// restrict access for externals users
if ($user->societe_id > 0 && ($object->dao->fk_soc != $user->societe_id)
if ($user->societe_id > 0 && ($object->fk_soc != $user->societe_id)
) {
accessforbidden('', 0);
}
// or for unauthorized internals users
if (!$user->societe_id && ($conf->global->TICKETS_LIMIT_VIEW_ASSIGNED_ONLY && $object->dao->fk_user_assign != $user->id) && !$user->rights->ticketsup->manage) {
if (!$user->societe_id && ($conf->global->TICKETS_LIMIT_VIEW_ASSIGNED_ONLY && $object->fk_user_assign != $user->id) && !$user->rights->ticketsup->manage) {
accessforbidden('', 0);
}
if ($socid > 0) {
$object->dao->fetch_thirdparty();
$head = societe_prepare_head($object->dao->thirdparty);
$object->fetch_thirdparty();
$head = societe_prepare_head($object->thirdparty);
dol_fiche_head($head, 'ticketsup', $langs->trans("ThirdParty"), 0, 'company');
dol_banner_tab($object->dao->thirdparty, 'socid', '', ($user->societe_id ? 0 : 1), 'rowid', 'nom');
dol_banner_tab($object->thirdparty, 'socid', '', ($user->societe_id ? 0 : 1), 'rowid', 'nom');
dol_fiche_end();
}
@ -101,26 +109,28 @@ if ($action == 'view') {
} elseif ($user->societe_id > 0) {
$object->next_prev_filter = "te.fk_soc = '" . $user->societe_id . "'";
}
$head = ticketsup_prepare_head($object->dao);
$head = ticketsup_prepare_head($object);
dol_fiche_head($head, 'tabTicketLogs', $langs->trans("Ticket"), 0, 'ticketsup');
$object->dao->label = $object->dao->ref;
$object->label = $object->ref;
// Author
if ($object->dao->fk_user_create > 0) {
$object->dao->label .= ' - ' . $langs->trans("CreatedBy") . ' ';
if ($object->fk_user_create > 0) {
$object->label .= ' - ' . $langs->trans("CreatedBy") . ' ';
$langs->load("users");
$fuser = new User($db);
$fuser->fetch($object->dao->fk_user_create);
$object->dao->label .= $fuser->getNomUrl(0);
$fuser->fetch($object->fk_user_create);
$object->label .= $fuser->getNomUrl(0);
}
$linkback = '<a href="' . dol_buildpath('/ticketsup/list.php', 1) . '"><strong>' . $langs->trans("BackToList") . '</strong></a> ';
$object->dao->ticketsupBannerTab('ref', '', ($user->societe_id ? 0 : 1), 'ref', 'subject', '', '', '', $morehtmlleft, $linkback);
// TODO Merge this with dol_banner_tab
$object->ticketsupBannerTab('ref', '', ($user->societe_id ? 0 : 1), 'ref', 'subject', '', '', '', $morehtmlleft, $linkback);
dol_fiche_end();
print '<div class="fichecenter">';
// Logs list
print load_fiche_titre($langs->trans('TicketHistory'), '', 'history@ticketsup');
$object->viewTimelineTicketLogs();
$actionobject->viewTimelineTicketLogs(true, $object);
print '</div><!-- fichecenter -->';
print '<br style="clear: both">';
}

View File

@ -53,7 +53,7 @@ $year = GETPOST('year') > 0 ? GETPOST('year') : $nowyear;
$startyear = $year - 1;
$endyear = $year;
$object = new ActionsTicketsup($db);
$object = new Ticketsup($db);
/*
@ -180,7 +180,7 @@ if ($result) {
if ((round($tick['unread']) ? 1 : 0) +(round($tick['read']) ? 1 : 0) +(round($tick['answered']) ? 1 : 0) +(round($tick['assigned']) ? 1 : 0) +(round($tick['inprogress']) ? 1 : 0) +(round($tick['waiting']) ? 1 : 0) +(round($tick['closed']) ? 1 : 0) +(round($tick['deleted']) ? 1 : 0) >= 2
) {
$dataseries = array();
$dataseries[] = array('label' => $langs->trans("NotRead"), 'data' => round($tick['unread']));
$dataseries[] = array('label' => $langs->trans("Unread"), 'data' => round($tick['unread']));
$dataseries[] = array('label' => $langs->trans("Read"), 'data' => round($tick['read']));
$dataseries[] = array('label' => $langs->trans("Answered"), 'data' => round($tick['answered']));
$dataseries[] = array('label' => $langs->trans("Assigned"), 'data' => round($tick['assigned']));

View File

@ -39,7 +39,6 @@ $socid = GETPOST('socid', 'int');
$contactid = GETPOST('contactid', 'int');
$msg_id = GETPOST('msg_id', 'int');
$notNotifyTiers = GETPOST("not_notify_tiers_at_create", 'alpha');
$notnotifytiersatcreate = !empty($notNotifyTiers);
$action = GETPOST('action', 'alpha', 3);
@ -48,14 +47,15 @@ if (!$user->rights->ticketsup->read || !$user->rights->ticketsup->write) {
accessforbidden();
}
$object = new ActionsTicketsup($db);
$object = new Ticketsup($db);
$actionobject = new ActionsTicketsup($db);
/*
* Actions
*/
$object->doActions($action);
$actionobject->doActions($action, $object);
@ -63,11 +63,12 @@ $object->doActions($action);
* View
*/
$form = new Form($db);
$help_url = 'FR:DocumentationModuleTicket';
$page_title = $object->getTitle($action);
$page_title = $actionobject->getTitle($action);
llxHeader('', $page_title, $help_url);
$form = new Form($db);
if ($action == 'create_ticket') {
$formticket = new FormTicketsup($db);
@ -77,7 +78,7 @@ if ($action == 'create_ticket') {
$formticket->withfromsocid = $socid ? $socid : $user->societe_id;
$formticket->withfromcontactid = $contactid ? $contactid : '';
$formticket->withtitletopic = 1;
$formticket->withnotnotifytiersatcreate = $notnotifytiersatcreate;
$formticket->withnotnotifytiersatcreate = $notnotifytiersatcreate?1:0;
$formticket->withusercreate = 1;
$formticket->withref = 1;
$formticket->fk_user_create = $user->id;