diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php
index 3cec6c19789..23c220d43df 100644
--- a/htdocs/core/class/html.formticket.class.php
+++ b/htdocs/core/class/html.formticket.class.php
@@ -569,90 +569,194 @@ class FormTicket
* @param int $noadmininfo 0=Add admin info, 1=Disable admin info
* @param int $maxlength Max length of label
* @param string $morecss More CSS
+ * @param int $use_multilevel if != 0 create a multilevel select ( Do not use any of the other params)
* @return void
*/
- public function selectGroupTickets($selected = '', $htmlname = 'ticketcategory', $filtertype = '', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss = '')
+ public function selectGroupTickets($selected = '', $htmlname = 'ticketcategory', $filtertype = '', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss = '', $use_multilevel = 0)
{
global $langs, $user;
- $ticketstat = new Ticket($this->db);
+ if ($use_multilevel == 0) {
+ $ticketstat = new Ticket($this->db);
- dol_syslog(get_class($this)."::selectCategoryTickets ".$selected.", ".$htmlname.", ".$filtertype.", ".$format, LOG_DEBUG);
+ dol_syslog(get_class($this)."::selectCategoryTickets ".$selected.", ".$htmlname.", ".$filtertype.", ".$format, LOG_DEBUG);
- $ticketstat->loadCacheCategoriesTickets();
+ $ticketstat->loadCacheCategoriesTickets();
- print '';
+ if ($user->admin && !$noadmininfo) {
+ print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
+ }
- print ajax_combobox('select'.$htmlname);
+ print ajax_combobox('select'.$htmlname);
+ } else {
+ $groupticket=GETPOST('groupticket', 'aZ09');
+ $groupticketchild=GETPOST('groupticket_child', 'aZ09');
+ $arraycodenotparent[] = "";
+ $stringtoprint = ''.$langs->trans("GroupOfTicket").' ';
+ $stringtoprint .= '';
+ $stringtoprint .= '';
+
+ $sql = "SELECT ctc.rowid, ctc.code, ctc.label, ctc.fk_parent, ";
+ $sql .= $this->db->ifsql("ctc.rowid NOT IN (SELECT ctcfather.rowid FROM llx_c_ticket_category as ctcfather JOIN llx_c_ticket_category as ctcjoin ON ctcfather.rowid = ctcjoin.fk_parent)", "'NOTPARENT'", "'PARENT'")." as isparent";
+ $sql .= " FROM ".MAIN_DB_PREFIX."c_ticket_category as ctc";
+ $sql .= " WHERE ctc.public = 1";
+ $sql .= " AND ctc.active = 1";
+ $sql .= " AND ctc.fk_parent = 0";
+ $sql .= $this->db->order('ctc.pos', 'ASC');
+ $resql = $this->db->query($sql);
+ if ($resql) {
+ $num_rows = $this->db->num_rows($resql);
+ $i = 0;
+ while ($i < $num_rows) {
+ $obj = $this->db->fetch_object($resql);
+ if ($obj) {
+ $grouprowid = $obj->rowid;
+ $groupvalue = $obj->code;
+ $grouplabel = $obj->label;
+ $isparent = $obj->isparent;
+ $iselected = $groupticket == $obj->code ?'selected':'';
+ $stringtoprint .= '';
+ if ($isparent == 'NOTPARENT') {
+ $arraycodenotparent[] = $groupvalue;
+ }
+ }
+ $i++;
+ }
+ } else {
+ dol_print_error($this->db);
+ }
+ if ($num_rows == 1) {
+ return '';
+ }
+ $stringtoprint .= ' ';
+
+ $stringtoprint .= '';
+ $stringtoprint .= '';
+
+ $sql = "SELECT ctc.rowid, ctc.code, ctc.label, ctc.fk_parent, ctcjoin.code as codefather";
+ $sql .= " FROM ".MAIN_DB_PREFIX."c_ticket_category as ctc";
+ $sql .= " JOIN ".MAIN_DB_PREFIX."c_ticket_category as ctcjoin ON ctc.fk_parent = ctcjoin.rowid";
+ $sql .= " WHERE ctc.public = 1";
+ $sql .= " AND ctc.active = 1";
+ $sql .= " AND ctc.fk_parent <> 0";
+ $sql .= $this->db->order('ctc.pos', 'ASC');
+ $resql = $this->db->query($sql);
+ if ($resql) {
+ $num_rows = $this->db->num_rows($resql);
+ $i = 0;
+ while ($i < $num_rows) {
+ $obj = $this->db->fetch_object($resql);
+ if ($obj) {
+ $grouprowid = $obj->rowid;
+ $groupvalue = $obj->code;
+ $grouplabel = $obj->label;
+ $fatherid = $obj->fk_parent;
+ $groupcodefather = $obj->codefather;
+ $iselected = $groupticketchild == $obj->code ?'selected':'';
+ $stringtoprint .= '';
+ $tabscript[] = 'if($("#groupticket")[0].value == "'.dol_escape_js($groupcodefather).'"){
+ $(".groupticket_'.dol_escape_htmltag($fatherid).'_child").show()
+ }else{
+ $(".groupticket_'.dol_escape_htmltag($fatherid).'_child").hide()
+ }';
+ }
+ $i++;
+ }
+ } else {
+ dol_print_error($this->db);
+ }
+ $stringtoprint .='';
+
+ $stringtoprint .='';
+ return $stringtoprint;
+ }
}
/**