// fix bug controller AdminDeliverySlipController (PSFV-94)
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@10075 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -1,104 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 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/osl-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 <contact@prestashop.com>
|
||||
* @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 = '
|
||||
<h2>'.$this->l('Print PDF delivery slips').'</h2>
|
||||
<fieldset>
|
||||
<form action="'.self::$currentIndex.'&submitPrint=1&token='.$this->token.'" method="post">
|
||||
<label>'.$this->l('From:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="4" maxlength="10" name="date_from" value="'.(date('Y-m-d')).'" style="width: 120px;" /> <sup>*</sup>
|
||||
<p class="clear">'.$this->l('Format: 2007-12-31 (inclusive)').'</p>
|
||||
</div>
|
||||
<label>'.$this->l('To:').' </label>
|
||||
<div class="margin-form">
|
||||
<input type="text" size="4" maxlength="10" name="date_to" value="'.(date('Y-m-d')).'" style="width: 120px;" /> <sup>*</sup>
|
||||
<p class="clear">'.$this->l('Format: 2008-12-31 (inclusive)').'</p>
|
||||
</div>
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l('Generate PDF file').'" name="submitPrint" class="button" />
|
||||
</div>
|
||||
<div class="small"><sup>*</sup> '.$this->l('Required fields').'</div>
|
||||
</form>
|
||||
</fieldset>';
|
||||
|
||||
echo $output;
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
$this->displayForm();
|
||||
echo '<br />';
|
||||
$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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+27
-15
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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().'<br />';
|
||||
$this->content .= $this->initOptions();
|
||||
|
||||
parent::initContent();
|
||||
$this->context->smarty->assign(array(
|
||||
'content' => $this->content,
|
||||
'url_post' => self::$currentIndex.'&token='.$this->token,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user