function displayFormInformations($obj, $currency, $languages, $defaultLanguage) { global $currentIndex, $cookie; $iso = Language::getIsoById(intval($cookie->id_lang)); $divLangName = 'cname¤cdesc¤cdesc_short¤clink_rewrite¤cmeta_description¤cmeta_title¤cmeta_keywords¤ctags¤cavailable_now¤cavailable_later'; $qty_state = 'readonly'; $qty = Attribute::getAttributeQty($this->getFieldValue($obj, 'id_product')); if ($qty === false) { if (Validate::isLoadedObject($obj)) { $qty = $this->getFieldValue($obj, 'quantity'); } else { $qty = 1; } $qty_state = ''; } $cover = Product::getCover($obj->id); $link = new Link(); //includeDatepicker(array('reduction_from', 'reduction_to')); echo ' <div class="tab-page" id="step1"> <h4 class="tab">1. ' . $this->l('Info.') . '</h4> <b>' . $this->l('Product global informations') . '</b> - '; if (isset($obj->id)) { echo ' <a href="' . $link->getProductLink($this->getFieldValue($obj, 'id'), $this->getFieldValue($obj, 'link_rewrite', $defaultLanguage), Category::getLinkRewrite($this->getFieldValue($obj, 'id_category_default'), intval($cookie->id_lang))) . '"><img src="../img/admin/details.gif" alt="' . $this->l('View product in shop') . '" title="' . $this->l('View product in shop') . '" /> ' . $this->l('View product in shop') . '</a>'; if (file_exists(_PS_MODULE_DIR_ . 'statsproduct/statsproduct.php')) { echo ' - <a href="index.php?tab=AdminStatsModules&module=statsproduct&id_product=' . $obj->id . '&token=' . Tools::getAdminToken('AdminStatsModules' . intval(Tab::getIdFromClassName('AdminStatsModules')) . intval($cookie->id_employee)) . '"><img src="../modules/statsproduct/logo.gif" alt="' . $this->l('View product sales') . '" title="' . $this->l('View product sales') . '" /> ' . $this->l('View product sales') . '</a>'; } } echo ' <hr class="clear"/> <br /> <table cellpadding="5" style="width:100%"> <tr> <td class="col-left">' . $this->l('Name:') . '</td> <td style="padding-bottom:5px;">'; foreach ($languages as $language) { echo ' <div id="cname_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left;"> <input size="55" type="text" id="name_' . $language['id_lang'] . '" name="name_' . $language['id_lang'] . '" value="' . stripslashes(htmlspecialchars($this->getFieldValue($obj, 'name', $language['id_lang']))) . '"' . (!$obj->id ? ' onkeyup="copy2friendlyURL();"' : '') . ' onchange="updateCurrentText();" /><sup> *</sup> <span class="hint" name="help_box">' . $this->l('Invalid characters:') . ' <>;=#{}<span class="hint-pointer"> </span></span> </div>'; } $this->displayFlags($languages, $defaultLanguage, $divLangName, 'cname'); echo '<script type="text/javascript">updateCurrentText();</script> </td> </tr> <tr> <td style="vertical-align:top">' . $this->l('Status:') . '</td> <td style="padding-bottom:5px;"> <input style="float:left;" type="radio" name="active" id="active_on" value="1" ' . ($this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '') . '/> <label for="active_on" class="t"><img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" style="float:left; padding:0px 5px 0px 5px;" />' . $this->l('Enabled') . '</label> <br style="clear:both;" /> <input style="float:left;" type="radio" name="active" id="active_off" value="0" ' . (!$this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '') . '/> <label for="active_off" class="t"><img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" style="float:left; padding:0px 5px 0px 5px" />' . $this->l('Disabled') . '</label> </td> </tr> <tr> <td>' . $this->l('Manufacturer:') . '</td> <td style="padding-bottom:5px;"> <select name="id_manufacturer" id="id_manufacturer"> <option value="0">-- ' . $this->l('Choose (optional)') . ' --</option>'; if ($id_manufacturer = $this->getFieldValue($obj, 'id_manufacturer')) { echo ' <option value="' . $id_manufacturer . '" selected="selected">' . Manufacturer::getNameById($id_manufacturer) . '</option> <option disabled="disabled">----------</option>'; } echo ' </select> <a href="?tab=AdminManufacturers&addmanufacturer&token=' . Tools::getAdminToken('AdminManufacturers' . intval(Tab::getIdFromClassName('AdminManufacturers')) . 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/add.gif" alt="' . $this->l('Create') . '" title="' . $this->l('Create') . '" /> <b>' . $this->l('Create') . '</b></a> <script type="text/javascript"> var ajaxManufacturersClicked = false; $("select#id_manufacturer").focus( function() { if (ajaxManufacturersClicked == true) return; else ajaxManufacturersClicked = true; $.getJSON("' . dirname($currentIndex) . '/ajax.php",{ajaxProductManufacturers:1}, function(j) { var options = \'\'; for (var i = 0; i < getE("id_manufacturer").options.length; i++) { if (getE("id_manufacturer").options[i].innerHTML == \'----------\') options += \'<option disabled="disabled">----------</option>\'; else options += \'<option value="\' + getE("id_manufacturer").options[i].value + \'">\' + getE("id_manufacturer").options[i].innerHTML + \'</option>\'; } for (var i = 0; i < j.length; i++) options += \'<option value="\' + j[i].optionValue + \'">\' + j[i].optionDisplay + \'</option>\'; $("select#id_manufacturer").html(options); } ) } ); </script> </td> </tr> <tr> <td>' . $this->l('Supplier:') . '</td> <td style="padding-bottom:5px;"> <select name="id_supplier" id="id_supplier"> <option value="0">-- ' . $this->l('Choose (optional)') . ' --</option>'; if ($id_supplier = $this->getFieldValue($obj, 'id_supplier')) { echo ' <option value="' . $id_supplier . '" selected="selected">' . Supplier::getNameById($id_supplier) . '</option> <option disabled="disabled">----------</option>'; } echo ' </select> <a href="?tab=AdminSuppliers&addsupplier&token=' . Tools::getAdminToken('AdminSuppliers' . intval(Tab::getIdFromClassName('AdminSuppliers')) . 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/add.gif" alt="' . $this->l('Create') . '" title="' . $this->l('Create') . '" /> <b>' . $this->l('Create') . '</b></a> <script type="text/javascript"> var ajaxSuppliersClicked = false; $("select#id_supplier").focus( function() { if (ajaxSuppliersClicked == true) return; else ajaxSuppliersClicked = true; $.getJSON("' . dirname($currentIndex) . '/ajax.php",{ajaxProductSuppliers:1}, function(j) { var options = \'\'; for (var i = 0; i < getE("id_supplier").options.length; i++) { if (getE("id_supplier").options[i].innerHTML == \'----------\') options += \'<option disabled="disabled">----------</option>\'; else options += \'<option value="\' + getE("id_supplier").options[i].value + \'">\' + getE("id_supplier").options[i].innerHTML + \'</option>\'; } for (var i = 0; i < j.length; i++) options += \'<option value="\' + j[i].optionValue + \'">\' + j[i].optionDisplay + \'</option>\'; $("select#id_supplier").html(options); } ) } ); </script> </td> </tr> <tr> <td class="col-left">' . $this->l('Reference:') . '</td> <td style="padding-bottom:5px;"> <input size="55" type="text" name="reference" value="' . htmlentities($this->getFieldValue($obj, 'reference'), ENT_COMPAT, 'UTF-8') . '" style="width: 130px; margin-right: 44px;" /> ' . $this->l('EAN13:') . '<input size="55" maxlength="13" type="text" name="ean13" value="' . $this->getFieldValue($obj, 'ean13') . '" 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 class="col-left">' . $this->l('Supplier Reference:') . '</td> <td style="padding-bottom:5px;"> <input size="55" type="text" name="supplier_reference" value="' . htmlentities($this->getFieldValue($obj, 'supplier_reference'), ENT_COMPAT, 'UTF-8') . '" style="width: 130px; margin-right: 44px;" /> ' . $this->l('Location:') . '<input size="55" type="text" name="location" value="' . $this->getFieldValue($obj, 'location') . '" 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 class="col-left">' . $this->l('Weight:') . '</td> <td style="padding-bottom:5px;"> <input size="6" maxlength="6" name="weight" type="text" value="' . htmlentities($this->getFieldValue($obj, 'weight'), ENT_COMPAT, 'UTF-8') . '" onKeyUp="javascript:this.value = this.value.replace(/,/g, \'.\');" /> ' . Configuration::get('PS_WEIGHT_UNIT') . ' </td> </tr> <tr><td colspan="2"><hr style="width:730px;"></td></tr>'; $this->displayPack($obj); echo ' <tr><td colspan="2"><hr style="width:730px;"></td></tr>'; /* * Form for add a virtual product like software, mp3, etc... */ $productDownload = new ProductDownload(); if ($id_product_download = $productDownload->getIdFromIdProduct($this->getFieldValue($obj, 'id'))) { $productDownload = new ProductDownload($id_product_download); } ?> <script type="text/javascript"> // <![CDATA[ ThickboxI18nImage = '<?php echo $this->l('Image'); ?> '; ThickboxI18nOf = '<?php echo $this->l('of'); ?> ';; ThickboxI18nClose = '<?php echo $this->l('Close'); ?> '; ThickboxI18nOrEscKey = '<?php echo $this->l('(or "Esc")'); ?> '; ThickboxI18nNext = '<?php echo $this->l('Next >'); ?> '; ThickboxI18nPrev = '<?php echo $this->l('< Previous'); ?> '; tb_pathToImage = '../img/loadingAnimation.gif'; //]]> </script> <script type="text/javascript" src="<?php echo _PS_JS_DIR_; ?> jquery/thickbox-modified.js"></script> <script type="text/javascript" src="<?php echo _PS_JS_DIR_; ?> jquery/ajaxfileupload.js"></script> <script type="text/javascript" src="<?php echo _PS_JS_DIR_; ?> date.js"></script> <style type="text/css"> <!-- @import url(<?php echo _PS_CSS_DIR_; ?> thickbox.css); --> </style> <script type="text/javascript"> <!-- function toggleVirtualProduct(elt) { if (elt.checked) { $('#virtual_good').show('slow'); getE('out_of_stock_1').checked = 'checked'; getE('out_of_stock_2').readOnly = true; getE('out_of_stock_3').readOnly = true; getE('label_out_of_stock_2').setAttribute('for', ''); getE('label_out_of_stock_3').setAttribute('for', ''); } else { $('#virtual_good').hide('slow'); getE('out_of_stock_2').readOnly = false; getE('out_of_stock_3').readOnly = false; getE('label_out_of_stock_2').setAttribute('for', 'out_of_stock_2'); getE('label_out_of_stock_3').setAttribute('for', 'out_of_stock_3'); } } function uploadFile() { $.ajaxFileUpload ( { url:'./uploadProductFile.php', secureuri:false, fileElementId:'virtual_product_file', dataType: 'xml', success: function (data, status) { data = data.getElementsByTagName('return')[0]; var result = data.getAttribute("result"); var msg = data.getAttribute("msg"); var fileName = data.getAttribute("filename"); if(result == "error") { $("#upload-confirmation").html('<p>error: ' + msg + '</p>'); } else { $('#virtual_product_file').remove(); $('#virtual_product_file_label').hide(); $('#virtual_product_name').attr('value', fileName); $('#upload-confirmation').html( '<a class="link" href="get-file-admin.php?file=' + msg + '"><?php echo $this->l('The file'); ?> "' + fileName + '" <?php echo $this->l('has successfully been uploaded'); ?> </a>' + '<input type="hidden" id="virtual_product_filename" name="virtual_product_filename" value="' + msg + '" />'); } } } ); } --> </script> <?php echo ' <script type="text/javascript"> var newLabel = \'' . $this->l('New label') . '\'; var choose_language = \'' . $this->l('Choose language:') . '\'; var required = \'' . $this->l('required') . '\'; var customizationUploadableFileNumber = ' . intval($this->getFieldValue($obj, 'uploadable_files')) . '; var customizationTextFieldNumber = ' . intval($this->getFieldValue($obj, 'text_fields')) . '; var uploadableFileLabel = 0; var textFieldLabel = 0; var defaultLanguage = ' . intval($defaultLanguage) . '; var languages = new Array();'; $i = 0; foreach ($languages as $language) { echo 'languages[' . $i++ . '] = new Array(' . intval($language['id_lang']) . ', \'' . $language['iso_code'] . '\', \'' . htmlentities($language['name'], ENT_COMPAT, 'UTF-8') . '\');' . "\n"; } echo ' </script>'; ?> <tr> <td colspan="2"> <input type="checkbox" id="is_virtual_good" name="is_virtual_good" value="true" onchange="toggleVirtualProduct(this)" onclick="toggleVirtualProduct(this);" <?php if (($productDownload->id or Tools::getValue('is_virtual_good') == 'true') and $productDownload->active) { echo 'checked="checked"'; } ?> /> <label for="is_virtual_good" class="t bold"><?php echo $this->l('Is this a downloadable product?'); ?> </label> <div id="virtual_good" <?php if (!$productDownload->id or !$productDownload->active) { echo 'style="display:none;"'; } ?> > <?php if (!ProductDownload::checkWritableDir()) { ?> <p class="alert"> <?php echo $this->l('Your download repository is not writable.'); ?> <br/> <?php echo realpath(_PS_DOWNLOAD_DIR_); ?> </p> <?php } else { ?> <?php if ($productDownload->id) { echo '<input type="hidden" id="virtual_product_id" name="virtual_product_id" value="' . $productDownload->id . '" />'; } ?> <p class="block"> <?php if (!$productDownload->checkFile()) { ?> <?php if ($productDownload->id) { ?> <p class="alert"> <?php echo $this->l('This product is missing'); ?> :<br/> <?php echo realpath(_PS_DOWNLOAD_DIR_) . '/' . $productDownload->physically_filename; ?> </p> <?php } ?> <p><?php echo $this->l('Your server\'s maximum upload file size is') . ': ' . ini_get('upload_max_filesize'); ?> </p> <?php if (!strval(Tools::getValue('virtual_product_filename'))) { ?> <label id="virtual_product_file_label" for="virtual_product_file" class="t"><?php echo $this->l('Upload a file'); ?> </label> <input type="file" id="virtual_product_file" name="virtual_product_file" value="" class="" onchange="uploadFile()" maxlength="<?php echo $this->maxFileSize; ?> " /> <?php } ?> <div id="upload-confirmation"> <?php if ($up_filename = strval(Tools::getValue('virtual_product_filename'))) { ?> <input type="hidden" id="virtual_product_filename" name="virtual_product_filename" value="<?php echo $up_filename; ?> " /> <?php } ?> </div> <?php } else { ?> <input type="hidden" id="virtual_product_filename" name="virtual_product_filename" value="<?php echo $productDownload->physically_filename; ?> " /> <?php echo $this->l('This is the link') . ': ' . $productDownload->getHtmlLink(false, true); ?> <a href="confirm.php?height=200&width=300&modal=true&referer=<?php echo rawurlencode($_SERVER['REQUEST_URI'] . '&deleteVirtualProduct=true'); ?> " class="thickbox red" title="<?php echo $this->l('Delete this file'); ?> "><?php echo $this->l('Delete this file'); ?> </a> <?php } // check if file exists ?> </p> <p class="block"> <label for="virtual_product_name" class="t"><?php echo $this->l('Filename'); ?> </label> <input type="text" id="virtual_product_name" name="virtual_product_name" class="" value="<?php echo $productDownload->id > 0 ? $productDownload->display_filename : htmlentities(Tools::getValue('virtual_product_name'), ENT_COMPAT, 'UTF-8'); ?> " /> <span class="hint" name="help_box" style="display:none;"><?php echo $this->l('The complete filename with its extension (e.g., Our best song.mp3)'); ?> </span> </p> <p class="block"> <label for="virtual_product_nb_downloable" class="t"><?php echo $this->l('Number of downloads'); ?> </label> <input type="text" id="virtual_product_nb_downloable" name="virtual_product_nb_downloable" value="<?php echo $productDownload->id > 0 ? $productDownload->nb_downloadable : htmlentities(Tools::getValue('virtual_product_nb_downloable'), ENT_COMPAT, 'UTF-8'); ?> " class="" size="6" /> <span class="hint" name="help_box" style="display:none"><?php echo $this->l('Number of authorized downloads per customer'); ?> </span> </p> <p class="block"> <label for="virtual_product_expiration_date" class="t"><?php echo $this->l('Expiration date'); ?> </label> <input type="text" id="virtual_product_expiration_date" name="virtual_product_expiration_date" value="<?php echo $productDownload->id > 0 ? (!empty($productDownload->date_expiration) and $productDownload->date_expiration != '0000-00-00 00:00:00') ? date('Y-m-d', strtotime($productDownload->date_expiration)) : '' : htmlentities(Tools::getValue('virtual_product_expiration_date'), ENT_COMPAT, 'UTF-8'); ?> " size="11" maxlength="10" autocomplete="off" /> <?php echo $this->l('Format: YYYY-MM-DD'); ?> <span class="hint" name="help_box" style="display:none"><?php echo $this->l('No expiration date if you leave this blank'); ?> </span> </p> <p class="block"> <label for="virtual_product_nb_days" class="t"><?php echo $this->l('Number of days'); ?> </label> <input type="text" id="virtual_product_nb_days" name="virtual_product_nb_days" value="<?php echo $productDownload->id > 0 ? $productDownload->nb_days_accessible : htmlentities(Tools::getValue('virtual_product_nb_days'), ENT_COMPAT, 'UTF-8'); ?> " class="" size="4" /><sup> *</sup> <span class="hint" name="help_box" style="display:none"><?php echo $this->l('How many days this file can be accessed by customers'); ?> </span> </p> <?php } // check if download directory is writable ?> </div> </td> </tr> <tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:730px;"></td></tr> <script type="text/javascript"> if ($('#is_virtual_good').attr('checked')) $('#virtual_good').show('slow'); </script> <?php echo ' <tr> <td class="col-left">' . $this->l('Pre-tax wholesale price:') . '</td> <td style="padding-bottom:5px;"> ' . ($currency->format == 1 ? $currency->sign . ' ' : '') . '<input size="11" maxlength="14" name="wholesale_price" type="text" value="' . htmlentities($this->getFieldValue($obj, 'wholesale_price'), ENT_COMPAT, 'UTF-8') . '" onKeyUp="javascript:this.value = this.value.replace(/,/g, \'.\');" />' . ($currency->format == 2 ? ' ' . $currency->sign : '') . ' <span style="margin-left:10px">' . $this->l('The wholesale price at which you bought this product') . '</span> </td> </tr>'; echo ' <tr> <td class="col-left">' . $this->l('Pre-tax retail price:') . '</td> <td style="padding-bottom:5px;"> ' . ($currency->format == 1 ? $currency->sign . ' ' : '') . '<input size="11" maxlength="14" id="priceTE" name="price" type="text" value="' . $this->getFieldValue($obj, 'price') . '" onKeyUp="javascript:this.value = this.value.replace(/,/g, \'.\'); calcPriceTI();" />' . ($currency->format == 2 ? ' ' . $currency->sign : '') . '<sup> *</sup> <span style="margin-left:2px">' . $this->l('The pre-tax retail price to sell this product') . '</span> </td> </tr>'; $taxes = Tax::getTaxes(intval($cookie->id_lang)); echo '<script type="text/javascript">'; echo 'noTax = ' . (Tax::excludeTaxeOption() ? 'true' : 'false'), ";\n"; echo 'taxesArray = new Array ();' . "\n"; echo 'taxesArray[0] = 0', ";\n"; foreach ($taxes as $k => $tax) { echo 'taxesArray[' . $tax['id_tax'] . ']=' . $tax['rate'] . "\n"; } echo ' </script>'; echo ' <tr> <td class="col-left">' . $this->l('Tax:') . '</td> <td style="padding-bottom:5px;"> <select onChange="javascript:calcPriceTI();" name="id_tax" id="id_tax" ' . (Tax::excludeTaxeOption() ? 'disabled="disabled"' : '') . '> <option value="0"' . ($this->getFieldValue($obj, 'id_tax') == 0 ? ' selected="selected"' : '') . '>' . $this->l('No tax') . '</option>'; foreach ($taxes as $k => $tax) { echo ' <option value="' . $tax['id_tax'] . '"' . ($this->getFieldValue($obj, 'id_tax') == $tax['id_tax'] ? ' selected="selected"' : '') . '>' . stripslashes($tax['name']) . ' (' . $tax['rate'] . '%)</option>'; } echo ' </select>'; if (Tax::excludeTaxeOption()) { echo '<span style="margin-left:10px; color:red;">' . $this->l('Taxes are currently disabled') . '</span> (<b><a href="index.php?tab=AdminTaxes&token=' . Tools::getAdminToken('AdminTaxes' . intval(Tab::getIdFromClassName('AdminTaxes')) . intval($cookie->id_employee)) . '">' . $this->l('Tax options') . '</a></b>)'; echo '<input type="hidden" value="' . intval($this->getFieldValue($obj, 'id_tax')) . '" name="id_tax" />'; } echo '</td> </tr> <tr> <td class="col-left">' . $this->l('Retail price with tax:') . '</td> <td style="padding-bottom:5px;"> ' . ($currency->format == 1 ? ' ' . $currency->sign : '') . ' <input size="11" maxlength="14" id="priceTI" type="text" value="" onKeyUp="noComma(\'priceTI\'); calcPriceTE();" />' . ($currency->format == 2 ? ' ' . $currency->sign : '') . ' <span style="margin-left:10px"> </td> </tr> <tr> <td class="col-left">' . $this->l('Eco-tax:') . '</td> <td style="padding-bottom:5px;"> ' . ($currency->format == 1 ? $currency->sign . ' ' : '') . '<input size="11" maxlength="14" id="ecotax" name="ecotax" type="text" value="' . $this->getFieldValue($obj, 'ecotax') . '" onKeyUp="javascript:this.value = this.value.replace(/,/g, \'.\'); if (parseInt(this.value) > getE(\'priceTE\').value) this.value = getE(\'priceTE\').value; if (isNaN(this.value)) this.value = 0;" />' . ($currency->format == 2 ? ' ' . $currency->sign : '') . ' <span style="margin-left:10px">(' . $this->l('already included in price') . ')</span> </td> </tr> <tr> <td class="col-left">' . $this->l('Reduction amount:') . '</td> <td style="padding-bottom:5px;"> ' . ($currency->format == 1 ? ' ' . $currency->sign . ' ' : '') . '<input size="11" maxlength="14" type="text" name="reduction_price" id="reduction_price" value="' . $this->getFieldValue($obj, 'reduction_price') . '" onkeyup="javascript:this.value = this.value.replace(/,/g, \'.\'); var key = window.event ? window.event.keyCode : event.which; if (key != 9) reductionPrice();" /> ' . ($currency->format == 2 ? ' ' . $currency->sign : '') . ' <span style="padding-right: 15px; padding-left: 15px; font-weight: bold">' . $this->l('OR') . '</span> <input size="10" maxlength="14" type="text" name="reduction_percent" id="reduction_percent" value="' . $this->getFieldValue($obj, 'reduction_percent') . '" onkeyup="javascript:this.value = this.value.replace(/,/g, \'.\'); var key = window.event ? window.event.keyCode : event.which; if (key != 9) reductionPercent();" /> % </td> </tr> <tr> <td class="col-left"> </td> <td>' . $this->l('available from') . ' <input type="text" id="reduction_from" name="reduction_from" value="' . (($from = $this->getFieldValue($obj, 'reduction_from') and $from != '0000-00-00' and $from != '1942-01-01') ? $from : date('Y-m-d')) . '" /> ' . $this->l('to') . ' <input type="text" id="reduction_to" name="reduction_to" value="' . (($to = $this->getFieldValue($obj, 'reduction_to') and $to != '0000-00-00' and $to != '1942-01-01') ? $to : date('Y-m-d')) . '" /> <p>' . $this->l('Leave same dates for undefined duration') . '</p> </td> </tr> <tr> <td class="col-left"> </td> <td style="padding-bottom:5px;"> <input type="checkbox" name="on_sale" id="on_sale" style="padding-top: 5px;" ' . ($this->getFieldValue($obj, 'on_sale') ? 'checked="checked"' : '') . 'value="1" /> <label for="on_sale" class="t">' . $this->l('Display "on sale" icon on product page and text on product listing') . '</label> </td> </tr> <tr> <td class="col-left"><b>' . $this->l('Final retail price:') . '</b></td> <td style="padding-bottom:5px;"> ' . ($currency->format == 1 ? $currency->sign . ' ' : '') . '<span id="finalPrice" style="font-weight: bold;"></span>' . ($currency->format == 2 ? ' ' . $currency->sign : '') . ' </td> </tr> <tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:730px;"></td></tr> <tr> <td class="col-left">' . $this->l('Quantity:') . '</td> <td style="padding-bottom:5px;"><input size="3" maxlength="6" ' . $qty_state . ' name="quantity" type="text" value="' . $qty . '" ' . ((isset($_POST['attQty']) and $_POST['attQty']) ? 'onclick="alert(\'' . $this->l('Quantity is already defined by Attributes') . '.<br />' . $this->l('Delete attributes first') . '.\');" readonly="readonly" ' : '') . '/><sup> *</sup> </tr> <tr> <td class="col-left">' . $this->l('Displayed text when in-stock:') . '</td> <td style="padding-bottom:5px;">'; foreach ($languages as $language) { echo ' <div id="cavailable_now_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left;"> <input size="30" type="text" id="available_now_' . $language['id_lang'] . '" name="available_now_' . $language['id_lang'] . '" value="' . stripslashes(htmlentities($this->getFieldValue($obj, 'available_now', $language['id_lang']), ENT_COMPAT, 'UTF-8')) . '" /> <span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' <>;=#{}<span class="hint-pointer"> </span></span> </div>'; } $this->displayFlags($languages, $defaultLanguage, $divLangName, 'cavailable_now'); echo ' </td> </tr> <tr> <td class="col-left">' . $this->l('Displayed text when allowed to be back-ordered:') . '</td> <td style="padding-bottom:5px;">'; foreach ($languages as $language) { echo ' <div id="cavailable_later_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left;"> <input size="30" type="text" id="available_later_' . $language['id_lang'] . '" name="available_later_' . $language['id_lang'] . '" value="' . stripslashes(htmlentities($this->getFieldValue($obj, 'available_later', $language['id_lang']), ENT_COMPAT, 'UTF-8')) . '" /> <span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' <>;=#{}<span class="hint-pointer"> </span></span> </div>'; } $this->displayFlags($languages, $defaultLanguage, $divLangName, 'cavailable_later'); echo ' </td> </tr> <script type="text/javascript" src="../js/price.js"></script> <script type="text/javascript"> calcPriceTI(); </script> <tr> <td class="col-left">' . $this->l('When out of stock:') . '</td> <td style="padding-bottom:5px;"> <input type="radio" name="out_of_stock" id="out_of_stock_1" value="0" ' . (intval($this->getFieldValue($obj, 'out_of_stock')) == 0 ? 'checked="checked"' : '') . '/> <label for="out_of_stock_1" class="t" id="label_out_of_stock_1">' . $this->l('Deny orders') . '</label> <br /><input type="radio" name="out_of_stock" id="out_of_stock_2" value="1" ' . ($this->getFieldValue($obj, 'out_of_stock') == 1 ? 'checked="checked"' : '') . '/> <label for="out_of_stock_2" class="t" id="label_out_of_stock_2">' . $this->l('Allow orders') . '</label> <br /><input type="radio" name="out_of_stock" id="out_of_stock_3" value="2" ' . ($this->getFieldValue($obj, 'out_of_stock') == 2 ? 'checked="checked"' : '') . '/> <label for="out_of_stock_3" class="t" id="label_out_of_stock_3">' . $this->l('Default:') . ' <i>' . $this->l(intval(Configuration::get('PS_ORDER_OUT_OF_STOCK')) ? 'Allow orders' : 'Deny orders') . '</i> (' . $this->l('as set in') . ' <a href="index.php?tab=AdminPPreferences&token=' . Tools::getAdminToken('AdminPPreferences' . intval(Tab::getIdFromClassName('AdminPPreferences')) . intval($cookie->id_employee)) . '" onclick="return confirm(\'' . $this->l('Are you sure you want to delete entered product information?', __CLASS__, true, false) . '\');">' . $this->l('Preferences') . '</a>)</label> </td> </tr> <tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:730px;"></td></tr> <tr> <td class="col-left"><label for="id_category_default" class="t">' . $this->l('Default category:') . '</label></td> <td> <select id="id_category_default" name="id_category_default" onchange="checkDefaultCategory(this.value);">'; $categories = Category::getCategories(intval($cookie->id_lang), false); Category::recurseCategory($categories, $categories[0][1], 1, $this->getFieldValue($obj, 'id_category_default') ? $this->getFieldValue($obj, 'id_category_default') : Tools::getValue('id_category', 1)); echo ' </select> </td> </tr> <tr> <td class="col-left">' . $this->l('Catalog:') . '</td> <td> <div style="overflow: auto; min-height: 300px; padding-top: 0.6em;" id="categoryList"> <table cellspacing="0" cellpadding="0" class="table"> <tr> <th><input type="checkbox" name="checkme" class="noborder" onclick="checkDelBoxes(this.form, \'categoryBox[]\', this.checked)" /></th> <th>' . $this->l('ID') . '</th> <th style="width: 400px">' . $this->l('Name') . '</th> </tr>'; $done = array(); $index = array(); $indexedCategories = isset($_POST['categoryBox']) ? $_POST['categoryBox'] : ($obj->id ? Product::getIndexedCategories($obj->id) : array()); foreach ($indexedCategories as $k => $row) { $index[] = $row['id_category']; } $this->recurseCategoryForInclude($index, $categories, $categories[0][1], 1, $obj->id_category_default); echo ' </table> <p style="padding:0px; margin:0px 0px 10px 0px;">' . $this->l('Mark all checkbox(es) of categories in which product is to appear') . '<sup> *</sup></p> </div> </td> </tr> <tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:730px;"></td></tr> <tr><td colspan="2"> <span onclick="javascript:openCloseLayer(\'seo\');" style="cursor: pointer"><img src="../img/admin/arrow.gif" alt="' . $this->l('SEO') . '" title="' . $this->l('SEO') . '" style="float:left; margin-right:5px;"/>' . $this->l('Click here to improve product\'s rank in search engines (SEO)') . '</span><br /> <div id="seo" style="display: none; padding-top: 15px;"> <table> <tr> <td class="col-left">' . $this->l('Meta title:') . '</td> <td>'; foreach ($languages as $language) { echo ' <div id="cmeta_title_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left;"> <input size="55" type="text" id="meta_title_' . $language['id_lang'] . '" name="meta_title_' . $language['id_lang'] . '" value="' . htmlentities($this->getFieldValue($obj, 'meta_title', $language['id_lang']), ENT_COMPAT, 'UTF-8') . '" /> <span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' <>;=#{}<span class="hint-pointer"> </span></span> </div>'; } $this->displayFlags($languages, $defaultLanguage, $divLangName, 'cmeta_title'); echo ' <p style="clear: both">' . $this->l('Product page title; leave blank to use product name') . '</p> </td> </tr> <tr> <td class="col-left">' . $this->l('Meta description:') . '</td> <td>'; foreach ($languages as $language) { echo ' <div id="cmeta_description_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left;"> <input size="55" type="text" id="meta_description_' . $language['id_lang'] . '" name="meta_description_' . $language['id_lang'] . '" value="' . htmlentities($this->getFieldValue($obj, 'meta_description', $language['id_lang']), ENT_COMPAT, 'UTF-8') . '" /> <span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' <>;=#{}<span class="hint-pointer"> </span></span> </div>'; } $this->displayFlags($languages, $defaultLanguage, $divLangName, 'cmeta_description'); echo ' <p style="clear: both">' . $this->l('A single sentence for HTML header') . '</p> </td> </tr> <tr> <td class="col-left">' . $this->l('Meta keywords:') . '</td> <td>'; foreach ($languages as $language) { echo ' <div id="cmeta_keywords_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left;"> <input size="55" type="text" id="meta_keywords_' . $language['id_lang'] . '" name="meta_keywords_' . $language['id_lang'] . '" value="' . htmlentities($this->getFieldValue($obj, 'meta_keywords', $language['id_lang']), ENT_COMPAT, 'UTF-8') . '" /> <span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' <>;=#{}<span class="hint-pointer"> </span></span> </div>'; } $this->displayFlags($languages, $defaultLanguage, $divLangName, 'cmeta_keywords'); echo ' <p style="clear: both">' . $this->l('Keywords for HTML header, separated by a comma') . '</p> </td> </tr> <tr> <td class="col-left">' . $this->l('Friendly URL:') . '</td> <td>'; foreach ($languages as $language) { echo ' <div id="clink_rewrite_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left;"> <input size="55" type="text" id="link_rewrite_' . $language['id_lang'] . '" name="link_rewrite_' . $language['id_lang'] . '" value="' . htmlentities($this->getFieldValue($obj, 'link_rewrite', $language['id_lang']), ENT_COMPAT, 'UTF-8') . '" onkeyup="this.value = str2url(this.value); updateFriendlyURL();" /><sup> *</sup> <span class="hint" name="help_box">' . $this->l('Only letters and the "less" character are allowed') . '<span class="hint-pointer"> </span></span> </div>'; } $this->displayFlags($languages, $defaultLanguage, $divLangName, 'clink_rewrite'); global $cookie; $iso = Language::getIsoById(intval($cookie->id_lang)); echo ' <p style="clear: both; width: 360px; word-wrap: break-word; overflow: auto;">' . $this->l('Product link will look like this:') . ' ' . (Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://') . $_SERVER['SERVER_NAME'] . '/id_product-<span id="friendly-url"></span>.html</p> </td> </tr> <script type="text/javascript">updateFriendlyURL();</script>'; echo '</td></tr></table> </div> </td></tr> <tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:730px;"></td></tr> <tr> <td class="col-left">' . $this->l('Short description:') . '<br /><br /><i>(' . $this->l('appears in search results') . ')</i></td> <td style="padding-bottom:5px;">'; foreach ($languages as $language) { echo ' <div id="cdesc_short_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . ';float: left;"> <textarea class="rte" cols="100" rows="10" id="description_short_' . $language['id_lang'] . '" name="description_short_' . $language['id_lang'] . '">' . htmlentities(stripslashes($this->getFieldValue($obj, 'description_short', $language['id_lang'])), ENT_COMPAT, 'UTF-8') . '</textarea> </div>'; } $this->displayFlags($languages, $defaultLanguage, $divLangName, 'cdesc_short'); echo ' </td> </tr> <tr> <td class="col-left">' . $this->l('Description:') . '</td> <td style="padding-bottom:5px;">'; foreach ($languages as $language) { echo ' <div id="cdesc_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . ';float: left;"> <textarea class="rte" cols="100" rows="20" id="description_' . $language['id_lang'] . '" name="description_' . $language['id_lang'] . '">' . htmlentities(stripslashes($this->getFieldValue($obj, 'description', $language['id_lang'])), ENT_COMPAT, 'UTF-8') . '</textarea> </div>'; } $this->displayFlags($languages, $defaultLanguage, $divLangName, 'cdesc'); echo ' </td> </tr>'; echo '<tr><td class="col-left">' . $this->l('Tags:') . '</td><td style="padding-bottom:5px;">'; foreach ($languages as $language) { echo '<div id="ctags_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left;"> <input size="55" type="text" id="tags_' . $language['id_lang'] . '" name="tags_' . $language['id_lang'] . '" value="' . htmlentities(Tools::getValue('tags_' . $language['id_lang'], $obj->getTags($language['id_lang'], true)), ENT_COMPAT, 'UTF-8') . '" /> <span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' !<>;?=+#"°{}_$%<span class="hint-pointer"> </span></span> </div>'; } $this->displayFlags($languages, $defaultLanguage, $divLangName, 'ctags'); echo '<p style="clear: both">' . $this->l('Tags separated by commas (e.g., dvd, dvd player, hifi)') . '</p>'; echo '</td> </tr>'; $accessories = Product::getAccessoriesLight(intval($cookie->id_lang), $obj->id); if ($postAccessories = Tools::getValue('inputAccessories')) { $postAccessoriesTab = explode('-', Tools::getValue('inputAccessories')); foreach ($postAccessoriesTab as $accessoryId) { if (!$this->haveThisAccessory($accessoryId, $accessories) and $accessory = Product::getAccessoryById($accessoryId)) { $accessories[] = $accessory; } } } echo ' <tr> <td class="col-left">' . $this->l('Accessories:') . '<br /><br /><i>' . $this->l('(Do not forget to Save the product afterward)') . '</i></td> <td style="padding-bottom:5px;"> <div id="divAccessories">'; foreach ($accessories as $accessory) { echo $accessory['name'] . '<span onclick="delAccessory(' . $accessory['id_product'] . ');" style="cursor: pointer;"><img src="../img/admin/delete.gif" /></span><br />'; } echo '</div> <input type="hidden" name="inputAccessories" id="inputAccessories" value="'; foreach ($accessories as $accessory) { echo $accessory['id_product'] . '-'; } echo '" /> <input type="hidden" name="nameAccessories" id="nameAccessories" value="'; foreach ($accessories as $accessory) { echo $accessory['name'] . '¤'; } echo '" /> <script type="text/javascript"> var formProduct; var accessories = new Array(); function fillAccessories() { $.getJSON("' . dirname($currentIndex) . '/ajax.php",{ajaxProductAccessories:1,id_lang:' . intval($cookie->id_lang) . ',id_product:' . ($obj->id ? intval($obj->id) : 0) . '}, function(j) { for (var i = 0; i < j.length; i++) accessories[i] = new Array(j[i].value, j[i].text); formProduct = document.layers ? document.forms.product : document.product; formProduct.selectAccessories.length = accessories.length + 1; for (i = 0, j = 1; i < accessories.length; i++) { if (formProduct.filter.value) if (accessories[i][1].toLowerCase().indexOf(formProduct.filter.value.toLowerCase()) == -1) continue; formProduct.selectAccessories.options[j].value = accessories[i][0]; formProduct.selectAccessories.options[j].text = accessories[i][1]; j++; } if (j == 1) { formProduct.selectAccessories.length = 2; formProduct.selectAccessories.options[1].value = -1; formProduct.selectAccessories.options[1].text = \'' . $this->l('No match found') . '\'; formProduct.selectAccessories.options.selectedIndex = 1; } else { formProduct.selectAccessories.length = j; formProduct.selectAccessories.options.selectedIndex = (formProduct.filter.value == \'\' ? 0 : 1); } } ); } </script> <select id="selectAccessories" name="selectAccessories" style="width: 380px;"> <option value="0" selected="selected">-- ' . $this->l('Choose') . ' --</option> </select> <script type="text/javascript"> fillAccessories(); </script> <span onclick="addAccessory();" style="cursor: pointer;"><img src="../img/admin/add.gif" alt="' . $this->l('Add an accessory') . '" title="' . $this->l('Add an accessory') . '" /></span> <br />' . $this->l('Filter:') . ' <input type="text" size="25" name="filter" onkeyup="fillAccessories();" class="space" /> </td> </tr> <tr><td colspan="2" style="padding-bottom:10px;"><hr style="width:730px;"></td></tr> <tr> <td colspan="2" style="text-align:center;"> <input type="submit" value="' . $this->l('Save') . '" name="submitAdd' . $this->table . '" class="button" /> <input type="submit" value="' . $this->l('Save and stay') . '" name="submitAdd' . $this->table . 'AndStay" class="button" /></td> </tr> </table> </div> <script type="text/javascript" src="' . __PS_BASE_URI__ . 'js/tinymce/jscripts/tiny_mce/jquery.tinymce.js"></script> <script type="text/javascript"> function tinyMCEInit(element) { $().ready(function() { $(element).tinymce({ // Location of TinyMCE script script_url : \'' . __PS_BASE_URI__ . 'js/tinymce/jscripts/tiny_mce/tiny_mce.js\', // General options theme : "advanced", plugins : "safari,pagebreak,style,layer,table,advimage,advlink,inlinepopups,media,searchreplace,contextmenu,paste,directionality,fullscreen", // Theme options theme_advanced_buttons1 : "newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect", theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,,|,forecolor,backcolor", theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,media,|,ltr,rtl,|,fullscreen", theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,pagebreak", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", width : "100", theme_advanced_statusbar_location : "bottom", theme_advanced_resizing : true, content_css : "' . __PS_BASE_URI__ . 'themes/' . _THEME_NAME_ . '/css/global.css", // Drop lists for link/image/media/template dialogs template_external_list_url : "lists/template_list.js", external_link_list_url : "lists/link_list.js", external_image_list_url : "lists/image_list.js", media_external_list_url : "lists/media_list.js", elements : "nourlconvert", convert_urls : false, language : "' . (file_exists(_PS_ROOT_DIR_ . '/js/tinymce/jscripts/tiny_mce/langs/' . $iso . '.js') ? $iso : 'en') . '" }); }); } tinyMCEInit(\'textarea.rte\'); toggleVirtualProduct(getE(\'is_virtual_good\')); </script> '; }
/** * Create a link to a product * * @param mixed $product Product object (can be an ID product, but deprecated) * @param string $alias * @param string $category * @param string $ean13 * @param int $id_lang * @param int $id_shop (since 1.5.0) ID shop need to be used when we generate a product link for a product in a cart * @param int $ipa ID product attribute * @return string */ public function getProductLink($product, $alias = null, $category = null, $ean13 = null, $id_lang = null, $id_shop = null, $ipa = 0, $force_routes = false, $relative_protocol = false) { $dispatcher = Dispatcher::getInstance(); if (!$id_lang) { $id_lang = Context::getContext()->language->id; } $url = $this->getBaseLink($id_shop, null, $relative_protocol) . $this->getLangLink($id_lang, null, $id_shop); if (!is_object($product)) { if (is_array($product) && isset($product['id_product'])) { $product = new Product($product['id_product'], false, $id_lang, $id_shop); } elseif ((int) $product) { $product = new Product((int) $product, false, $id_lang, $id_shop); } else { throw new PrestaShopException('Invalid product vars'); } } // Set available keywords $params = array(); $params['id'] = $product->id; $params['rewrite'] = !$alias ? $product->getFieldByLang('link_rewrite') : $alias; $params['ean13'] = !$ean13 ? $product->ean13 : $ean13; $params['meta_keywords'] = Tools::str2url($product->getFieldByLang('meta_keywords')); $params['meta_title'] = Tools::str2url($product->getFieldByLang('meta_title')); if ($dispatcher->hasKeyword('product_rule', $id_lang, 'manufacturer', $id_shop)) { $params['manufacturer'] = Tools::str2url($product->isFullyLoaded ? $product->manufacturer_name : Manufacturer::getNameById($product->id_manufacturer)); } if ($dispatcher->hasKeyword('product_rule', $id_lang, 'supplier', $id_shop)) { $params['supplier'] = Tools::str2url($product->isFullyLoaded ? $product->supplier_name : Supplier::getNameById($product->id_supplier)); } if ($dispatcher->hasKeyword('product_rule', $id_lang, 'price', $id_shop)) { $params['price'] = $product->isFullyLoaded ? $product->price : Product::getPriceStatic($product->id, false, null, 6, null, false, true, 1, false, null, null, null, $product->specificPrice); } if ($dispatcher->hasKeyword('product_rule', $id_lang, 'tags', $id_shop)) { $params['tags'] = Tools::str2url($product->getTags($id_lang)); } if ($dispatcher->hasKeyword('product_rule', $id_lang, 'category', $id_shop)) { $params['category'] = !is_null($product->category) && !empty($product->category) ? Tools::str2url($product->category) : Tools::str2url($category); } if ($dispatcher->hasKeyword('product_rule', $id_lang, 'reference', $id_shop)) { $params['reference'] = Tools::str2url($product->reference); } if ($dispatcher->hasKeyword('product_rule', $id_lang, 'categories', $id_shop)) { $params['category'] = !$category ? $product->category : $category; $cats = array(); foreach ($product->getParentCategories() as $cat) { if (!in_array($cat['id_category'], Link::$category_disable_rewrite)) { //remove root and home category from the URL $cats[] = $cat['link_rewrite']; } } $params['categories'] = implode('/', $cats); } $anchor = $ipa ? $product->getAnchor($ipa) : ''; return $url . $dispatcher->createUrl('product_rule', $id_lang, $params, $force_routes, $anchor, $id_shop); }
/** * @param \Product $product * * @return mixed * @throws \Exception * @author Panagiotis Vagenas <*****@*****.**> * @since 150213 */ protected function getProductManufacturer(\Product &$product) { $option = $this->Options->getValue('map_manufacturer'); return $option == 0 ? $product->getWsManufacturerName() : \Supplier::getNameById($product->id_supplier); }
protected function supplyOrdersImportOne($info, $force_ids, $current_line, $validateOnly = false) { // sets default values if needed AdminImportController::setDefaultValues($info); // if an id is set, instanciates a supply order with this id if possible if (array_key_exists('id', $info) && (int) $info['id'] && SupplyOrder::exists((int) $info['id'])) { $supply_order = new SupplyOrder((int) $info['id']); } elseif (array_key_exists('reference', $info) && $info['reference'] && SupplyOrder::exists(pSQL($info['reference']))) { $supply_order = SupplyOrder::getSupplyOrderByReference(pSQL($info['reference'])); } else { // new supply order $supply_order = new SupplyOrder(); } // gets parameters $id_supplier = (int) $info['id_supplier']; $id_lang = (int) $info['id_lang']; $id_warehouse = (int) $info['id_warehouse']; $id_currency = (int) $info['id_currency']; $reference = pSQL($info['reference']); $date_delivery_expected = pSQL($info['date_delivery_expected']); $discount_rate = (double) $info['discount_rate']; $is_template = (bool) $info['is_template']; $error = ''; // checks parameters if (!Supplier::supplierExists($id_supplier)) { $error = sprintf($this->l('Supplier ID (%d) is not valid (at line %d).'), $id_supplier, $current_line + 1); } if (!Language::getLanguage($id_lang)) { $error = sprintf($this->l('Lang ID (%d) is not valid (at line %d).'), $id_lang, $current_line + 1); } if (!Warehouse::exists($id_warehouse)) { $error = sprintf($this->l('Warehouse ID (%d) is not valid (at line %d).'), $id_warehouse, $current_line + 1); } if (!Currency::getCurrency($id_currency)) { $error = sprintf($this->l('Currency ID (%d) is not valid (at line %d).'), $id_currency, $current_line + 1); } if (empty($supply_order->reference) && SupplyOrder::exists($reference)) { $error = sprintf($this->l('Reference (%s) already exists (at line %d).'), $reference, $current_line + 1); } if (!empty($supply_order->reference) && ($supply_order->reference != $reference && SupplyOrder::exists($reference))) { $error = sprintf($this->l('Reference (%s) already exists (at line %d).'), $reference, $current_line + 1); } if (!Validate::isDateFormat($date_delivery_expected)) { $error = sprintf($this->l('Date format (%s) is not valid (at line %d). It should be: %s.'), $date_delivery_expected, $current_line + 1, $this->l('YYYY-MM-DD')); } elseif (new DateTime($date_delivery_expected) <= new DateTime('yesterday')) { $error = sprintf($this->l('Date (%s) cannot be in the past (at line %d). Format: %s.'), $date_delivery_expected, $current_line + 1, $this->l('YYYY-MM-DD')); } if ($discount_rate < 0 || $discount_rate > 100) { $error = sprintf($this->l('Discount rate (%d) is not valid (at line %d). %s.'), $discount_rate, $current_line + 1, $this->l('Format: Between 0 and 100')); } if ($supply_order->id > 0 && !$supply_order->isEditable()) { $error = sprintf($this->l('Supply Order (%d) is not editable (at line %d).'), $supply_order->id, $current_line + 1); } // if no errors, sets supply order if (empty($error)) { // adds parameters $info['id_ref_currency'] = (int) Currency::getDefaultCurrency()->id; $info['supplier_name'] = pSQL(Supplier::getNameById($id_supplier)); if ($supply_order->id > 0) { $info['id_supply_order_state'] = (int) $supply_order->id_supply_order_state; $info['id'] = (int) $supply_order->id; } else { $info['id_supply_order_state'] = 1; } // sets parameters AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $supply_order); // updatesd($supply_order); $res = false; if ((int) $supply_order->id && ($supply_order->exists((int) $supply_order->id) || $supply_order->exists($supply_order->reference))) { $res = $validateOnly || $supply_order->update(); } else { $supply_order->force_id = (bool) $force_ids; $res = $validateOnly || $supply_order->add(); } // errors if (!$res) { $this->errors[] = sprintf($this->l('Supply Order could not be saved (at line %d).'), $current_line + 1); } } else { $this->errors[] = $error; } }
public function __construct($id_product = NULL, $full = false, $id_lang = NULL) { global $cart; parent::__construct($id_product, $id_lang); if ($full and $this->id) { $this->tax_name = 'deprecated'; // The applicable tax may be BOTH the product one AND the state one (moreover this variable is some deadcode) $this->manufacturer_name = Manufacturer::getNameById((int) $this->id_manufacturer); $this->supplier_name = Supplier::getNameById((int) $this->id_supplier); self::$_tax_rules_group[$this->id] = $this->id_tax_rules_group; if (is_object($cart) and $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')} != NULL) { $this->tax_rate = Tax::getProductTaxRate($this->id, $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}); } else { $this->tax_rate = Tax::getProductTaxRate($this->id, NULL); } $this->new = $this->isNew(); $this->price = Product::getPriceStatic((int) $this->id, false, NULL, 6, NULL, false, true, 1, false, NULL, NULL, NULL, $this->specificPrice); $this->unit_price = $this->unit_price_ratio != 0 ? $this->price / $this->unit_price_ratio : 0; if ($this->id) { $this->tags = Tag::getProductTags((int) $this->id); } } if ($this->id_category_default) { $this->category = Category::getLinkRewrite((int) $this->id_category_default, (int) $id_lang); } }
public function __construct($id_product = NULL, $full = false, $id_lang = NULL, $from_cache = TRUE) { global $cart; parent::__construct($id_product, $id_lang, $from_cache); if ($full and $this->id) { $this->tax_name = 'deprecated'; // The applicable tax may be BOTH the product one AND the state one (moreover this variable is some deadcode) $this->manufacturer_name = Manufacturer::getNameById((int) $this->id_manufacturer); $this->supplier_name = Supplier::getNameById((int) $this->id_supplier); self::$_tax_rules_group[$this->id] = $this->id_tax_rules_group; if (is_object($cart) and $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')} != NULL) { $this->tax_rate = Tax::getProductTaxRate($this->id, $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}); } else { $this->tax_rate = Tax::getProductTaxRate($this->id, NULL); } $this->new = $this->isNew(); $this->price = Product::getPriceStatic((int) $this->id, false, NULL, 6, NULL, false, true, 1, false, NULL, NULL, NULL, $this->specificPrice); $this->unit_price = $this->unit_price_ratio != 0 ? $this->price / $this->unit_price_ratio : 0; if ($this->id) { $this->tags = Tag::getProductTags((int) $this->id); } $features = $this->getFrontFeatures($id_lang); foreach ($features as $row) { if ($row['id_feature'] == 1) { $this->fabric = $row['value']; } if ($row['id_feature'] == 2) { $this->color = $row['value']; } if ($row['id_feature'] == 3) { $this->garment_type = $row['value']; } if ($row['id_feature'] == 4) { $this->work_type = $row['value']; } if ($row['id_feature'] == 5) { $this->blouse_length = $row['value']; } if ($row['id_feature'] == 6) { $this->wash_care = $row['value']; } if ($row['id_feature'] == 7) { $this->other_info = $row['value']; } if ($row['id_feature'] == 8) { $this->shipping_estimate = $row['value']; $this->shipping_sla = (int) preg_replace('/\\D/', '', $this->shipping_estimate); } if ($row['id_feature'] == 9) { $this->kameez_style = $row['value']; } if ($row['id_feature'] == 10) { $this->salwar_style = $row['value']; } if ($row['id_feature'] == 11) { $this->sleeves = $row['value']; } if ($row['id_feature'] == 12) { $this->generic_color = $row['value']; } if ($row['id_feature'] == 13) { $this->skirt_length = $row['value']; } if ($row['id_feature'] == 14) { $this->dupatta_length = $row['value']; } if ($row['id_feature'] == 15) { $this->stone = $row['value']; } if ($row['id_feature'] == 16) { $this->plating = $row['value']; } if ($row['id_feature'] == 17) { $this->material = $row['value']; } if ($row['id_feature'] == 18) { $this->dimensions = $row['value']; } if ($row['id_feature'] == 19) { $this->look = $row['value']; } if ($row['id_feature'] == 21) { $this->handbag_occasion = $row['value']; } if ($row['id_feature'] == 22) { $this->handbag_style = $row['value']; } if ($row['id_feature'] == 23) { $this->handbag_material = $row['value']; } } } if ($this->id_category_default) { $this->category = Category::getLinkRewrite((int) $this->id_category_default, (int) $id_lang); } }
/** * AdminController::postProcess() override * @see AdminController::postProcess() */ public function postProcess() { $this->is_editing_order = false; // Checks access if (Tools::isSubmit('submitAddsupply_order') && !($this->tabAccess['add'] === '1')) { $this->errors[] = Tools::displayError('You do not have permission to add a supply order.'); } if (Tools::isSubmit('submitBulkUpdatesupply_order_detail') && !($this->tabAccess['edit'] === '1')) { $this->errors[] = Tools::displayError('You do not have permission to edit an order.'); } // Trick to use both Supply Order as template and actual orders if (Tools::isSubmit('is_template')) { $_GET['mod'] = 'template'; } // checks if supply order reference is unique if (Tools::isSubmit('reference')) { // gets the reference $ref = pSQL(Tools::getValue('reference')); if (Tools::getValue('id_supply_order') != 0 && SupplyOrder::getReferenceById((int) Tools::getValue('id_supply_order')) != $ref) { if ((int) SupplyOrder::exists($ref) != 0) { $this->errors[] = Tools::displayError('The reference has to be unique.'); } } elseif (Tools::getValue('id_supply_order') == 0 && (int) SupplyOrder::exists($ref) != 0) { $this->errors[] = Tools::displayError('The reference has to be unique.'); } } if ($this->errors) { return; } // Global checks when add / update a supply order if (Tools::isSubmit('submitAddsupply_order') || Tools::isSubmit('submitAddsupply_orderAndStay')) { $this->action = 'save'; $this->is_editing_order = true; // get supplier ID $id_supplier = (int) Tools::getValue('id_supplier', 0); if ($id_supplier <= 0 || !Supplier::supplierExists($id_supplier)) { $this->errors[] = Tools::displayError('The selected supplier is not valid.'); } // get warehouse id $id_warehouse = (int) Tools::getValue('id_warehouse', 0); if ($id_warehouse <= 0 || !Warehouse::exists($id_warehouse)) { $this->errors[] = Tools::displayError('The selected warehouse is not valid.'); } // get currency id $id_currency = (int) Tools::getValue('id_currency', 0); if ($id_currency <= 0 || (!($result = Currency::getCurrency($id_currency)) || empty($result))) { $this->errors[] = Tools::displayError('The selected currency is not valid.'); } // get delivery date if (Tools::getValue('mod') != 'template' && strtotime(Tools::getValue('date_delivery_expected')) <= strtotime('-1 day')) { $this->errors[] = Tools::displayError('The specified date cannot be in the past.'); } // gets threshold $quantity_threshold = Tools::getValue('load_products'); if (is_numeric($quantity_threshold)) { $quantity_threshold = (int) $quantity_threshold; } else { $quantity_threshold = null; } if (!count($this->errors)) { // forces date for templates if (Tools::isSubmit('is_template') && !Tools::getValue('date_delivery_expected')) { $_POST['date_delivery_expected'] = date('Y-m-d h:i:s'); } // specify initial state $_POST['id_supply_order_state'] = 1; //defaut creation state // specify global reference currency $_POST['id_ref_currency'] = Currency::getDefaultCurrency()->id; // specify supplier name $_POST['supplier_name'] = Supplier::getNameById($id_supplier); //specific discount check $_POST['discount_rate'] = (double) str_replace(array(' ', ','), array('', '.'), Tools::getValue('discount_rate', 0)); } // manage each associated product $this->manageOrderProducts(); // if the threshold is defined and we are saving the order if (Tools::isSubmit('submitAddsupply_order') && Validate::isInt($quantity_threshold)) { $this->loadProducts((int) $quantity_threshold); } } // Manage state change if (Tools::isSubmit('submitChangestate') && Tools::isSubmit('id_supply_order') && Tools::isSubmit('id_supply_order_state')) { if ($this->tabAccess['edit'] != '1') { $this->errors[] = Tools::displayError('You do not have permission to change the order status.'); } // get state ID $id_state = (int) Tools::getValue('id_supply_order_state', 0); if ($id_state <= 0) { $this->errors[] = Tools::displayError('The selected supply order status is not valid.'); } // get supply order ID $id_supply_order = (int) Tools::getValue('id_supply_order', 0); if ($id_supply_order <= 0) { $this->errors[] = Tools::displayError('The supply order ID is not valid.'); } if (!count($this->errors)) { // try to load supply order $supply_order = new SupplyOrder($id_supply_order); if (Validate::isLoadedObject($supply_order)) { // get valid available possible states for this order $states = SupplyOrderState::getSupplyOrderStates($supply_order->id_supply_order_state); foreach ($states as $state) { // if state is valid, change it in the order if ($id_state == $state['id_supply_order_state']) { $new_state = new SupplyOrderState($id_state); $old_state = new SupplyOrderState($supply_order->id_supply_order_state); // special case of validate state - check if there are products in the order and the required state is not an enclosed state if ($supply_order->isEditable() && !$supply_order->hasEntries() && !$new_state->enclosed) { $this->errors[] = Tools::displayError('It is not possible to change the status of this order because you did not order any products.'); } if (!count($this->errors)) { $supply_order->id_supply_order_state = $state['id_supply_order_state']; if ($supply_order->save()) { if ($new_state->pending_receipt) { $supply_order_details = $supply_order->getEntries(); foreach ($supply_order_details as $supply_order_detail) { $is_present = Stock::productIsPresentInStock($supply_order_detail['id_product'], $supply_order_detail['id_product_attribute'], $supply_order->id_warehouse); if (!$is_present) { $stock = new Stock(); $stock_params = array('id_product_attribute' => $supply_order_detail['id_product_attribute'], 'id_product' => $supply_order_detail['id_product'], 'physical_quantity' => 0, 'price_te' => $supply_order_detail['price_te'], 'usable_quantity' => 0, 'id_warehouse' => $supply_order->id_warehouse); // saves stock in warehouse $stock->hydrate($stock_params); $stock->add(); } } } // if pending_receipt, // or if the order is being canceled, // or if the order is received completely // synchronizes StockAvailable if ($new_state->pending_receipt && !$new_state->receipt_state || ($old_state->receipt_state || $old_state->pending_receipt) && $new_state->enclosed && !$new_state->receipt_state || $new_state->receipt_state && $new_state->enclosed) { $supply_order_details = $supply_order->getEntries(); $products_done = array(); foreach ($supply_order_details as $supply_order_detail) { if (!in_array($supply_order_detail['id_product'], $products_done)) { StockAvailable::synchronize($supply_order_detail['id_product']); $products_done[] = $supply_order_detail['id_product']; } } } $token = Tools::getValue('token') ? Tools::getValue('token') : $this->token; $redirect = self::$currentIndex . '&token=' . $token; $this->redirect_after = $redirect . '&conf=5'; } } } } } else { $this->errors[] = Tools::displayError('The selected supplier is not valid.'); } } } // updates receipt if (Tools::isSubmit('submitBulkUpdatesupply_order_detail') && Tools::isSubmit('id_supply_order')) { $this->postProcessUpdateReceipt(); } // use template to create a supply order if (Tools::isSubmit('create_supply_order') && Tools::isSubmit('id_supply_order')) { $this->postProcessCopyFromTemplate(); } if (!count($this->errors) && $this->is_editing_order || !$this->is_editing_order) { parent::postProcess(); } }
function displayFormInformations($obj, $currency) { parent::displayForm(false); global $currentIndex, $cookie, $link; $default_country = new Country((int) Configuration::get('PS_COUNTRY_DEFAULT')); $iso = Language::getIsoById((int) $cookie->id_lang); $has_attribute = false; $qty_state = 'readonly'; $qty = Attribute::getAttributeQty($this->getFieldValue($obj, 'id_product')); if ($qty === false) { if (Validate::isLoadedObject($obj)) { $qty = $this->getFieldValue($obj, 'quantity'); } else { $qty = 1; } $qty_state = ''; } else { $has_attribute = true; } $cover = Product::getCover($obj->id); $this->_applyTaxToEcotax($obj); echo ' <div class="tab-page" id="step1"> <h4 class="tab">1. ' . $this->l('Info.') . '</h4> <script type="text/javascript"> $(document).ready(function() { updateCurrentText(); updateFriendlyURL(); $.ajax({ url: "' . dirname($currentIndex) . '/ajax.php", cache: false, dataType: "json", data: "ajaxProductManufacturers=1", success: function(j) { var options = $("select#id_manufacturer").html(); if (j) for (var i = 0; i < j.length; i++) options += \'<option value="\' + j[i].optionValue + \'">\' + j[i].optionDisplay + \'</option>\'; $("select#id_manufacturer").html(options); }, error: function(XMLHttpRequest, textStatus, errorThrown) { alert(\'Manufacturer ajax error: \'+textStatus); } }); $.ajax({ url: "' . dirname($currentIndex) . '/ajax.php", cache: false, dataType: "json", data: "ajaxProductSuppliers=1", success: function(j) { var options = $("select#id_supplier").html(); if (j) for (var i = 0; i < j.length; i++) options += \'<option value="\' + j[i].optionValue + \'">\' + j[i].optionDisplay + \'</option>\'; $("select#id_supplier").html(options); }, error: function(XMLHttpRequest, textStatus, errorThrown) { alert(\'Supplier ajax error: \'+textStatus); } }); if ($(\'#available_for_order\').is(\':checked\')){ $(\'#show_price\').attr(\'checked\', \'checked\'); $(\'#show_price\').attr(\'disabled\', \'disabled\'); } else { $(\'#show_price\').attr(\'disabled\', \'\'); } }); </script> <b>' . $this->l('Product global information') . '</b> - '; $preview_url = ''; if (isset($obj->id)) { $preview_url = $link->getProductLink($this->getFieldValue($obj, 'id'), $this->getFieldValue($obj, 'link_rewrite', $this->_defaultFormLanguage), Category::getLinkRewrite($this->getFieldValue($obj, 'id_category_default'), (int) $cookie->id_lang)); if (!$obj->active) { $admin_dir = dirname($_SERVER['PHP_SELF']); $admin_dir = substr($admin_dir, strrpos($admin_dir, '/') + 1); $token = Tools::encrypt('PreviewProduct' . $obj->id); $preview_url .= $obj->active ? '' : '&adtoken=' . $token . '&ad=' . $admin_dir; } echo ' <a href="index.php?tab=AdminCatalog&id_product=' . $obj->id . '&deleteproduct&token=' . $this->token . '" style="float:right;" onclick="return confirm(\'' . $this->l('Are you sure?', __CLASS__, true, false) . '\');"> <img src="../img/admin/delete.gif" alt="' . $this->l('Delete this product') . '" title="' . $this->l('Delete this product') . '" /> ' . $this->l('Delete this product') . '</a> <a href="' . $preview_url . '" target="_blank"><img src="../img/admin/details.gif" alt="' . $this->l('View product in shop') . '" title="' . $this->l('View product in shop') . '" /> ' . $this->l('View product in shop') . '</a>'; if (file_exists(_PS_MODULE_DIR_ . 'statsproduct/statsproduct.php')) { echo ' - <a href="index.php?tab=AdminStats&module=statsproduct&id_product=' . $obj->id . '&token=' . Tools::getAdminToken('AdminStats' . (int) Tab::getIdFromClassName('AdminStats') . (int) $cookie->id_employee) . '"><img src="../modules/statsproduct/logo.gif" alt="' . $this->l('View product sales') . '" title="' . $this->l('View product sales') . '" /> ' . $this->l('View product sales') . '</a>'; } } echo ' <hr class="clear"/> <br /> <table cellpadding="5" style="width: 50%; float: left; margin-right: 20px; border-right: 1px solid #E0D0B1;"> <tr> <td class="col-left">' . $this->l('Name:') . '</td> <td style="padding-bottom:5px;" class="translatable">'; foreach ($this->_languages as $language) { echo ' <div class="lang_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . '; float: left;"> <input size="43" type="text" id="name_' . $language['id_lang'] . '" name="name_' . $language['id_lang'] . '" value="' . stripslashes(htmlspecialchars($this->getFieldValue($obj, 'name', $language['id_lang']))) . '"' . (!$obj->id ? ' onkeyup="if (isArrowKey(event)) return; copy2friendlyURL();"' : '') . ' onkeyup="if (isArrowKey(event)) return; updateCurrentText();" onchange="updateCurrentText();" /><sup> *</sup> <span class="hint" name="help_box">' . $this->l('Invalid characters:') . ' <>;=#{}<span class="hint-pointer"> </span></span> </div>'; } echo ' </td> </tr> <tr> <td class="col-left">' . $this->l('Reference:') . '</td> <td style="padding-bottom:5px;"> <input size="55" type="text" name="reference" value="' . htmlentities($this->getFieldValue($obj, 'reference'), ENT_COMPAT, 'UTF-8') . '" style="width: 130px; margin-right: 44px;" /> <span class="hint" name="help_box">' . $this->l('Special characters allowed:') . ' .-_#\\<span class="hint-pointer"> </span></span> </td> </tr> <tr> <td class="col-left">' . $this->l('Supplier Reference:') . '</td> <td style="padding-bottom:5px;"> <input size="55" type="text" name="supplier_reference" value="' . htmlentities($this->getFieldValue($obj, 'supplier_reference'), ENT_COMPAT, 'UTF-8') . '" style="width: 130px; margin-right: 44px;" /> <span class="hint" name="help_box">' . $this->l('Special characters allowed:') . ' .-_#\\<span class="hint-pointer"> </span></span> </td> </tr> <tr> <td class="col-left">' . $this->l('EAN13 or JAN:') . '</td> <td style="padding-bottom:5px;"> <input size="55" maxlength="13" type="text" name="ean13" value="' . htmlentities($this->getFieldValue($obj, 'ean13'), ENT_COMPAT, 'UTF-8') . '" style="width: 130px; margin-right: 5px;" /> <span class="small">' . $this->l('(Europe, Japan)') . '</span> </td> </tr> <tr> <td class="col-left">' . $this->l('UPC:') . '</td> <td style="padding-bottom:5px;"> <input size="55" maxlength="12" type="text" name="upc" value="' . htmlentities($this->getFieldValue($obj, 'upc'), ENT_COMPAT, 'UTF-8') . '" style="width: 130px; margin-right: 5px;" /> <span class="small">' . $this->l('(US, Canada)') . '</span> </td> </tr> <tr> <td class="col-left">' . $this->l('Location (warehouse):') . '</td> <td style="padding-bottom:5px;"> <input size="55" type="text" name="location" value="' . htmlentities($this->getFieldValue($obj, 'location'), ENT_COMPAT, 'UTF-8') . '" style="width: 130px; margin-right: 44px;" /> </td> </tr> <tr> <td class="col-left">' . $this->l('Width ( package ) :') . '</td> <td style="padding-bottom:5px;"> <input size="6" maxlength="6" name="width" type="text" value="' . htmlentities($this->getFieldValue($obj, 'width'), ENT_COMPAT, 'UTF-8') . '" onKeyUp="if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, \'.\');" /> ' . Configuration::get('PS_DIMENSION_UNIT') . ' </td> </tr> <tr> <td class="col-left">' . $this->l('Height ( package ) :') . '</td> <td style="padding-bottom:5px;"> <input size="6" maxlength="6" name="height" type="text" value="' . htmlentities($this->getFieldValue($obj, 'height'), ENT_COMPAT, 'UTF-8') . '" onKeyUp="if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, \'.\');" /> ' . Configuration::get('PS_DIMENSION_UNIT') . ' </td> </tr> <tr> <td class="col-left">' . $this->l('Deep ( package ) :') . '</td> <td style="padding-bottom:5px;"> <input size="6" maxlength="6" name="depth" type="text" value="' . htmlentities($this->getFieldValue($obj, 'depth'), ENT_COMPAT, 'UTF-8') . '" onKeyUp="if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, \'.\');" /> ' . Configuration::get('PS_DIMENSION_UNIT') . ' </td> </tr> <tr> <td class="col-left">' . $this->l('Weight ( package ) :') . '</td> <td style="padding-bottom:5px;"> <input size="6" maxlength="6" name="weight" type="text" value="' . htmlentities($this->getFieldValue($obj, 'weight'), ENT_COMPAT, 'UTF-8') . '" onKeyUp="if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, \'.\');" /> ' . Configuration::get('PS_WEIGHT_UNIT') . ' </td> </tr> </table> <table cellpadding="5" style="width: 40%; float: left; margin-left: 10px;"> <tr> <td style="vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">' . $this->l('Status:') . '</td> <td style="padding-bottom:5px;"> <input style="float:left;" onclick="toggleDraftWarning(false);showOptions(true);" type="radio" name="active" id="active_on" value="1" ' . ($this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '') . '/> <label for="active_on" class="t"><img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" style="float:left; padding:0px 5px 0px 5px;" />' . $this->l('Enabled') . '</label> <br class="clear" /> <input style="float:left;" onclick="toggleDraftWarning(true);showOptions(false);" type="radio" name="active" id="active_off" value="0" ' . (!$this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '') . '/> <label for="active_off" class="t"><img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" style="float:left; padding:0px 5px 0px 5px" />' . $this->l('Disabled') . ($obj->active ? '' : ' (<a href="' . $preview_url . '" alt="" target="_blank">' . $this->l('View product in shop') . '</a>)') . '</label> </td> </tr> <tr id="product_options" ' . (!$obj->active ? 'style="display:none"' : '') . '> <td style="vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">' . $this->l('Options:') . '</td> <td style="padding-bottom:5px;"> <input style="float: left;" type="checkbox" name="available_for_order" id="available_for_order" value="1" ' . ($this->getFieldValue($obj, 'available_for_order') ? 'checked="checked" ' : '') . ' onclick="if ($(this).is(\':checked\')){$(\'#show_price\').attr(\'checked\', \'checked\');$(\'#show_price\').attr(\'disabled\', \'disabled\');}else{$(\'#show_price\').attr(\'disabled\', \'\');}"/> <label for="available_for_order" class="t"><img src="../img/admin/products.gif" alt="' . $this->l('available for order') . '" title="' . $this->l('available for order') . '" style="float:left; padding:0px 5px 0px 5px" />' . $this->l('available for order') . '</label> <br class="clear" /> <input style="float: left;" type="checkbox" name="show_price" id="show_price" value="1" ' . ($this->getFieldValue($obj, 'show_price') ? 'checked="checked" ' : '') . ' /> <label for="show_price" class="t"><img src="../img/admin/gold.gif" alt="' . $this->l('display price') . '" title="' . $this->l('show price') . '" style="float:left; padding:0px 5px 0px 5px" />' . $this->l('show price') . '</label> <br class="clear" /> <input style="float: left;" type="checkbox" name="online_only" id="online_only" value="1" ' . ($this->getFieldValue($obj, 'online_only') ? 'checked="checked" ' : '') . ' /> <label for="online_only" class="t"><img src="../img/admin/basket_error.png" alt="' . $this->l('online only') . '" title="' . $this->l('online only') . '" style="float:left; padding:0px 5px 0px 5px" />' . $this->l('online only (not sold in store)') . '</label> </td> </tr> <tr> <td style="vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">' . $this->l('Condition:') . '</td> <td style="padding-bottom:5px;"> <select name="condition" id="condition"> <option value="new" ' . ($obj->condition == 'new' ? 'selected="selected"' : '') . '>' . $this->l('New') . '</option> <option value="used" ' . ($obj->condition == 'used' ? 'selected="selected"' : '') . '>' . $this->l('Used') . '</option> <option value="refurbished" ' . ($obj->condition == 'refurbished' ? 'selected="selected"' : '') . '>' . $this->l('Refurbished') . '</option> </select> </td> </tr> <tr> <td style="vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">' . $this->l('Manufacturer:') . '</td> <td style="padding-bottom:5px;"> <select name="id_manufacturer" id="id_manufacturer"> <option value="0">-- ' . $this->l('Choose (optional)') . ' --</option>'; if ($id_manufacturer = $this->getFieldValue($obj, 'id_manufacturer')) { echo ' <option value="' . $id_manufacturer . '" selected="selected">' . Manufacturer::getNameById($id_manufacturer) . '</option> <option disabled="disabled">----------</option>'; } echo ' </select> <a href="?tab=AdminManufacturers&addmanufacturer&token=' . Tools::getAdminToken('AdminManufacturers' . (int) Tab::getIdFromClassName('AdminManufacturers') . (int) $cookie->id_employee) . '" onclick="return confirm(\'' . $this->l('Are you sure you want to delete product information entered?', __CLASS__, true, false) . '\');"><img src="../img/admin/add.gif" alt="' . $this->l('Create') . '" title="' . $this->l('Create') . '" /> <b>' . $this->l('Create') . '</b></a> </td> </tr> <tr> <td style="vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">' . $this->l('Supplier:') . '</td> <td style="padding-bottom:5px;"> <select name="id_supplier" id="id_supplier"> <option value="0">-- ' . $this->l('Choose (optional)') . ' --</option>'; if ($id_supplier = $this->getFieldValue($obj, 'id_supplier')) { echo ' <option value="' . $id_supplier . '" selected="selected">' . Supplier::getNameById($id_supplier) . '</option> <option disabled="disabled">----------</option>'; } echo ' </select> <a href="?tab=AdminSuppliers&addsupplier&token=' . Tools::getAdminToken('AdminSuppliers' . (int) Tab::getIdFromClassName('AdminSuppliers') . (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/add.gif" alt="' . $this->l('Create') . '" title="' . $this->l('Create') . '" /> <b>' . $this->l('Create') . '</b></a> </td> </tr> </table> <div class="clear"></div> <table cellpadding="5" style="width: 100%;"> <tr><td colspan="2"><hr style="width:100%;" /></td></tr>'; $this->displayPack($obj); echo ' <tr><td colspan="2"><hr style="width:100%;" /></td></tr>'; /* * Form for add a virtual product like software, mp3, etc... */ $productDownload = new ProductDownload(); if ($id_product_download = $productDownload->getIdFromIdProduct($this->getFieldValue($obj, 'id'))) { $productDownload = new ProductDownload($id_product_download); } ?> <script type="text/javascript"> // <![CDATA[ ThickboxI18nImage = '<?php echo $this->l('Image'); ?> '; ThickboxI18nOf = '<?php echo $this->l('of'); ?> '; ThickboxI18nClose = '<?php echo $this->l('Close'); ?> '; ThickboxI18nOrEscKey = '<?php echo $this->l('(or "Esc")'); ?> '; ThickboxI18nNext = '<?php echo $this->l('Next >'); ?> '; ThickboxI18nPrev = '<?php echo $this->l('< Previous'); ?> '; tb_pathToImage = '../img/loadingAnimation.gif'; //]]> </script> <script type="text/javascript" src="<?php echo _PS_JS_DIR_; ?> jquery/thickbox-modified.js"></script> <script type="text/javascript" src="<?php echo _PS_JS_DIR_; ?> jquery/ajaxfileupload.js"></script> <script type="text/javascript" src="<?php echo _PS_JS_DIR_; ?> date.js"></script> <style type="text/css"> <!-- @import url(<?php echo _PS_CSS_DIR_; ?> thickbox.css); --> </style> <script type="text/javascript"> //<![CDATA[ function toggleVirtualProduct(elt) { if (elt.checked) { $('#virtual_good').show('slow'); $('#virtual_good_more').show('slow'); getE('out_of_stock_1').checked = 'checked'; getE('out_of_stock_2').disabled = 'disabled'; getE('out_of_stock_3').disabled = 'disabled'; getE('label_out_of_stock_2').setAttribute('for', ''); getE('label_out_of_stock_3').setAttribute('for', ''); } else { $('#virtual_good').hide('slow'); $('#virtual_good_more').hide('slow'); getE('out_of_stock_2').disabled = false; getE('out_of_stock_3').disabled = false; getE('label_out_of_stock_2').setAttribute('for', 'out_of_stock_2'); getE('label_out_of_stock_3').setAttribute('for', 'out_of_stock_3'); } } function uploadFile() { $.ajaxFileUpload ( { url:'./uploadProductFile.php', secureuri:false, fileElementId:'virtual_product_file', dataType: 'xml', success: function (data, status) { data = data.getElementsByTagName('return')[0]; var result = data.getAttribute("result"); var msg = data.getAttribute("msg"); var fileName = data.getAttribute("filename"); if (result == "error") { $("#upload-confirmation").html('<p>error: ' + msg + '</p>'); } else { $('#virtual_product_file').remove(); $('#virtual_product_file_label').hide(); $('#file_missing').hide(); new_href = $('#delete_downloadable_product').attr('href').replace('%26deleteVirtualProduct%3Dtrue', '%26file%3D'+msg+'%26deleteVirtualProduct%3Dtrue'); $('#delete_downloadable_product').attr('href', new_href); $('#delete_downloadable_product').show(); $('#virtual_product_name').attr('value', fileName); $('#upload-confirmation').html( '<a class="link" href="get-file-admin.php?file='+msg+'&filename='+fileName+'"><?php echo $this->l('The file'); ?> "' + fileName + '" <?php echo $this->l('has successfully been uploaded'); ?> </a>' + '<input type="hidden" id="virtual_product_filename" name="virtual_product_filename" value="' + msg + '" />'); } } } ); } //]]> </script> <?php echo ' <script type="text/javascript" src="../js/price.js"></script> <script type="text/javascript"> var newLabel = \'' . $this->l('New label') . '\'; var choose_language = \'' . $this->l('Choose language:') . '\'; var required = \'' . $this->l('required') . '\'; var customizationUploadableFileNumber = ' . (int) $this->getFieldValue($obj, 'uploadable_files') . '; var customizationTextFieldNumber = ' . (int) $this->getFieldValue($obj, 'text_fields') . '; var uploadableFileLabel = 0; var textFieldLabel = 0; </script>'; ?> <tr> <td colspan="2"> <p><input type="checkbox" id="is_virtual_good" name="is_virtual_good" value="true" onclick="toggleVirtualProduct(this);" <?php if (($productDownload->id or Tools::getValue('is_virtual_good') == 'true') and $productDownload->active) { echo 'checked="checked"'; } ?> /> <label for="is_virtual_good" class="t bold" style="color: black;"><?php echo $this->l('Is this a downloadable product?'); ?> </label></p> <div id="virtual_good" <?php if (!$productDownload->id or !$productDownload->active) { echo 'style="display:none;"'; } ?> > <?php if (!ProductDownload::checkWritableDir()) { ?> <p class="alert"> <?php echo $this->l('Your download repository is not writable.'); ?> <br/> <?php echo realpath(_PS_DOWNLOAD_DIR_); ?> </p> <?php } else { ?> <?php if ($productDownload->id) { echo '<input type="hidden" id="virtual_product_id" name="virtual_product_id" value="' . $productDownload->id . '" />'; } ?> <p class="block"> <?php if (!$productDownload->checkFile()) { ?> <div style="padding:5px;width:50%;float:left;margin-right:20px;border-right:1px solid #E0D0B1"> <?php if ($productDownload->id) { ?> <p class="alert" id="file_missing"> <?php echo $this->l('This product is missing'); ?> :<br/> <?php echo realpath(_PS_DOWNLOAD_DIR_) . '/' . $productDownload->physically_filename; ?> </p> <?php } ?> <p><?php $max_upload = (int) ini_get('upload_max_filesize'); $max_post = (int) ini_get('post_max_size'); $upload_mb = min($max_upload, $max_post); echo $this->l('Your server\'s maximum upload file size is') . ': ' . $upload_mb . $this->l('Mb'); ?> </p> <?php if (!strval(Tools::getValue('virtual_product_filename'))) { ?> <label id="virtual_product_file_label" for="virtual_product_file" class="t"><?php echo $this->l('Upload a file'); ?> </label> <p><input type="file" id="virtual_product_file" name="virtual_product_file" onchange="uploadFile();" /></p> <?php } ?> <div id="upload-confirmation"> <?php if ($up_filename = strval(Tools::getValue('virtual_product_filename'))) { ?> <input type="hidden" id="virtual_product_filename" name="virtual_product_filename" value="<?php echo $up_filename; ?> " /> <?php } ?> </div> <a id="delete_downloadable_product" style="display:none;" href="confirm.php?height=200&width=300&modal=true&referer=<?php echo rawurlencode($_SERVER['REQUEST_URI'] . '&deleteVirtualProduct=true'); ?> " class="thickbox red" title="<?php echo $this->l('Delete this file'); ?> "><?php echo $this->l('Delete this file'); ?> </a> <?php } else { ?> <input type="hidden" id="virtual_product_filename" name="virtual_product_filename" value="<?php echo $productDownload->physically_filename; ?> " /> <?php echo $this->l('This is the link') . ': ' . $productDownload->getHtmlLink(false, true); ?> <a href="confirm.php?height=200&width=300&modal=true&referer=<?php echo rawurlencode($_SERVER['REQUEST_URI'] . '&deleteVirtualProduct=true'); ?> " class="thickbox red" title="<?php echo $this->l('Delete this file'); ?> "><?php echo $this->l('Delete this file'); ?> </a> <?php } // check if file exists ?> </p> <p class="block"> <label for="virtual_product_name" class="t"><?php echo $this->l('Filename'); ?> </label> <input type="text" id="virtual_product_name" name="virtual_product_name" style="width:200px" value="<?php echo $productDownload->id > 0 ? $productDownload->display_filename : htmlentities(Tools::getValue('virtual_product_name'), ENT_COMPAT, 'UTF-8'); ?> " /> <span class="hint" name="help_box" style="display:none;"><?php echo $this->l('The full filename with its extension (e.g., Book.pdf)'); ?> </span> </p> </div> <div id="virtual_good_more" style="<?php if (!$productDownload->id or !$productDownload->active) { echo 'display:none;'; } ?> padding:5px;width:40%;float:left;margin-left:10px"> <p class="block"> <label for="virtual_product_nb_downloable" class="t"><?php echo $this->l('Number of downloads'); ?> </label> <input type="text" id="virtual_product_nb_downloable" name="virtual_product_nb_downloable" value="<?php echo $productDownload->id > 0 ? $productDownload->nb_downloadable : htmlentities(Tools::getValue('virtual_product_nb_downloable'), ENT_COMPAT, 'UTF-8'); ?> " class="" size="6" /> <span class="hint" name="help_box" style="display:none"><?php echo $this->l('Number of authorized downloads per customer'); ?> </span> </p> <p class="block"> <label for="virtual_product_expiration_date" class="t"><?php echo $this->l('Expiration date'); ?> </label> <input type="text" id="virtual_product_expiration_date" name="virtual_product_expiration_date" value="<?php echo $productDownload->id > 0 ? (!empty($productDownload->date_expiration) and $productDownload->date_expiration != '0000-00-00 00:00:00') ? date('Y-m-d', strtotime($productDownload->date_expiration)) : '' : htmlentities(Tools::getValue('virtual_product_expiration_date'), ENT_COMPAT, 'UTF-8'); ?> " size="11" maxlength="10" autocomplete="off" /> <?php echo $this->l('Format: YYYY-MM-DD'); ?> <span class="hint" name="help_box" style="display:none"><?php echo $this->l('No expiration date if you leave this blank'); ?> </span> </p> <p class="block"> <label for="virtual_product_nb_days" class="t"><?php echo $this->l('Number of days'); ?> </label> <input type="text" id="virtual_product_nb_days" name="virtual_product_nb_days" value="<?php echo $productDownload->id > 0 ? $productDownload->nb_days_accessible : htmlentities(Tools::getValue('virtual_product_nb_days'), ENT_COMPAT, 'UTF-8'); ?> " class="" size="4" /><sup> *</sup> <span class="hint" name="help_box" style="display:none"><?php echo $this->l('How many days this file can be accessed by customers'); ?> - <em>(<?php echo $this->l('set to zero for unlimited access'); ?> )</em></span> </p> </div> <?php } // check if download directory is writable ?> </div> </td> </tr> <tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:100%;" /></td></tr> <script type="text/javascript"> if ($('#is_virtual_good').attr('checked')) { $('#virtual_good').show('slow'); $('#virtual_good_more').show('slow'); } </script> <?php echo ' <tr> <td class="col-left">' . $this->l('Pre-tax wholesale price:') . '</td> <td style="padding-bottom:5px;"> ' . ($currency->format % 2 != 0 ? $currency->sign . ' ' : '') . '<input size="11" maxlength="14" name="wholesale_price" type="text" value="' . htmlentities($this->getFieldValue($obj, 'wholesale_price'), ENT_COMPAT, 'UTF-8') . '" onchange="this.value = this.value.replace(/,/g, \'.\');" />' . ($currency->format % 2 == 0 ? ' ' . $currency->sign : '') . ' <span style="margin-left:10px">' . $this->l('The wholesale price at which you bought this product') . '</span> </td> </tr>'; echo ' <tr> <td class="col-left">' . $this->l('Pre-tax retail price:') . '</td> <td style="padding-bottom:5px;"> ' . ($currency->format % 2 != 0 ? $currency->sign . ' ' : '') . '<input size="11" maxlength="14" id="priceTE" name="price" type="text" value="' . htmlentities($this->getFieldValue($obj, 'price'), ENT_COMPAT, 'UTF-8') . '" onchange="this.value = this.value.replace(/,/g, \'.\');" onkeyup="if (isArrowKey(event)) return; calcPriceTI();" />' . ($currency->format % 2 == 0 ? ' ' . $currency->sign : '') . '<sup> *</sup> <span style="margin-left:2px">' . $this->l('The pre-tax retail price to sell this product') . '</span> </td> </tr>'; $tax_rules_groups = TaxRulesGroup::getTaxRulesGroups(true); $taxesRatesByGroup = TaxRulesGroup::getAssociatedTaxRatesByIdCountry(Country::getDefaultCountryId()); $ecotaxTaxRate = Tax::getProductEcotaxRate(); echo '<script type="text/javascript">'; echo 'noTax = ' . (Tax::excludeTaxeOption() ? 'true' : 'false'), ";\n"; echo 'taxesArray = new Array ();' . "\n"; echo 'taxesArray[0] = 0', ";\n"; foreach ($tax_rules_groups as $tax_rules_group) { $tax_rate = array_key_exists($tax_rules_group['id_tax_rules_group'], $taxesRatesByGroup) ? $taxesRatesByGroup[$tax_rules_group['id_tax_rules_group']] : 0; echo 'taxesArray[' . $tax_rules_group['id_tax_rules_group'] . ']=' . $tax_rate . "\n"; } echo ' ecotaxTaxRate = ' . $ecotaxTaxRate / 100 . '; </script>'; echo ' <tr> <td class="col-left">' . $this->l('Tax rule:') . '</td> <td style="padding-bottom:5px;"> <span ' . (Tax::excludeTaxeOption() ? 'style="display:none;"' : '') . '> <select onChange="javascript:calcPriceTI(); unitPriceWithTax(\'unit\');" name="id_tax_rules_group" id="id_tax_rules_group" ' . (Tax::excludeTaxeOption() ? 'disabled="disabled"' : '') . '> <option value="0">' . $this->l('No Tax') . '</option>'; foreach ($tax_rules_groups as $tax_rules_group) { echo '<option value="' . $tax_rules_group['id_tax_rules_group'] . '" ' . ($this->getFieldValue($obj, 'id_tax_rules_group') == $tax_rules_group['id_tax_rules_group'] ? ' selected="selected"' : '') . '>' . Tools::htmlentitiesUTF8($tax_rules_group['name']) . '</option>'; } echo '</select> <a href="?tab=AdminTaxRulesGroup&addtax_rules_group&token=' . Tools::getAdminToken('AdminTaxRulesGroup' . (int) Tab::getIdFromClassName('AdminTaxRulesGroup') . (int) $cookie->id_employee) . '&id_product=' . (int) $obj->id . '" onclick="return confirm(\'' . $this->l('Are you sure you want to delete entered product information?', __CLASS__, true, false) . '\');"><img src="../img/admin/add.gif" alt="' . $this->l('Create') . '" title="' . $this->l('Create') . '" /> <b>' . $this->l('Create') . '</b></a></span> '; if (Tax::excludeTaxeOption()) { echo '<span style="margin-left:10px; color:red;">' . $this->l('Taxes are currently disabled') . '</span> (<b><a href="index.php?tab=AdminTaxes&token=' . Tools::getAdminToken('AdminTaxes' . (int) Tab::getIdFromClassName('AdminTaxes') . (int) $cookie->id_employee) . '">' . $this->l('Tax options') . '</a></b>)'; echo '<input type="hidden" value="' . (int) $this->getFieldValue($obj, 'id_tax_rules_group') . '" name="id_tax_rules_group" />'; } echo '</td> </tr> '; if (Configuration::get('PS_USE_ECOTAX')) { echo ' <tr> <td class="col-left">' . $this->l('Eco-tax (tax incl.):') . '</td> <td style="padding-bottom:5px;"> ' . ($currency->format % 2 != 0 ? $currency->sign . ' ' : '') . '<input size="11" maxlength="14" id="ecotax" name="ecotax" type="text" value="' . $this->getFieldValue($obj, 'ecotax') . '" onkeyup="if (isArrowKey(event))return; calcPriceTE(); this.value = this.value.replace(/,/g, \'.\'); if (parseInt(this.value) > getE(\'priceTE\').value) this.value = getE(\'priceTE\').value; if (isNaN(this.value)) this.value = 0;" />' . ($currency->format % 2 == 0 ? ' ' . $currency->sign : '') . ' <span style="margin-left:10px">(' . $this->l('already included in price') . ')</span> </td> </tr>'; } if ($default_country->display_tax_label) { echo ' <tr ' . (Tax::excludeTaxeOption() ? 'style="display:none"' : '') . '> <td class="col-left">' . $this->l('Retail price with tax:') . '</td> <td style="padding-bottom:5px;"> ' . ($currency->format % 2 != 0 ? ' ' . $currency->sign : '') . ' <input size="11" maxlength="14" id="priceTI" type="text" value="" onchange="noComma(\'priceTI\');" onkeyup="if (isArrowKey(event)) return; calcPriceTE();" />' . ($currency->format % 2 == 0 ? ' ' . $currency->sign : '') . ' </td> </tr>'; } else { echo '<input size="11" maxlength="14" id="priceTI" type="hidden" value="" onchange="noComma(\'priceTI\');" onkeyup="if (isArrowKey(event)) return; calcPriceTE();" />'; } echo ' <tr id="tr_unit_price"> <td class="col-left">' . $this->l('Unit price without tax:') . '</td> <td style="padding-bottom:5px;"> ' . ($currency->format % 2 != 0 ? ' ' . $currency->sign : '') . ' <input size="11" maxlength="14" id="unit_price" name="unit_price" type="text" value="' . ($this->getFieldValue($obj, 'unit_price_ratio') != 0 ? Tools::ps_round($this->getFieldValue($obj, 'price') / $this->getFieldValue($obj, 'unit_price_ratio'), 2) : 0) . '" onkeyup="if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, \'.\'); unitPriceWithTax(\'unit\');"/>' . ($currency->format % 2 == 0 ? ' ' . $currency->sign : '') . ' ' . $this->l('per') . ' <input size="6" maxlength="10" id="unity" name="unity" type="text" value="' . (Validate::isCleanHtml($this->getFieldValue($obj, 'unity')) ? htmlentities($this->getFieldValue($obj, 'unity'), ENT_QUOTES, 'UTF-8') : '') . '" onkeyup="if (isArrowKey(event)) return ;unitySecond();" onchange="unitySecond();"/>' . (Configuration::get('PS_TAX') && $default_country->display_tax_label ? '<span style="margin-left:15px">' . $this->l('or') . ' ' . ($currency->format % 2 != 0 ? ' ' . $currency->sign : '') . '<span id="unit_price_with_tax">0.00</span>' . ($currency->format % 2 == 0 ? ' ' . $currency->sign : '') . ' ' . $this->l('per') . ' <span id="unity_second">' . (Validate::isCleanHtml($this->getFieldValue($obj, 'unity')) ? htmlentities($this->getFieldValue($obj, 'unity'), ENT_QUOTES, 'UTF-8') : '') . '</span> ' . $this->l('with tax') : '') . '</span> <p>' . $this->l('Eg. $15 per Lb') . '</p> </td> </tr> <tr> <td class="col-left"> </td> <td style="padding-bottom:5px;"> <input type="checkbox" name="on_sale" id="on_sale" style="padding-top: 5px;" ' . ($this->getFieldValue($obj, 'on_sale') ? 'checked="checked"' : '') . 'value="1" /> <label for="on_sale" class="t">' . $this->l('Display "on sale" icon on product page and text on product listing') . '</label> </td> </tr> <tr> <td class="col-left"><b>' . $this->l('Final retail price:') . '</b></td> <td style="padding-bottom:5px;"> <span style="' . ($default_country->display_tax_label ? '' : 'display:none') . '"> ' . ($currency->format % 2 != 0 ? $currency->sign . ' ' : '') . '<span id="finalPrice" style="font-weight: bold;"></span>' . ($currency->format % 2 == 0 ? ' ' . $currency->sign : '') . '<span' . (!Configuration::get('PS_TAX') ? ' style="display:none;"' : '') . '> (' . $this->l('tax incl.') . ')</span> </span> <span' . (!Configuration::get('PS_TAX') ? ' style="display:none;"' : '') . '>'; if ($default_country->display_tax_label) { echo ' / '; } echo ($currency->format % 2 != 0 ? $currency->sign . ' ' : '') . '<span id="finalPriceWithoutTax" style="font-weight: bold;"></span>' . ($currency->format % 2 == 0 ? ' ' . $currency->sign : '') . ' ' . ($default_country->display_tax_label ? '(' . $this->l('tax excl.') . ')' : '') . '</span> </td> </tr> <tr> <td class="col-left"> </td> <td> <div class="hint clear" style="display: block;width: 70%;">' . $this->l('You can define many discounts and specific price rules in the Prices tab') . '</div> </td> </tr> <tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:100%;" /></td></tr>'; if ((int) Configuration::get('PS_STOCK_MANAGEMENT')) { if (!$has_attribute) { if ($obj->id) { echo ' <tr><td 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 id="mvt_quantity" type="text" name="mvt_quantity" size="3" maxlength="10" value="0"/> <span style="display:none;" id="mvt_sign"></span> </td> </tr> <tr> <td class="col-left"> </td> <td> <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>'; } else { echo '<tr><td class="col-left">' . $this->l('Initial stock:') . '</td> <td style="padding-bottom:5px;"> <input size="3" maxlength="10" name="quantity" type="text" value="0" /> </td>'; } echo '<tr> <td class="col-left">' . $this->l('Minimum quantity:') . '</td> <td style="padding-bottom:5px;"> <input size="3" maxlength="10" name="minimal_quantity" id="minimal_quantity" type="text" value="' . ($this->getFieldValue($obj, 'minimal_quantity') ? $this->getFieldValue($obj, 'minimal_quantity') : 1) . '" /> <p>' . $this->l('The minimum quantity to buy this product (set to 1 to disable this feature)') . '</p> </td> </tr>'; } if ($obj->id) { echo ' <tr><td class="col-left">' . $this->l('Quantity in stock:') . '</td> <td style="padding-bottom:5px;"><b>' . $qty . '</b><input type="hidden" name="quantity" value="' . $qty . '" /></td> </tr> '; } if ($has_attribute) { echo '<tr> <td class="col-left"> </td> <td> <div class="hint clear" style="display: block;width: 70%;">' . $this->l('You used combinations, for this reason you cannot edit your stock quantity here, but in the Combinations tab') . '</div> </td> </tr>'; } } else { echo '<tr> <td colspan="2">' . $this->l('The stock management is disabled') . '</td> </tr>'; echo ' <tr> <td class="col-left">' . $this->l('Minimum quantity:') . '</td> <td style="padding-bottom:5px;"> <input size="3" maxlength="10" name="minimal_quantity" id="minimal_quantity" type="text" value="' . ($this->getFieldValue($obj, 'minimal_quantity') ? $this->getFieldValue($obj, 'minimal_quantity') : 1) . '" /> <p>' . $this->l('The minimum quantity to buy this product (set to 1 to disable this feature)') . '</p> </td> </tr> '; } echo ' <tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:100%;" /></td></tr> <tr> <td class="col-left">' . $this->l('Additional shipping cost:') . '</td> <td style="padding-bottom:5px;"> <input type="text" name="additional_shipping_cost" value="' . Tools::safeOutput($this->getFieldValue($obj, 'additional_shipping_cost')) . '" />' . ($currency->format % 2 == 0 ? ' ' . $currency->sign : ''); if ($default_country->display_tax_label) { echo ' (' . $this->l('tax excl.') . ')'; } echo '<p>' . $this->l('Carrier tax will be applied.') . '</p> </td> </tr> <tr> <td class="col-left">' . $this->l('Displayed text when in-stock:') . '</td> <td style="padding-bottom:5px;" class="translatable">'; foreach ($this->_languages as $language) { echo ' <div class="lang_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . '; float: left;"> <input size="30" type="text" id="available_now_' . $language['id_lang'] . '" name="available_now_' . $language['id_lang'] . '" value="' . stripslashes(htmlentities($this->getFieldValue($obj, 'available_now', $language['id_lang']), ENT_COMPAT, 'UTF-8')) . '" /> <span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' <>;=#{}<span class="hint-pointer"> </span></span> </div>'; } echo ' </td> </tr> <tr> <td class="col-left">' . $this->l('Displayed text when allowed to be back-ordered:') . '</td> <td style="padding-bottom:5px;" class="translatable">'; foreach ($this->_languages as $language) { echo ' <div class="lang_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . '; float: left;"> <input size="30" type="text" id="available_later_' . $language['id_lang'] . '" name="available_later_' . $language['id_lang'] . '" value="' . stripslashes(htmlentities($this->getFieldValue($obj, 'available_later', $language['id_lang']), ENT_COMPAT, 'UTF-8')) . '" /> <span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' <>;=#{}<span class="hint-pointer"> </span></span> </div>'; } echo ' </td> </tr> <script type="text/javascript"> calcPriceTI(); </script> <tr> <td class="col-left">' . $this->l('When out of stock:') . '</td> <td style="padding-bottom:5px;"> <input type="radio" name="out_of_stock" id="out_of_stock_1" value="0" ' . ((int) $this->getFieldValue($obj, 'out_of_stock') == 0 ? 'checked="checked"' : '') . '/> <label for="out_of_stock_1" class="t" id="label_out_of_stock_1">' . $this->l('Deny orders') . '</label> <br /><input type="radio" name="out_of_stock" id="out_of_stock_2" value="1" ' . ($this->getFieldValue($obj, 'out_of_stock') == 1 ? 'checked="checked"' : '') . '/> <label for="out_of_stock_2" class="t" id="label_out_of_stock_2">' . $this->l('Allow orders') . '</label> <br /><input type="radio" name="out_of_stock" id="out_of_stock_3" value="2" ' . ($this->getFieldValue($obj, 'out_of_stock') == 2 ? 'checked="checked"' : '') . '/> <label for="out_of_stock_3" class="t" id="label_out_of_stock_3">' . $this->l('Default:') . ' <i>' . $this->l((int) Configuration::get('PS_ORDER_OUT_OF_STOCK') ? 'Allow orders' : 'Deny orders') . '</i> (' . $this->l('as set in') . ' <a href="index.php?tab=AdminPPreferences&token=' . Tools::getAdminToken('AdminPPreferences' . (int) Tab::getIdFromClassName('AdminPPreferences') . (int) $cookie->id_employee) . '" onclick="return confirm(\'' . $this->l('Are you sure you want to delete entered product information?', __CLASS__, true, false) . '\');">' . $this->l('Preferences') . '</a>)</label> </td> </tr> <tr> <td colspan="2" style="padding-bottom:5px;"> <hr style="width:100%;" /> </td> </tr> <tr> <td class="col-left"><label for="id_category_default" class="t">' . $this->l('Default category:') . '</label></td> <td> <div id="no_default_category" style="color: red;font-weight: bold;display: none;">' . $this->l('Please check a category in order to select the default category.') . '</div> <script type="text/javascript"> var post_selected_cat; </script>'; $default_category = Tools::getValue('id_category', 1); if (!$obj->id) { $selectedCat = Category::getCategoryInformations(Tools::getValue('categoryBox', array($default_category)), $this->_defaultFormLanguage); echo ' <script type="text/javascript"> post_selected_cat = \'' . implode(',', array_keys($selectedCat)) . '\'; </script>'; } else { if (Tools::isSubmit('categoryBox')) { $selectedCat = Category::getCategoryInformations(Tools::getValue('categoryBox', array($default_category)), $this->_defaultFormLanguage); } else { $selectedCat = Product::getProductCategoriesFull($obj->id, $this->_defaultFormLanguage); } } echo '<select id="id_category_default" name="id_category_default">'; foreach ($selectedCat as $cat) { echo '<option value="' . $cat['id_category'] . '" ' . ($obj->id_category_default == $cat['id_category'] ? 'selected' : '') . '>' . $cat['name'] . '</option>'; } echo '</select> </td> </tr> <tr id="tr_categories"> <td colspan="2"> '; // Translations are not automatic for the moment ;) $trads = array('Home' => $this->l('Home'), 'selected' => $this->l('selected'), 'Collapse All' => $this->l('Collapse All'), 'Expand All' => $this->l('Expand All'), 'Check All' => $this->l('Check All'), 'Uncheck All' => $this->l('Uncheck All')); echo Helper::renderAdminCategorieTree($trads, $selectedCat) . ' </td> </tr> <tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:100%;" /></td></tr> <tr><td colspan="2"> <span onclick="$(\'#seo\').slideToggle();" style="cursor: pointer"><img src="../img/admin/arrow.gif" alt="' . $this->l('SEO') . '" title="' . $this->l('SEO') . '" style="float:left; margin-right:5px;"/>' . $this->l('Click here to improve product\'s rank in search engines (SEO)') . '</span><br /> <div id="seo" style="display: none; padding-top: 15px;"> <table> <tr> <td class="col-left">' . $this->l('Meta title:') . '</td> <td class="translatable">'; foreach ($this->_languages as $language) { echo ' <div class="lang_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . '; float: left;"> <input size="55" type="text" id="meta_title_' . $language['id_lang'] . '" name="meta_title_' . $language['id_lang'] . '" value="' . htmlentities($this->getFieldValue($obj, 'meta_title', $language['id_lang']), ENT_COMPAT, 'UTF-8') . '" /> <span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' <>;=#{}<span class="hint-pointer"> </span></span> </div>'; } echo ' <p class="clear">' . $this->l('Product page title; leave blank to use product name') . '</p> </td> </tr> <tr> <td class="col-left">' . $this->l('Meta description:') . '</td> <td class="translatable">'; foreach ($this->_languages as $language) { echo ' <div class="lang_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . '; float: left;"> <input size="55" type="text" id="meta_description_' . $language['id_lang'] . '" name="meta_description_' . $language['id_lang'] . '" value="' . htmlentities($this->getFieldValue($obj, 'meta_description', $language['id_lang']), ENT_COMPAT, 'UTF-8') . '" /> <span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' <>;=#{}<span class="hint-pointer"> </span></span> </div>'; } echo ' <p class="clear">' . $this->l('A single sentence for HTML header') . '</p> </td> </tr> <tr> <td class="col-left">' . $this->l('Meta keywords:') . '</td> <td class="translatable">'; foreach ($this->_languages as $language) { echo ' <div class="lang_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . '; float: left;"> <input size="55" type="text" id="meta_keywords_' . $language['id_lang'] . '" name="meta_keywords_' . $language['id_lang'] . '" value="' . htmlentities($this->getFieldValue($obj, 'meta_keywords', $language['id_lang']), ENT_COMPAT, 'UTF-8') . '" /> <span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' <>;=#{}<span class="hint-pointer"> </span></span> </div>'; } echo ' <p class="clear">' . $this->l('Keywords for HTML header, separated by a comma') . '</p> </td> </tr> <tr> <td class="col-left">' . $this->l('Friendly URL:') . '</td> <td class="translatable">'; foreach ($this->_languages as $language) { echo ' <div class="lang_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . '; float: left;"> <input size="55" type="text" id="link_rewrite_' . $language['id_lang'] . '" name="link_rewrite_' . $language['id_lang'] . '" value="' . htmlentities($this->getFieldValue($obj, 'link_rewrite', $language['id_lang']), ENT_COMPAT, 'UTF-8') . '" onkeyup="if (isArrowKey(event)) return ;updateFriendlyURL();" onchange="updateFriendlyURL();" /><sup> *</sup> <span class="hint" name="help_box">' . $this->l('Only letters and the "less" character are allowed') . '<span class="hint-pointer"> </span></span> </div>'; } echo ' <p class="clear" style="padding:10px 0 0 0">' . '<a style="cursor:pointer" class="button" onmousedown="updateFriendlyURLByName();">' . $this->l('Generate') . '</a> ' . $this->l('Friendly-url from product\'s name.') . '<br /><br />'; echo ' ' . $this->l('Product link will look like this:') . ' ' . (Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://') . $_SERVER['SERVER_NAME'] . '/<b>id_product</b>-<span id="friendly-url"></span>.html</p> </td> </tr>'; echo '</td></tr></table> </div> </td></tr> <tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:100%;" /></td></tr> <tr> <td class="col-left">' . $this->l('Short description:') . '<br /><br /><i>(' . $this->l('appears in the product lists and on the top of the product page') . ')</i></td> <td style="padding-bottom:5px;" class="translatable">'; foreach ($this->_languages as $language) { echo ' <div class="lang_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . ';float: left;"> <textarea class="rte" cols="100" rows="10" id="description_short_' . $language['id_lang'] . '" name="description_short_' . $language['id_lang'] . '">' . htmlentities(stripslashes($this->getFieldValue($obj, 'description_short', $language['id_lang'])), ENT_COMPAT, 'UTF-8') . '</textarea> </div>'; } echo ' </td> </tr> <tr> <td class="col-left">' . $this->l('Description:') . '<br /><br /><i>(' . $this->l('appears in the body of the product page') . ')</i></td> <td style="padding-bottom:5px;" class="translatable">'; foreach ($this->_languages as $language) { echo ' <div class="lang_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . ';float: left;"> <textarea class="rte" cols="100" rows="20" id="description_' . $language['id_lang'] . '" name="description_' . $language['id_lang'] . '">' . htmlentities(stripslashes($this->getFieldValue($obj, 'description', $language['id_lang'])), ENT_COMPAT, 'UTF-8') . '</textarea> </div>'; } echo ' </td> </tr>'; echo ' <tr> <td class="col-left">' . $this->l('Tags:') . '</td> <td style="padding-bottom:5px;" class="translatable">'; if ($obj->id) { $obj->tags = Tag::getProductTags((int) $obj->id); } foreach ($this->_languages as $language) { echo '<div class="lang_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . '; float: left;"> <input size="55" type="text" id="tags_' . $language['id_lang'] . '" name="tags_' . $language['id_lang'] . '" value="' . htmlentities(Tools::getValue('tags_' . $language['id_lang'], $obj->getTags($language['id_lang'], true)), ENT_COMPAT, 'UTF-8') . '" /> <span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' !<>;?=+#"°{}_$%<span class="hint-pointer"> </span></span> </div>'; } echo ' <p class="clear">' . $this->l('Tags separated by commas (e.g., dvd, dvd player, hifi)') . '</p> </td> </tr>'; $accessories = Product::getAccessoriesLight((int) $cookie->id_lang, $obj->id); if ($postAccessories = Tools::getValue('inputAccessories')) { $postAccessoriesTab = explode('-', Tools::getValue('inputAccessories')); foreach ($postAccessoriesTab as $accessoryId) { if (!$this->haveThisAccessory($accessoryId, $accessories) and $accessory = Product::getAccessoryById($accessoryId)) { $accessories[] = $accessory; } } } echo ' <tr> <td class="col-left">' . $this->l('Accessories:') . '<br /><br /><i>' . $this->l('(Do not forget to Save the product afterward)') . '</i></td> <td style="padding-bottom:5px;"> <div id="divAccessories">'; foreach ($accessories as $accessory) { echo htmlentities($accessory['name'], ENT_COMPAT, 'UTF-8') . (!empty($accessory['reference']) ? ' (' . $accessory['reference'] . ')' : '') . ' <span onclick="delAccessory(' . $accessory['id_product'] . ');" style="cursor: pointer;"><img src="../img/admin/delete.gif" class="middle" alt="" /></span><br />'; } echo '</div> <input type="hidden" name="inputAccessories" id="inputAccessories" value="'; foreach ($accessories as $accessory) { echo (int) $accessory['id_product'] . '-'; } echo '" /> <input type="hidden" name="nameAccessories" id="nameAccessories" value="'; foreach ($accessories as $accessory) { echo htmlentities($accessory['name'], ENT_COMPAT, 'UTF-8') . '¤'; } echo '" /> <script type="text/javascript"> var formProduct; var accessories = new Array(); </script> <link rel="stylesheet" type="text/css" href="' . __PS_BASE_URI__ . 'css/jquery.autocomplete.css" /> <script type="text/javascript" src="' . __PS_BASE_URI__ . 'js/jquery/jquery.autocomplete.js"></script> <div id="ajax_choose_product" style="padding:6px; padding-top:2px; width:600px;"> <p class="clear">' . $this->l('Begin typing the first letters of the product name, then select the product from the drop-down list:') . '</p> <input type="text" value="" id="product_autocomplete_input" /> <img onclick="$(this).prev().search();" style="cursor: pointer;" src="../img/admin/add.gif" alt="' . $this->l('Add an accessory') . '" title="' . $this->l('Add an accessory') . '" /> </div> <script type="text/javascript"> urlToCall = null; /* function autocomplete */ $(function() { $(\'#product_autocomplete_input\') .autocomplete(\'ajax_products_list.php\', { minChars: 1, autoFill: true, max:20, matchContains: true, mustMatch:true, scroll:false, cacheLength:0, formatItem: function(item) { return item[1]+\' - \'+item[0]; } }).result(addAccessory); $(\'#product_autocomplete_input\').setOptions({ extraParams: {excludeIds : getAccessorieIds()} }); }); </script> </td> </tr> <tr><td colspan="2" style="padding-bottom:10px;"><hr style="width:100%;" /></td></tr> <tr> <td colspan="2" style="text-align:center;"> <input type="submit" value="' . $this->l('Save') . '" name="submitAdd' . $this->table . '" class="button" /> <input type="submit" value="' . $this->l('Save and stay') . '" name="submitAdd' . $this->table . 'AndStay" class="button" /></td> </tr> </table> <br /> </div>'; // TinyMCE global $cookie; $iso = Language::getIsoById((int) $cookie->id_lang); $isoTinyMCE = file_exists(_PS_ROOT_DIR_ . '/js/tiny_mce/langs/' . $iso . '.js') ? $iso : 'en'; $ad = dirname($_SERVER["PHP_SELF"]); echo ' <script type="text/javascript"> var iso = \'' . $isoTinyMCE . '\' ; var pathCSS = \'' . _THEME_CSS_DIR_ . '\' ; var ad = \'' . $ad . '\' ; </script> <script type="text/javascript" src="' . __PS_BASE_URI__ . 'js/tiny_mce/tiny_mce.js"></script> <script type="text/javascript" src="' . __PS_BASE_URI__ . 'js/tinymce.inc.js"></script> <script type="text/javascript"> toggleVirtualProduct(getE(\'is_virtual_good\')); unitPriceWithTax(\'unit\'); </script>'; $categoryBox = Tools::getValue('categoryBox', array()); }
public function __construct($id_product = null, $full = false, $id_lang = null, $id_shop = null, Context $context = null) { parent::__construct($id_product, $id_lang, $id_shop); if (!$context) { $context = Context::getContext(); } if ($full && $this->id) { $this->isFullyLoaded = $full; $this->tax_name = 'deprecated'; // The applicable tax may be BOTH the product one AND the state one (moreover this variable is some deadcode) $this->manufacturer_name = Manufacturer::getNameById((int) $this->id_manufacturer); $this->supplier_name = Supplier::getNameById((int) $this->id_supplier); $address = null; if (is_object($context->cart) && $context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')} != null) { $address = $context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}; } $this->tax_rate = $this->getTaxesRate(new Address($address)); $this->new = $this->isNew(); $this->price = Product::getPriceStatic((int) $this->id, false, null, 6, null, false, true, 1, false, null, null, null, $this->specificPrice); $this->unit_price = $this->unit_price_ratio != 0 ? $this->price / $this->unit_price_ratio : 0; if ($this->id) { $this->tags = Tag::getProductTags((int) $this->id); } $this->loadStockData(); } if ($this->id_category_default) { $this->category = Category::getLinkRewrite((int) $this->id_category_default, (int) $id_lang); } }
/** * @since 1.5.0 */ public function supplyOrdersImport() { // opens CSV & sets locale $this->receiveTab(); $handle = $this->openCsvFile(); AdminImportController::setLocale(); // main loop, for each supply orders to import for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); ++$current_line) { // if convert requested if (Tools::getValue('convert')) { $line = $this->utf8EncodeArray($line); } $info = AdminImportController::getMaskedRow($line); // sets default values if needed AdminImportController::setDefaultValues($info); // if an id is set, instanciates a supply order with this id if possible if (array_key_exists('id', $info) && (int) $info['id'] && SupplyOrder::exists((int) $info['id'])) { $supply_order = new SupplyOrder((int) $info['id']); } elseif (array_key_exists('reference', $info) && $info['reference'] && SupplyOrder::exists(pSQL($info['reference']))) { $supply_order = SupplyOrder::getSupplyOrderByReference(pSQL($info['reference'])); } else { // new supply order $supply_order = new SupplyOrder(); } // gets parameters $id_supplier = (int) $info['id_supplier']; $id_lang = (int) $info['id_lang']; $id_warehouse = (int) $info['id_warehouse']; $id_currency = (int) $info['id_currency']; $reference = pSQL($info['reference']); $date_delivery_expected = pSQL($info['date_delivery_expected']); $discount_rate = (double) $info['discount_rate']; $is_template = (bool) $info['is_template']; $error = ''; // checks parameters if (!Supplier::supplierExists($id_supplier)) { $error = sprintf($this->l('Supplier ID (%d) is not valid (at line %d).'), $id_supplier, $current_line + 1); } if (!Language::getLanguage($id_lang)) { $error = sprintf($this->l('Lang ID (%d) is not valid (at line %d).'), $id_lang, $current_line + 1); } if (!Warehouse::exists($id_warehouse)) { $error = sprintf($this->l('Warehouse ID (%d) is not valid (at line %d).'), $id_warehouse, $current_line + 1); } if (!Currency::getCurrency($id_currency)) { $error = sprintf($this->l('Currency ID (%d) is not valid (at line %d).'), $id_currency, $current_line + 1); } if (empty($supply_order->reference) && SupplyOrder::exists($reference)) { $error = sprintf($this->l('Reference (%s) already exists (at line %d).'), $reference, $current_line + 1); } if (!empty($supply_order->reference) && ($supply_order->reference != $reference && SupplyOrder::exists($reference))) { $error = sprintf($this->l('Reference (%s) already exists (at line %d).'), $reference, $current_line + 1); } if (!Validate::isDateFormat($date_delivery_expected)) { $error = sprintf($this->l('Date (%s) is not valid (at line %d). Format: %s.'), $date_delivery_expected, $current_line + 1, $this->l('YYYY-MM-DD')); } elseif (new DateTime($date_delivery_expected) <= new DateTime('yesterday')) { $error = sprintf($this->l('Date (%s) cannot be in the past (at line %d). Format: %s.'), $date_delivery_expected, $current_line + 1, $this->l('YYYY-MM-DD')); } if ($discount_rate < 0 || $discount_rate > 100) { $error = sprintf($this->l('Discount rate (%d) is not valid (at line %d). %s.'), $discount_rate, $current_line + 1, $this->l('Format: Between 0 and 100')); } if ($supply_order->id > 0 && !$supply_order->isEditable()) { $error = sprintf($this->l('Supply Order (%d) is not editable (at line %d).'), $supply_order->id, $current_line + 1); } // if no errors, sets supply order if (empty($error)) { // adds parameters $info['id_ref_currency'] = (int) Currency::getDefaultCurrency()->id; $info['supplier_name'] = pSQL(Supplier::getNameById($id_supplier)); if ($supply_order->id > 0) { $info['id_supply_order_state'] = (int) $supply_order->id_supply_order_state; $info['id'] = (int) $supply_order->id; } else { $info['id_supply_order_state'] = 1; } // sets parameters AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $supply_order); // updatesd($supply_order); $res = true; if ((int) $supply_order->id && ($supply_order->exists((int) $supply_order->id) || $supply_order->exists($supply_order->reference))) { $res &= $supply_order->update(); } else { $supply_order->force_id = (bool) Tools::getValue('forceIDs'); $res &= $supply_order->add(); } // errors if (!$res) { $this->errors[] = sprintf($this->l('Supply Order could not be saved (at line %d).'), $current_line + 1); } } else { $this->errors[] = $error; } } // closes $this->closeCsvFile($handle); }
public function __construct($id_product = NULL, $full = false, $id_lang = NULL) { global $cart; parent::__construct($id_product, $id_lang); if ($full and $this->id) { $this->tax_name = 'deprecated'; // The applicable tax may be BOTH the product one AND the state one (moreover this variable is some deadcode) $this->manufacturer_name = Manufacturer::getNameById(intval($this->id_manufacturer)); $this->supplier_name = Supplier::getNameById(intval($this->id_supplier)); $tax = new Tax(intval($this->id_tax)); if (is_object($cart) and $cart->id_address_delivery != NULL) { $this->tax_rate = Tax::getApplicableTax(intval($this->id_tax), floatval($tax->rate)); } else { $this->tax_rate = floatval($tax->rate); } $this->new = $this->isNew(); } if ($this->id_category_default) { $this->category = Category::getLinkRewrite(intval($this->id_category_default), intval($id_lang)); } if ($this->id) { $this->tags = Tag::getProductTags(intval($this->id)); } }
/** * AdminController::postProcess() override * @see AdminController::postProcess() */ public function postProcess() { $this->is_editing_order = false; // Checks access if (Tools::isSubmit('submitAddsupply_order') && !($this->tabAccess['add'] === '1')) { $this->errors[] = Tools::displayError($this->l('You do not have permission to add a supply order.')); } if (Tools::isSubmit('submitBulkUpdatesupply_order_detail') && !($this->tabAccess['edit'] === '1')) { $this->errors[] = Tools::displayError($this->l('You do not have permission to edit an order.')); } // Trick to use both Supply Order as template and actual orders if (Tools::isSubmit('is_template')) { $_GET['mod'] = 'template'; } // checks if supply order reference is unique if (Tools::isSubmit('reference')) { // gets the reference $ref = pSQL(Tools::getValue('reference')); if (Tools::getValue('id_supply_order') != 0 && SupplyOrder::getReferenceById((int) Tools::getValue('id_supply_order')) != $ref) { if ((int) SupplyOrder::exists($ref) != 0) { $this->errors[] = Tools::displayError($this->l('The reference has to be unique.')); } } else { if (Tools::getValue('id_supply_order') == 0 && (int) SupplyOrder::exists($ref) != 0) { $this->errors[] = Tools::displayError($this->l('The reference has to be unique.')); } } } if ($this->errors) { return; } // Global checks when add / update a supply order if (Tools::isSubmit('submitAddsupply_order') || Tools::isSubmit('submitAddsupply_orderAndStay')) { $this->action = 'save'; $this->is_editing_order = true; // get supplier ID $id_supplier = (int) Tools::getValue('id_supplier', 0); if ($id_supplier <= 0 || !Supplier::supplierExists($id_supplier)) { $this->errors[] = Tools::displayError($this->l('The selected supplier is not valid.')); } // get warehouse id $id_warehouse = (int) Tools::getValue('id_warehouse', 0); if ($id_warehouse <= 0 || !Warehouse::exists($id_warehouse)) { $this->errors[] = Tools::displayError($this->l('The selected warehouse is not valid.')); } // get currency id $id_currency = (int) Tools::getValue('id_currency', 0); if ($id_currency <= 0 || (!($result = Currency::getCurrency($id_currency)) || empty($result))) { $this->errors[] = Tools::displayError($this->l('The selected currency is not valid.')); } // get delivery date $delivery_expected = new DateTime(pSQL(Tools::getValue('date_delivery_expected'))); // converts date to timestamp if ($delivery_expected <= new DateTime('yesterday')) { $this->errors[] = Tools::displayError($this->l('The date you specified cannot be in the past.')); } // gets threshold $quantity_threshold = Tools::getValue('load_products'); if (is_numeric($quantity_threshold)) { $quantity_threshold = (int) $quantity_threshold; } else { $quantity_threshold = null; } if (!count($this->errors)) { // forces date for templates if (Tools::isSubmit('is_template') && !Tools::getValue('date_delivery_expected')) { $_POST['date_delivery_expected'] = date('Y-m-d h:i:s'); } // specify initial state $_POST['id_supply_order_state'] = 1; //defaut creation state // specify global reference currency $_POST['id_ref_currency'] = Currency::getDefaultCurrency()->id; // specify supplier name $_POST['supplier_name'] = Supplier::getNameById($id_supplier); //specific discount check $_POST['discount_rate'] = (double) str_replace(array(' ', ','), array('', '.'), Tools::getValue('discount_rate', 0)); } // manage each associated product $this->manageOrderProducts(); // if the threshold is defined and we are saving the order if (Tools::isSubmit('submitAddsupply_order') && Validate::isInt($quantity_threshold)) { $this->loadProducts((int) $quantity_threshold); } //--ERP informations // updates/creates erp_supplier_order if it does not exist if (Tools::isSubmit('id_erpip_supply_order') && (int) Tools::getValue('id_erpip_supply_order') > 0) { $erp_supplier_order = new ErpSupplyOrder((int) Tools::getValue('id_erpip_supply_order')); } else { $erp_supplier_order = new ErpSupplyOrder(); } // creates erp_supplier_order $erp_supplier_order->escompte = Tools::getValue('escompte', null); $erp_supplier_order->global_discount_amount = Tools::getValue('global_discount_type', null); $erp_supplier_order->global_discount_type = Tools::getValue('global_discount_type', null); $erp_supplier_order->shipping_amount = Tools::getValue('shipping_amount', null); $erp_supplier_order->description = Tools::getValue('description', null); $validation = $erp_supplier_order->validateController(); // checks erp_supplier_order validity if (count($validation) > 0) { foreach ($validation as $item) { $this->errors[] = $item; } $this->errors[] = Tools::displayError('The ErpIllicopresta Supplier Order is not correct. Please make sure all of the required fields are completed.'); } else { if (Tools::isSubmit('id_erpip_supply_order') && Tools::getValue('id_erpip_supply_order') > 0) { $erp_supplier_order->update(); } else { $erp_supplier_order->save(); $_POST['id_erpip_supply_order'] = $erp_supplier_order->id; } } } // Manage state change if (Tools::isSubmit('submitChangestate') && Tools::isSubmit('id_supply_order') && Tools::isSubmit('id_supply_order_state')) { if ($this->tabAccess['edit'] != '1') { $this->errors[] = Tools::displayError($this->l('You do not have permission to change the order status.')); } // get state ID $id_state = (int) Tools::getValue('id_supply_order_state', 0); if ($id_state <= 0) { $this->errors[] = Tools::displayError($this->l('The selected supply order status is not valid.')); } // get supply order ID $id_supply_order = (int) Tools::getValue('id_supply_order', 0); if ($id_supply_order <= 0) { $this->errors[] = Tools::displayError($this->l('The supply order ID is not valid.')); } if (!count($this->errors)) { // try to load supply order $supply_order = new SupplyOrder($id_supply_order); if (Validate::isLoadedObject($supply_order)) { // get valid available possible states for this order $states = SupplyOrderState::getSupplyOrderStates($supply_order->id_supply_order_state); foreach ($states as $state) { // if state is valid, change it in the order if ($id_state == $state['id_supply_order_state']) { $new_state = new SupplyOrderState($id_state); $old_state = new SupplyOrderState($supply_order->id_supply_order_state); // special case of validate state - check if there are products in the order and the required state is not an enclosed state if ($supply_order->isEditable() && !$supply_order->hasEntries() && !$new_state->enclosed) { $this->errors[] = Tools::displayError($this->l('It is not possible to change the status of this order because you did not order any product.')); } if (!count($this->errors)) { // send mail to supplier with supply order if ($this->sendMailOnValidateSupplyOrder($supply_order)) { $supply_order->id_supply_order_state = $state['id_supply_order_state']; if ($supply_order->save()) { //-ERP information // save erp_supply_order additionale information // loads current erp_supplier` informationfor this supplier - if possible $erp_supply_order = null; if (isset($supply_order->id)) { $id_erpip_supply_order = ErpSupplyOrder::getErpSupplierOrderIdBySupplierOrderId((int) $supply_order->id); if ($id_erpip_supply_order > 0) { $erp_supply_order = new ErpSupplyOrder((int) $id_erpip_supply_order); } else { $erp_supply_order = new ErpSupplyOrder(); } } if ($erp_supply_order != null) { if (Tools::isSubmit('date_to_invoice')) { $erp_supply_order->date_to_invoice = Tools::getValue('date_to_invoice', '000-00-00'); } if (Tools::isSubmit('invoice_number')) { $erp_supply_order->invoice_number = Tools::getValue('invoice_number', ''); } $erp_supply_order->id_supply_order = $supply_order->id; $erp_supply_order->save(); } // if pending_receipt, // or if the order is being canceled, // synchronizes StockAvailable if ($new_state->pending_receipt && !$new_state->receipt_state || $old_state->receipt_state && $new_state->enclosed && !$new_state->receipt_state) { $supply_order_details = $supply_order->getEntries(); $products_done = array(); foreach ($supply_order_details as $supply_order_detail) { if (!in_array($supply_order_detail['id_product'], $products_done)) { StockAvailable::synchronize($supply_order_detail['id_product']); $products_done[] = $supply_order_detail['id_product']; } } } $token = Tools::getValue('token') ? Tools::getValue('token') : $this->token; $redirect = self::$currentIndex . '&token=' . $token; $this->redirect_after = $redirect . '&conf=5'; } } } } } } else { $this->errors[] = Tools::displayError($this->l('The selected supplier is not valid.')); } } } // get id_supplier $id_supply_order = (int) Tools::getValue('id_supply_order', null); $supply_order = new SupplyOrder($id_supply_order); $erp_supplier_order = new ErpSupplyOrder($id_supply_order); $this->context->smarty->assign(array('supplier_id' => $supply_order->id_supplier, 'currency' => new CurrencyCore((int) $supply_order->id_currency), 'random' => rand(99999, 150000), 'template_path' => $this->template_path, 'controller_status' => $this->controller_status, 'supply_order_description' => $erp_supplier_order->description)); $this->getFilters(); //-ErpIllicopresta // Fixed bug : different variable available according Prestashop version // 1.5.4.1 => submitFiltersupply_order_detail // 1.5.5.0 => submitFiltersupply_order // Add an OR to take into account this two version // updates receipt if (Tools::isSubmit('submitBulkUpdatesupply_order_detail') && Tools::isSubmit('id_supply_order') && (Tools::isSubmit('submitFiltersupply_order') || Tools::isSubmit('submitFiltersupply_order_detail'))) { $this->postProcessUpdateReceipt(); } // use template to create a supply order if (Tools::isSubmit('create_supply_order') && Tools::isSubmit('id_supply_order')) { $this->postProcessCopyFromTemplate(); } // Export PDF of supply order if (Tools::isSubmit('submitAction') && Tools::getValue('submitAction') == 'generateSupplyOrderFormPDF') { $this->processGenerateSupplyOrderFormPDF(); } // Export PDF of receiving slip if (Tools::isSubmit('submitAction') && Tools::getValue('submitAction') == 'generateSupplyReceivingSlipFormPDF') { $this->processGenerateSupplyReceivingSlipFormPDF(); } if (!count($this->errors) && $this->is_editing_order || !$this->is_editing_order) { parent::postProcess(); } }
public function __construct($id_product = NULL, $full = false, $id_lang = NULL) { parent::__construct($id_product, $id_lang); if ($full and $this->id) { $this->manufacturer_name = Manufacturer::getNameById(intval($this->id_manufacturer)); $this->supplier_name = Supplier::getNameById(intval($this->id_supplier)); $tax = new Tax(intval($this->id_tax), intval($id_lang)); $this->tax_name = $tax->name; $this->tax_rate = floatval($tax->rate); $this->new = $this->isNew(); } if ($this->id_category_default) { $this->category = Category::getLinkRewrite(intval($this->id_category_default), intval($id_lang)); } if ($this->id) { $this->tags = Tag::getProductTags(intval($this->id)); } }
public function __construct($id_product = NULL, $full = false, $id_lang = NULL) { parent::__construct($id_product, $id_lang); if ($full and $this->id) { $this->manufacturer_name = Manufacturer::getNameById(intval($this->id_manufacturer)); $this->supplier_name = Supplier::getNameById(intval($this->id_supplier)); if (!class_exists("Vendor", false)) { include_once dirname(__FILE__) . '/../modules/ordervendor/Vendor.php'; } $this->vendor_name = Vendor::getNameById(intval($this->id_vendor)); } $this->category = Category::getLinkRewrite(intval($this->id_category_default), intval($id_lang)); $this->tags = Tag::getProductTags($this->id); }