NEW Can set if a ticket group is visible on public interface or not.

This commit is contained in:
Laurent Destailleur 2021-03-24 13:16:17 +01:00
parent 4015f5952e
commit 211c5b53eb
5 changed files with 24 additions and 20 deletions

View File

@ -126,9 +126,10 @@ class FormTicket
* *
* @param int $withdolfichehead With dol_get_fiche_head() and dol_get_fiche_end() * @param int $withdolfichehead With dol_get_fiche_head() and dol_get_fiche_end()
* @param string $mode Mode ('create' or 'edit') * @param string $mode Mode ('create' or 'edit')
* @param int $public 1=If we show the form for the public interface
* @return void * @return void
*/ */
public function showForm($withdolfichehead = 0, $mode = 'edit') public function showForm($withdolfichehead = 0, $mode = 'edit', $public = 0)
{ {
global $conf, $langs, $user, $hookmanager; global $conf, $langs, $user, $hookmanager;
@ -182,6 +183,7 @@ class FormTicket
if (isset($this->param['origin']) && $this->param['originid'] > 0) { if (isset($this->param['origin']) && $this->param['originid'] > 0) {
// Parse element/subelement (ex: project_task) // Parse element/subelement (ex: project_task)
$element = $subelement = $this->param['origin']; $element = $subelement = $this->param['origin'];
$regs = array();
if (preg_match('/^([^_]+)_([^_]+)/i', $this->param['origin'], $regs)) { if (preg_match('/^([^_]+)_([^_]+)/i', $this->param['origin'], $regs)) {
$element = $regs[1]; $element = $regs[1];
$subelement = $regs[2]; $subelement = $regs[2];
@ -208,7 +210,11 @@ class FormTicket
// Group // Group
print '<tr><td><span class="fieldrequired"><label for="selectcategory_code">'.$langs->trans("TicketCategory").'</span></label></td><td>'; print '<tr><td><span class="fieldrequired"><label for="selectcategory_code">'.$langs->trans("TicketCategory").'</span></label></td><td>';
$this->selectGroupTickets((GETPOST('category_code') ? GETPOST('category_code') : $this->category_code), 'category_code', '', 2, 0, 0, 0, 'minwidth200'); $filter = '';
if ($public) {
$filter = 'public=1';
}
$this->selectGroupTickets((GETPOST('category_code') ? GETPOST('category_code') : $this->category_code), 'category_code', $filter, 2, 0, 0, 0, 'minwidth200');
print '</td></tr>'; print '</td></tr>';
// Severity // Severity
@ -307,7 +313,7 @@ class FormTicket
if ($this->withfile == 2) { // Can add other files if ($this->withfile == 2) { // Can add other files
$out .= '<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans("Upload").'" />'; $out .= '<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans("Upload").'" />';
$out .= ' '; $out .= ' ';
$out .= '<input type="submit" class="button" id="addfile" name="addfile" value="'.$langs->trans("MailingAddFile").'" />'; $out .= '<input type="submit" class="button smallpaddingimp" id="addfile" name="addfile" value="'.$langs->trans("MailingAddFile").'" />';
} }
$out .= "</td></tr>\n"; $out .= "</td></tr>\n";
@ -439,8 +445,8 @@ class FormTicket
print dol_get_fiche_end(); print dol_get_fiche_end();
} }
print '<div class="center">'; print '<br><div class="center">';
print '<input class="button" type="submit" name="add" value="'.$langs->trans(($this->withthreadid > 0 ? "SendResponse" : "NewTicket")).'" />'; print '<input class="button" type="submit" name="add" value="'.$langs->trans(($this->withthreadid > 0 ? "SendResponse" : "CreateTicket")).'" />';
if ($this->withcancel) { if ($this->withcancel) {
print " &nbsp; &nbsp; &nbsp;"; print " &nbsp; &nbsp; &nbsp;";
print '<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">'; print '<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
@ -551,7 +557,7 @@ class FormTicket
* *
* @param string $selected Id categorie pre-selectionnée * @param string $selected Id categorie pre-selectionnée
* @param string $htmlname Nom de la zone select * @param string $htmlname Nom de la zone select
* @param string $filtertype To filter on field type in llx_c_ticket_category (array('code'=>xx,'label'=>zz)) * @param string $filtertype To filter on some properties in llx_c_ticket_category ('public = 1'). This parameter must not come from input of users.
* @param int $format 0=id+libelle, 1=code+code, 2=code+libelle, 3=id+code * @param int $format 0=id+libelle, 1=code+code, 2=code+libelle, 3=id+code
* @param int $empty 1=peut etre vide, 0 sinon * @param int $empty 1=peut etre vide, 0 sinon
* @param int $noadmininfo 0=Add admin info, 1=Disable admin info * @param int $noadmininfo 0=Add admin info, 1=Disable admin info
@ -567,12 +573,6 @@ class FormTicket
dol_syslog(get_class($this)."::selectCategoryTickets ".$selected.", ".$htmlname.", ".$filtertype.", ".$format, LOG_DEBUG); dol_syslog(get_class($this)."::selectCategoryTickets ".$selected.", ".$htmlname.", ".$filtertype.", ".$format, LOG_DEBUG);
$filterarray = array();
if ($filtertype != '' && $filtertype != '-1') {
$filterarray = explode(',', $filtertype);
}
$ticketstat->loadCacheCategoriesTickets(); $ticketstat->loadCacheCategoriesTickets();
print '<select id="select'.$htmlname.'" class="flat minwidth100'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'">'; print '<select id="select'.$htmlname.'" class="flat minwidth100'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'">';
@ -582,10 +582,12 @@ class FormTicket
if (is_array($ticketstat->cache_category_tickets) && count($ticketstat->cache_category_tickets)) { if (is_array($ticketstat->cache_category_tickets) && count($ticketstat->cache_category_tickets)) {
foreach ($ticketstat->cache_category_tickets as $id => $arraycategories) { foreach ($ticketstat->cache_category_tickets as $id => $arraycategories) {
// On passe si on a demande de filtrer sur des modes de paiments particuliers // Exclude some record
if (count($filterarray) && !in_array($arraycategories['type'], $filterarray)) { if ($filtertype == 'public=1') {
if (empty($arraycategories['public'])) {
continue; continue;
} }
}
// We discard empty line if showempty is on because an empty line has already been output. // We discard empty line if showempty is on because an empty line has already been output.
if ($empty && empty($arraycategories['code'])) { if ($empty && empty($arraycategories['code'])) {
@ -1081,7 +1083,7 @@ class FormTicket
if ($this->withfile == 2) { // Can add other files if ($this->withfile == 2) { // Can add other files
$out .= '<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans("Upload").'" />'; $out .= '<input type="file" class="flat" id="addedfile" name="addedfile" value="'.$langs->trans("Upload").'" />';
$out .= ' '; $out .= ' ';
$out .= '<input type="submit" class="button" id="'.$addfileaction.'" name="'.$addfileaction.'" value="'.$langs->trans("MailingAddFile").'" />'; $out .= '<input type="submit" class="button smallpaddingimp" id="'.$addfileaction.'" name="'.$addfileaction.'" value="'.$langs->trans("MailingAddFile").'" />';
} }
$out .= "</td></tr>\n"; $out .= "</td></tr>\n";

View File

@ -392,7 +392,7 @@ if ($action != "infos_success") {
print '<div>'; print '<div>';
} else { } else {
print '<div class="info marginleftonly marginrightonly">'.$langs->trans('TicketPublicInfoCreateTicket').'</div>'; print '<div class="info marginleftonly marginrightonly">'.$langs->trans('TicketPublicInfoCreateTicket').'</div>';
$formticket->showForm(); $formticket->showForm(0, 'edit', 1);
} }
} }

View File

@ -432,7 +432,7 @@ if ($action == "view_ticketlist") {
if (!empty($arrayfields['category.code']['checked'])) { if (!empty($arrayfields['category.code']['checked'])) {
print '<td class="liste_titre">'; print '<td class="liste_titre">';
$formTicket->selectGroupTickets($search_category, 'search_category', '', 2, 1, 1); $formTicket->selectGroupTickets($search_category, 'search_category', 'public=1', 2, 1, 1);
print '</td>'; print '</td>';
} }

View File

@ -691,7 +691,7 @@ if ($action == 'create' || $action == 'presend') {
$formticket->withextrafields = 1; $formticket->withextrafields = 1;
$formticket->param = array('origin' => GETPOST('origin'), 'originid' => GETPOST('originid')); $formticket->param = array('origin' => GETPOST('origin'), 'originid' => GETPOST('originid'));
$formticket->showForm(1, 'create'); $formticket->showForm(1, 'create', 0);
} elseif ($action == 'edit' && $user->rights->ticket->write && $object->fk_statut < Ticket::STATUS_CLOSED) { } elseif ($action == 'edit' && $user->rights->ticket->write && $object->fk_statut < Ticket::STATUS_CLOSED) {
$formticket = new FormTicket($db); $formticket = new FormTicket($db);

View File

@ -1177,7 +1177,7 @@ class Ticket extends CommonObject
} }
// Cache deja charge // Cache deja charge
$sql = "SELECT rowid, code, label, use_default, pos, description"; $sql = "SELECT rowid, code, label, use_default, pos, description, public, active";
$sql .= " FROM ".MAIN_DB_PREFIX."c_ticket_category"; $sql .= " FROM ".MAIN_DB_PREFIX."c_ticket_category";
$sql .= " WHERE active > 0"; $sql .= " WHERE active > 0";
$sql .= " ORDER BY pos"; $sql .= " ORDER BY pos";
@ -1194,6 +1194,8 @@ class Ticket extends CommonObject
$this->cache_category_tickets[$obj->rowid]['label'] = $label; $this->cache_category_tickets[$obj->rowid]['label'] = $label;
$this->cache_category_tickets[$obj->rowid]['use_default'] = $obj->use_default; $this->cache_category_tickets[$obj->rowid]['use_default'] = $obj->use_default;
$this->cache_category_tickets[$obj->rowid]['pos'] = $obj->pos; $this->cache_category_tickets[$obj->rowid]['pos'] = $obj->pos;
$this->cache_category_tickets[$obj->rowid]['public'] = $obj->public;
$this->cache_category_tickets[$obj->rowid]['active'] = $obj->active;
$i++; $i++;
} }
return $num; return $num;