public static function setDepartment($IDDepartment = NULL) { $IDDepartment = self::NumberValidate($IDDepartment, EXC_INVALID_IDDEPARTMENT); if (!empty($IDDepartment)) { $StWhere = " TD.IDDepartment = {$IDDepartment} "; } else { if (empty(self::$IDSupporterLogged)) { throw new errorHandler(EXC_BAD_ARGUMENT . ' "IDSupporterLogged" '); } // die('aqui >> '. self::$IDSupporterLogged); $ArDepartment = F1DeskUtils::getDepartments(self::$IDSupporterLogged); $ArDepartment = array_keys($ArDepartment); // print_R($ArDepartment); foreach ((array) $ArDepartment as $StDepartment) { if (is_numeric($StDepartment)) { $ArIDDepartment[] = $StDepartment; } } unset($ArDepartment); $StInDepartment = implode(',', $ArIDDepartment); $StWhere = " TD.IDDepartment IN ( {$StInDepartment} ) "; } self::$BoSetDepartment = TRUE; self::ArWhereAdd($StWhere); }
<?php require_once 'main.php'; $ObjTicket = new TicketHandler(); if (F1DeskUtils::IsSupporter()) { $IDSupporter = getSessionProp('IDSupporter'); $ArDepartments = F1DeskUtils::getDepartments($IDSupporter); $ArIDDepartments = array_keys($ArDepartments); $ArTickets = $ObjTicket->getTickets($ArIDDepartments, $IDSupporter); } else { $IDUser = getSessionProp('IDUser'); $ArDepartments = F1DeskUtils::getUserDepartments(); $ArIDDepartments = array_keys($ArDepartments); $ArTickets = $ObjTicket->getUserTickets($IDUser); }
public static function getDepartmentsFormatted($IDSupporter) { $ArFormatted = array(); $ArDepartments = F1DeskUtils::getDepartments($IDSupporter); $ArSubDepartments = F1DeskUtils::getSubDepartments($IDSupporter); foreach ($ArDepartments as $IDDepartment => $StDepartment) { if (array_key_exists($IDDepartment, $ArSubDepartments) === true) { $ArSubs = $ArSubDepartments[$IDDepartment]; } else { $ArSubs = array(); } $ArFormatted[$IDDepartment] = array('ID' => $IDDepartment, 'StDepartment' => $StDepartment, 'ArSubDepartments' => $ArSubs); } foreach ($ArSubDepartments as $IDDepartment => $ArSubDepartments) { foreach ($ArSubDepartments as $IDSubDepartments) { if (array_key_exists($IDSubDepartments, $ArDepartments) === true) { $ArFormatted[$IDSubDepartments] = array('ID' => $IDSubDepartments, 'StDepartment' => $ArDepartments[$IDDepartment] . '::' . $ArDepartments[$IDSubDepartments]); } } } return $ArFormatted; }