// Product Admin Controller : update interfaces for quantities, suppliers and warehouses + bugs fix

This commit is contained in:
dSevere
2011-11-22 16:41:42 +00:00
parent dacb4f7eb4
commit 46a7f9ff83
4 changed files with 225 additions and 121 deletions
@@ -1,3 +1,95 @@
<div class="hint" style="display:block; position:'auto';">
<p>{l s='This interface allows you to manage the available quantities for sale of the current product and its combinations on the current shop.'}</p>
<p>{l s='You can manually specify the quantities for the product / each product combinations, or choose to automatically determine these quantities based on your stock.'}</p>
<p>{l s='In this case, the quantities correspond to the quantitites of the real stock in the warehouses associated to the current shop.'}</p>
</div>
<br />
<table cellpadding="5">
<tbody>
<tr>
<td colspan="2">
<b>{l s='Available quantities for sale'}</b>
</td>
</tr>
</tbody>
</table>
<div class="separation"></div>
<div class="warn" id="available_quantity_ajax_msg" style="display: none;"></div>
<div class="error" id="available_quantity_ajax_error_msg" style="display: none;"></div>
<div class="conf" id="available_quantity_ajax_success_msg" style="display: none;"></div>
<table cellpadding="5" style="width:100%">
<tbody>
<tr>
<td valign="top" style="vertical-align:top;">
<input {if $product->depends_on_stock == 1}checked="checked" {/if} type="radio" name="depends_on_stock" class="depends_on_stock" id="depends_on_stock_1" value="1"/>
<label style="float:none;font-weight:normal" for="depends_on_stock_1">{l s='Available quantities for current product and its combinations are based on stock in the warehouses'}</label>
<br /><br />
</td>
</tr>
<tr>
<td valign="top" style="vertical-align:top;">
<input {if $product->depends_on_stock == 0}checked="checked" {/if} type="radio" name="depends_on_stock" class="depends_on_stock" id="depends_on_stock_0" value="0"/>
<label style="float:none;font-weight:normal" for="depends_on_stock_0">{l s='I want to specify available quantities manually, and manage my stock independently'}</label>
<br /><br />
</td>
</tr>
<tr>
<td valign="top" style="text-align:center;vertical-align:top;">
<table class="table" cellpadding="0" cellspacing="0" style="width:60%;margin-left:20%;">
<thead>
<tr>
<th style="width:200px;">{l s='Quantity'}</th>
<th>{l s='Designation'}</th>
</tr>
</thead>
<tbody>
{foreach from=$attributes item=attribute}
<tr>
<td class="available_quantity" id="qty_{$attribute['id_product_attribute']}">
<span>{$available_quantity[$attribute['id_product_attribute']]}</span>
<input type="text" value="{$available_quantity[$attribute['id_product_attribute']]}"/>
</td>
<td>{$product_designation[$attribute['id_product_attribute']]}</td>
</tr>
{/foreach}
</tbody>
</table>
</td>
</tr>
<tr id="when_out_of_stock">
<td>
<table style="margin-top: 15px;">
<tbody>
<tr>
<td class="col-left"><label>{l s='When out of stock:'}</label></td>
<td style="padding-bottom:5px;">
<input {if $product->out_of_stock == 0}checked="checked" {/if} id="out_of_stock_1" type="radio" checked="checked" value="0" class="out_of_stock" name="out_of_stock">
<label id="label_out_of_stock_1" class="t" for="out_of_stock_1">{l s='Deny orders'}</label>
<br>
<input {if $product->out_of_stock == 1} 'checked="checked" {/if} id="out_of_stock_2" type="radio" value="1" class="out_of_stock" name="out_of_stock">
<label id="label_out_of_stock_2" class="t" for="out_of_stock_2">{l s='Allow orders'}</label>
<br>
<input {if $product->out_of_stock == 2} 'checked="checked" {/if} id="out_of_stock_3" type="radio" value="2" class="out_of_stock" name="out_of_stock">
<label id="label_out_of_stock_3" class="t" for="out_of_stock_3">
Default:
<i>Deny orders</i>
{assign var=confirm value="Are you sure you want to delete entered product information?"}
<a onclick="return confirm(' {$confirm} ');"
href="index.php?tab=AdminPPreferences&token={$token_preferences}">
{l s='as set in Preferences'}
</a>
</label>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<script type="text/javascript">
var showAjaxError = function(msg)
{
@@ -103,92 +195,4 @@
});
refreshQtyAvaibilityForm();
</script>
<p>{l s='This interface ...'}</p>
<br />
<table cellpadding="5">
<tbody>
<tr>
<td colspan="2">
<b>{l s='Available quantities for sale'}</b>
</td>
</tr>
</tbody>
</table>
<div class="separation"></div>
<div class="warn" id="available_quantity_ajax_msg" style="display: none;"></div>
<div class="error" id="available_quantity_ajax_error_msg" style="display: none;"></div>
<div class="conf" id="available_quantity_ajax_success_msg" style="display: none;"></div>
<table cellpadding="5" style="width:100%">
<tbody>
<tr>
<td valign="top" style="vertical-align:top;">
<input {if $product->depends_on_stock == 1}checked="checked" {/if} type="radio" name="depends_on_stock" class="depends_on_stock" id="depends_on_stock_1" value="1"/>
<label style="float:none;font-weight:normal" for="depends_on_stock_1">{l s='Available quantities for current product and its combinations are based on stock in the warehouses'}</label>
<br /><br />
</td>
</tr>
<tr>
<td valign="top" style="vertical-align:top;">
<input {if $product->depends_on_stock == 0}checked="checked" {/if} type="radio" name="depends_on_stock" class="depends_on_stock" id="depends_on_stock_0" value="0"/>
<label style="float:none;font-weight:normal" for="depends_on_stock_0">{l s='I want to specify available quantities manually, and manage my stock independently'}</label>
<br /><br />
</td>
</tr>
<tr>
<td valign="top" style="text-align:center;vertical-align:top;">
<table class="table" cellpadding="0" cellspacing="0" style="width:60%;margin-left:20%;">
<thead>
<tr>
<th style="width:200px;">{l s='Quantity'}</th>
<th>{l s='Designation'}</th>
</tr>
</thead>
<tbody>
{foreach from=$attributes item=attribute}
<tr>
<td class="available_quantity" id="qty_{$attribute['id_product_attribute']}">
<span>{$available_quantity[$attribute['id_product_attribute']]}</span>
<input type="text" value="{$available_quantity[$attribute['id_product_attribute']]}"/>
</td>
<td>{$product_designation[$attribute['id_product_attribute']]}</td>
</tr>
{/foreach}
</tbody>
</table>
</td>
</tr>
<tr id="when_out_of_stock">
<td>
<table style="margin-top: 15px;">
<tbody>
<tr>
<td class="col-left"><label>{l s='When out of stock:'}</label></td>
<td style="padding-bottom:5px;">
<input {if $product->out_of_stock == 0}checked="checked" {/if} id="out_of_stock_1" type="radio" checked="checked" value="0" class="out_of_stock" name="out_of_stock">
<label id="label_out_of_stock_1" class="t" for="out_of_stock_1">{l s='Deny orders'}</label>
<br>
<input {if $product->out_of_stock == 1} 'checked="checked" {/if} id="out_of_stock_2" type="radio" value="1" class="out_of_stock" name="out_of_stock">
<label id="label_out_of_stock_2" class="t" for="out_of_stock_2">{l s='Allow orders'}</label>
<br>
<input {if $product->out_of_stock == 2} 'checked="checked" {/if} id="out_of_stock_3" type="radio" value="2" class="out_of_stock" name="out_of_stock">
<label id="label_out_of_stock_3" class="t" for="out_of_stock_3">
Default:
<i>Deny orders</i>
{assign var=confirm value="Are you sure you want to delete entered product information?"}
<a onclick="return confirm(' {$confirm} ');"
href="index.php?tab=AdminPPreferences&token={$token_preferences}">
{l s='as set in Preferences'}
</a>
</label>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</script>
@@ -1,3 +1,8 @@
<div class="hint" style="display:block; position:'auto';">
<p>{l s='This interface allows you to specify the suppliers of the current product and eventually its combinations.'}</p>
<p>{l s='It is also possible to specify for each product/product combinations the supplier reference according to previously associated suppliers.'}</p>
</div>
<br />
<table cellpadding="5">
<tbody>
<tr>
@@ -56,7 +61,7 @@
<div class="separation"></div>
<p>{l s='You can specify product reference(s) for each supplier associated.'}</p>
<div id="accordion" style="margin-top:10px; display:block;">
<div id="suppliers_accordion" style="margin-top:10px; display:block;">
{foreach from=$associated_suppliers item=supplier}
<h3 style="margin-bottom:0;"><a href="#">{$supplier->name}</a></h3>
<div style="display:block;">
@@ -95,8 +100,72 @@
<script type="text/javascript">
$(function() {
window.setTimeout(function() {
$('#accordion').accordion();
var default_is_ok = false;
var manageDefaultSupplier = function() {
var availables_radio_buttons = [];
var radio_buttons = $('input[name="default_supplier"]');
for (i=0; i<radio_buttons.length; i++)
{
var item = $(radio_buttons[i]);
if (item.is(':disabled'))
{
if (item.is(':checked'))
{
item.attr("checked", "");
default_is_ok = false;
}
}
else
{
availables_radio_buttons.push(item);
}
}
if (default_is_ok == false)
{
for (i=0; i<availables_radio_buttons.length; i++)
{
var item = $(availables_radio_buttons[i]);
if (item.is(':disabled') == false)
{
item.attr("checked", "checked");
default_is_ok = true;
}
break;
}
}
};
$('.supplierCheckBox').click(function() {
var check = $(this);
var checkbox = $('#default_supplier_'+check.val());
if (this.checked)
{
//enable default radio button associated
checkbox.attr("disabled","");
}
else
{
//enable default radio button associated
checkbox.attr("disabled","disabled");
}
//manage default supplier check
manageDefaultSupplier();
});
setTimeout(function() {
$('#suppliers_accordion').accordion();
}, 500);
});
</script>
@@ -1,3 +1,8 @@
<div class="hint" style="display:block; position:'auto';">
<p>{l s='This interface allows you to specify in which warehouses the product is stocked.'}</p>
<p>{l s='It is also possible to specify for each product/product combinations its location in each warehouse.'}</p>
</div>
<br />
<table cellpadding="5">
<tbody>
<tr>
@@ -16,54 +21,80 @@
<img src="../img/admin/add.gif" alt="{l s='Create new warehouse'}" title="{l s='Create new warehouse'}" /> <b>{l s='Create new warehouse'}</b>
</a>
<div id="accordion" style="margin-top:10px; display:block;">
<div id="warehouse_accordion" style="margin-top:10px; display:block;">
{foreach from=$warehouses item=warehouse}
<h3 style="margin-bottom:0;"><a href="#">{$warehouse['name']}</a></h3>
<div style="display:block;">
<table cellpadding="5" cellspacing="5" style="width:80%; margin-left:0;">
<tr>
<th width="40">{l s='In the warehouse?'}</th>
<th width="100">{l s='In the warehouse?'}</th>
<th>{l s='product name'}</th>
<th width="150">{l s='location in the warehouse (optionnal)'}</th>
</tr>
{foreach from=$attributes item=attribute}
{assign var=location value=''}
{assign var=selected value=''}
{foreach from=$associated_warehouses item=aw}
{if $aw->id_product == $attribute['id_product'] && $aw->id_product_attribute == $attribute['id_product_attribute'] && $aw->id_warehouse == $warehouse['id_warehouse']}
{assign var=location value=$aw->location}
{assign var=selected value=true}
{/if}
{foreach from=$attributes item=attribute}
{assign var=location value=''}
{assign var=selected value=''}
{foreach from=$associated_warehouses item=aw}
{if $aw->id_product == $attribute['id_product'] && $aw->id_product_attribute == $attribute['id_product_attribute'] && $aw->id_warehouse == $warehouse['id_warehouse']}
{assign var=location value=$aw->location}
{assign var=selected value=true}
{/if}
{/foreach}
<tr>
<td><input type="checkbox"
name="check_warehouse_{$warehouse['id_warehouse']}_{$attribute['id_product']}_{$attribute['id_product_attribute']}"
{if $selected == true}checked="checked"{/if}
value="1" />
</td>
<td>{$product_designation[$attribute['id_product_attribute']]}</td>
<td><input type="text"
name="location_warehouse_{$warehouse['id_warehouse']}_{$attribute['id_product']}_{$attribute['id_product_attribute']}"
value="{$location}"
size="20" />
</td>
</tr>
{/foreach}
<tr>
<td><input type="checkbox"
name="check_warehouse_{$warehouse['id_warehouse']}_{$attribute['id_product']}_{$attribute['id_product_attribute']}"
{if $selected == true}checked="checked"{/if}
value="1" />
</td>
<td>{$product_designation[$attribute['id_product_attribute']]}</td>
<td><input type="text"
name="location_warehouse_{$warehouse['id_warehouse']}_{$attribute['id_product']}_{$attribute['id_product_attribute']}"
value="{$location}"
size="20" />
</td>
<td colspan="3">&nbsp;</td>
</tr>
<tr>
<td><input type="checkbox" id="check_all_suppliers" value="check_warehouse_{$warehouse['id_warehouse']}" /></td>
<td colspan="2"><i>{l s='Mark all products available in the current warehouse.'}</i></td>
</tr>
{/foreach}
</table>
</div>
{/foreach}
</div>
<p>&nbsp;</p>
<div class="margin-form">
<input type="submit" class="button" name="submitProductWarehouses" value="{l s='Update warehouses locations'}"/>
<input type="submit" class="button" name="submitProductWarehouses" value="{l s='Update warehouses locations'}" />
</div>
<script type="text/javascript">
$(function() {
window.setTimeout(function() {
$('#accordion').accordion();
$('#check_all_suppliers').click(function() {
var check = $(this);
//get all checkboxes of current warehouse
var checkboxes = $('input[name*="'+check.val()+'"]');
for (i=0; i<checkboxes.length; i++)
{
var item = $(checkboxes[i]);
if (item.is(':checked'))
{
item.attr("checked", "");
}
else
{
item.attr("checked", "checked");
}
}
});
setTimeout(function() {
$('#warehouse_accordion').accordion();
}, 500);
});
</script>
@@ -1787,12 +1787,12 @@ class AdminProductsControllerCore extends AdminController
{
$this->toolbar_btn['save'] = array(
'short' => 'Save',
'href' => '#todo'.$this->context->link->getAdminLink('AdminProducts').'&amp;id_product='.$product->id,
'href' => '#todo'.$this->context->link->getAdminLink('AdminProducts').'&amp;id_product='.$product->id,
'desc' => $this->l('Save'),
);
$this->toolbar_btn['save-and-stay'] = array(
'short' => 'SaveAndStay',
'href' => '#todo'.$this->context->link->getAdminLink('AdminProducts').'&amp;id_product='.$product->id,
'href' => '#todo'.$this->context->link->getAdminLink('AdminProducts').'&amp;id_product='.$product->id,
'desc' => $this->l('Save and stay'),
);
}