setQuery($q, 0, 1); $record = $dbo->loadAssoc(); if (!$record) { return [0, null]; } return [(float)$record['aliq'], $record['name']]; } /** * Gets the tax rate assigned to the given tax ID. * * @param int $tax_id the tax ID. * * @return array float|int (tax rate) and string (tax name). */ public static function getTaxRateFromId($tax_id) { if (empty($tax_id)) { return [0, null]; } $dbo = JFactory::getDbo(); $q = "SELECT `t`.`name`, `t`.`aliq` FROM `#__vikbooking_iva` AS `t` WHERE `t`.`id`=" . (int)$tax_id; $dbo->setQuery($q, 0, 1); $record = $dbo->loadAssoc(); if (!$record) { return [0, null]; } return [(float)$record['aliq'], $record['name']]; } /** * Returns the whole tax rate record from the given ID. * * @param int $tax_id the tax record ID. * * @return array * * @since 1.16.1 (J) - 1.6.1 (WP) */ public static function getTaxRateRecord($tax_id) { static $tax_map = []; $tax_id = (int)$tax_id; if (isset($tax_map[$tax_id])) { return $tax_map[$tax_id]; } $dbo = JFactory::getDbo(); $q = "SELECT * FROM `#__vikbooking_iva` WHERE `id`=" . $tax_id; $dbo->setQuery($q, 0, 1); $record = $dbo->loadAssoc(); if (!$record) { $record = []; } // cache value and return it $tax_map[$tax_id] = $record; return $record; } /** * Gets the tax summary associative array. * * @param bool $sort if true, the array will be sorted by key desc. * * @return array */ public static function get($sort = true) { if ($sort) { krsort(static::$summary); } return static::$summary; } /** * Gets the tax names associative array. * * @return array */ public static function getNames() { return static::$tax_names; } /** * Sets the tax summary associative array. * * @param array $summary * * @return void */ public static function set(array $summary = []) { static::$summary = $summary; } /** * Sets the tax names associative array. * * @param array $names * * @return void */ public static function setNames(array $names = []) { static::$tax_names = $names; } }