XoopsModules25x /
oledrion
| 1 | <?php |
||
| 2 | |||
| 3 | namespace XoopsModules\Oledrion; |
||
| 4 | |||
| 5 | /* |
||
| 6 | You may not change or alter any portion of this comment or credits |
||
| 7 | of supporting developers from this source code or any supporting source code |
||
| 8 | which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 9 | |||
| 10 | This program is distributed in the hope that it will be useful, |
||
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 13 | */ |
||
| 14 | |||
| 15 | /** |
||
| 16 | * oledrion |
||
| 17 | * |
||
| 18 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||
| 19 | * @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license} |
||
| 20 | * @author Hervé Thouzard (http://www.herve-thouzard.com/) |
||
| 21 | */ |
||
| 22 | |||
| 23 | use XoopsModules\Oledrion; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Gestion des TVA |
||
| 27 | */ |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Class VatHandler |
||
| 31 | */ |
||
| 32 | class VatHandler extends OledrionPersistableObjectHandler |
||
| 33 | { |
||
| 34 | /** |
||
| 35 | * VatHandler constructor. |
||
| 36 | * @param \XoopsDatabase|null $db |
||
| 37 | */ |
||
| 38 | public function __construct(\XoopsDatabase $db = null) |
||
| 39 | { |
||
| 40 | // Table Classe Id |
||
| 41 | parent::__construct($db, 'oledrion_vat', Vat::class, 'vat_id'); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * Renvoie la liste de toutes les TVA du module |
||
| 46 | * |
||
| 47 | * @param Parameters $parameters |
||
| 48 | * @return array tableau d'objets de type TVA |
||
| 49 | * @internal param int $start Position de départ |
||
| 50 | * @internal param int $limit Nombre total d'enregistrements à renvoyer |
||
| 51 | * @internal param string $order Champ sur lequel faire le tri |
||
| 52 | * @internal param string $order Ordre du tri |
||
| 53 | * @internal param bool $idaskey Indique si le tableau renvoyé doit avoir pour clé l'identifiant unique de l'enregistrement |
||
| 54 | */ |
||
| 55 | public function getAllVats(Parameters $parameters) |
||
| 56 | { |
||
| 57 | $parameters = $parameters->extend(new Oledrion\Parameters([ |
||
| 58 | 'start' => 0, |
||
| 59 | 'limit' => 0, |
||
| 60 | 'sort' => 'vat_id', |
||
| 61 | 'order' => 'ASC', |
||
| 62 | 'idaskey' => true, |
||
| 63 | ])); |
||
| 64 | $critere = new \Criteria('vat_id', 0, '<>'); |
||
| 65 | $critere->setLimit($parameters['limit']); |
||
| 66 | $critere->setStart($parameters['start']); |
||
| 67 | $critere->setSort($parameters['sort']); |
||
| 68 | $critere->setOrder($parameters['order']); |
||
| 69 | $vats = []; |
||
| 70 | $vats = $this->getObjects($critere, $parameters['idaskey']); |
||
| 71 | |||
| 72 | return $vats; |
||
| 73 | } |
||
| 74 | |||
| 75 | /** |
||
| 76 | * Renvoie la liste de toutes les TVA du module |
||
| 77 | * |
||
| 78 | * @param $country |
||
| 79 | * @return array tableau d'objets de type TVA |
||
| 80 | * @internal param int $start Position de départ |
||
| 81 | * @internal param int $limit Nombre total d'enregistrements à renvoyer |
||
| 82 | * @internal param string $order Champ sur lequel faire le tri |
||
| 83 | * @internal param string $order Ordre du tri |
||
| 84 | * @internal param bool $idaskey Indique si le tableau renvoyé doit avoir pour clé l'identifiant unique de l'enregistrement |
||
| 85 | */ |
||
| 86 | public function getCountryVats($country) |
||
| 87 | { |
||
| 88 | $parameters = new Oledrion\Parameters([ |
||
| 89 | 'start' => 0, |
||
| 90 | 'limit' => 0, |
||
| 91 | 'sort' => 'vat_id', |
||
| 92 | 'order' => 'ASC', |
||
| 93 | 'idaskey' => true, |
||
| 94 | ]); |
||
| 95 | $critere = new \CriteriaCompo(); |
||
| 96 | if (!empty($country)) { |
||
| 97 | $critere->add(new \Criteria('vat_country', $country, 'LIKE')); |
||
| 98 | } |
||
| 99 | $critere->setLimit($parameters['limit']); |
||
| 100 | $critere->setStart($parameters['start']); |
||
| 101 | $critere->setSort($parameters['sort']); |
||
| 102 | $critere->setOrder($parameters['order']); |
||
| 103 | $vats = []; |
||
| 104 | $vats = $this->getObjects($critere, $parameters['idaskey']); |
||
| 105 | |||
| 106 | return $vats; |
||
| 107 | } |
||
| 108 | |||
| 109 | /** |
||
| 110 | * Suppression d'une TVA |
||
| 111 | * |
||
| 112 | * @param Vat $vat |
||
| 113 | * @return bool Le résultat de la suppressin |
||
| 114 | */ |
||
| 115 | public function deleteVat(Vat $vat) |
||
| 116 | { |
||
| 117 | return $this->delete($vat, true); |
||
| 118 | } |
||
| 119 | |||
| 120 | /** |
||
| 121 | * Retourne le nombre de produits associés à une TVA |
||
| 122 | * |
||
| 123 | * @param int $vat_id L'ID de la TVA |
||
| 124 | * @return int Le nombre de produits |
||
| 125 | */ |
||
| 126 | public function getVatProductsCount($vat_id) |
||
| 127 | { |
||
| 128 | global $productsHandler; |
||
| 129 | |||
| 130 | return $productsHandler->getVatProductsCount($vat_id); |
||
| 131 | } |
||
| 132 | } |
||
| 133 |