/** * Get mandatory fields for a template * * @since version 0.83 * * @param $ID integer the template ID * @param $withtypeandcategory boolean with type and category (true by default) * * @return an array of mandatory fields **/ function getMandatoryFields($ID, $withtypeandcategory = true) { global $DB; $sql = "SELECT *\n FROM `" . $this->getTable() . "`\n WHERE `" . static::$items_id . "` = '{$ID}'\n ORDER BY `id`"; $result = $DB->query($sql); $tt = new TicketTemplate(); $allowed_fields = $tt->getAllowedFields($withtypeandcategory); $fields = array(); while ($rule = $DB->fetch_assoc($result)) { if (isset($allowed_fields[$rule['num']])) { $fields[$allowed_fields[$rule['num']]] = $rule['num']; } } return $fields; }
/** * Get predefined fields for a template * * @since version 0.83 * * @param $ID integer the template ID * @param $withtypeandcategory boolean with type and category (false by default) * * @return an array of predefined fields **/ function getPredefinedFields($ID, $withtypeandcategory = false) { global $DB; $sql = "SELECT *\n FROM `" . $this->getTable() . "`\n WHERE `" . static::$items_id . "` = '{$ID}'\n ORDER BY `id`"; $result = $DB->query($sql); $tt = new TicketTemplate(); $allowed_fields = $tt->getAllowedFields($withtypeandcategory, true); $fields = array(); $multiple = self::getMultiplePredefinedValues(); while ($rule = $DB->fetch_assoc($result)) { if (isset($allowed_fields[$rule['num']])) { if (in_array($rule['num'], $multiple)) { if ($allowed_fields[$rule['num']] == 'items_id') { $item_itemtype = explode("_", $rule['value']); $fields[$allowed_fields[$rule['num']]][$item_itemtype[0]][$item_itemtype[1]] = $item_itemtype[1]; } else { $fields[$allowed_fields[$rule['num']]][] = $rule['value']; } } else { $fields[$allowed_fields[$rule['num']]] = $rule['value']; } } } return $fields; }