Exemplo n.º 1
0
 public function postProcess()
 {
     ${"GLOBALS"}["blpimnned"] = "id_order_seller";
     $dbodbxes = "id_order";
     ${${"GLOBALS"}["qusrvgm"]} = (int) Tools::getValue("id_order");
     if (!$this->context->customer->isLogged() && !Tools::getValue("secure_key")) {
         Tools::redirect("index.php?controller=authentication&back=my-account");
     }
     ${"GLOBALS"}["tvasln"] = "id_order";
     $jpdhpfqcj = "id_order";
     if (!(int) Configuration::get("PS_INVOICE")) {
         die(Tools::displayError("Invoices are disabled in this shop."));
     }
     if (isset(${${"GLOBALS"}["qusrvgm"]}) && Validate::isUnsignedId(${$dbodbxes})) {
         ${${"GLOBALS"}["ymjzko"]} = new Order(${$jpdhpfqcj});
     }
     if (!isset(${${"GLOBALS"}["ymjzko"]}) || !Validate::isLoadedObject(${${"GLOBALS"}["ymjzko"]})) {
         die(Tools::displayError("Invoice not found"));
     }
     ${${"GLOBALS"}["vewtbt"]} = AgileSellerManager::getObjectOwnerID("order", ${${"GLOBALS"}["tvasln"]});
     ${${"GLOBALS"}["sokafjqdei"]} = AgileSellerManager::getLinkedSellerID($this->context->customer->id);
     if (${${"GLOBALS"}["blpimnned"]} != ${${"GLOBALS"}["sokafjqdei"]}) {
         die(Tools::displayError("You do not have permission to see this invoice"));
     }
     if (Tools::isSubmit("secure_key") && $order->secure_key != Tools::getValue("secure_key")) {
         die(Tools::displayError("You do not have permission to see this invoice"));
     }
     if (!OrderState::invoiceAvailable($order->getCurrentState()) && !$order->invoice_number) {
         die(Tools::displayError("No invoice available"));
     }
     $this->order = ${${"GLOBALS"}["ymjzko"]};
 }
Exemplo n.º 2
0
 public static function getUrlToInvoice($order, $context)
 {
     $url_to_invoice = '';
     if ((bool) Configuration::get('PS_INVOICE') && OrderState::invoiceAvailable($order->current_state) && count($order->getInvoicesCollection())) {
         $url_to_invoice = $context->link->getPageLink('pdf-invoice', true, null, 'id_order=' . $order->id);
         if ($context->cookie->is_guest) {
             $url_to_invoice .= '&secure_key=' . $order->secure_key;
         }
     }
     return $url_to_invoice;
 }
 public function process()
 {
     parent::process();
     if ($id_order = Tools::getValue('id_order') and $email = Tools::getValue('email')) {
         $order = new Order((int) $id_order);
         if (!Validate::isLoadedObject($order)) {
             $this->errors[] = Tools::displayError('Invalid order');
         } elseif (!$order->isAssociatedAtGuest($email)) {
             $this->errors[] = Tools::displayError('Invalid order');
         } else {
             $customer = new Customer((int) $order->id_customer);
             $id_order_state = (int) $order->getCurrentState();
             $carrier = new Carrier((int) $order->id_carrier, (int) $order->id_lang);
             $addressInvoice = new Address((int) $order->id_address_invoice);
             $addressDelivery = new Address((int) $order->id_address_delivery);
             $inv_adr_fields = AddressFormat::getOrderedAddressFields($addressInvoice->id_country);
             $dlv_adr_fields = AddressFormat::getOrderedAddressFields($addressDelivery->id_country);
             $invoiceAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($addressInvoice, $inv_adr_fields);
             $deliveryAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($addressDelivery, $dlv_adr_fields);
             if ($order->total_discounts > 0) {
                 self::$smarty->assign('total_old', (double) ($order->total_paid - $order->total_discounts));
             }
             $products = $order->getProducts();
             $customizedDatas = Product::getAllCustomizedDatas((int) $order->id_cart);
             Product::addCustomizationPrice($products, $customizedDatas);
             $this->processAddressFormat($addressDelivery, $addressInvoice);
             self::$smarty->assign(array('shop_name' => Configuration::get('PS_SHOP_NAME'), 'order' => $order, 'return_allowed' => false, 'currency' => new Currency($order->id_currency), 'order_state' => (int) $id_order_state, 'invoiceAllowed' => (int) Configuration::get('PS_INVOICE'), 'invoice' => OrderState::invoiceAvailable((int) $id_order_state) and $order->invoice_number, 'order_history' => $order->getHistory((int) self::$cookie->id_lang, false, true), 'products' => $products, 'discounts' => $order->getDiscounts(), 'carrier' => $carrier, 'address_invoice' => $addressInvoice, 'invoiceState' => (Validate::isLoadedObject($addressInvoice) and $addressInvoice->id_state) ? new State((int) $addressInvoice->id_state) : false, 'address_delivery' => $addressDelivery, 'deliveryState' => (Validate::isLoadedObject($addressDelivery) and $addressDelivery->id_state) ? new State((int) $addressDelivery->id_state) : false, 'is_guest' => true, 'group_use_tax' => Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC, 'CUSTOMIZE_FILE' => _CUSTOMIZE_FILE_, 'CUSTOMIZE_TEXTFIELD' => _CUSTOMIZE_TEXTFIELD_, 'use_tax' => Configuration::get('PS_TAX'), 'customizedDatas' => $customizedDatas, 'invoiceAddressFormatedValues' => $invoiceAddressFormatedValues, 'deliveryAddressFormatedValues' => $deliveryAddressFormatedValues));
             if ($carrier->url and $order->shipping_number) {
                 self::$smarty->assign('followup', str_replace('@', $order->shipping_number, $carrier->url));
             }
             self::$smarty->assign('HOOK_ORDERDETAILDISPLAYED', Module::hookExec('orderDetailDisplayed', array('order' => $order)));
             Module::hookExec('OrderDetail', array('carrier' => $carrier, 'order' => $order));
             if (Tools::isSubmit('submitTransformGuestToCustomer')) {
                 $customer = new Customer((int) $order->id_customer);
                 if (!Validate::isLoadedObject($customer)) {
                     $this->errors[] = Tools::displayError('Invalid customer');
                 }
                 if (!$customer->transformToCustomer(self::$cookie->id_lang, Tools::getValue('password'))) {
                     $this->errors[] = Tools::displayError('An error occurred while transforming guest to customer.');
                 }
                 if (!Tools::getValue('password')) {
                     $this->errors[] = Tools::displayError('Invalid password');
                 } else {
                     self::$smarty->assign('transformSuccess', true);
                 }
             }
         }
         if (sizeof($this->errors)) {
             /* Handle brute force attacks */
             sleep(1);
         }
     }
     self::$smarty->assign(array('action' => 'guest-tracking.php', 'errors' => $this->errors));
 }
 public function postProcess()
 {
     if (!$this->context->customer->isLogged() && !Tools::getValue('secure_key')) {
         Tools::redirect('index.php?controller=authentication&back=pdf-invoice');
     }
     if (!(int) Configuration::get('PS_INVOICE')) {
         die(Tools::displayError('Invoices are disabled in this shop.'));
     }
     $id_order = (int) Tools::getValue('id_order');
     if (Validate::isUnsignedId($id_order)) {
         $order = new Order((int) $id_order);
     }
     if (!isset($order) || !Validate::isLoadedObject($order)) {
         die(Tools::displayError('The invoice was not found.'));
     }
     if (isset($this->context->customer->id) && $order->id_customer != $this->context->customer->id || Tools::isSubmit('secure_key') && $order->secure_key != Tools::getValue('secure_key')) {
         die(Tools::displayError('The invoice was not found.'));
     }
     if (!OrderState::invoiceAvailable($order->getCurrentState()) && !$order->invoice_number) {
         die(Tools::displayError('No invoice is available.'));
     }
     $this->order = $order;
 }
Exemplo n.º 5
0
 /**
  * Assign template vars related to order tracking informations
  */
 protected function assignOrderTracking($order_collection)
 {
     $customer = new Customer((int) $order_collection->getFirst()->id_customer);
     $order_collection = $order_collection->getAll();
     $order_list = array();
     foreach ($order_collection as $order) {
         $order_list[] = $order;
     }
     foreach ($order_list as &$order) {
         $order->id_order_state = (int) $order->getCurrentState();
         $order->invoice = OrderState::invoiceAvailable((int) $order->id_order_state) && $order->invoice_number;
         $order->order_history = $order->getHistory((int) $this->context->language->id, false, true);
         $order->carrier = new Carrier((int) $order->id_carrier, (int) $order->id_lang);
         $order->address_invoice = new Address((int) $order->id_address_invoice);
         $order->address_delivery = new Address((int) $order->id_address_delivery);
         $order->inv_adr_fields = AddressFormat::getOrderedAddressFields($order->address_invoice->id_country);
         $order->dlv_adr_fields = AddressFormat::getOrderedAddressFields($order->address_delivery->id_country);
         $order->invoiceAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($order->address_invoice, $order->inv_adr_fields);
         $order->deliveryAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($order->address_delivery, $order->dlv_adr_fields);
         $order->currency = new Currency($order->id_currency);
         $order->discounts = $order->getCartRules();
         $order->invoiceState = Validate::isLoadedObject($order->address_invoice) && $order->address_invoice->id_state ? new State((int) $order->address_invoice->id_state) : false;
         $order->deliveryState = Validate::isLoadedObject($order->address_delivery) && $order->address_delivery->id_state ? new State((int) $order->address_delivery->id_state) : false;
         $order->products = $order->getProducts();
         $order->customizedDatas = Product::getAllCustomizedDatas((int) $order->id_cart);
         Product::addCustomizationPrice($order->products, $order->customizedDatas);
         $order->total_old = $order->total_discounts > 0 ? (double) ($order->total_paid - $order->total_discounts) : false;
         if ($order->carrier->url && $order->shipping_number) {
             $order->followup = str_replace('@', $order->shipping_number, $order->carrier->url);
         }
         $order->hook_orderdetaildisplayed = Hook::exec('displayOrderDetail', array('order' => $order));
         Hook::exec('actionOrderDetail', array('carrier' => $order->carrier, 'order' => $order));
     }
     $this->context->smarty->assign(array('shop_name' => Configuration::get('PS_SHOP_NAME'), 'order_collection' => $order_list, 'return_allowed' => false, 'invoiceAllowed' => (int) Configuration::get('PS_INVOICE'), 'is_guest' => true, 'group_use_tax' => Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC, 'CUSTOMIZE_FILE' => _CUSTOMIZE_FILE_, 'CUSTOMIZE_TEXTFIELD' => _CUSTOMIZE_TEXTFIELD_, 'use_tax' => Configuration::get('PS_TAX')));
 }
Exemplo n.º 6
0
 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     if (!($id_order = (int) Tools::getValue('id_order')) || !Validate::isUnsignedId($id_order)) {
         $this->errors[] = Tools::displayError('Order ID required');
     } else {
         $order = new Order($id_order);
         if (Validate::isLoadedObject($order) && $order->id_customer == $this->context->customer->id) {
             $id_order_state = (int) $order->getCurrentState();
             $carrier = new Carrier((int) $order->id_carrier, (int) $order->id_lang);
             $addressInvoice = new Address((int) $order->id_address_invoice);
             $addressDelivery = new Address((int) $order->id_address_delivery);
             $inv_adr_fields = AddressFormat::getOrderedAddressFields($addressInvoice->id_country);
             $dlv_adr_fields = AddressFormat::getOrderedAddressFields($addressDelivery->id_country);
             $invoiceAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($addressInvoice, $inv_adr_fields);
             $deliveryAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($addressDelivery, $dlv_adr_fields);
             if ($order->total_discounts > 0) {
                 $this->context->smarty->assign('total_old', (double) ($order->total_paid - $order->total_discounts));
             }
             $products = $order->getProducts();
             /* DEPRECATED: customizedDatas @since 1.5 */
             $customizedDatas = Product::getAllCustomizedDatas((int) $order->id_cart);
             Product::addCustomizationPrice($products, $customizedDatas);
             OrderReturn::addReturnedQuantity($products, $order->id);
             $customer = new Customer($order->id_customer);
             $this->context->smarty->assign(array('shop_name' => strval(Configuration::get('PS_SHOP_NAME')), 'order' => $order, 'return_allowed' => (int) $order->isReturnable(), 'currency' => new Currency($order->id_currency), 'order_state' => (int) $id_order_state, 'invoiceAllowed' => (int) Configuration::get('PS_INVOICE'), 'invoice' => OrderState::invoiceAvailable($id_order_state) && count($order->getInvoicesCollection()), 'order_history' => $order->getHistory($this->context->language->id, false, true), 'products' => $products, 'discounts' => $order->getCartRules(), 'carrier' => $carrier, 'address_invoice' => $addressInvoice, 'invoiceState' => Validate::isLoadedObject($addressInvoice) && $addressInvoice->id_state ? new State($addressInvoice->id_state) : false, 'address_delivery' => $addressDelivery, 'inv_adr_fields' => $inv_adr_fields, 'dlv_adr_fields' => $dlv_adr_fields, 'invoiceAddressFormatedValues' => $invoiceAddressFormatedValues, 'deliveryAddressFormatedValues' => $deliveryAddressFormatedValues, 'deliveryState' => Validate::isLoadedObject($addressDelivery) && $addressDelivery->id_state ? new State($addressDelivery->id_state) : false, 'is_guest' => false, 'messages' => CustomerMessage::getMessagesByOrderId((int) $order->id, false), 'CUSTOMIZE_FILE' => Product::CUSTOMIZE_FILE, 'CUSTOMIZE_TEXTFIELD' => Product::CUSTOMIZE_TEXTFIELD, 'isRecyclable' => Configuration::get('PS_RECYCLABLE_PACK'), 'use_tax' => Configuration::get('PS_TAX'), 'group_use_tax' => Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC, 'customizedDatas' => $customizedDatas));
             if ($carrier->url && $order->shipping_number) {
                 $this->context->smarty->assign('followup', str_replace('@', $order->shipping_number, $carrier->url));
             }
             $this->context->smarty->assign('HOOK_ORDERDETAILDISPLAYED', Hook::exec('displayOrderDetail', array('order' => $order)));
             Hook::exec('actionOrderDetail', array('carrier' => $carrier, 'order' => $order));
             unset($carrier, $addressInvoice, $addressDelivery);
         } else {
             $this->errors[] = Tools::displayError('This order cannot be found.');
         }
         unset($order);
     }
     $this->setTemplate(_PS_THEME_DIR_ . 'order-detail.tpl');
 }
 public function preProcess()
 {
     parent::preProcess();
     if (Tools::isSubmit('submitMessage')) {
         $idOrder = (int) Tools::getValue('id_order');
         $msgText = htmlentities(Tools::getValue('msgText'), ENT_COMPAT, 'UTF-8');
         if (!$idOrder or !Validate::isUnsignedId($idOrder)) {
             $this->errors[] = Tools::displayError('Order is no longer valid');
         } elseif (empty($msgText)) {
             $this->errors[] = Tools::displayError('Message cannot be blank');
         } elseif (!Validate::isMessage($msgText)) {
             $this->errors[] = Tools::displayError('Message is invalid (HTML is not allowed)');
         }
         if (!sizeof($this->errors)) {
             $order = new Order((int) $idOrder);
             if (Validate::isLoadedObject($order) and $order->id_customer == self::$cookie->id_customer) {
                 $message = new Message();
                 $message->id_customer = (int) self::$cookie->id_customer;
                 $message->message = $msgText;
                 $message->id_order = (int) $idOrder;
                 $message->private = false;
                 $message->add();
                 if (!Configuration::get('PS_MAIL_EMAIL_MESSAGE')) {
                     $to = strval(Configuration::get('PS_SHOP_EMAIL'));
                 } else {
                     $to = new Contact((int) Configuration::get('PS_MAIL_EMAIL_MESSAGE'));
                     $to = strval($to->email);
                 }
                 $toName = strval(Configuration::get('PS_SHOP_NAME'));
                 $customer = new Customer((int) self::$cookie->id_customer);
                 if (Validate::isLoadedObject($customer)) {
                     Mail::Send((int) self::$cookie->id_lang, 'order_customer_comment', Mail::l('Message from a customer', (int) self::$cookie->id_lang), array('{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname, '{email}' => $customer->email, '{id_order}' => (int) $message->id_order, '{order_name}' => sprintf("#%06d", (int) $message->id_order), '{message}' => $message->message), $to, $toName, $customer->email, $customer->firstname . ' ' . $customer->lastname);
                 }
                 if (Tools::getValue('ajax') != 'true') {
                     Tools::redirect('order-detail.php?id_order=' . (int) $idOrder);
                 }
             } else {
                 $this->errors[] = Tools::displayError('Order not found');
             }
         }
     }
     if (!($id_order = (int) Tools::getValue('id_order')) or !Validate::isUnsignedId($id_order)) {
         $this->errors[] = Tools::displayError('Order ID required');
     } else {
         $order = new Order($id_order);
         if (Validate::isLoadedObject($order) and $order->id_customer == self::$cookie->id_customer) {
             $id_order_state = (int) $order->getCurrentState();
             $carrier = new Carrier((int) $order->id_carrier, (int) $order->id_lang);
             $addressInvoice = new Address((int) $order->id_address_invoice);
             $addressDelivery = new Address((int) $order->id_address_delivery);
             //	$stateInvoiceAddress = new State((int)$addressInvoice->id_state);
             $inv_adr_fields = AddressFormat::getOrderedAddressFields($addressInvoice->id_country);
             $dlv_adr_fields = AddressFormat::getOrderedAddressFields($addressDelivery->id_country);
             $invoiceAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($addressInvoice, $inv_adr_fields);
             $deliveryAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($addressDelivery, $dlv_adr_fields);
             if ($order->total_discounts > 0) {
                 self::$smarty->assign('total_old', (double) ($order->total_paid - $order->total_discounts));
             }
             $products = $order->getProducts();
             $customizedDatas = Product::getAllCustomizedDatas((int) $order->id_cart);
             Product::addCustomizationPrice($products, $customizedDatas);
             $customer = new Customer($order->id_customer);
             self::$smarty->assign(array('shop_name' => strval(Configuration::get('PS_SHOP_NAME')), 'order' => $order, 'return_allowed' => (int) $order->isReturnable(), 'currency' => new Currency($order->id_currency), 'order_state' => (int) $id_order_state, 'invoiceAllowed' => (int) Configuration::get('PS_INVOICE'), 'invoice' => OrderState::invoiceAvailable((int) $id_order_state) and $order->invoice_number, 'order_history' => $order->getHistory((int) self::$cookie->id_lang, false, true), 'products' => $products, 'discounts' => $order->getDiscounts(), 'carrier' => $carrier, 'address_invoice' => $addressInvoice, 'invoiceState' => (Validate::isLoadedObject($addressInvoice) and $addressInvoice->id_state) ? new State((int) $addressInvoice->id_state) : false, 'address_delivery' => $addressDelivery, 'inv_adr_fields' => $inv_adr_fields, 'dlv_adr_fields' => $dlv_adr_fields, 'invoiceAddressFormatedValues' => $invoiceAddressFormatedValues, 'deliveryAddressFormatedValues' => $deliveryAddressFormatedValues, 'deliveryState' => (Validate::isLoadedObject($addressDelivery) and $addressDelivery->id_state) ? new State((int) $addressDelivery->id_state) : false, 'is_guest' => false, 'messages' => Message::getMessagesByOrderId((int) $order->id), 'CUSTOMIZE_FILE' => _CUSTOMIZE_FILE_, 'CUSTOMIZE_TEXTFIELD' => _CUSTOMIZE_TEXTFIELD_, 'isRecyclable' => Configuration::get('PS_RECYCLABLE_PACK'), 'use_tax' => Configuration::get('PS_TAX'), 'group_use_tax' => Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC, 'customizedDatas' => $customizedDatas));
             if ($carrier->url and $order->shipping_number) {
                 self::$smarty->assign('followup', str_replace('@', $order->shipping_number, $carrier->url));
             }
             self::$smarty->assign('HOOK_ORDERDETAILDISPLAYED', Module::hookExec('orderDetailDisplayed', array('order' => $order)));
             Module::hookExec('OrderDetail', array('carrier' => $carrier, 'order' => $order));
             unset($carrier);
             unset($addressInvoice);
             unset($addressDelivery);
         } else {
             $this->errors[] = Tools::displayError('Cannot find this order');
         }
         unset($order);
     }
 }
Exemplo n.º 8
0
 /**
  * Main
  *
  * @param object $order Order
  * @param string $mode Download or display (optional)
  */
 public static function invoice($order, $mode = 'D', $multiple = false, &$pdf = NULL, $slip = false, $delivery = false)
 {
     global $cookie;
     if (!Validate::isLoadedObject($order) or !$cookie->id_employee and (!OrderState::invoiceAvailable($order->getCurrentState()) and !$order->invoice_number)) {
         die('Invalid order or invalid order state');
     }
     self::$order = $order;
     self::$orderSlip = $slip;
     self::$delivery = $delivery;
     self::$_iso = strtoupper(Language::getIsoById((int) self::$order->id_lang));
     if ((self::$_priceDisplayMethod = $order->getTaxCalculationMethod()) === false) {
         die(self::l('No price display method defined for the customer group'));
     }
     if (!$multiple) {
         $pdf = new PDF('P', 'mm', 'A4');
     }
     $pdf->SetAutoPageBreak(true, 35);
     $pdf->StartPageGroup();
     self::$currency = Currency::getCurrencyInstance((int) self::$order->id_currency);
     $pdf->AliasNbPages();
     $pdf->AddPage();
     $width = 100;
     $pdf->SetX(10);
     $pdf->SetY(25);
     $pdf->SetFont(self::fontname(), '', 12);
     $pdf->Cell($width, 10, self::l('Delivery'), 0, 'L');
     $pdf->Cell($width, 10, self::l('Invoicing'), 0, 'L');
     $pdf->Ln(5);
     $pdf->SetFont(self::fontname(), '', 9);
     $addressType = array('delivery' => array(), 'invoice' => array());
     $patternRules = array('optional' => array('address2', 'company'), 'avoid' => array('State:iso_code'));
     $addressType = self::generateHeaderAddresses($pdf, $order, $addressType, $patternRules, $width);
     if (Configuration::get('VATNUMBER_MANAGEMENT') and !empty($addressType['invoice']['addressObject']->vat_number)) {
         $vat_delivery = '';
         if ($addressType['invoice']['addressObject']->id != $addressType['delivery']['addressObject']->id) {
             $vat_delivery = $addressType['delivery']['addressObject']->vat_number;
         }
         $pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $vat_delivery), 0, 'L');
         $pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $addressType['invoice']['addressObject']->vat_number), 0, 'L');
         $pdf->Ln(5);
     }
     if ($addressType['invoice']['addressObject']->dni != NULL) {
         $pdf->Cell($width, 10, self::l('Tax ID number:') . ' ' . Tools::iconv('utf-8', self::encoding(), $addressType['invoice']['addressObject']->dni), 0, 'L');
     }
     /*
      * display order information
      */
     $carrier = new Carrier(self::$order->id_carrier);
     if ($carrier->name == '0') {
         $carrier->name = Configuration::get('PS_SHOP_NAME');
     }
     $history = self::$order->getHistory(self::$order->id_lang);
     foreach ($history as $h) {
         if ($h['id_order_state'] == Configuration::get('PS_OS_SHIPPING')) {
             $shipping_date = $h['date_add'];
         }
     }
     $pdf->Ln(12);
     $pdf->SetFillColor(240, 240, 240);
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetFont(self::fontname(), '', 9);
     if (self::$orderSlip) {
         $pdf->Cell(0, 6, self::l('SLIP #') . ' ' . sprintf('%06d', self::$orderSlip->id) . ' ' . self::l('from') . ' ' . Tools::displayDate(self::$orderSlip->date_upd, self::$order->id_lang), 1, 2, 'L', 1);
     } elseif (self::$delivery) {
         $pdf->Cell(0, 6, self::l('DELIVERY SLIP #') . Tools::iconv('utf-8', self::encoding(), Configuration::get('PS_DELIVERY_PREFIX', (int) $cookie->id_lang)) . sprintf('%06d', self::$delivery) . ' ' . self::l('from') . ' ' . Tools::displayDate(self::$order->delivery_date, self::$order->id_lang), 1, 2, 'L', 1);
     } elseif ((int) self::$order->invoice_date) {
         $pdf->Cell(0, 6, self::l('INVOICE #') . ' ' . Tools::iconv('utf-8', self::encoding(), Configuration::get('PS_INVOICE_PREFIX', (int) $cookie->id_lang)) . sprintf('%06d', self::$order->invoice_number) . ' ' . self::l('from') . ' ' . Tools::displayDate(self::$order->invoice_date, self::$order->id_lang), 1, 2, 'L', 1);
     } else {
         $pdf->Cell(0, 6, self::l('Invoice draft'), 1, 2, 'L', 1);
     }
     $pdf->Cell(55, 6, self::l('Order #') . ' ' . sprintf('%06d', self::$order->id), 'L', 0);
     $pdf->Cell(70, 6, self::l('Carrier:') . ($order->gift ? ' ' . Tools::iconv('utf-8', self::encoding(), $carrier->name) : ''), 'L');
     $pdf->Cell(0, 6, self::l('Payment method:'), 'LR');
     $pdf->Ln(5);
     $pdf->Cell(55, 6, isset($shipping_date) ? self::l('Shipping date:') . ' ' . Tools::displayDate($shipping_date, self::$order->id_lang) : ' ', 'LB', 0);
     $pdf->Cell(70, 6, $order->gift ? self::l('Gift-wrapped order') : Tools::iconv('utf-8', self::encoding(), $carrier->name), 'LRB');
     $pdf->Cell(0, 6, Tools::iconv('utf-8', self::encoding(), $order->payment), 'LRB');
     $pdf->Ln(15);
     $pdf->ProdTab(self::$delivery ? true : '');
     /* Canada */
     $taxable_address = new Address((int) self::$order->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
     if (!self::$delivery && strtoupper(Country::getIsoById((int) $taxable_address->id_country)) == 'CA') {
         $pdf->Ln(15);
         $taxToDisplay = Db::getInstance()->ExecuteS('SELECT * FROM ' . _DB_PREFIX_ . 'order_tax WHERE id_order = ' . (int) self::$order->id);
         foreach ($taxToDisplay as $t) {
             $pdf->Cell(0, 6, utf8_decode($t['tax_name']) . ' (' . number_format($t['tax_rate'], 2, '.', '') . '%)      ' . self::convertSign(Tools::displayPrice($t['amount'], self::$currency, true)), 0, 0, 'R');
             $pdf->Ln(5);
         }
     }
     /* End */
     /* Exit if delivery */
     if (!self::$delivery) {
         if (!self::$orderSlip) {
             $pdf->DiscTab();
         }
         $priceBreakDown = array();
         $pdf->priceBreakDownCalculation($priceBreakDown);
         if (!self::$orderSlip or self::$orderSlip and self::$orderSlip->shipping_cost) {
             $priceBreakDown['totalWithoutTax'] += Tools::ps_round($priceBreakDown['shippingCostWithoutTax'], 2) + Tools::ps_round($priceBreakDown['wrappingCostWithoutTax'], 2);
             $priceBreakDown['totalWithTax'] += self::$order->total_shipping + self::$order->total_wrapping;
         }
         if (!self::$orderSlip) {
             $taxDiscount = self::$order->getTaxesAverageUsed();
             if ($taxDiscount != 0) {
                 $priceBreakDown['totalWithoutTax'] -= Tools::ps_round(self::$order->total_discounts / (1 + self::$order->getTaxesAverageUsed() * 0.01), 2);
             } else {
                 $priceBreakDown['totalWithoutTax'] -= self::$order->total_discounts;
             }
             $priceBreakDown['totalWithTax'] -= self::$order->total_discounts;
         }
         /*
          * Display price summation
          */
         if (Configuration::get('PS_TAX') or $order->total_products_wt != $order->total_products) {
             $pdf->Ln(5);
             $pdf->SetFont(self::fontname(), 'B', 8);
             $width = 165;
             $pdf->Cell($width, 0, self::l('Total products (tax excl.)') . ' : ', 0, 0, 'R');
             $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice($priceBreakDown['totalProductsWithoutTax'], self::$currency, true)), 0, 0, 'R');
             $pdf->Ln(4);
             $pdf->SetFont(self::fontname(), 'B', 8);
             $width = 165;
             $pdf->Cell($width, 0, self::l('Total products (tax incl.)') . ' : ', 0, 0, 'R');
             $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice($priceBreakDown['totalProductsWithTax'], self::$currency, true)), 0, 0, 'R');
             $pdf->Ln(4);
         } else {
             $pdf->Ln(5);
             $pdf->SetFont(self::fontname(), 'B', 8);
             $width = 165;
             $pdf->Cell($width, 0, self::l('Total products ') . ' : ', 0, 0, 'R');
             $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice($priceBreakDown['totalProductsWithoutTax'], self::$currency, true)), 0, 0, 'R');
             $pdf->Ln(4);
         }
         if (!self::$orderSlip and self::$order->total_discounts != '0.00') {
             $pdf->Cell($width, 0, self::l('Total discounts (tax incl.)') . ' : ', 0, 0, 'R');
             $pdf->Cell(0, 0, (!self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice(self::$order->total_discounts, self::$currency, true)), 0, 0, 'R');
             $pdf->Ln(4);
         }
         if (isset(self::$order->total_wrapping) and (double) self::$order->total_wrapping > 0) {
             $pdf->Cell($width, 0, self::l('Total gift-wrapping') . ' : ', 0, 0, 'R');
             if (self::$_priceDisplayMethod == PS_TAX_EXC) {
                 $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice($priceBreakDown['wrappingCostWithoutTax'], self::$currency, true)), 0, 0, 'R');
             } else {
                 $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice(self::$order->total_wrapping, self::$currency, true)), 0, 0, 'R');
             }
             $pdf->Ln(4);
         }
         if (self::$order->total_shipping != '0.00' and (!self::$orderSlip or self::$orderSlip and self::$orderSlip->shipping_cost)) {
             if (self::$_priceDisplayMethod == PS_TAX_EXC) {
                 $pdf->Cell($width, 0, self::l('Total shipping (tax excl.)') . ' : ', 0, 0, 'R');
                 $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice(Tools::ps_round($priceBreakDown['shippingCostWithoutTax'], 2), self::$currency, true)), 0, 0, 'R');
             } else {
                 $pdf->Cell($width, 0, self::l('Total shipping (tax incl.)') . ' : ', 0, 0, 'R');
                 $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice(self::$order->total_shipping, self::$currency, true)), 0, 0, 'R');
             }
             $pdf->Ln(4);
         }
         if (Configuration::get('PS_TAX') or $order->total_products_wt != $order->total_products) {
             $pdf->Cell($width, 0, self::l('Total') . ' ' . (self::$_priceDisplayMethod == PS_TAX_EXC ? self::l(' (tax incl.)') : self::l(' (tax excl.)')) . ' : ', 0, 0, 'R');
             $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice(self::$_priceDisplayMethod == PS_TAX_EXC ? $priceBreakDown['totalWithTax'] : $priceBreakDown['totalWithoutTax'], self::$currency, true)), 0, 0, 'R');
             $pdf->Ln(4);
             $pdf->Cell($width, 0, self::l('Total') . ' ' . (self::$_priceDisplayMethod == PS_TAX_EXC ? self::l(' (tax excl.)') : self::l(' (tax incl.)')) . ' : ', 0, 0, 'R');
             $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice(self::$_priceDisplayMethod == PS_TAX_EXC ? $priceBreakDown['totalWithoutTax'] : $priceBreakDown['totalWithTax'], self::$currency, true)), 0, 0, 'R');
             $pdf->Ln(4);
         } else {
             $pdf->Cell($width, 0, self::l('Total') . ' : ', 0, 0, 'R');
             $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice($priceBreakDown['totalWithoutTax'], self::$currency, true)), 0, 0, 'R');
             $pdf->Ln(4);
         }
         $pdf->TaxTab($priceBreakDown);
     }
     Hook::PDFInvoice($pdf, self::$order->id);
     if (!$multiple) {
         return $pdf->Output(sprintf('%06d', self::$order->id) . '.pdf', $mode);
     }
 }
Exemplo n.º 9
0
 /**
  * Main
  *
  * @param object $order Order
  * @param string $mode Download or display (optional)
  */
 public static function invoice($order, $mode = 'D', $multiple = false, &$pdf = NULL, $slip = false, $delivery = false)
 {
     global $cookie, $ecotax;
     if (!Validate::isLoadedObject($order) or !$cookie->id_employee and (!OrderState::invoiceAvailable($order->getCurrentState()) and !$order->invoice_number)) {
         die('Invalid order or invalid order state');
     }
     self::$order = $order;
     self::$orderSlip = $slip;
     self::$delivery = $delivery;
     self::$_iso = strtoupper(Language::getIsoById(intval(self::$order->id_lang)));
     if ((self::$_priceDisplayMethod = $order->getTaxCalculationMethod()) === false) {
         die(self::l('No price display method defined for the customer group'));
     }
     if (!$multiple) {
         $pdf = new PDF('P', 'mm', 'A4');
     }
     $pdf->SetAutoPageBreak(true, 35);
     $pdf->StartPageGroup();
     self::$currency = Currency::getCurrencyInstance(intval(self::$order->id_currency));
     $pdf->AliasNbPages();
     $pdf->AddPage();
     /* Display address information */
     $invoice_address = new Address(intval($order->id_address_invoice));
     $invoiceState = $invoice_address->id_state ? new State($invoice_address->id_state) : false;
     $delivery_address = new Address(intval($order->id_address_delivery));
     $deliveryState = $delivery_address->id_state ? new State($delivery_address->id_state) : false;
     $shop_country = Configuration::get('PS_SHOP_COUNTRY');
     $invoice_customer = new Customer(intval($invoice_address->id_customer));
     $width = 100;
     $pdf->SetX(10);
     $pdf->SetY(25);
     $pdf->SetFont(self::fontname(), '', 12);
     $pdf->Cell($width, 10, self::l('Delivery'), 0, 'L');
     $pdf->Cell($width, 10, self::l('Invoicing'), 0, 'L');
     $pdf->Ln(5);
     $pdf->SetFont(self::fontname(), '', 9);
     if (!empty($delivery_address->company) or !empty($invoice_address->company)) {
         $pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $delivery_address->company), 0, 'L');
         $pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $invoice_address->company), 0, 'L');
         $pdf->Ln(5);
     }
     $pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $delivery_address->firstname) . ' ' . Tools::iconv('utf-8', self::encoding(), $delivery_address->lastname), 0, 'L');
     $pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $invoice_address->firstname) . ' ' . Tools::iconv('utf-8', self::encoding(), $invoice_address->lastname), 0, 'L');
     $pdf->Ln(5);
     $pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $delivery_address->address1), 0, 'L');
     $pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $invoice_address->address1), 0, 'L');
     $pdf->Ln(5);
     if (!empty($invoice_address->address2) or !empty($delivery_address->address2)) {
         $pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $delivery_address->address2), 0, 'L');
         $pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $invoice_address->address2), 0, 'L');
         $pdf->Ln(5);
     }
     $pdf->Cell($width, 10, $delivery_address->postcode . ' ' . Tools::iconv('utf-8', self::encoding(), $delivery_address->city), 0, 'L');
     $pdf->Cell($width, 10, $invoice_address->postcode . ' ' . Tools::iconv('utf-8', self::encoding(), $invoice_address->city), 0, 'L');
     $pdf->Ln(5);
     $pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $delivery_address->country . ($deliveryState ? ' - ' . $deliveryState->name : '')), 0, 'L');
     $pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $invoice_address->country . ($invoiceState ? ' - ' . $invoiceState->name : '')), 0, 'L');
     $pdf->Ln(5);
     $pdf->Cell($width, 10, $delivery_address->phone, 0, 'L');
     if ($invoice_customer->dni != NULL) {
         $pdf->Cell($width, 10, self::l('Tax ID number:') . ' ' . Tools::iconv('utf-8', self::encoding(), $invoice_customer->dni), 0, 'L');
     }
     if (!empty($delivery_address->phone_mobile)) {
         $pdf->Ln(5);
         $pdf->Cell($width, 10, $delivery_address->phone_mobile, 0, 'L');
     }
     /*
      * display order information
      */
     $carrier = new Carrier(self::$order->id_carrier);
     if ($carrier->name == '0') {
         $carrier->name = Configuration::get('PS_SHOP_NAME');
     }
     $history = self::$order->getHistory(self::$order->id_lang);
     foreach ($history as $h) {
         if ($h['id_order_state'] == _PS_OS_SHIPPING_) {
             $shipping_date = $h['date_add'];
         }
     }
     $pdf->Ln(12);
     $pdf->SetFillColor(240, 240, 240);
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetFont(self::fontname(), '', 9);
     if (self::$orderSlip) {
         $pdf->Cell(0, 6, self::l('SLIP #') . sprintf('%06d', self::$orderSlip->id) . ' ' . self::l('from') . ' ' . Tools::displayDate(self::$orderSlip->date_upd, self::$order->id_lang), 1, 2, 'L', 1);
     } elseif (self::$delivery) {
         $pdf->Cell(0, 6, self::l('DELIVERY SLIP #') . Configuration::get('PS_DELIVERY_PREFIX', intval($cookie->id_lang)) . sprintf('%06d', self::$delivery) . ' ' . self::l('from') . ' ' . Tools::displayDate(self::$order->delivery_date, self::$order->id_lang), 1, 2, 'L', 1);
     } else {
         $pdf->Cell(0, 6, self::l('INVOICE #') . Configuration::get('PS_INVOICE_PREFIX', intval($cookie->id_lang)) . sprintf('%06d', self::$order->invoice_number) . ' ' . self::l('from') . ' ' . Tools::displayDate(self::$order->invoice_date, self::$order->id_lang), 1, 2, 'L', 1);
     }
     $pdf->Cell(55, 6, self::l('Order #') . sprintf('%06d', self::$order->id), 'L', 0);
     $pdf->Cell(70, 6, self::l('Carrier:') . ($order->gift ? ' ' . Tools::iconv('utf-8', self::encoding(), $carrier->name) : ''), 'L');
     $pdf->Cell(0, 6, self::l('Payment method:'), 'LR');
     $pdf->Ln(5);
     $pdf->Cell(55, 6, isset($shipping_date) ? self::l('Shipping date:') . ' ' . Tools::displayDate($shipping_date, self::$order->id_lang) : ' ', 'LB', 0);
     $pdf->Cell(70, 6, $order->gift ? self::l('Gift-wrapped order') : Tools::iconv('utf-8', self::encoding(), $carrier->name), 'LRB');
     $pdf->Cell(0, 6, Tools::iconv('utf-8', self::encoding(), $order->payment), 'LRB');
     $pdf->Ln(15);
     $pdf->ProdTab(self::$delivery ? true : '');
     /* Exit if delivery */
     if (!self::$delivery) {
         if (!self::$orderSlip) {
             $pdf->DiscTab();
         }
         $priceBreakDown = array();
         $pdf->priceBreakDownCalculation($priceBreakDown);
         if (!self::$orderSlip or self::$orderSlip and self::$orderSlip->shipping_cost) {
             $priceBreakDown['totalWithoutTax'] += Tools::ps_round($priceBreakDown['shippingCostWithoutTax'], 2) + Tools::ps_round($priceBreakDown['wrappingCostWithoutTax'], 2);
             $priceBreakDown['totalWithTax'] += self::$order->total_shipping + self::$order->total_wrapping;
         }
         if (!self::$orderSlip) {
             $taxDiscount = self::$order->getTaxesAverageUsed();
             if ($taxDiscount != 0) {
                 $priceBreakDown['totalWithoutTax'] -= Tools::ps_round(self::$order->total_discounts / (1 + self::$order->getTaxesAverageUsed() * 0.01), 2);
             } else {
                 $priceBreakDown['totalWithoutTax'] -= self::$order->total_discounts;
             }
             $priceBreakDown['totalWithTax'] -= self::$order->total_discounts;
         }
         /*
          * Display price summation
          */
         if (Configuration::get('PS_TAX') or $order->total_products_wt != $order->total_products) {
             $pdf->Ln(5);
             $pdf->SetFont(self::fontname(), 'B', 8);
             $width = 165;
             $pdf->Cell($width, 0, self::l('Total products (tax excl.)') . ' : ', 0, 0, 'R');
             $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice($priceBreakDown['totalProductsWithoutTax'], self::$currency, true, false)), 0, 0, 'R');
             $pdf->Ln(4);
             $pdf->SetFont(self::fontname(), 'B', 8);
             $width = 165;
             $pdf->Cell($width, 0, self::l('Total products (tax incl.)') . ' : ', 0, 0, 'R');
             $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice($priceBreakDown['totalProductsWithTax'], self::$currency, true, false)), 0, 0, 'R');
             $pdf->Ln(4);
         } else {
             $pdf->Ln(5);
             $pdf->SetFont(self::fontname(), 'B', 8);
             $width = 165;
             $pdf->Cell($width, 0, self::l('Total products ') . ' : ', 0, 0, 'R');
             $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice($priceBreakDown['totalProductsWithoutTax'], self::$currency, true, false)), 0, 0, 'R');
             $pdf->Ln(4);
         }
         if (!self::$orderSlip and self::$order->total_discounts != '0.00') {
             $pdf->Cell($width, 0, self::l('Total discounts (tax incl.)') . ' : ', 0, 0, 'R');
             $pdf->Cell(0, 0, (!self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice(self::$order->total_discounts, self::$currency, true, false)), 0, 0, 'R');
             $pdf->Ln(4);
         }
         if (isset(self::$order->total_wrapping) and floatval(self::$order->total_wrapping) > 0) {
             $pdf->Cell($width, 0, self::l('Total wrapping') . ' : ', 0, 0, 'R');
             if (self::$_priceDisplayMethod == PS_TAX_EXC) {
                 $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice($priceBreakDown['wrappingCostWithoutTax'], self::$currency, true, false)), 0, 0, 'R');
             } else {
                 $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice(self::$order->total_wrapping, self::$currency, true, false)), 0, 0, 'R');
             }
             $pdf->Ln(4);
         }
         if (self::$order->total_shipping != '0.00' and (!self::$orderSlip or self::$orderSlip and self::$orderSlip->shipping_cost)) {
             $pdf->Cell($width, 0, self::l('Total shipping') . ' : ', 0, 0, 'R');
             if (self::$_priceDisplayMethod == PS_TAX_EXC) {
                 $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice(Tools::ps_round($priceBreakDown['shippingCostWithoutTax'], 2), self::$currency, true, false)), 0, 0, 'R');
             } else {
                 $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice(self::$order->total_shipping, self::$currency, true, false)), 0, 0, 'R');
             }
             $pdf->Ln(4);
         }
         if (Configuration::get('PS_TAX') or $order->total_products_wt != $order->total_products) {
             $pdf->Cell($width, 0, self::l('Total') . ' ' . (self::$_priceDisplayMethod == PS_TAX_EXC ? self::l(' (tax incl.)') : self::l(' (tax excl.)')) . ' : ', 0, 0, 'R');
             $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice(self::$_priceDisplayMethod == PS_TAX_EXC ? $priceBreakDown['totalWithTax'] : $priceBreakDown['totalWithoutTax'], self::$currency, true, false)), 0, 0, 'R');
             $pdf->Ln(4);
             $pdf->Cell($width, 0, self::l('Total') . ' ' . (self::$_priceDisplayMethod == PS_TAX_EXC ? self::l(' (tax excl.)') : self::l(' (tax incl.)')) . ' : ', 0, 0, 'R');
             $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice(self::$_priceDisplayMethod == PS_TAX_EXC ? $priceBreakDown['totalWithoutTax'] : $priceBreakDown['totalWithTax'], self::$currency, true, false)), 0, 0, 'R');
             $pdf->Ln(4);
         } else {
             $pdf->Cell($width, 0, self::l('Total') . ' : ', 0, 0, 'R');
             $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice($priceBreakDown['totalWithoutTax'], self::$currency, true, false)), 0, 0, 'R');
             $pdf->Ln(4);
         }
         if ($ecotax != '0.00' and !self::$orderSlip) {
             $pdf->Cell($width, 0, self::l('Eco-participation') . ' : ', 0, 0, 'R');
             $pdf->Cell(0, 0, self::convertSign(Tools::displayPrice($ecotax, self::$currency, true, false)), 0, 0, 'R');
             $pdf->Ln(5);
         }
         $pdf->TaxTab($priceBreakDown);
     }
     Hook::PDFInvoice($pdf, self::$order->id);
     if (!$multiple) {
         return $pdf->Output(sprintf('%06d', self::$order->id) . '.pdf', $mode);
     }
 }
 public function process()
 {
     parent::process();
     self::$smarty->assign(array('is_guest' => self::$cookie->is_guest, 'HOOK_ORDER_CONFIRMATION' => Hook::orderConfirmation((int) $this->id_order), 'HOOK_PAYMENT_RETURN' => Hook::paymentReturn((int) $this->id_order, (int) $this->id_module)));
     if (self::$cookie->is_guest) {
         self::$smarty->assign(array('id_order' => $this->id_order, 'id_order_formatted' => sprintf('#%06d', $this->id_order)));
         /* If guest we clear the cookie for security reason */
         self::$cookie->logout();
     } else {
         self::$smarty->assign(array('id_order' => $this->id_order, 'id_order_formatted' => sprintf('#%06d', $this->id_order)));
     }
     //assign order details here
     $order = new Order($this->id_order);
     if (Validate::isLoadedObject($order) and $order->id_customer == self::$cookie->id_customer) {
         $id_order_state = (int) $order->getCurrentState();
         $carrier = new Carrier((int) $order->id_carrier, (int) $order->id_lang);
         $addressInvoice = new Address((int) $order->id_address_invoice);
         $addressDelivery = new Address((int) $order->id_address_delivery);
         //	$stateInvoiceAddress = new State((int)$addressInvoice->id_state);
         $inv_adr_fields = AddressFormat::getOrderedAddressFields($addressInvoice->id_country);
         $dlv_adr_fields = AddressFormat::getOrderedAddressFields($addressDelivery->id_country);
         $invoiceAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($addressInvoice, $inv_adr_fields);
         $deliveryAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($addressDelivery, $dlv_adr_fields);
         if ($order->total_discounts > 0) {
             self::$smarty->assign('total_old', (double) ($order->total_paid - $order->total_discounts));
         }
         self::$smarty->assign('order_total', Tools::ps_round($order->total_paid));
         self::$smarty->assign('order_total_usd', Tools::ps_round(Tools::convertPrice($order->total_paid, self::$cookie->id_currency, false)));
         $products = $order->getProducts();
         $customizedDatas = Product::getAllCustomizedDatas((int) $order->id_cart);
         Product::addCustomizationPrice($products, $customizedDatas);
         $customer = new Customer($order->id_customer);
         $order->customization_fee = Cart::getCustomizationCostStatic((int) $order->id_cart);
         $totalQuantity = 0;
         foreach ($products as $productRow) {
             $totalQuantity += $productRow['product_quantity'];
         }
         if (strpos($order->payment, 'COD') === false) {
             self::$smarty->assign('paymentMethod', 'ONLINE');
         } else {
             self::$smarty->assign('paymentMethod', 'COD');
         }
         $shippingdate = new DateTime($order->expected_shipping_date);
         self::$smarty->assign(array('shipping_date' => $shippingdate->format("F j, Y"), 'shop_name' => strval(Configuration::get('PS_SHOP_NAME')), 'order' => $order, 'return_allowed' => (int) $order->isReturnable(), 'currency' => new Currency($order->id_currency), 'order_state' => (int) $id_order_state, 'invoiceAllowed' => (int) Configuration::get('PS_INVOICE'), 'invoice' => OrderState::invoiceAvailable((int) $id_order_state) and $order->invoice_number, 'order_history' => $order->getHistory((int) self::$cookie->id_lang, false, true), 'products' => $products, 'discounts' => $order->getDiscounts(), 'carrier' => $carrier, 'address_invoice' => $addressInvoice, 'invoiceState' => (Validate::isLoadedObject($addressInvoice) and $addressInvoice->id_state) ? new State((int) $addressInvoice->id_state) : false, 'address_delivery' => $addressDelivery, 'inv_adr_fields' => $inv_adr_fields, 'dlv_adr_fields' => $dlv_adr_fields, 'invoiceAddressFormatedValues' => $invoiceAddressFormatedValues, 'deliveryAddressFormatedValues' => $deliveryAddressFormatedValues, 'deliveryState' => (Validate::isLoadedObject($addressDelivery) and $addressDelivery->id_state) ? new State((int) $addressDelivery->id_state) : false, 'is_guest' => false, 'messages' => Message::getMessagesByOrderId((int) $order->id), 'CUSTOMIZE_FILE' => _CUSTOMIZE_FILE_, 'CUSTOMIZE_TEXTFIELD' => _CUSTOMIZE_TEXTFIELD_, 'use_tax' => Configuration::get('PS_TAX'), 'group_use_tax' => Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC, 'customizedDatas' => $customizedDatas, 'totalQuantity' => $totalQuantity));
         if ($carrier->url and $order->shipping_number) {
             self::$smarty->assign('followup', str_replace('@', $order->shipping_number, $carrier->url));
         }
         self::$smarty->assign('HOOK_ORDERDETAILDISPLAYED', Module::hookExec('orderDetailDisplayed', array('order' => $order)));
         Module::hookExec('OrderDetail', array('carrier' => $carrier, 'order' => $order));
         //FB Share
         //$products = $order->getProducts();
         $orderProducts = array();
         $productMaxVal = 0;
         $productMaxId = null;
         foreach ($products as $product) {
             array_push($orderProducts, $product['product_id']);
             if ($product['product_price'] > $productMaxVal) {
                 $productMaxId = $product['product_id'];
                 $productMaxVal = $product['product_price'];
             }
         }
         $productObj = new Product($productMaxId, true, 1);
         self::$smarty->assign('fbShareProductObject', $productObj->getLink());
         self::$smarty->assign('fbShareProductObjectId', $productMaxId);
         self::$smarty->assign('orderProducts', implode(",", $orderProducts));
         self::$cookie->shareProductCode = md5(time() . $productMaxId);
         self::$cookie->write();
         unset($carrier);
         unset($addressInvoice);
         unset($addressDelivery);
     }
 }
Exemplo n.º 11
0
*
* 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-2013 PrestaShop SA
*  @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*/
include dirname(__FILE__) . '/config/config.inc.php';
include dirname(__FILE__) . '/init.php';
$cookie = new Cookie('ps');
if (!$cookie->isLogged() and !Tools::getValue('secure_key')) {
    Tools::redirect('authentication.php?back=pdf-invoice.php');
}
if (!(int) Configuration::get('PS_INVOICE')) {
    die(Tools::displayError('Invoices are disabled in this shop.'));
}
if (isset($_GET['id_order']) and Validate::isUnsignedId($_GET['id_order'])) {
    $order = new Order((int) $_GET['id_order']);
}
if (!isset($order) or !Validate::isLoadedObject($order)) {
    die(Tools::displayError('Invoice not found'));
} elseif (isset($cookie->id_customer) and $order->id_customer != $cookie->id_customer or Tools::isSubmit('secure_key') and $order->secure_key != Tools::getValue('secure_key')) {
    die(Tools::displayError('Invoice not found'));
} elseif (!OrderState::invoiceAvailable($order->getCurrentState()) and !$order->invoice_number) {
    die(Tools::displayError('No invoice available'));
} else {
    PDF::invoice($order, 'I');
}
Exemplo n.º 12
0
if (!($id_order = intval(Tools::getValue('id_order'))) or !Validate::isUnsignedId($id_order)) {
    $errors[] = Tools::displayError('order ID is required');
} else {
    $order = new Order($id_order);
    if (Validate::isLoadedObject($order) and $order->id_customer == $cookie->id_customer) {
        $id_order_state = intval($order->getCurrentState());
        $carrier = new Carrier(intval($order->id_carrier), intval($order->id_lang));
        $addressInvoice = new Address(intval($order->id_address_invoice));
        $addressDelivery = new Address(intval($order->id_address_delivery));
        if ($order->total_discounts > 0) {
            $smarty->assign('total_old', floatval($order->total_paid - $order->total_discounts));
        }
        $products = $order->getProducts();
        $customizedDatas = Product::getAllCustomizedDatas(intval($order->id_cart));
        Product::addCustomizationPrice($products, $customizedDatas);
        $smarty->assign(array('shop_name' => strval(Configuration::get('PS_SHOP_NAME')), 'order' => $order, 'return_allowed' => intval($order->isReturnable()), 'currency' => new Currency($order->id_currency), 'order_state' => intval($id_order_state), 'invoiceAllowed' => intval(Configuration::get('PS_INVOICE')), 'invoice' => OrderState::invoiceAvailable(intval($id_order_state)) or $order->invoice_number, 'order_history' => $order->getHistory(intval($cookie->id_lang), false, true), 'products' => $products, 'discounts' => $order->getDiscounts(), 'carrier' => $carrier, 'address_invoice' => $addressInvoice, 'invoiceState' => (Validate::isLoadedObject($addressInvoice) and $addressInvoice->id_state) ? new State(intval($addressInvoice->id_state)) : false, 'address_delivery' => $addressDelivery, 'deliveryState' => (Validate::isLoadedObject($addressDelivery) and $addressDelivery->id_state) ? new State(intval($addressDelivery->id_state)) : false, 'messages' => Message::getMessagesByOrderId(intval($order->id)), 'CUSTOMIZE_FILE' => _CUSTOMIZE_FILE_, 'CUSTOMIZE_TEXTFIELD' => _CUSTOMIZE_TEXTFIELD_, 'customizedDatas' => $customizedDatas));
        if ($carrier->url and $order->shipping_number) {
            $smarty->assign('followup', str_replace('@', $order->shipping_number, $carrier->url));
        }
    } else {
        $errors[] = Tools::displayError('cannot find this order');
    }
}
$smarty->assign('errors', $errors);
if (Tools::getValue('ajax') == 'true') {
    $smarty->display(_PS_THEME_DIR_ . 'order-detail.tpl');
} else {
    include dirname(__FILE__) . '/header.php';
    $smarty->display(_PS_THEME_DIR_ . 'order-detail.tpl');
    include dirname(__FILE__) . '/footer.php';
}
 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     if (!($id_order = (int) Tools::getValue('id_order')) || !Validate::isUnsignedId($id_order)) {
         $this->errors[] = Tools::displayError('Order ID required');
     } else {
         $order = new Order($id_order);
         if (Validate::isLoadedObject($order) && $order->id_customer == $this->context->customer->id) {
             $id_order_state = (int) $order->getCurrentState();
             $carrier = new Carrier((int) $order->id_carrier, (int) $order->id_lang);
             $addressInvoice = new Address((int) $order->id_address_invoice);
             $addressDelivery = new Address((int) $order->id_address_delivery);
             $inv_adr_fields = AddressFormat::getOrderedAddressFields($addressInvoice->id_country);
             $dlv_adr_fields = AddressFormat::getOrderedAddressFields($addressDelivery->id_country);
             $invoiceAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($addressInvoice, $inv_adr_fields);
             $deliveryAddressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($addressDelivery, $dlv_adr_fields);
             if ($order->total_discounts > 0) {
                 $this->context->smarty->assign('total_old', (double) $order->total_paid - $order->total_discounts);
             }
             $products = $order->getProducts();
             /* DEPRECATED: customizedDatas @since 1.5 */
             $customizedDatas = Product::getAllCustomizedDatas((int) $order->id_cart);
             Product::addCustomizationPrice($products, $customizedDatas);
             OrderReturn::addReturnedQuantity($products, $order->id);
             $order_status = new OrderState((int) $id_order_state, (int) $order->id_lang);
             $customer = new Customer($order->id_customer);
             //by webkul to show order details properly on order history page
             if (Module::isInstalled('hotelreservationsystem')) {
                 require_once _PS_MODULE_DIR_ . 'hotelreservationsystem/define.php';
                 $obj_cart_bk_data = new HotelCartBookingData();
                 $obj_htl_bk_dtl = new HotelBookingDetail();
                 $obj_rm_type = new HotelRoomType();
                 if (!empty($products)) {
                     foreach ($products as $type_key => $type_value) {
                         $product = new Product($type_value['product_id'], false, $this->context->language->id);
                         $cover_image_arr = $product->getCover($type_value['product_id']);
                         if (!empty($cover_image_arr)) {
                             $cover_img = $this->context->link->getImageLink($product->link_rewrite, $product->id . '-' . $cover_image_arr['id_image'], 'small_default');
                         } else {
                             $cover_img = $this->context->link->getImageLink($product->link_rewrite, $this->context->language->iso_code . "-default", 'small_default');
                         }
                         $unit_price = Product::getPriceStatic($type_value['product_id'], true, null, 6, null, false, true, 1);
                         if (isset($customer->id)) {
                             $cart_bk_data = $obj_cart_bk_data->getOnlyCartBookingData($order->id_cart, (new Cart($order->id_cart))->id_guest, $type_value['product_id'], $customer->id);
                         } else {
                             $cart_bk_data = $obj_cart_bk_data->getOnlyCartBookingData($order->id_cart, $customer->id_guest, $type_value['product_id']);
                         }
                         $rm_dtl = $obj_rm_type->getRoomTypeInfoByIdProduct($type_value['product_id']);
                         $cart_htl_data[$type_key]['id_product'] = $type_value['product_id'];
                         $cart_htl_data[$type_key]['cover_img'] = $cover_img;
                         $cart_htl_data[$type_key]['name'] = $product->name;
                         $cart_htl_data[$type_key]['unit_price'] = $unit_price;
                         $cart_htl_data[$type_key]['adult'] = $rm_dtl['adult'];
                         $cart_htl_data[$type_key]['children'] = $rm_dtl['children'];
                         foreach ($cart_bk_data as $data_k => $data_v) {
                             $date_join = strtotime($data_v['date_from']) . strtotime($data_v['date_to']);
                             if (isset($cart_htl_data[$type_key]['date_diff'][$date_join])) {
                                 $cart_htl_data[$type_key]['date_diff'][$date_join]['num_rm'] += 1;
                                 $num_days = $cart_htl_data[$type_key]['date_diff'][$date_join]['num_days'];
                                 $vart_quant = (int) $cart_htl_data[$type_key]['date_diff'][$date_join]['num_rm'] * $num_days;
                                 $amount = Product::getPriceStatic($type_value['product_id'], true, null, 6, null, false, true, 1);
                                 $amount *= $vart_quant;
                                 $cart_htl_data[$type_key]['date_diff'][$date_join]['amount'] = $amount;
                             } else {
                                 $num_days = $obj_htl_bk_dtl->getNumberOfDays($data_v['date_from'], $data_v['date_to']);
                                 $cart_htl_data[$type_key]['date_diff'][$date_join]['num_rm'] = 1;
                                 $cart_htl_data[$type_key]['date_diff'][$date_join]['data_form'] = $data_v['date_from'];
                                 $cart_htl_data[$type_key]['date_diff'][$date_join]['data_to'] = $data_v['date_to'];
                                 $cart_htl_data[$type_key]['date_diff'][$date_join]['num_days'] = $num_days;
                                 $amount = Product::getPriceStatic($type_value['product_id'], true, null, 6, null, false, true, 1);
                                 $amount *= $num_days;
                                 $cart_htl_data[$type_key]['date_diff'][$date_join]['amount'] = $amount;
                             }
                         }
                     }
                     $this->context->smarty->assign('cart_htl_data', $cart_htl_data);
                 }
             }
             //end
             $this->context->smarty->assign(array('shop_name' => strval(Configuration::get('PS_SHOP_NAME')), 'order' => $order, 'return_allowed' => (int) $order->isReturnable(), 'currency' => new Currency($order->id_currency), 'order_state' => (int) $id_order_state, 'invoiceAllowed' => (int) Configuration::get('PS_INVOICE'), 'invoice' => OrderState::invoiceAvailable($id_order_state) && count($order->getInvoicesCollection()), 'logable' => (bool) $order_status->logable, 'order_history' => $order->getHistory($this->context->language->id, false, true), 'products' => $products, 'discounts' => $order->getCartRules(), 'carrier' => $carrier, 'address_invoice' => $addressInvoice, 'invoiceState' => Validate::isLoadedObject($addressInvoice) && $addressInvoice->id_state ? new State($addressInvoice->id_state) : false, 'address_delivery' => $addressDelivery, 'inv_adr_fields' => $inv_adr_fields, 'dlv_adr_fields' => $dlv_adr_fields, 'invoiceAddressFormatedValues' => $invoiceAddressFormatedValues, 'deliveryAddressFormatedValues' => $deliveryAddressFormatedValues, 'deliveryState' => Validate::isLoadedObject($addressDelivery) && $addressDelivery->id_state ? new State($addressDelivery->id_state) : false, 'is_guest' => false, 'messages' => CustomerMessage::getMessagesByOrderId((int) $order->id, false), 'CUSTOMIZE_FILE' => Product::CUSTOMIZE_FILE, 'CUSTOMIZE_TEXTFIELD' => Product::CUSTOMIZE_TEXTFIELD, 'isRecyclable' => Configuration::get('PS_RECYCLABLE_PACK'), 'use_tax' => Configuration::get('PS_TAX'), 'group_use_tax' => Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC, 'customizedDatas' => $customizedDatas, 'reorderingAllowed' => !(bool) Configuration::get('PS_DISALLOW_HISTORY_REORDERING')));
             if ($carrier->url && $order->shipping_number) {
                 $this->context->smarty->assign('followup', str_replace('@', $order->shipping_number, $carrier->url));
             }
             $this->context->smarty->assign('HOOK_ORDERDETAILDISPLAYED', Hook::exec('displayOrderDetail', array('order' => $order)));
             Hook::exec('actionOrderDetail', array('carrier' => $carrier, 'order' => $order));
             unset($carrier, $addressInvoice, $addressDelivery);
         } else {
             $this->errors[] = Tools::displayError('This order cannot be found.');
         }
         unset($order);
     }
     $this->setTemplate(_PS_THEME_DIR_ . 'order-detail.tpl');
 }
Exemplo n.º 14
0
 public function initContent()
 {
     ${"GLOBALS"}["wcbwhorf"] = "id_order";
     parent::initContent();
     if (!(${${"GLOBALS"}["tdrhijkvhp"]} = (int) Tools::getValue("id_order")) || !Validate::isUnsignedId(${${"GLOBALS"}["wcbwhorf"]})) {
         $this->errors[] = Tools::displayError("Order ID required");
     } else {
         ${"GLOBALS"}["vtkcznmlk"] = "id_customer_seller";
         ${"GLOBALS"}["bwkdjg"] = "id_order";
         ${${"GLOBALS"}["thtbvco"]} = new Order(${${"GLOBALS"}["bwkdjg"]});
         ${"GLOBALS"}["tkggscllp"] = "order";
         ${${"GLOBALS"}["gfrblyem"]} = AgileSellerManager::getObjectOwnerID("order", $order->id);
         ${${"GLOBALS"}["taultlaseq"]} = AgileSellerManager::getLinkedSellerID($this->context->customer->id);
         if (Validate::isLoadedObject(${${"GLOBALS"}["thtbvco"]}) && ${${"GLOBALS"}["gfrblyem"]} == ${${"GLOBALS"}["vtkcznmlk"]} && ${${"GLOBALS"}["taultlaseq"]} > 0) {
             $fwsweyfqnpv = "dlv_adr_fields";
             $gcjosivnd = "carrier";
             ${"GLOBALS"}["pffjtshcnb"] = "deliveryAddressFormatedValues";
             $uztnjfwuwsv = "customizedDatas";
             $uvmwhue = "addressDelivery";
             ${"GLOBALS"}["atrcjjwf"] = "carrier";
             ${"GLOBALS"}["flawpcbih"] = "products";
             ${${"GLOBALS"}["tthrzd"]} = (int) $order->getCurrentState();
             ${$gcjosivnd} = new Carrier((int) $order->id_carrier, (int) $order->id_lang);
             ${"GLOBALS"}["rovfqvkjb"] = "addressDelivery";
             ${${"GLOBALS"}["hoviucftx"]} = new Address((int) $order->id_address_invoice);
             $mjqwhmgoyrm = "customizedDatas";
             ${"GLOBALS"}["qguglflbdd"] = "dlv_adr_fields";
             $sitqckqhoebi = "inv_adr_fields";
             $vejelhbyrbl = "addressDelivery";
             ${"GLOBALS"}["zpyvneijb"] = "addressInvoice";
             $tsvbkseunn = "dlv_adr_fields";
             ${"GLOBALS"}["cdlqrupc"] = "inv_adr_fields";
             ${${"GLOBALS"}["rovfqvkjb"]} = new Address((int) $order->id_address_delivery);
             ${$sitqckqhoebi} = AddressFormat::getOrderedAddressFields($addressInvoice->id_country);
             $shfzuivbjgg = "inv_adr_fields";
             ${${"GLOBALS"}["qguglflbdd"]} = AddressFormat::getOrderedAddressFields($addressDelivery->id_country);
             ${${"GLOBALS"}["elucej"]} = AddressFormat::getFormattedAddressFieldsValues(${${"GLOBALS"}["hoviucftx"]}, ${$shfzuivbjgg});
             ${${"GLOBALS"}["pffjtshcnb"]} = AddressFormat::getFormattedAddressFieldsValues(${${"GLOBALS"}["gkxhkddsjf"]}, ${$fwsweyfqnpv});
             $tbfgtqy = "order";
             if ($order->total_discounts > 0) {
                 $this->context->smarty->assign("total_old", (double) ($order->total_paid - $order->total_discounts));
             }
             ${"GLOBALS"}["ikavgzhqpt"] = "deliveryAddressFormatedValues";
             ${${"GLOBALS"}["flawpcbih"]} = $order->getProducts();
             ${${"GLOBALS"}["gdodxcerle"]} = Product::getAllCustomizedDatas((int) $order->id_cart);
             Product::addCustomizationPrice(${${"GLOBALS"}["umrxyqn"]}, ${$mjqwhmgoyrm});
             $buaccdx = "carrier";
             ${${"GLOBALS"}["cdmray"]} = new Customer($order->id_customer);
             ${"GLOBALS"}["betrwosx"] = "products";
             ${${"GLOBALS"}["bfrxhizen"]} = $order->getCurrentOrderState();
             ${${"GLOBALS"}["sslziuxrs"]} = OrderState::getOrderStates((int) $this->context->language->id);
             ${"GLOBALS"}["bwcmquq"] = "addressInvoice";
             $this->context->smarty->assign(array("order_states" => ${${"GLOBALS"}["sslziuxrs"]}));
             $this->context->smarty->assign(array("shop_name" => strval(Configuration::get("PS_SHOP_NAME")), "order" => ${${"GLOBALS"}["thtbvco"]}, "return_allowed" => (int) $order->isReturnable(), "currency" => new Currency($order->id_currency), "order_cur_state" => (int) ${${"GLOBALS"}["tthrzd"]}, "invoiceAllowed" => (int) Configuration::get("PS_INVOICE"), "invoice" => OrderState::invoiceAvailable(${${"GLOBALS"}["tthrzd"]}) && $order->invoice_number, "order_history" => $order->getHistory($this->context->language->id, false, true), "products" => ${${"GLOBALS"}["betrwosx"]}, "discounts" => $order->getCartRules(), "carrier" => ${${"GLOBALS"}["atrcjjwf"]}, "address_invoice" => ${${"GLOBALS"}["bwcmquq"]}, "invoiceState" => Validate::isLoadedObject(${${"GLOBALS"}["zpyvneijb"]}) && $addressInvoice->id_state ? new State($addressInvoice->id_state) : false, "address_delivery" => ${$uvmwhue}, "inv_adr_fields" => ${${"GLOBALS"}["cdlqrupc"]}, "dlv_adr_fields" => ${$tsvbkseunn}, "invoiceAddressFormatedValues" => ${${"GLOBALS"}["elucej"]}, "deliveryAddressFormatedValues" => ${${"GLOBALS"}["ikavgzhqpt"]}, "deliveryState" => Validate::isLoadedObject(${${"GLOBALS"}["gkxhkddsjf"]}) && $addressDelivery->id_state ? new State($addressDelivery->id_state) : false, "is_guest" => false, "messages" => CustomerMessage::getMessagesByOrderId((int) $order->id, false), "CUSTOMIZE_FILE" => Product::CUSTOMIZE_FILE, "CUSTOMIZE_TEXTFIELD" => Product::CUSTOMIZE_TEXTFIELD, "isRecyclable" => Configuration::get("PS_RECYCLABLE_PACK"), "use_tax" => Configuration::get("PS_TAX"), "group_use_tax" => Group::getPriceDisplayMethod($customer->id_default_group) == PS_TAX_INC, "customizedDatas" => ${$uztnjfwuwsv}));
             if ($carrier->url && $order->shipping_number) {
                 $this->context->smarty->assign("followup", str_replace("@", $order->shipping_number, $carrier->url));
             }
             $this->context->smarty->assign("HOOK_ORDERDETAILDISPLAYED", Hook::exec("displayOrderDetail", array("order" => ${${"GLOBALS"}["thtbvco"]})));
             Hook::exec("actionOrderDetail", array("carrier" => ${${"GLOBALS"}["tvqrewgc"]}, "order" => ${$tbfgtqy}));
             unset(${$buaccdx}, ${${"GLOBALS"}["hoviucftx"]}, ${$vejelhbyrbl});
         } else {
             $this->errors[] = Tools::displayError("Cannot find this order");
         }
         unset(${${"GLOBALS"}["tkggscllp"]});
     }
     self::$smarty->assign(array("seller_tab_id" => 4));
     $this->setTemplate("sellerorderdetail.tpl");
 }
Exemplo n.º 15
0
 /**
  * Main
  *
  * @param object $order Order
  * @param string $mode Download or display (optional)
  */
 public static function invoice($order, $mode = 'D', $multiple = false, &$pdf = NULL, $slip = false, $delivery = false)
 {
     global $cookie;
     if (!Validate::isLoadedObject($order) or !$cookie->id_employee and (!OrderState::invoiceAvailable($order->getCurrentState()) and !$order->invoice_number)) {
         die('Invalid order or invalid order state');
     }
     self::$order = $order;
     self::$orderSlip = $slip;
     self::$delivery = $delivery;
     self::$_iso = strtoupper(Language::getIsoById((int) self::$order->id_lang));
     if ((self::$_priceDisplayMethod = $order->getTaxCalculationMethod()) === false) {
         die(self::l('No price display method defined for the customer group'));
     }
     if (!$multiple) {
         $pdf = new PDF('P', 'mm', 'A4');
     }
     $pdf->SetAutoPageBreak(true, 35);
     $pdf->StartPageGroup();
     self::$currency = Currency::getCurrencyInstance((int) self::$order->id_currency);
     $pdf->AliasNbPages();
     $pdf->AddPage();
     $width = 100;
     $pdf->SetX(10);
     $pdf->SetY(25);
     $pdf->SetFont(self::fontname(), '', 12);
     $pdf->Cell($width, 10, self::l('Billing Address'), 0, 'L');
     $pdf->Cell($width, 10, self::l('Delivery Address'), 0, 'L');
     $pdf->Ln(5);
     $pdf->SetFont(self::fontname(), '', 9);
     $addressType = array('invoice' => array(), 'delivery' => array());
     $patternRules = array('optional' => array('address2', 'company'), 'avoid' => array('State:iso_code'));
     $addressType = self::generateHeaderAddresses($pdf, $order, $addressType, $patternRules, $width);
     if (Configuration::get('VATNUMBER_MANAGEMENT') and !empty($addressType['invoice']['addressObject']->vat_number)) {
         $vat_delivery = '';
         if ($addressType['invoice']['addressObject']->id != $addressType['delivery']['addressObject']->id) {
             $vat_delivery = $addressType['delivery']['addressObject']->vat_number;
         }
         $pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $vat_delivery), 0, 'L');
         $pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $addressType['invoice']['addressObject']->vat_number), 0, 'L');
         $pdf->Ln(5);
     }
     if ($addressType['invoice']['addressObject']->dni != NULL) {
         $pdf->Cell($width, 10, self::l('Tax ID number:') . ' ' . Tools::iconv('utf-8', self::encoding(), $addressType['invoice']['addressObject']->dni), 0, 'L');
     }
     /*
      * display order information
      */
     $boxTop = $pdf->GetY();
     $pdf->Rect(10, $boxTop, 90, 45);
     $pdf->Rect(110, $boxTop, 90, 45);
     //$pdf->SetY(70);
     $pdf->SetFillColor(240, 240, 240);
     $pdf->SetTextColor(0, 0, 0);
     $pdf->Cell(90, 6, self::l('Order Details'), 1, 2, 'C', 1);
     $carrier = new Carrier(self::$order->id_carrier);
     if ($carrier->name == '0') {
         $carrier->name = Configuration::get('PS_SHOP_NAME');
     }
     $history = self::$order->getHistory(self::$order->id_lang);
     foreach ($history as $h) {
         if ($h['id_order_state'] == _PS_OS_SHIPPING_) {
             $shipping_date = $h['date_add'];
         }
     }
     //$pdf->Ln(12);
     //Initialize price calculations
     $priceBreakDown = array();
     $pdf->priceBreakDownCalculation($priceBreakDown);
     if (!self::$orderSlip or self::$orderSlip and self::$orderSlip->shipping_cost) {
         $priceBreakDown['totalWithoutTax'] += Tools::ps_round($priceBreakDown['shippingCostWithoutTax'], 2) + Tools::ps_round($priceBreakDown['wrappingCostWithoutTax'], 2);
         $priceBreakDown['totalWithTax'] += self::$order->total_shipping + self::$order->total_wrapping + self::$order->total_cod + $priceBreakDown['customizationCost'];
     }
     if (!self::$orderSlip) {
         $taxDiscount = self::$order->getTaxesAverageUsed();
         if ($taxDiscount != 0) {
             $priceBreakDown['totalWithoutTax'] -= Tools::ps_round(self::$order->total_discounts / (1 + self::$order->getTaxesAverageUsed() * 0.01), 2);
         } else {
             $priceBreakDown['totalWithoutTax'] -= self::$order->total_discounts;
         }
         $priceBreakDown['totalWithTax'] -= self::$order->total_discounts;
     }
     $pdf->SetFont(self::fontname(), '', 9);
     /*if (self::$orderSlip)
     			$pdf->Cell(0, 6, self::l('SLIP #').' '.sprintf('%06d', self::$orderSlip->id).' '.self::l('from') . ' ' .Tools::displayDate(self::$orderSlip->date_upd, self::$order->id_lang), 1, 2, 'L', 1);
     		elseif (self::$delivery)
     			$pdf->Cell(0, 6, self::l('DELIVERY SLIP #').Tools::iconv('utf-8', self::encoding(), Configuration::get('PS_DELIVERY_PREFIX', (int)($cookie->id_lang))).sprintf('%06d', self::$delivery).' '.self::l('from') . ' ' .Tools::displayDate(self::$order->delivery_date, self::$order->id_lang), 1, 2, 'L', 1);
     		else
     			$pdf->Cell(0, 6, self::l('Order Details'), 1, 2, 'L', 1);*/
     $pdf->SetFontSize(10);
     $pdf->Ln(3);
     $pdf->Cell(90, 6, self::l('Order No. :') . ' ' . sprintf('%06d', self::$order->id), 0, 2, 'C');
     $pdf->Cell(90, 6, self::l('Order Date:') . ' ' . Tools::displayDate($order->invoice_date, self::$order->id_lang), 0, 2, 'C');
     $pdf->Cell(90, 6, 'Invoice No.' . ' ' . Tools::iconv('utf-8', self::encoding(), Configuration::get('PS_INVOICE_PREFIX', (int) $cookie->id_lang)) . sprintf('%06d', self::$order->invoice_number), 0, 2, 'C');
     $pdf->SetY($boxTop);
     $pdf->SetX(110);
     $pdf->SetFontSize(10);
     $pdf->Cell(90, 6, self::l('Shipment Details'), 1, 2, 'C', 1);
     $pdf->SetFontSize(10);
     //$pdf->Cell(45, 6, self::l('Payment:').($order->gift ? ' '.Tools::iconv('utf-8', self::encoding(), $carrier->name) : ''), 0, 0, 'C');
     if (strpos($order->payment, 'COD') === false) {
         $pdf->Cell(90, 6, 'Payment: ' . Tools::iconv('utf-8', self::encoding(), 'Online Payment'), 0, 2, 'C');
         $pdf->Cell(90, 6, 'PAID', 'B', 2, 'C');
     } else {
         $pdf->Cell(90, 6, 'Payment: ' . Tools::iconv('utf-8', self::encoding(), 'COD'), 0, 2, 'C');
         $pdf->Cell(90, 6, 'Collect: ' . self::convertSign(Tools::displayPrice(self::$_priceDisplayMethod == PS_TAX_EXC ? $priceBreakDown['totalWithoutTax'] : $priceBreakDown['totalWithTax'], self::$currency, true)), 'B', 2, 'C');
     }
     $pdf->Cell(90, 6, self::l('Shipping: ') . $carrier->name, 0, 2, 'C');
     //$pdf->Ln(5);
     $tracking_number = '';
     if ($order->shipping_number) {
         $tracking_number = 'Tracking code: ' . $order->shipping_number;
         $pdf->Cell(90, 6, $tracking_number, 'B', 2, 'C');
         $pdf->addBarcode($order->shipping_number);
     }
     $pdf->SetY($boxTop + 45);
     $pdf->Ln(5);
     $pdf->ProdTab(self::$delivery ? true : '');
     /* Exit if delivery */
     if (!self::$delivery) {
         //if (!self::$orderSlip)
         //$pdf->DiscTab();
         if (self::$orderQuantity) {
             $pdf->Ln(3);
             $pdf->SetFont(self::fontname(), 'B', 8);
             $width = 165;
             $pdf->Cell(150, 4, self::l('Total Quantity') . ' : ', 'B', 0, 'R');
             $pdf->Cell(0, 4, self::$orderQuantity, 'B', 2, 'L');
             $pdf->Ln(6);
         }
         /*
          * Display price summation
          */
         if (Configuration::get('PS_TAX') or $order->total_products_wt != $order->total_products) {
             /*$pdf->Ln(5);
             		$pdf->SetFont(self::fontname(), 'B', 8);
             		$width = 165;
             		$pdf->Cell($width, 0, self::l('Order Total').' : ', 0, 0, 'R');
             		$pdf->Cell(0, 0, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice($priceBreakDown['totalProductsWithoutTax'], self::$currency, true)), 0, 0, 'R');
             		$pdf->Ln(4);
             		*/
             /*
             $pdf->SetFont(self::fontname(), 'B', 8);
             $width = 165;
             $pdf->Cell($width, 0, self::l('Total products (tax incl.)').' : ', 0, 0, 'R');
             $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '').self::convertSign(Tools::displayPrice($priceBreakDown['totalProductsWithTax'], self::$currency, true)), 0, 0, 'R');
             $pdf->Ln(4);
             */
         } else {
             $pdf->Ln(5);
             $pdf->SetFont(self::fontname(), 'B', 8);
             $width = 165;
             $pdf->Cell($width, 0, self::l('Total products ') . ' : ', 0, 0, 'R');
             $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice($priceBreakDown['totalProductsWithoutTax'], self::$currency, true)), 0, 0, 'R');
             $pdf->Ln(4);
         }
         if (isset(self::$order->total_wrapping) and (double) self::$order->total_wrapping > 0) {
             $pdf->Cell($width, 0, self::l('Total gift-wrapping') . ' : ', 0, 0, 'R');
             if (self::$_priceDisplayMethod == PS_TAX_EXC) {
                 $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice($priceBreakDown['wrappingCostWithoutTax'], self::$currency, true)), 0, 0, 'R');
             } else {
                 $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice(self::$order->total_wrapping, self::$currency, true)), 0, 0, 'R');
             }
             $pdf->Ln(4);
         }
         /*
         $pdf->Cell($width, 0, self::l('Tax').' : ', 0, 0, 'R');
         $pdf->Cell(0, 0, self::convertSign(Tools::displayPrice($priceBreakDown['totalProductsWithTax'] - $priceBreakDown['totalProductsWithoutTax'], self::$currency, true)), 0, 0, 'R');
         $pdf->Ln(4);
         */
         if ($priceBreakDown['customizationCost'] > 0) {
             $pdf->Cell($width, 0, self::l('Stitching and Customizations') . ' : ', 0, 0, 'R');
             if (self::$_priceDisplayMethod == PS_TAX_EXC) {
                 $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice($priceBreakDown['customizationCost'], self::$currency, true)), 0, 0, 'R');
             } else {
                 $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice($priceBreakDown['customizationCost'], self::$currency, true)), 0, 0, 'R');
             }
             $pdf->Ln(4);
         }
         if (isset(self::$order->total_cod) and (double) self::$order->total_cod > 0) {
             $pdf->Cell($width, 0, self::l('COD Charges') . ' : ', 0, 0, 'R');
             if (self::$_priceDisplayMethod == PS_TAX_EXC) {
                 $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice(self::$order->total_cod, self::$currency, true)), 0, 0, 'R');
             } else {
                 $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice(self::$order->total_cod, self::$currency, true)), 0, 0, 'R');
             }
             $pdf->Ln(4);
         }
         if (self::$order->total_shipping != '0.00' and (!self::$orderSlip or self::$orderSlip and self::$orderSlip->shipping_cost)) {
             $pdf->Cell($width, 0, self::l('Shipping') . ' : ', 0, 0, 'R');
             if (self::$_priceDisplayMethod == PS_TAX_EXC) {
                 $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice(Tools::ps_round($priceBreakDown['shippingCostWithoutTax'], 2), self::$currency, true)), 0, 0, 'R');
             } else {
                 $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice(self::$order->total_shipping, self::$currency, true)), 0, 0, 'R');
             }
             $pdf->Ln(4);
         }
         if (!self::$orderSlip and self::$order->total_discounts != '0.00') {
             $pdf->Cell($width, 0, self::l('Discounts') . ' : ', 0, 0, 'R');
             $pdf->Cell(0, 0, (!self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice(self::$order->total_discounts, self::$currency, true)), 0, 0, 'R');
             $pdf->Ln(4);
             /*$pdf->Cell($width, 0, self::l('Sub-total').' : ', 0, 0, 'R');
             		$pdf->Cell(0, 0, self::convertSign(Tools::displayPrice($priceBreakDown['totalProductsWithoutTax'] - self::$order->total_discounts, self::$currency, true)), 0, 0, 'R');
             		$pdf->Ln(4);*/
         }
         if (Configuration::get('PS_TAX') or $order->total_products_wt != $order->total_products) {
             $pdf->Cell($width, 0, self::l('Total') . ' ' . (self::$_priceDisplayMethod == PS_TAX_EXC ? self::l(' (tax excl.)') : self::l(' (tax incl.)')) . ' : ', 0, 0, 'R');
             $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice(self::$_priceDisplayMethod == PS_TAX_EXC ? $priceBreakDown['totalWithoutTax'] : $priceBreakDown['totalWithTax'], self::$currency, true)), 0, 0, 'R');
             $pdf->Ln(4);
         } else {
             $pdf->Cell($width, 0, self::l('Total') . ' : ', 0, 0, 'R');
             $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice($priceBreakDown['totalWithoutTax'], self::$currency, true)), 0, 0, 'R');
             $pdf->Ln(4);
         }
         $pdf->TaxTab($priceBreakDown);
         $pdf->addShopAddress1();
     }
     Hook::PDFInvoice($pdf, self::$order->id);
     if (!$multiple) {
         return $pdf->Output('IndusDiva Order #' . sprintf('%06d', self::$order->id) . '.pdf', $mode);
     }
 }
Exemplo n.º 16
0
 /**
  * Main
  *
  * @param object $order Order
  * @param string $mode Download or display (optional)
  */
 public static function invoice($order, $mode = 'D', $multiple = false, &$pdf = NULL, $slip = false, $delivery = false)
 {
     global $cookie;
     if (!Validate::isLoadedObject($order) or !$cookie->id_employee and (!OrderState::invoiceAvailable($order->getCurrentState()) and !$order->invoice_number)) {
         die('Invalid order or invalid order state');
     }
     self::$order = $order;
     self::$orderSlip = $slip;
     self::$delivery = $delivery;
     self::$_iso = strtoupper(Language::getIsoById((int) self::$order->id_lang));
     if ((self::$_priceDisplayMethod = $order->getTaxCalculationMethod()) === false) {
         die(self::l('No price display method defined for the customer group'));
     }
     if (!$multiple) {
         $pdf = new PDF('P', 'mm', 'A4');
     }
     $pdf->SetAutoPageBreak(true, 35);
     $pdf->StartPageGroup();
     self::$currency = Currency::getCurrencyInstance((int) self::$order->id_currency);
     $pdf->AliasNbPages();
     $pdf->AddPage();
     /* Display address information */
     $invoice_address = new Address((int) $order->id_address_invoice);
     $invoiceState = $invoice_address->id_state ? new State($invoice_address->id_state) : false;
     $delivery_address = new Address((int) $order->id_address_delivery);
     $deliveryState = $delivery_address->id_state ? new State($delivery_address->id_state) : false;
     $ordered_adr_fields = AddressFormat::getOrderedAddressFields($invoice_address->id_country);
     $optional_fields = array('address2' => 1, 'company' => 1);
     $ignore_fields = array('phone' => 1, 'mobile_phone' => 1);
     $width = 100;
     $pdf->SetX(10);
     $pdf->SetY(25);
     $pdf->SetFont(self::fontname(), '', 12);
     $pdf->Cell($width, 10, self::l('Delivery'), 0, 'L');
     $pdf->Cell($width, 10, self::l('Invoicing'), 0, 'L');
     $pdf->Ln(5);
     $pdf->SetFont(self::fontname(), '', 9);
     foreach ($ordered_adr_fields as $adr_line) {
         $line_fields = explode(" ", trim($adr_line));
         $tmp_inv_vals = array();
         $tmp_dlv_vals = array();
         foreach ($line_fields as $field_name) {
             // if not skip
             if (!isset($ignore_fields[$field_name])) {
                 $tmp_inv = $invoice_address->{$field_name};
                 $tmp_dlv = $delivery_address->{$field_name};
                 if (!((empty($tmp_inv) || $tmp_inv == '') && isset($optional_fields[$field_name]))) {
                     $tmp_inv = $field_name == "country" ? $tmp_inv . ($deliveryState ? ' - ' . $deliveryState->name : '') : $tmp_inv;
                     $tmp_inv_vals[] = Tools::iconv('utf-8', self::encoding(), $tmp_inv);
                 }
                 if (!((empty($tmp_dlv) || $tmp_dlv == '') && isset($optional_fields[$field_name]))) {
                     $tmp_dlv = $field_name == "country" ? $tmp_dlv . ($deliveryState ? ' - ' . $deliveryState->name : '') : $tmp_dlv;
                     $tmp_dlv_vals[] = Tools::iconv('utf-8', self::encoding(), $tmp_dlv);
                 }
             }
         }
         $str_inv_vals = implode(" ", $tmp_inv_vals);
         $str_dlv_vals = implode(" ", $tmp_dlv_vals);
         $need_nl = false;
         if (!empty($str_dlv_vals) && $str_dlv_vals != '' && $str_dlv_vals != ' ') {
             $need_nl = true;
             $pdf->Cell($width, 10, $str_dlv_vals, 0, 'L');
         }
         if (!empty($str_inv_vals) && $str_inv_vals != '' && $str_inv_vals != ' ') {
             $need_nl = true;
             $pdf->Cell($width, 10, $str_inv_vals, 0, 'L');
         }
         if ($need_nl) {
             $pdf->Ln(5);
         }
     }
     if (Configuration::get('VATNUMBER_MANAGEMENT') and !empty($invoice_address->vat_number)) {
         $vat_delivery = '';
         if ($invoice_address->id != $delivery_address->id) {
             $vat_delivery = $delivery_address->vat_number;
         }
         $pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $vat_delivery), 0, 'L');
         $pdf->Cell($width, 10, Tools::iconv('utf-8', self::encoding(), $invoice_address->vat_number), 0, 'L');
         $pdf->Ln(5);
     }
     $pdf->Cell($width, 10, $delivery_address->phone, 0, 'L');
     if ($invoice_address->dni != NULL) {
         $pdf->Cell($width, 10, self::l('Tax ID number:') . ' ' . Tools::iconv('utf-8', self::encoding(), $invoice_address->dni), 0, 'L');
     }
     if (!empty($delivery_address->phone_mobile)) {
         $pdf->Ln(5);
         $pdf->Cell($width, 10, $delivery_address->phone_mobile, 0, 'L');
     }
     /*
      * display order information
      */
     $carrier = new Carrier(self::$order->id_carrier);
     if ($carrier->name == '0') {
         $carrier->name = Configuration::get('PS_SHOP_NAME');
     }
     $history = self::$order->getHistory(self::$order->id_lang);
     foreach ($history as $h) {
         if ($h['id_order_state'] == _PS_OS_SHIPPING_) {
             $shipping_date = $h['date_add'];
         }
     }
     $pdf->Ln(12);
     $pdf->SetFillColor(240, 240, 240);
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetFont(self::fontname(), '', 9);
     if (self::$orderSlip) {
         $pdf->Cell(0, 6, self::l('SLIP #') . sprintf('%06d', self::$orderSlip->id) . ' ' . self::l('from') . ' ' . Tools::displayDate(self::$orderSlip->date_upd, self::$order->id_lang), 1, 2, 'L', 1);
     } elseif (self::$delivery) {
         $pdf->Cell(0, 6, self::l('DELIVERY SLIP #') . Configuration::get('PS_DELIVERY_PREFIX', (int) $cookie->id_lang) . sprintf('%06d', self::$delivery) . ' ' . self::l('from') . ' ' . Tools::displayDate(self::$order->delivery_date, self::$order->id_lang), 1, 2, 'L', 1);
     } else {
         $pdf->Cell(0, 6, self::l('INVOICE #') . Configuration::get('PS_INVOICE_PREFIX', (int) $cookie->id_lang) . sprintf('%06d', self::$order->invoice_number) . ' ' . self::l('from') . ' ' . Tools::displayDate(self::$order->invoice_date, self::$order->id_lang), 1, 2, 'L', 1);
     }
     $pdf->Cell(55, 6, self::l('Order #') . sprintf('%06d', self::$order->id), 'L', 0);
     $pdf->Cell(70, 6, self::l('Carrier:') . ($order->gift ? ' ' . Tools::iconv('utf-8', self::encoding(), $carrier->name) : ''), 'L');
     $pdf->Cell(0, 6, self::l('Payment method:'), 'LR');
     $pdf->Ln(5);
     $pdf->Cell(55, 6, isset($shipping_date) ? self::l('Shipping date:') . ' ' . Tools::displayDate($shipping_date, self::$order->id_lang) : ' ', 'LB', 0);
     $pdf->Cell(70, 6, $order->gift ? self::l('Gift-wrapped order') : Tools::iconv('utf-8', self::encoding(), $carrier->name), 'LRB');
     $pdf->Cell(0, 6, Tools::iconv('utf-8', self::encoding(), $order->payment), 'LRB');
     $pdf->Ln(15);
     $pdf->ProdTab(self::$delivery ? true : '');
     /* Exit if delivery */
     if (!self::$delivery) {
         if (!self::$orderSlip) {
             $pdf->DiscTab();
         }
         $priceBreakDown = array();
         $pdf->priceBreakDownCalculation($priceBreakDown);
         if (!self::$orderSlip or self::$orderSlip and self::$orderSlip->shipping_cost) {
             $priceBreakDown['totalWithoutTax'] += Tools::ps_round($priceBreakDown['shippingCostWithoutTax'], 2) + Tools::ps_round($priceBreakDown['wrappingCostWithoutTax'], 2);
             $priceBreakDown['totalWithTax'] += self::$order->total_shipping + self::$order->total_wrapping;
         }
         if (!self::$orderSlip) {
             $taxDiscount = self::$order->getTaxesAverageUsed();
             if ($taxDiscount != 0) {
                 $priceBreakDown['totalWithoutTax'] -= Tools::ps_round(self::$order->total_discounts / (1 + self::$order->getTaxesAverageUsed() * 0.01), 2);
             } else {
                 $priceBreakDown['totalWithoutTax'] -= self::$order->total_discounts;
             }
             $priceBreakDown['totalWithTax'] -= self::$order->total_discounts;
         }
         /*
          * Display price summation
          */
         if (Configuration::get('PS_TAX') or $order->total_products_wt != $order->total_products) {
             $pdf->Ln(5);
             $pdf->SetFont(self::fontname(), 'B', 8);
             $width = 165;
             $pdf->Cell($width, 0, self::l('Total products (tax excl.)') . ' : ', 0, 0, 'R');
             $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice($priceBreakDown['totalProductsWithoutTax'], self::$currency, true, false)), 0, 0, 'R');
             $pdf->Ln(4);
             $pdf->SetFont(self::fontname(), 'B', 8);
             $width = 165;
             $pdf->Cell($width, 0, self::l('Total products (tax incl.)') . ' : ', 0, 0, 'R');
             $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice($priceBreakDown['totalProductsWithTax'], self::$currency, true, false)), 0, 0, 'R');
             $pdf->Ln(4);
         } else {
             $pdf->Ln(5);
             $pdf->SetFont(self::fontname(), 'B', 8);
             $width = 165;
             $pdf->Cell($width, 0, self::l('Total products ') . ' : ', 0, 0, 'R');
             $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice($priceBreakDown['totalProductsWithoutTax'], self::$currency, true, false)), 0, 0, 'R');
             $pdf->Ln(4);
         }
         if (!self::$orderSlip and self::$order->total_discounts != '0.00') {
             $pdf->Cell($width, 0, self::l('Total discounts (tax incl.)') . ' : ', 0, 0, 'R');
             $pdf->Cell(0, 0, (!self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice(self::$order->total_discounts, self::$currency, true, false)), 0, 0, 'R');
             $pdf->Ln(4);
         }
         if (isset(self::$order->total_wrapping) and (double) self::$order->total_wrapping > 0) {
             $pdf->Cell($width, 0, self::l('Total gift-wrapping') . ' : ', 0, 0, 'R');
             if (self::$_priceDisplayMethod == PS_TAX_EXC) {
                 $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice($priceBreakDown['wrappingCostWithoutTax'], self::$currency, true, false)), 0, 0, 'R');
             } else {
                 $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice(self::$order->total_wrapping, self::$currency, true, false)), 0, 0, 'R');
             }
             $pdf->Ln(4);
         }
         if (self::$order->total_shipping != '0.00' and (!self::$orderSlip or self::$orderSlip and self::$orderSlip->shipping_cost)) {
             $pdf->Cell($width, 0, self::l('Total shipping') . ' : ', 0, 0, 'R');
             if (self::$_priceDisplayMethod == PS_TAX_EXC) {
                 $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice(Tools::ps_round($priceBreakDown['shippingCostWithoutTax'], 2), self::$currency, true, false)), 0, 0, 'R');
             } else {
                 $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice(self::$order->total_shipping, self::$currency, true, false)), 0, 0, 'R');
             }
             $pdf->Ln(4);
         }
         if (Configuration::get('PS_TAX') or $order->total_products_wt != $order->total_products) {
             $pdf->Cell($width, 0, self::l('Total') . ' ' . (self::$_priceDisplayMethod == PS_TAX_EXC ? self::l(' (tax incl.)') : self::l(' (tax excl.)')) . ' : ', 0, 0, 'R');
             $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice(self::$_priceDisplayMethod == PS_TAX_EXC ? $priceBreakDown['totalWithTax'] : $priceBreakDown['totalWithoutTax'], self::$currency, true, false)), 0, 0, 'R');
             $pdf->Ln(4);
             $pdf->Cell($width, 0, self::l('Total') . ' ' . (self::$_priceDisplayMethod == PS_TAX_EXC ? self::l(' (tax excl.)') : self::l(' (tax incl.)')) . ' : ', 0, 0, 'R');
             $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice(self::$_priceDisplayMethod == PS_TAX_EXC ? $priceBreakDown['totalWithoutTax'] : $priceBreakDown['totalWithTax'], self::$currency, true, false)), 0, 0, 'R');
             $pdf->Ln(4);
         } else {
             $pdf->Cell($width, 0, self::l('Total') . ' : ', 0, 0, 'R');
             $pdf->Cell(0, 0, (self::$orderSlip ? '-' : '') . self::convertSign(Tools::displayPrice($priceBreakDown['totalWithoutTax'], self::$currency, true, false)), 0, 0, 'R');
             $pdf->Ln(4);
         }
         $pdf->TaxTab($priceBreakDown);
     }
     Hook::PDFInvoice($pdf, self::$order->id);
     if (!$multiple) {
         return $pdf->Output(sprintf('%06d', self::$order->id) . '.pdf', $mode);
     }
 }