public function set_status() { $this->load->language('sale/order_items'); $orderItems = array(); if (isset($this->parameters['selectedItems'])) { $orderItems = array_values($this->parameters['selectedItems']); } else { $this->error['warning'] = $this->language->get('error_no_selected_items'); } $orderItemNewStatus = null; if (isset($_REQUEST['order_item_new_status'])) { $orderItemNewStatus = $_REQUEST['order_item_new_status']; } else { $this->error['warning'] = $this->language->get('error_no_status_set'); } if (!isset($this->error['warning'])) { $this->error['warning'] = ''; $this->session->data['success'] = ''; $this->load->model('localisation/order_item_status'); foreach ($orderItems as $orderItemId) { if (OrderItemDAO::getInstance()->setStatus($orderItemId, $orderItemNewStatus)) { $this->session->data['success'] .= sprintf($this->language->get("text_status_set"), $orderItemId, Status::getStatus($orderItemNewStatus, $this->config->get('language_id'))); } else { $this->error['warning'] .= sprintf($this->language->get('error_status_already_set'), $orderItemId, Status::getStatus($orderItemNewStatus, $this->config->get('language_id'))); } $orderItem = OrderItemDAO::getInstance()->getOrderItem($orderItemId); $this->modelSaleOrder->verifyOrderCompletion($orderItem->getOrderId()); } // $this->clearSelection(); } $this->index(); }
public function setStatus() { $this->load->language('sale/order'); $this->load->library('Status'); if (!isset($this->error['warning'])) { $this->error['warning'] = ''; $this->session->data['success'] = ''; $this->load->model('sale/order'); $this->load->model('localisation/order_status'); foreach ($this->parameters['selected'] as $orderId) { $this->modelSaleOrder->addOrderHistory($orderId, array('order_status_id' => $this->parameters['orderStatusId'])); $this->session->data['success'] .= sprintf($this->language->get("STATUS_SET"), $orderId, Status::getStatus(0x80000 + $this->parameters['orderStatusId'], $this->config->get('language_id'))); } } $this->redirect($this->url->link('sale/order', $this->buildUrlParameterString($this->parameters), 'SSL')); }
private function showCreateForm() { //$this->log->write(print_r($this->request->request, true)); if (!sizeof($this->parameters['selectedItems'])) { return; } $orderItems = OrderItemDAO::getInstance()->getOrderItems(array('selected_items' => $this->parameters['selectedItems']), null, true); //print_r($orderItems); /// Initialize interface values $this->data['button_action'] = $this->language->get('buttonCreate'); $this->data['readOnly'] = ""; /// Check whether input for invoice creation is valid $this->validateInput($orderItems); /// Prepare list $totalWeight = 0; $total = 0; $totalCustomerCurrency = 0; $orderItemIdParam = ''; $localShipping = []; foreach ($orderItems as $orderItem) { // $orderItemObject = new OrderItem($this->registry, $orderItem['affiliate_id'], // $orderItem['affiliate_transaction_id'], $orderItem['comment'], $orderItem['customer_id'], // $orderItem['customer_name'], $orderItem['customer_nick'], $orderItem['order_item_id'], // $orderItem['image_path'], $orderItem['internal_model'], $orderItem['model'], $orderItem['name'], // $orderItem['order_id'], $orderItem['price'], $orderItem['product_id'], $orderItem['public_comment'], // $orderItem['quantity'], $orderItem['shipping'], $orderItem['status_date'], $orderItem['status_id'], // $orderItem['supplier_group_id'], $orderItem['supplier_id'], $orderItem['supplier_name'], $orderItem['total'], // $orderItem['weight'], $orderItem['weight_class_id']); $this->data['orderItems'][$orderItem->getId()] = array('id' => $orderItem->getId(), 'comment' => $orderItem->getPublicComment(), 'image_path' => $this->registry->get('model_tool_image')->getImage($orderItem->getImagePath()), 'model' => $orderItem->getModel(), 'name' => $orderItem->getName(), 'order_id' => $orderItem->getOrderId(), 'options' => OrderItemDAO::getInstance()->getOrderItemOptionsString($orderItem->getId()), 'price' => $this->getCurrency()->format($orderItem->getPrice(), $this->getConfig()->get('config_currency')), 'quantity' => $orderItem->getQuantity(), 'shipping' => $orderItem->getShippingCost(), 'subtotal' => $this->getCurrency()->format($orderItem->getPrice() * $orderItem->getQuantity() + $orderItem->getShippingCost(), $this->getConfig()->get('config_currency')), 'subtotalCustomerCurrency' => $this->getCurrency()->format($orderItem->getPrice(true) * $orderItem->getQuantity() + $orderItem->getShippingCost(true), $orderItem->getCustomer()['base_currency_code'], 1)); $totalWeight += $this->weight->convert($orderItem->getWeight(), $orderItem->getWeightClassId(), $this->getConfig()->get('config_weight_class_id')) * $orderItem->getQuantity(); $total += $orderItem->getPrice() * $orderItem->getQuantity(); // + $orderItem->getShippingCost(); $totalCustomerCurrency += $orderItem->getPrice(true) * $orderItem->getQuantity(); // + $orderItem->getShippingCost(true); $orderItemIdParam .= '&orderItemId[]=' . $orderItem->getId(); /// Calculate local shipping $localShipping = $this->calculateLocalShipping($orderItem, $localShipping); } /// Check whether suppliers have free shipping $this->checkFreeLocalShipping($localShipping, $total, $totalCustomerCurrency); /// Set invoice data $firstItemOrder = $this->modelSaleOrder->getOrder($orderItems[0]->getOrderId()); // $this->log->write(print_r($firstItemOrder, true)); $customer = CustomerDAO::getInstance()->getCustomer($firstItemOrder['customer_id']); // $shippingCost = \Shipping::getCost($orderItems, $firstItemOrder['shipping_method'], array('weight' => $totalWeight), $this->registry); $shippingCost = ShippingMethodDAO::getInstance()->getMethod(explode('.', $firstItemOrder['shipping_method'])[0])->getCost($firstItemOrder['shipping_method'], $orderItems, ['weight' => $totalWeight]); $this->data['comment'] = ''; $this->data['discount'] = 0; $this->data['invoiceId'] = 0; $this->data['packageNumber'] = ''; $this->data['shippingAddress'] = nl2br($this->getOrderAddressString($firstItemOrder)) . " (" . $firstItemOrder['shipping_phone'] . ")"; $this->data['shippingCost'] = $this->getCurrency()->format($shippingCost, $this->getConfig()->get('config_currency')); $this->data['shippingCostRoute'] = $this->url->link('sale/invoice/getShippingCost', 'token=' . $this->parameters['token'] . $orderItemIdParam, 'SSL'); $this->data['shippingMethod'] = $firstItemOrder['shipping_method']; $this->data['shippingMethodCode'] = $firstItemOrder['shipping_method']; $this->data['total'] = $this->getCurrency()->format($total, $this->getConfig()->get('config_currency')); $this->data['totalRaw'] = $total; $this->data['totalWeight'] = $totalWeight; $this->data['grandTotal'] = $this->getCurrency()->format($total + $shippingCost, $this->getConfig()->get('config_currency')); $this->data['totalCustomerCurrency'] = $this->getCurrency()->format($totalCustomerCurrency + $this->getCurrency()->convert($shippingCost, $this->getConfig()->get('config_currency'), $customer['base_currency_code']), $customer['base_currency_code'], 1); $this->data['shippingMethods'] = ShippingMethodDAO::getInstance()->getShippingOptions($this->getOrderAddress($firstItemOrder)); // $this->log->write(print_r($this->data, true)); $this->data['customerCurrencyCode'] = $customer['base_currency_code']; }