From 611b4f7bdee3298f5ded788216b59dd69c54ccf0 Mon Sep 17 00:00:00 2001 From: lLefevre Date: Fri, 18 Nov 2011 10:51:27 +0000 Subject: [PATCH] //fix change initForm() method in AdminSlipController git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@10255 b9a71923-0436-4b27-9f14-aed3839534dd --- admin-dev/themes/template/slip/content.tpl | 48 ------- admin-dev/themes/template/slip/form.tpl | 47 +++++++ controllers/admin/AdminSlipController.php | 155 ++++++++++++--------- 3 files changed, 137 insertions(+), 113 deletions(-) delete mode 100644 admin-dev/themes/template/slip/content.tpl create mode 100644 admin-dev/themes/template/slip/form.tpl diff --git a/admin-dev/themes/template/slip/content.tpl b/admin-dev/themes/template/slip/content.tpl deleted file mode 100644 index 2ce6b1f8d..000000000 --- a/admin-dev/themes/template/slip/content.tpl +++ /dev/null @@ -1,48 +0,0 @@ -{* -* 2007-2011 PrestaShop -* -* NOTICE OF LICENSE -* -* This source file is subject to the Academic Free License (AFL 3.0) -* that is bundled with this package in the file LICENSE.txt. -* It is also available through the world-wide-web at this URL: -* http://opensource.org/licenses/afl-3.0.php -* If you did not receive a copy of the license and are unable to -* obtain it through the world-wide-web, please send an email -* to license@prestashop.com so we can send you a copy immediately. -* -* DISCLAIMER -* -* Do not edit or add to this file if you wish to upgrade PrestaShop to newer -* versions in the future. If you wish to customize PrestaShop for your -* needs please refer to http://www.prestashop.com for more information. -* -* @author PrestaShop SA -* @copyright 2007-2011 PrestaShop SA -* @version Release: $Revision$ -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*} - -{$content} - -

{l s='Print PDF'}

-
{l s='By date'} -
- -
- * -

{l s='Format: 2007-12-31 (inclusive)'}

-
- -
- * -

{l s='Format: 2008-12-31 (inclusive)'}

-
-
- -
-
-
- - diff --git a/admin-dev/themes/template/slip/form.tpl b/admin-dev/themes/template/slip/form.tpl new file mode 100644 index 000000000..3fa2a8a1f --- /dev/null +++ b/admin-dev/themes/template/slip/form.tpl @@ -0,0 +1,47 @@ +{* +* 2007-2011 PrestaShop +* +* NOTICE OF LICENSE +* +* This source file is subject to the Academic Free License (AFL 3.0) +* that is bundled with this package in the file LICENSE.txt. +* It is also available through the world-wide-web at this URL: +* http://opensource.org/licenses/afl-3.0.php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to license@prestashop.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade PrestaShop to newer +* versions in the future. If you wish to customize PrestaShop for your +* needs please refer to http://www.prestashop.com for more information. +* +* @author PrestaShop SA +* @copyright 2007-2011 PrestaShop SA +* @version Release: $Revision: 8971 $ +* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*} +{extends file="helper/form/form.tpl"} + +{block name=script} + + $(document).ready(function() { + var btn_save_date = $('span[class~="process-icon-save-date"]').parent(); + var btn_submit_date = $('#submitPrint'); + + if (btn_save_date.length > 0 && btn_submit_date.length > 0) + { + btn_submit_date.hide(); + btn_save_date.find('span').removeClass('process-icon-save-date'); + btn_save_date.find('span').addClass('process-icon-save-calendar'); + btn_save_date.click(function() { + btn_submit_date.before(''); + + $('#order_slip_form').submit(); + }); + } + }); + +{/block} \ No newline at end of file diff --git a/controllers/admin/AdminSlipController.php b/controllers/admin/AdminSlipController.php index f25371ab0..69dcedbd6 100644 --- a/controllers/admin/AdminSlipController.php +++ b/controllers/admin/AdminSlipController.php @@ -30,98 +30,123 @@ class AdminSlipControllerCore extends AdminController public function __construct() { $this->table = 'order_slip'; - $this->className = 'OrderSlip'; - $this->addRowAction('edit'); - $this->addRowAction('delete'); - $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'))); - unset($this->toolbar_btn['new']); + $this->className = 'OrderSlip'; - $this->fieldsDisplay = array( - 'id_order_slip' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), - 'id_order' => array('title' => $this->l('ID Order'), 'width' => 75, 'align' => 'center'), - 'date_add' => array('title' => $this->l('Date issued'), 'width' => 60, 'type' => 'date', 'align' => 'right')); + $this->fieldsDisplay = array( + 'id_order_slip' => array( + 'title' => $this->l('ID'), + 'align' => 'center', + 'width' => 25 + ), + 'id_order' => array( + 'title' => $this->l('ID Order'), + 'width' => 75, + 'align' => 'center' + ), + 'date_add' => array( + 'title' => $this->l('Date issued'), + 'width' => 60, + 'type' => 'date', + 'align' => 'right' + ) + ); $this->optionTitle = $this->l('Slip'); parent::__construct(); } + public function initList() + { + $this->addRowAction('edit'); + $this->addRowAction('delete'); + $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'))); + + return parent::initList(); + } + + public function initForm() + { + $this->fields_form = array( + 'legend' => array( + 'title' => $this->l('Print a PDF'), + 'image' => '../img/admin/pdf.gif' + ), + 'input' => array( + array( + 'type' => 'text', + 'label' => $this->l('From:'), + 'name' => 'date_from', + 'size' => 20, + 'maxlength' => 10, + 'required' => true, + 'p' => $this->l('Format: 2007-12-31 (inclusive)') + ), + array( + 'type' => 'text', + 'label' => $this->l('To:'), + 'name' => 'date_to', + 'size' => 20, + 'maxlength' => 10, + 'required' => true, + 'p' => $this->l('Format: 2008-12-31 (inclusive)') + ) + ), + 'submit' => array( + 'title' => $this->l('Generate PDF file'), + 'class' => 'button', + 'id' => 'submitPrint' + ) + ); + + $this->fields_value = array( + 'date_from' => date('Y-m-d'), + 'date_to' => date('Y-m-d') + ); + + $this->show_toolbar = false; + return parent::initForm(); + } + public function postProcess() { - if (Tools::isSubmit('submitPrint')) + if (Tools::getValue('submitAddorder_slip')) { if (!Validate::isDate(Tools::getValue('date_from'))) $this->_errors[] = $this->l('Invalid from date'); if (!Validate::isDate(Tools::getValue('date_to'))) $this->_errors[] = $this->l('Invalid end date'); - if (!sizeof($this->_errors)) + if (!count($this->_errors)) { - $orderSlips = OrderSlip::getSlipsIdByDate(Tools::getValue('date_from'), Tools::getValue('date_to')); - if (count($orderSlips)) - Tools::redirectAdmin('pdf.php?slips&date_from='.urlencode(Tools::getValue('date_from')).'&date_to='.urlencode(Tools::getValue('date_to')).'&token='.$this->token); + $order_slips = OrderSlip::getSlipsIdByDate(Tools::getValue('date_from'), Tools::getValue('date_to')); + if (count($order_slips)) + Tools::redirectAdmin( + 'pdf.php?slips&date_from='.urlencode(Tools::getValue('date_from')).'&date_to='.urlencode(Tools::getValue('date_to')).'&token='.$this->token); $this->_errors[] = $this->l('No order slips found for this period'); } } - return parent::postProcess(); + else + return parent::postProcess(); } public function initContent() { + $this->initToolbar(); + $this->content .= $this->initList(); + $this->content .= $this->initForm(); + $this->context->smarty->assign(array( - 'date' => date('Y-m-d'), + 'content' => $this->content, + 'url_post' => self::$currentIndex.'&token='.$this->token, )); - - parent::initContent(); } -/* public function display() + public function initToolbar() { - echo '
'; - $this->getList($this->context->language->id, !Tools::getValue($this->table.'Orderby') ? 'date_add' : NULL, !Tools::getValue($this->table.'Orderway') ? 'DESC' : NULL); - $this->displayList(); - echo '
'; - - echo ' -
'.$this->l('Print PDF').' -
- -
- -

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

-
- -
- -

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

-
-
- -
-
-
 
'; + $this->toolbar_btn['save-date'] = array( + 'href' => '#', + 'desc' => $this->l('Generate PDF file') + ); } -*/ -/* public function displayListContent($token = NULL) - { - $irow = 0; - if ($this->_list) - foreach ($this->_list AS $tr) - { - $tr['id_order'] = $this->l('#').sprintf('%06d', $tr['id_order']); - echo ''; - echo ''; - foreach ($this->fieldsDisplay AS $key => $params) - echo ''.$tr[$key].''; - echo ''; - echo ' - - '.$this->l('View').''; - echo ' - - '.$this->l('Delete').''; - echo ''; - echo ''; - } - }*/ }