From bc565999d15e7a8aee13480c02877a406af327a3 Mon Sep 17 00:00:00 2001
From: dSevere
Date: Thu, 13 Oct 2011 16:18:09 +0000
Subject: [PATCH] // stock: add warehouse tab and update stock mvt tab
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@9332 b9a71923-0436-4b27-9f14-aed3839534dd
---
admin-dev/tabs/AdminProducts.php | 234 +++++++++++++--------------
admin-dev/tabs/AdminStockMvt.php | 76 ++++-----
admin-dev/tabs/AdminWarehouses.php | 245 +++++++++++++++++++++++++++++
3 files changed, 403 insertions(+), 152 deletions(-)
create mode 100644 admin-dev/tabs/AdminWarehouses.php
diff --git a/admin-dev/tabs/AdminProducts.php b/admin-dev/tabs/AdminProducts.php
index ee9be0dbc..5ddfc11c9 100644
--- a/admin-dev/tabs/AdminProducts.php
+++ b/admin-dev/tabs/AdminProducts.php
@@ -192,8 +192,8 @@ class AdminProducts extends AdminTab
$this->deleteVirtualProduct();
else
$this->_errors[] = Tools::displayError('You do not have permission to delete here.');
- }
- else
+ }
+ else
/* Delete a product in the download folder */
if (Tools::getValue('deleteVirtualProductAttribute'))
{
@@ -479,9 +479,9 @@ class AdminProducts extends AdminTab
{
if (!Combination::isFeatureActive())
return;
-
+
$is_virtual = (int)Tools::getValue('is_virtual');
-
+
if (Validate::isLoadedObject($product = new Product((int)(Tools::getValue('id_product')))))
{
if (!isset($_POST['attribute_price']) || $_POST['attribute_price'] == null)
@@ -577,13 +577,13 @@ class AdminProducts extends AdminTab
if (!sizeof($this->_errors))
{
if (!$product->cache_default_attribute)
- Product::updateDefaultAttribute($product->id);
-
+ Product::updateDefaultAttribute($product->id);
+
if (!empty($is_virtual))
Product::updateIsVirtual($product->id);
-
+
Tools::redirectAdmin(self::$currentIndex.'&id_product='.$product->id.'&id_category='.(!empty($_REQUEST['id_category'])?$_REQUEST['id_category']:'1').'&add'.$this->table.'&tabs=3&token='.($token ? $token : $this->token));
- }
+ }
}
}
}
@@ -596,7 +596,7 @@ class AdminProducts extends AdminTab
if (($id_product = (int)(Tools::getValue('id_product'))) && Validate::isUnsignedId($id_product) && Validate::isLoadedObject($product = new Product($id_product)))
{
$product->deleteAttributeCombinaison(Tools::getValue('id_product_attribute'));
-
+
$id_product_download = ProductDownload::getIdFromIdAttribute((int) $id_product, (int) Tools::getValue('id_product_attribute'));
if ($id_product_download)
{
@@ -934,7 +934,7 @@ class AdminProducts extends AdminTab
die(true);
}
}
-
+
protected function _validateSpecificPrice($id_shop, $id_currency, $id_country, $id_group, $price, $from_quantity, $reduction, $reduction_type, $from, $to)
{
if (!Validate::isUnsignedId($id_shop) || !Validate::isUnsignedId($id_currency) || !Validate::isUnsignedId($id_country) || !Validate::isUnsignedId($id_group))
@@ -1079,7 +1079,7 @@ class AdminProducts extends AdminTab
$saveShort = $_POST['description_short'];
$_POST['description_short'] = strip_tags($_POST['description_short']);
}
-
+
/* Check description short size without html */
$limit = (int)Configuration::get('PS_PRODUCT_SHORT_DESC_LIMIT');
if ($limit <= 0) $limit = 400;
@@ -1273,7 +1273,7 @@ class AdminProducts extends AdminTab
public function updateDownloadProduct($product, $edit = 0, $id_product_attribute = null)
{
$is_virtual_file = (int) Tools::getValue('is_virtual_file');
-
+
/* add or update a virtual product */
if (Tools::getValue('is_virtual_good') == 'true')
{
@@ -1310,10 +1310,10 @@ class AdminProducts extends AdminTab
{
$this->_errors[] = $this->l('the field').' '.$this->l('number of days').' '.$this->l('is required');
return false;
- }
+ }
}
}
-
+
if (Tools::getValue('virtual_product_expiration_date') && !Validate::isDate(Tools::getValue('virtual_product_expiration_date') && !empty($is_virtual_file))
&& Tools::getValue('virtual_product_expiration_date_attribute') && !Validate::isDate(Tools::getValue('virtual_product_expiration_date_attribute')))
{
@@ -1328,50 +1328,50 @@ class AdminProducts extends AdminTab
{
$this->_errors[] = $this->l('the field').' '.$this->l('expiration date').' '.$this->l('is not valid');
return false;
- }
+ }
}
}
-
+
// The oos behavior MUST be "Deny orders" for virtual products
if (Tools::getValue('out_of_stock') != 0)
{
$this->_errors[] = $this->l('The "when out of stock" behavior selection must be "deny order" for virtual products');
return false;
}
-
- // Trick's
+
+ // Trick's
if ($edit == 1)
{
$id_product_download_attibute = ProductDownload::getIdFromIdAttribute((int) $product->id, $id_product_attribute);
$id_product_download = ($id_product_download_attibute) ? (int) $id_product_download_attibute : (int) Tools::getValue('virtual_product_id');
}
-
+
$is_shareable = Tools::getValue('virtual_product_is_shareable');
$virtual_product_name = Tools::getValue('virtual_product_name');
$virtual_product_filename = Tools::getValue('virtual_product_filename');
$virtual_product_nb_days = Tools::getValue('virtual_product_nb_days');
$virtual_product_nb_downloable = Tools::getValue('virtual_product_nb_downloable');
$virtual_product_expiration_date = Tools::getValue('virtual_product_expiration_date');
-
+
$is_shareable_attribute = Tools::getValue('virtual_product_is_shareable_attribute');
$virtual_product_name_attribute = Tools::getValue('virtual_product_name_attribute');
$virtual_product_filename_attribute = Tools::getValue('virtual_product_filename_attribute');
$virtual_product_nb_days_attribute = Tools::getValue('virtual_product_nb_days_attribute');
$virtual_product_nb_downloable_attribute = Tools::getValue('virtual_product_nb_downloable_attribute');
$virtual_product_expiration_date_attribute = Tools::getValue('virtual_product_expiration_date_attribute');
-
+
if (!empty($is_shareable_attribute))
$is_shareable = $is_shareable_attribute;
-
+
if (!empty($virtual_product_name_attribute))
$virtual_product_name = $virtual_product_name_attribute;
-
+
if (!empty($virtual_product_nb_days_attribute))
$virtual_product_nb_days = $virtual_product_nb_days_attribute;
-
+
if (!empty($virtual_product_nb_downloable_attribute))
- $virtual_product_nb_downloable = $virtual_product_nb_downloable_attribute;
-
+ $virtual_product_nb_downloable = $virtual_product_nb_downloable_attribute;
+
if (!empty($virtual_product_expiration_date_attribute))
$virtual_product_expiration_date = $virtual_product_expiration_date_attribute;
@@ -1381,7 +1381,7 @@ class AdminProducts extends AdminTab
$filename = $virtual_product_filename;
else
$filename = ProductDownload::getNewFilename();
-
+
$download = new ProductDownload($id_product_download);
$download->id_product = (int) $product->id;
$download->id_product_attribute = (int) $id_product_attribute;
@@ -1393,7 +1393,7 @@ class AdminProducts extends AdminTab
$download->nb_downloadable = (int) $virtual_product_nb_downloable;
$download->active = 1;
$download->is_shareable = (int) $is_shareable;
-
+
if ($download->save())
return true;
}
@@ -1407,7 +1407,7 @@ class AdminProducts extends AdminTab
}
else
$id_product_download = ProductDownload::getIdFromIdProduct($product->id);
-
+
if (!empty($id_product_download))
{
$productDownload = new ProductDownload($id_product_download);
@@ -1418,7 +1418,7 @@ class AdminProducts extends AdminTab
}
return false;
}
-
+
public function deleteDownloadProduct($id_product_attribute = NULL)
{
if (!empty($id_product_attribute))
@@ -1430,7 +1430,7 @@ class AdminProducts extends AdminTab
}
return false;
}
-
+
/**
* Update product accessories
*
@@ -1493,7 +1493,7 @@ class AdminProducts extends AdminTab
$id_category = 1;
echo ''.(!$this->_listTotal ? ($this->l('No products found')) : ($this->_listTotal.' '.($this->_listTotal > 1 ? $this->l('products') : $this->l('product')))).' ';
////////////////////////
- // @todo lot of ergonomy works around here
+ // @todo lot of ergonomy works around here
echo ''.$this->l('Go to category');
$select_child = ' Jump to ... ';
// @todo : move blockcategories select queries in class Category
@@ -1506,7 +1506,7 @@ class AdminProducts extends AdminTab
$categ = new Category($categ['id_category'],$this->context->language->id);
$select_child .= '_category->id_category == $categ->id ? 'selected="selected" class="selected level-depth-'.$categ->level_depth.'"':'class="level-depth-'.$categ->level_depth.'"') .'>' . str_repeat(' - ',$categ->level_depth). $categ->name .' ('.$categ->id.') ';
}
-
+
$select_child .= ' ';
echo $select_child;
echo '
@@ -2220,7 +2220,7 @@ class AdminProducts extends AdminTab
$hidden = $display_filename = $check = '';
?>
-
+
id || !$productDownload->active)
+ if(!$productDownload->id || !$productDownload->active)
$hidden = 'style="display:none;"';
-
+
$cache_default_attribute = (int)$this->getFieldValue($obj, 'cache_default_attribute');
$is_virtual = (int)$this->getFieldValue($obj, 'is_virtual');
- if($is_virtual && $productDownload->active)
+ if($is_virtual && $productDownload->active)
$check = 'checked="checked"';
- if($productDownload->id)
+ if($productDownload->id)
$virtual = 1;
else
$virtual = 0;
@@ -2664,7 +2664,7 @@ class AdminProducts extends AdminTab
'.$this->l('Does this product has an associated file ?').' ';
$exists_file = realpath(_PS_DOWNLOAD_DIR_).'/'.$productDownload->filename;
-
+
if ($productDownload->id && !empty($cache_default_attribute) || !empty($productDownload->display_filename))
{
$check_yes = 'checked="checked"';
@@ -2675,10 +2675,10 @@ class AdminProducts extends AdminTab
$check_yes = '';
$check_no = 'checked="checked"';
}
-
+
echo ' '. $this->l('Yes').'
- '.$this->l('No').' ';
-
+ '.$this->l('No').' ';
+
if (!file_exists($exists_file) && !empty($productDownload->display_filename) && empty($cache_default_attribute))
{
$msg = sprintf(Tools::displayError('This file "%s" is missing'), $productDownload->display_filename);
@@ -2686,24 +2686,24 @@ class AdminProducts extends AdminTab
'.$msg.' :
'.realpath(_PS_DOWNLOAD_DIR_) .'/'. $productDownload->filename.'
';
- }
+ }
if (!ProductDownload::checkWritableDir())
- {
+ {
echo '
'.$this->l('Your download repository is not writable.').'
'.realpath(_PS_DOWNLOAD_DIR_).'
';
}
-
+
echo '';
if (empty($cache_default_attribute))
{
- if($productDownload->id)
+ if($productDownload->id)
echo '
';
-
+
echo '
';
-
+
if (!$productDownload->checkFile())
{
echo '
@@ -2713,11 +2713,11 @@ class AdminProducts extends AdminTab
echo '
'.$this->l('Upload a file').'
';
}
-
+
echo '
';
if ($up_filename = strval(Tools::getValue('virtual_product_filename')))
echo ' ';
-
+
echo '
'.$this->l('Delete this file').' ';
}
@@ -2727,24 +2727,24 @@ class AdminProducts extends AdminTab
'.$this->l('This is the link').': '.$productDownload->getHtmlLink(false, true).'
'.$this->l('Delete this file').' ';
}
-
+
$display_filename = ($productDownload->id > 0) ? $productDownload->display_filename : htmlentities(Tools::getValue('virtual_product_name'), ENT_COMPAT, 'UTF-8');
echo '
'.$this->l('Filename').'
'.$this->l('The full filename with its extension (e.g., Book.pdf)').'
-
+
';
-
- if (!$productDownload->id || !$productDownload->active)
+
+ if (!$productDownload->id || !$productDownload->active)
$hidden = 'display:none;';
-
+
$nb_downloadable = ($productDownload->id > 0) ? $productDownload->nb_downloadable : htmlentities(Tools::getValue('virtual_product_nb_downloable'), ENT_COMPAT, 'UTF-8');
$date_expiration = ($productDownload->id > 0) ? ((!empty($productDownload->date_expiration) && $productDownload->date_expiration != '0000-00-00 00:00:00') ? date('Y-m-d', strtotime($productDownload->date_expiration)) : '' ) : htmlentities(Tools::getValue('virtual_product_expiration_date'), ENT_COMPAT, 'UTF-8');
$nb_days_accessible = ($productDownload->id > 0) ? $productDownload->nb_days_accessible : htmlentities(Tools::getValue('virtual_product_nb_days'), ENT_COMPAT, 'UTF-8');
$is_shareable = ($productDownload->id > 0 && $productDownload->is_shareable) ? 'checked="checked"' : '';
-
+
echo '
- ';
+ ';
}
- else
+ else
{
$error ='';
echo '
'.$this->l('You used combinations, for this reason you can\'t edit your file here, but in the Combinations tab').'
@@ -2794,9 +2794,9 @@ class AdminProducts extends AdminTab
';
-
+
includeDatepicker('virtual_product_expiration_date');
-
+
echo '
@@ -2818,7 +2818,7 @@ class AdminProducts extends AdminTab
$("#virtual_good_attributes").hide();
$("#is_virtual_file_product").hide();
}
-
+
$("input[name=is_virtual_file]").live("change", function() {
if($(this).val() == "1")
{
@@ -2830,8 +2830,8 @@ class AdminProducts extends AdminTab
$("#virtual_good_attributes").hide();
$("#is_virtual_file_product").hide();
}
- });
-
+ });
+
$("input[name=is_virtual_good]").live("change", function() {
if($(this).attr("checked"))
{
@@ -2918,8 +2918,8 @@ class AdminProducts extends AdminTab
'.($currency->format % 2 != 0 ? ' '.$currency->sign : '').' '.($currency->format % 2 == 0 ? ' '.$currency->sign : '').'
';
- }
- else
+ }
+ else
echo ' ';
echo '
@@ -3032,7 +3032,7 @@ class AdminProducts extends AdminTab
';
}
-
+
echo '
@@ -3498,12 +3498,12 @@ class AdminProducts extends AdminTab
if ($("#tr_" + id).find(".covered").attr("src") == "../img/admin/enabled.gif")
cover = 1;
$("#tr_" + id).remove();
-
+
if (cover)
$("#imageTable tr").eq(1).find(".covered").attr("src", "../img/admin/enabled.gif");
-
+
$("#countImage").html(parseInt($("#countImage").html()) - 1);
-
+
refreshImagePositions($("#imageTable"));
}
});
@@ -3548,7 +3548,7 @@ class AdminProducts extends AdminTab
$("#img" + id).addClass("red");
$("#img" + id + " .errorImg").html(responseJSON.error);
$("#img" + id + " .errorImg").show();
-
+
}
if (percent >= 100)
{
@@ -3569,7 +3569,7 @@ class AdminProducts extends AdminTab
addImage : 1,
ajaxMode : 1,
},
-
+
});
});
@@ -3660,11 +3660,11 @@ class AdminProducts extends AdminTab
echo '
';
}
-
-
+
+
function displayQuantities($obj)
{
-
+
// Get all id_product_atribute
$attributes = $obj->getAttributeCombinaisons($this->context->language->id);
if (empty($attributes))
@@ -3672,7 +3672,7 @@ class AdminProducts extends AdminTab
'id_product_attribute' => 0,
'attribute_name' => ''
);
-
+
// Get physical quantities & available quantities
$totalQuantity = 0;
$physicalQuantity = array();
@@ -3680,16 +3680,16 @@ class AdminProducts extends AdminTab
$productDesignation = array();
foreach ($attributes as $attribute)
{
- $physicalQuantity[$attribute['id_product_attribute']] = (int)rand(0, 100);//StockManagerFactory::getManager()->getProductPhysicalQuantities((int)$obj->id, $attribute['id_product_attribute']);
+ $physicalQuantity[$attribute['id_product_attribute']] = (int)StockManagerFactory::getManager()->getProductPhysicalQuantities((int)$obj->id, $attribute['id_product_attribute']);
$totalQuantity += $physicalQuantity[$attribute['id_product_attribute']];
-
+
// @TODO
$availableQuantity[$attribute['id_product_attribute']] = StockAvailable::getStockAvailableForProduct((int)$obj->id, $attribute['id_product_attribute']);
-
+
// Get all product designation
$productDesignation[$attribute['id_product_attribute']] = $obj->name[$this->context->language->id].' '.$attribute['attribute_name'];
}
-
+
$return = '
8. '.$this->l('Quantities').'
@@ -3825,7 +3825,7 @@ class AdminProducts extends AdminTab
$(\'#available_quantity_ajax_msg\').hide();
$(\'#available_quantity_ajax_success_msg\').hide();
};
-
+
var showAjaxSuccess = function(msg)
{
$(\'#available_quantity_ajax_success_msg\').html(msg);
@@ -3833,7 +3833,7 @@ class AdminProducts extends AdminTab
$(\'#available_quantity_ajax_msg\').hide();
$(\'#available_quantity_ajax_success_msg\').show();
};
-
+
var showAjaxMsg = function(msg)
{
$(\'#available_quantity_ajax_msg\').html(msg);
@@ -3841,7 +3841,7 @@ class AdminProducts extends AdminTab
$(\'#available_quantity_ajax_msg\').show();
$(\'#available_quantity_ajax_success_msg\').hide();
};
-
+
var ajaxCall = function(data)
{
data.ajaxProductQuantity = 1;
@@ -3896,15 +3896,15 @@ class AdminProducts extends AdminTab
});
refreshQtyAvaibilityForm();
';
-
+
return $return;
}
-
+
public function ajaxProductQuantity($obj)
{
if(!Tools::getValue('action'))
return Tools::jsonEncode(array('error' => 'Undefined action'));
-
+
switch(Tools::getValue('action'))
{
case 'depends_on_stock':elog((int)Tools::getValue('value'));
@@ -3912,19 +3912,19 @@ class AdminProducts extends AdminTab
return Tools::jsonEncode(array('error' => 'Undefined value'));
if ((int)Tools::getValue('value') != 0 && (int)Tools::getValue('value') != 1)
return Tools::jsonEncode(array('error' => 'Uncorrect value'));
-
+
StockAvailable::setProductDependsOnStock((int)Tools::getValue('value'), $obj->id);
break;
-
+
case 'out_of_stock':
if (Tools::getValue('value') === false)
return Tools::jsonEncode(array('error' => 'Undefined value'));
if (!in_array((int)Tools::getValue('value'), array(0, 1, 2)))
return Tools::jsonEncode(array('error' => 'Uncorrect value'));
-
+
StockAvailable::setProductOutOfStock((int)Tools::getValue('value'), $obj->id);
break;
-
+
case 'set_qty':
if (Tools::getValue('value') === false)
return Tools::jsonEncode(array('error' => 'Undefined value'));
@@ -3935,7 +3935,7 @@ class AdminProducts extends AdminTab
$stock_available->save();
break;
}
-
+
return Tools::jsonEncode(array('error' => false));
}
@@ -4005,12 +4005,12 @@ class AdminProducts extends AdminTab
$currency = $this->context->currency;
$attributes_groups = AttributeGroup::getAttributesGroups($this->context->language->id);
$default_country = new Country((int)Configuration::get('PS_COUNTRY_DEFAULT'));
-
+
$productDownload = new ProductDownload();
$id_product_download = (int) $productDownload->getIdFromIdProduct($this->getFieldValue($obj, 'id'));
if (!empty($id_product_download))
- $productDownload = new ProductDownload($id_product_download);
-
+ $productDownload = new ProductDownload($id_product_download);
+
$images = Image::getImages($this->context->language->id, $obj->id);
if ($obj->id)
{
@@ -4021,7 +4021,7 @@ class AdminProducts extends AdminTab
updateMvtStatus($(this).val());
});
updateMvtStatus($(this).val());
-
+
if ( $("input[name=is_virtual_file]:checked").val() == 1)
{
$("#virtual_good_attributes").show();
@@ -4032,7 +4032,7 @@ class AdminProducts extends AdminTab
$("#virtual_good_attributes").hide();
$("#is_virtual_file_product").hide();
}
-
+
$("input[name=is_virtual_file]").live("change", function() {
if($(this).val() == "1")
{
@@ -4045,7 +4045,7 @@ class AdminProducts extends AdminTab
$("#is_virtual_file_product").hide();
}
});
- });
+ });
@@ -4084,7 +4084,7 @@ class AdminProducts extends AdminTab
-
+
'.$this->l('Reference:').'
@@ -4106,7 +4106,7 @@ class AdminProducts extends AdminTab
-
+
'.$this->l('Your server\'s maximum upload file size is') . ': ' . ini_get('upload_max_filesize').'
'.$this->l('Upload a file').'
@@ -4115,13 +4115,13 @@ class AdminProducts extends AdminTab
echo '
'.$this->l('This is the link').': '.$productDownload->getHtmlLink(false, true).'
'.$this->l('Delete this file').'
';
-
+
echo '
'.$this->l('Delete this file').' ';
-
+
if ($up_filename = strval(Tools::getValue('virtual_product_filename_attribute')))
echo ' ';
-
+
echo '
'.$this->l('Filename').'
@@ -4296,7 +4296,7 @@ class AdminProducts extends AdminTab
'.$this->l('UPC').'
'.$this->l('Quantity').' ';
-
+
if ($id_product_download && !empty($productDownload->display_filename))
{
echo '
@@ -4305,7 +4305,7 @@ class AdminProducts extends AdminTab
';
}
-
+
echo ''.$this->l('Actions').'
';
if ($obj->id)
@@ -4362,12 +4362,12 @@ class AdminProducts extends AdminTab
$id_product_download = $productDownload->getIdFromIdAttribute((int) $obj->id, (int) $id_product_attribute);
if ($id_product_download)
$productDownload = new ProductDownload($id_product_download);
-
+
$available_date_attribute = substr($productDownload->date_expiration, 0, -9);
-
+
if ($available_date_attribute == '0000-00-00')
- $available_date_attribute = '';
-
+ $available_date_attribute = '';
+
if ($productDownload->is_shareable == 1)
$is_shareable = $this->l('Yes');
else
@@ -4382,7 +4382,7 @@ class AdminProducts extends AdminTab
'.$product_attribute['ean13'].'
'.$product_attribute['upc'].'
'.$product_attribute['quantity'].' ';
-
+
if ($id_product_download && !empty($productDownload->display_filename))
{
echo ''.$productDownload->getHtmlLink(false, true).'
@@ -4390,19 +4390,19 @@ class AdminProducts extends AdminTab
'.$productDownload->nb_downloadable.'
'.$is_shareable.' ';
}
-
+
$exists_file = realpath(_PS_DOWNLOAD_DIR_).'/'.$productDownload->filename;
-
+
if ($productDownload->id && file_exists($exists_file))
$filename = $productDownload->filename;
else
$filename = '';
-
+
echo '
'.(!$product_attribute['default_on'] ? '
' : '').'
diff --git a/admin-dev/tabs/AdminStockMvt.php b/admin-dev/tabs/AdminStockMvt.php
index 068319ebe..4c9337f78 100755
--- a/admin-dev/tabs/AdminStockMvt.php
+++ b/admin-dev/tabs/AdminStockMvt.php
@@ -1,6 +1,6 @@
className = 'StockMvt';
$this->edit = false;
$this->delete = false;
- $this->view = true;
-
+ $this->view = false;
+
$this->fieldsDisplay = array(
'id_stock_mvt' => array('title' => $this->l('ID'), 'width' => 40),
- 'product_name' => array('title' => $this->l('Product Name'), 'width' => 250, 'havingFilter' => true),
- 'quantity' => array('title' => $this->l('Quantity'), 'width' => 40),
- 'reason' => array('title' => $this->l('Reason'), 'width' => 250),
+ 'product_name' => array('title' => $this->l('Product Name'), 'width' => 200, 'havingFilter' => true),
+ 'physical_quantity' => array('title' => $this->l('Quantity'), 'width' => 40),
+ 'reason' => array('title' => $this->l('Reason'), 'width' => 200),
'id_order' => array('title' => $this->l('ID Order'), 'width' => 40),
'employee' => array('title' => $this->l('Employee'), 'width' => 100, 'havingFilter' => true),
+ 'warehouse' => array('title' => $this->l('Warehouse'), 'width' => 100, 'havingFilter' => true),
);
-
-
- $this->_select = 'CONCAT(pl.name, \' \', GROUP_CONCAT(IFNULL(al.name, \'\'), \'\')) product_name, CONCAT(e.lastname, \' \', e.firstname) employee, mrl.name reason';
- $this->_join = 'INNER JOIN '._DB_PREFIX_.'stock stock ON a.id_stock = stock.id_stock '.$this->context->shop->sqlRestriction(Shop::SHARE_STOCK, 'stock').'
+
+ $this->_select = 'CONCAT(pl.name, \' \', GROUP_CONCAT(IFNULL(al.name, \'\'), \'\')) product_name, CONCAT(e.lastname, \' \', e.firstname) AS employee, mrl.name AS reason, CONCAT(w.reference, " - ", w.name) AS warehouse';
+ $this->_join = 'INNER JOIN '._DB_PREFIX_.'stock stock ON a.id_stock = stock.id_stock
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (stock.id_product = pl.id_product AND pl.id_lang = '.(int)$this->context->language->id.$this->context->shop->sqlLang('pl').')
LEFT JOIN `'._DB_PREFIX_.'stock_mvt_reason_lang` mrl ON (a.id_stock_mvt_reason = mrl.id_stock_mvt_reason AND mrl.id_lang = '.(int)$this->context->language->id.')
LEFT JOIN `'._DB_PREFIX_.'employee` e ON (e.id_employee = a.id_employee)
+ LEFT JOIN `'._DB_PREFIX_.'warehouse` w ON (w.id_warehouse = stock.id_warehouse)
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON (pac.id_product_attribute = stock.id_product_attribute)
LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al ON (al.id_attribute = pac.id_attribute AND al.id_lang = '.(int)$this->context->language->id.')';
$this->_group = 'GROUP BY a.id_stock_mvt';
@@ -59,11 +60,11 @@ class AdminStockMvt extends AdminTab
public function postProcess()
{
- if (Tools::isSubmit('rebuildStock'))
- StockMvt::addMissingMvt($this->context->employee->id, false);
+ /*if (Tools::isSubmit('rebuildStock'))
+ StockMvt::addMissingMvt($this->context->employee->id, false);*/
return parent::postProcess();
}
-
+
public function displayForm($isMainTab = true)
{
parent::displayForm();
@@ -90,14 +91,14 @@ class AdminStockMvt extends AdminTab
'.$this->l('Decrease stock').'
-
';
- echo '
';
}
-
+*/
public function display()
{
$old_post = false;
-
- if (!isset($_GET['addstock_mvt_reason']) OR (Tools::isSubmit('submitAddstock_mvt_reason') AND Tools::getValue('id_stock_mvt_reason')))
+
+ if (!isset($_GET['addstock_mvt_reason']) || (Tools::isSubmit('submitAddstock_mvt_reason') && Tools::getValue('id_stock_mvt_reason')))
{
if (isset($_POST))
- {
$old_post = $_POST;
- }
+
echo ''.$this->l('Stock movement history').' ';
parent::display();
- if (!isset($_GET['view'.$this->table]))
+ /*if (!isset($_GET['view'.$this->table]))
echo '
- ';
+ ';*/
}
if (isset($_GET['view'.$this->table]))
return;
@@ -169,35 +169,41 @@ class AdminStockMvt extends AdminTab
$this->add = true;
$this->view = false;
$this->_listSkipDelete = array(1,2,3,4);
-
+
$this->_defaultOrderBy = $this->identifier;
$this->fieldsDisplay = array('id_stock_mvt_reason' => array('title' => $this->l('ID'), 'width' => 40),
'sign' => array('title' => $this->l('Sign'), 'width' => 15, 'align' => 'center', 'type' => 'select', 'icon' => array(-1 => 'arrow_down.png', 1 => 'arrow_up.png'), 'orderby' => false),
'name' => array('title' => $this->l('Name'), 'width' => 500));
-
- $reasons = StockMvtReason::getStockMvtReasons($this->context->language->id);
+
+ $reasons_inc = StockMvtReason::getStockMvtReasons($this->context->language->id, 1);
+ $reasons_dec = StockMvtReason::getStockMvtReasons($this->context->language->id, -1);
$this->optionsList = array(
'general' => array(
'title' => $this->l('Options'),
'fields' => array(
- 'PS_STOCK_MVT_REASON_DEFAULT' => array(
- 'title' => $this->l('Default Stock Movement reason:'),
- 'cast' => 'intval',
- 'type' => 'select',
- 'list' => $reasons,
+ 'PS_STOCK_MVT_INC_REASON_DEFAULT' => array(
+ 'title' => $this->l('Default Stock Movement reason for increment stock:'),
+ 'cast' => 'intval',
+ 'type' => 'select',
+ 'list' => $reasons_inc,
+ 'identifier' => 'id_stock_mvt_reason'
+ ),
+ 'PS_STOCK_MVT_DEC_REASON_DEFAULT' => array(
+ 'title' => $this->l('Default Stock Movement reason for decrement stock:'),
+ 'cast' => 'intval',
+ 'type' => 'select',
+ 'list' => $reasons_dec,
'identifier' => 'id_stock_mvt_reason'
),
),
),
);
unset($this->_select, $this->_join, $this->_group, $this->_filterHaving, $this->_filter);
-
+
echo ''.$this->l('Stock movement reason').' ';
$this->postProcess();
return parent::display();
}
-}
-
-
+}
\ No newline at end of file
diff --git a/admin-dev/tabs/AdminWarehouses.php b/admin-dev/tabs/AdminWarehouses.php
new file mode 100644
index 000000000..65c598f6b
--- /dev/null
+++ b/admin-dev/tabs/AdminWarehouses.php
@@ -0,0 +1,245 @@
+
+* @copyright 2007-2011 PrestaShop SA
+* @version Release: $Revision: 7307 $
+* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
+* International Registered Trademark & Property of PrestaShop SA
+*/
+
+/**
+ * @since 1.5.0
+ */
+class AdminWarehouses extends AdminTab
+{
+ public function __construct()
+ {
+ $this->context = Context::getContext();
+ $this->table = 'warehouse';
+ $this->className = 'Warehouse';
+ $this->edit = true;
+ $this->delete = false;
+ $this->view = false;
+
+ $this->fieldsDisplay = array(
+ 'reference' => array('title' => $this->l('Reference'), 'width' => 40),
+ 'name' => array('title' => $this->l('Name'), 'width' => 300, 'havingFilter' => true),
+ 'management_type' => array('title' => $this->l('Managment type'), 'width' => 40),
+ 'employee' => array('title' => $this->l('Manager'), 'width' => 150, 'havingFilter' => true),
+ 'location' => array('title' => $this->l('Location'), 'width' => 150),
+ 'contact' => array('title' => $this->l('Phone Number'), 'width' => 50),
+ );
+
+ $this->_select = 'reference, name, management_type,
+ CONCAT(e.lastname, \' \', e.firstname) AS employee,
+ ad.phone AS contact,
+ CONCAT(ad.city, \' \', c.iso_code) location';
+ $this->_join = 'LEFT JOIN `'._DB_PREFIX_.'employee` e ON (e.id_employee = a.id_employee)
+ LEFT JOIN `'._DB_PREFIX_.'address` ad ON (ad.id_address = a.id_address)
+ LEFT JOIN `'._DB_PREFIX_.'country` c ON (c.id_country = ad.id_country)';
+
+ // Get countries list for warehouse localisation
+ $countries = Country::getCountries($this->context->language->id);
+ foreach ($countries as $country)
+ $this->countries_array[$country['id_country']] = $country['name'];
+
+ // Get employee list for warehouse manager
+ $query = new DbQuery();
+ $query->select('id_employee, CONCAT(lastname," ",firstname) as name');
+ $query->from('employee');
+ $query->where('active = 1');
+ $employees = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
+ foreach ($employees as $employee)
+ $this->employees_array[$employee['id_employee']] = $employee['name'];
+
+ parent::__construct();
+ }
+
+ public function postProcess()
+ {
+ // update/create address if not exists
+ if (isset($_POST['submitAdd'.$this->table]))
+ {
+ if (isset($_POST['id_address']) && $_POST['id_address'] > 0)
+ //update address
+ $address = new Address((int)$_POST['id_address']);
+ else
+ //create address
+ $address = new Address();
+
+ $address->alias = $_POST['name'];
+ $address->lastname = $_POST['name'];
+ $address->firstname = $_POST['name'];
+ $address->address1 = $_POST['address1'];
+ $address->address2 = $_POST['address2'];
+ $address->postcode = $_POST['postcode'];
+ $address->phone = $_POST['phone'];
+ $address->id_country = $_POST['id_country'];
+ $address->city = $_POST['city'];
+
+ if (isset($_POST['id_address']) && $_POST['id_address'] > 0)
+ {
+ //update address
+ $address->update();
+ }
+ else {
+ $address->save();
+ $_POST['id_address'] = $address->id;
+ }
+ }
+
+ return parent::postProcess();
+ }
+
+ public function displayForm($is_main_tab = true)
+ {
+ parent::displayForm();
+
+ if (!($obj = $this->loadObject(true)))
+ return;
+
+ if ($obj->id_address > 0)
+ $address = new Address($obj->id_address);
+
+ echo '';
+ }
+
+}
+
+