function displayFormAttributes($obj, $languages, $defaultLanguage) { global $currentIndex, $cookie; $attributeJs = array(); $attributes = Attribute::getAttributes(intval($cookie->id_lang), true); foreach ($attributes as $k => $attribute) { $attributeJs[$attribute['id_attribute_group']][$attribute['id_attribute']] = $attribute['name']; } $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT')); $attributes_groups = AttributeGroup::getAttributesGroups(intval($cookie->id_lang)); $images = Image::getImages(intval($cookie->id_lang), $obj->id); if ($obj->id) { echo ' <table cellpadding="5"> <tr> <td colspan="2"><b>' . $this->l('Add or modify combinations for this product') . '</b> - <a href="index.php?tab=AdminCatalog&id_product=' . $obj->id . '&id_category=' . intval(Tools::getValue('id_category')) . '&attributegenerator&token=' . Tools::getAdminToken('AdminCatalog' . intval(Tab::getIdFromClassName('AdminCatalog')) . intval($cookie->id_employee)) . '" onclick="return confirm(\'' . $this->l('Are you sure you want to delete entered product information?', __CLASS__, true, false) . '\');"><img src="../img/admin/appearance.gif" alt="combinations_generator" class="middle" title="' . $this->l('Product combinations generator') . '" /> ' . $this->l('Product combinations generator') . '</a> </td> </tr> </table> <hr style="width:730px;"><br /> <table cellpadding="5" style="width:100%"> <tr> <td style="width:150px" valign="top">' . $this->l('Group:') . '</td> <td style="padding-bottom:5px;"><select name="attribute_group" id="attribute_group" style="width: 200px;" onchange="populate_attrs();">'; if (isset($attributes_groups)) { foreach ($attributes_groups as $k => $attribute_group) { if (isset($attributeJs[$attribute_group['id_attribute_group']])) { echo ' <option value="' . $attribute_group['id_attribute_group'] . '"> ' . htmlentities(stripslashes($attribute_group['name']), ENT_COMPAT, 'UTF-8') . ' </option>'; } } } echo ' </select></td> </tr> <tr> <td style="width:150px" valign="top">' . $this->l('Attribute:') . '</td> <td style="padding-bottom:5px;"><select name="attribute" id="attribute" style="width: 200px;"> <option value="0">---</option> </select> <script type="text/javascript" language="javascript">populate_attrs();</script> </td> </tr> <tr> <td style="width:150px" valign="top"> <input style="width: 140px; margin-bottom: 10px;" type="button" value="' . $this->l('Add') . '" class="button" onclick="add_attr();"/><br /> <input style="width: 140px;" type="button" value="' . $this->l('Delete') . '" class="button" onclick="del_attr()"/></td> <td align="left"> <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:730px;"></td></tr> <tr> <td style="width:150px">' . $this->l('Reference:') . '</td> <td style="padding-bottom:5px;"> <input size="55" type="text" id="attribute_reference" name="attribute_reference" value="" style="width: 130px; margin-right: 44px;" /> ' . $this->l('EAN13:') . '<input size="55" maxlength="13" type="text" id="attribute_ean13" name="attribute_ean13" value="" style="width: 110px; margin-left: 10px;" /> <span class="hint" name="help_box">' . $this->l('Special characters allowed:') . ' .-_#<span class="hint-pointer"> </span></span> </td> </tr> <tr> <td style="width:150px">' . $this->l('Supplier Reference:') . '</td> <td style="padding-bottom:5px;"> <input size="55" type="text" id="attribute_supplier_reference" name="attribute_supplier_reference" value="" style="width: 130px; margin-right: 44px;" /> ' . $this->l('Location:') . '<input size="55" type="text" id="attribute_location" name="attribute_location" value="" style="width: 101px; margin-left: 10px;" /> <span class="hint" name="help_box">' . $this->l('Special characters allowed:') . ' .-_#<span class="hint-pointer"> </span></span> </td> </tr> <tr><td colspan="2"><hr style="width:730px;"></td></tr> <tr> <td style="width:150px">' . $this->l('Wholesale price:') . '</td> <td style="padding-bottom:5px;">' . ($currency->format == 1 ? $currency->sign . ' ' : '') . '<input type="text" size="6" name="attribute_wholesale_price" id="attribute_wholesale_price" value="0.00" onKeyUp="javascript:this.value = this.value.replace(/,/g, \'.\');" />' . ($currency->format == 2 ? ' ' . $currency->sign : '') . ' (' . $this->l('overrides Wholesale price on Information tab') . ')</td> </tr> <tr> <td style="width:150px">' . $this->l('Impact on price:') . '</td> <td colspan="2" style="padding-bottom:5px;"> <select name="attribute_price_impact" id="attribute_price_impact" style="width: 140px;" onchange="check_impact();"> <option value="0">' . $this->l('None') . '</option> <option value="1">' . $this->l('Increase') . '</option> <option value="-1">' . $this->l('Reduction') . '</option> </select> <sup>*</sup> <span id="span_impact"> ' . $this->l('of') . ' ' . ($currency->format == 1 ? $currency->sign . ' ' : '') . ' <input type="text" size="6" name="attribute_price" id="attribute_price" value="0.00" onKeyUp="javascript:this.value = this.value.replace(/,/g, \'.\');"/>' . ($currency->format == 2 ? ' ' . $currency->sign : '') . ' </span> </td> </tr> <tr> <td style="width:150px">' . $this->l('Impact on weight:') . '</td> <td colspan="2" style="padding-bottom:5px;"><select name="attribute_weight_impact" id="attribute_weight_impact" style="width: 140px;" onchange="check_weight_impact();"> <option value="0">' . $this->l('None') . '</option> <option value="1">' . $this->l('Increase') . '</option> <option value="-1">' . $this->l('Reduction') . '</option> </select> <span id="span_weight_impact"> ' . $this->l('of') . ' <input type="text" size="6" name="attribute_weight" id="attribute_weight" value="0.00" onKeyUp="javascript:this.value = this.value.replace(/,/g, \'.\');" /> ' . Configuration::get('PS_WEIGHT_UNIT') . '</span></td> </tr> <tr> <td style="width:150px">' . $this->l('Eco-tax:') . '</td> <td style="padding-bottom:5px;">' . ($currency->format == 1 ? $currency->sign . ' ' : '') . '<input type="text" size="3" name="attribute_ecotax" id="attribute_ecotax" value="0.00" onKeyUp="javascript:this.value = this.value.replace(/,/g, \'.\');" />' . ($currency->format == 2 ? ' ' . $currency->sign : '') . ' (' . $this->l('overrides Eco-tax on Information tab') . ')</td> </tr> <tr> <td style="width:150px">' . $this->l('Quantity:') . '</td> <td style="padding-bottom:5px;"><input type="text" size="3" name="attribute_quantity" id="attribute_quantity" value="1" /> (' . $this->l('overrides Quantity on Information tab') . ')</td> </tr> <tr> <td colspan="2"><sup>*</sup> ' . $this->l('included tax') . '</td> </tr> <tr><td colspan="2"><hr style="width:730px;"></td></tr> <tr> <td style="width:150px">' . $this->l('Image:') . '</td> <td style="padding-bottom:5px;"> <ul id="id_image_attr">'; $i = 0; $imageType = ImageType::getByNameNType('small', 'products'); $imageWidth = (isset($imageType['width']) ? intval($imageType['width']) : 64) + 25; foreach ($images as $image) { echo '<li style="float: left; width: ' . $imageWidth . 'px;"><input type="checkbox" name="id_image_attr[]" value="' . intval($image['id_image']) . '" id="id_image_attr_' . intval($image['id_image']) . '" /> <label for="id_image_attr_' . intval($image['id_image']) . '" style="float: none;"><img src="../img/p/' . $obj->id . '-' . $image['id_image'] . '-small.jpg" alt="' . htmlentities(stripslashes($image['legend']), ENT_COMPAT, 'UTF-8') . '" title="' . htmlentities(stripslashes($image['legend']), ENT_COMPAT, 'UTF-8') . '" /></label></li>'; ++$i; } echo '</ul> <img id="pic" alt="" title="" style="display: none; width: 100px; height: 100px; float: left; border: 1px dashed #BBB; margin-left: 20px;" /> </td> </tr> <tr> <td style="width:150px">' . $this->l('Default:') . '<br /><br /></td> <td style="padding-bottom:5px;"> <input type="checkbox" name="attribute_default" id="attribute_default" value="1" /> ' . $this->l('Make the default combination for this product') . '<br /><br /> </td> </tr> <tr> <td style="width:150px"> </td> <td style="padding-bottom:5px;"> <span style="float: left;"><input type="submit" name="submitProductAttribute" id="submitProductAttribute" value="' . $this->l('Add this combination') . '" class="button" onclick="attr_selectall();" /> </span> <span id="ResetSpan" style="float: left; margin-left: 8px; display: none;"> <input type="reset" name="ResetBtn" id="ResetBtn" onclick="if (!confirm(\'' . $this->l('Are you sure you want to cancel?', __CLASS__, true, false) . '\')) return; init_elems(); getE(\'submitProductAttribute\').value = \'' . $this->l('Add this attributes group', __CLASS__, true) . '\'; getE(\'id_product_attribute\').value = -1; openCloseLayer(\'ResetSpan\');" class="button" value="' . $this->l('Cancel modification') . '" /></span><span style="clear: both;"></span> </td> </tr> <tr><td colspan="2"><hr style="width:730px;"></td></tr> <tr> <td colspan="2"> <br /> <table border="0" cellpadding="0" cellspacing="0" class="table" style="width: 600px;"> <tr> <th>' . $this->l('Attributes') . '</th> <th>' . $this->l('Price') . '</th> <th>' . $this->l('Weight') . '</th> <th>' . $this->l('Reference') . '</th> <th>' . $this->l('EAN13') . '</th> <th class="center">' . $this->l('Quantity') . '</th> <th class="center">' . $this->l('Actions') . '</th> </tr>'; if ($obj->id) { /* Build attributes combinaisons */ $combinaisons = $obj->getAttributeCombinaisons(intval($cookie->id_lang)); $groups = array(); if (is_array($combinaisons)) { $combinationImages = $obj->getCombinationImages(intval($cookie->id_lang)); foreach ($combinaisons as $k => $combinaison) { $combArray[$combinaison['id_product_attribute']]['wholesale_price'] = $combinaison['wholesale_price']; $combArray[$combinaison['id_product_attribute']]['price'] = $combinaison['price']; $combArray[$combinaison['id_product_attribute']]['weight'] = $combinaison['weight']; $combArray[$combinaison['id_product_attribute']]['reference'] = $combinaison['reference']; $combArray[$combinaison['id_product_attribute']]['supplier_reference'] = $combinaison['supplier_reference']; $combArray[$combinaison['id_product_attribute']]['ean13'] = $combinaison['ean13']; $combArray[$combinaison['id_product_attribute']]['location'] = $combinaison['location']; $combArray[$combinaison['id_product_attribute']]['quantity'] = $combinaison['quantity']; $combArray[$combinaison['id_product_attribute']]['id_image'] = isset($combinationImages[$combinaison['id_product_attribute']][0]['id_image']) ? $combinationImages[$combinaison['id_product_attribute']][0]['id_image'] : 0; $combArray[$combinaison['id_product_attribute']]['default_on'] = $combinaison['default_on']; $combArray[$combinaison['id_product_attribute']]['ecotax'] = $combinaison['ecotax']; $combArray[$combinaison['id_product_attribute']]['attributes'][] = array($combinaison['group_name'], $combinaison['attribute_name'], $combinaison['id_attribute']); if ($combinaison['is_color_group']) { $groups[$combinaison['id_attribute_group']] = $combinaison['group_name']; } } } $irow = 0; if (isset($combArray)) { foreach ($combArray as $id_product_attribute => $product_attribute) { $list = ''; $jsList = ''; foreach ($product_attribute['attributes'] as $attribute) { $list .= addslashes(htmlspecialchars($attribute[0])) . ' - ' . addslashes(htmlspecialchars($attribute[1])) . ', '; $jsList .= '\'' . addslashes(htmlspecialchars($attribute[0])) . ' : ' . addslashes(htmlspecialchars($attribute[1])) . '\', \'' . $attribute[2] . '\', '; } $list = rtrim($list, ', '); $jsList = rtrim($jsList, ', '); $attrImage = $product_attribute['id_image'] ? new Image($product_attribute['id_image']) : false; echo ' <tr' . ($irow++ % 2 ? ' class="alt_row"' : '') . ($product_attribute['default_on'] ? ' style="background-color:#D1EAEF"' : '') . '> <td>' . stripslashes($list) . '</td> <td class="right">' . ($currency->format == 1 ? $currency->sign . ' ' : '') . $product_attribute['price'] . ($currency->format == 2 ? ' ' . $currency->sign : '') . '</td> <td class="right">' . $product_attribute['weight'] . Configuration::get('PS_WEIGHT_UNIT') . '</td> <td class="right">' . $product_attribute['reference'] . '</td> <td class="right">' . $product_attribute['ean13'] . '</td> <td class="center">' . $product_attribute['quantity'] . '</td> <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['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'] . '\');" /></a> <a href="' . $currentIndex . '&deleteProductAttribute&id_product_attribute=' . $id_product_attribute . '&id_product=' . $obj->id . '&token=' . Tools::getAdminToken('AdminCatalog' . intval(Tab::getIdFromClassName('AdminCatalog')) . intval($cookie->id_employee)) . '" onclick="return confirm(\'' . $this->l('Are you sure?', __CLASS__, true, false) . '\');"> <img src="../img/admin/delete.gif" alt="' . $this->l('Delete this combination') . '" /></a></td> </tr>'; } } else { echo '<tr><td colspan="7" align="center"><i>' . $this->l('No combination yet') . '.</i></td></tr>'; } } echo ' </table> <br />' . $this->l('The row in blue is the default combination.') . ' <br /> ' . $this->l('A default combination must be designated for each product.') . ' </td> </tr> </table> <script type="text/javascript"> var impact = getE(\'attribute_price_impact\'); var impact2 = getE(\'attribute_weight_impact\'); var s_attr_group = document.getElementById(\'span_new_group\'); var s_attr_name = document.getElementById(\'span_new_attr\'); var s_impact = document.getElementById(\'span_impact\'); var s_impact2 = document.getElementById(\'span_weight_impact\'); init_elems(); </script> <hr style="width:730px;"> <table cellpadding="5"> <tr> <td class="col-left"><b>' . $this->l('Color picker:') . '</b></td> <td style="padding-bottom:5px;"> <select name="id_color_default"> <option value="0">' . $this->l('Do not display') . '</option>'; foreach ($attributes_groups as $k => $attribute_group) { if (isset($groups[$attribute_group['id_attribute_group']])) { echo '<option value="' . intval($attribute_group['id_attribute_group']) . '" ' . (intval($attribute_group['id_attribute_group']) == intval($obj->id_color_default) ? 'selected="selected"' : '') . '>' . htmlentities(stripslashes($attribute_group['name']), ENT_COMPAT, 'UTF-8') . '</option>'; } } echo ' </select> <input type="submit" value="' . $this->l('OK') . '" name="submitAdd' . $this->table . '" class="button" /> <a href="index.php?tab=AdminAttributesGroups&token=' . Tools::getAdminToken('AdminAttributesGroups' . intval(Tab::getIdFromClassName('AdminAttributesGroups')) . intval($cookie->id_employee)) . '" onclick="return confirm(\'' . $this->l('Are you sure you want to delete entered product information?', __CLASS__, true, false) . '\');"><img src="../img/admin/asterisk.gif" alt="" /> ' . $this->l('Color attribute management') . '</a> <p >' . $this->l('Active the color choice by selecting a color attribute group.') . '</p> </td> </tr> </table>'; } else { echo '<b>' . $this->l('You must save this product before adding combinations') . '.</b>'; } }
public function setPicturesSettings() { // Default if ($medium = ImageType::getByNameNType('thickbox', 'products')) { $sizeMedium = (int) $medium['id_image_type']; } elseif ($medium = ImageType::getByNameNType('thickbox_default', 'products')) { $sizeMedium = (int) $medium['id_image_type']; } else { $sizeMedium = 0; } // Small if ($small = ImageType::getByNameNType('small', 'products')) { $sizeSmall = (int) $small['id_image_type']; } elseif ($small = ImageType::getByNameNType('small_default', 'products')) { $sizeSmall = (int) $small['id_image_type']; } else { $sizeSmall = 0; } // Large if ($large = ImageType::getByNameNType('large', 'products')) { $sizeBig = (int) $large['id_image_type']; } elseif ($large = ImageType::getByNameNType('large_default', 'products')) { $sizeBig = (int) $large['id_image_type']; } else { $sizeBig = 0; } $this->setConfiguration('EBAY_PICTURE_SIZE_DEFAULT', $sizeMedium); $this->setConfiguration('EBAY_PICTURE_SIZE_SMALL', $sizeSmall); $this->setConfiguration('EBAY_PICTURE_SIZE_BIG', $sizeBig); $this->setConfiguration('EBAY_PICTURE_PER_LISTING', 0); }
function displayFormAttributes($obj, $languages, $defaultLanguage) { global $currentIndex, $cookie; $attributeJs = array(); $attributes = Attribute::getAttributes((int) $cookie->id_lang, true); foreach ($attributes as $k => $attribute) { $attributeJs[$attribute['id_attribute_group']][$attribute['id_attribute']] = $attribute['name']; } $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT')); $attributes_groups = AttributeGroup::getAttributesGroups((int) $cookie->id_lang); $default_country = new Country((int) Configuration::get('PS_COUNTRY_DEFAULT')); $images = Image::getImages((int) $cookie->id_lang, $obj->id); if ($obj->id) { echo ' <script type="text/javascript"> $(document).ready(function(){ $(\'#id_mvt_reason\').change(function(){ updateMvtStatus($(this).val()); }); updateMvtStatus($(this).val()); }); </script> <table cellpadding="5"> <tr> <td colspan="2"><b>' . $this->l('Add or modify combinations for this product') . '</b> - <a href="index.php?tab=AdminCatalog&id_product=' . $obj->id . '&id_category=' . (int) Tools::getValue('id_category') . '&attributegenerator&token=' . Tools::getAdminToken('AdminCatalog' . (int) Tab::getIdFromClassName('AdminCatalog') . (int) $cookie->id_employee) . '" onclick="return confirm(\'' . $this->l('Are you sure you want to delete entered product information?', __CLASS__, true, false) . '\');"><img src="../img/admin/appearance.gif" alt="combinations_generator" class="middle" title="' . $this->l('Product combinations generator') . '" /> ' . $this->l('Product combinations generator') . '</a> </td> </tr> </table> <hr style="width:100%;" /><br /> <table cellpadding="5" style="width:100%"> <tr> <td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;" valign="top">' . $this->l('Group:') . '</td> <td style="padding-bottom:5px;"><select name="attribute_group" id="attribute_group" style="width: 200px;" onchange="populate_attrs();">'; if (isset($attributes_groups)) { foreach ($attributes_groups as $k => $attribute_group) { if (isset($attributeJs[$attribute_group['id_attribute_group']])) { echo ' <option value="' . $attribute_group['id_attribute_group'] . '"> ' . htmlentities(stripslashes($attribute_group['name']), ENT_COMPAT, 'UTF-8') . ' </option>'; } } } echo ' </select></td> </tr> <tr> <td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;" valign="top">' . $this->l('Attribute:') . '</td> <td style="padding-bottom:5px;"><select name="attribute" id="attribute" style="width: 200px;"> <option value="0">---</option> </select> <script type="text/javascript" language="javascript">populate_attrs();</script> </td> </tr> <tr> <td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;" valign="top"> <input style="width: 140px; margin-bottom: 10px;" type="button" value="' . $this->l('Add') . '" class="button" onclick="add_attr();"/><br /> <input style="width: 140px;" type="button" value="' . $this->l('Delete') . '" class="button" onclick="del_attr()"/></td> <td align="left"> <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> <td style="padding-bottom:5px;"> <input size="55" type="text" id="attribute_reference" name="attribute_reference" value="" style="width: 130px; margin-right: 44px;" /> ' . $this->l('EAN13:') . '<input size="55" maxlength="13" type="text" id="attribute_ean13" name="attribute_ean13" value="" style="width: 110px; margin-left: 10px; margin-right: 44px;" /> ' . $this->l('UPC:') . '<input size="55" maxlength="12" type="text" id="attribute_upc" name="attribute_upc" value="" style="width: 110px; margin-left: 10px;" /> <span class="hint" name="help_box">' . $this->l('Special characters allowed:') . ' .-_#<span class="hint-pointer"> </span></span> </td> </tr> <tr> <td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">' . $this->l('Supplier Reference:') . '</td> <td style="padding-bottom:5px;"> <input size="55" type="text" id="attribute_supplier_reference" name="attribute_supplier_reference" value="" style="width: 130px; margin-right: 44px;" /> ' . $this->l('Location:') . '<input size="55" type="text" id="attribute_location" name="attribute_location" value="" style="width: 101px; margin-left: 10px;" /> <span class="hint" name="help_box">' . $this->l('Special characters allowed:') . ' .-_#<span class="hint-pointer"> </span></span> </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('Wholesale price:') . '</td> <td style="padding-bottom:5px;">' . ($currency->format % 2 != 0 ? $currency->sign . ' ' : '') . '<input type="text" size="6" name="attribute_wholesale_price" id="attribute_wholesale_price" value="0.00" onKeyUp="if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, \'.\');" />' . ($currency->format % 2 == 0 ? ' ' . $currency->sign : '') . ' (' . $this->l('overrides Wholesale price on Information tab') . ')</td> </tr> <tr> <td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">' . $this->l('Impact on price:') . '</td> <td colspan="2" style="padding-bottom:5px;"> <select name="attribute_price_impact" id="attribute_price_impact" style="width: 140px;" onchange="check_impact(); calcImpactPriceTI();"> <option value="0">' . $this->l('None') . '</option> <option value="1">' . $this->l('Increase') . '</option> <option value="-1">' . $this->l('Reduction') . '</option> </select> <span id="span_impact"> ' . $this->l('of') . ' ' . ($currency->format % 2 != 0 ? $currency->sign . ' ' : '') . ' <input type="text" size="6" name="attribute_price" id="attribute_price" value="0.00" onKeyUp="if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, \'.\'); calcImpactPriceTI();"/>' . ($currency->format % 2 == 0 ? ' ' . $currency->sign : ''); if ($default_country->display_tax_label) { echo ' ' . $this->l('(tax excl.)') . '<span ' . (Tax::excludeTaxeOption() ? 'style="display:none"' : '') . '> ' . $this->l('or') . ' ' . ($currency->format % 2 != 0 ? $currency->sign . ' ' : '') . ' <input type="text" size="6" name="attribute_priceTI" id="attribute_priceTI" value="0.00" onKeyUp="if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, \'.\'); calcImpactPriceTE();"/>' . ($currency->format % 2 == 0 ? ' ' . $currency->sign : '') . ' ' . $this->l('(tax incl.)') . '</span> ' . $this->l('final product price will be set to') . ' ' . ($currency->format % 2 != 0 ? $currency->sign . ' ' : '') . '<span id="attribute_new_total_price">0.00</span>' . ($currency->format % 2 == 0 ? $currency->sign . ' ' : ''); } echo ' </span> </td> </tr> <tr> <td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">' . $this->l('Impact on weight:') . '</td> <td colspan="2" style="padding-bottom:5px;"><select name="attribute_weight_impact" id="attribute_weight_impact" style="width: 140px;" onchange="check_weight_impact();"> <option value="0">' . $this->l('None') . '</option> <option value="1">' . $this->l('Increase') . '</option> <option value="-1">' . $this->l('Reduction') . '</option> </select> <span id="span_weight_impact"> ' . $this->l('of') . ' <input type="text" size="6" name="attribute_weight" id="attribute_weight" value="0.00" onKeyUp="if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, \'.\');" /> ' . Configuration::get('PS_WEIGHT_UNIT') . '</span></td> </tr> <tr id="tr_unit_impact"> <td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">' . $this->l('Impact on unit price :') . '</td> <td colspan="2" style="padding-bottom:5px;"><select name="attribute_unit_impact" id="attribute_unit_impact" style="width: 140px;" onchange="check_unit_impact();"> <option value="0">' . $this->l('None') . '</option> <option value="1">' . $this->l('Increase') . '</option> <option value="-1">' . $this->l('Reduction') . '</option> </select> <span id="span_unit_impact"> ' . $this->l('of') . ' ' . ($currency->format % 2 != 0 ? $currency->sign . ' ' : '') . ' <input type="text" size="6" name="attribute_unity" id="attribute_unity" value="0.00" onKeyUp="if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, \'.\');" />' . ($currency->format % 2 == 0 ? ' ' . $currency->sign : '') . ' / <span id="unity_third">' . $this->getFieldValue($obj, 'unity') . '</span> </span></td> </tr>'; if (Configuration::get('PS_USE_ECOTAX')) { echo ' <tr> <td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">' . $this->l('Eco-tax:') . '</td> <td style="padding-bottom:5px;">' . ($currency->format % 2 != 0 ? $currency->sign . ' ' : '') . '<input type="text" size="3" name="attribute_ecotax" id="attribute_ecotax" value="0.00" onKeyUp="if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, \'.\');" />' . ($currency->format % 2 == 0 ? ' ' . $currency->sign : '') . ' (' . $this->l('overrides Eco-tax on Information tab') . ')</td> </tr>'; } echo ' <tr id="initial_stock_attribute"> <td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;" class="col-left">' . $this->l('Initial stock:') . '</td> <td><input type="text" name="attribute_quantity" size="3" maxlength="10" value="0"/></td> </tr> </tr> <tr id="stock_mvt_attribute" style="display:none;"> <td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;" class="col-left">' . $this->l('Stock movement:') . '</td> <td style="padding-bottom:5px;"> <select id="id_mvt_reason" name="id_mvt_reason"> <option value="-1">--</option>'; $reasons = StockMvtReason::getStockMvtReasons((int) $cookie->id_lang); foreach ($reasons as $reason) { echo '<option rel="' . $reason['sign'] . '" value="' . $reason['id_stock_mvt_reason'] . '" ' . (Configuration::get('PS_STOCK_MVT_REASON_DEFAULT') == $reason['id_stock_mvt_reason'] ? 'selected="selected"' : '') . '>' . $reason['name'] . '</option>'; } echo '</select> <input type="text" name="attribute_mvt_quantity" size="3" maxlength="10" value="0"/> <span style="display:none;" id="mvt_sign"></span> <br /> <div class="hint clear" style="display: block;width: 70%;">' . $this->l('Choose the reason and enter the quantity that you want to increase or decrease in your stock') . '</div> </td> </tr> <tr> <td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;" class="col-left">' . $this->l('Minimum quantity:') . '</td> <td style="padding-bottom:5px;"> <input size="3" maxlength="10" name="attribute_minimal_quantity" id="attribute_minimal_quantity" type="text" value="' . ($this->getFieldValue($obj, 'attribute_minimal_quantity') ? $this->getFieldValue($obj, 'attribute_minimal_quantity') : 1) . '" /> <p>' . $this->l('The minimum quantity to buy this product (set to 1 to disable this feature)') . '</p> </td> </tr> <tr style="display:none;" id="attr_qty_stock"> <td style="width:150px">' . $this->l('Quantity in stock:') . '</td> <td style="padding-bottom:5px;"><b><span style="display:none;" id="attribute_quantity"></span></b></td> </tr> <tr><td colspan="2"><hr style="width:100%;" /></td></tr> <tr> <td style="width:150px">' . $this->l('Image:') . '</td> <td style="padding-bottom:5px;"> <ul id="id_image_attr">'; $i = 0; $imageType = ImageType::getByNameNType('small', 'products'); $imageWidth = (isset($imageType['width']) ? (int) $imageType['width'] : 64) + 25; foreach ($images as $image) { $imageObj = new Image($image['id_image']); echo '<li style="float: left; width: ' . $imageWidth . 'px;"><input type="checkbox" name="id_image_attr[]" value="' . (int) $image['id_image'] . '" id="id_image_attr_' . (int) $image['id_image'] . '" /> <label for="id_image_attr_' . (int) $image['id_image'] . '" style="float: none;"><img src="' . _THEME_PROD_DIR_ . $imageObj->getExistingImgPath() . '-small.jpg" alt="' . htmlentities(stripslashes($image['legend']), ENT_COMPAT, 'UTF-8') . '" title="' . htmlentities(stripslashes($image['legend']), ENT_COMPAT, 'UTF-8') . '" /></label></li>'; ++$i; } echo '</ul> <img id="pic" alt="" title="" style="display: none; width: 100px; height: 100px; float: left; border: 1px dashed #BBB; margin-left: 20px;" /> </td> </tr> <tr> <td style="width:150px">' . $this->l('Default:') . '<br /><br /></td> <td style="padding-bottom:5px;"> <input type="checkbox" name="attribute_default" id="attribute_default" value="1" /> ' . $this->l('Make this the default combination for this product') . '<br /><br /> </td> </tr> <tr> <td style="width:150px"> </td> <td style="padding-bottom:5px;"> <span style="float: left;"><input type="submit" name="submitProductAttribute" id="submitProductAttribute" value="' . $this->l('Add this combination') . '" class="button" onclick="attr_selectall(); this.form.action += \'&addproduct&tabs=3\';" /> </span> <span id="ResetSpan" style="float: left; margin-left: 8px; display: none;"> <input type="reset" name="ResetBtn" id="ResetBtn" onclick="init_elems(); getE(\'submitProductAttribute\').value = \'' . $this->l('Add this attributes group', __CLASS__, true) . '\'; getE(\'id_product_attribute\').value = 0; $(\'#ResetSpan\').slideToggle();" class="button" value="' . $this->l('Cancel modification') . '" /></span><span class="clear"></span> </td> </tr> <tr><td colspan="2"><hr style="width:100%;" /></td></tr> <tr> <td colspan="2"> <br /> <table border="0" cellpadding="0" cellspacing="0" class="table"> <tr> <th>' . $this->l('Attributes') . '</th> <th>' . $this->l('Impact') . '</th> <th>' . $this->l('Weight') . '</th> <th>' . $this->l('Reference') . '</th> <th>' . $this->l('EAN13') . '</th> <th>' . $this->l('UPC') . '</th> <th class="center">' . $this->l('Quantity') . '</th> <th class="center">' . $this->l('Actions') . '</th> </tr>'; if ($obj->id) { /* Build attributes combinaisons */ $combinaisons = $obj->getAttributeCombinaisons((int) $cookie->id_lang); $groups = array(); if (is_array($combinaisons)) { $combinationImages = $obj->getCombinationImages((int) $cookie->id_lang); foreach ($combinaisons as $k => $combinaison) { $combArray[$combinaison['id_product_attribute']]['wholesale_price'] = $combinaison['wholesale_price']; $combArray[$combinaison['id_product_attribute']]['price'] = $combinaison['price']; $combArray[$combinaison['id_product_attribute']]['weight'] = $combinaison['weight']; $combArray[$combinaison['id_product_attribute']]['unit_impact'] = $combinaison['unit_price_impact']; $combArray[$combinaison['id_product_attribute']]['reference'] = $combinaison['reference']; $combArray[$combinaison['id_product_attribute']]['supplier_reference'] = $combinaison['supplier_reference']; $combArray[$combinaison['id_product_attribute']]['ean13'] = $combinaison['ean13']; $combArray[$combinaison['id_product_attribute']]['upc'] = $combinaison['upc']; $combArray[$combinaison['id_product_attribute']]['attribute_minimal_quantity'] = $combinaison['minimal_quantity']; $combArray[$combinaison['id_product_attribute']]['location'] = $combinaison['location']; $combArray[$combinaison['id_product_attribute']]['quantity'] = $combinaison['quantity']; $combArray[$combinaison['id_product_attribute']]['id_image'] = isset($combinationImages[$combinaison['id_product_attribute']][0]['id_image']) ? $combinationImages[$combinaison['id_product_attribute']][0]['id_image'] : 0; $combArray[$combinaison['id_product_attribute']]['default_on'] = $combinaison['default_on']; $combArray[$combinaison['id_product_attribute']]['ecotax'] = $combinaison['ecotax']; $combArray[$combinaison['id_product_attribute']]['attributes'][] = array($combinaison['group_name'], $combinaison['attribute_name'], $combinaison['id_attribute']); if ($combinaison['is_color_group']) { $groups[$combinaison['id_attribute_group']] = $combinaison['group_name']; } } } $irow = 0; if (isset($combArray)) { foreach ($combArray as $id_product_attribute => $product_attribute) { $list = ''; $jsList = ''; /* In order to keep the same attributes order */ asort($product_attribute['attributes']); foreach ($product_attribute['attributes'] as $attribute) { $list .= addslashes(htmlspecialchars($attribute[0])) . ' - ' . addslashes(htmlspecialchars($attribute[1])) . ', '; $jsList .= '\'' . addslashes(htmlspecialchars($attribute[0])) . ' : ' . addslashes(htmlspecialchars($attribute[1])) . '\', \'' . $attribute[2] . '\', '; } $list = rtrim($list, ', '); $jsList = rtrim($jsList, ', '); $attrImage = $product_attribute['id_image'] ? new Image($product_attribute['id_image']) : false; echo ' <tr' . ($irow++ % 2 ? ' class="alt_row"' : '') . ($product_attribute['default_on'] ? ' style="background-color:#D1EAEF"' : '') . '> <td>' . stripslashes($list) . '</td> <td class="right">' . ($currency->format % 2 != 0 ? $currency->sign . ' ' : '') . $product_attribute['price'] . ($currency->format % 2 == 0 ? ' ' . $currency->sign : '') . '</td> <td class="right">' . $product_attribute['weight'] . Configuration::get('PS_WEIGHT_UNIT') . '</td> <td class="right">' . $product_attribute['reference'] . '</td> <td class="right">' . $product_attribute['ean13'] . '</td> <td class="right">' . $product_attribute['upc'] . '</td> <td class="center">' . $product_attribute['quantity'] . '</td> <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['attribute_minimal_quantity'] . '\'); calcImpactPriceTI();" /></a> ' . (!$product_attribute['default_on'] ? '<a href="' . $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') . (int) $cookie->id_employee) . '"> <img src="../img/admin/asterisk.gif" alt="' . $this->l('Make this the default combination') . '" title="' . $this->l('Make this combination the default one') . '"></a>' : '') . ' <a href="' . $currentIndex . '&deleteProductAttribute&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') . (int) $cookie->id_employee) . '" onclick="return confirm(\'' . $this->l('Are you sure?', __CLASS__, true, false) . '\');"> <img src="../img/admin/delete.gif" alt="' . $this->l('Delete this combination') . '" /></a></td> </tr>'; } echo '<tr><td colspan="7" align="center"><a href="' . $currentIndex . '&deleteAllProductAttributes&id_product=' . $obj->id . '&token=' . Tools::getAdminToken('AdminCatalog' . (int) Tab::getIdFromClassName('AdminCatalog') . (int) $cookie->id_employee) . '" onclick="return confirm(\'' . $this->l('Are you sure?', __CLASS__, true, false) . '\');"><img src="../img/admin/delete.gif" alt="' . $this->l('Delete this combination') . '" /> ' . $this->l('Delete all combinations') . '</a></td></tr>'; } else { echo '<tr><td colspan="7" align="center"><i>' . $this->l('No combination yet') . '.</i></td></tr>'; } } echo ' </table> <br />' . $this->l('The row in blue is the default combination.') . ' <br /> ' . $this->l('A default combination must be designated for each product.') . ' </td> </tr> </table> <script type="text/javascript"> var impact = getE(\'attribute_price_impact\'); var impact2 = getE(\'attribute_weight_impact\'); var s_attr_group = document.getElementById(\'span_new_group\'); var s_attr_name = document.getElementById(\'span_new_attr\'); var s_impact = document.getElementById(\'span_impact\'); var s_impact2 = document.getElementById(\'span_weight_impact\'); init_elems(); </script> <hr style="width:100%;" /> <table cellpadding="5"> <tr> <td class="col-left"><b>' . $this->l('Color picker:') . '</b></td> <td style="padding-bottom:5px;"> <select name="id_color_default"> <option value="0">' . $this->l('Do not display') . '</option>'; foreach ($attributes_groups as $k => $attribute_group) { if (isset($groups[$attribute_group['id_attribute_group']])) { echo '<option value="' . (int) $attribute_group['id_attribute_group'] . '" ' . ((int) $attribute_group['id_attribute_group'] == (int) $obj->id_color_default ? 'selected="selected"' : '') . '>' . htmlentities(stripslashes($attribute_group['name']), ENT_COMPAT, 'UTF-8') . '</option>'; } } echo ' </select> <input type="submit" value="' . $this->l('OK') . '" name="submitAdd' . $this->table . 'AndStay" class="button" /> <a href="index.php?tab=AdminAttributesGroups&token=' . Tools::getAdminToken('AdminAttributesGroups' . (int) Tab::getIdFromClassName('AdminAttributesGroups') . (int) $cookie->id_employee) . '" onclick="return confirm(\'' . $this->l('Are you sure you want to delete entered product information?', __CLASS__, true, false) . '\');"><img src="../img/admin/asterisk.gif" alt="" /> ' . $this->l('Color attribute management') . '</a> <p >' . $this->l('Activate the color choice by selecting a color attribute group.') . '</p> </td> </tr> </table>'; } else { echo '<b>' . $this->l('You must save this product before adding combinations') . '.</b>'; } }
public function initFormAttributes($product) { $data = $this->createTemplate($this->tpl_form); if (!Combination::isFeatureActive()) { $this->displayWarning($this->l('This feature has been disabled. ') . ' <a href="index.php?tab=AdminPerformance&token=' . Tools::getAdminTokenLite('AdminPerformance') . '#featuresDetachables">' . $this->l('Performances') . '</a>'); } else { if (Validate::isLoadedObject($product)) { if ($this->product_exists_in_shop) { if ($product->is_virtual) { $data->assign('product', $product); $this->displayWarning($this->l('A virtual product cannot have combinations.')); } else { $attribute_js = array(); $attributes = Attribute::getAttributes($this->context->language->id, true); foreach ($attributes as $k => $attribute) { $attribute_js[$attribute['id_attribute_group']][$attribute['id_attribute']] = $attribute['name']; } $currency = $this->context->currency; $data->assign('attributeJs', $attribute_js); $data->assign('attributes_groups', AttributeGroup::getAttributesGroups($this->context->language->id)); $data->assign('currency', $currency); $images = Image::getImages($this->context->language->id, $product->id); $data->assign('tax_exclude_option', Tax::excludeTaxeOption()); $data->assign('ps_weight_unit', Configuration::get('PS_WEIGHT_UNIT')); $data->assign('ps_use_ecotax', Configuration::get('PS_USE_ECOTAX')); $data->assign('field_value_unity', $this->getFieldValue($product, 'unity')); $data->assign('reasons', $reasons = StockMvtReason::getStockMvtReasons($this->context->language->id)); $data->assign('ps_stock_mvt_reason_default', $ps_stock_mvt_reason_default = Configuration::get('PS_STOCK_MVT_REASON_DEFAULT')); $data->assign('minimal_quantity', $this->getFieldValue($product, 'minimal_quantity') ? $this->getFieldValue($product, 'minimal_quantity') : 1); $data->assign('available_date', $this->getFieldValue($product, 'available_date') != 0 ? stripslashes(htmlentities($this->getFieldValue($product, 'available_date'), $this->context->language->id)) : '0000-00-00'); $i = 0; $type = ImageType::getByNameNType('%', 'products', 'height'); if (isset($type['name'])) { $data->assign('imageType', $type['name']); } else { $data->assign('imageType', 'small_default'); } $data->assign('imageWidth', (isset($image_type['width']) ? (int) $image_type['width'] : 64) + 25); foreach ($images as $k => $image) { $images[$k]['obj'] = new Image($image['id_image']); ++$i; } $data->assign('images', $images); $data->assign($this->tpl_form_vars); $data->assign(array('list' => $this->renderListAttributes($product, $currency), 'product' => $product, 'id_category' => $product->getDefaultCategory(), 'token_generator' => Tools::getAdminTokenLite('AdminAttributeGenerator'), 'combination_exists' => Shop::isFeatureActive() && Shop::getContextShopGroup()->share_stock && count(AttributeGroup::getAttributesGroups($this->context->language->id)) > 0 && $product->hasAttributes())); } } else { $this->displayWarning($this->l('You must save the product in this shop before adding combinations.')); } } else { $data->assign('product', $product); $this->displayWarning($this->l('You must save this product before adding combinations.')); } } $this->tpl_form_vars['custom_form'] = $data->fetch(); }
/** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { header('HTTP/1.1 404 Not Found'); header('Status: 404 Not Found'); if (preg_match('/\\.(gif|jpe?g|png|ico)$/i', parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH))) { $this->context->cookie->disallowWriting(); if (!isset($_SERVER['REDIRECT_URL'])) { $_SERVER['REDIRECT_URL'] = ''; if (preg_match('@^' . __PS_BASE_URI__ . '([0-9]+)\\-([_a-zA-Z0-9-]+)(/[_a-zA-Z0-9-]+)?\\.jpg$@', $_SERVER['REQUEST_URI'], $matches)) { $_SERVER['REDIRECT_URL'] = __PS_BASE_URI__ . 'p/' . Image::getImgFolderStatic($matches[0]) . '/' . $matches[0] . '-' . $matches[1] . '.jpg'; } } if (preg_match('#/p[0-9/]*/([0-9]+)\\-([_a-zA-Z]*)\\.(png|jpe?g|gif)$#', $_SERVER['REDIRECT_URL'], $matches)) { // Backward compatibility since we suffixed the template image with _default if (Tools::strtolower(substr($matches[2], -8)) != '_default') { header('Location: ' . $this->context->link->getImageLink('', $matches[1], $matches[2]), true, 302); exit; } else { $image_type = ImageType::getByNameNType($matches[2], 'products'); if ($image_type && count($image_type)) { $root = _PS_PROD_IMG_DIR_; $folder = Image::getImgFolderStatic($matches[1]); $file = $matches[1]; $ext = '.' . $matches[3]; if (file_exists($root . $folder . $file . $ext)) { if (ImageManager::resize($root . $folder . $file . $ext, $root . $folder . $file . '-' . $matches[2] . $ext, (int) $image_type['width'], (int) $image_type['height'])) { header('HTTP/1.1 200 Found'); header('Status: 200 Found'); header('Content-Type: image/jpg'); readfile($root . $folder . $file . '-' . $matches[2] . $ext); exit; } } } } } elseif (preg_match('#/c/([0-9]+)\\-([_a-zA-Z]*)\\.(png|jpe?g|gif)$#', $_SERVER['REDIRECT_URL'], $matches)) { $image_type = ImageType::getByNameNType($matches[2], 'categories'); if ($image_type && count($image_type)) { $root = _PS_CAT_IMG_DIR_; $file = $matches[1]; $ext = '.' . $matches[3]; if (file_exists($root . $file . $ext)) { if (ImageManager::resize($root . $file . $ext, $root . $file . '-' . $matches[2] . $ext, (int) $image_type['width'], (int) $image_type['height'])) { header('HTTP/1.1 200 Found'); header('Status: 200 Found'); header('Content-Type: image/jpg'); readfile($root . $file . '-' . $matches[2] . $ext); exit; } } } } header('Content-Type: image/gif'); readfile(_PS_IMG_DIR_ . '404.gif'); exit; } elseif (in_array(Tools::strtolower(substr($_SERVER['REQUEST_URI'], -3)), array('.js', 'css'))) { $this->context->cookie->disallowWriting(); exit; } parent::initContent(); $this->setTemplate(_PS_THEME_DIR_ . '404.tpl'); }
/** * @param Offer $obj * @throws Exception * @throws SmartyException */ public function initFormImages($obj) { $data = $this->createTemplate($this->tpl_form); if ((bool) $obj->id) { // if ($this->offer_exists_in_shop) { $data->assign('offer', $this->loadObject()); $count_images = Db::getInstance()->getValue(' SELECT COUNT(id_offer) FROM ' . _DB_PREFIX_ . 'offer_image WHERE id_offer = ' . (int) $obj->id); $images = AphOfferImage::getImages($this->context->language->id, $obj->id); foreach ($images as $k => $image) { $images[$k] = new AphOfferImage($image['id_image']); } if ($this->context->shop->getContext() == Shop::CONTEXT_SHOP) { $current_shop_id = (int) $this->context->shop->id; } else { $current_shop_id = 0; } $language = Language::getLanguage(Configuration::get('PS_LANG_DEFAULT')); $image_uploader = new HelperImageUploader('file'); $image_uploader->setTemplateDirectory($this->tpl_dir . 'helpers/uploader/')->setMultiple(!(Tools::getUserBrowser() == 'Apple Safari' && Tools::getUserPlatform() == 'Windows'))->setUseAjax(true)->setUrl(Context::getContext()->link->getAdminLink('AdminAphOffers') . '&ajax=1&id_offer=' . (int) $obj->id . '&action=addOfferImage')->setTemplate('ajax.tpl'); $data->assign(array('countImages' => $count_images, 'id_offer' => (int) Tools::getValue('id_offer'), 'images' => $images, 'iso_lang' => $language['iso_code'], 'token' => $this->token, 'table' => $this->table, 'max_image_size' => $this->max_image_size / 1024 / 1024, 'currency' => $this->context->currency, 'current_shop_id' => $current_shop_id, 'languages' => $this->_languages, 'default_language' => (int) Configuration::get('PS_LANG_DEFAULT'), 'image_uploader' => $image_uploader->render())); $type = ImageType::getByNameNType('%', 'products', 'height'); if (isset($type['name'])) { $data->assign('imageType', $type['name']); } else { $data->assign('imageType', ImageType::getFormatedName('small')); } // } else { // $this->displayWarning($this->l('You must save the offer in this shop before adding images.')); // } } else { $this->displayWarning($this->l('You must save this offer before adding images.')); } $this->tpl_form_vars['custom_form'] = $data->fetch(); }
protected static function _getImageTypeFormatedName($name) { if (method_exists('ImageType', 'getFormatedName')) { return ImageType::getFormatedName($name); } else { $theme_name = Context::getContext()->shop->theme_name; $name_without_theme_name = str_replace(array('_' . $theme_name, $theme_name . '_'), '', $name); if (strstr($name, $theme_name) && ImageType::getByNameNType($name)) { return $name; } else { if (ImageType::getByNameNType($name_without_theme_name . '_' . $theme_name, 'products')) { return $name_without_theme_name . '_' . $theme_name; } else { return $theme_name . '_' . $name_without_theme_name; } } } }
public function initContentForCombinations() { ${${"GLOBALS"}["vmqqtmkyw"]} = $this->object; if (!Combination::isFeatureActive()) { $this->displayWarning($this->getMessage("This feature has been disabled, you can activate this feature at this page:") . $this->getMessage("link to Performances")); return; } ${"GLOBALS"}["weevwwkl"] = "product"; if (Validate::isLoadedObject(${${"GLOBALS"}["weevwwkl"]})) { self::$smarty->assign("country_display_tax_label", $this->context->country->display_tax_label); $zsahvowoo = "lang"; self::$smarty->assign("tax_exclude_taxe_option", Tax::excludeTaxeOption()); self::$smarty->assign("id_tax_rules_group", $product->id_tax_rules_group); self::$smarty->assign("tax_rules_groups", TaxRulesGroup::getTaxRulesGroups(true)); ${$zsahvowoo} = new Language($this->id_language); self::$smarty->assign("iso_code", $lang->iso_code); self::$smarty->assign("combinationImagesJs", $this->getCombinationImagesJs()); if ($product->is_virtual) { $tpkpvyor = "product"; self::$smarty->assign("product", ${$tpkpvyor}); $this->displayWarning($this->getMessage("A virtual product cannot have combinations.")); } else { ${"GLOBALS"}["qqjbnscylsi"] = "attribute_js"; ${"GLOBALS"}["nqxaoftbn"] = "attribute"; $bcesaxqdqqq = "images"; ${"GLOBALS"}["zcxmuajd"] = "ps_stock_mvt_reason_default"; $vmytjghdfi = "attribute_js"; $nrkrfhirkx = "attributes"; ${${"GLOBALS"}["qqjbnscylsi"]} = array(); $cappytc = "k"; ${"GLOBALS"}["jyaoxpe"] = "attribute"; ${$nrkrfhirkx} = Attribute::getAttributes($this->context->language->id, true); foreach (${${"GLOBALS"}["ecblflvypvt"]} as ${$cappytc} => ${${"GLOBALS"}["jyaoxpe"]}) { ${$vmytjghdfi}[${${"GLOBALS"}["iixdipeiyldv"]}["id_attribute_group"]][${${"GLOBALS"}["iixdipeiyldv"]}["id_attribute"]] = ${${"GLOBALS"}["nqxaoftbn"]}["name"]; } ${"GLOBALS"}["higiwiyuxd"] = "k"; ${${"GLOBALS"}["sxexnhlq"]} = new Currency((int) Configuration::get("PS_CURRENCY_DEFAULT")); self::$smarty->assign("attributeJs", ${${"GLOBALS"}["xenfvrjowsy"]}); self::$smarty->assign("attributes_groups", AttributeGroup::getAttributesGroups($this->context->language->id)); self::$smarty->assign("currency", ${${"GLOBALS"}["sxexnhlq"]}); ${"GLOBALS"}["xzqtsdnlkv"] = "images"; ${$bcesaxqdqqq} = Image::getImages($this->context->language->id, $product->id); self::$smarty->assign("tax_exclude_option", Tax::excludeTaxeOption()); $rbxbrbxg = "product"; self::$smarty->assign("ps_weight_unit", Configuration::get("PS_WEIGHT_UNIT")); self::$smarty->assign("ps_use_ecotax", Configuration::get("PS_USE_ECOTAX")); self::$smarty->assign("field_value_unity", $this->getFieldValue(${${"GLOBALS"}["vmqqtmkyw"]}, "unity")); ${"GLOBALS"}["vpcuib"] = "image_type"; self::$smarty->assign("reasons", ${${"GLOBALS"}["nqegxbae"]} = StockMvtReason::getStockMvtReasons($this->context->language->id)); self::$smarty->assign("ps_stock_mvt_reason_default", ${${"GLOBALS"}["zcxmuajd"]} = Configuration::get("PS_STOCK_MVT_REASON_DEFAULT")); self::$smarty->assign("minimal_quantity", $this->getFieldValue(${${"GLOBALS"}["vmqqtmkyw"]}, "minimal_quantity") ? $this->getFieldValue(${${"GLOBALS"}["vmqqtmkyw"]}, "minimal_quantity") : 1); self::$smarty->assign("available_date", $this->getFieldValue(${$rbxbrbxg}, "available_date") != 0 ? stripslashes(htmlentities(Tools::displayDate($this->getFieldValue(${${"GLOBALS"}["vmqqtmkyw"]}, "available_date"), version_compare(_PS_VERSION_, "1.5.5", ">=") ? null : $this->context->language->id))) : "0000-00-00"); ${${"GLOBALS"}["tqkkuicfgax"]} = 0; ${"GLOBALS"}["ucamhp"] = "product"; self::$smarty->assign("imageType", ImageType::getByNameNType("small_default", "products")); self::$smarty->assign("imageWidth", (isset(${${"GLOBALS"}["rvkjjxqs"]}["width"]) ? (int) ${${"GLOBALS"}["vpcuib"]}["width"] : 64) + 25); foreach (${${"GLOBALS"}["xzqtsdnlkv"]} as ${${"GLOBALS"}["higiwiyuxd"]} => ${${"GLOBALS"}["inpuwydsyk"]}) { $cshrlmyryz = "image"; ${${"GLOBALS"}["dhvuermstcbs"]}[${${"GLOBALS"}["qtxqhylrbsm"]}]["obj"] = new Image(${$cshrlmyryz}["id_image"]); $kcvbkys = "i"; ++${$kcvbkys}; } self::$smarty->assign("images", ${${"GLOBALS"}["dhvuermstcbs"]}); self::$smarty->assign(array("combinationArray" => $this->getCombinations(${${"GLOBALS"}["ucamhp"]}, ${${"GLOBALS"}["sxexnhlq"]}), "product" => ${${"GLOBALS"}["vmqqtmkyw"]}, "id_category" => $product->getDefaultCategory(), "token_generator" => "tokengenerator", "combination_exists" => Shop::isFeatureActive() && Shop::getContextShopGroup()->share_stock && count(AttributeGroup::getAttributesGroups($this->context->language->id)) > 0)); } } else { self::$smarty->assign("product", ${${"GLOBALS"}["vmqqtmkyw"]}); $this->displayWarning($this->getMessage("You must save this product before adding combinations.")); } }
/** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { $category_rewrite = explode('/', $_SERVER['REQUEST_URI']); if (isset($category_rewrite[1]) && !empty($category_rewrite[1])) { $id_category = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(' SELECT `id_category` FROM `' . _DB_PREFIX_ . 'category_lang` WHERE `link_rewrite` = \'' . $category_rewrite[1] . '\''); if ($id_category > 0) { $category = new Category($id_category); if (is_object($category) && isset($category->id, $this->context->language->id)) { $url = _PS_BASE_URL_ . __PS_BASE_URI__ . $category_rewrite[1] . '/'; $redirect_type = Configuration::get('PS_CANONICAL_REDIRECT') == 2 ? '301' : '302'; header('HTTP/1.0 ' . $redirect_type . ' Moved'); header('Cache-Control: no-cache'); Tools::redirectLink($url); } } } header('HTTP/1.1 404 Not Found'); header('Status: 404 Not Found'); if (preg_match('/\\.(gif|jpe?g|png|ico)$/i', parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH))) { $this->context->cookie->disallowWriting(); if (!isset($_SERVER['REDIRECT_URL'])) { $_SERVER['REDIRECT_URL'] = ''; if (preg_match('@^' . __PS_BASE_URI__ . '([0-9]+)\\-([_a-zA-Z0-9-]+)(/[_a-zA-Z0-9-]+)?\\.jpg$@', $_SERVER['REQUEST_URI'], $matches)) { $_SERVER['REDIRECT_URL'] = __PS_BASE_URI__ . 'p/' . Image::getImgFolderStatic($matches[0]) . '/' . $matches[0] . '-' . $matches[1] . '.jpg'; } } if (preg_match('#/p[0-9/]*/([0-9]+)\\-([_a-zA-Z]*)\\.(png|jpe?g|gif)$#', $_SERVER['REDIRECT_URL'], $matches)) { // Backward compatibility since we suffixed the template image with _default if (Tools::strtolower(substr($matches[2], -8)) != '_default') { header('Location: ' . $this->context->link->getImageLink('', $matches[1], $matches[2]), true, 302); exit; } else { $image_type = ImageType::getByNameNType($matches[2], 'products'); if ($image_type && count($image_type)) { $root = _PS_PROD_IMG_DIR_; $folder = Image::getImgFolderStatic($matches[1]); $file = $matches[1]; $ext = '.' . $matches[3]; if (file_exists($root . $folder . $file . $ext)) { if (ImageManager::resize($root . $folder . $file . $ext, $root . $folder . $file . '-' . $matches[2] . $ext, (int) $image_type['width'], (int) $image_type['height'])) { header('HTTP/1.1 200 Found'); header('Status: 200 Found'); header('Content-Type: image/jpg'); readfile($root . $folder . $file . '-' . $matches[2] . $ext); exit; } } } } } elseif (preg_match('#/c/([0-9]+)\\-([_a-zA-Z]*)\\.(png|jpe?g|gif)$#', $_SERVER['REDIRECT_URL'], $matches)) { $image_type = ImageType::getByNameNType($matches[2], 'categories'); if ($image_type && count($image_type)) { $root = _PS_CAT_IMG_DIR_; $file = $matches[1]; $ext = '.' . $matches[3]; if (file_exists($root . $file . $ext)) { if (ImageManager::resize($root . $file . $ext, $root . $file . '-' . $matches[2] . $ext, (int) $image_type['width'], (int) $image_type['height'])) { header('HTTP/1.1 200 Found'); header('Status: 200 Found'); header('Content-Type: image/jpg'); readfile($root . $file . '-' . $matches[2] . $ext); exit; } } } } header('Content-Type: image/gif'); readfile(_PS_IMG_DIR_ . '404.gif'); exit; } elseif (in_array(Tools::strtolower(substr($_SERVER['REQUEST_URI'], -3)), array('.js', 'css'))) { $this->context->cookie->disallowWriting(); exit; } parent::initContent(); $this->setTemplate(_PS_THEME_DIR_ . '404.tpl'); }
public static function installPicturesSettings($module) { // Default if ($default = ImageType::getByNameNType('medium', 'products')) { $sizeMedium = (int) $default['id_image_type']; } else { if ($medium = ImageType::getByNameNType('medium_default', 'products')) { $sizeMedium = (int) $default['id_image_type']; } else { $sizeMedium = 0; } } // Small if ($small = ImageType::getByNameNType('small', 'products')) { $sizeSmall = (int) $small['id_image_type']; } else { if ($small = ImageType::getByNameNType('small_default', 'products')) { $sizeSmall = (int) $small['id_image_type']; } else { $sizeSmall = 0; } } // Large if ($large = ImageType::getByNameNType('large', 'products')) { $sizeBig = (int) $large['id_image_type']; } else { if ($large = ImageType::getByNameNType('large_default', 'products')) { $sizeBig = (int) $large['id_image_type']; } else { $sizeBig = 0; } } $module->setConfiguration('EBAY_PICTURE_SIZE_DEFAULT', $sizeMedium); $module->setConfiguration('EBAY_PICTURE_SIZE_SMALL', $sizeSmall); $module->setConfiguration('EBAY_PICTURE_SIZE_BIG', $sizeBig); }
/** * @param Store $obj * @throws Exception * @throws SmartyException */ public function initFormImages($obj) { if ((bool) $obj->id) { $count_images = Db::getInstance()->getValue(' SELECT COUNT(id_shop) FROM ' . _DB_PREFIX_ . 'store_image WHERE id_shop = ' . (int) $obj->id_shop); $images = AphStoreImage::getImages($this->context->language->id, $obj->id_shop); foreach ($images as $k => $image) { $images[$k] = new AphStoreImage($image['id_image']); } $language = Language::getLanguage(Configuration::get('PS_LANG_DEFAULT')); $image_uploader = new HelperImageUploader('file'); $image_uploader->setTemplateDirectory($this->tpl_dir . 'helpers/uploader/')->setMultiple(!(Tools::getUserBrowser() == 'Apple Safari' && Tools::getUserPlatform() == 'Windows'))->setUseAjax(true)->setUrl(Context::getContext()->link->getAdminLink('AdminAphStores') . '&ajax=1&id_store=' . (int) $obj->id . '&action=addStoreImage')->setTemplate('ajax.tpl'); $this->context->smarty->assign(array('iso_lang' => $language['iso_code'], 'token' => $this->token, 'table' => $this->table, 'countImages' => $count_images, 'images' => $images, 'max_image_size' => $this->max_image_size / 1024 / 1024, "image_uploader" => $image_uploader->render(), 'table' => $this->table, 'default_language' => (int) Configuration::get('PS_LANG_DEFAULT'), 'current_shop_id' => (int) $obj->id_shop, 'id_shop' => (int) $obj->id_shop, 'id_store' => (int) $obj->id)); $type = ImageType::getByNameNType('%', 'stores', 'height'); if (isset($type['name'])) { $this->context->smarty->assign('imageType', $type['name']); } else { $this->context->smarty->assign('imageType', ImageType::getFormatedName('medium')); } } }