[-] BO: Fix #PSCFV-8422 it is now possible to manage minimal quantity even if stock management is disabled

This commit is contained in:
Rémi Gaillard
2013-03-25 16:48:57 +01:00
parent 2120d1f948
commit 3aba9f026b
2 changed files with 193 additions and 198 deletions
@@ -26,177 +26,174 @@
{if isset($product->id)} {if isset($product->id)}
<input type="hidden" name="submitted_tabs[]" value="Quantities" /> <input type="hidden" name="submitted_tabs[]" value="Quantities" />
<h4>{l s='Available quantities for sale'}</h4> <h4>{l s='Available quantities for sale'}</h4>
{include file="controllers/products/multishop/check_fields.tpl" product_tab="Quantities"}
<div class="separation"></div> <div class="separation"></div>
<div class="hint" style="display:block; position:'auto';"> {if !$ps_stock_management}
<p>{l s='This interface allows you to manage available quantities for sale for products. It also allows you to manage product combinations in the current shop.'}</p> <div class="hint" style="display:block; position:auto;">{l s='The stock management is disabled'}</div>
<p>{l s='You can choose whether or not to use the advanced stock management system for this product.'}</p> {else}
<p>{l s='You can manually specify the quantities for the product/each product combination, or you can choose to automatically determine these quantities based on your stock (if advanced stock management is activated).'}</p> {include file="controllers/products/multishop/check_fields.tpl" product_tab="Quantities"}
<p>{l s='In this case, quantities correspond to the real-stock quantities in the warehouses connected with the current shop, or current group of shops.'}</p> <div class="hint" style="display:block; position:'auto';">
<br/> <p>{l s='This interface allows you to manage available quantities for sale for products. It also allows you to manage product combinations in the current shop.'}</p>
<p>{l s='For packs: If it has products that use advanced stock management, you have to specify a common warehouse for these products in the pack.'}</p> <p>{l s='You can choose whether or not to use the advanced stock management system for this product.'}</p>
<p>{l s='Also, please note that when a product has combinations, its default combination will be used in stock movements.'}</p> <p>{l s='You can manually specify the quantities for the product/each product combination, or you can choose to automatically determine these quantities based on your stock (if advanced stock management is activated).'}</p>
</div> <p>{l s='In this case, quantities correspond to the real-stock quantities in the warehouses connected with the current shop, or current group of shops.'}</p>
<br /> <br/>
<h4>{l s='Available quantities for sale'}</h4> <p>{l s='For packs: If it has products that use advanced stock management, you have to specify a common warehouse for these products in the pack.'}</p>
<div class="separation"></div> <p>{l s='Also, please note that when a product has combinations, its default combination will be used in stock movements.'}</p>
{if $show_quantities == true} </div>
<div class="warn" id="available_quantity_ajax_msg" style="display: none;"></div> <br />
<div class="error" id="available_quantity_ajax_error_msg" style="display: none;"></div> {if $show_quantities == true}
<div class="conf" id="available_quantity_ajax_success_msg" style="display: none;"></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%"> <table cellpadding="5" style="width:100%">
<tbody> <tbody>
<tr {if $product->is_virtual || $product->cache_is_pack}style="display:none;"{/if} class="stockForVirtualProduct"> <tr {if $product->is_virtual || $product->cache_is_pack}style="display:none;"{/if} class="stockForVirtualProduct">
<td valign="top" style="vertical-align:top;"> <td valign="top" style="vertical-align:top;">
<input <input
{if $product->advanced_stock_management == 1 && $stock_management_active == 1} {if $product->advanced_stock_management == 1 && $stock_management_active == 1}
value="1" checked="checked" value="1" checked="checked"
{else} {else}
value="0" value="0"
{/if} {/if}
{if $stock_management_active == 0 || $product->cache_is_pack} {if $stock_management_active == 0 || $product->cache_is_pack}
disabled="disabled" disabled="disabled"
{/if} {/if}
type="checkbox" name="advanced_stock_management" class="advanced_stock_management" id="advanced_stock_management" /> type="checkbox" name="advanced_stock_management" class="advanced_stock_management" id="advanced_stock_management" />
<label style="float:none;font-weight:normal" for="advanced_stock_management"> <label style="float:none;font-weight:normal" for="advanced_stock_management">
{l s='I want to use the advanced stock management system for this product.'} {l s='I want to use the advanced stock management system for this product.'}
{if $stock_management_active == 0 && !$product->cache_is_pack} {if $stock_management_active == 0 && !$product->cache_is_pack}
&nbsp;-&nbsp;<b>{l s='This requires you to enable advanced stock management.'}</b> &nbsp;-&nbsp;<b>{l s='This requires you to enable advanced stock management.'}</b>
{else if $product->cache_is_pack} {else if $product->cache_is_pack}
&nbsp;-&nbsp;<b>{l s='This parameter depends on the product(s) in the pack.'}</b> &nbsp;-&nbsp;<b>{l s='This parameter depends on the product(s) in the pack.'}</b>
{/if} {/if}
</label> </label>
<br /><br /> <br /><br />
</td> </td>
</tr> </tr>
<tr {if $product->is_virtual || $product->cache_is_pack}style="display:none;"{/if} class="stockForVirtualProduct"> <tr {if $product->is_virtual || $product->cache_is_pack}style="display:none;"{/if} class="stockForVirtualProduct">
<td valign="top" style="vertical-align:top;"> <td valign="top" style="vertical-align:top;">
<input <input
{if $product->depends_on_stock == 1 && $stock_management_active == 1} {if $product->depends_on_stock == 1 && $stock_management_active == 1}
checked="checked" checked="checked"
{/if} {/if}
{if $stock_management_active == 0 || $product->advanced_stock_management == 0 || $product->cache_is_pack} {if $stock_management_active == 0 || $product->advanced_stock_management == 0 || $product->cache_is_pack}
disabled="disabled" disabled="disabled"
{/if} {/if}
type="radio" name="depends_on_stock" class="depends_on_stock" id="depends_on_stock_1" value="1"/> 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"> <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 warehouse stock. '} {l s='Available quantities for current product and its combinations are based on warehouse stock. '}
{if ($stock_management_active == 0 || $product->advanced_stock_management == 0) && !$product->cache_is_pack} {if ($stock_management_active == 0 || $product->advanced_stock_management == 0) && !$product->cache_is_pack}
&nbsp;-&nbsp;<b>{l s='This requires you to enable advanced stock management globally or for this product.'}</b> &nbsp;-&nbsp;<b>{l s='This requires you to enable advanced stock management globally or for this product.'}</b>
{else if $product->cache_is_pack} {else if $product->cache_is_pack}
&nbsp;-&nbsp;<b>{l s='This parameter depends on the product(s) in the pack.'}</b> &nbsp;-&nbsp;<b>{l s='This parameter depends on the product(s) in the pack.'}</b>
{/if} {/if}
</label> </label>
<br /><br /> <br /><br />
</td> </td>
</tr> </tr>
<tr {if $product->is_virtual || $product->cache_is_pack}style="display:none;"{/if} class="stockForVirtualProduct"> <tr {if $product->is_virtual || $product->cache_is_pack}style="display:none;"{/if} class="stockForVirtualProduct">
<td valign="top" style="vertical-align:top;"> <td valign="top" style="vertical-align:top;">
<input <input
{if $product->depends_on_stock == 0 || $stock_management_active == 0} {if $product->depends_on_stock == 0 || $stock_management_active == 0}
checked="checked" checked="checked"
{/if} {/if}
type="radio" name="depends_on_stock" class="depends_on_stock" id="depends_on_stock_0" value="0"/> 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"> <label style="float:none;font-weight:normal" for="depends_on_stock_0">
{l s='I want to specify available quantities manually.'} {l s='I want to specify available quantities manually.'}
</label> </label>
<br /><br /> <br /><br />
</td> </td>
</tr> </tr>
{if isset($pack_quantity)} {if isset($pack_quantity)}
<tr> <tr>
<td valign="top" style="text-align:left;vertical-align:top;"> <td valign="top" style="text-align:left;vertical-align:top;">
<p><b>{l s='When a product has combinations, quantities will be based on the default combination.'}</b></p> <p><b>{l s='When a product has combinations, quantities will be based on the default combination.'}</b></p>
<p><b>{l s='Given the quantities of the products in this pack, the maximum quantity should be:'} {$pack_quantity}</b></p> <p><b>{l s='Given the quantities of the products in this pack, the maximum quantity should be:'} {$pack_quantity}</b></p>
</td> </td>
</tr> </tr>
{/if} {/if}
<tr> <tr>
<td valign="top" style="text-align:left;vertical-align:top;"> <td valign="top" style="text-align:left;vertical-align:top;">
<table class="table" cellpadding="0" cellspacing="0" style="width:100%;"> <table class="table" cellpadding="0" cellspacing="0" style="width:100%;">
<colgroup> <colgroup>
<col width="50"> <col width="50">
<col> <col>
</colgroup> </colgroup>
<thead> <thead>
<tr> <tr>
<th>{l s='Quantity'}</th> <th>{l s='Quantity'}</th>
<th>{l s='Designation'}</th> <th>{l s='Designation'}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{foreach from=$attributes item=attribute} {foreach from=$attributes item=attribute}
<tr> <tr>
<td class="available_quantity" id="qty_{$attribute['id_product_attribute']}"> <td class="available_quantity" id="qty_{$attribute['id_product_attribute']}">
<span>{$available_quantity[$attribute['id_product_attribute']]}</span> <span>{$available_quantity[$attribute['id_product_attribute']]}</span>
<input type="text" value="{$available_quantity[$attribute['id_product_attribute']]|htmlentities}"/> <input type="text" value="{$available_quantity[$attribute['id_product_attribute']]|htmlentities}"/>
</td> </td>
<td>{$product_designation[$attribute['id_product_attribute']]}</td> <td>{$product_designation[$attribute['id_product_attribute']]}</td>
</tr> </tr>
{/foreach} {/foreach}
</tbody> </tbody>
</table> </table>
</td> </td>
</tr> </tr>
<tr id="when_out_of_stock"> <tr id="when_out_of_stock">
<td> <td>
<table style="margin-top: 15px;"> <table style="margin-top: 15px;">
<tbody> <tbody>
<tr> <tr>
<td class="col-left"><label>{l s='When out of stock:'}</label></td> <td class="col-left"><label>{l s='When out of stock:'}</label></td>
<td style="padding-bottom:5px;"> <td style="padding-bottom:5px;">
<ul class="listForm"> <ul class="listForm">
<li> <li>
<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"> <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> <label id="label_out_of_stock_1" class="t" for="out_of_stock_1">{l s='Deny orders'}</label>
</li>
<li>
<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>
</li> </li>
<li> <li>
<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"> <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_2" class="t" for="out_of_stock_2">{l s='Allow orders'}</label> <label id="label_out_of_stock_3" class="t" for="out_of_stock_3">
</li> {l s='Default'}:
<li> {if $order_out_of_stock == 1}
<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"> <i>{l s='Allow orders'}</i>
<label id="label_out_of_stock_3" class="t" for="out_of_stock_3"> {else}
{l s='Default'}: <i>{l s='Deny orders'}</i>
{if $order_out_of_stock == 1} {/if}
<i>{l s='Allow orders'}</i> <a class="confirm_leave" href="index.php?tab=AdminPPreferences&token={$token_preferences}">
{else} {l s='as set in Preferences'}
<i>{l s='Deny orders'}</i> </a>
{/if} </label>
<a class="confirm_leave" href="index.php?tab=AdminPPreferences&token={$token_preferences}"> </li>
{l s='as set in Preferences'} </ul>
</a> </td>
</label> </tr>
</li> </tbody>
</ul> </table>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</td> {else}
</tr> <div class="warn">
</tbody> <p>{l s='It is not possible to manage quantities when:'}</p>
</table> <ul>
{else} <li>{l s='You are currently managing all of your shops.'}</li>
<div class="warn"> <li>{l s='You are currently managing a group of shops where quantities are not shared between every shop in this group.'}</li>
<p>{l s='It is not possible to manage quantities when:'}</p> <li>{l s='You are currently managing a shop that is in a group where quantities are shared between every shop in this group.'}</li>
<ul> </ul>
<li>{l s='You are currently managing all of your shops.'}</li> </div>
<li>{l s='You are currently managing a group of shops where quantities are not shared between every shop in this group.'}</li> {/if}
<li>{l s='You are currently managing a shop that is in a group where quantities are shared between every shop in this group.'}</li>
</ul>
</div>
{/if} {/if}
<div class="separation"></div> <div class="separation"></div>
<h4>{l s='Availability settings'}</h4> <h4>{l s='Availability settings'}</h4>
<table cellpadding="5"> <table cellpadding="5">
{if !$ps_stock_management}
<tr>
<td colspan="2">{l s='The stock management is disabled'}</td>
</tr>
{/if}
{if !$has_attribute} {if !$has_attribute}
<tr> <tr>
<td class="col-left"><label>{l s='Minimum quantity:'}</label></td> <td class="col-left"><label>{l s='Minimum quantity:'}</label></td>
@@ -206,41 +203,43 @@
</td> </td>
</tr> </tr>
{/if} {/if}
<tr> {if $ps_stock_management}
<td class="col-left">
{include file="controllers/products/multishop/checkbox.tpl" field="available_now" type="default" multilang="true"}
<label>{l s='Displayed text when in-stock:'}</label>
</td>
<td style="padding-bottom:5px;" class="col-right">
{include file="controllers/products/input_text_lang.tpl"
languages=$languages
input_value=$product->available_now
input_name='available_now'}
<span class="hint" name="help_box">{l s='Forbidden characters:'} <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
</td>
</tr>
<tr>
<td class="col-left">
{include file="controllers/products/multishop/checkbox.tpl" field="available_later" type="default" multilang="true"}
<label>{l s='Displayed text when back-ordereding is allowed:'}</label>
</td>
<td style="padding-bottom:5px;" class="col-right">
{include file="controllers/products/input_text_lang.tpl"
languages=$languages
input_value=$product->available_later
input_name='available_later'}
<span class="hint" name="help_box">{l s='Forbidden characters:'} <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
</td>
</tr>
{if !$countAttributes}
<tr> <tr>
<td class="col-left"><label>{l s='Available date:'}</label></td> <td class="col-left">
<td style="padding-bottom:5px;"> {include file="controllers/products/multishop/checkbox.tpl" field="available_now" type="default" multilang="true"}
<input id="available_date" name="available_date" value="{$product->available_date}" class="datepicker" <label>{l s='Displayed text when in-stock:'}</label>
style="text-align: center;" type="text" /> </td>
<p>{l s='The available date when this product is out of stock.'}</p> <td style="padding-bottom:5px;" class="col-right">
{include file="controllers/products/input_text_lang.tpl"
languages=$languages
input_value=$product->available_now
input_name='available_now'}
<span class="hint" name="help_box">{l s='Forbidden characters:'} <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
</td>
</tr>
<tr>
<td class="col-left">
{include file="controllers/products/multishop/checkbox.tpl" field="available_later" type="default" multilang="true"}
<label>{l s='Displayed text when back-ordereding is allowed:'}</label>
</td>
<td style="padding-bottom:5px;" class="col-right">
{include file="controllers/products/input_text_lang.tpl"
languages=$languages
input_value=$product->available_later
input_name='available_later'}
<span class="hint" name="help_box">{l s='Forbidden characters:'} <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
</td> </td>
</tr> </tr>
{if !$countAttributes}
<tr>
<td class="col-left"><label>{l s='Available date:'}</label></td>
<td style="padding-bottom:5px;">
<input id="available_date" name="available_date" value="{$product->available_date}" class="datepicker"
style="text-align: center;" type="text" />
<p>{l s='The available date when this product is out of stock.'}</p>
</td>
</tr>
{/if}
{/if} {/if}
</table> </table>
@@ -2206,10 +2206,6 @@ class AdminProductsControllerCore extends AdminController
foreach ($this->available_tabs as $product_tab => $value) foreach ($this->available_tabs as $product_tab => $value)
{ {
// if it's the quantities tab and stock management is disabled, continue
if ($stock_management_active == 0 && $product_tab == 'Quantities')
continue;
// if it's the warehouses tab and advanced stock management is disabled, continue // if it's the warehouses tab and advanced stock management is disabled, continue
if ($advanced_stock_management_active == 0 && $product_tab == 'Warehouses') if ($advanced_stock_management_active == 0 && $product_tab == 'Warehouses')
continue; continue;