// More BO product page cleanup
This commit is contained in:
@@ -92,109 +92,28 @@
|
||||
$('#product-tab-content-wait').show();
|
||||
var post_data = {$post_data};
|
||||
|
||||
var product_type;
|
||||
{*var is_pack = {$is_pack};
|
||||
var is_virtual = {$product->is_virtual};
|
||||
var mce_maximum = '{l s='Maximum'}';
|
||||
var product_type = {$product_type};
|
||||
{*var mce_maximum = '{l s='Maximum'}';
|
||||
var mce_characters = '{l s='characters'}';*}
|
||||
|
||||
$(document).ready(function()
|
||||
{
|
||||
product_type = $("input[name=type_product]:checked").val();
|
||||
$('#product-tab-content-wait').show();
|
||||
{if $is_pack}
|
||||
tabs_manager.onLoad('Informations', function(){
|
||||
$('#pack_product').attr('checked', 'checked');
|
||||
});
|
||||
//product_type = $("input[name=type_product]:checked").val();
|
||||
if (product_type == product_type_pack)
|
||||
{
|
||||
$('li.tab-row a[id*="VirtualProduct"]').hide();
|
||||
{elseif $product->is_virtual}
|
||||
tabs_manager.onLoad('Informations', function(){
|
||||
$('#virtual_product').attr('checked', 'checked');
|
||||
$('#condition').attr('disabled', 'disabled');
|
||||
$('#condition option[value=new]').attr('selected', 'selected');
|
||||
});
|
||||
}
|
||||
else if (product_type == product_type_virtual)
|
||||
{
|
||||
$('li.tab-row a[id*="Pack"]').hide();
|
||||
$('li.tab-row a[id*="Shipping"]').hide();
|
||||
{else}
|
||||
tabs_manager.onLoad('Informations', function(){
|
||||
$('#simple_product').attr('checked', 'checked');
|
||||
});
|
||||
$('li.tab-row a[id*="Pack"]').hide();
|
||||
$('li.tab-row a[id*="VirtualProduct"]').hide();
|
||||
{/if}
|
||||
|
||||
$('input[name="type_product"]').live('click', function()
|
||||
}
|
||||
else
|
||||
{
|
||||
// Reset settings
|
||||
$('li.tab-row a[id*="Pack"]').hide();
|
||||
$('li.tab-row a[id*="VirtualProduct"]').hide();
|
||||
$('div.ppack').hide();
|
||||
$('#is_virtual_good').removeAttr('checked');
|
||||
$('div.is_virtual_good').hide();
|
||||
$('#is_virtual').val(0);
|
||||
$("#virtual_good_attributes").hide();
|
||||
|
||||
// product_type is now global
|
||||
product_type = $(this).val();
|
||||
|
||||
// until a product is added in the pack
|
||||
// if product is PTYPE_PACK, save buttons will be disabled
|
||||
if (product_type == {Product::PTYPE_PACK})
|
||||
{
|
||||
//when you change the type of the product, directly go to the pack tab
|
||||
$('li.tab-row a[id*="Pack"]').show().click();
|
||||
$('#ppack').val(1).attr('checked', true).attr('disabled', 'disabled');
|
||||
$('#ppackdiv').show();
|
||||
// If the pack tab has not finished loaded the changes will be made when the loading event is triggered
|
||||
$("#product-tab-content-Pack").bind('loaded', function(){
|
||||
$('#ppack').val(1).attr('checked', true).attr('disabled', 'disabled');
|
||||
$('#ppackdiv').show();
|
||||
});
|
||||
$("#product-tab-content-Quantities").bind('loaded', function(){
|
||||
$('.stockForVirtualProduct').show();
|
||||
});
|
||||
|
||||
$('li.tab-row a[id*="Shipping"]').show();
|
||||
$('#condition').removeAttr('disabled');
|
||||
$('#condition option[value=new]').removeAttr('selected');
|
||||
$('.stockForVirtualProduct').show();
|
||||
// if pack is enabled, if you choose pack, automatically switch to pack page
|
||||
}
|
||||
else if (product_type == {Product::PTYPE_VIRTUAL})
|
||||
{
|
||||
$('li.tab-row a[id*="VirtualProduct"]').show().click();
|
||||
|
||||
tabs_manager.onLoad('VirtualProduct', function(){
|
||||
$('#is_virtual_good').attr('checked', true);
|
||||
$('#virtual_good').show();
|
||||
$('#is_virtual').val(1);
|
||||
$("#virtual_good_attributes").show();
|
||||
});
|
||||
|
||||
tabs_manager.onLoad('Quantities', function(){
|
||||
$('.stockForVirtualProduct').hide();
|
||||
});
|
||||
|
||||
$('li.tab-row a[id*="Shipping"]').hide();
|
||||
|
||||
tabs_manager.onLoad('Informations', function(){
|
||||
$('#condition').attr('disabled', 'disabled');
|
||||
$('#condition option[value=refurbished]').removeAttr('selected');
|
||||
$('#condition option[value=used]').removeAttr('selected');
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
// 3rd case : product_type is PTYPE_SIMPLE (0)
|
||||
$('li.tab-row a[id*="Shipping"]').show();
|
||||
$('#condition').removeAttr('disabled');
|
||||
$('#condition option[value=new]').removeAttr('selected');
|
||||
$('.stockForVirtualProduct').show();
|
||||
}
|
||||
// this handle the save button displays and warnings
|
||||
handleSaveButtons();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
$('#desc-product-newCombination').hide();
|
||||
|
||||
|
||||
@@ -34,11 +34,11 @@
|
||||
|
||||
<div>
|
||||
<label class="text">{l s='Type:'}</label>
|
||||
<input type="radio" name="type_product" id="simple_product" value="{Product::PTYPE_SIMPLE}" {if (isset($smarty.post.type_product) && Product::PTYPE_SIMPLE == $smarty.post.type_product)}checked="checked"{/if} />
|
||||
<input type="radio" name="type_product" id="simple_product" value="{Product::PTYPE_SIMPLE}" {if $product_type == Product::PTYPE_SIMPLE}checked="checked"{/if} />
|
||||
<label class="radioCheck" for="simple_product">{l s='Product'}</label>
|
||||
<input type="radio" name="type_product" id="pack_product" value="{Product::PTYPE_PACK}" {if $is_pack || (isset($smarty.post.type_product) && Product::PTYPE_PACK == $smarty.post.type_product)}checked="checked"{/if} />
|
||||
<input type="radio" name="type_product" id="pack_product" value="{Product::PTYPE_PACK}" {if $product_type == Product::PTYPE_PACK}checked="checked"{/if} />
|
||||
<label class="radioCheck" for="pack_product">{l s='Pack'}</label>
|
||||
<input type="radio" name="type_product" id="virtual_product" value="{Product::PTYPE_VIRTUAL}" {if (isset($smarty.post.type_product) && Product::PTYPE_VIRTUAL == $smarty.post.type_product)}checked="checked"{/if} />
|
||||
<input type="radio" name="type_product" id="virtual_product" value="{Product::PTYPE_VIRTUAL}" {if $product_type == Product::PTYPE_VIRTUAL}checked="checked"{/if} />
|
||||
<label class="radioCheck" for="virtual_product">{l s='Virtual Product (services, booking and downloadable products)'}</label>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -36,12 +36,12 @@
|
||||
<tr>
|
||||
<td>
|
||||
<div class="ppack">
|
||||
<input type="checkbox" name="ppack" id="ppack" value="1" {if $is_pack}checked="checked"{/if} onclick="$('#ppackdiv').slideToggle();" />
|
||||
<input type="checkbox" name="ppack" id="ppack" value="1" {if $product_type == Product::PTYPE_PACK}checked="checked"{/if} onclick="$('#ppackdiv').slideToggle();" />
|
||||
<label class="t" for="ppack">{l s='Pack'}</label>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div id="ppackdiv" {if !$is_pack}style="display: none;"{/if}>
|
||||
<div id="ppackdiv" {if !($product_type == Product::PTYPE_PACK)}style="display: none;"{/if}>
|
||||
|
||||
<label for="curPackItemName" style="width:560px;text-align:left;">
|
||||
{l s='Begin typing the first letters of the product name, then select the product from the drop-down list:'}
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
|
||||
{* BEGIN CUSTOMER AUTO-COMPLETE / TO REFACTO *}
|
||||
|
||||
<script type="text/javascript">
|
||||
var Customer = {
|
||||
"hiddenField": jQuery('#id_customer'),
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
$('#is_virtual_file_product').hide();
|
||||
}
|
||||
|
||||
$('input[name=is_virtual_file]').live('change', function() {
|
||||
$('input[name=is_virtual_file]').live('change', function(e) {
|
||||
if($(this).val() == '1')
|
||||
{
|
||||
$('#virtual_good_more').show();
|
||||
|
||||
@@ -36,6 +36,9 @@ class PackCore extends Product
|
||||
if (!Pack::isFeatureActive())
|
||||
return false;
|
||||
|
||||
if (!$id_product)
|
||||
return false;
|
||||
|
||||
if (!array_key_exists($id_product, self::$cacheIsPack))
|
||||
{
|
||||
$result = Db::getInstance()->getValue('SELECT COUNT(*) FROM '._DB_PREFIX_.'pack WHERE id_product_pack = '.(int)$id_product);
|
||||
|
||||
@@ -4907,4 +4907,21 @@ class ProductCore extends ObjectModel
|
||||
return $this->deleteAttributeCombination($id_lang);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the product type (simple, virtual, pack)
|
||||
* @since in 1.5.0
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
if (!$this->id)
|
||||
return Product::PTYPE_SIMPLE;
|
||||
if (Pack::isPack($this->id))
|
||||
return Product::PTYPE_PACK;
|
||||
if ($this->is_virtual)
|
||||
return Product::PTYPE_VIRTUAL;
|
||||
|
||||
return Product::PTYPE_SIMPLE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2144,10 +2144,14 @@ class AdminProductsControllerCore extends AdminController
|
||||
if (!method_exists($this, 'initForm'.$this->tab_display))
|
||||
return;
|
||||
|
||||
$product = $this->object;
|
||||
|
||||
// Sort the tabs that need to be preloaded by their priority number
|
||||
asort($this->available_tabs, SORT_NUMERIC);
|
||||
$this->tpl_form_vars['tabs_preloaded'] = $this->available_tabs;
|
||||
|
||||
$this->tpl_form_vars['product_type'] = $product->getType();
|
||||
|
||||
// getLanguages init this->_languages
|
||||
$this->getLanguages();
|
||||
$languages = $this->_languages;
|
||||
@@ -2708,9 +2712,9 @@ class AdminProductsControllerCore extends AdminController
|
||||
'languages' => $languages,
|
||||
'default_language' => $default_language,
|
||||
'ps_ssl_enabled' => Configuration::get('PS_SSL_ENABLED'),
|
||||
'is_pack' => ($product->id && Pack::isPack($product->id)) || Tools::getValue('ppack') || Tools::getValue('type_product') == Product::PTYPE_PACK,
|
||||
'input_pack_items' => $input_pack_items,
|
||||
'input_namepack_items' => $input_namepack_items
|
||||
'input_namepack_items' => $input_namepack_items,
|
||||
'product_type' => $product->getType()
|
||||
));
|
||||
|
||||
$this->tpl_form_vars['custom_form'] = $data->fetch();
|
||||
@@ -3143,6 +3147,8 @@ class AdminProductsControllerCore extends AdminController
|
||||
|
||||
$product->tags = Tag::getProductTags($product->id);
|
||||
|
||||
$data->assign('product_type', $product->getType());
|
||||
|
||||
// TinyMCE
|
||||
$iso_tiny_mce = $this->context->language->iso_code;
|
||||
$iso_tiny_mce = (file_exists(_PS_JS_DIR_.'tiny_mce/langs/'.$iso_tiny_mce.'.js') ? $iso_tiny_mce : 'en');
|
||||
|
||||
+92
-3
@@ -24,6 +24,7 @@
|
||||
*/
|
||||
|
||||
// array of product tab objects containing methods and dom bindings
|
||||
// The ProductTabsManager instance will make sure the onReady() methods of each tabs are executed once the tab has loaded
|
||||
var product_tabs = [];
|
||||
|
||||
product_tabs['Combinations'] = {
|
||||
@@ -251,7 +252,7 @@ function enableSave()
|
||||
|
||||
function handleSaveButtons(e)
|
||||
{
|
||||
product_type = $("input[name=type_product]:checked").val();
|
||||
//product_type = $("input[name=type_product]:checked").val();
|
||||
msg = [];
|
||||
var i = 0;
|
||||
// relative to type of product
|
||||
@@ -542,6 +543,93 @@ product_tabs['Informations'] = {
|
||||
}
|
||||
});
|
||||
},
|
||||
'switchProductType' : function(){
|
||||
if (product_type == product_type_pack)
|
||||
{
|
||||
$('#pack_product').attr('checked', 'checked');
|
||||
}
|
||||
else if (product_type == product_type_virtual)
|
||||
{
|
||||
$('#virtual_product').attr('checked', 'checked');
|
||||
$('#condition').attr('disabled', 'disabled');
|
||||
$('#condition option[value=new]').attr('selected', 'selected');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#simple_product').attr('checked', 'checked');
|
||||
}
|
||||
|
||||
$('input[name="type_product"]').live('click', function()
|
||||
{
|
||||
// Reset settings
|
||||
$('li.tab-row a[id*="Pack"]').hide();
|
||||
$('li.tab-row a[id*="VirtualProduct"]').hide();
|
||||
$('div.ppack').hide();
|
||||
$('#is_virtual_good').removeAttr('checked');
|
||||
$('div.is_virtual_good').hide();
|
||||
$('#is_virtual').val(0);
|
||||
$("#virtual_good_attributes").hide();
|
||||
|
||||
product_type = $(this).val();
|
||||
|
||||
// until a product is added in the pack
|
||||
// if product is PTYPE_PACK, save buttons will be disabled
|
||||
if (product_type == product_type_pack)
|
||||
{
|
||||
//when you change the type of the product, directly go to the pack tab
|
||||
$('li.tab-row a[id*="Pack"]').show().click();
|
||||
$('#ppack').val(1).attr('checked', true).attr('disabled', 'disabled');
|
||||
$('#ppackdiv').show();
|
||||
// If the pack tab has not finished loaded the changes will be made when the loading event is triggered
|
||||
$("#product-tab-content-Pack").bind('loaded', function(){
|
||||
$('#ppack').val(1).attr('checked', true).attr('disabled', 'disabled');
|
||||
$('#ppackdiv').show();
|
||||
});
|
||||
$("#product-tab-content-Quantities").bind('loaded', function(){
|
||||
$('.stockForVirtualProduct').show();
|
||||
});
|
||||
|
||||
$('li.tab-row a[id*="Shipping"]').show();
|
||||
$('#condition').removeAttr('disabled');
|
||||
$('#condition option[value=new]').removeAttr('selected');
|
||||
$('.stockForVirtualProduct').show();
|
||||
// if pack is enabled, if you choose pack, automatically switch to pack page
|
||||
}
|
||||
else if (product_type == product_type_virtual)
|
||||
{
|
||||
$('li.tab-row a[id*="VirtualProduct"]').show().click();
|
||||
|
||||
tabs_manager.onLoad('VirtualProduct', function(){
|
||||
$('#is_virtual_good').attr('checked', true);
|
||||
$('#virtual_good').show();
|
||||
$('#is_virtual').val(1);
|
||||
$("#virtual_good_attributes").show();
|
||||
});
|
||||
|
||||
tabs_manager.onLoad('Quantities', function(){
|
||||
$('.stockForVirtualProduct').hide();
|
||||
});
|
||||
|
||||
$('li.tab-row a[id*="Shipping"]').hide();
|
||||
|
||||
tabs_manager.onLoad('Informations', function(){
|
||||
$('#condition').attr('disabled', 'disabled');
|
||||
$('#condition option[value=refurbished]').removeAttr('selected');
|
||||
$('#condition option[value=used]').removeAttr('selected');
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
// 3rd case : product_type is PTYPE_SIMPLE (0)
|
||||
$('li.tab-row a[id*="Shipping"]').show();
|
||||
$('#condition').removeAttr('disabled');
|
||||
$('#condition option[value=new]').removeAttr('selected');
|
||||
$('.stockForVirtualProduct').show();
|
||||
}
|
||||
// this handle the save button displays and warnings
|
||||
handleSaveButtons();
|
||||
});
|
||||
},
|
||||
/*'setup_tinymce': function(){
|
||||
// change each by click to load only on click
|
||||
$(".autoload_rte").each(function(e){
|
||||
@@ -577,11 +665,12 @@ product_tabs['Informations'] = {
|
||||
'onReady' : function(){
|
||||
product_tabs['Informations'].bindAvailableForOrder();
|
||||
product_tabs['Informations'].bindTagImage();
|
||||
product_tabs['Informations'].switchProductType();
|
||||
}
|
||||
}
|
||||
|
||||
product_tabs['Pack'] = {
|
||||
'packFunctions' : function (){
|
||||
'bindPackEvents' : function (){
|
||||
if ($('#ppack').attr('checked'))
|
||||
{
|
||||
$('#ppack').attr('disabled', 'disabled');
|
||||
@@ -710,7 +799,7 @@ product_tabs['Pack'] = {
|
||||
}
|
||||
},
|
||||
'onReady' : function(){
|
||||
product_tabs['Pack'].packFunctions();
|
||||
product_tabs['Pack'].bindPackEvents();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user