Beispiel #1
0
 /**
  * To be used only in Adapters. Should not been called by Core classes. Prefer to use Core\context class,
  * that will contains all you need in the Core architecture
  *
  * @throws LogicException If legacy context is not set properly
  *
  * @return Context The Legacy context, for Adapter use only.
  */
 public function getContext()
 {
     static $legacyContext = null;
     if (null === $legacyContext) {
         $legacyContext = OldContext::getContext();
         if ($legacyContext && !empty($legacyContext->shop) && !isset($legacyContext->controller) && isset($legacyContext->employee)) {
             //init real legacy shop context
             $adminController = new \AdminControllerCore();
             $adminController->initShopContext();
         }
     }
     return $legacyContext;
 }
Beispiel #2
0
 public function refresh($file_to_refresh, $external_file)
 {
     if (self::$is_prestashop_up && ($content = Tools::file_get_contents($external_file))) {
         return (bool) file_put_contents(_PS_ROOT_DIR_ . $file_to_refresh, $content);
     }
     self::$is_prestashop_up = false;
     return false;
 }
 public function processSave()
 {
     return parent::processSave();
 }
Beispiel #4
0
 public function processDelete()
 {
     if (!Module::isInstalled('agilemultipleseller')) {
         return parent::processDelete();
     }
     if (!$this->can_edit()) {
         $this->errors[] = Tools::displayError('You do not have permission to delete this data');
         return false;
     }
     return parent::processDelete();
 }
Beispiel #5
0
 /**
  * Init context and dependencies, handles POST and GET
  */
 public function init()
 {
     // Has to be removed for the next Prestashop version
     global $currentIndex;
     parent::init();
     if (Tools::getValue('ajax')) {
         $this->ajax = '1';
     }
     /* Server Params */
     $protocol_link = Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://';
     $protocol_content = isset($useSSL) && $useSSL && Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://';
     $this->context->link = new Link($protocol_link, $protocol_content);
     if (isset($_GET['logout'])) {
         $this->context->employee->logout();
     }
     if ($this->controller_name != 'AdminLogin' && (!isset($this->context->employee) || !$this->context->employee->isLoggedBack())) {
         Tools::redirectAdmin($this->context->link->getAdminLink('AdminLogin') . (!isset($_GET['logout']) ? '&redirect=' . $this->controller_name : ''));
     }
     // Set current index
     $current_index = __PS_BASE_URI__ . basename(_PS_ADMIN_DIR_) . '/index.php' . (($controller = Tools::getValue('controller')) ? '?controller=' . $controller : '');
     if ($back = Tools::getValue('back')) {
         $current_index .= '&back=' . urlencode($back);
     }
     self::$currentIndex = $current_index;
     $currentIndex = $current_index;
     if ((int) Tools::getValue('liteDisplaying')) {
         $this->display_header = false;
         $this->display_footer = false;
         $this->content_only = false;
         $this->lite_display = true;
     }
     if ($this->ajax && method_exists($this, 'ajaxPreprocess')) {
         $this->ajaxPreProcess();
     }
     $this->context->smarty->assign(array('table' => $this->table, 'current' => self::$currentIndex, 'token' => $this->token));
     if ($this->display_header) {
         $this->context->smarty->assign('displayBackOfficeHeader', Hook::exec('displayBackOfficeHeader', array()));
     }
     $this->context->smarty->assign(array('displayBackOfficeTop' => Hook::exec('displayBackOfficeTop', array()), 'submit_form_ajax' => (int) Tools::getValue('submitFormAjax')));
     $this->initProcess();
 }
 public function renderView()
 {
     $neoExchange = new NeoExchanges(Tools::getValue('id_neo_exchange'));
     $order = new Order(Tools::getValue('id_neo_exchange'));
     if (!Validate::isLoadedObject($neoExchange)) {
         $this->errors[] = Tools::displayError('The order cannot be found within your database.');
     }
     $customer = new Customer($neoExchange->id_customer);
     //$carrier = new Carrier($neoExchange->id_carrier);
     $currency = new Currency((int) $neoExchange->id_currency);
     $buys = new NeoItemsBuyCore(Tools::getValue('id_neo_exchange'));
     $sales = new NeoItemsSalesCore(Tools::getValue('id_neo_exchange'));
     $products = $this->getProducts($buys);
     $products2 = $this->getProducts($sales);
     //$products = $this->getProducts($neoExchange);
     // 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'), $neoExchange->id_cart);
             }
     
             // Retrieve addresses information
             $addressInvoice = new Address($neoExchange->id_address_invoice, $this->context->language->id);
             if (Validate::isLoadedObject($addressInvoice) && $addressInvoice->id_state)
                 $invoiceState = new State((int)$addressInvoice->id_state);
     
             if ($neoExchange->id_address_invoice == $neoExchange->id_address_delivery)
             {
                 $addressDelivery = $addressInvoice;
                 if (isset($invoiceState))
                     $deliveryState = $invoiceState;
             }
             else
             {
                 $addressDelivery = new Address($neoExchange->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('Intercambio #%1$d (%2$s) - %3$s %4$s'), $neoExchange->id, $neoExchange->reference, $customer->firstname, $customer->lastname);
     if (Shop::isFeatureActive()) {
         $shop = new Shop((int) $neoExchange->id_shop);
         $this->toolbar_title .= ' - ' . sprintf($this->l('Shop: %s'), $shop->name);
     }
     // gets warehouses to ship products, if and only if advanced stock management is activated
     $warehouse_list = null;
     $payment_methods = array();
     foreach (PaymentModule::getInstalledPaymentModules() as $payment) {
         $module = Module::getInstanceByName($payment['name']);
         if (Validate::isLoadedObject($module) && $module->active) {
             $payment_methods[] = $module->displayName;
         }
     }
     // display warning if there are products out of stock
     $display_out_of_stock_warning = false;
     $current_order_state = $neoExchange->getCurrentOrderState();
     if (Configuration::get('PS_STOCK_MANAGEMENT') && (!Validate::isLoadedObject($current_order_state) || $current_order_state->delivery != 1 && $current_order_state->shipped != 1)) {
         $display_out_of_stock_warning = true;
     }
     $total_buy = 0;
     $total_sale = 0;
     $products_buy = count($products);
     $products_sale = count($products2);
     // products current stock (from stock_available)
     foreach ($products as &$product) {
         $total_buy += $product['price'];
     }
     foreach ($products2 as &$product) {
         $total_sale += $product['price'];
     }
     $gender = new Gender((int) $customer->id_gender, $this->context->language->id);
     $history = $neoExchange->getHistory($this->context->language->id);
     foreach ($history as &$order_state) {
         $order_state['text-color'] = Tools::getBrightness($order_state['color']) < 128 ? 'white' : 'black';
     }
     // Smarty assign
     $this->tpl_view_vars = array('order' => $neoExchange, 'customer' => $customer, 'gender' => $gender, 'customer_addresses' => $customer->getAddresses($this->context->language->id), 'customerStats' => $customer->getStats(), 'products' => $products, 'products2' => $products2, 'total_buy' => $total_buy, 'total_sale' => $total_sale, 'products_buy' => $products_buy, 'products_sale' => $products_sale, 'neo_order_shipping_price' => 0, 'orders_total_paid_tax_incl' => $neoExchange->getOrdersTotalPaid(), 'total_paid' => $neoExchange->getTotalPaid(), 'returns' => OrderReturn::getOrdersReturn($neoExchange->id_customer, $neoExchange->id), 'customer_thread_message' => CustomerThread::getCustomerMessages($neoExchange->id_customer), 'orderMessages' => OrderMessage::getOrderMessages($neoExchange->id_lang), 'messages' => Message::getMessagesByOrderId($neoExchange->id, true), 'history' => $history, 'neoStatus' => NeoStatusCore::getNeoStatus(), 'warehouse_list' => $warehouse_list, 'sources' => ConnectionsSource::getOrderSources($neoExchange->id), 'currentState' => $neoExchange->getCurrentOrderState(), 'currency' => new Currency($neoExchange->id_currency), 'currencies' => Currency::getCurrenciesByIdShop($neoExchange->id_shop), 'previousOrder' => $neoExchange->getPreviousOrderId(), 'nextOrder' => $neoExchange->getNextOrderId(), 'current_index' => self::$currentIndex, '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' => $neoExchange->getInvoicesCollection(), 'not_paid_invoices_collection' => $neoExchange->getNotPaidInvoicesCollection(), 'payment_methods' => $payment_methods, 'invoice_management_active' => Configuration::get('PS_INVOICE', null, null, $neoExchange->id_shop), 'display_warehouse' => (int) Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT'), 'HOOK_CONTENT_ORDER' => Hook::exec('displayAdminOrderContentOrder', array('order' => $neoExchange, 'products' => $products, 'customer' => $customer)), 'HOOK_CONTENT_SHIP' => Hook::exec('displayAdminOrderContentShip', array('order' => $neoExchange, 'products' => $products, 'customer' => $customer)), 'HOOK_TAB_ORDER' => Hook::exec('displayAdminOrderTabOrder', array('order' => $neoExchange, 'products' => $products, 'customer' => $customer)), 'HOOK_TAB_SHIP' => Hook::exec('displayAdminOrderTabShip', array('order' => $neoExchange, 'products' => $products, 'customer' => $customer)));
     return parent::renderView();
 }
 public function adminControllerRenderList()
 {
     return parent::renderList();
 }