public function preProcess() { parent::preProcess(); if (Tools::isSubmit('submitReturnMerchandise')) { $customizationQtyInput = Tools::getValue('customization_qty_input'); if (!($id_order = (int) Tools::getValue('id_order'))) { Tools::redirect('history.php'); } if (!($order_qte_input = Tools::getValue('order_qte_input'))) { Tools::redirect('order-follow.php?errorDetail1'); } if ($customizationIds = Tools::getValue('customization_ids') and !$customizationQtyInput) { Tools::redirect('order-follow.php?errorDetail1'); } if (!($ids_order_detail = Tools::getValue('ids_order_detail')) and !$customizationIds) { Tools::redirect('order-follow.php?errorDetail2'); } $order = new Order((int) $id_order); if (!$order->isReturnable()) { Tools::redirect('order-follow.php?errorNotReturnable'); } if ($order->id_customer != self::$cookie->id_customer) { die(Tools::displayError()); } $orderReturn = new OrderReturn(); $orderReturn->id_customer = (int) self::$cookie->id_customer; $orderReturn->id_order = $id_order; $orderReturn->question = strval(Tools::getValue('returnText')); if (empty($orderReturn->question)) { Tools::redirect('order-follow.php?errorMsg'); } if (!$orderReturn->checkEnoughProduct($ids_order_detail, $order_qte_input, $customizationIds, $customizationQtyInput)) { Tools::redirect('order-follow.php?errorQuantity'); } $orderReturn->state = 1; $orderReturn->add(); $orderReturn->addReturnDetail($ids_order_detail, $order_qte_input, $customizationIds, $customizationQtyInput); Module::hookExec('orderReturn', array('orderReturn' => $orderReturn)); Tools::redirect('order-follow.php'); } $ordersReturn = OrderReturn::getOrdersReturn((int) self::$cookie->id_customer); if (Tools::isSubmit('errorQuantity')) { self::$smarty->assign('errorQuantity', true); } elseif (Tools::isSubmit('errorMsg')) { self::$smarty->assign('errorMsg', true); } elseif (Tools::isSubmit('errorDetail1')) { self::$smarty->assign('errorDetail1', true); } elseif (Tools::isSubmit('errorDetail2')) { self::$smarty->assign('errorDetail2', true); } elseif (Tools::isSubmit('errorNotReturnable')) { self::$smarty->assign('errorNotReturnable', true); } self::$smarty->assign('ordersReturn', $ordersReturn); }
/** * Returns the template's HTML content * @return string HTML content */ public function getContent() { $delivery_address = new Address((int) $this->order->id_address_delivery); $formatted_delivery_address = AddressFormat::generateAddress($delivery_address, array(), '<br />', ' '); $formatted_invoice_address = ''; if ($this->order->id_address_delivery != $this->order->id_address_invoice) { $invoice_address = new Address((int) $this->order->id_address_invoice); $formatted_invoice_address = AddressFormat::generateAddress($invoice_address, array(), '<br />', ' '); } $this->smarty->assign(array('order_return' => $this->order_return, 'return_nb_days' => (int) Configuration::get('PS_ORDER_RETURN_NB_DAYS'), 'products' => OrderReturn::getOrdersReturnProducts((int) $this->order_return->id, $this->order), 'delivery_address' => $formatted_delivery_address, 'invoice_address' => $formatted_invoice_address, 'shop_address' => AddressFormat::generateAddress($this->shop->getAddress(), array(), '<br />', ' '))); return $this->smarty->fetch($this->getTemplate('order-return')); }
public function hookOrderReturn($params) { $sEmail = Configuration::get('NOW_ORDER_RETURN_EMAIL'); if (Configuration::get('NOW_ORDER_RETURN_ACTIVE') && $sEmail) { $oOrderReturn = $params['orderReturn']; $oOrder = new Order((int) $oOrderReturn->id_order); if (Validate::isLoadedObject($oOrderReturn)) { $context = Context::getContext(); $aProducts = OrderReturn::getOrdersReturnProducts((int) $oOrderReturn->id, $oOrder); $aParamsEmail = array('{firstname}' => $context->customer->firstname, '{lastname}' => $context->customer->lastname, '{id_order_return}' => $oOrderReturn->id, '{id_order}' => $oOrderReturn->id_order, '{product_html}' => $this->getProductListforEmailHTML($aProducts), '{product_txt}' => $this->getProductListforEmailTXT($aProducts)); $return = Mail::Send($context->language->id, 'order_return', Mail::l('Order Return', $context->language->id), $aParamsEmail, $sEmail, 'Administrator', $context->customer->email, $context->customer->lastname . ' - ' . $context->customer->firstname, NULL, NULL, $this->module_dir . 'mails/'); return $return; } } }
/** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { parent::initContent(); $ordersReturn = OrderReturn::getOrdersReturn($this->context->customer->id); if (Tools::isSubmit('errorQuantity')) { $this->context->smarty->assign('errorQuantity', true); } elseif (Tools::isSubmit('errorMsg')) { $this->context->smarty->assign(array('errorMsg' => true, 'ids_order_detail' => Tools::getValue('ids_order_detail', array()), 'order_qte_input' => Tools::getValue('order_qte_input', array()), 'id_order' => Tools::getValue('id_order'))); } elseif (Tools::isSubmit('errorDetail1')) { $this->context->smarty->assign('errorDetail1', true); } elseif (Tools::isSubmit('errorDetail2')) { $this->context->smarty->assign('errorDetail2', true); } elseif (Tools::isSubmit('errorNotReturnable')) { $this->context->smarty->assign('errorNotReturnable', true); } $this->context->smarty->assign('ordersReturn', $ordersReturn); $this->setTemplate(_PS_THEME_DIR_ . 'order-follow.tpl'); }
public function preProcess() { parent::preProcess(); if (!isset($_GET['id_order_return']) or !Validate::isUnsignedId($_GET['id_order_return'])) { $this->errors[] = Tools::displayError('Order ID required'); } else { $orderRet = new OrderReturn((int) $_GET['id_order_return']); if (Validate::isLoadedObject($orderRet) and $orderRet->id_customer == self::$cookie->id_customer) { $order = new Order((int) $orderRet->id_order); if (Validate::isLoadedObject($order)) { $state = new OrderReturnState((int) $orderRet->state); self::$smarty->assign(array('orderRet' => $orderRet, 'order' => $order, 'state_name' => $state->name[(int) self::$cookie->id_lang], 'return_allowed' => false, 'products' => OrderReturn::getOrdersReturnProducts((int) $orderRet->id, $order), 'returnedCustomizations' => OrderReturn::getReturnedCustomizedProducts((int) $orderRet->id_order), 'customizedDatas' => Product::getAllCustomizedDatas((int) $order->id_cart))); } else { $this->errors[] = Tools::displayError('Cannot find this order return'); } } else { $this->errors[] = Tools::displayError('Cannot find this order return'); } } self::$smarty->assign(array('errors' => $this->errors, 'nbdaysreturn' => (int) Configuration::get('PS_ORDER_RETURN_NB_DAYS'))); }
/** * Initialize order return controller * @see FrontController::init() */ public function init() { parent::init(); header('Cache-Control: no-cache, must-revalidate'); header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); if (!isset($_GET['id_order_return']) || !Validate::isUnsignedId($_GET['id_order_return'])) { $this->errors[] = Tools::displayError('Order ID required'); } else { $orderRet = new OrderReturn((int) $_GET['id_order_return']); if (Validate::isLoadedObject($orderRet) && $orderRet->id_customer == $this->context->cookie->id_customer) { $order = new Order((int) $orderRet->id_order); if (Validate::isLoadedObject($order)) { $state = new OrderReturnState((int) $orderRet->state); $this->context->smarty->assign(array('orderRet' => $orderRet, 'order' => $order, 'state_name' => $state->name[(int) $this->context->language->id], 'return_allowed' => false, 'products' => OrderReturn::getOrdersReturnProducts((int) $orderRet->id, $order), 'returnedCustomizations' => OrderReturn::getReturnedCustomizedProducts((int) $orderRet->id_order), 'customizedDatas' => Product::getAllCustomizedDatas((int) $order->id_cart))); } else { $this->errors[] = Tools::displayError('Cannot find the order return.'); } } else { $this->errors[] = Tools::displayError('Cannot find the order return.'); } } }
public function cronReturnSync() { // Check if client is initialized if (is_null($this->client)) { return false; } //Retrieve returns $returns = $this->client->getReturns(array(0)); //Check declared returns if (is_null($returns) || $returns->count() == 0) { return false; } $customizationQtyInput = Tools::getValue('customization_qty_input'); $customizationIds = Tools::getValue('customization_ids'); foreach ($returns as $return) { $return_lines = $return->getLines(); $channelengine_order_id = $return->getOrderId(); $sql = "SELECT id_order FROM " . _DB_PREFIX_ . "orders WHERE id_channelengine_order ='" . $channelengine_order_id . "'"; $prestashop_order_id = Db::getInstance()->getValue($sql); $sql = "SELECT id_order_detail FROM" . _DB_PREFIX_ . "order_detail WHERE id_order ='" . $prestashop_order_id . "'"; $ids_order_details = Db::getInstance()->executeS($sql); $ids_order_detail_array = array(); foreach ($ids_order_details as $key => $ids_order_detail) { $ids_order_detail_array[$ids_order_detail['id_order_detail']] = $ids_order_detail['id_order_detail']; } $quantity_array = array(); $keys = array_keys($ids_order_detail_array); foreach ($return_lines as $i => $return_line) { $quantity_array[$keys[$i]] = $return_line->getQuantity(); $order = new Order((int) $prestashop_order_id); $orderReturn = new OrderReturn(); $orderReturn->id_customer = (int) $order->id_customer; $orderReturn->id_order = $prestashop_order_id; $orderReturn->question = htmlspecialchars(Tools::getValue('returnText')); if (empty($orderReturn->question)) { http_build_query(array('ids_order_detail' => $ids_order_detail_array, 'order_qte_input' => $quantity_array, 'id_order' => $prestashop_order_id)); } } $orderReturn->state = 1; $orderReturn->add(); $orderReturn->addReturnDetail($ids_order_detail_array, $quantity_array, $customizationIds, $customizationQtyInput); Hook::exec('actionOrderReturn', array('orderReturn' => $orderReturn)); } }
public function hookOrderReturn($params) { $result = Db::getInstance()->getRow(' SELECT f.id_loyalty FROM `' . _DB_PREFIX_ . 'loyalty` f WHERE f.id_customer = ' . intval($params['orderReturn']->id_customer) . ' AND f.id_order = ' . intval($params['orderReturn']->id_order)); $loyalty = new LoyaltyModule(intval($result['id_loyalty'])); if (!Validate::isLoadedObject($loyalty)) { return false; } $totalPrice = 0; $details = OrderReturn::getOrdersReturnDetail($params['orderReturn']->id); foreach ($details as $detail) { $result = Db::getInstance()->getRow(' SELECT product_price * (1 + (tax_rate / 100)) AS ttc FROM ' . _DB_PREFIX_ . 'order_detail od WHERE id_order_detail = ' . intval($detail['id_order_detail'])); $totalPrice += $result['ttc'] * $detail['product_quantity']; } $canceledTotal = floor($totalPrice / floatval(Configuration::get('PS_LOYALTY_POINT_RATE'))); if ($canceledTotal > $loyalty->points) { $canceledTotal = $loyalty->points; } Db::getInstance()->Execute(' INSERT INTO `' . _DB_PREFIX_ . 'loyalty_history` (`id_loyalty`, `id_loyalty_state`, `points`, `date_add`) VALUES (' . intval($loyalty->id) . ', ' . intval(LoyaltyStateModule::getCancelId()) . ', -' . intval($canceledTotal) . ', NOW())'); $loyalty->points -= $canceledTotal; $loyalty->update(); Db::getInstance()->Execute(' INSERT INTO `' . _DB_PREFIX_ . 'loyalty_history` (`id_loyalty`, `id_loyalty_state`, `points`, `date_add`) VALUES (' . intval($loyalty->id) . ', ' . intval(LoyaltyStateModule::getValidationId()) . ', ' . intval($loyalty->points) . ', NOW())'); }
public function hookOrderReturn($params) { include_once dirname(__FILE__) . '/LoyaltyStateModule.php'; include_once dirname(__FILE__) . '/LoyaltyModule.php'; $total_price = 0; $details = OrderReturn::getOrdersReturnDetail((int) $params['orderReturn']->id); foreach ($details as $detail) { $total_price += Db::getInstance()->getValue(' SELECT ROUND(total_price_tax_incl, 2) FROM ' . _DB_PREFIX_ . 'order_detail od WHERE id_order_detail = ' . (int) $detail['id_order_detail']); } $loyalty_new = new LoyaltyModule(); $loyalty_new->points = (int) (-1 * LoyaltyModule::getNbPointsByPrice($total_price)); $loyalty_new->id_loyalty_state = (int) LoyaltyStateModule::getCancelId(); $loyalty_new->id_order = (int) $params['orderReturn']->id_order; $loyalty_new->id_customer = (int) $params['orderReturn']->id_customer; $loyalty_new->save(); }
public function getTemplateVarOrdersReturns() { $orders_returns = array(); $orders_return = OrderReturn::getOrdersReturn($this->context->customer->id); $orderReturnPresenter = new OrderReturnPresenter(Configuration::get('PS_RETURN_PREFIX', $this->context->language->id), $this->context->link); foreach ($orders_return as $id_order_return => $order_return) { $orders_returns[$id_order_return] = $orderReturnPresenter->present($order_return); } return $orders_returns; }
public static function getOrdersReturnProducts($orderReturnId, $order) { $productsRet = OrderReturn::getOrdersReturnDetail($orderReturnId); $products = $order->getProducts(); $tmp = array(); foreach ($productsRet as $return_detail) { $tmp[$return_detail['id_order_detail']]['quantity'] = isset($tmp[$return_detail['id_order_detail']]['quantity']) ? $tmp[$return_detail['id_order_detail']]['quantity'] + (int) $return_detail['product_quantity'] : (int) $return_detail['product_quantity']; $tmp[$return_detail['id_order_detail']]['customizations'] = (int) $return_detail['id_customization']; } $resTab = array(); foreach ($products as $key => $product) { if (isset($tmp[$product['id_order_detail']])) { $resTab[$key] = $product; $resTab[$key]['product_quantity'] = $tmp[$product['id_order_detail']]['quantity']; $resTab[$key]['customizations'] = $tmp[$product['id_order_detail']]['customizations']; } } return $resTab; }
/* JS files calls */ $js_files = array(__PS_BASE_URI__ . 'js/jquery/jquery.scrollto.js', _THEME_JS_DIR_ . 'history.js'); if (Tools::isSubmit('submitReturnMerchandise')) { if (!($id_order = intval(Tools::getValue('id_order')))) { Tools::redirect('history.php'); } if (!($order_qte_input = Tools::getValue('order_qte_input'))) { Tools::redirect('order-follow.php?errorDetail1'); } if ($customizationIds = Tools::getValue('customization_ids') and !($customizationQtyInput = Tools::getValue('customization_qty_input'))) { Tools::redirect('order-follow.php?errorDetail1'); } if (!($ids_order_detail = Tools::getValue('ids_order_detail')) and !$customizationIds) { Tools::redirect('order-follow.php?errorDetail2'); } $orderReturn = new OrderReturn(); $orderReturn->id_customer = intval($cookie->id_customer); $orderReturn->id_order = $id_order; $orderReturn->question = strval(Tools::getValue('returnText')); if (empty($orderReturn->question)) { Tools::redirect('order-follow.php?errorMsg'); } if (!$orderReturn->checkEnoughProduct($ids_order_detail, $order_qte_input, $customizationIds, $customizationQtyInput)) { Tools::redirect('order-follow.php?errorQuantity'); } $orderReturn->state = 1; $orderReturn->add(); $orderReturn->addReturnDetail($ids_order_detail, $order_qte_input, $customizationIds, $customizationQtyInput); Module::hookExec('orderReturn', array('orderReturn' => $orderReturn)); Tools::redirect('order-follow.php'); }
public function ajaxProcessAddProductOnOrder() { // Load object $order = new Order((int) Tools::getValue('id_order')); if (!Validate::isLoadedObject($order)) { die(Tools::jsonEncode(array('result' => false, 'error' => Tools::displayError('The order object cannot be loaded.')))); } if ($order->hasBeenShipped()) { die(Tools::jsonEncode(array('result' => false, 'error' => Tools::displayError('You cannot add products to delivered orders. ')))); } $product_informations = $_POST['add_product']; if (isset($_POST['add_invoice'])) { $invoice_informations = $_POST['add_invoice']; } else { $invoice_informations = array(); } $product = new Product($product_informations['product_id'], false, $order->id_lang); if (!Validate::isLoadedObject($product)) { die(Tools::jsonEncode(array('result' => false, 'error' => Tools::displayError('The product object cannot be loaded.')))); } if (isset($product_informations['product_attribute_id']) && $product_informations['product_attribute_id']) { $combination = new Combination($product_informations['product_attribute_id']); if (!Validate::isLoadedObject($combination)) { die(Tools::jsonEncode(array('result' => false, 'error' => Tools::displayError('The combination object cannot be loaded.')))); } } // Total method $total_method = Cart::BOTH_WITHOUT_SHIPPING; // Create new cart $cart = new Cart(); $cart->id_shop_group = $order->id_shop_group; $cart->id_shop = $order->id_shop; $cart->id_customer = $order->id_customer; $cart->id_carrier = $order->id_carrier; $cart->id_address_delivery = $order->id_address_delivery; $cart->id_address_invoice = $order->id_address_invoice; $cart->id_currency = $order->id_currency; $cart->id_lang = $order->id_lang; $cart->secure_key = $order->secure_key; // Save new cart $cart->add(); // Save context (in order to apply cart rule) $this->context->cart = $cart; $this->context->customer = new Customer($order->id_customer); // always add taxes even if there are not displayed to the customer $use_taxes = true; $initial_product_price_tax_incl = Product::getPriceStatic($product->id, $use_taxes, isset($combination) ? $combination->id : null, 2, null, false, true, 1, false, $order->id_customer, $cart->id, $order->{Configuration::get('PS_TAX_ADDRESS_TYPE', null, null, $order->id_shop)}); // Creating specific price if needed if ($product_informations['product_price_tax_incl'] != $initial_product_price_tax_incl) { $specific_price = new SpecificPrice(); $specific_price->id_shop = 0; $specific_price->id_shop_group = 0; $specific_price->id_currency = 0; $specific_price->id_country = 0; $specific_price->id_group = 0; $specific_price->id_customer = $order->id_customer; $specific_price->id_product = $product->id; if (isset($combination)) { $specific_price->id_product_attribute = $combination->id; } else { $specific_price->id_product_attribute = 0; } $specific_price->price = $product_informations['product_price_tax_excl']; $specific_price->from_quantity = 1; $specific_price->reduction = 0; $specific_price->reduction_type = 'amount'; $specific_price->from = '0000-00-00 00:00:00'; $specific_price->to = '0000-00-00 00:00:00'; $specific_price->add(); } // Add product to cart $update_quantity = $cart->updateQty($product_informations['product_quantity'], $product->id, isset($product_informations['product_attribute_id']) ? $product_informations['product_attribute_id'] : null, isset($combination) ? $combination->id : null, 'up', 0, new Shop($cart->id_shop)); if ($update_quantity < 0) { // If product has attribute, minimal quantity is set with minimal quantity of attribute $minimal_quantity = $product_informations['product_attribute_id'] ? Attribute::getAttributeMinimalQty($product_informations['product_attribute_id']) : $product->minimal_quantity; die(Tools::jsonEncode(array('error' => sprintf(Tools::displayError('You must add %d minimum quantity', false), $minimal_quantity)))); } elseif (!$update_quantity) { die(Tools::jsonEncode(array('error' => Tools::displayError('You already have the maximum quantity available for this product.', false)))); } // If order is valid, we can create a new invoice or edit an existing invoice if ($order->hasInvoice()) { $order_invoice = new OrderInvoice($product_informations['invoice']); // Create new invoice if ($order_invoice->id == 0) { // If we create a new invoice, we calculate shipping cost $total_method = Cart::BOTH; // Create Cart rule in order to make free shipping if (isset($invoice_informations['free_shipping']) && $invoice_informations['free_shipping']) { $cart_rule = new CartRule(); $cart_rule->id_customer = $order->id_customer; $cart_rule->name = array(Configuration::get('PS_LANG_DEFAULT') => $this->l('[Generated] CartRule for Free Shipping')); $cart_rule->date_from = date('Y-m-d H:i:s', time()); $cart_rule->date_to = date('Y-m-d H:i:s', time() + 24 * 3600); $cart_rule->quantity = 1; $cart_rule->quantity_per_user = 1; $cart_rule->minimum_amount_currency = $order->id_currency; $cart_rule->reduction_currency = $order->id_currency; $cart_rule->free_shipping = true; $cart_rule->active = 1; $cart_rule->add(); // Add cart rule to cart and in order $cart->addCartRule($cart_rule->id); $values = array('tax_incl' => $cart_rule->getContextualValue(true), 'tax_excl' => $cart_rule->getContextualValue(false)); $order->addCartRule($cart_rule->id, $cart_rule->name[Configuration::get('PS_LANG_DEFAULT')], $values); } $order_invoice->id_order = $order->id; if ($order_invoice->number) { Configuration::updateValue('PS_INVOICE_START_NUMBER', false, false, null, $order->id_shop); } else { $order_invoice->number = Order::getLastInvoiceNumber() + 1; } $invoice_address = new Address((int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE', null, null, $order->id_shop)}); $carrier = new Carrier((int) $order->id_carrier); $tax_calculator = $carrier->getTaxCalculator($invoice_address); $order_invoice->total_paid_tax_excl = Tools::ps_round((double) $cart->getOrderTotal(false, $total_method), 2); $order_invoice->total_paid_tax_incl = Tools::ps_round((double) $cart->getOrderTotal($use_taxes, $total_method), 2); $order_invoice->total_products = (double) $cart->getOrderTotal(false, Cart::ONLY_PRODUCTS); $order_invoice->total_products_wt = (double) $cart->getOrderTotal($use_taxes, Cart::ONLY_PRODUCTS); $order_invoice->total_shipping_tax_excl = (double) $cart->getTotalShippingCost(null, false); $order_invoice->total_shipping_tax_incl = (double) $cart->getTotalShippingCost(); $order_invoice->total_wrapping_tax_excl = abs($cart->getOrderTotal(false, Cart::ONLY_WRAPPING)); $order_invoice->total_wrapping_tax_incl = abs($cart->getOrderTotal($use_taxes, Cart::ONLY_WRAPPING)); $order_invoice->shipping_tax_computation_method = (int) $tax_calculator->computation_method; // Update current order field, only shipping because other field is updated later $order->total_shipping += $order_invoice->total_shipping_tax_incl; $order->total_shipping_tax_excl += $order_invoice->total_shipping_tax_excl; $order->total_shipping_tax_incl += $use_taxes ? $order_invoice->total_shipping_tax_incl : $order_invoice->total_shipping_tax_excl; $order->total_wrapping += abs($cart->getOrderTotal($use_taxes, Cart::ONLY_WRAPPING)); $order->total_wrapping_tax_excl += abs($cart->getOrderTotal(false, Cart::ONLY_WRAPPING)); $order->total_wrapping_tax_incl += abs($cart->getOrderTotal($use_taxes, Cart::ONLY_WRAPPING)); $order_invoice->add(); $order_invoice->saveCarrierTaxCalculator($tax_calculator->getTaxesAmount($order_invoice->total_shipping_tax_excl)); $order_carrier = new OrderCarrier(); $order_carrier->id_order = (int) $order->id; $order_carrier->id_carrier = (int) $order->id_carrier; $order_carrier->id_order_invoice = (int) $order_invoice->id; $order_carrier->weight = (double) $cart->getTotalWeight(); $order_carrier->shipping_cost_tax_excl = (double) $order_invoice->total_shipping_tax_excl; $order_carrier->shipping_cost_tax_incl = $use_taxes ? (double) $order_invoice->total_shipping_tax_incl : (double) $order_invoice->total_shipping_tax_excl; $order_carrier->add(); } else { $order_invoice->total_paid_tax_excl += Tools::ps_round((double) $cart->getOrderTotal(false, $total_method), 2); $order_invoice->total_paid_tax_incl += Tools::ps_round((double) $cart->getOrderTotal($use_taxes, $total_method), 2); $order_invoice->total_products += (double) $cart->getOrderTotal(false, Cart::ONLY_PRODUCTS); $order_invoice->total_products_wt += (double) $cart->getOrderTotal($use_taxes, Cart::ONLY_PRODUCTS); $order_invoice->update(); } } // Create Order detail information $order_detail = new OrderDetail(); $order_detail->createList($order, $cart, $order->getCurrentOrderState(), $cart->getProducts(), isset($order_invoice) ? $order_invoice->id : 0, $use_taxes, (int) Tools::getValue('add_product_warehouse')); // update totals amount of order $order->total_products += (double) $cart->getOrderTotal(false, Cart::ONLY_PRODUCTS); $order->total_products_wt += (double) $cart->getOrderTotal($use_taxes, Cart::ONLY_PRODUCTS); $order->total_paid += Tools::ps_round((double) $cart->getOrderTotal(true, $total_method), 2); $order->total_paid_tax_excl += Tools::ps_round((double) $cart->getOrderTotal(false, $total_method), 2); $order->total_paid_tax_incl += Tools::ps_round((double) $cart->getOrderTotal($use_taxes, $total_method), 2); if (isset($order_invoice) && Validate::isLoadedObject($order_invoice)) { $order->total_shipping = $order_invoice->total_shipping_tax_incl; $order->total_shipping_tax_incl = $order_invoice->total_shipping_tax_incl; $order->total_shipping_tax_excl = $order_invoice->total_shipping_tax_excl; } // discount $order->total_discounts += (double) abs($cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS)); $order->total_discounts_tax_excl += (double) abs($cart->getOrderTotal(false, Cart::ONLY_DISCOUNTS)); $order->total_discounts_tax_incl += (double) abs($cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS)); // Save changes of order $order->update(); // Update weight SUM $order_carrier = new OrderCarrier((int) $order->getIdOrderCarrier()); if (Validate::isLoadedObject($order_carrier)) { $order_carrier->weight = (double) $order->getTotalWeight(); if ($order_carrier->update()) { $order->weight = sprintf("%.3f " . Configuration::get('PS_WEIGHT_UNIT'), $order_carrier->weight); } } // Update Tax lines $order_detail->updateTaxAmount($order); // Delete specific price if exists if (isset($specific_price)) { $specific_price->delete(); } $products = $this->getProducts($order); // Get the last product $product = end($products); $resume = OrderSlip::getProductSlipResume((int) $product['id_order_detail']); $product['quantity_refundable'] = $product['product_quantity'] - $resume['product_quantity']; $product['amount_refundable'] = $product['total_price_tax_incl'] - $resume['amount_tax_incl']; $product['amount_refund'] = Tools::displayPrice($resume['amount_tax_incl']); $product['return_history'] = OrderReturn::getProductReturnDetail((int) $product['id_order_detail']); $product['refund_history'] = OrderSlip::getProductSlipDetail((int) $product['id_order_detail']); if ($product['id_warehouse'] != 0) { $warehouse = new Warehouse((int) $product['id_warehouse']); $product['warehouse_name'] = $warehouse->name; } else { $product['warehouse_name'] = '--'; } // Get invoices collection $invoice_collection = $order->getInvoicesCollection(); $invoice_array = array(); foreach ($invoice_collection as $invoice) { $invoice->name = $invoice->getInvoiceNumberFormatted(Context::getContext()->language->id, (int) $order->id_shop); $invoice_array[] = $invoice; } // Assign to smarty informations in order to show the new product line $this->context->smarty->assign(array('product' => $product, 'order' => $order, 'currency' => new Currency($order->id_currency), 'can_edit' => $this->tabAccess['edit'], 'invoices_collection' => $invoice_collection, 'current_id_lang' => Context::getContext()->language->id, 'link' => Context::getContext()->link, 'current_index' => self::$currentIndex, 'display_warehouse' => (int) Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT'))); $this->sendChangedNotification($order); die(Tools::jsonEncode(array('result' => true, 'view' => $this->createTemplate('_product_line.tpl')->fetch(), 'can_edit' => $this->tabAccess['add'], 'order' => $order, 'invoices' => $invoice_array, 'documents_html' => $this->createTemplate('_documents.tpl')->fetch(), 'shipping_html' => $this->createTemplate('_shipping.tpl')->fetch(), 'discount_form_html' => $this->createTemplate('_discount_form.tpl')->fetch()))); }
public function getReturn() { return OrderReturn::getOrdersReturn($this->id_customer, $this->id); }
public function hookOrderReturn($params) { include_once dirname(__FILE__) . '/LoyaltyStateModule.php'; include_once dirname(__FILE__) . '/LoyaltyModule.php'; $totalPrice = 0; $details = OrderReturn::getOrdersReturnDetail((int) $params['orderReturn']->id); foreach ($details as $detail) { $price_wt = Db::getInstance()->getValue(' SELECT product_price * (1 + (tax_rate / 100)) price FROM ' . _DB_PREFIX_ . 'order_detail od WHERE id_order_detail = ' . (int) $detail['id_order_detail']); $totalPrice += number_format($price_wt, 2, '.', '') * $detail['product_quantity']; } $loyaltyNew = new LoyaltyModule(); $loyaltyNew->points = (int) (-1 * LoyaltyModule::getNbPointsByPrice($totalPrice)); $loyaltyNew->id_loyalty_state = (int) LoyaltyStateModule::getCancelId(); $loyaltyNew->id_order = (int) $params['orderReturn']->id_order; $loyaltyNew->id_customer = (int) $params['orderReturn']->id_customer; $loyaltyNew->save(); }
/** * Send a mail when a customer return an order. * * @param array $params Hook params. */ public function hookActionOrderReturn($params) { if (!$this->return_slip || empty($this->return_slip)) { return; } $context = Context::getContext(); $id_lang = (int) $context->language->id; $id_shop = (int) $context->shop->id; $configuration = Configuration::getMultiple(array('PS_SHOP_EMAIL', 'PS_MAIL_METHOD', 'PS_MAIL_SERVER', 'PS_MAIL_USER', 'PS_MAIL_PASSWD', 'PS_SHOP_NAME', 'PS_MAIL_COLOR'), $id_lang, null, $id_shop); // Shop iso $iso = Language::getIsoById((int) Configuration::get('PS_LANG_DEFAULT')); $order = new Order((int) $params['orderReturn']->id_order); $customer = new Customer((int) $params['orderReturn']->id_customer); $delivery = new Address((int) $order->id_address_delivery); $invoice = new Address((int) $order->id_address_invoice); $order_date_text = Tools::displayDate($order->date_add); if ($delivery->id_state) { $delivery_state = new State((int) $delivery->id_state); } if ($invoice->id_state) { $invoice_state = new State((int) $invoice->id_state); } $order_return_products = OrderReturn::getOrdersReturnProducts($params['orderReturn']->id, $order); $items_table = ''; foreach ($order_return_products as $key => $product) { $url = $context->link->getProductLink($product['product_id']); $items_table .= '<tr style="background-color:' . ($key % 2 ? '#DDE2E6' : '#EBECEE') . ';"> <td style="padding:0.6em 0.4em;">' . $product['product_reference'] . '</td> <td style="padding:0.6em 0.4em;"> <strong><a href="' . $url . '">' . $product['product_name'] . '</a> </strong> </td> <td style="padding:0.6em 0.4em; text-align:center;">' . (int) $product['product_quantity'] . '</td> </tr>'; } $template_vars = array('{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{email}' => $customer->email, '{delivery_block_txt}' => MailAlert::getFormatedAddress($delivery, "\n"), '{invoice_block_txt}' => MailAlert::getFormatedAddress($invoice, "\n"), '{delivery_block_html}' => MailAlert::getFormatedAddress($delivery, '<br />', array('firstname' => '<span style="color:' . $configuration['PS_MAIL_COLOR'] . '; font-weight:bold;">%s</span>', 'lastname' => '<span style="color:' . $configuration['PS_MAIL_COLOR'] . '; font-weight:bold;">%s</span>')), '{invoice_block_html}' => MailAlert::getFormatedAddress($invoice, '<br />', array('firstname' => '<span style="color:' . $configuration['PS_MAIL_COLOR'] . '; font-weight:bold;">%s</span>', 'lastname' => '<span style="color:' . $configuration['PS_MAIL_COLOR'] . '; font-weight:bold;">%s</span>')), '{delivery_company}' => $delivery->company, '{delivery_firstname}' => $delivery->firstname, '{delivery_lastname}' => $delivery->lastname, '{delivery_address1}' => $delivery->address1, '{delivery_address2}' => $delivery->address2, '{delivery_city}' => $delivery->city, '{delivery_postal_code}' => $delivery->postcode, '{delivery_country}' => $delivery->country, '{delivery_state}' => $delivery->id_state ? $delivery_state->name : '', '{delivery_phone}' => $delivery->phone ? $delivery->phone : $delivery->phone_mobile, '{delivery_other}' => $delivery->other, '{invoice_company}' => $invoice->company, '{invoice_firstname}' => $invoice->firstname, '{invoice_lastname}' => $invoice->lastname, '{invoice_address2}' => $invoice->address2, '{invoice_address1}' => $invoice->address1, '{invoice_city}' => $invoice->city, '{invoice_postal_code}' => $invoice->postcode, '{invoice_country}' => $invoice->country, '{invoice_state}' => $invoice->id_state ? $invoice_state->name : '', '{invoice_phone}' => $invoice->phone ? $invoice->phone : $invoice->phone_mobile, '{invoice_other}' => $invoice->other, '{order_name}' => $order->reference, '{shop_name}' => $configuration['PS_SHOP_NAME'], '{date}' => $order_date_text, '{items}' => $items_table, '{message}' => Tools::purifyHTML($params['orderReturn']->question)); // Send 1 email by merchant mail, because Mail::Send doesn't work with an array of recipients $merchant_mails = explode(self::__MA_MAIL_DELIMITOR__, $this->merchant_mails); foreach ($merchant_mails as $merchant_mail) { // Default language $mail_id_lang = $id_lang; $mail_iso = $iso; // Use the merchant lang if he exists as an employee $results = Db::getInstance()->executeS(' SELECT `id_lang` FROM `' . _DB_PREFIX_ . 'employee` WHERE `email` = \'' . pSQL($merchant_mail) . '\' '); if ($results) { $user_iso = Language::getIsoById((int) $results[0]['id_lang']); if ($user_iso) { $mail_id_lang = (int) $results[0]['id_lang']; $mail_iso = $user_iso; } } $dir_mail = false; if (file_exists(dirname(__FILE__) . '/mails/' . $mail_iso . '/return_slip.txt') && file_exists(dirname(__FILE__) . '/mails/' . $mail_iso . '/return_slip.html')) { $dir_mail = dirname(__FILE__) . '/mails/'; } if (file_exists(_PS_MAIL_DIR_ . $mail_iso . '/return_slip.txt') && file_exists(_PS_MAIL_DIR_ . $mail_iso . '/return_slip.html')) { $dir_mail = _PS_MAIL_DIR_; } if ($dir_mail) { Mail::Send($mail_id_lang, 'return_slip', sprintf(Mail::l('New return from order #%d - %s', $mail_id_lang), $order->id, $order->reference), $template_vars, $merchant_mail, null, $configuration['PS_SHOP_EMAIL'], $configuration['PS_SHOP_NAME'], null, null, $dir_mail, null, $id_shop); } } }
/** * 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'); }
public function viewDetails() { global $currentIndex, $cookie, $link; $irow = 0; if (!($order = $this->loadObject())) { return; } $customer = new Customer($order->id_customer); $customerStats = $customer->getStats(); $addressInvoice = new Address($order->id_address_invoice, (int) $cookie->id_lang); if (Validate::isLoadedObject($addressInvoice) and $addressInvoice->id_state) { $invoiceState = new State((int) $addressInvoice->id_state); } $addressDelivery = new Address($order->id_address_delivery, (int) $cookie->id_lang); if (Validate::isLoadedObject($addressDelivery) and $addressDelivery->id_state) { $deliveryState = new State((int) $addressDelivery->id_state); } $carrier = new Carrier($order->id_carrier); $history = $order->getHistory($cookie->id_lang); $products = $order->getProducts(); $customizedDatas = Product::getAllCustomizedDatas((int) $order->id_cart); Product::addCustomizationPrice($products, $customizedDatas); $discounts = $order->getDiscounts(); $messages = Message::getMessagesByOrderId($order->id, true); $states = OrderState::getOrderStates((int) $cookie->id_lang); $currency = new Currency($order->id_currency); $currentLanguage = new Language((int) $cookie->id_lang); $currentState = OrderHistory::getLastOrderState($order->id); $sources = ConnectionsSource::getOrderSources($order->id); $cart = Cart::getCartByOrderId($order->id); $row = array_shift($history); if ($prevOrder = Db::getInstance()->getValue('SELECT id_order FROM ' . _DB_PREFIX_ . 'orders WHERE id_order < ' . (int) $order->id . ' ORDER BY id_order DESC')) { $prevOrder = '<a href="' . $currentIndex . '&token=' . Tools::getValue('token') . '&vieworder&id_order=' . $prevOrder . '"><img style="width:24px;height:24px" src="../img/admin/arrow-left.png" /></a>'; } if ($nextOrder = Db::getInstance()->getValue('SELECT id_order FROM ' . _DB_PREFIX_ . 'orders WHERE id_order > ' . (int) $order->id . ' ORDER BY id_order ASC')) { $nextOrder = '<a href="' . $currentIndex . '&token=' . Tools::getValue('token') . '&vieworder&id_order=' . $nextOrder . '"><img style="width:24px;height:24px" src="../img/admin/arrow-right.png" /></a>'; } if ($order->total_paid != $order->total_paid_real) { echo '<center><span class="warning" style="font-size: 16px">' . $this->l('Warning:') . ' ' . Tools::displayPrice($order->total_paid_real, $currency, false) . ' ' . $this->l('paid instead of') . ' ' . Tools::displayPrice($order->total_paid, $currency, false) . ' !</span></center><div class="clear"><br /><br /></div>'; } // display bar code if module enabled $hook = Module::hookExec('invoice', array('id_order' => $order->id)); if ($hook !== false) { echo '<div style="float: right; margin: -40px 40px 10px 0;">'; echo $hook; echo '</div><br class="clear" />'; } // display order header echo ' <div style="float:left" style="width:440px">'; echo '<h2> ' . $prevOrder . ' ' . (Validate::isLoadedObject($customer) ? $customer->firstname . ' ' . $customer->lastname . ' - ' : '') . $this->l('Order #') . sprintf('%06d', $order->id) . ' ' . $nextOrder . ' </h2> <div style="width:429px"> ' . ((($currentState->invoice or $order->invoice_number) and count($products)) ? '<a href="pdf.php?id_order=' . $order->id . '&pdf"><img src="../img/admin/charged_ok.gif" alt="' . $this->l('View invoice') . '" /> ' . $this->l('View invoice') . '</a>' : '<img src="../img/admin/charged_ko.gif" alt="' . $this->l('No invoice') . '" /> ' . $this->l('No invoice')) . ' - ' . (($currentState->delivery or $order->delivery_number) ? '<a href="pdf.php?id_delivery=' . $order->delivery_number . '"><img src="../img/admin/delivery.gif" alt="' . $this->l('View delivery slip') . '" /> ' . $this->l('View delivery slip') . '</a>' : '<img src="../img/admin/delivery_ko.gif" alt="' . $this->l('No delivery slip') . '" /> ' . $this->l('No delivery slip')) . ' - <a href="javascript:window.print()"><img src="../img/admin/printer.gif" alt="' . $this->l('Print order') . '" title="' . $this->l('Print order') . '" /> ' . $this->l('Print page') . '</a> </div> <div class="clear"> </div>'; /* Display current status */ echo ' <table cellspacing="0" cellpadding="0" class="table" style="width: 429px"> <tr> <th>' . Tools::displayDate($row['date_add'], (int) $cookie->id_lang, true) . '</th> <th><img src="../img/os/' . $row['id_order_state'] . '.gif" /></th> <th>' . stripslashes($row['ostate_name']) . '</th> <th>' . (!empty($row['employee_lastname']) ? '(' . stripslashes(Tools::substr($row['employee_firstname'], 0, 1)) . '. ' . stripslashes($row['employee_lastname']) . ')' : '') . '</th> </tr>'; /* Display previous status */ foreach ($history as $row) { echo ' <tr class="' . ($irow++ % 2 ? 'alt_row' : '') . '"> <td>' . Tools::displayDate($row['date_add'], (int) $cookie->id_lang, true) . '</td> <td><img src="../img/os/' . $row['id_order_state'] . '.gif" /></td> <td>' . stripslashes($row['ostate_name']) . '</td> <td>' . (!empty($row['employee_lastname']) ? '(' . stripslashes(Tools::substr($row['employee_firstname'], 0, 1)) . '. ' . stripslashes($row['employee_lastname']) . ')' : '') . '</td> </tr>'; } echo ' </table> <br />'; /* Display status form */ echo ' <form action="' . $currentIndex . '&view' . $this->table . '&token=' . $this->token . '" method="post" style="text-align:center;"> <select name="id_order_state">'; $currentStateTab = $order->getCurrentStateFull($cookie->id_lang); foreach ($states as $state) { echo '<option value="' . $state['id_order_state'] . '"' . ($state['id_order_state'] == $currentStateTab['id_order_state'] ? ' selected="selected"' : '') . '>' . stripslashes($state['name']) . '</option>'; } echo ' </select> <input type="hidden" name="id_order" value="' . $order->id . '" /> <input type="submit" name="submitState" value="' . $this->l('Change') . '" class="button" /> </form>'; /* Display customer information */ if (Validate::isLoadedObject($customer)) { echo '<br /> <fieldset style="width: 400px"> <legend><img src="../img/admin/tab-customers.gif" /> ' . $this->l('Customer information') . '</legend> <span style="font-weight: bold; font-size: 14px;"><a href="?tab=AdminCustomers&id_customer=' . $customer->id . '&viewcustomer&token=' . Tools::getAdminToken('AdminCustomers' . (int) Tab::getIdFromClassName('AdminCustomers') . (int) $cookie->id_employee) . '"> ' . $customer->firstname . ' ' . $customer->lastname . '</a></span> (' . $this->l('#') . $customer->id . ')<br /> (<a href="mailto:' . $customer->email . '">' . $customer->email . '</a>)<br /><br />'; if ($customer->isGuest()) { echo ' ' . $this->l('This order has been placed by a') . ' <b>' . $this->l('guest') . '</b>'; if (!Customer::customerExists($customer->email)) { echo '<form method="POST" action="index.php?tab=AdminCustomers&id_customer=' . (int) $customer->id . '&token=' . Tools::getAdminTokenLite('AdminCustomers') . '"> <input type="hidden" name="id_lang" value="' . (int) $order->id_lang . '" /> <p class="center"><input class="button" type="submit" name="submitGuestToCustomer" value="' . $this->l('Transform to customer') . '" /></p> ' . $this->l('This feature will generate a random password and send an e-mail to the customer') . ' </form>'; } else { echo '<div><b style="color:red;">' . $this->l('A registered customer account exists with the same email address') . '</b></div>'; } } else { echo $this->l('Account registered:') . ' ' . Tools::displayDate($customer->date_add, (int) $cookie->id_lang, true) . '<br /> ' . $this->l('Valid orders placed:') . ' <b>' . $customerStats['nb_orders'] . '</b><br /> ' . $this->l('Total paid since registration:') . ' <b>' . Tools::displayPrice(Tools::ps_round(Tools::convertPrice($customerStats['total_orders'], $currency), 2), $currency, false) . '</b><br />'; } echo '</fieldset>'; } /* Display sources */ if (sizeof($sources)) { echo '<br /> <fieldset style="width: 400px;"><legend><img src="../img/admin/tab-stats.gif" /> ' . $this->l('Sources') . '</legend><ul ' . (sizeof($sources) > 3 ? 'style="height: 200px; overflow-y: scroll; width: 360px;"' : '') . '>'; foreach ($sources as $source) { echo '<li> ' . Tools::displayDate($source['date_add'], (int) $cookie->id_lang, true) . '<br /> <b>' . $this->l('From:') . '</b> <a href="' . $source['http_referer'] . '">' . preg_replace('/^www./', '', parse_url($source['http_referer'], PHP_URL_HOST)) . '</a><br /> <b>' . $this->l('To:') . '</b> ' . $source['request_uri'] . '<br /> ' . ($source['keywords'] ? '<b>' . $this->l('Keywords:') . '</b> ' . $source['keywords'] . '<br />' : '') . '<br /> </li>'; } echo '</ul></fieldset>'; } // display hook specified to this page : AdminOrder if (($hook = Module::hookExec('adminOrder', array('id_order' => $order->id))) !== false) { echo $hook; } echo ' </div> <div style="float: left; margin-left: 40px">'; /* Display invoice information */ echo '<fieldset style="width: 400px">'; if (($currentState->invoice or $order->invoice_number) and count($products)) { echo '<legend><a href="pdf.php?id_order=' . $order->id . '&pdf"><img src="../img/admin/charged_ok.gif" /> ' . $this->l('Invoice') . '</a></legend> <a href="pdf.php?id_order=' . $order->id . '&pdf">' . $this->l('Invoice #') . '<b>' . Configuration::get('PS_INVOICE_PREFIX', (int) $cookie->id_lang) . sprintf('%06d', $order->invoice_number) . '</b></a> <br />' . $this->l('Created on:') . ' ' . Tools::displayDate($order->invoice_date, (int) $cookie->id_lang, true); } else { echo '<legend><img src="../img/admin/charged_ko.gif" />' . $this->l('Invoice') . '</legend> ' . $this->l('No invoice yet.'); } echo '</fieldset><br />'; /* Display shipping infos */ echo ' <fieldset style="width:400px"> <legend><img src="../img/admin/delivery.gif" /> ' . $this->l('Shipping information') . '</legend> ' . $this->l('Total weight:') . ' <b>' . number_format($order->getTotalWeight(), 3) . ' ' . Configuration::get('PS_WEIGHT_UNIT') . '</b><br /> ' . $this->l('Carrier:') . ' <b>' . ($carrier->name == '0' ? Configuration::get('PS_SHOP_NAME') : $carrier->name) . '</b><br /> ' . (($currentState->delivery or $order->delivery_number) ? '<br /><a href="pdf.php?id_delivery=' . $order->delivery_number . '">' . $this->l('Delivery slip #') . '<b>' . Configuration::get('PS_DELIVERY_PREFIX', (int) $cookie->id_lang) . sprintf('%06d', $order->delivery_number) . '</b></a><br />' : ''); if ($order->shipping_number) { echo $this->l('Tracking number:') . ' <b>' . $order->shipping_number . '</b> ' . (!empty($carrier->url) ? '(<a href="' . str_replace('@', $order->shipping_number, $carrier->url) . '" target="_blank">' . $this->l('Track the shipment') . '</a>)' : ''); } /* Carrier module */ if ($carrier->is_module == 1) { $module = Module::getInstanceByName($carrier->external_module_name); if (method_exists($module, 'displayInfoByCart')) { echo call_user_func(array($module, 'displayInfoByCart'), $order->id_cart); } } /* Display shipping number field */ if ($carrier->url && $order->hasBeenShipped()) { echo ' <form action="' . $currentIndex . '&view' . $this->table . '&token=' . $this->token . '" method="post" style="margin-top:10px;"> <input type="text" name="shipping_number" value="' . $order->shipping_number . '" /> <input type="hidden" name="id_order" value="' . $order->id . '" /> <input type="submit" name="submitShippingNumber" value="' . $this->l('Set shipping number') . '" class="button" /> </form>'; } echo ' </fieldset>'; /* Display summary order */ echo ' <br /> <fieldset style="width: 400px"> <legend><img src="../img/admin/details.gif" /> ' . $this->l('Order details') . '</legend> <label>' . $this->l('Original cart:') . ' </label> <div style="margin: 2px 0 1em 190px;"><a href="?tab=AdminCarts&id_cart=' . $cart->id . '&viewcart&token=' . Tools::getAdminToken('AdminCarts' . (int) Tab::getIdFromClassName('AdminCarts') . (int) $cookie->id_employee) . '">' . $this->l('Cart #') . sprintf('%06d', $cart->id) . '</a></div> <label>' . $this->l('Payment mode:') . ' </label> <div style="margin: 2px 0 1em 190px;">' . Tools::substr($order->payment, 0, 32) . ' ' . ($order->module ? '(' . $order->module . ')' : '') . '</div> <div style="margin: 2px 0 1em 50px;"> <table class="table" width="300px;" cellspacing="0" cellpadding="0"> <tr><td width="150px;">' . $this->l('Products') . '</td><td align="right">' . Tools::displayPrice($order->getTotalProductsWithTaxes(), $currency, false) . '</td></tr> ' . ($order->total_discounts > 0 ? '<tr><td>' . $this->l('Discounts') . '</td><td align="right">-' . Tools::displayPrice($order->total_discounts, $currency, false) . '</td></tr>' : '') . ' ' . ($order->total_wrapping > 0 ? '<tr><td>' . $this->l('Wrapping') . '</td><td align="right">' . Tools::displayPrice($order->total_wrapping, $currency, false) . '</td></tr>' : '') . ' <tr><td>' . $this->l('Shipping') . '</td><td align="right">' . Tools::displayPrice($order->total_shipping, $currency, false) . '</td></tr> <tr style="font-size: 20px"><td>' . $this->l('Total') . '</td><td align="right">' . Tools::displayPrice($order->total_paid, $currency, false) . ($order->total_paid != $order->total_paid_real ? '<br /><font color="red">(' . $this->l('Paid:') . ' ' . Tools::displayPrice($order->total_paid_real, $currency, false, false) . ')</font>' : '') . '</td></tr> </table> </div> <div style="float: left; margin-right: 10px; margin-left: 42px;"> <span class="bold">' . $this->l('Recycled package:') . '</span> ' . ($order->recyclable ? '<img src="../img/admin/enabled.gif" />' : '<img src="../img/admin/disabled.gif" />') . ' </div> <div style="float: left; margin-right: 10px;"> <span class="bold">' . $this->l('Gift wrapping:') . '</span> ' . ($order->gift ? '<img src="../img/admin/enabled.gif" /> </div> <div style="clear: left; margin: 0px 42px 0px 42px; padding-top: 2px;"> ' . (!empty($order->gift_message) ? '<div style="border: 1px dashed #999; padding: 5px; margin-top: 8px;"><b>' . $this->l('Message:') . '</b><br />' . nl2br2($order->gift_message) . '</div>' : '') : '<img src="../img/admin/disabled.gif" />') . ' </div> </fieldset>'; echo '</div> <div class="clear"> </div>'; /* Display adresses : delivery & invoice */ echo '<div class="clear"> </div> <div style="float: left"> <fieldset style="width: 400px;"> <legend><img src="../img/admin/delivery.gif" alt="' . $this->l('Shipping address') . '" />' . $this->l('Shipping address') . '</legend> <div style="float: right"> <a href="?tab=AdminAddresses&id_address=' . $addressDelivery->id . '&addaddress&realedit=1&id_order=' . $order->id . ($addressDelivery->id == $addressInvoice->id ? '&address_type=1' : '') . '&token=' . Tools::getAdminToken('AdminAddresses' . (int) Tab::getIdFromClassName('AdminAddresses') . (int) $cookie->id_employee) . '&back=' . urlencode($_SERVER['REQUEST_URI']) . '"><img src="../img/admin/edit.gif" /></a> <a href="http://maps.google.com/maps?f=q&hl=' . $currentLanguage->iso_code . '&geocode=&q=' . $addressDelivery->address1 . ' ' . $addressDelivery->postcode . ' ' . $addressDelivery->city . ($addressDelivery->id_state ? ' ' . $deliveryState->name : '') . '" target="_blank"><img src="../img/admin/google.gif" alt="" class="middle" /></a> </div> ' . $this->displayAddressDetail($addressDelivery) . (!empty($addressDelivery->other) ? '<hr />' . $addressDelivery->other . '<br />' : '') . '</fieldset> </div> <div style="float: left; margin-left: 40px"> <fieldset style="width: 400px;"> <legend><img src="../img/admin/invoice.gif" alt="' . $this->l('Invoice address') . '" />' . $this->l('Invoice address') . '</legend> <div style="float: right"><a href="?tab=AdminAddresses&id_address=' . $addressInvoice->id . '&addaddress&realedit=1&id_order=' . $order->id . ($addressDelivery->id == $addressInvoice->id ? '&address_type=2' : '') . '&back=' . urlencode($_SERVER['REQUEST_URI']) . '&token=' . Tools::getAdminToken('AdminAddresses' . (int) Tab::getIdFromClassName('AdminAddresses') . (int) $cookie->id_employee) . '"><img src="../img/admin/edit.gif" /></a></div> ' . $this->displayAddressDetail($addressInvoice) . (!empty($addressInvoice->other) ? '<hr />' . $addressInvoice->other . '<br />' : '') . '</fieldset> </div> <div class="clear"> </div>'; // List of products echo ' <a name="products"><br /></a> <form action="' . $currentIndex . '&submitCreditSlip&vieworder&token=' . $this->token . '" method="post" onsubmit="return orderDeleteProduct(\'' . $this->l('Cannot return this product') . '\', \'' . $this->l('Quantity to cancel is greater than quantity available') . '\');"> <input type="hidden" name="id_order" value="' . $order->id . '" /> <fieldset style="width: 868px; "> <legend><img src="../img/admin/cart.gif" alt="' . $this->l('Products') . '" />' . $this->l('Products') . '</legend> <div style="float:left;"> <table style="width: 868px;" cellspacing="0" cellpadding="0" class="table" id="orderProducts"> <tr> <th align="center" style="width: 60px"> </th> <th>' . $this->l('Product') . '</th> <th style="width: 80px; text-align: center">' . $this->l('UP') . ' <sup>*</sup></th> <th style="width: 20px; text-align: center">' . $this->l('Qty') . '</th> ' . ($order->hasBeenPaid() ? '<th style="width: 20px; text-align: center">' . $this->l('Refunded') . '</th>' : '') . ' ' . ($order->hasBeenDelivered() ? '<th style="width: 20px; text-align: center">' . $this->l('Returned') . '</th>' : '') . ' <th style="width: 30px; text-align: center">' . $this->l('Stock') . '</th> <th style="width: 90px; text-align: center">' . $this->l('Total') . ' <sup>*</sup></th> <th colspan="2" style="width: 120px;"><img src="../img/admin/delete.gif" alt="' . $this->l('Products') . '" /> ' . ($order->hasBeenDelivered() ? $this->l('Return') : ($order->hasBeenPaid() ? $this->l('Refund') : $this->l('Cancel'))) . '</th>'; echo ' </tr>'; $tokenCatalog = Tools::getAdminToken('AdminCatalog' . (int) Tab::getIdFromClassName('AdminCatalog') . (int) $cookie->id_employee); foreach ($products as $k => $product) { if ($order->getTaxCalculationMethod() == PS_TAX_EXC) { $product_price = $product['product_price'] + $product['ecotax']; } else { $product_price = $product['product_price_wt']; } $image = array(); if (isset($product['product_attribute_id']) and (int) $product['product_attribute_id']) { $image = Db::getInstance()->getRow(' SELECT id_image FROM ' . _DB_PREFIX_ . 'product_attribute_image WHERE id_product_attribute = ' . (int) $product['product_attribute_id']); } if (!isset($image['id_image']) or !$image['id_image']) { $image = Db::getInstance()->getRow(' SELECT id_image FROM ' . _DB_PREFIX_ . 'image WHERE id_product = ' . (int) $product['product_id'] . ' AND cover = 1'); } $stock = Db::getInstance()->getRow(' SELECT ' . ($product['product_attribute_id'] ? 'pa' : 'p') . '.quantity FROM ' . _DB_PREFIX_ . 'product p ' . ($product['product_attribute_id'] ? 'LEFT JOIN ' . _DB_PREFIX_ . 'product_attribute pa ON p.id_product = pa.id_product' : '') . ' WHERE p.id_product = ' . (int) $product['product_id'] . ' ' . ($product['product_attribute_id'] ? 'AND pa.id_product_attribute = ' . (int) $product['product_attribute_id'] : '')); if (isset($image['id_image'])) { $target = _PS_TMP_IMG_DIR_ . 'product_mini_' . (int) $product['product_id'] . (isset($product['product_attribute_id']) ? '_' . (int) $product['product_attribute_id'] : '') . '.jpg'; if (file_exists($target)) { $products[$k]['image_size'] = getimagesize($target); } } // Customization display $this->displayCustomizedDatas($customizedDatas, $product, $currency, $image, $tokenCatalog, $k); // Normal display if ($product['product_quantity'] > $product['customizationQuantityTotal']) { $quantity = $product['product_quantity'] - $product['customizationQuantityTotal']; $imageObj = new Image($image['id_image']); echo ' <tr' . ((isset($image['id_image']) and isset($products[$k]['image_size'])) ? ' height="' . ($products[$k]['image_size'][1] + 7) . '"' : '') . '> <td align="center">' . (isset($image['id_image']) ? cacheImage(_PS_IMG_DIR_ . 'p/' . $imageObj->getExistingImgPath() . '.jpg', 'product_mini_' . (int) $product['product_id'] . (isset($product['product_attribute_id']) ? '_' . (int) $product['product_attribute_id'] : '') . '.jpg', 45, 'jpg') : '--') . '</td> <td><a href="index.php?tab=AdminCatalog&id_product=' . $product['product_id'] . '&updateproduct&token=' . $tokenCatalog . '"> <span class="productName">' . $product['product_name'] . '</span><br /> ' . ($product['product_reference'] ? $this->l('Ref:') . ' ' . $product['product_reference'] . '<br />' : '') . ($product['product_supplier_reference'] ? $this->l('Ref Supplier:') . ' ' . $product['product_supplier_reference'] : '') . '</a></td> <td align="center">' . Tools::displayPrice($product_price, $currency, false) . '</td> <td align="center" class="productQuantity" ' . ($quantity > 1 ? 'style="font-weight:700;font-size:1.1em;color:red"' : '') . '>' . (int) $quantity . '</td> ' . ($order->hasBeenPaid() ? '<td align="center" class="productQuantity">' . (int) $product['product_quantity_refunded'] . '</td>' : '') . ' ' . ($order->hasBeenDelivered() ? '<td align="center" class="productQuantity">' . (int) $product['product_quantity_return'] . '</td>' : '') . ' <td align="center" class="productQuantity">' . (int) $stock['quantity'] . '</td> <td align="center">' . Tools::displayPrice(Tools::ps_round($product_price, 2) * ((int) $product['product_quantity'] - $product['customizationQuantityTotal']), $currency, false) . '</td> <td align="center" class="cancelCheck"> <input type="hidden" name="totalQtyReturn" id="totalQtyReturn" value="' . (int) $product['product_quantity_return'] . '" /> <input type="hidden" name="totalQty" id="totalQty" value="' . (int) $product['product_quantity'] . '" /> <input type="hidden" name="productName" id="productName" value="' . $product['product_name'] . '" />'; if ((!$order->hasBeenDelivered() or Configuration::get('PS_ORDER_RETURN')) and (int) $product['product_quantity_return'] < (int) $product['product_quantity']) { echo ' <input type="checkbox" name="id_order_detail[' . $k . ']" id="id_order_detail[' . $k . ']" value="' . $product['id_order_detail'] . '" onchange="setCancelQuantity(this, ' . (int) $product['id_order_detail'] . ', ' . (int) ($product['product_quantity_in_stock'] - $product['customizationQuantityTotal'] - $product['product_quantity_reinjected']) . ')" ' . ((int) ($product['product_quantity_return'] + $product['product_quantity_refunded']) >= (int) $product['product_quantity'] ? 'disabled="disabled" ' : '') . '/>'; } else { echo '--'; } echo ' </td> <td class="cancelQuantity">'; if ((int) ($product['product_quantity_return'] + $product['product_quantity_refunded']) >= (int) $product['product_quantity']) { echo '<input type="hidden" name="cancelQuantity[' . $k . ']" value="0" />'; } elseif (!$order->hasBeenDelivered() or Configuration::get('PS_ORDER_RETURN')) { echo ' <input type="text" id="cancelQuantity_' . (int) $product['id_order_detail'] . '" name="cancelQuantity[' . $k . ']" size="2" onclick="selectCheckbox(this);" value="" /> '; } echo $this->getCancelledProductNumber($order, $product) . ' </td> </tr>'; } } echo ' </table> <div style="float:left; width:280px; margin-top:15px;"><sup>*</sup> ' . $this->l('According to the group of this customer, prices are printed:') . ' ' . ($order->getTaxCalculationMethod() == PS_TAX_EXC ? $this->l('tax excluded.') : $this->l('tax included.')) . (!Configuration::get('PS_ORDER_RETURN') ? '<br /><br />' . $this->l('Merchandise returns are disabled') : '') . '</div>'; if (sizeof($discounts)) { echo ' <div style="float:right; width:280px; margin-top:15px;"> <table cellspacing="0" cellpadding="0" class="table" style="width:100%;"> <tr> <th><img src="../img/admin/coupon.gif" alt="' . $this->l('Discounts') . '" />' . $this->l('Discount name') . '</th> <th align="center" style="width: 100px">' . $this->l('Value') . '</th> </tr>'; foreach ($discounts as $discount) { echo ' <tr> <td>' . $discount['name'] . '</td> <td align="center">' . ($discount['value'] != 0.0 ? '- ' : '') . Tools::displayPrice($discount['value'], $currency, false) . '</td> </tr>'; } echo ' </table></div>'; } echo ' </div>'; // Cancel product echo ' <div style="clear:both; height:15px;"> </div> <div style="float: right; width: 160px;">'; if ($order->hasBeenDelivered() and Configuration::get('PS_ORDER_RETURN')) { echo ' <input type="checkbox" id="reinjectQuantities" name="reinjectQuantities" class="button" /> <label for="reinjectQuantities" style="float:none; font-weight:normal;">' . $this->l('Re-stock products') . '</label><br />'; } if (!$order->hasBeenDelivered() and $order->hasBeenPaid() or $order->hasBeenDelivered() and Configuration::get('PS_ORDER_RETURN')) { echo ' <input type="checkbox" id="generateCreditSlip" name="generateCreditSlip" class="button" onclick="toogleShippingCost(this)" /> <label for="generateCreditSlip" style="float:none; font-weight:normal;">' . $this->l('Generate a credit slip') . '</label><br /> <input type="checkbox" id="generateDiscount" name="generateDiscount" class="button" onclick="toogleShippingCost(this)" /> <label for="generateDiscount" style="float:none; font-weight:normal;">' . $this->l('Generate a voucher') . '</label><br /> <span id="spanShippingBack" style="display:none;"><input type="checkbox" id="shippingBack" name="shippingBack" class="button" /> <label for="shippingBack" style="float:none; font-weight:normal;">' . $this->l('Repay shipping costs') . '</label><br /></span>'; } if (!$order->hasBeenDelivered() or $order->hasBeenDelivered() and Configuration::get('PS_ORDER_RETURN')) { echo ' <div style="text-align:center; margin-top:5px;"><input type="submit" name="cancelProduct" value="' . ($order->hasBeenDelivered() ? $this->l('Return products') : ($order->hasBeenPaid() ? $this->l('Refund products') : $this->l('Cancel products'))) . '" class="button" style="margin-top:8px;" /></div>'; } echo ' </div>'; echo ' </fieldset> </form> <div class="clear" style="height:20px;"> </div>'; /* Display send a message to customer & returns/credit slip*/ $returns = OrderReturn::getOrdersReturn($order->id_customer, $order->id); $slips = OrderSlip::getOrdersSlip($order->id_customer, $order->id); echo ' <div style="float: left"> <form action="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '&token=' . $this->token . '" method="post" onsubmit="if (getE(\'visibility\').checked == true) return confirm(\'' . $this->l('Do you want to send this message to the customer?', __CLASS__, true, false) . '\');"> <fieldset style="width: 400px;"> <legend style="cursor: pointer;" onclick="$(\'#message\').slideToggle();$(\'#message_m\').slideToggle();return false"><img src="../img/admin/email_edit.gif" /> ' . $this->l('New message') . '</legend> <div id="message_m" style="display: ' . (Tools::getValue('message') ? 'none' : 'block') . '; overflow: auto; width: 400px;"> <a href="#" onclick="$(\'#message\').slideToggle();$(\'#message_m\').slideToggle();return false"><b>' . $this->l('Click here') . '</b> ' . $this->l('to add a comment or send a message to the customer') . '</a> </div> <div id="message" style="display: ' . (Tools::getValue('message') ? 'block' : 'none') . '"> <select name="order_message" id="order_message" onchange="orderOverwriteMessage(this, \'' . $this->l('Do you want to overwrite your existing message?') . '\')"> <option value="0" selected="selected">-- ' . $this->l('Choose a standard message') . ' --</option>'; $orderMessages = OrderMessage::getOrderMessages((int) $order->id_lang); foreach ($orderMessages as $orderMessage) { echo ' <option value="' . htmlentities($orderMessage['message'], ENT_COMPAT, 'UTF-8') . '">' . $orderMessage['name'] . '</option>'; } echo ' </select><br /><br /> <b>' . $this->l('Display to consumer?') . '</b> <input type="radio" name="visibility" id="visibility" value="0" /> ' . $this->l('Yes') . ' <input type="radio" name="visibility" value="1" checked="checked" /> ' . $this->l('No') . ' <p id="nbchars" style="display:inline;font-size:10px;color:#666;"></p><br /><br /> <textarea id="txt_msg" name="message" cols="50" rows="8" onKeyUp="var length = document.getElementById(\'txt_msg\').value.length; if (length > 600) length = \'600+\'; document.getElementById(\'nbchars\').innerHTML = \'' . $this->l('600 chars max') . ' (\' + length + \')\';">' . htmlentities(Tools::getValue('message'), ENT_COMPAT, 'UTF-8') . '</textarea><br /><br /> <input type="hidden" name="id_order" value="' . (int) $order->id . '" /> <input type="hidden" name="id_customer" value="' . (int) $order->id_customer . '" /> <input type="submit" class="button" name="submitMessage" value="' . $this->l('Send') . '" /> </div> </fieldset> </form>'; /* Display list of messages */ if (sizeof($messages)) { echo ' <br /> <fieldset style="width: 400px;"> <legend><img src="../img/admin/email.gif" /> ' . $this->l('Messages') . '</legend>'; foreach ($messages as $message) { echo '<div style="overflow:auto; width:400px;" ' . ($message['is_new_for_me'] ? 'class="new_message"' : '') . '>'; if ($message['is_new_for_me']) { echo '<a class="new_message" title="' . $this->l('Mark this message as \'viewed\'') . '" href="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '&token=' . $this->token . '&messageReaded=' . (int) $message['id_message'] . '"><img src="../img/admin/enabled.gif" alt="" /></a>'; } echo $this->l('At') . ' <i>' . Tools::displayDate($message['date_add'], (int) $cookie->id_lang, true); echo '</i> ' . $this->l('from') . ' <b>' . ($message['elastname'] ? $message['efirstname'] . ' ' . $message['elastname'] : $message['cfirstname'] . ' ' . $message['clastname']) . '</b>'; echo (int) $message['private'] == 1 ? '<span style="color:red; font-weight:bold;">' . $this->l('Private:') . '</span>' : ''; echo '<p>' . nl2br2($message['message']) . '</p>'; echo '</div>'; echo '<br />'; } echo '<p class="info">' . $this->l('When you read a message, please click on the green check.') . '</p>'; echo '</fieldset>'; } echo '</div>'; /* Display return product */ echo '<div style="float: left; margin-left: 40px"> <fieldset style="width: 400px;"> <legend><img src="../img/admin/return.gif" alt="' . $this->l('Merchandise returns') . '" />' . $this->l('Merchandise returns') . '</legend>'; if (!sizeof($returns)) { echo $this->l('No merchandise return for this order.'); } else { foreach ($returns as $return) { $state = new OrderReturnState($return['state']); echo '(' . Tools::displayDate($return['date_upd'], $cookie->id_lang) . ') : <b><a href="index.php?tab=AdminReturn&id_order_return=' . $return['id_order_return'] . '&updateorder_return&token=' . Tools::getAdminToken('AdminReturn' . (int) Tab::getIdFromClassName('AdminReturn') . (int) $cookie->id_employee) . '">' . $this->l('#') . sprintf('%06d', $return['id_order_return']) . '</a></b> - ' . $state->name[$cookie->id_lang] . '<br />'; } } echo '</fieldset>'; /* Display credit slip */ echo ' <br /> <fieldset style="width: 400px;"> <legend><img src="../img/admin/slip.gif" alt="' . $this->l('Credit slip') . '" />' . $this->l('Credit slip') . '</legend>'; if (!sizeof($slips)) { echo $this->l('No slip for this order.'); } else { foreach ($slips as $slip) { echo '(' . Tools::displayDate($slip['date_upd'], $cookie->id_lang) . ') : <b><a href="pdf.php?id_order_slip=' . $slip['id_order_slip'] . '">' . $this->l('#') . sprintf('%06d', $slip['id_order_slip']) . '</a></b><br />'; } } echo '</fieldset> </div>'; echo '<div class="clear"> </div>'; echo '<br /><br /><a href="' . $currentIndex . '&token=' . $this->token . '"><img src="../img/admin/arrow2.gif" /> ' . $this->l('Back to list') . '</a><br />'; }
public function renderView() { $order = new Order(Tools::getValue('id_order')); if (!Validate::isLoadedObject($order)) { throw new PrestaShopException('object can\'t be loaded'); } $customer = new Customer($order->id_customer); $carrier = new Carrier($order->id_carrier); $products = $this->getProducts($order); // Carrier module call $carrier_module_call = null; if ($carrier->is_module) { $module = Module::getInstanceByName($carrier->external_module_name); if (method_exists($module, 'displayInfoByCart')) { $carrier_module_call = call_user_func(array($module, 'displayInfoByCart'), $order->id_cart); } } // Retrieve addresses information $addressInvoice = new Address($order->id_address_invoice, $this->context->language->id); if (Validate::isLoadedObject($addressInvoice) && $addressInvoice->id_state) { $invoiceState = new State((int) $addressInvoice->id_state); } if ($order->id_address_invoice == $order->id_address_delivery) { $addressDelivery = $addressInvoice; if (isset($invoiceState)) { $deliveryState = $invoiceState; } } else { $addressDelivery = new Address($order->id_address_delivery, $this->context->language->id); if (Validate::isLoadedObject($addressDelivery) && $addressDelivery->id_state) { $deliveryState = new State((int) $addressDelivery->id_state); } } $this->toolbar_title = sprintf($this->l('Order #%1$d (%2$s) - %3$s %4$s'), $order->id, $order->reference, $customer->firstname, $customer->lastname); // gets warehouses to ship products, if and only if advanced stock management is activated $warehouse_list = null; $order_details = $order->getOrderDetailList(); foreach ($order_details as $order_detail) { $product = new Product($order_detail['product_id']); if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && $product->advanced_stock_management) { $warehouses = Warehouse::getWarehousesByProductId($order_detail['product_id'], $order_detail['product_attribute_id']); foreach ($warehouses as $warehouse) { if (!isset($warehouse_list[$warehouse['id_warehouse']])) { $warehouse_list[$warehouse['id_warehouse']] = $warehouse; } } } } $payment_methods = array(); foreach (PaymentModule::getInstalledPaymentModules() as $payment) { $module = Module::getInstanceByName($payment['name']); if (Validate::isLoadedObject($module)) { $payment_methods[] = $module->displayName; } } // display warning if there are products out of stock $display_out_of_stock_warning = false; $current_order_state = $order->getCurrentOrderState(); if ($current_order_state->delivery != 1 && $current_order_state->shipped != 1) { $display_out_of_stock_warning = true; } // products current stock (from stock_available) foreach ($products as &$product) { $product['current_stock'] = StockAvailable::getQuantityAvailableByProduct($product['product_id'], $product['product_attribute_id'], $product['id_shop']); $resume = OrderSlip::getProductSlipResume($product['id_order_detail']); $product['quantity_refundable'] = $product['product_quantity'] - $resume['product_quantity']; $product['amount_refundable'] = $product['total_price_tax_incl'] - $resume['amount_tax_incl']; $product['amount_refund'] = Tools::displayPrice($resume['amount_tax_incl']); $product['refund_history'] = OrderSlip::getProductSlipDetail($product['id_order_detail']); $product['return_history'] = OrderReturn::getProductReturnDetail($product['id_order_detail']); // if the current stock requires a warning if ($product['current_stock'] == 0 && $display_out_of_stock_warning) { $this->displayWarning($this->l('This product is out of stock: ') . ' ' . $product['product_name']); } } // Smarty assign $this->tpl_view_vars = array('order' => $order, 'cart' => new Cart($order->id_cart), 'customer' => $customer, 'customer_addresses' => $customer->getAddresses($this->context->language->id), 'addresses' => array('delivery' => $addressDelivery, 'deliveryState' => isset($deliveryState) ? $deliveryState : null, 'invoice' => $addressInvoice, 'invoiceState' => isset($invoiceState) ? $invoiceState : null), 'customerStats' => $customer->getStats(), 'products' => $products, 'discounts' => $order->getCartRules(), 'orders_total_paid_tax_incl' => $order->getOrdersTotalPaid(), 'total_paid' => $order->getTotalPaid(), 'returns' => OrderReturn::getOrdersReturn($order->id_customer, $order->id), 'customer_thread_message' => CustomerThread::getCustomerMessages($order->id_customer, 0), 'orderMessages' => OrderMessage::getOrderMessages($order->id_lang), 'messages' => Message::getMessagesByOrderId($order->id, true), 'carrier' => new Carrier($order->id_carrier), 'history' => $order->getHistory($this->context->language->id), 'states' => OrderState::getOrderStates($this->context->language->id), 'warehouse_list' => $warehouse_list, 'sources' => ConnectionsSource::getOrderSources($order->id), 'currentState' => $order->getCurrentOrderState(), 'currency' => new Currency($order->id_currency), 'currencies' => Currency::getCurrencies(), 'previousOrder' => $order->getPreviousOrderId(), 'nextOrder' => $order->getNextOrderId(), 'current_index' => self::$currentIndex, 'carrierModuleCall' => $carrier_module_call, 'iso_code_lang' => $this->context->language->iso_code, 'id_lang' => $this->context->language->id, 'can_edit' => $this->tabAccess['edit'] == 1, 'current_id_lang' => $this->context->language->id, 'invoices_collection' => $order->getInvoicesCollection(), 'not_paid_invoices_collection' => $order->getNotPaidInvoicesCollection(), 'payment_methods' => $payment_methods, 'invoice_management_active' => Configuration::get('PS_INVOICE')); return parent::renderView(); }
public function displayForm() { global $currentIndex, $cookie; $obj = $this->loadObject(true); $defaultLanguage = intval(Configuration::get('PS_LANG_DEFAULT')); $languages = Language::getLanguages(); echo ' <script type="text/javascript"> id_language = Number(' . $defaultLanguage . '); </script> <form action="' . $currentIndex . '&submitAdd' . $this->table . '=1&token=' . $this->token . '" method="post"> ' . ($obj->id ? '<input type="hidden" name="id_' . $this->table . '" value="' . $obj->id . '" />' : '') . ' <input type="hidden" name="id_order" value="' . $obj->id_order . '" /> <input type="hidden" name="id_customer" value="' . $obj->id_customer . '" /> <fieldset class="width3"><legend><img src="../img/admin/return.gif" />' . $this->l('Return Merchandise Authorization (RMA)') . '</legend> <label>' . $this->l('Customer:') . ' </label>'; $customer = new Customer(intval($obj->id_customer)); echo ' <div class="margin-form">' . $customer->firstname . ' ' . $customer->lastname . ' <p style="clear: both"><a href="index.php?tab=AdminCustomers&id_customer=' . $customer->id . '&viewcustomer&token=' . Tools::getAdminToken('AdminCustomers' . intval(Tab::getIdFromClassName('AdminCustomers')) . intval($cookie->id_employee)) . '">' . $this->l('View details on customer page') . '</a></p> </div> <label>' . $this->l('Order:') . ' </label>'; $order = new Order(intval($obj->id_order)); echo ' <div class="margin-form">' . $this->l('Order #') . sprintf('%06d', $order->id) . ' ' . $this->l('from') . ' ' . Tools::displayDate($order->date_upd, $order->id_lang) . ' <p style="clear: both"><a href="index.php?tab=AdminOrders&id_order=' . $order->id . '&vieworder&token=' . Tools::getAdminToken('AdminOrders' . intval(Tab::getIdFromClassName('AdminOrders')) . intval($cookie->id_employee)) . '">' . $this->l('View details on order page') . '</a></p> </div> <label>' . $this->l('Customer explanation:') . ' </label> <div class="margin-form">' . $obj->question . '</div> <input type="submit" value="' . $this->l(' Save ') . '" name="submitAdd' . $this->table . '" class="button" style="float:right; margin-right:120px;"/> <label>' . $this->l('Status:') . ' </label> <div class="margin-form"> <select name=\'state\'>'; $states = OrderReturnState::getOrderReturnStates($cookie->id_lang); foreach ($states as $state) { echo '<option value="' . $state['id_order_return_state'] . '"' . ($obj->state == $state['id_order_return_state'] ? ' selected="selected"' : '') . '>' . $state['name'] . '</option>'; } echo ' </select> <p style="clear: both">' . $this->l('Merchandise return (RMA) status') . '</p> </div>'; if ($obj->state >= 3) { echo ' <label>' . $this->l('Slip:') . ' </label> <div class="margin-form">' . $this->l('Generate a new slip from the customer order') . ' <p style="clear: both"><a href="index.php?tab=AdminOrders&id_order=' . $order->id . '&vieworder&token=' . Tools::getAdminToken('AdminOrders' . intval(Tab::getIdFromClassName('AdminOrders')) . intval($cookie->id_employee)) . '#products">' . $this->l('More information on order page') . '</a></p> </div>'; } echo ' <label>' . $this->l('Products:') . ' </label> <div class="margin-form">'; echo '<table cellpadding="0" cellspacing="0"> <tr> <td class="col-left"> </td> <td> <table cellspacing="0" cellpadding="0" class="table"> <tr> <th style="width: 100px;">' . $this->l('Reference') . '</th> <th>' . $this->l('Product name') . '</th> <th>' . $this->l('Quantity') . '</th> <th>' . $this->l('Action') . '</th> </tr>'; $order = new Order(intval($obj->id_order)); $quantityDisplayed = array(); /* Customized products */ if ($returnedCustomizations = OrderReturn::getReturnedCustomizedProducts(intval($obj->id_order))) { $allCustomizedDatas = Product::getAllCustomizedDatas(intval($order->id_cart)); foreach ($returnedCustomizations as $returnedCustomization) { echo ' <tr> <td>' . $returnedCustomization['reference'] . '</td> <td class="center">' . $returnedCustomization['name'] . '</td> <td class="center">' . intval($returnedCustomization['product_quantity']) . '</td> <td class="center"><a href="' . $currentIndex . '&deleteorder_return_detail&id_order_detail=' . $returnedCustomization['id_order_detail'] . '&id_customization=' . $returnedCustomization['id_customization'] . '&id_order_return=' . $obj->id . '&token=' . $this->token . '"><img src="../img/admin/delete.gif"></a></td> </tr>'; $customizationDatas =& $allCustomizedDatas[intval($returnedCustomization['product_id'])][intval($returnedCustomization['product_attribute_id'])][intval($returnedCustomization['id_customization'])]['datas']; foreach ($customizationDatas as $type => $datas) { echo '<tr> <td colspan="4">'; if ($type == _CUSTOMIZE_FILE_) { $i = 0; echo '<ul style="margin: 4px 0px 4px 0px; padding: 0px; list-style-type: none;">'; foreach ($datas as $data) { echo '<li style="display: inline; margin: 2px;"> <a href="displayImage.php?img=' . $data['value'] . '&name=' . intval($order->id) . '-file' . ++$i . '" target="_blank"><img src="' . _THEME_PROD_PIC_DIR_ . $data['value'] . '_small" alt="" /></a> </li>'; } echo '</ul>'; } elseif ($type == _CUSTOMIZE_TEXTFIELD_) { $i = 0; echo '<ul style="margin: 0px 0px 4px 0px; padding: 0px 0px 0px 6px; list-style-type: none;">'; foreach ($datas as $data) { echo '<li>' . $this->l('Text #') . ++$i . $this->l(':') . ' ' . $data['value'] . '</li>'; } echo '</ul>'; } echo '</td> </tr>'; } $quantityDisplayed[intval($returnedCustomization['id_order_detail'])] = isset($quantityDisplayed[intval($returnedCustomization['id_order_detail'])]) ? $quantityDisplayed[intval($returnedCustomization['id_order_detail'])] + intval($returnedCustomization['product_quantity']) : intval($returnedCustomization['product_quantity']); } } /* Classic products */ $products = OrderReturn::getOrdersReturnProducts($obj->id, $order); foreach ($products as $k => $product) { if (!isset($quantityDisplayed[intval($product['id_order_detail'])]) or intval($product['product_quantity']) > intval($quantityDisplayed[intval($product['id_order_detail'])])) { echo ' <tr> <td>' . $product['product_reference'] . '</td> <td class="center">' . $product['product_name'] . '</td> <td class="center">' . $product['product_quantity'] . '</td> <td class="center"><a href="' . $currentIndex . '&deleteorder_return_detail&id_order_detail=' . $product['id_order_detail'] . '&id_order_return=' . $obj->id . '&token=' . $this->token . '"><img src="../img/admin/delete.gif"></a></td> </tr>'; } } echo ' </table> </td> </tr> </table> <p>' . $this->l('List of products in return package') . '</p> </div> <div class="margin-form"> </div> </fieldset> </form>'; }
public function getTemplateVarProducts($order_return_id, $order) { $products = array(); $return_products = OrderReturn::getOrdersReturnProducts((int) $order_return_id, $order); foreach ($return_products as $id_return_product => $return_product) { if (!isset($return_product['deleted'])) { $products[$id_return_product] = $return_product; $products[$id_return_product]['customizations'] = $return_product['customizedDatas'] ? $this->getTemplateVarCustomization($return_product) : array(); } } return $products; }
/** * 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'); }
$useSSL = true; include dirname(__FILE__) . '/config/config.inc.php'; require_once dirname(__FILE__) . '/init.php'; $errors = array(); if (!$cookie->isLogged()) { Tools::redirect('authentication.php?back=history.php'); } if (!isset($_GET['id_order_return']) or !Validate::isUnsignedId($_GET['id_order_return'])) { $errors[] = Tools::displayError('order ID is required'); } else { $orderRet = new OrderReturn(intval($_GET['id_order_return'])); if (Validate::isLoadedObject($orderRet) and $orderRet->id_customer == $cookie->id_customer) { $order = new Order(intval($orderRet->id_order)); if (Validate::isLoadedObject($order)) { $state = new OrderReturnState(intval($orderRet->state)); $smarty->assign(array('orderRet' => $orderRet, 'order' => $order, 'state_name' => $state->name[intval($cookie->id_lang)], 'return_allowed' => false, 'products' => OrderReturn::getOrdersReturnProducts(intval($orderRet->id), $order), 'returnedCustomizations' => OrderReturn::getReturnedCustomizedProducts(intval($orderRet->id_order)), 'customizedDatas' => Product::getAllCustomizedDatas(intval($order->id_cart)))); } else { $errors[] = Tools::displayError('cannot find this order return'); } } else { $errors[] = Tools::displayError('cannot find this order return'); } } $smarty->assign(array('errors' => $errors, 'nbdaysreturn' => intval(Configuration::get('PS_ORDER_RETURN_NB_DAYS')))); if (Tools::getValue('ajax') == 'true') { $smarty->display(_PS_THEME_DIR_ . 'order-return.tpl'); } else { include dirname(__FILE__) . '/header.php'; $smarty->display(_PS_THEME_DIR_ . 'order-return.tpl'); include dirname(__FILE__) . '/footer.php'; }
public function postProcess() { $this->context = Context::getContext(); if (Tools::isSubmit('deleteorder_return_detail')) { if ($this->tabAccess['delete'] === '1') { if (($id_order_detail = (int) Tools::getValue('id_order_detail')) && Validate::isUnsignedId($id_order_detail)) { if (($id_order_return = (int) Tools::getValue('id_order_return')) && Validate::isUnsignedId($id_order_return)) { $orderReturn = new OrderReturn($id_order_return); if (!Validate::isLoadedObject($orderReturn)) { die(Tools::displayError()); } if ((int) $orderReturn->countProduct() > 1) { if (OrderReturn::deleteOrderReturnDetail($id_order_return, $id_order_detail, (int) Tools::getValue('id_customization', 0))) { Tools::redirectAdmin(self::$currentIndex . '&conf=4token=' . $this->token); } else { $this->errors[] = Tools::displayError('An error occurred while deleting the details of your order return.'); } } else { $this->errors[] = Tools::displayError('You need at least one product.'); } } else { $this->errors[] = Tools::displayError('The order return is invalid.'); } } else { $this->errors[] = Tools::displayError('The order return content is invalid.'); } } else { $this->errors[] = Tools::displayError('You do not have permission to delete this.'); } } elseif (Tools::isSubmit('submitAddorder_return') || Tools::isSubmit('submitAddorder_returnAndStay')) { if ($this->tabAccess['edit'] === '1') { if (($id_order_return = (int) Tools::getValue('id_order_return')) && Validate::isUnsignedId($id_order_return)) { $orderReturn = new OrderReturn($id_order_return); $order = new Order($orderReturn->id_order); $customer = new Customer($orderReturn->id_customer); $orderReturn->state = (int) Tools::getValue('state'); if ($orderReturn->save()) { $orderReturnState = new OrderReturnState($orderReturn->state); $vars = array('{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname, '{id_order_return}' => $id_order_return, '{state_order_return}' => isset($orderReturnState->name[(int) $order->id_lang]) ? $orderReturnState->name[(int) $order->id_lang] : $orderReturnState->name[(int) Configuration::get('PS_LANG_DEFAULT')]); Mail::Send((int) $order->id_lang, 'order_return_state', Mail::l('Your order return status has changed', $order->id_lang), $vars, $customer->email, $customer->firstname . ' ' . $customer->lastname, null, null, null, null, _PS_MAIL_DIR_, true, (int) $order->id_shop); if (Tools::isSubmit('submitAddorder_returnAndStay')) { Tools::redirectAdmin(self::$currentIndex . '&conf=4&token=' . $this->token . '&updateorder_return&id_order_return=' . (int) $id_order_return); } else { Tools::redirectAdmin(self::$currentIndex . '&conf=4&token=' . $this->token); } } } else { $this->errors[] = Tools::displayError('No order return ID has been specified.'); } } else { $this->errors[] = Tools::displayError('You do not have permission to edit this.'); } } parent::postProcess(); }
/** * Product table with references, quantities... */ public function ProdReturnTab() { $header = array(array(self::l('Description'), 'L'), array(self::l('Reference'), 'L'), array(self::l('Qty'), 'C')); $w = array(110, 25, 20); $this->SetFont(self::fontname(), 'B', 8); $this->SetFillColor(240, 240, 240); for ($i = 0; $i < sizeof($header); $i++) { $this->Cell($w[$i], 5, $header[$i][0], 'T', 0, $header[$i][1], 1); } $this->Ln(); $this->SetFont(self::fontname(), '', 7); $products = OrderReturn::getOrdersReturnProducts(self::$orderReturn->id, self::$order); foreach ($products as $product) { $before = $this->GetY(); $this->MultiCell($w[0], 5, Tools::iconv('utf-8', self::encoding(), $product['product_name']), 'B'); $lineSize = $this->GetY() - $before; $this->SetXY($this->GetX() + $w[0], $this->GetY() - $lineSize); $this->Cell($w[1], $lineSize, $product['product_reference'] != '' ? Tools::iconv('utf-8', self::encoding(), $product['product_reference']) : '---', 'B'); $this->Cell($w[2], $lineSize, $product['product_quantity'], 'B', 0, 'C'); $this->Ln(); } }