diff --git a/admin-dev/tabs/AdminDeliverySlip.php b/admin-dev/tabs/AdminDeliverySlip.php deleted file mode 100644 index ebe71ad02..000000000 --- a/admin-dev/tabs/AdminDeliverySlip.php +++ /dev/null @@ -1,104 +0,0 @@ - -* @copyright 2007-2011 PrestaShop SA -* @version Release: $Revision: 7060 $ -* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -class AdminDeliverySlip extends AdminTab -{ - public function __construct() - { - $this->table = 'delivery'; - - $this->optionsList = array( - 'general' => array( - 'title' => $this->l('Delivery slips options'), - 'fields' => array( - 'PS_DELIVERY_PREFIX' => array('title' => $this->l('Delivery prefix:'), 'desc' => $this->l('Prefix used for delivery slips'), 'size' => 6, 'type' => 'textLang'), - 'PS_DELIVERY_NUMBER' => array('title' => $this->l('Delivery number:'), 'desc' => $this->l('The next delivery slip will begin with this number, and then increase with each additional slip'), 'size' => 6, 'type' => 'text'), - ), - ), - ); - - parent::__construct(); - } - - public function displayForm($isMainTab = true) - { - parent::displayForm(); - - $output = ' -

'.$this->l('Print PDF delivery slips').'

-
-
- -
- * -

'.$this->l('Format: 2007-12-31 (inclusive)').'

-
- -
- * -

'.$this->l('Format: 2008-12-31 (inclusive)').'

-
-
- -
-
* '.$this->l('Required fields').'
-
-
'; - - echo $output; - } - - public function display() - { - $this->displayForm(); - echo '
'; - $this->displayOptionsList(); - } - - public function postProcess() - { - if (Tools::getValue('submitPrint')) - { - if (!Validate::isDate($_POST['date_from'])) - $this->_errors[] = $this->l('Invalid from date'); - if (!Validate::isDate($_POST['date_to'])) - $this->_errors[] = $this->l('Invalid end date'); - if (!sizeof($this->_errors)) - { - $orders = Order::getOrdersIdByDate($_POST['date_from'], $_POST['date_to'], NULL, 'delivery'); - if (sizeof($orders)) - Tools::redirectAdmin('pdf.php?deliveryslips='.urlencode(serialize($orders)).'&token='.$this->token); - else - $this->_errors[] = $this->l('No delivery slip found for this period'); - } - } - else - parent::postProcess(); - } -} - - diff --git a/classes/Delivery.php b/classes/Delivery.php index 91beba4cc..bd116ece7 100644 --- a/classes/Delivery.php +++ b/classes/Delivery.php @@ -29,13 +29,13 @@ class DeliveryCore extends ObjectModel { /** @var integer */ public $id_delivery; - + /** @var int **/ public $id_shop; - + /** @var int **/ public $id_group_shop; - + /** @var integer */ public $id_carrier; @@ -45,20 +45,32 @@ class DeliveryCore extends ObjectModel /** @var integer */ public $id_range_weight; - /** @var integer */ + /** @var integer */ public $id_zone; - /** @var float */ + /** @var float */ public $price; - protected $fieldsRequired = array ('id_carrier', 'id_range_price', 'id_range_weight', 'id_zone', 'price'); - protected $fieldsValidate = array ('id_carrier' => 'isUnsignedId', 'id_range_price' => 'isUnsignedId', - 'id_range_weight' => 'isUnsignedId', 'id_zone' => 'isUnsignedId', 'price' => 'isPrice'); + protected $fieldsRequired = array ( + 'id_carrier', + 'id_range_price', + 'id_range_weight', + 'id_zone', + 'price' + ); - protected $table = 'delivery'; - protected $identifier = 'id_delivery'; - - protected $webserviceParameters = array( + protected $fieldsValidate = array ( + 'id_carrier' => 'isUnsignedId', + 'id_range_price' => 'isUnsignedId', + 'id_range_weight' => 'isUnsignedId', + 'id_zone' => 'isUnsignedId', + 'price' => 'isPrice' + ); + + protected $table = 'delivery'; + protected $identifier = 'id_delivery'; + + protected $webserviceParameters = array( 'objectsNodeName' => 'deliveries', 'fields' => array( 'id_carrier' => array('xlink_resource' => 'carriers'), @@ -67,7 +79,7 @@ class DeliveryCore extends ObjectModel 'id_zone' => array('xlink_resource' => 'zones'), ) ); - + public function getFields() { $this->validateFields(); @@ -81,8 +93,8 @@ class DeliveryCore extends ObjectModel $fields['id_range_weight'] = (int)$this->id_range_weight; $fields['id_zone'] = (int)$this->id_zone; $fields['price'] = (float)$this->price; - + return $fields; - } + } } diff --git a/controllers/admin/AdminDeliverySlipController.php b/controllers/admin/AdminDeliverySlipController.php index eb3ad2516..089255fd2 100644 --- a/controllers/admin/AdminDeliverySlipController.php +++ b/controllers/admin/AdminDeliverySlipController.php @@ -30,6 +30,7 @@ class AdminDeliverySlipControllerCore extends AdminController public function __construct() { $this->table = 'delivery'; + $this->context = Context::getContext(); $this->options = array( @@ -59,7 +60,10 @@ class AdminDeliverySlipControllerCore extends AdminController public function initForm() { $this->fields_form = array( - 'title' => $this->l('Print PDF delivery slips'), + 'legend' => array( + 'title' => $this->l('Print PDF delivery slips'), + 'image' => '../img/t/AdminPDF.gif' + ), 'input' => array( array( 'type' => 'text', @@ -90,11 +94,13 @@ class AdminDeliverySlipControllerCore extends AdminController 'date_from' => date('Y-m-d'), 'date_to' => date('Y-m-d') ); + + return parent::initForm(); } public function postProcess() { - if (Tools::isSubmit('submitPrint')) + if (Tools::isSubmit('submitAdddelivery')) { if (!Validate::isDate(Tools::getValue('date_from'))) $this->_errors[] = Tools::displayError('Invalid from date'); @@ -115,24 +121,14 @@ class AdminDeliverySlipControllerCore extends AdminController public function initContent() { - $this->initForm(); - $helper = new HelperForm(); - $helper->override_folder = $this->tpl_folder; - $helper->currentIndex = self::$currentIndex; - $helper->token = $this->token; - $helper->table = $this->table; - $helper->identifier = $this->identifier; - $helper->languages = $this->_languages; - $helper->submit_action = 'submitPrint'; - $helper->no_back = true; - $helper->default_form_language = $this->default_form_language; - $helper->allow_employee_form_lang = $this->allow_employee_form_lang; - $helper->fields_value = $this->fields_value; - $this->content .= $helper->generateForm($this->fields_form); + $this->content .= $this->initForm().'
'; + $this->content .= $this->initOptions(); - parent::initContent(); + $this->context->smarty->assign(array( + 'content' => $this->content, + 'url_post' => self::$currentIndex.'&token='.$this->token, + )); } - }