'isDate', 'to' => 'isDate', 'id_category' => 'isInt'); protected $table = 'privatesale_order_form'; protected $identifier = 'id_order_form'; public function getFields() { parent::validateFields(); if (isset($this->id)) $fields['id_order_form'] = (int)($this->id); $fields['from'] = pSQL($this->from); $fields['id_category'] = pSQL($this->id_category); $fields['to'] = pSQL($this->to); $fields['date_add'] = pSQL($this->date_add); return $fields; } static function getByCategorie($id_category) { $sql = 'SELECT * FROM '._DB_PREFIX_.'privatesale_order_form WHERE id_category = '.(int)$id_category.' ORDER BY date_add DESC'; return Db::getInstance()->ExecuteS($sql); } static function getLastByCategory($id_category) { $sql = 'SELECT `to` FROM '._DB_PREFIX_.'privatesale_order_form WHERE id_category = '.(int)$id_category.' ORDER BY `to` DESC'; return Db::getInstance()->getValue($sql); } public static function getDir($root = true) { if($root === true) return _PS_MODULE_DIR_.'privatesales_logistique/files/bdc/'; else return '/modules/privatesales_logistique/files/bdc/'; } public static function getFileStatic($id_privatesales_export, $root) { return self::getDir($root).$id_privatesales_export.'.xlsx'; } public function getFile($root = true) { return self::getFileStatic($this->id, $root); } }