// stock management : Bugs fix after rename and historization modifications

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@10131 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
dSevere
2011-11-15 14:05:57 +00:00
parent b9ee33bdcb
commit ac8177b68c
5 changed files with 416 additions and 85 deletions
@@ -30,17 +30,17 @@
<p>&nbsp;</p>
<input type="hidden" id="product_ids" name="product_ids" value="{$product_ids}" />
<input type="hidden" name="updatesupplier_order" value="1" />
<input type="hidden" name="updatesupply_order" value="1" />
<fieldset>
<legend>
<img alt="Supplier Order Management" src="../img/admin/edit.gif">
<img alt="Supply Order Management" src="../img/admin/edit.gif">
{l s='Manage the products you want to order from your supplier'}
</legend>
<p class="clear">{l s='To add a product to the order, type the first letters of the product name, then select the it from the drop-down list:'}</p>
<input type="text" size="100" id="cur_product_name" />
<span onclick="addProduct();" style="cursor: pointer;"><img src="../img/admin/add.gif" alt="{l s='Add a product to the supplier order'}" title="{l s='Add a product to the supplier order'}" /></span>
<span onclick="addProduct();" style="cursor: pointer;"><img src="../img/admin/add.gif" alt="{l s='Add a product to the supply order'}" title="{l s='Add a product to the supply order'}" /></span>
<p>&nbsp;</p>
@@ -48,7 +48,7 @@
<tr>
<td>
<table
id="products_in_supplier_order"
id="products_in_supply_order"
class="table"
cellpadding="0" cellspacing="0"
style="width: 100%; margin-bottom:10px;"
@@ -73,7 +73,7 @@
{$product.reference}
<input type="hidden" name="input_check_{$product.id_product}_{$product.id_product_attribute}" value="{$product.checksum}" />
<input type="hidden" name="input_reference_{$product.id_product}_{$product.id_product_attribute}" value="{$product.reference}" />
<input type="hidden" name="input_id_{$product.id_product}_{$product.id_product_attribute}" value="{$product.id_supplier_order_detail}" />
<input type="hidden" name="input_id_{$product.id_product}_{$product.id_product_attribute}" value="{$product.id_supply_order_detail}" />
</td>
<td>
{$product.ean13}
@@ -100,7 +100,7 @@
<input type="text" name="input_tax_rate_{$product.id_product}_{$product.id_product_attribute}" value="{round($product.tax_rate, 4)}" size="5" />%
</td>
<td class="center">
<a href="#" id="deletelink|{$product.id_product}_{$product.id_product_attribute}" class="removeProductFromSupplierOrderLink">
<a href="#" id="deletelink|{$product.id_product}_{$product.id_product_attribute}" class="removeProductFromSupplyOrderLink">
<img src="../img/admin/delete.gif" alt="{l s='Remove this product from the order'}" title="{l s='Remove this product from the order'}" />
</a>
</td>
@@ -132,7 +132,7 @@
}
// add a new line in the products table
$('#products_in_supplier_order > tbody:last').append(
$('#products_in_supply_order > tbody:last').append(
'<tr style="height:50px;">'+
'<td>'+product_infos.reference+'<input type="hidden" name="input_check_'+product_infos.id+'" value="'+product_infos.checksum+'" /><input type="hidden" name="input_name_'+product_infos.id+'" value="'+product_infos.reference+'" /></td>'+
'<td>'+product_infos.ean13+'<input type="hidden" name="input_ean13_'+product_infos.id+'" value="'+product_infos.ean13+'" /></td>'+
@@ -142,7 +142,7 @@
'<td class="center"><input type="text" name="input_quantity_expected_'+product_infos.id+'" value="0" size="5" /></td>'+
'<td class="center"><input type="text" name="input_discount_rate_'+product_infos.id+'" value="0" size="5" />%</td>'+
'<td class="center"><input type="text" name="input_tax_rate_'+product_infos.id+'" value="0" size="5" />%</td>'+
'<td class="center"><a href="#" class="removeProductFromSupplierOrderLink" id="deletelink|'+product_infos.id+'">'+
'<td class="center"><a href="#" class="removeProductFromSupplyOrderLink" id="deletelink|'+product_infos.id+'">'+
'<img src="../img/admin/delete.gif" alt="{l s="Remove this product from the order"}" title="{l s="Remove this product from the order"}" />'+
'</a></td></tr>'
);
@@ -163,7 +163,7 @@
/* function autocomplete */
$(function() {
// add click event on just created delete item link
$('a.removeProductFromSupplierOrderLink').live('click', function() {
$('a.removeProductFromSupplyOrderLink').live('click', function() {
var id = $(this).attr('id');
var product_id = id.split('|')[1];
@@ -192,7 +192,7 @@
btn_save = $('span[class~="process-icon-save"]').parent();
btn_save.click(function() {
$('#supplier_order_form').submit();
$('#supply_order_form').submit();
});
// bind enter key event on search field
@@ -0,0 +1,125 @@
{*
* 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 <contact@prestashop.com>
* @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
*}
<script type="text/javascript">
$(document).ready(function() {
$('#details_{$id}').click(function() {
if (typeof(this.dataMaped) == 'undefined') {
$.ajax({
url: 'index.php',
data: {
id_supply_order_detail: '{$id}',
controller: '{$controller}',
token: '{$token}',
action: '{$action}',
ajax: true
},
context: document.body,
dataType: 'json',
context: this,
async: false,
success: function(data) {
if (typeof(data.use_parent_structure) == 'undefined' || (data.use_parent_structure == true))
{
if ($('#details_{$id}').parent().parent().hasClass('alt_row'))
var alt_row = true;
else
var alt_row = false;
$('#details_{$id}').parent().parent().after($('<tr class="details_{$id} small '+(alt_row ? 'alt_row' : '')+'"></tr>')
.append($('<td style="border:none!important;" class="empty"></td>')
.attr('colspan', $('#details_{$id}').parent().parent().find('td').length)));
$.each(data.data, function(it, row)
{
var content = $('<tr class="action_details details_{$id} '+(alt_row ? 'alt_row' : '')+'"></tr>');
content.append($('<td class="empty"></td>'));
var first = true;
var count = 0; // Number of non-empty collum
$.each(row, function(it)
{
if(typeof(data.fields_display[it]) != 'undefined')
count++;
});
$.each(data.fields_display, function(it, line)
{
if (typeof(row[it]) == 'undefined')
{
if (first || count == 0)
content.append($('<td class="'+this.align+' empty"></td>'));
else
content.append($('<td class="'+this.align+'"></td>'));
}
else
{
count--;
if (first)
{
first = false;
content.append($('<td class="'+this.align+' first">'+row[it]+'</td>'));
}
else if (count == 0)
content.append($('<td class="'+this.align+' last">'+row[it]+'</td>'));
else
content.append($('<td class="'+this.align+' '+count+'">'+row[it]+'</td>'));
}
});
content.append($('<td class="empty"></td>'));
$('#details_{$id}').parent().parent().after(content);
});
}
else
{
if ($('#details_{$id}').parent().parent().hasClass('alt_row'))
var content = $('<tr class="details_{$id} alt_row"></tr>');
else
var content = $('<tr class="details_{$id}"></tr>');
content.append($('<td style="border:none!important;">'+data.data+'</td>').attr('colspan', $('#details_{$id}').parent().parent().find('td').length));
$('#details_{$id}').parent().parent().after(content);
}
this.dataMaped = true;
this.opened = false;
initTableDnD('.details_{$id} table.tableDnD');
}
});
}
if (this.opened)
{
$(this).find('img').attr('src', '../img/admin/more.png');
$(this).parent().parent().parent().find('.details_{$id}').hide();
this.opened = false
}
else
{
$(this).find('img').attr('src', '../img/admin/less.png');
$(this).parent().parent().parent().find('.details_{$id}').show();
this.opened = true;
}
return false;
});
});
</script>
<a href="#" id="details_{$id}">
<img src="../img/admin/more.png" alt="{$action}" title="{$action}" />
</a>
+5 -4
View File
@@ -258,7 +258,7 @@ class SupplyOrderCore extends ObjectModel
$query->select('
s.*,
IFNULL(CONCAT(pl.name, \' : \', GROUP_CONCAT(agl.name, \' - \', al.name SEPARATOR \', \')), pl.name) as name,
IFNULL(CONCAT(pl.name, \' : \', GROUP_CONCAT(agl.name, \' - \', al.name SEPARATOR \', \')), pl.name) as name_displayed,
p.reference as reference,
p.ean13 as ean13');
@@ -369,12 +369,13 @@ class SupplyOrderCore extends ObjectModel
*/
protected function addHistory()
{
$context = Context::getContext();
$history = new SupplyOrderHistory();
$history->id_supply_order = $this->id;
$history->id_state = $this->id_supply_order_state;
$history->id_employee = (int)$this->context->employee->id;
$history->employee_firstname = pSQL($this->context->employee->firstname);
$history->employee_lastname = pSQL($this->context->employee->lastname);
$history->id_employee = (int)$context->employee->id;
$history->employee_firstname = pSQL($context->employee->firstname);
$history->employee_lastname = pSQL($context->employee->lastname);
$history->save();
}
@@ -0,0 +1,215 @@
<?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: 7300 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
class AdminSuppliersControllerCore extends AdminController
{
public function __construct()
{
$this->table = 'supplier';
$this->className = 'Supplier';
$this->addRowAction('view');
$this->addRowAction('edit');
$this->addRowAction('delete');
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?')));
$this->_select = 'COUNT(p.`id_product`) AS products';
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'product` p ON (a.`id_supplier` = p.`id_supplier`)';
$this->_group = 'GROUP BY a.`id_supplier`';
$this->fieldImageSettings = array('name' => 'logo', 'dir' => 'su');
$this->fieldsDisplay = array(
'id_supplier' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
'logo' => array('title' => $this->l('Logo'), 'width' => 150, 'align' => 'center', 'image' => 'su', 'orderby' => false, 'search' => false),
'name' => array('title' => $this->l('Name'), 'width' => 'auto'),
'products' => array('title' => $this->l('Number of products'), 'width' => 70, 'align' => 'right', 'filter_type' => 'int', 'tmpTableFilter' => true),
'active' => array('title' => $this->l('Enabled'), 'width' => 70, 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false)
);
parent::__construct();
}
public function initForm()
{
$this->fields_form = array(
'legend' => array(
'title' => $this->l('Suppliers'),
'image' => '../img/admin/suppliers.gif'
),
'input' => array(
array(
'type' => 'text',
'label' => $this->l('Name:'),
'name' => 'name',
'size' => 40,
'required' => true,
'hint' => $this->l('Invalid characters:').' <>;=#{}',
),
array(
'type' => 'text',
'label' => $this->l('Description:'),
'name' => 'description',
'size' => 33,
'lang' => true,
'hint' => $this->l('Invalid characters:').' <>;=#{}',
'p' => $this->l('Will appear in supplier list')
),
array(
'type' => 'file',
'label' => $this->l('Logo:'),
'name' => 'logo',
'display_image' => true,
'p' => $this->l('Upload supplier logo from your computer')
),
array(
'type' => 'text',
'label' => $this->l('Meta title:'),
'name' => 'smeta_title',
'lang' => true,
'hint' => $this->l('Forbidden characters:').' <>;=#{}'
),
array(
'type' => 'text',
'label' => $this->l('Meta description:'),
'name' => 'meta_description',
'lang' => true,
'hint' => $this->l('Forbidden characters:').' <>;=#{}'
),
array(
'type' => 'text',
'label' => $this->l('Meta keywords:'),
'name' => 'meta_keywords',
'lang' => true,
'hint' => $this->l('Forbidden characters:').' <>;=#{}'
),
array(
'type' => 'radio',
'label' => $this->l('Enable:'),
'name' => 'active',
'required' => false,
'class' => 't',
'is_bool' => true,
'values' => array(
array(
'id' => 'active_on',
'value' => 1,
'label' => $this->l('Enabled')
),
array(
'id' => 'active_off',
'value' => 0,
'label' => $this->l('Disabled')
)
)
)
),
'submit' => array(
'title' => $this->l(' Save '),
'class' => 'button'
)
);
if (Shop::isFeatureActive())
{
$this->fields_form['input'][] = array(
'type' => 'group_shop',
'label' => $this->l('Shop association:'),
'name' => 'checkBoxShopAsso',
'values' => Shop::getTree()
);
}
// Set logo image
$image = cacheImage(_PS_SUPP_IMG_DIR_.'/'.$this->object->id.'.jpg', $this->table.'_'.(int)$this->object->id.'.'.$this->imageType, 350, $this->imageType, true);
$this->fields_value = array(
'image' => $image ? $image : false,
'size' => $image ? filesize(_PS_SUPP_IMG_DIR_.'/'.$this->object->id.'.jpg') / 1000 : false
);
return parent::initForm();
}
public function initView()
{
$products = $this->object->getProductsLite($this->context->language->id);
$total_product = count($products);
for ($i = 0; $i < $total_product; $i++)
{
$products[$i] = new Product($products[$i]['id_product'], false, $this->context->language->id);
// Build attributes combinaisons
$combinaisons = $products[$i]->getAttributeCombinaisons($this->context->language->id);
foreach ($combinaisons as $k => $combinaison)
{
$comb_array[$combinaison['id_product_attribute']]['reference'] = $combinaison['reference'];
$comb_array[$combinaison['id_product_attribute']]['ean13'] = $combinaison['ean13'];
$comb_array[$combinaison['id_product_attribute']]['upc'] = $combinaison['upc'];
$comb_array[$combinaison['id_product_attribute']]['quantity'] = $combinaison['quantity'];
$comb_array[$combinaison['id_product_attribute']]['attributes'][] = array(
$combinaison['group_name'],
$combinaison['attribute_name'],
$combinaison['id_attribute']
);
}
if (isset($comb_array))
{
foreach ($comb_array as $key => $product_attribute)
{
$list = '';
foreach ($product_attribute['attributes'] as $attribute)
$list .= $attribute[0].' - '.$attribute[1].', ';
$comb_array[$key]['attributes'] = rtrim($list, ', ');
}
isset($comb_array) ? $products[$i]->combinaison = $comb_array : '';
unset($comb_array);
}
}
$this->context->smarty->assign(array(
'supplier' => $this->object,
'products' => $products,
'stock_management' => Configuration::get('PS_STOCK_MANAGEMENT'),
));
}
public function afterImageUpload()
{
/* Generate image with differents size */
if (($id_supplier = (int)(Tools::getValue('id_supplier'))) AND isset($_FILES) AND count($_FILES) AND file_exists(_PS_SUPP_IMG_DIR_.$id_supplier.'.jpg'))
{
$imagesTypes = ImageType::getImagesTypes('suppliers');
foreach ($imagesTypes AS $k => $imageType)
{
$file = _PS_SUPP_IMG_DIR_.$id_supplier.'.jpg';
imageResize($file, _PS_SUPP_IMG_DIR_.$id_supplier.'-'.stripslashes($imageType['name']).'.jpg', (int)($imageType['width']), (int)($imageType['height']));
}
}
}
}
@@ -523,10 +523,6 @@ class AdminSupplyOrdersControllerCore extends AdminController
'width' => 120,
'havingFilter' => true
),
/*'employee' => array(
'title' => $this->l('Employee'),
'havingFilter' => true
),*/
'supplier' => array(
'title' => $this->l('Supplier'),
'width' => 200,
@@ -780,15 +776,7 @@ class AdminSupplyOrdersControllerCore extends AdminController
// re-defines fieldsDisplay
$this->fieldsDisplay = array(
'id' => array(
'title' => $this->l('ID'),
'align' => 'center',
'width' => 20,
'orderby' => false,
'filter' => false,
'search' => false,
),
'p_reference' => array(
'reference' => array(
'title' => $this->l('Reference'),
'align' => 'center',
'width' => 30,
@@ -796,7 +784,7 @@ class AdminSupplyOrdersControllerCore extends AdminController
'filter' => false,
'search' => false,
),
'p_ean13' => array(
'ean13' => array(
'title' => $this->l('EAN13'),
'align' => 'center',
'width' => 30,
@@ -804,6 +792,14 @@ class AdminSupplyOrdersControllerCore extends AdminController
'filter' => false,
'search' => false,
),
'upc' => array(
'title' => $this->l('UPC'),
'align' => 'center',
'width' => 30,
'orderby' => false,
'filter' => false,
'search' => false,
),
'p_name' => array(
'title' => $this->l('Name'),
'align' => 'center',
@@ -860,41 +856,40 @@ class AdminSupplyOrdersControllerCore extends AdminController
// sets toolbar title with order reference
$this->toolbar_title = sprintf($this->l('Reception of products for supply order #%s'), $supply_order->reference);
// gets lang info
$this->lang = false;
$lang_id = (int)$this->context->language->id;
$lang_id = (int)$this->context->language->id; //employee lang
// gets values corresponding to fieldsDisplay
$this->_select = '
a.id_supply_order_detail as id,
a.quantity_received as quantity_received,
a.quantity_expected as quantity_expected,
IF (a.quantity_expected < a.quantity_received, 0, a.quantity_expected - a.quantity_received) as quantity_left,
IF (a.quantity_expected < a.quantity_received, 0, a.quantity_expected - a.quantity_received) as quantity_received_today,
IFNULL(CONCAT(pl.name, \' : \', GROUP_CONCAT(agl.name, \' - \', al.name SEPARATOR \', \')), pl.name) as p_name,
p.reference as p_reference,
p.ean13 as p_ean13';
a.id_supply_order_detail as id,
a.quantity_received as quantity_received,
a.quantity_expected as quantity_expected,
IF (a.quantity_expected < a.quantity_received, 0, a.quantity_expected - a.quantity_received) as quantity_left,
IF (a.quantity_expected < a.quantity_received, 0, a.quantity_expected - a.quantity_received) as quantity_received_today,
IFNULL(CONCAT(pl.name, \' : \', GROUP_CONCAT(agl.name, \' - \', al.name SEPARATOR \', \')), pl.name) as p_name';
$this->_join = '
INNER JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = a.id_product AND pl.id_lang = '.$lang_id.')
LEFT JOIN '._DB_PREFIX_.'product p ON (p.id_product = a.id_product)
LEFT JOIN '._DB_PREFIX_.'product_attribute_combination pac ON (pac.id_product_attribute = a.id_product_attribute)
LEFT JOIN '._DB_PREFIX_.'attribute atr ON (atr.id_attribute = pac.id_attribute)
LEFT JOIN '._DB_PREFIX_.'attribute_lang al ON (al.id_attribute = atr.id_attribute AND al.id_lang = '.$lang_id.')
LEFT JOIN '._DB_PREFIX_.'attribute_group_lang agl ON (agl.id_attribute_group = atr.id_attribute_group AND agl.id_lang = '.$lang_id.')';
INNER JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = a.id_product AND pl.id_lang = '.$lang_id.')
LEFT JOIN '._DB_PREFIX_.'product_attribute_combination pac ON (pac.id_product_attribute = a.id_product_attribute)
LEFT JOIN '._DB_PREFIX_.'attribute atr ON (atr.id_attribute = pac.id_attribute)
LEFT JOIN '._DB_PREFIX_.'attribute_lang al ON (al.id_attribute = atr.id_attribute AND al.id_lang = '.$lang_id.')
LEFT JOIN '._DB_PREFIX_.'attribute_group_lang agl ON (agl.id_attribute_group = atr.id_attribute_group AND agl.id_lang = '.$lang_id.')';
$this->_where = 'AND a.`id_supply_order` = '.(int)$id_supply_order;
$this->_group = 'GROUP BY a.id_supply_order_detail';
// gets the list ordered by price desc, without limit
$this->getList($lang_id, 'quantity_expected', 'DESC', 0, false, false);
// defines action for POST
$action = '&id_supply_order='.$id_supply_order.'&submitUpdateReceipt';
$action = '&id_supply_order='.$id_supply_order;
// renders list
$helper = new HelperList();
$this->setHelperDisplay($helper);
$helper->override_folder = 'supply_orders_receipt_history/';
//$helper->shopLinkType = '';
$helper->currentIndex = self::$currentIndex.$action;
// display these global order informations
@@ -940,14 +935,12 @@ class AdminSupplyOrdersControllerCore extends AdminController
{
// load supply order
$id_supply_order = (int)Tools::getValue('id_supply_order', null);
$products_already_in_order = array();
if ($id_supply_order != null)
{
$supply_order = new SupplyOrder($id_supply_order);
$products_already_in_order = $supply_order->getEntries();
$currency = new Currency($supply_order->id_ref_currency);
if (Validate::isLoadedObject($supply_order))
{
// tests if the supplier or currency have changed in the supply order
@@ -962,6 +955,9 @@ class AdminSupplyOrdersControllerCore extends AdminController
}
else
{
$products_already_in_order = $supply_order->getEntries();
$currency = new Currency($supply_order->id_ref_currency);
// gets all product ids to manage
$product_ids_str = Tools::getValue('product_ids', null);
$product_ids = explode('|', $product_ids_str);
@@ -1147,8 +1143,11 @@ class AdminSupplyOrdersControllerCore extends AdminController
// if state is valid, change it in the order
if ($id_state == $state['id_supply_order_state'])
{
// special case of validate state - check if there are products in the order
if ($supply_order->isEditable() && !$supply_order->hasEntries())
$new_state = new SupplyOrderState($id_state);
// special case of validate state - check if there are products in the order and the required state is not an enclosed state
if ($supply_order->isEditable() && !$supply_order->hasEntries() && !$new_state->enclosed)
$this->_errors[] = Tools::displayError(
$this->l('It is not possible to change the state of this order because of no product are present in it')
);
@@ -1171,7 +1170,7 @@ class AdminSupplyOrdersControllerCore extends AdminController
}
}
if (Tools::isSubmit('submitUpdateReceipt') && Tools::isSubmit('id_supply_order'))
if (Tools::isSubmit('submitBulkUpdatesupply_order_detail') && Tools::isSubmit('id_supply_order'))
$this->postProcessUpdateReceipt();
parent::postProcess();
@@ -1184,6 +1183,7 @@ class AdminSupplyOrdersControllerCore extends AdminController
*/
protected function postProcessUpdateReceipt()
{
trace('test');
// gets all box selected
$rows = Tools::getValue('supply_order_detailBox');
if (!$rows)
@@ -1363,7 +1363,7 @@ class AdminSupplyOrdersControllerCore extends AdminController
unset($this->_select, $this->_join, $this->_where, $this->_orderBy, $this->_orderWay, $this->_group, $this->_filterHaving, $this->_filter);
$this->_select = '
a.`date_add` as history_date,
CONCAT(e.`lastname`, \' \', e.`firstname`) as history_employee,
CONCAT(a.`employee_lastname`, \' \', a.`employee_firstname`) as history_employee,
sosl.`name` as history_state_name,
sos.`color` as color';
@@ -1373,8 +1373,7 @@ class AdminSupplyOrdersControllerCore extends AdminController
(
a.`id_state` = sosl.`id_supply_order_state`
AND sosl.`id_lang` = '.(int)$lang_id.'
)
LEFT JOIN `'._DB_PREFIX_.'employee` e ON (e.`id_employee` = a.`id_employee`)';
)';
$this->_where = 'AND a.`id_supply_order` = '.(int)$id_supply_order;
$this->_orderBy = 'a.`date_add`';
@@ -1430,8 +1429,7 @@ class AdminSupplyOrdersControllerCore extends AdminController
// loads history of the given order
unset($this->_select, $this->_join, $this->_where, $this->_orderBy, $this->_orderWay, $this->_group, $this->_filterHaving, $this->_filter);
$this->_select = 'CONCAT(e.`lastname`, \' \', e.`firstname`) as employee';
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'employee` e ON (e.`id_employee` = a.`id_employee`)';
$this->_select = 'CONCAT(a.`employee_lastname`, \' \', a.`employee_firstname`) as employee';
$this->_where = 'AND a.`id_supply_order_detail` = '.(int)$id_supply_order_detail;
// gets list and forces no limit clause in the request
@@ -1469,45 +1467,30 @@ class AdminSupplyOrdersControllerCore extends AdminController
$this->lang = false;
$this->list_simple_header = true;
$this->list_no_link = true;
$lang_id = (int)$this->context->language->id;
// gets the id supplier to view
$id_supply_order = (int)Tools::getValue('id_supply_order');
// just in case..
unset($this->_select, $this->_join, $this->_where, $this->_orderBy, $this->_orderWay, $this->_group, $this->_filterHaving, $this->_filter);
// gets all information on the products ordered
$this->_select = '
IFNULL(CONCAT(pl.name, \' : \', GROUP_CONCAT(agl.name, \' - \', al.name SEPARATOR \', \')), pl.name) as p_name,
p.reference as p_reference,
p.ean13 as p_ean13';
$this->_join = '
INNER JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = a.id_product AND pl.id_lang = '.$lang_id.')
LEFT JOIN '._DB_PREFIX_.'product p ON (p.id_product = a.id_product)
LEFT JOIN '._DB_PREFIX_.'product_attribute_combination pac ON (pac.id_product_attribute = a.id_product_attribute)
LEFT JOIN '._DB_PREFIX_.'attribute atr ON (atr.id_attribute = pac.id_attribute)
LEFT JOIN '._DB_PREFIX_.'attribute_lang al ON (al.id_attribute = atr.id_attribute AND al.id_lang = '.$lang_id.')
LEFT JOIN '._DB_PREFIX_.'attribute_group_lang agl ON (agl.id_attribute_group = atr.id_attribute_group AND agl.id_lang = '.$lang_id.')';
$this->_where = 'AND a.`id_supply_order` = '.(int)$id_supply_order;
$this->_group = 'GROUP BY a.id_product';
// gets global order information
$supply_order = new SupplyOrder((int)$id_supply_order);
if (Validate::isLoadedObject($supply_order))
{
$lang_id = (int)$supply_order->id_lang;
// just in case..
unset($this->_select, $this->_join, $this->_where, $this->_orderBy, $this->_orderWay, $this->_group, $this->_filterHaving, $this->_filter);
// gets all information on the products ordered
$this->_where = 'AND a.`id_supply_order` = '.(int)$id_supply_order;
$this->_group = 'GROUP BY a.id_product';
// gets the list ordered by price desc, without limit
$this->getList($lang_id, 'price_te', 'DESC', 0, false, false);
// gets the currency used in this order
$currency = new Currency($supply_order->id_currency);
// gets the employee in charge of the order
$employee = new Employee($supply_order->id_employee);
// gets the warehouse where products will be received
$warehouse = new Warehouse($supply_order->id_warehouse);
@@ -1516,7 +1499,7 @@ class AdminSupplyOrdersControllerCore extends AdminController
// re-defines fieldsDisplay
$this->fieldsDisplay = array(
'p_reference' => array(
'reference' => array(
'title' => $this->l('Reference'),
'align' => 'center',
'width' => 120,
@@ -1524,7 +1507,7 @@ class AdminSupplyOrdersControllerCore extends AdminController
'filter' => false,
'search' => false,
),
'p_ean13' => array(
'ean13' => array(
'title' => $this->l('EAN13'),
'align' => 'center',
'width' => 100,
@@ -1532,7 +1515,15 @@ class AdminSupplyOrdersControllerCore extends AdminController
'filter' => false,
'search' => false,
),
'p_name' => array(
'upc' => array(
'title' => $this->l('UPC'),
'align' => 'center',
'width' => 100,
'orderby' => false,
'filter' => false,
'search' => false,
),
'name' => array(
'title' => $this->l('Name'),
'orderby' => false,
'filter' => false,
@@ -1643,7 +1634,6 @@ class AdminSupplyOrdersControllerCore extends AdminController
// display these global order informations
$this->tpl_view_vars = array(
'supply_order_detail_content' => $content,
'supply_order_employee' => (Validate::isLoadedObject($employee) ? $employee->firstname.' '.$employee->lastname : ''),
'supply_order_warehouse' => (Validate::isLoadedObject($warehouse) ? $warehouse->name : ''),
'supply_order_reference' => $supply_order->reference,
'supply_order_creation_date' => Tools::displayDate($supply_order->date_add, $lang_id, true),