<?php /* * 2007-2014 PrestaShop * * NOTICE OF LICENSE * * This source file is subject to the Academic Free License (AFL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/afl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@prestashop.com so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade PrestaShop to newer * versions in the future. If you wish to customize PrestaShop for your * needs please refer to http://www.prestashop.com for more information. * * @author PrestaShop SA <*****@*****.**> * @copyright 2007-2014 PrestaShop SA * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registred Trademark & Property of PrestaShop SA */ include dirname(__FILE__) . '/../../config/config.inc.php'; include dirname(__FILE__) . '/../../init.php'; include dirname(__FILE__) . '/converttopdf.php'; $convertpdf = new ConvertToPDF(); echo $convertpdf->ajaxCall();
/** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { parent::initContent(); if (!$this->errors) { $webservice_exi = new SoapClient('http://www2.promoshop.com.mx/ws_store/service.asmx?WSDL'); $parameter = array("ItemNumber" => $this->product->item_number, "key" => EXIMAGEN_KEY); $inventory = $webservice_exi->GetInventory($parameter); if (isset($inventory->GetInventoryResult->InventoryData->SKU)) { $inventory = $inventory->GetInventoryResult; } else { $inventory = $inventory->GetInventoryResult->InventoryData; } $quote_table = ""; $decoration_list = ''; $decoration = json_decode($this->product->decoration_details); if (!isset($decoration->areasimp->ItemNumber)) { $decoration = $decoration->areasimp; } foreach ($decoration as $deco) { $decoration_list .= $deco->TecnicaFull . ', '; } $decoration_list = substr($decoration_list, 0, -2); $margin = Configuration::get('PROFIT_MARGIN'); $price_type = Configuration::get('PRODUCT_DYNAMIC_PRICE'); if (isset($margin) && $price_type == 1) { $margin = floatval($margin) / 100; $margin = 1 - $margin; $this->product->base_price = $this->product->base_price / $margin; } else { $margin = 1; } if ($this->product->quick_quote != '') { $quote = json_decode($this->product->quick_quote); $quote_table_pdf = array(); //var_dump($this->product->quick_quote); foreach ($quote->PricesArray->Prices as $price) { $quote_table .= "<tr><td>" . $price->Piezas; $quote_table_pdf1 = array(); $quote_table_pdf1['piezas'] = $price->Piezas; $precio = $price->Precio; $precio = floatval($precio) / $margin; $precio_imp = $price->PrecioImp; $precio_imp = floatval($precio_imp) / $margin; if (intval($price->Piezas) < 10) { $quote_table .= " Muestra"; $quote_table_pdf1['piezas'] .= " Muestra"; } else { $quote_table .= " Piezas"; $quote_table_pdf1['piezas'] .= " Piezas"; } $quote_table .= "</td>"; $quote_table .= "<td>\$" . number_format($precio, 2) . "</td>"; $quote_table_pdf1['precio'] = "\$" . number_format($precio, 2); $quote_table .= "<td>\$" . number_format($precio_imp, 2) . "</td></tr>"; $quote_table_pdf1['precioImp'] = "\$" . number_format($precio_imp, 2); array_push($quote_table_pdf, $quote_table_pdf1); } } $link = new Link(); $productUrl = $link->getProductLink($this->product); if (Pack::isPack((int) $this->product->id) && !Pack::isInStock((int) $this->product->id)) { $this->product->quantity = 0; } $this->product->description = $this->transformDescriptionWithImg($this->product->description); // Assign to the template the id of the virtual product. "0" if the product is not downloadable. $this->context->smarty->assign('virtual', ProductDownload::getIdFromIdProduct((int) $this->product->id)); $this->context->smarty->assign('customizationFormTarget', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI']))); if (Tools::isSubmit('submitCustomizedDatas')) { // If cart has not been saved, we need to do it so that customization fields can have an id_cart // We check that the cookie exists first to avoid ghost carts if (!$this->context->cart->id && isset($_COOKIE[$this->context->cookie->getName()])) { $this->context->cart->add(); $this->context->cookie->id_cart = (int) $this->context->cart->id; } $this->pictureUpload(); $this->textRecord(); $this->formTargetFormat(); } else { if (Tools::getIsset('deletePicture') && !$this->context->cart->deleteCustomizationToProduct($this->product->id, Tools::getValue('deletePicture'))) { $this->errors[] = Tools::displayError('An error occurred while deleting the selected picture.'); } } $pictures = array(); $text_fields = array(); if ($this->product->customizable) { $files = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_FILE, true); foreach ($files as $file) { $pictures['pictures_' . $this->product->id . '_' . $file['index']] = $file['value']; } $texts = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_TEXTFIELD, true); foreach ($texts as $text_field) { $text_fields['textFields_' . $this->product->id . '_' . $text_field['index']] = str_replace('<br />', "\n", $text_field['value']); } } $this->context->smarty->assign(array('pictures' => $pictures, 'textFields' => $text_fields)); $this->product->customization_required = false; $customizationFields = $this->product->customizable ? $this->product->getCustomizationFields($this->context->language->id) : false; if (is_array($customizationFields)) { foreach ($customizationFields as $customizationField) { if ($this->product->customization_required = $customizationField['required']) { break; } } } // Assign template vars related to the category + execute hooks related to the category $this->assignCategory(); // Assign template vars related to the price and tax $this->assignPriceAndTax(); // Assign template vars related to the images $this->assignImages(); // Assign attribute groups to the template $this->assignAttributesGroups(); // Assign attributes combinations to the template $this->assignAttributesCombinations(); // Pack management $pack_items = $this->product->cache_is_pack ? Pack::getItemTable($this->product->id, $this->context->language->id, true) : array(); $this->context->smarty->assign('packItems', $pack_items); $this->context->smarty->assign('packs', Pack::getPacksTable($this->product->id, $this->context->language->id, true, 1)); $converttopdf = new ConvertToPDF(); $product_download_btn = ''; if ((int) Configuration::get('PRODUCT_DOWNLOAD_BUTTON')) { $product_download_btn = $converttopdf->hookdisplayconverttopdf(); } $product_price = $this->product->getPrice(true, NULL, 2); $product_info_pdf = array("name" => $this->product->name, "reference" => $this->product->reference, "condition" => $this->product->condition, "details" => $this->product->description, "price" => $product_price, "color" => $color, "decoration" => $decoration_list); $inventory_column = array(array("title" => "Producto", "key" => "SKU"), array("title" => "Fiscal", "key" => "WHS01"), array("title" => "Cedis", "key" => "WHS02"), array("title" => "DF", "key" => "WHS30"), array("title" => "Suma", "key" => "WHSEXT"), array("title" => "Apartado", "key" => "Sum"), array("title" => "Disponible", "key" => "Commited"), array("title" => "Compras", "key" => "Available"), array("title" => "Fecha de Llegada", "key" => "OnTransit")); $inventory_column = json_encode($inventory_column); if (isset($inventory->InventoryData)) { $inventory_data = json_encode(array($inventory->InventoryData)); } else { $inventory_data = json_encode($inventory); } $quick_quote_column = array(array("title" => "Piezas Pedido", "key" => "piezas"), array("title" => "Precio Producto", "key" => "precio"), array("title" => "Precio Producto + Impresion", "key" => "precioImp")); $quick_quote_column = json_encode($quick_quote_column); $quick_quote_data = json_encode($quote_table_pdf); if (isset($this->category->id) && $this->category->id) { $return_link = Tools::safeOutput($this->context->link->getCategoryLink($this->category)); } else { $return_link = 'javascript: history.back();'; } $profit_margin = 1; if ($price_type) { $profit_margin = $margin; } $this->context->smarty->assign(array('stock_management' => Configuration::get('PS_STOCK_MANAGEMENT'), 'customizationFields' => $customizationFields, 'accessories' => $this->product->getAccessories($this->context->language->id), 'return_link' => $return_link, 'product' => $this->product, 'inventory_column' => $inventory_column, 'inventory_data' => $inventory_data, 'profit_margin' => $profit_margin, 'quick_quote_column' => $quick_quote_column, 'quick_quote_data' => $quick_quote_data, 'product_info_pdf' => json_encode($product_info_pdf), 'product_manufacturer' => new Manufacturer((int) $this->product->id_manufacturer, $this->context->language->id), 'token' => Tools::getToken(false), 'features' => $this->product->getFrontFeatures($this->context->language->id), 'attachments' => $this->product->cache_has_attachments ? $this->product->getAttachments($this->context->language->id) : array(), 'allow_oosp' => $this->product->isAvailableWhenOutOfStock((int) $this->product->out_of_stock), 'last_qties' => (int) Configuration::get('PS_LAST_QTIES'), 'show_request_sample' => (int) Configuration::get('PRODUCT_REQUEST_SAMPLE'), 'HOOK_EXTRA_LEFT' => Hook::exec('displayLeftColumnProduct'), 'HOOK_EXTRA_RIGHT' => Hook::exec('displayRightColumnProduct'), 'HOOK_PRODUCT_OOS' => Hook::exec('actionProductOutOfStock', array('product' => $this->product)), 'HOOK_PRODUCT_ACTIONS' => Hook::exec('displayProductButtons', array('product' => $this->product)), 'HOOK_PRODUCT_TAB' => Hook::exec('displayProductTab', array('product' => $this->product)), 'HOOK_PRODUCT_TAB_CONTENT' => Hook::exec('displayProductTabContent', array('product' => $this->product)), 'HOOK_PRODUCT_CONTENT' => Hook::exec('displayProductContent', array('product' => $this->product)), 'HOOK_PRODUCT_FILE_CONTENT' => Hook::exec('productFileContent', array('product' => $this->product)), 'HOOK_PRODUCT_FILE' => Hook::exec('productFile', array('product' => $this->product)), 'HOOK_CUSTOM_QUOTE' => Hook::exec('displayProductcustomquote', array('product' => $this->product, 'customizationFields' => $customizationFields)), 'HOOK_PRODUCT_DOWNLOAD' => $product_download_btn, 'display_qties' => (int) Configuration::get('PS_DISPLAY_QTIES'), 'display_ht' => !Tax::excludeTaxeOption(), 'currencySign' => $this->context->currency->sign, 'currencyRate' => $this->context->currency->conversion_rate, 'currencyFormat' => $this->context->currency->format, 'currencyBlank' => $this->context->currency->blank, 'jqZoomEnabled' => Configuration::get('PS_DISPLAY_JQZOOM'), 'ENT_NOQUOTES' => ENT_NOQUOTES, 'outOfStockAllowed' => (int) Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'errors' => $this->errors, 'quote_table_detail' => $quote_table, 'inventory' => $inventory, 'decoration_list' => $decoration_list, 'product_url' => $productUrl, 'body_classes' => array($this->php_self . '-' . $this->product->id, $this->php_self . '-' . $this->product->link_rewrite, 'category-' . (isset($this->category) ? $this->category->id : ''), 'category-' . (isset($this->category) ? $this->category->getFieldByLang('link_rewrite') : '')), 'display_discount_price' => Configuration::get('PS_DISPLAY_DISCOUNT_PRICE'))); } $this->setTemplate(_PS_THEME_DIR_ . 'product.tpl'); }