[+] Project : adding Features detachables in order to improve performance
// clean code
This commit is contained in:
@@ -99,7 +99,7 @@ class AdminAttributeGenerator extends AdminTab
|
||||
parent::postProcess();
|
||||
}
|
||||
|
||||
static private function displayAndReturnAttributeJs()
|
||||
private static function displayAndReturnAttributeJs()
|
||||
{
|
||||
$attributes = Attribute::getAttributes($this->context->language->id, true);
|
||||
$attributeJs = array();
|
||||
@@ -142,7 +142,7 @@ class AdminAttributeGenerator extends AdminTab
|
||||
</div>';
|
||||
}
|
||||
|
||||
static private function setAttributesImpacts($id_product, $tab)
|
||||
private static function setAttributesImpacts($id_product, $tab)
|
||||
{
|
||||
$attributes = array();
|
||||
foreach ($tab AS $group)
|
||||
@@ -155,7 +155,7 @@ class AdminAttributeGenerator extends AdminTab
|
||||
);
|
||||
}
|
||||
|
||||
static private function getAttributesImpacts($id_product)
|
||||
private static function getAttributesImpacts($id_product)
|
||||
{
|
||||
$tab = array();
|
||||
$result = Db::getInstance()->ExecuteS(
|
||||
@@ -216,6 +216,12 @@ class AdminAttributeGenerator extends AdminTab
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
if (!Combination::isFeatureActive())
|
||||
{
|
||||
$this->displayWarning($this->l('This feature has been disabled, you can active this feature at this page:').' <a href="index.php?tab=AdminPerformance&token='.Tools::getAdminTokenLite('AdminPerformance').'#featuresDetachables">'.$this->l('Performances').'</a>');
|
||||
return;
|
||||
}
|
||||
|
||||
parent::displayForm();
|
||||
|
||||
$jsAttributes = self::displayAndReturnAttributeJs();
|
||||
|
||||
@@ -46,6 +46,12 @@ class AdminAttributes extends AdminTab
|
||||
*/
|
||||
public function displayForm($token = NULL)
|
||||
{
|
||||
if (!Combination::isFeatureActive())
|
||||
{
|
||||
$this->displayWarning($this->l('This feature has been disabled, you can active this feature at this page:').' <a href="index.php?tab=AdminPerformance&token='.Tools::getAdminTokenLite('AdminPerformance').'#featuresDetachables">'.$this->l('Performances').'</a>');
|
||||
return;
|
||||
}
|
||||
|
||||
parent::displayForm();
|
||||
|
||||
if (!($obj = $this->loadObject(true)))
|
||||
@@ -127,6 +133,9 @@ class AdminAttributes extends AdminTab
|
||||
*/
|
||||
public function postProcess($token = NULL)
|
||||
{
|
||||
if (!Combination::isFeatureActive())
|
||||
return;
|
||||
|
||||
if (Tools::getValue('submitDel'.$this->table))
|
||||
{
|
||||
if ($this->tabAccess['delete'] === '1')
|
||||
|
||||
@@ -50,20 +50,26 @@ class AdminAttributesGroups extends AdminTab
|
||||
|
||||
public function display()
|
||||
{
|
||||
if ((isset($_POST['submitAddattribute']) AND sizeof($this->adminAttributes->_errors))
|
||||
OR isset($_GET['updateattribute']) OR isset($_GET['addattribute']))
|
||||
if (Combination::isFeatureActive())
|
||||
{
|
||||
$this->adminAttributes->displayForm($this->token);
|
||||
echo '<br /><br /><a href="'.self::$currentIndex.'&token='.$this->token.'"><img src="../img/admin/arrow2.gif" /> '.$this->l('Back to list').'</a><br />';
|
||||
if ((isset($_POST['submitAddattribute']) AND sizeof($this->adminAttributes->_errors))
|
||||
OR isset($_GET['updateattribute']) OR isset($_GET['addattribute']))
|
||||
{
|
||||
$this->adminAttributes->displayForm($this->token);
|
||||
echo '<br /><br /><a href="'.self::$currentIndex.'&token='.$this->token.'"><img src="../img/admin/arrow2.gif" /> '.$this->l('Back to list').'</a><br />';
|
||||
}
|
||||
else
|
||||
parent::display();
|
||||
}
|
||||
else
|
||||
{
|
||||
parent::display();
|
||||
}
|
||||
$this->displayWarning($this->l('This feature has been disabled, you can active this feature at this page:').' <a href="index.php?tab=AdminPerformance&token='.Tools::getAdminTokenLite('AdminPerformance').'#featuresDetachables">'.$this->l('Performances').'</a>');
|
||||
}
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (!Combination::isFeatureActive())
|
||||
return;
|
||||
|
||||
$this->adminAttributes->tabAccess = Profile::getProfileAccess(Context::getContext()->employee->id_profile, $this->id);
|
||||
$this->adminAttributes->postProcess($this->token);
|
||||
|
||||
@@ -166,6 +172,12 @@ class AdminAttributesGroups extends AdminTab
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
if (!Combination::isFeatureActive())
|
||||
{
|
||||
$this->displayWarning($this->l('This feature has been disabled, you can active this feature at this page:').' <a href="index.php?tab=AdminPerformance&token='.Tools::getAdminTokenLite('AdminPerformance').'#featuresDetachables">'.$this->l('Performances').'</a>');
|
||||
return;
|
||||
}
|
||||
|
||||
parent::displayForm();
|
||||
|
||||
if (!($obj = $this->loadObject(true)))
|
||||
|
||||
@@ -281,7 +281,7 @@ class AdminCarts extends AdminTab
|
||||
<tr>
|
||||
<td colspan="2">';
|
||||
foreach ($customization['datas'] AS $type => $datas)
|
||||
if ($type == _CUSTOMIZE_FILE_)
|
||||
if ($type == Product::CUSTOMIZE_FILE)
|
||||
{
|
||||
$i = 0;
|
||||
echo '<ul style="margin: 4px 0px 4px 0px; padding: 0px; list-style-type: none;">';
|
||||
@@ -291,7 +291,7 @@ class AdminCarts extends AdminTab
|
||||
</li>';
|
||||
echo '</ul>';
|
||||
}
|
||||
elseif ($type == _CUSTOMIZE_TEXTFIELD_)
|
||||
elseif ($type == Product::CUSTOMIZE_TEXTFIELD)
|
||||
{
|
||||
$i = 0;
|
||||
echo '<ul style="margin: 0px 0px 4px 0px; padding: 0px 0px 0px 6px; list-style-type: none;">';
|
||||
|
||||
@@ -36,8 +36,8 @@ class AdminDiscounts extends AdminTab
|
||||
$this->edit = true;
|
||||
$this->delete = true;
|
||||
$this->_select = 'dtl.`name` AS discount_type,
|
||||
IF(a.id_discount_type = 1, CONCAT(a.value, " %"),
|
||||
IF(a.id_discount_type = 2, CONCAT(a.value, " ", c.sign),
|
||||
IF(a.id_discount_type = '.(int)Discount::PERCENT.', CONCAT(a.value, " %"),
|
||||
IF(a.id_discount_type = '.(int)Discount::AMOUNT.', CONCAT(a.value, " ", c.sign),
|
||||
"--")) as strvalue';
|
||||
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'currency` c ON (c.`id_currency` = a.`id_currency`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'discount_type` dt ON (dt.`id_discount_type` = a.`id_discount_type`)
|
||||
@@ -91,9 +91,9 @@ class AdminDiscounts extends AdminTab
|
||||
{
|
||||
if (Tools::getValue('id_discount_type') == 0)
|
||||
$this->_errors[] = Tools::displayError('Please set a type for this voucher.');
|
||||
if (Tools::getValue('id_discount_type') == 2 AND Tools::getValue('id_currency') == 0)
|
||||
if (Tools::getValue('id_discount_type') == Discount::AMOUNT AND Tools::getValue('id_currency') == 0)
|
||||
$this->_errors[] = Tools::displayError('Please set a currency for this voucher.');
|
||||
if ((Tools::getValue('id_discount_type') == 1 || Tools::getValue('id_discount_type') == 2) && !Tools::getValue('value'))
|
||||
if ((Tools::getValue('id_discount_type') == Discount::PERCENT || Tools::getValue('id_discount_type') == 2) && !Tools::getValue('value'))
|
||||
$this->_errors[] = Tools::displayError('Please set a amount for this voucher.');
|
||||
if (!Validate::isBool_Id(Tools::getValue('id_target')))
|
||||
$this->_errors[] = Tools::displayError('Invalid customer or group ID field');
|
||||
@@ -227,13 +227,13 @@ class AdminDiscounts extends AdminTab
|
||||
{
|
||||
if ($("#id_discount_type").val() == 0)
|
||||
$("#value-div").css("display", "none");
|
||||
else if ($("#id_discount_type").val() == 1)
|
||||
else if ($("#id_discount_type").val() == '.Discount::PERCENT.')
|
||||
{
|
||||
$("#value-div").css("display", "block");
|
||||
$("#percent-span").css("display", "block");
|
||||
$("#id_currency").css("display", "none");
|
||||
}
|
||||
else if ($("#id_discount_type").val() == 2)
|
||||
else if ($("#id_discount_type").val() == '.Discount::AMOUNT.')
|
||||
{
|
||||
$("#value-div").css("display", "block");
|
||||
$("#percent-span").css("display", "none");
|
||||
@@ -241,9 +241,9 @@ class AdminDiscounts extends AdminTab
|
||||
$(\'#behavior_not_exhausted\').show();
|
||||
|
||||
}
|
||||
else if ($("#id_discount_type").val() == 3)
|
||||
else if ($("#id_discount_type").val() == '.Discount::FREE_SHIPPING.')
|
||||
$("#value-div").css("display", "none");
|
||||
if ($(\'#id_discount_type\').val() != 2)
|
||||
if ($(\'#id_discount_type\').val() != '.Discount::AMOUNT.')
|
||||
$(\'#behavior_not_exhausted\').hide();
|
||||
|
||||
}
|
||||
|
||||
@@ -47,16 +47,19 @@ class AdminFeatures extends AdminTab
|
||||
|
||||
public function display()
|
||||
{
|
||||
if ((isset($_POST['submitAddfeature_value']) AND sizeof($this->adminFeaturesValues->_errors))
|
||||
OR isset($_GET['updatefeature_value']) OR isset($_GET['addfeature_value']))
|
||||
if (Feature::isFeatureActive())
|
||||
{
|
||||
$this->adminFeaturesValues->displayForm($this->token);
|
||||
echo '<br /><br /><a href="'.self::$currentIndex.'&token='.$this->token.'"><img src="../img/admin/arrow2.gif" alt="" /> '.$this->l('Back to the features list').'</a><br />';
|
||||
if ((isset($_POST['submitAddfeature_value']) AND sizeof($this->adminFeaturesValues->_errors))
|
||||
OR isset($_GET['updatefeature_value']) OR isset($_GET['addfeature_value']))
|
||||
{
|
||||
$this->adminFeaturesValues->displayForm($this->token);
|
||||
echo '<br /><br /><a href="'.self::$currentIndex.'&token='.$this->token.'"><img src="../img/admin/arrow2.gif" alt="" /> '.$this->l('Back to the features list').'</a><br />';
|
||||
}
|
||||
else
|
||||
parent::display();
|
||||
}
|
||||
else
|
||||
{
|
||||
parent::display();
|
||||
}
|
||||
$this->displayWarning($this->l('This feature has been disabled, you can active this feature at this page:').' <a href="index.php?tab=AdminPerformance&token='.Tools::getAdminTokenLite('AdminPerformance').'#featuresDetachables">'.$this->l('Performances').'</a>');
|
||||
}
|
||||
|
||||
/* Report to AdminTab::displayList() for more details */
|
||||
@@ -131,6 +134,12 @@ class AdminFeatures extends AdminTab
|
||||
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
if (!Feature::isFeatureActive())
|
||||
{
|
||||
$this->displayWarning($this->l('This feature has been disabled, you can active this feature at this page:').'<a href="index.php?tab=AdminPerformance&token='.Tools::getAdminTokenLite('AdminPerformance').'#featuresDetachables">'.$this->l('Performances').'</a>');
|
||||
return;
|
||||
}
|
||||
|
||||
parent::displayForm();
|
||||
|
||||
if (!($obj = $this->loadObject(true)))
|
||||
@@ -177,6 +186,9 @@ class AdminFeatures extends AdminTab
|
||||
|
||||
public function postProcess()
|
||||
{
|
||||
if (!Feature::isFeatureActive())
|
||||
return ;
|
||||
|
||||
$this->adminFeaturesValues->tabAccess = Profile::getProfileAccess($this->context->employee->id_profile, $this->id);
|
||||
$this->adminFeaturesValues->postProcess($this->token);
|
||||
|
||||
|
||||
@@ -43,6 +43,12 @@ class AdminFeaturesValues extends AdminTab
|
||||
*/
|
||||
public function displayForm($isMainTab = true)
|
||||
{
|
||||
if (!Feature::isFeatureActive())
|
||||
{
|
||||
$this->displayWarning($this->l('This feature has been disabled, you can active this feature at this page:').' <a href="index.php?tab=AdminPerformance&token='.Tools::getAdminTokenLite('AdminPerformance').'#featuresDetachables">'.$this->l('Performances').'</a>');
|
||||
return;
|
||||
}
|
||||
|
||||
parent::displayForm();
|
||||
|
||||
if (!($obj = $this->loadObject(true)))
|
||||
|
||||
@@ -391,7 +391,7 @@ class AdminOrders extends AdminTab
|
||||
<tr>
|
||||
<td colspan="2">';
|
||||
foreach ($customization['datas'] AS $type => $datas)
|
||||
if ($type == _CUSTOMIZE_FILE_)
|
||||
if ($type == Product::CUSTOMIZE_FILE)
|
||||
{
|
||||
$i = 0;
|
||||
echo '<ul style="margin: 4px 0px 4px 0px; padding: 0px; list-style-type: none;">';
|
||||
@@ -401,7 +401,7 @@ class AdminOrders extends AdminTab
|
||||
</li>';
|
||||
echo '</ul>';
|
||||
}
|
||||
elseif ($type == _CUSTOMIZE_TEXTFIELD_)
|
||||
elseif ($type == Product::CUSTOMIZE_TEXTFIELD)
|
||||
{
|
||||
$i = 0;
|
||||
echo '<ul style="margin: 0px 0px 4px 0px; padding: 0px 0px 0px 6px; list-style-type: none;">';
|
||||
@@ -472,7 +472,8 @@ class AdminOrders extends AdminTab
|
||||
$history = $order->getHistory($this->context->language->id);
|
||||
$products = $order->getProducts();
|
||||
$customizedDatas = Product::getAllCustomizedDatas((int)($order->id_cart));
|
||||
Product::addCustomizationPrice($products, $customizedDatas);
|
||||
if ($customizedDatas)
|
||||
Product::addCustomizationPrice($products, $customizedDatas);
|
||||
$discounts = $order->getDiscounts();
|
||||
$messages = Message::getMessagesByOrderId($order->id, true);
|
||||
$states = OrderState::getOrderStates($this->context->language->id);
|
||||
@@ -770,7 +771,9 @@ class AdminOrders extends AdminTab
|
||||
}
|
||||
// Customization display
|
||||
$this->displayCustomizedDatas($customizedDatas, $product, $currency, $image, $tokenCatalog, $k);
|
||||
|
||||
|
||||
if (!isset($product['customizationQuantityTotal']))
|
||||
$product['customizationQuantityTotal'] = 0;
|
||||
// Normal display
|
||||
if ($product['product_quantity'] > $product['customizationQuantityTotal'])
|
||||
{
|
||||
@@ -787,7 +790,7 @@ class AdminOrders extends AdminTab
|
||||
.($product['product_supplier_reference'] ? $this->l('Ref Supplier:').' '.$product['product_supplier_reference'] : '')
|
||||
.'</a></td>
|
||||
<td align="center">'.Tools::displayPrice($product_price, $currency, false).'</td>
|
||||
<td align="center" class="productQuantity" '.($quantity > 1 ? 'style="font-weight:700;font-size:1.1em;color:red"' : '').'>'.(int)$quantity.'</td>
|
||||
<td align="center" class="productQuantity" '.($product['product_quantity'] > 1 ? 'style="font-weight:700;font-size:1.1em;color:red"' : '').'>'.(int)$product['product_quantity'].'</td>
|
||||
'.($order->hasBeenPaid() ? '<td align="center" class="productQuantity">'.(int)($product['product_quantity_refunded']).'</td>' : '').'
|
||||
'.($order->hasBeenDelivered() ? '<td align="center" class="productQuantity">'.(int)($product['product_quantity_return']).'</td>' : '').'
|
||||
<td align="center" class="productQuantity">'.$productObj->getStock($product['product_attribute_id']).'</td>
|
||||
|
||||
@@ -200,6 +200,18 @@ class AdminPerformance extends AdminTab
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
|
||||
}
|
||||
if (Tools::isSubmit('submitFeaturesDetachables'))
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
if (!Combination::isActuallyUsed())
|
||||
Configuration::updateValue('PS_COMBINATION_FEATURE_ACTIVE', Tools::getValue('combination'));
|
||||
Configuration::updateValue('PS_FEATURE_FEATURE_ACTIVE', Tools::getValue('feature'));
|
||||
Tools::redirectAdmin(self::$currentIndex.'&token='.Tools::getValue('token').'&conf=4');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('You do not have permission to edit here.');
|
||||
}
|
||||
return parent::postProcess();
|
||||
}
|
||||
|
||||
@@ -268,6 +280,51 @@ class AdminPerformance extends AdminTab
|
||||
</fieldset>
|
||||
</form>';
|
||||
|
||||
echo '
|
||||
<form action="'.self::$currentIndex.'&token='.Tools::getValue('token').'" method="post" style="margin-top:10px;" id="featuresDetachables">
|
||||
<fieldset>
|
||||
<legend><img src="../img/admin/tab-plugins.gif" /> '.$this->l('Features detachables').'</legend>
|
||||
|
||||
<p>'.$this->l('Some features can be disabled in order to improve performance.').'</p>
|
||||
|
||||
<label>'.$this->l('Combination:').'</label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="combination" id="combination_1" value="1" '.(Combination::isFeatureActive() ? 'checked="checked"' : '').' '.(Combination::isActuallyUsed() ? 'disabled="disabled"' : '').' /> <label class="t"><img src="../img/admin/enabled.gif" alt="" /> '.$this->l('Yes').'</label>
|
||||
<input type="radio" name="combination" id="combination_0" value="0" '.(!Combination::isFeatureActive() ? 'checked="checked"' : '').' '.(Combination::isActuallyUsed() ? 'disabled="disabled"' : '').' /> <label class="t"><img src="../img/admin/disabled.gif" alt="" /> '.$this->l('No').'</label>
|
||||
';
|
||||
if (Combination::isActuallyUsed())
|
||||
$this->displayWarning($this->l('This feature can\'t be disabled beacause this is currently in use.'));
|
||||
echo '
|
||||
<p>
|
||||
'.$this->l('These features are going to be disabled:').'
|
||||
<ul>
|
||||
<li>'.$this->l('Combinations tab on product page').'</li>
|
||||
<li>'.$this->l('Attribute').'</li>
|
||||
<li>'.$this->l('Group of attribute').'</li>
|
||||
</ul>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<label>'.$this->l('Feature:').'</label>
|
||||
<div class="margin-form">
|
||||
<input type="radio" name="feature" id="feature_1" value="1" '.(Feature::isFeatureActive() ? 'checked="checked"' : '').' /> <label class="t"><img src="../img/admin/enabled.gif" alt="" /> '.$this->l('Yes').'</label>
|
||||
<input type="radio" name="feature" id="feature_0" value="0" '.(!Feature::isFeatureActive() ? 'checked="checked"' : '').' /> <label class="t"><img src="../img/admin/disabled.gif" alt="" /> '.$this->l('No').'</label>
|
||||
<p>
|
||||
'.$this->l('These features are going to be disabled:').'
|
||||
<ul>
|
||||
<li>'.$this->l('Features tab on product page').'</li>
|
||||
<li>'.$this->l('Feature').'</li>
|
||||
<li>'.$this->l('Feature value').'</li>
|
||||
</ul>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="margin-form">
|
||||
<input type="submit" value="'.$this->l(' Save ').'" name="submitFeaturesDetachables" class="button" />
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>';
|
||||
|
||||
echo '
|
||||
<form action="'.self::$currentIndex.'&token='.Tools::getValue('token').'" method="post" style="margin-top:10px;">
|
||||
<fieldset>
|
||||
|
||||
@@ -191,7 +191,6 @@ class AdminProducts extends AdminTab
|
||||
{
|
||||
if ($this->tabAccess['add'] === '1')
|
||||
{
|
||||
|
||||
$languages = Language::getLanguages(false);
|
||||
$is_attachment_name_valid = false;
|
||||
foreach ($languages AS $language)
|
||||
@@ -268,7 +267,7 @@ class AdminProducts extends AdminTab
|
||||
{
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
if ($id = (int)(Tools::getValue($this->identifier)))
|
||||
if (Attachment::attachToProduct($id, $_POST['attachments']))
|
||||
if (Attachment::attachToProduct($id, Tools::getValue('attachments')))
|
||||
Tools::redirectAdmin(self::$currentIndex.'&id_product='.(int)$id.(isset($_POST['id_category']) ? '&id_category='.(int)$_POST['id_category'] : '').'&conf=4&add'.$this->table.'&tabs=6&token='.($token ? $token : $this->token));
|
||||
}
|
||||
|
||||
@@ -481,6 +480,8 @@ class AdminProducts extends AdminTab
|
||||
/* Product attributes management */
|
||||
elseif (Tools::isSubmit('submitProductAttribute'))
|
||||
{
|
||||
if (!Combination::isFeatureActive())
|
||||
return;
|
||||
if (Validate::isLoadedObject($product = new Product((int)(Tools::getValue('id_product')))))
|
||||
{
|
||||
if (!isset($_POST['attribute_price']) OR $_POST['attribute_price'] == NULL)
|
||||
@@ -573,6 +574,8 @@ class AdminProducts extends AdminTab
|
||||
}
|
||||
elseif (Tools::isSubmit('deleteProductAttribute'))
|
||||
{
|
||||
if (!Combination::isFeatureActive())
|
||||
return;
|
||||
if ($this->tabAccess['delete'] === '1')
|
||||
{
|
||||
if (($id_product = (int)(Tools::getValue('id_product'))) AND Validate::isUnsignedId($id_product) AND Validate::isLoadedObject($product = new Product($id_product)))
|
||||
@@ -598,6 +601,8 @@ class AdminProducts extends AdminTab
|
||||
}
|
||||
elseif (Tools::isSubmit('deleteAllProductAttributes'))
|
||||
{
|
||||
if (!Combination::isFeatureActive())
|
||||
return;
|
||||
if ($this->tabAccess['delete'] === '1')
|
||||
{
|
||||
if (($id_product = (int)(Tools::getValue('id_product'))) AND Validate::isUnsignedId($id_product) AND Validate::isLoadedObject($product = new Product($id_product)))
|
||||
@@ -619,6 +624,8 @@ class AdminProducts extends AdminTab
|
||||
}
|
||||
elseif (Tools::isSubmit('defaultProductAttribute'))
|
||||
{
|
||||
if (!Combination::isFeatureActive())
|
||||
return;
|
||||
if (Validate::isLoadedObject($product = new Product((int)(Tools::getValue('id_product')))))
|
||||
{
|
||||
$product->deleteDefaultAttributes();
|
||||
@@ -632,6 +639,8 @@ class AdminProducts extends AdminTab
|
||||
/* Product features management */
|
||||
elseif (Tools::isSubmit('submitProductFeature'))
|
||||
{
|
||||
if (!Feature::isFeatureActive())
|
||||
return;
|
||||
if ($this->tabAccess['edit'] === '1')
|
||||
{
|
||||
if (Validate::isLoadedObject($product = new Product((int)(Tools::getValue('id_product')))))
|
||||
@@ -1561,12 +1570,13 @@ class AdminProducts extends AdminTab
|
||||
/* Tabs */
|
||||
$this->displayFormInformations($obj, $currency);
|
||||
$this->displayFormImages($obj, $this->token);
|
||||
$countAttributes = (int)Db::getInstance()->getValue('SELECT COUNT(*) FROM '._DB_PREFIX_.'product_attribute WHERE id_product = '.(int)$obj->id);
|
||||
if (Combination::isFeatureActive())
|
||||
$countAttributes = (int)Db::getInstance()->getValue('SELECT COUNT(*) FROM '._DB_PREFIX_.'product_attribute WHERE id_product = '.(int)$obj->id);
|
||||
$countAttachments = (int)Db::getInstance()->getValue('SELECT COUNT(*) FROM '._DB_PREFIX_.'product_attachment WHERE id_product = '.(int)$obj->id);
|
||||
if ($obj->id)
|
||||
echo '
|
||||
<div class="tab-page" id="step3"><h4 class="tab">3. '.$this->l('Prices').'</h4></div>
|
||||
<div class="tab-page" id="step4"><h4 class="tab">4. '.$this->l('Combinations').' ('.$countAttributes.')</h4></div>
|
||||
<div class="tab-page" id="step4"><h4 class="tab">4. '.$this->l('Combinations').(isset($countAttributes) ? ' ('.$countAttributes.')' : '').'</h4></div>
|
||||
<div class="tab-page" id="step5"><h4 class="tab">5. '.$this->l('Features').'</h4></div>
|
||||
<div class="tab-page" id="step6"><h4 class="tab">6. '.$this->l('Customization').'</h4></div>
|
||||
<div class="tab-page" id="step7"><h4 class="tab">7. '.$this->l('Attachments').' ('.$countAttachments.')</h4></div>';
|
||||
@@ -1898,18 +1908,18 @@ class AdminProducts extends AdminTab
|
||||
private function _getCustomizationFieldIds($labels, $alreadyGenerated, $obj)
|
||||
{
|
||||
$customizableFieldIds = array();
|
||||
if (isset($labels[_CUSTOMIZE_FILE_]))
|
||||
foreach ($labels[_CUSTOMIZE_FILE_] AS $id_customization_field => $label)
|
||||
$customizableFieldIds[] = 'label_'._CUSTOMIZE_FILE_.'_'.(int)($id_customization_field);
|
||||
if (isset($labels[_CUSTOMIZE_TEXTFIELD_]))
|
||||
foreach ($labels[_CUSTOMIZE_TEXTFIELD_] AS $id_customization_field => $label)
|
||||
$customizableFieldIds[] = 'label_'._CUSTOMIZE_TEXTFIELD_.'_'.(int)($id_customization_field);
|
||||
if (isset($labels[Product::CUSTOMIZE_FILE]))
|
||||
foreach ($labels[Product::CUSTOMIZE_FILE] AS $id_customization_field => $label)
|
||||
$customizableFieldIds[] = 'label_'.Product::CUSTOMIZE_FILE.'_'.(int)($id_customization_field);
|
||||
if (isset($labels[Product::CUSTOMIZE_TEXTFIELD]))
|
||||
foreach ($labels[Product::CUSTOMIZE_TEXTFIELD] AS $id_customization_field => $label)
|
||||
$customizableFieldIds[] = 'label_'.Product::CUSTOMIZE_TEXTFIELD.'_'.(int)($id_customization_field);
|
||||
$j = 0;
|
||||
for ($i = $alreadyGenerated[_CUSTOMIZE_FILE_]; $i < (int)($this->getFieldValue($obj, 'uploadable_files')); $i++)
|
||||
$customizableFieldIds[] = 'newLabel_'._CUSTOMIZE_FILE_.'_'.$j++;
|
||||
for ($i = $alreadyGenerated[Product::CUSTOMIZE_FILE]; $i < (int)($this->getFieldValue($obj, 'uploadable_files')); $i++)
|
||||
$customizableFieldIds[] = 'newLabel_'.Product::CUSTOMIZE_FILE.'_'.$j++;
|
||||
$j = 0;
|
||||
for ($i = $alreadyGenerated[_CUSTOMIZE_TEXTFIELD_]; $i < (int)($this->getFieldValue($obj, 'text_fields')); $i++)
|
||||
$customizableFieldIds[] = 'newLabel_'._CUSTOMIZE_TEXTFIELD_.'_'.$j++;
|
||||
for ($i = $alreadyGenerated[Product::CUSTOMIZE_TEXTFIELD]; $i < (int)($this->getFieldValue($obj, 'text_fields')); $i++)
|
||||
$customizableFieldIds[] = 'newLabel_'.Product::CUSTOMIZE_TEXTFIELD.'_'.$j++;
|
||||
return implode('¤', $customizableFieldIds);
|
||||
}
|
||||
|
||||
@@ -1937,7 +1947,7 @@ class AdminProducts extends AdminTab
|
||||
private function _displayLabelFields(&$obj, &$labels, $languages, $defaultLanguage, $type)
|
||||
{
|
||||
$type = (int)($type);
|
||||
$labelGenerated = array(_CUSTOMIZE_FILE_ => (isset($labels[_CUSTOMIZE_FILE_]) ? count($labels[_CUSTOMIZE_FILE_]) : 0), _CUSTOMIZE_TEXTFIELD_ => (isset($labels[_CUSTOMIZE_TEXTFIELD_]) ? count($labels[_CUSTOMIZE_TEXTFIELD_]) : 0));
|
||||
$labelGenerated = array(Product::CUSTOMIZE_FILE => (isset($labels[Product::CUSTOMIZE_FILE]) ? count($labels[Product::CUSTOMIZE_FILE]) : 0), Product::CUSTOMIZE_TEXTFIELD => (isset($labels[Product::CUSTOMIZE_TEXTFIELD]) ? count($labels[Product::CUSTOMIZE_TEXTFIELD]) : 0));
|
||||
|
||||
$fieldIds = $this->_getCustomizationFieldIds($labels, $labelGenerated, $obj);
|
||||
if (isset($labels[$type]))
|
||||
@@ -1989,7 +1999,7 @@ class AdminProducts extends AdminTab
|
||||
<tr>
|
||||
<td style="width:150px" valign="top">'.$this->l('Files fields:').'</td>
|
||||
<td>';
|
||||
$this->_displayLabelFields($obj, $labels, $languages, $defaultLanguage, _CUSTOMIZE_FILE_);
|
||||
$this->_displayLabelFields($obj, $labels, $languages, $defaultLanguage, Product::CUSTOMIZE_FILE);
|
||||
echo '
|
||||
</td>
|
||||
</tr>';
|
||||
@@ -2002,7 +2012,7 @@ class AdminProducts extends AdminTab
|
||||
<tr>
|
||||
<td style="width:150px" valign="top">'.$this->l('Text fields:').'</td>
|
||||
<td>';
|
||||
$this->_displayLabelFields($obj, $labels, $languages, $defaultLanguage, _CUSTOMIZE_TEXTFIELD_);
|
||||
$this->_displayLabelFields($obj, $labels, $languages, $defaultLanguage, Product::CUSTOMIZE_TEXTFIELD);
|
||||
echo '
|
||||
</td>
|
||||
</tr>';
|
||||
@@ -3170,9 +3180,14 @@ class AdminProducts extends AdminTab
|
||||
return $content;
|
||||
}
|
||||
|
||||
function displayFormAttributes($obj, $languages, $defaultLanguage)
|
||||
public function displayFormAttributes($obj, $languages, $defaultLanguage)
|
||||
{
|
||||
|
||||
if (!Combination::isFeatureActive())
|
||||
{
|
||||
$this->displayWarning($this->l('This feature has been disabled, you can active this feature at this page:').' <a href="index.php?tab=AdminPerformance&token='.Tools::getAdminTokenLite('AdminPerformance').'#featuresDetachables">'.$this->l('Performances').'</a>');
|
||||
return;
|
||||
}
|
||||
|
||||
$attributeJs = array();
|
||||
$attributes = Attribute::getAttributes($this->context->language->id, true);
|
||||
foreach ($attributes AS $k => $attribute)
|
||||
@@ -3181,11 +3196,10 @@ class AdminProducts extends AdminTab
|
||||
$attributes_groups = AttributeGroup::getAttributesGroups($this->context->language->id);
|
||||
$default_country = new Country((int)Configuration::get('PS_COUNTRY_DEFAULT'));
|
||||
|
||||
|
||||
$images = Image::getImages($this->context->language->id, $obj->id);
|
||||
if ($obj->id)
|
||||
{
|
||||
echo '
|
||||
{
|
||||
echo '
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
$(\'#id_mvt_reason\').change(function(){
|
||||
@@ -3500,8 +3514,14 @@ class AdminProducts extends AdminTab
|
||||
echo '<b>'.$this->l('You must save this product before adding combinations').'.</b>';
|
||||
}
|
||||
|
||||
function displayFormFeatures($obj)
|
||||
public function displayFormFeatures($obj)
|
||||
{
|
||||
if (!Feature::isFeatureActive())
|
||||
{
|
||||
$this->displayWarning($this->l('This feature has been disabled, you can active this feature at this page:').' <a href="index.php?tab=AdminPerformance&token='.Tools::getAdminTokenLite('AdminPerformance').'#featuresDetachables">'.$this->l('Performances').'</a>');
|
||||
return;
|
||||
}
|
||||
|
||||
parent::displayForm();
|
||||
|
||||
if ($obj->id)
|
||||
|
||||
@@ -235,7 +235,7 @@ class AdminReturn extends AdminTab
|
||||
{
|
||||
echo '<tr>
|
||||
<td colspan="4">';
|
||||
if ($type == _CUSTOMIZE_FILE_)
|
||||
if ($type == Product::CUSTOMIZE_FILE)
|
||||
{
|
||||
$i = 0;
|
||||
echo '<ul style="margin: 4px 0px 4px 0px; padding: 0px; list-style-type: none;">';
|
||||
@@ -245,7 +245,7 @@ class AdminReturn extends AdminTab
|
||||
</li>';
|
||||
echo '</ul>';
|
||||
}
|
||||
elseif ($type == _CUSTOMIZE_TEXTFIELD_)
|
||||
elseif ($type == Product::CUSTOMIZE_TEXTFIELD)
|
||||
{
|
||||
$i = 0;
|
||||
echo '<ul style="margin: 0px 0px 4px 0px; padding: 0px 0px 0px 6px; list-style-type: none;">';
|
||||
|
||||
Reference in New Issue
Block a user