Merge pull request #17773 from Hystepik/develop#4
New : add of a new param in selectGroupTicket
This commit is contained in:
commit
b31b210324
@ -569,12 +569,14 @@ class FormTicket
|
|||||||
* @param int $noadmininfo 0=Add admin info, 1=Disable admin info
|
* @param int $noadmininfo 0=Add admin info, 1=Disable admin info
|
||||||
* @param int $maxlength Max length of label
|
* @param int $maxlength Max length of label
|
||||||
* @param string $morecss More CSS
|
* @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
|
* @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;
|
global $langs, $user;
|
||||||
|
|
||||||
|
if ($use_multilevel == 0) {
|
||||||
$ticketstat = new Ticket($this->db);
|
$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);
|
||||||
@ -653,6 +655,108 @@ class FormTicket
|
|||||||
}
|
}
|
||||||
|
|
||||||
print ajax_combobox('select'.$htmlname);
|
print ajax_combobox('select'.$htmlname);
|
||||||
|
} else {
|
||||||
|
$groupticket=GETPOST('groupticket', 'aZ09');
|
||||||
|
$groupticketchild=GETPOST('groupticket_child', 'aZ09');
|
||||||
|
$arraycodenotparent[] = "";
|
||||||
|
$stringtoprint = '<span class="supportemailfield bold">'.$langs->trans("GroupOfTicket").'</span> ';
|
||||||
|
$stringtoprint .= '<select name="groupticket" id ="groupticket" class="maxwidth500 minwidth400">';
|
||||||
|
$stringtoprint .= '<option value=""> </option>';
|
||||||
|
|
||||||
|
$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 .= '<option '.$iselected.' class="groupticket'.dol_escape_htmltag($grouprowid).'" value="'.dol_escape_htmltag($groupvalue).'" data-html="'.dol_escape_htmltag($grouplabel).'">'.dol_escape_htmltag($grouplabel).'</option>';
|
||||||
|
if ($isparent == 'NOTPARENT') {
|
||||||
|
$arraycodenotparent[] = $groupvalue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dol_print_error($this->db);
|
||||||
|
}
|
||||||
|
if ($num_rows == 1) {
|
||||||
|
return '<input type="hidden" name="groupticket" id="groupticket" value="'.dol_escape_htmltag($groupvalue).'">';
|
||||||
|
}
|
||||||
|
$stringtoprint .= '</select> ';
|
||||||
|
|
||||||
|
$stringtoprint .= '<select name="groupticket_child" id ="groupticket_child" class="maxwidth500 minwidth400">';
|
||||||
|
$stringtoprint .= '<option value=""> </option>';
|
||||||
|
|
||||||
|
$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 .= '<option '.$iselected.' class="groupticket_'.dol_escape_htmltag($fatherid).'_child" value="'.dol_escape_htmltag($groupvalue).'" data-html="'.dol_escape_htmltag($grouplabel).'">'.dol_escape_htmltag($grouplabel).'</option>';
|
||||||
|
$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 .='</select>';
|
||||||
|
|
||||||
|
$stringtoprint .='<script>';
|
||||||
|
$stringtoprint .='var arraynotparents = '.json_encode($arraycodenotparent).';';
|
||||||
|
$stringtoprint .='if (arraynotparents.includes($("#groupticket")[0].value)){$("#groupticket_child").hide()}
|
||||||
|
else{';
|
||||||
|
foreach ($tabscript as $script) {
|
||||||
|
$stringtoprint .= $script;
|
||||||
|
};
|
||||||
|
$stringtoprint .='}
|
||||||
|
$("#groupticket").change(function() {
|
||||||
|
$("#groupticket_child")[0].value = ""
|
||||||
|
if (!arraynotparents.includes(this.value)) {
|
||||||
|
$("#groupticket_child").show()
|
||||||
|
} else {
|
||||||
|
$("#groupticket_child").hide()
|
||||||
|
}
|
||||||
|
';
|
||||||
|
foreach ($tabscript as $script) {
|
||||||
|
$stringtoprint .= $script;
|
||||||
|
};
|
||||||
|
$stringtoprint .='})';
|
||||||
|
$stringtoprint .='</script>';
|
||||||
|
return $stringtoprint;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user