// 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
This commit is contained in:
dSevere
2011-10-13 16:18:09 +00:00
parent e16af90d6a
commit bc565999d1
3 changed files with 403 additions and 152 deletions
+117 -117
View File
@@ -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').' <b>'.$this->l('number of days').'</b> '.$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').' <b>'.$this->l('expiration date').'</b> '.$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 '<h3>'.(!$this->_listTotal ? ($this->l('No products found')) : ($this->_listTotal.' '.($this->_listTotal > 1 ? $this->l('products') : $this->l('product')))).'</h3>';
////////////////////////
// @todo lot of ergonomy works around here
// @todo lot of ergonomy works around here
echo '<p>'.$this->l('Go to category');
$select_child = ' <select id="go_to_categ"><option value="0">Jump to ...</option>';
// @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 .= '<option value="'.$categ->id.'" '.($this->_category->id_category == $categ->id ? 'selected="selected" class="selected level-depth-'.$categ->level_depth.'"':'class="level-depth-'.$categ->level_depth.'"') .'>' . str_repeat('&nbsp;-&nbsp;',$categ->level_depth). $categ->name .' ('.$categ->id.')</option>';
}
$select_child .= '</select>';
echo $select_child;
echo '</p>
@@ -2220,7 +2220,7 @@ class AdminProducts extends AdminTab
$hidden = $display_filename = $check = '';
?>
<script type="text/javascript">
// <![CDATA[
ThickboxI18nImage = '<?php echo $this->l('Image') ?>';
@@ -2246,7 +2246,7 @@ class AdminProducts extends AdminTab
{
$("#is_virtual_file_product").hide();
$("#virtual_good_attributes").hide();
if (elt.checked)
{
$('#virtual_good').show('slow');
@@ -2289,7 +2289,7 @@ class AdminProducts extends AdminTab
}
}
);
}
}
function uploadFile2()
{
@@ -2318,8 +2318,8 @@ class AdminProducts extends AdminTab
$('#upload-confirmation2').html(
'<a class="link" href="get-file-admin.php?file='+msg+'&filename='+fileName+'"><?php echo $this->l('The file') ?>&nbsp;"' + fileName + '"&nbsp;<?php echo $this->l('has successfully been uploaded') ?></a>' +
'<input type="hidden" id="virtual_product_filename_attribute" name="virtual_product_filename_attribute" value="' + msg + '" />');
link = $("#delete_downloadable_product_attribute").attr('href');
link = $("#delete_downloadable_product_attribute").attr('href');
$("#delete_downloadable_product_attribute").attr('href', link+"&file="+msg);
}
}
@@ -2330,16 +2330,16 @@ class AdminProducts extends AdminTab
</script>
<?php
if(!$productDownload->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
<br/>'.$this->l('Does this product has an associated file ?').'<br/>';
$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 '<input type="radio" value="1" id="virtual_good_file_1" name="is_virtual_file" '.$check_yes.'/>'. $this->l('Yes').'
<input type="radio" value="0" id="virtual_good_file_2" name="is_virtual_file" '.$check_no.'/>'.$this->l('No').'<br /><br />';
<input type="radio" value="0" id="virtual_good_file_2" name="is_virtual_file" '.$check_no.'/>'.$this->l('No').'<br /><br />';
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
<b>'.$msg.' :<br/>
'.realpath(_PS_DOWNLOAD_DIR_) .'/'. $productDownload->filename.'</b>
</p>';
}
}
if (!ProductDownload::checkWritableDir())
{
{
echo '<p class="alert">
'.$this->l('Your download repository is not writable.').'<br/>
'.realpath(_PS_DOWNLOAD_DIR_).'
</p>';
}
echo '<div id="is_virtual_file_product" style="display:none;">';
if (empty($cache_default_attribute))
{
if($productDownload->id)
if($productDownload->id)
echo '<input type="hidden" id="virtual_product_id" name="virtual_product_id" value="'.$productDownload->id.'" />';
echo '<p class="block">';
if (!$productDownload->checkFile())
{
echo '<div style="padding:5px;width:50%;float:left;margin-right:20px;border-right:1px solid #E0D0B1">
@@ -2713,11 +2713,11 @@ class AdminProducts extends AdminTab
echo '<label id="virtual_product_file_label" for="virtual_product_file" class="t">'.$this->l('Upload a file').'</label>
<p><input type="file" id="virtual_product_file" name="virtual_product_file" onchange="uploadFile();" maxlength="'.$this->maxFileSize.'" /></p>';
}
echo '<div id="upload-confirmation">';
if ($up_filename = strval(Tools::getValue('virtual_product_filename')))
echo '<input type="hidden" id="virtual_product_filename" name="virtual_product_filename" value="'.$up_filename.'" />';
echo '</div>
<a id="delete_downloadable_product" style="display:none;" onclick="return confirm(\''.addslashes($this->l('Delete this file')).'\')" href="'.$_SERVER['REQUEST_URI'].'&deleteVirtualProduct=true'.'" class="red">'.$this->l('Delete this file').'</a>';
}
@@ -2727,24 +2727,24 @@ class AdminProducts extends AdminTab
'.$this->l('This is the link').':&nbsp;'.$productDownload->getHtmlLink(false, true).'
<a onclick="return confirm(\''.addslashes($this->l('Delete this file')).'\')" href="'.$_SERVER['REQUEST_URI'].'&deleteVirtualProduct=true'.'" class="red">'.$this->l('Delete this file').'</a>';
}
$display_filename = ($productDownload->id > 0) ? $productDownload->display_filename : htmlentities(Tools::getValue('virtual_product_name'), ENT_COMPAT, 'UTF-8');
echo '</p><p class="block">
<label for="virtual_product_name" class="t">'.$this->l('Filename').'</label>
<input type="text" id="virtual_product_name" name="virtual_product_name" style="width:200px" value="'.$display_filename.'" />
<span class="hint" name="help_box" style="display:none;">'.$this->l('The full filename with its extension (e.g., Book.pdf)').'</span>
</p>
</div>';
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 '<div id="virtual_good_more" style="'.$hidden.'padding:5px;width:40%;float:left;margin-left:10px">
<p class="block">
<label for="virtual_product_nb_downloable" class="t">'.$this->l('Number of downloads').'</label>
@@ -2760,16 +2760,16 @@ class AdminProducts extends AdminTab
<label for="virtual_product_nb_days" class="t">'.$this->l('Number of days').'</label>
<input type="text" id="virtual_product_nb_days" name="virtual_product_nb_days" value="'.$nb_days_accessible.'" class="" size="4" /><sup> *</sup>
<span class="hint" name="help_box" style="display:none">'.$this->l('How many days this file can be accessed by customers').' - <em>('.$this->l('set to zero for unlimited access').')</em></span>
</p>
</p>
<p class="block">
<label for="virtual_product_is_shareable" class="t">'.$this->l('is shareable').'</label>
<input type="checkbox" id="virtual_product_is_shareable" name="virtual_product_is_shareable" value="1" '.$is_shareable.'/>
<span class="hint" name="help_box" style="display:none">'.$this->l('Specify if the file can be shared').'</span>
</p>
</div>
';
';
}
else
else
{
$error ='';
echo '<div class="hint clear" style="display: block;width: 70%;">'.$this->l('You used combinations, for this reason you can\'t edit your file here, but in the Combinations tab').'</div>
@@ -2794,9 +2794,9 @@ class AdminProducts extends AdminTab
</div>
</td>
</tr>';
includeDatepicker('virtual_product_expiration_date');
echo '<tr>
<td colspan="2" style="padding-bottom:5px;"><hr style="width:100%;" /></td>
</tr>
@@ -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 : '').' <input size="11" maxlength="14" id="priceTI" type="text" value="" onchange="noComma(\'priceTI\');" onkeyup="if (isArrowKey(event)) return; calcPriceTE();" />'.($currency->format % 2 == 0 ? ' '.$currency->sign : '').'
</td>
</tr>';
}
else
}
else
echo '<input size="11" maxlength="14" id="priceTI" type="hidden" value="" onchange="noComma(\'priceTI\');" onkeyup="if (isArrowKey(event)) return; calcPriceTE();" />';
echo '
@@ -3032,7 +3032,7 @@ class AdminProducts extends AdminTab
</tr>
';
}
echo '
<tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:100%;" /></td></tr>
<tr>
@@ -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,
},
});
});
</script>
@@ -3660,11 +3660,11 @@ class AdminProducts extends AdminTab
echo '
</script>';
}
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 = '
<div class="tab-page" id="step8">
<h4 class="tab">8. '.$this->l('Quantities').'</h4>
@@ -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();
</script>';
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();
}
});
});
});
</script>
<table cellpadding="5">
<tr>
@@ -4084,7 +4084,7 @@ class AdminProducts extends AdminTab
<select id="product_att_list" name="attribute_combinaison_list[]" multiple="multiple" size="4" style="width: 320px;"></select>
</td>
</tr>
<tr><td colspan="2"><hr style="width:100%;" /></td></tr>
<tr>
<td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">'.$this->l('Reference:').'</td>
@@ -4106,7 +4106,7 @@ class AdminProducts extends AdminTab
<tr><td colspan="2"><hr style="width:100%;" /></td></tr>
<table cellpadding="5" id="virtual_good_attributes" style="width:100%;display:none;">
<tr>
<td colspan="2">
<td colspan="2">
<div style="padding:5px;width:50%;float:left;margin-right:20px;border-right:1px solid #E0D0B1">
<p>'.$this->l('Your server\'s maximum upload file size is') . ':&nbsp;' . ini_get('upload_max_filesize').'</p>
<label id="virtual_product_file_attribute_label" for="virtual_product_file_attribute" class="t">'.$this->l('Upload a file').'</label>
@@ -4115,13 +4115,13 @@ class AdminProducts extends AdminTab
echo '<p id="gethtmlink" style="display: none;">'.$this->l('This is the link').':&nbsp;'.$productDownload->getHtmlLink(false, true).'
<a id="make_downloadable_product_attribute" onclick="return confirm(\''.addslashes($this->l('Delete this file')).'\')" href="'.$_SERVER['HTTP_REFERER'].'&deleteVirtualProductAttribute=true'.'" class="red">'.$this->l('Delete this file').'</a></p>';
echo '</div>
<a id="delete_downloadable_product_attribute" style="display:none;" onclick="return confirm(\''.addslashes($this->l('Delete this file')).'\')" href="'.$_SERVER['HTTP_REFERER'].'&deleteVirtualProductAttribute=true" class="red">'.$this->l('Delete this file').'</a>';
if ($up_filename = strval(Tools::getValue('virtual_product_filename_attribute')))
echo '<input type="hidden" id="virtual_product_filename_attribute" name="virtual_product_filename_attribute" value="'.$up_filename.'" />';
echo '<p class="block">
<label for="virtual_product_name" class="t">'.$this->l('Filename').'</label>
<input id="virtual_product_name_attribute" name="virtual_product_name_attribute" style="width:200px" value="" type="text">
@@ -4296,7 +4296,7 @@ class AdminProducts extends AdminTab
<th>'.$this->l('UPC').'</th>
<th class="center">'.$this->l('Quantity').'</th>';
if ($id_product_download && !empty($productDownload->display_filename))
{
echo '
@@ -4305,7 +4305,7 @@ class AdminProducts extends AdminTab
<th class="center virtual_header">'.$this->l('Number of days').'</th>
<th class="center virtual_header">'.$this->l('Share').'</th>';
}
echo '<th class="center">'.$this->l('Actions').'</th>
</tr>';
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
<td class="right">'.$product_attribute['ean13'].'</td>
<td class="right">'.$product_attribute['upc'].'</td>
<td class="center">'.$product_attribute['quantity'].'</td>';
if ($id_product_download && !empty($productDownload->display_filename))
{
echo '<td class="right">'.$productDownload->getHtmlLink(false, true).'</td>
@@ -4390,19 +4390,19 @@ class AdminProducts extends AdminTab
<td class="center">'.$productDownload->nb_downloadable.'</td>
<td class="right">'.$is_shareable.'</td>';
}
$exists_file = realpath(_PS_DOWNLOAD_DIR_).'/'.$productDownload->filename;
if ($productDownload->id && file_exists($exists_file))
$filename = $productDownload->filename;
else
$filename = '';
echo '<td class="center">
<a style="cursor: pointer;">
<img src="../img/admin/edit.gif" alt="'.$this->l('Modify this combination').'"
onclick="javascript:fillCombinaison(\''.$product_attribute['wholesale_price'].'\', \''.$product_attribute['price'].'\', \''.$product_attribute['weight'].'\', \''.$product_attribute['unit_impact'].'\', \''.$product_attribute['reference'].'\', \''.$product_attribute['supplier_reference'].'\', \''.$product_attribute['ean13'].'\',
\''.$product_attribute['quantity'].'\', \''.($attrImage ? $attrImage->id : 0).'\', Array('.$jsList.'), \''.$id_product_attribute.'\', \''.$product_attribute['default_on'].'\', \''.$product_attribute['ecotax'].'\', \''.$product_attribute['location'].'\', \''.$product_attribute['upc'].'\', \''.$product_attribute['minimal_quantity'].'\', \''.$available_date.'\',
\''.$product_attribute['quantity'].'\', \''.($attrImage ? $attrImage->id : 0).'\', Array('.$jsList.'), \''.$id_product_attribute.'\', \''.$product_attribute['default_on'].'\', \''.$product_attribute['ecotax'].'\', \''.$product_attribute['location'].'\', \''.$product_attribute['upc'].'\', \''.$product_attribute['minimal_quantity'].'\', \''.$available_date.'\',
\''.$productDownload->display_filename.'\', \''.$filename.'\', \''.$productDownload->nb_downloadable.'\', \''.$available_date_attribute.'\', \''.$productDownload->nb_days_accessible.'\', \''.$productDownload->is_shareable.'\'); calcImpactPriceTI();" /></a>&nbsp;
'.(!$product_attribute['default_on'] ? '<a href="'.self::$currentIndex.'&defaultProductAttribute&id_product_attribute='.$id_product_attribute.'&id_product='.$obj->id.'&'.(Tools::isSubmit('id_category') ? 'id_category='.(int)(Tools::getValue('id_category')).'&' : '&').'token='.Tools::getAdminToken('AdminCatalog'.(int)(Tab::getIdFromClassName('AdminCatalog')).$this->context->employee->id).'">
<img src="../img/admin/asterisk.gif" alt="'.$this->l('Make this the default combination').'" title="'.$this->l('Make this combination the default one').'"></a>' : '').'
+41 -35
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2011 PrestaShop
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -34,23 +34,24 @@ class AdminStockMvt extends AdminTab
$this->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
<option value="-1">'.$this->l('Decrease stock').'</option>
</select>
</div>
<div class="clear space">&nbsp;</div>';
echo '<div class="margin-form">
<div class="clear space">&nbsp;</div>
<div class="margin-form">
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
</div>
</fieldset>
</form>';
}
/*
public function viewstock_mvt()
{
$stockMvt = new StockMvt((int)Tools::getValue('id_stock_mvt'));
@@ -131,20 +132,19 @@ class AdminStockMvt extends AdminTab
}
echo '</table>';
}
*/
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 '<h2>'.$this->l('Stock movement history').'</h2>';
parent::display();
if (!isset($_GET['view'.$this->table]))
/*if (!isset($_GET['view'.$this->table]))
echo '
<fieldset>
<form method="post" action="'.self::$currentIndex.'&token='.$this->token.'&rebuildMvt=1">
@@ -153,7 +153,7 @@ class AdminStockMvt extends AdminTab
<input class="button" type="submit" name="rebuildStock" value="'.$this->l('Submit').'" />
</div>
</form>
</fieldset><br />';
</fieldset><br />';*/
}
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 '<h2>'.$this->l('Stock movement reason').'</h2>';
$this->postProcess();
return parent::display();
}
}
}
+245
View File
@@ -0,0 +1,245 @@
<?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: 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 '<form action="'.self::$currentIndex.'&submitAdd'.$this->table.'=1&token='.$this->token.'&addwarehouse" method="post">
'.($obj->id ? '<input type="hidden" name="id_'.$this->table.'" value="'.$obj->id.'" />' : '').'
<input type="hidden" name="id_address" value="'.(isset($obj->id_address) ? $obj->id_address : 0).'" />
<fieldset><legend><img src="../img/admin/tab.gif" />'.$this->l('Warehouse').'</legend>
<label>'.$this->l('Reference:').'</label>
<div class="margin-form">
<input size="20" type="text" name="reference" value="'.htmlentities($this->getFieldValue($obj, 'reference'), ENT_COMPAT, 'UTF-8').'" /><sup> *</sup>
</div>
<label>'.$this->l('Name:').'</label>
<div class="margin-form">
<input size="50" type="text" name="name" value="'.htmlentities($this->getFieldValue($obj, 'name'), ENT_COMPAT, 'UTF-8').'" /><sup> *</sup>
</div>
<label>'.$this->l('Phone Number').'</label>
<div class="margin-form">
<input type="text" size="33" name="phone" value="'.htmlentities(isset($address) ? $address->phone : '', ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
</div>
<label>'.$this->l('Address').'</label>
<div class="margin-form">
<input type="text" size="33" name="address1" value="'.htmlentities(isset($address) ? $address->address1 : '', ENT_COMPAT, 'UTF-8').'" /> <sup>*</sup>
</div>
<label>'.$this->l('Address').' (2)</label>
<div class="margin-form">
<input type="text" size="33" name="address2" value="'.htmlentities(isset($address) ? $address->address2 : '', ENT_COMPAT, 'UTF-8').'" />
</div>
<label>'.$this->l('Postcode/ Zip Code').'</label>
<div class="margin-form">
<input type="text" size="33" name="postcode" value="'.htmlentities(isset($address) ? $address->postcode : '', ENT_COMPAT, 'UTF-8').'" />
</div>
<label>'.$this->l('City').'</label>
<div class="margin-form">
<input type="text" size="33" name="city" value="'.htmlentities(isset($address) ? $address->city : '', ENT_COMPAT, 'UTF-8').'" style="text-transform: uppercase;" /> <sup>*</sup>
</div>
<label>'.$this->l('Country').'</label>
<div class="margin-form">
<select name="id_country" id="id_country" />';
$selected_country = $this->getFieldValue($obj, 'id_country');
foreach ($this->countries_array as $id_country => $name)
echo '<option value="'.$id_country.'"'.((!$selected_country && Configuration::get('PS_COUNTRY_DEFAULT') == $id_country) ? ' selected="selected"' : ($selectedCountry == $id_country ? ' selected="selected"' : '')).'>'.$name.'</option>';
echo '</select> <sup>*</sup>
</div>
<div id="contains_states" '.(!Country::containsStates((int)$selected_country) ? 'style="display:none;"' : '').'>
<label>'.$this->l('State').'</label>
<div class="margin-form">
<select name="id_state" id="id_state">
</select>
<sup>*</sup>
</div>
</div>';
$id_country_ajax = (int)$this->getFieldValue($obj, 'id_country');
echo '
<script type="text/javascript">
$(document).ready(function(){
ajaxStates ();
$(\'#id_country\').change(function() {
ajaxStates ();
});
function ajaxStates ()
{
$.ajax({
url: "ajax.php",
cache: false,
data: "ajaxStates=1&id_country="+$(\'#id_country\').val()+"&id_state="+$(\'#id_state\').val(),
success: function(html)
{
if (html == \'false\')
{
$("#contains_states").fadeOut();
$(\'#id_state option[value=0]\').attr("selected", "selected");
}
else
{
$("#id_state").html(html);
$("#contains_states").fadeIn();
$(\'#id_state option[value='.(isset($address) ? $address->id_state : 0).']\').attr("selected", "selected");
}
}
});
};
});
</script>
<label>'.$this->l('Manager').'</label>
<div class="margin-form">
<select name="id_employee" id="id_employee" />';
$selected_employee = $this->getFieldValue($obj, 'id_employee');
$selected_management_type = $this->getFieldValue($obj, 'management_type');
foreach ($this->employees_array as $id_employee => $name)
echo '<option value="'.$id_employee.'"'.(($selected_employee == $id_employee) ? ' selected="selected"' : '').'>'.$name.'</option>';
echo '</select> <sup>*</sup>
</div>
<label>'.$this->l('Management type').'</label>
<div class="margin-form">
<select name="management_type" id="management_type">
<option value="FIFO"'.(($selected_management_type == 'FIFO') ? ' selected="selected"' : '').'>'.$this->l('First In, First Out').'</option>
<option value="LIFO"'.(($selected_management_type == 'LIFO') ? ' selected="selected"' : '').'>'.$this->l('Last In, First Out').'</option>
<option value="WA"'.(($selected_management_type == 'WA') ? ' selected="selected"' : '').'>'.$this->l('Weight Average').'</option>
</select>
<sup>*</sup>
</div>
<div class="clear"></div><br />
<div class="margin-form">
<input type="submit" value="'.$this->l(' Save ').'" name="submitAdd'.$this->table.'" class="button" />
</div>
</fieldset>
</form>';
}
}