69 lines
1.7 KiB
PHP
Executable File
69 lines
1.7 KiB
PHP
Executable File
<?php
|
|
|
|
class OrderForm extends ObjectModel
|
|
{
|
|
public $id;
|
|
|
|
/** @var integer manufacturer ID */
|
|
public $id_order_form;//FIXME is it really usefull...?
|
|
|
|
/** @var string Name */
|
|
public $from;
|
|
|
|
/** @var string A description */
|
|
public $to;
|
|
|
|
public $date_add;
|
|
|
|
public $id_category;
|
|
|
|
protected $fieldsRequired = array('from', 'to', 'id_category');
|
|
protected $fieldsValidate = array('from' => '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);
|
|
}
|
|
}
|