Dolibarrize module ticket

This commit is contained in:
Laurent Destailleur
2018-03-18 20:01:11 +01:00
parent d4ae0395ed
commit 51b6723b08
9 changed files with 100 additions and 114 deletions

View File

@@ -178,7 +178,7 @@ class FormTicketsup
// altairis: force company and contact id for external user
if (empty($user->socid)) {
// Company
print '<tr><td class="titlefield">' . $langs->trans("Thirdparty") . '</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);
@@ -297,8 +297,8 @@ class FormTicketsup
print '</td></tr>';
// 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 '<tr><td><label for="notify_tiers_at_create">' . $langs->trans("TicketNotifyTiersAtCreation") . '</label></td><td>';
print '<input type="checkbox" id="notify_tiers_at_create" name="notify_tiers_at_create"'.($this->withnotifytiersatcreate?' checked="checked"':'').'>';
print '</td></tr>';
// TITLE

View File

@@ -1340,6 +1340,25 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
//}
}
}
elseif ($object->element == 'ticketsup')
{
$width=80; $cssclass='photoref';
$showimage=$object->is_photo_available($conf->ticketsup->dir_output.'/'.$object->track_id);
$maxvisiblephotos=(isset($conf->global->TICKETSUP_MAX_VISIBLE_PHOTO)?$conf->global->TICKETSUP_MAX_VISIBLE_PHOTO:2);
if ($conf->browser->phone) $maxvisiblephotos=1;
if ($showimage) $morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref">'.$object->show_photos($conf->ticketsup->dir_output,'small',$maxvisiblephotos,0,0,0,$width,0).'</div>';
else
{
if (!empty($conf->global->TICKETSUP_NODISPLAYIFNOPHOTO)) {
$nophoto='';
$morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref"></div>';
}
//elseif ($conf->browser->layout != 'phone') { // Show no photo link
$nophoto='/public/theme/common/nophoto.png';
$morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref"><img class="photo'.$modulepart.($cssclass?' '.$cssclass:'').'" alt="No photo" border="0"'.($width?' width="'.$width.'"':'').' src="'.DOL_URL_ROOT.$nophoto.'"></div>';
//}
}
}
else
{
if ($showimage)
@@ -3063,7 +3082,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', 'unlink', 'uparrow')))
if (in_array($pictowithoutext, array('delete', 'edit', 'off', 'on', 'printer', 'resize', 'switch_off', 'switch_on', 'unlink', 'uparrow')))
{
$fakey = $pictowithoutext; $facolor=''; $fasize='';
if ($pictowithoutext == 'switch_off') { $fakey = 'fa-toggle-off'; $facolor='#999'; $fasize='2em'; }
@@ -3072,6 +3091,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
elseif ($pictowithoutext == 'on') { $fakey = 'fa-check-square-o'; $fasize='1.3em'; }
elseif ($pictowithoutext == 'delete') { $fakey = 'fa-trash'; $facolor='#444'; }
elseif ($pictowithoutext == 'edit') { $fakey = 'fa-pencil'; $facolor='#444'; }
elseif ($pictowithoutext == 'printer') { $fakey = 'fa-print'; $fasize='1.2em'; $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'; }

View File

@@ -203,6 +203,7 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
} elseif ($socid > 0) {
$object->fetch_thirdparty();
$head = societe_prepare_head($object->thirdparty);
dol_fiche_head($head, 'ticketsup', $langs->trans("ThirdParty"), 0, 'company');
dol_banner_tab($object->thirdparty, 'socid', '', ($user->societe_id ? 0 : 1), 'rowid', 'nom');
dol_fiche_end();
@@ -218,22 +219,26 @@ if ($action == 'view' || $action == 'add_message' || $action == 'close' || $acti
dol_fiche_head($head, 'tabTicketsup', $langs->trans("Ticket"), -1, 'ticketsup');
$object->label = $object->ref;
$morehtmlref ='<div class="refidno">';
$morehtmlref.= $object->subject;
// Author
if ($object->fk_user_create > 0) {
$object->label .= ' - ' . $langs->trans("CreatedBy") . ' ';
$morehtmlref .= '<br>' . $langs->trans("CreatedBy") . ' ';
$langs->load("users");
$fuser = new User($db);
$fuser->fetch($object->fk_user_create);
$object->label .= $fuser->getNomUrl(0);
$morehtmlref .= $fuser->getNomUrl(0);
}
if (!empty($object->origin_email)) {
$object->label .= ' - ' . $langs->trans("CreatedBy") . ' ';
$object->label .= $object->origin_email . ' <small>(' . $langs->trans("TicketEmailOriginIssuer") . ')</small>';
$morehtmlref .= '<br>' . $langs->trans("CreatedBy") . ' ';
$morehtmlref .= $object->origin_email . ' <small>(' . $langs->trans("TicketEmailOriginIssuer") . ')</small>';
}
$morehtmlref.='</div>';
$linkback = '<a href="' . dol_buildpath('/ticketsup/list.php', 1) . '"><strong>' . $langs->trans("BackToList") . '</strong></a> ';
$object->ticketsupBannerTab('ref', '', ($user->societe_id ? 0 : 1), 'ref', 'subject', '', '', '', $morehtmlleft, $linkback);
dol_banner_tab($object, 'ref', $linkback, ($user->societe_id ? 0 : 1), 'ref', 'ref', $morehtmlref);
print '<div class="fichecenter"><div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';

View File

@@ -152,15 +152,15 @@ class ActionsTicketsup
$object->track_id = generate_random_id(16);
$object->ref = GETPOST("ref", 'alpha');
$object->fk_soc = GETPOST("socid", 'int');
$object->fk_soc = GETPOST("socid", 'int') > 0 ? GETPOST("socid", 'int') : 0;
$object->subject = GETPOST("subject", 'alpha');
$object->message = GETPOST("message");
$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');
$object->notify_tiers_at_create = empty($notNotifyTiers) ? 1 : 0;
$notifyTiers = GETPOST("notify_tiers_at_create", 'alpha');
$object->notify_tiers_at_create = empty($notifyTiers) ? 0 : 1;
$extrafields = new ExtraFields($this->db);
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
@@ -174,7 +174,8 @@ class ActionsTicketsup
$action = 'create_ticket';
}
if (!$error && $id > 0) {
if (!$error && $id > 0)
{
$this->db->commit();
// File transfer
@@ -189,7 +190,7 @@ class ActionsTicketsup
}
// altairis: link ticket to project
if (GETPOST('projectid')) {
if (GETPOST('projectid') > 0) {
$object->setProject(GETPOST('projectid'));
}
@@ -216,7 +217,8 @@ class ActionsTicketsup
}
// Auto create fiche intervention
if ($conf->global->TICKETS_AUTO_CREATE_FICHINTER_CREATE) {
if ($conf->global->TICKETS_AUTO_CREATE_FICHINTER_CREATE)
{
$fichinter = new Fichinter($this->db);
$fichinter->socid = $object->fk_soc;
$fichinter->fk_project = GETPOST('projectid', 'int');
@@ -623,6 +625,8 @@ class ActionsTicketsup
$contactstatic = new Contact($this->db);
$error = 0;
$object = new Ticketsup($this->db);
$ret = $object->fetch('', GETPOST('track_id'));
$object->socid = $object->fk_soc;
$object->fetch_thirdparty();

View File

@@ -352,8 +352,8 @@ class Ticketsup extends CommonObject
$sql .= ") VALUES (";
$sql .= " " . (!isset($this->ref) ? '' : "'" . $this->db->escape($this->ref) . "'") . ",";
$sql .= " " . (!isset($this->track_id) ? 'NULL' : "'" . $this->db->escape($this->track_id) . "'") . ",";
$sql .= " " . (!isset($this->fk_soc) ? '0' : "'" . $this->db->escape($this->fk_soc) . "'") . ",";
$sql .= " " . (!isset($this->fk_project) ? '0' : "'" . $this->db->escape($this->fk_project) . "'") . ",";
$sql .= " " . ($this->fk_soc > 0 ? $this->db->escape($this->fk_soc) : "null") . ",";
$sql .= " " . ($this->fk_project > 0 ? $this->db->escape($this->fk_project) : "null") . ",";
$sql .= " " . (!isset($this->origin_email) ? 'NULL' : "'" . $this->db->escape($this->origin_email) . "'") . ",";
$sql .= " " . ($this->fk_user_create > 0 ? $this->fk_user_create : ($user->id > 0 ? $user->id : 'NULL')) . ",";
$sql .= " " . ($this->fk_user_assign > 0 ? $this->fk_user_assign : 'NULL') . ",";
@@ -2412,78 +2412,6 @@ class Ticketsup extends CommonObject
return $defaultref;
}
/**
* Show tab footer of a card
*
* @param string $paramid Name of parameter to use to name the id into the URL next/previous link
* @param string $morehtml More html content to output just before the nav bar
* @param int $shownav Show Condition (navigation is shown if value is 1)
* @param string $fieldid Nom du champ en base a utiliser pour select next et previous (we make the select max and min on this field)
* @param string $fieldref Nom du champ objet ref (object->ref) a utiliser pour select next et previous
* @param string $morehtmlref More html to show after ref
* @param string $moreparam More param to add in nav link url.
* @param int $nodbprefix Do not include DB prefix to forge table name
* @param string $morehtmlleft More html code to show before ref
* @param string $morehtmlright More html code to show before navigation arrows
* @param string $onlybanner 1
* @return void
*/
public function ticketsupBannerTab($paramid, $morehtml = '', $shownav = 1, $fieldid = 'id', $fieldref = 'ref', $morehtmlref = '', $moreparam = '', $nodbprefix = 0, $morehtmlleft = '', $morehtmlright = '', $onlybanner=0)
{
global $conf, $form, $user, $langs;
$maxvisiblephotos = 1;
$showimage = 1;
$showbarcode = empty($conf->barcode->enabled) ? 0 : ($this->barcode ? 1 : 0);
if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) {
$showbarcode = 0;
}
$modulepart = 'ticketsup';
print '<div class="'.($onlybanner?'arearefnobottom':'arearef').' heightref valignmiddle" width="100%">';
$width = 80;
$height = 70;
$cssclass = 'photoref';
//$showimage=$this->is_photo_available($conf->ticketsup->multidir_output[$this->entity]);
$showimage = $this->is_photo_available($conf->ticketsup->dir_output . '/' . $this->track_id);
$maxvisiblephotos = (isset($conf->global->PRODUCT_MAX_VISIBLE_PHOTO) ? $conf->global->PRODUCT_MAX_VISIBLE_PHOTO : $maxvisiblephotos);
if ($conf->browser->phone) {
$maxvisiblephotos = 1;
}
if ($showimage) {
$morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref">'
. $this->show_photos($conf->ticketsup->dir_output, 'small', $maxvisiblephotos, 0, 0, 0, $height, $width, 0)
. '</div>';
} else {
$nophoto = '/public/theme/common/nophoto.png';
$morehtmlleft .= '<div class="floatleft inline-block valignmiddle divphotoref"><img class="photo' . $modulepart . ($cssclass ? ' ' . $cssclass : '') . '" alt="No photo" border="0"' . ($width ? ' width="' . $width . '"' : '') . ($height ? ' height="' . $height . '"' : '') . ' src="' . DOL_URL_ROOT . $nophoto . '"></div>';
}
$morehtmlright .= $this->getLibStatut(2);
if (!empty($this->name_alias)) {
$morehtmlref .= '<div class="refidno">' . $this->name_alias . '</div>';
}
// For thirdparty
if (!empty($this->label)) {
$morehtmlref .= '<div class="refidno">' . $this->label . '</div>';
}
// For product
if ($this->element != 'product') {
$morehtmlref .= '<div class="refidno">';
$morehtmlref .= $this->getBannerAddress('refaddress', $this);
$morehtmlref .= '</div>';
}
if (!empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
$morehtmlref .= '<div style="clear: both;"></div><div class="refidno">';
$morehtmlref .= $langs->trans("TechnicalID") . ': ' . $this->id;
$morehtmlref .= '</div>';
}
print $form->showrefnav($this, 'ref', $morehtml, $shownav, $fieldid, $fieldref, $morehtmlref, $moreparam, $nodbprefix, $morehtmlleft, $morehtmlright);
print '</div>';
print '<div class="underrefbanner clearboth"></div>';
}
/**
* Return if at least one photo is available

View File

@@ -149,17 +149,26 @@ if ($id > 0 || !empty($track_id) || !empty($ref)) {
dol_fiche_head($head, 'contact', $langs->trans("Ticket"), -1, 'ticketsup');
$object->label = $object->ref;
$morehtmlref ='<div class="refidno">';
$morehtmlref.= $object->subject;
// Author
if ($object->fk_user_create > 0) {
$object->label .= ' - ' . $langs->trans("CreatedBy") . ' ';
$morehtmlref .= '<br>' . $langs->trans("CreatedBy") . ' ';
$langs->load("users");
$fuser = new User($db);
$fuser->fetch($object->fk_user_create);
$object->label .= $fuser->getNomUrl(0);
$morehtmlref .= $fuser->getNomUrl(0);
}
if (!empty($object->origin_email)) {
$morehtmlref .= '<br>' . $langs->trans("CreatedBy") . ' ';
$morehtmlref .= $object->origin_email . ' <small>(' . $langs->trans("TicketEmailOriginIssuer") . ')</small>';
}
$morehtmlref.='</div>';
$linkback = '<a href="' . dol_buildpath('/ticketsup/list.php', 1) . '"><strong>' . $langs->trans("BackToList") . '</strong></a> ';
$object->ticketsupBannerTab('ref', '', ($user->societe_id ? 0 : 1), 'ref', 'subject', '', '', '', $morehtmlleft, $linkback, 1);
dol_banner_tab($object, 'ref', $linkback, ($user->societe_id ? 0 : 1), 'ref', 'ref', $morehtmlref);
dol_fiche_end();

View File

@@ -123,18 +123,29 @@ if ($object->id) {
$object->next_prev_filter = "te.fk_soc = '" . $user->societe_id . "'";
}
$head = ticketsup_prepare_head($object);
dol_fiche_head($head, 'tabTicketDocument', $langs->trans("Ticket"), 0, 'ticketsup');
$object->label = $object->ref;
$morehtmlref ='<div class="refidno">';
$morehtmlref.= $object->subject;
// Author
if ($object->fk_user_create > 0) {
$object->label .= ' - ' . $langs->trans("CreatedBy") . ' ';
$morehtmlref .= '<br>' . $langs->trans("CreatedBy") . ' ';
$langs->load("users");
$fuser = new User($db);
$fuser->fetch($object->fk_user_create);
$object->label .= $fuser->getNomUrl(0);
$morehtmlref .= $fuser->getNomUrl(0);
}
if (!empty($object->origin_email)) {
$morehtmlref .= '<br>' . $langs->trans("CreatedBy") . ' ';
$morehtmlref .= $object->origin_email . ' <small>(' . $langs->trans("TicketEmailOriginIssuer") . ')</small>';
}
$morehtmlref.='</div>';
$linkback = '<a href="' . dol_buildpath('/ticketsup/list.php', 1) . '"><strong>' . $langs->trans("BackToList") . '</strong></a> ';
$object->ticketsupBannerTab('ref', '', ($user->societe_id ? 0 : 1), 'ref', 'subject', '', '', '', $morehtmlleft, $linkback);
dol_banner_tab($object, 'ref', $linkback, ($user->societe_id ? 0 : 1), 'ref', 'ref', $morehtmlref);
dol_fiche_end();

View File

@@ -110,20 +110,29 @@ if ($action == 'view') {
$object->next_prev_filter = "te.fk_soc = '" . $user->societe_id . "'";
}
$head = ticketsup_prepare_head($object);
dol_fiche_head($head, 'tabTicketLogs', $langs->trans("Ticket"), 0, 'ticketsup');
$object->label = $object->ref;
$morehtmlref ='<div class="refidno">';
$morehtmlref.= $object->subject;
// Author
if ($object->fk_user_create > 0) {
$object->label .= ' - ' . $langs->trans("CreatedBy") . ' ';
$morehtmlref .= '<br>' . $langs->trans("CreatedBy") . ' ';
$langs->load("users");
$fuser = new User($db);
$fuser->fetch($object->fk_user_create);
$object->label .= $fuser->getNomUrl(0);
$morehtmlref .= $fuser->getNomUrl(0);
}
if (!empty($object->origin_email)) {
$morehtmlref .= '<br>' . $langs->trans("CreatedBy") . ' ';
$morehtmlref .= $object->origin_email . ' <small>(' . $langs->trans("TicketEmailOriginIssuer") . ')</small>';
}
$morehtmlref.='</div>';
$linkback = '<a href="' . dol_buildpath('/ticketsup/list.php', 1) . '"><strong>' . $langs->trans("BackToList") . '</strong></a> ';
// TODO Merge this with dol_banner_tab
$object->ticketsupBannerTab('ref', '', ($user->societe_id ? 0 : 1), 'ref', 'subject', '', '', '', $morehtmlleft, $linkback);
dol_banner_tab($object, 'ref', $linkback, ($user->societe_id ? 0 : 1), 'ref', 'ref', $morehtmlref);
dol_fiche_end();

View File

@@ -38,7 +38,7 @@ $id = GETPOST('id', 'int');
$socid = GETPOST('socid', 'int');
$contactid = GETPOST('contactid', 'int');
$msg_id = GETPOST('msg_id', 'int');
$notNotifyTiers = GETPOST("not_notify_tiers_at_create", 'alpha');
$notifyTiers = GETPOST("notify_tiers_at_create", 'alpha');
$action = GETPOST('action', 'alpha', 3);
@@ -78,7 +78,7 @@ if ($action == 'create_ticket') {
$formticket->withfromsocid = $socid ? $socid : $user->societe_id;
$formticket->withfromcontactid = $contactid ? $contactid : '';
$formticket->withtitletopic = 1;
$formticket->withnotnotifytiersatcreate = $notnotifytiersatcreate?1:0;
$formticket->withnotifytiersatcreate = ($notifyTiers?1:0);
$formticket->withusercreate = 1;
$formticket->withref = 1;
$formticket->fk_user_create = $user->id;