示例#1
0
 public function getCodList()
 {
     $modules = PaymentModule::getInstalledPaymentModules();
     $binded = unserialize(Configuration::get(self::KONFIG_PREFIX . self::KONFIG_POBRANIE));
     $list = array();
     foreach ($modules as $key => $c) {
         $list[] = new BindedCod($c['id_module'], $c['name'], is_array($binded) && in_array($c['id_module'], $binded) ? "true" : "false");
     }
     return $list;
 }
示例#2
0
 public function __construct()
 {
     $modules_infos = PaymentModule::getInstalledPaymentModules();
     foreach ($modules_infos as $module_infos) {
         $module = Module::getInstanceByName($module_infos['name']);
         if (!$module) {
             continue;
         }
         if ($module->tab == 'payments_gateways') {
             if ($module->id) {
                 if (!get_class($module) == 'SimpleXMLElement') {
                     $module->country = array();
                 }
                 $countries = Db::getInstance()->ExecuteS('SELECT id_country FROM ' . _DB_PREFIX_ . 'module_country WHERE id_module = ' . (int) $module->id);
                 foreach ($countries as $country) {
                     $module->country[] = $country['id_country'];
                 }
                 if (!get_class($module) == 'SimpleXMLElement') {
                     $module->currency = array();
                 }
                 $currencies = Db::getInstance()->ExecuteS('SELECT id_currency FROM ' . _DB_PREFIX_ . 'module_currency WHERE id_module = ' . (int) $module->id);
                 foreach ($currencies as $currency) {
                     $module->currency[] = $currency['id_currency'];
                 }
                 if (!get_class($module) == 'SimpleXMLElement') {
                     $module->group = array();
                 }
                 $groups = Db::getInstance()->ExecuteS('SELECT id_group FROM ' . _DB_PREFIX_ . 'module_group WHERE id_module = ' . (int) $module->id);
                 foreach ($groups as $group) {
                     $module->group[] = $group['id_group'];
                 }
             } else {
                 $module->country = NULL;
                 $module->currency = NULL;
                 $module->group = NULL;
             }
             $this->paymentModules[] = $module;
         }
     }
     parent::__construct();
 }
示例#3
0
 public function renderView()
 {
     $order = new Order(Tools::getValue('id_order'));
     if (!Validate::isLoadedObject($order)) {
         $this->errors[] = Tools::displayError('The order cannot be found within your database.');
     }
     $customer = new Customer($order->id_customer);
     $carrier = new Carrier($order->id_carrier);
     $products = $this->getProducts($order);
     $currency = new Currency((int) $order->id_currency);
     // 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);
     if (Shop::isFeatureActive()) {
         $shop = new Shop((int) $order->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;
     $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) && $module->active) {
             $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 (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;
     }
     // 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'], $currency);
         $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']);
         }
         if ($product['id_warehouse'] != 0) {
             $warehouse = new Warehouse((int) $product['id_warehouse']);
             $product['warehouse_name'] = $warehouse->name;
         } else {
             $product['warehouse_name'] = '--';
         }
     }
     $gender = new Gender((int) $customer->id_gender, $this->context->language->id);
     $history = $order->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' => $order, 'cart' => new Cart($order->id_cart), 'customer' => $customer, 'gender' => $gender, '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), 'orderMessages' => OrderMessage::getOrderMessages($order->id_lang), 'messages' => Message::getMessagesByOrderId($order->id, true), 'carrier' => new Carrier($order->id_carrier), 'history' => $history, '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::getCurrenciesByIdShop($order->id_shop), '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', null, null, $order->id_shop), 'display_warehouse' => (int) Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT'));
     return parent::renderView();
 }
 public function ajaxProcessChangePaymentMethod()
 {
     $customer = new Customer(Tools::getValue('id_customer'));
     $modules = Module::getAuthorizedModules($customer->id_default_group);
     $authorized_modules = array();
     if (!Validate::isLoadedObject($customer) || !is_array($modules)) {
         die(Tools::jsonEncode(array('result' => false)));
     }
     foreach ($modules as $module) {
         $authorized_modules[] = (int) $module['id_module'];
     }
     $payment_modules = array();
     foreach (PaymentModule::getInstalledPaymentModules() as $p_module) {
         if (in_array((int) $p_module['id_module'], $authorized_modules)) {
             $payment_modules[] = Module::getInstanceById((int) $p_module['id_module']);
         }
     }
     $this->context->smarty->assign(array('payment_modules' => $payment_modules));
     die(Tools::jsonEncode(array('result' => true, 'view' => $this->createTemplate('_select_payment.tpl')->fetch())));
 }
示例#5
0
    private function _displayConfiguration()
    {
        $this->_html .= '
		<script type="text/javascript">
			$(document).ready(function() {
				$(\'#submitCreateAccount\').unbind(\'click\').click(function() {
					if (!$(\'#terms_and_conditions\').attr(\'checked\'))
					{
						alert(\'' . addslashes($this->l('Please accept the terms of service.')) . '\');
						return false;
					}
				});										
			});
		</script>
		<fieldset><legend>' . $this->l('PrestaShop Security configuration') . '</legend>
			<div id="choose_account">
				<center>
				<form>
					<input type="radio" ' . (!Configuration::get('PS_TRUST_SHOP_ID') ? 'checked="checked"' : '') . ' onclick="$(\'#create_account\').show(); $(\'#module_configuration\').hide();" id="trust_account_on" name="trust_account" value="0"/> <b>' . $this->l('My shop does not have a PrestaShop Security account yet') . '</b>&nbsp;&nbsp;&nbsp;
					<input type="radio" ' . (Configuration::get('PS_TRUST_SHOP_ID') ? 'checked="checked"' : '') . ' onclick="$(\'#create_account\').hide(); $(\'#module_configuration\').show();"  id="trust_account_off" name="trust_account" value="1" /> <b>' . $this->l('I already have an account') . '</b>
				</form>
				</center>
			</div>
			<div class="clear">&nbsp;</div>
			<div id="create_account" ' . (Configuration::get('PS_TRUST_SHOP_ID') ? 'style="display:none;"' : '') . '>
				<form action="' . Tools::htmlentitiesUTF8($_SERVER['REQUEST_URI']) . '" method="post" name="prestashop_trust" id="prestashop_trust">
					<label>' . $this->l('Your email') . '</label>
					<div class="margin-form">
						<input type="text" style="width:200px;" name="email" value="' . Tools::safeOutput(Tools::getValue('email')) . '" />
					</div>
					<label>' . $this->l('Shop Url') . '</label>
					<div class="margin-form">
						<input type="text" style="width:400px;" name="shop_url" value="http://www.' . Tools::getHttpHost() . __PS_BASE_URI__ . '"/>
					</div>
					<div class="margin-form">
						<input id="terms_and_conditions" type="checkbox" value="1" /> ' . $this->l('I agree with the terms of PrestaShop Security service and I adhere to them unconditionally.') . '</label>
					</div>
					<div id="terms" class="margin-form">';
        $terms = Tools::file_get_contents($this->_trustUrl . 'terms.php?lang=' . $this->context->language->iso_code);
        $this->_html .= '<div style="height:300px;border:1px solid #E0D0B1;overflow-y:scroll;padding:8px;color:black">' . Tools::nl2br(strip_tags($terms)) . '</div>';
        $this->_html .= '</div>
					<div class="margin-form">
						<input class="button" type="submit" id="submitCreateAccount" name="submitCreateAccount" value="' . $this->l('Create account') . '"/>
					</div>
				</form>
				<div class="clear">&nbsp;</div>
			</div>
			<div id="module_configuration" ' . (!Configuration::get('PS_TRUST_SHOP_ID') ? 'style="display:none"' : '') . '>
			<form action="' . Tools::htmlentitiesUTF8($_SERVER['REQUEST_URI']) . '" method="post" name="prestashop_trust" id="prestashop_trust">
				<label>' . $this->l('Shop ID') . '</label>
				<div class="margin-form">
					<input type="text" style="width:150px"  name="shop_id" value="' . Configuration::get('PS_TRUST_SHOP_ID') . '"/>
				</div>
				<label>' . $this->l('Shop KEY') . '</label>
				<div class="margin-form">
					<input type="text" style="width:300px" name="shop_key" value="' . Configuration::get('PS_TRUST_SHOP_KEY') . '"/>
				</div>
				<div class="clear">&nbsp;</div>
				<label>' . $this->l('Shop activity') . '</label>
				<div class="margin-form">
					<select name="shop_activity">';
        foreach ($this->_activities as $k => $activity) {
            $this->_html .= '<option value="' . $k . '" ' . ($k == Configuration::get('PS_SHOP_ACTIVITY') ? 'selected="selected"' : '') . '>' . $activity . '</option>';
        }
        $this->_html .= '</select>
				</div>';
        $carriers = Carrier::getCarriers($this->context->language->id, true);
        $trust_carriers_type = $this->_getPrestaTrustCarriersType();
        $configured_carriers = $this->_getConfiguredCarriers();
        $this->_html .= '
				<label>' . $this->l('Carriers') . '</label>
				<div class="margin-form">
					<table cellspacing="0" cellpadding="0" class="table">
						<thead><tr><th>' . $this->l('Carrier') . '</th><th>' . $this->l('Carrier Type') . '</th></tr></thead><tbody>';
        foreach ($carriers as $carrier) {
            $this->_html .= '<tr><td>' . $carrier['name'] . '</td><td><select name="carrier_' . $carrier['id_carrier'] . '">
			<option value="0">' . $this->l('Choose a carrier type...') . '</option>';
            foreach ($this->_getPrestaTrustCarriersType() as $type => $name) {
                $this->_html .= '<option value="' . $type . '"' . ((isset($configured_carriers[$carrier['id_carrier']]) and $type == $configured_carriers[$carrier['id_carrier']]) ? ' selected="selected"' : '') . '>' . $name . '</option>';
            }
            $this->_html .= '</select></td>';
        }
        $this->_html .= '</tbody></table></margin>
			</div>';
        $modules = PaymentModule::getInstalledPaymentModules();
        $configured_payments = $this->_getConfiguredPayments();
        $this->_html .= '
				<label>' . $this->l('Payments') . '</label>
				<div class="margin-form">
					<table cellspacing="0" cellpadding="0" class="table">
						<thead><tr><th>' . $this->l('Payment Module') . '</th><th>' . $this->l('Payment Type') . '</th></tr></thead><tbody>';
        foreach ($modules as $module) {
            $mod = Module::getInstanceByName($module['name']);
            $this->_html .= '<tr><td>' . $mod->displayName . '</td><td><select name="paymentmodule_' . $mod->id . '">
			<option value="0">' . $this->l('Choose a payment type...') . '</option>';
            foreach ($this->_payment_types as $type => $name) {
                $this->_html .= '<option value="' . $type . '"' . ((isset($configured_payments[$mod->id]) and $type == $configured_payments[$mod->id]) ? ' selected="true"' : '') . '>' . $name . '</option>';
            }
            $this->_html .= '</select></td>';
        }
        $this->_html .= '</tbody></table></margin>
			</div>';
        $this->_html .= '<center><input type="submit" name="submitSettings" value="' . $this->l('Save') . '" class="button" /></center>
		</form>
		</div>
		</fieldset>';
        return $this->_html;
    }
 public function renderView()
 {
     $order = new Order(Tools::getValue('id_order'));
     if (!Validate::isLoadedObject($order)) {
         $this->errors[] = Tools::displayError('The order cannot be found within your database.');
     }
     $customer = new Customer($order->id_customer);
     $carrier = new Carrier($order->id_carrier);
     $products = $this->getProducts($order);
     $order_details = AphOrderDetail::getList($order->id);
     foreach ($order_details as &$order_detail) {
         $products[$order_detail['id_order_detail']]['delivery_date'] = $order_detail['delivery_date'];
         $products[$order_detail['id_order_detail']]['delivery_time_from'] = $order_detail['delivery_time_from'];
         $products[$order_detail['id_order_detail']]['delivery_time_to'] = $order_detail['delivery_time_to'];
     }
     $currency = new Currency((int) $order->id_currency);
     // 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);
     if (Shop::isFeatureActive()) {
         $shop = new Shop((int) $order->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;
     $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) && $module->active) {
             $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 (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;
     }
     // products current stock (from stock_available)
     foreach ($products as &$product) {
         // Get total customized quantity for current product
         $customized_product_quantity = 0;
         if (is_array($product['customizedDatas'])) {
             foreach ($product['customizedDatas'] as $customizationPerAddress) {
                 foreach ($customizationPerAddress as $customizationId => $customization) {
                     $customized_product_quantity += (int) $customization['quantity'];
                 }
             }
         }
         $product['customized_product_quantity'] = $customized_product_quantity;
         $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_excl'] - $resume['amount_tax_excl'];
         $product['amount_refundable_tax_incl'] = $product['total_price_tax_incl'] - $resume['amount_tax_incl'];
         $product['amount_refund'] = Tools::displayPrice($resume['amount_tax_incl'], $currency);
         $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']);
         }
         if ($product['id_warehouse'] != 0) {
             $warehouse = new Warehouse((int) $product['id_warehouse']);
             $product['warehouse_name'] = $warehouse->name;
             $warehouse_location = WarehouseProductLocation::getProductLocation($product['product_id'], $product['product_attribute_id'], $product['id_warehouse']);
             if (!empty($warehouse_location)) {
                 $product['warehouse_location'] = $warehouse_location;
             } else {
                 $product['warehouse_location'] = false;
             }
         } else {
             $product['warehouse_name'] = '--';
             $product['warehouse_location'] = false;
         }
     }
     $gender = new Gender((int) $customer->id_gender, $this->context->language->id);
     $history = $order->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' => $order, 'cart' => new Cart($order->id_cart), 'customer' => $customer, 'gender' => $gender, '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, null, $order->id), 'orderMessages' => OrderMessage::getOrderMessages($order->id_lang), 'messages' => Message::getMessagesByOrderId($order->id, true), 'carrier' => new Carrier($order->id_carrier), 'history' => $history, '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::getCurrenciesByIdShop($order->id_shop), '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', null, null, $order->id_shop), 'display_warehouse' => (int) Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT'), 'HOOK_CONTENT_ORDER' => Hook::exec('displayAdminOrderContentOrder', array('order' => $order, 'products' => $products, 'customer' => $customer)), 'HOOK_CONTENT_SHIP' => Hook::exec('displayAdminOrderContentShip', array('order' => $order, 'products' => $products, 'customer' => $customer)), 'HOOK_TAB_ORDER' => Hook::exec('displayAdminOrderTabOrder', array('order' => $order, 'products' => $products, 'customer' => $customer)), 'HOOK_TAB_SHIP' => Hook::exec('displayAdminOrderTabShip', array('order' => $order, 'products' => $products, 'customer' => $customer)));
     $options_time = array();
     $time_slice = Configuration::get('APH_CALENDAR_TIME_SLICE');
     for ($hours = 0; $hours < 24; $hours++) {
         // the interval for hours is '1'
         for ($mins = 0; $mins < 60; $mins += $time_slice) {
             // the interval for mins is 'APH_CALENDAR_TIME_SLICE'
             $options_time[str_pad($hours, 2, '0', STR_PAD_LEFT) . ':' . str_pad($mins, 2, '0', STR_PAD_LEFT)] = str_pad($hours, 2, '0', STR_PAD_LEFT) . ':' . str_pad($mins, 2, '0', STR_PAD_LEFT);
         }
     }
     $this->tpl_view_vars['options_time'] = $options_time;
     $employees = array();
     $e = AphEmployeeProduct::getEmployeesByShop((int) Context::getContext()->shop->id);
     foreach ($e as $employee) {
         $employees[$employee['id_employee']] = $employee['fullName'];
     }
     $this->tpl_view_vars['employees'] = $employees;
     $helper = new HelperView($this);
     $this->setHelperDisplay($helper);
     $helper->tpl_vars = $this->getTemplateViewVars();
     $helper->base_folder = $this->getTemplatePath() . 'aph_orders/helpers/';
     $helper->base_tpl = 'view/view.tpl';
     $view = $helper->generateView();
     return $view;
 }
 public function ajaxProcessChangePaymentMethod()
 {
     $id_customer = Tools::getValue('id_customer');
     $customer = new Customer(Tools::getValue('id_customer'));
     $this->context->customer = $customer;
     //by webkul code to add id_customer in cart table
     $this->context->customer = new Customer($id_customer);
     if ($id_customer) {
         // setting data in the cart set from book now page by webkul
         $this->context->cart = new Cart(Tools::getValue('id_cart'));
         $this->context->cart->id_customer = $id_customer;
         /*if (Validate::isLoadedObject($this->context->cart) && $this->context->cart->OrderExists())
         		return;*/
         if (!$this->context->cart->secure_key) {
             $this->context->cart->secure_key = $this->context->customer->secure_key;
         }
         if (!$this->context->cart->id_shop) {
             $this->context->cart->id_shop = (int) $this->context->shop->id;
         }
         if (!$this->context->cart->id_lang) {
             $this->context->cart->id_lang = ($id_lang = (int) Tools::getValue('id_lang')) ? $id_lang : Configuration::get('PS_LANG_DEFAULT');
         }
         if (!$this->context->cart->id_currency) {
             $this->context->cart->id_currency = ($id_currency = (int) Tools::getValue('id_currency')) ? $id_currency : Configuration::get('PS_CURRENCY_DEFAULT');
         }
         $addresses = $customer->getAddresses((int) $this->context->cart->id_lang);
         if (!$this->context->cart->id_address_invoice && isset($addresses[0])) {
             $this->context->cart->id_address_invoice = (int) $addresses[0]['id_address'];
         } elseif ($id_address_invoice) {
             $this->context->cart->id_address_invoice = (int) $id_address_invoice;
         }
         if (!$this->context->cart->id_address_delivery && isset($addresses[0])) {
             $this->context->cart->id_address_delivery = $addresses[0]['id_address'];
         }
         $this->context->cart->save();
     }
     //end
     $modules = Module::getAuthorizedModules($customer->id_default_group);
     $authorized_modules = array();
     if (!Validate::isLoadedObject($customer) || !is_array($modules)) {
         die(Tools::jsonEncode(array('result' => false)));
     }
     foreach ($modules as $module) {
         $authorized_modules[] = (int) $module['id_module'];
     }
     $payment_modules = array();
     foreach (PaymentModule::getInstalledPaymentModules() as $p_module) {
         if (in_array((int) $p_module['id_module'], $authorized_modules)) {
             $payment_modules[] = Module::getInstanceById((int) $p_module['id_module']);
         }
     }
     $this->context->smarty->assign(array('payment_modules' => $payment_modules));
     die(Tools::jsonEncode(array('result' => true, 'view' => $this->createTemplate('_select_payment.tpl')->fetch())));
 }
 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();
 }
示例#9
0
 public function createAccountInApp($email)
 {
     // Get default language
     $default_lang = (int) Configuration::get('PS_LANG_DEFAULT');
     $lang = new Language($default_lang);
     // Get order states
     $oss = OrderState::getOrderStates($default_lang);
     $states = array();
     foreach ($oss as $os) {
         $states[$os['id_order_state']] = $os['name'];
     }
     // Get payment modules
     $modules = array();
     $pms = PaymentModule::getInstalledPaymentModules();
     foreach ($pms as $pm) {
         $p = Module::getInstanceByName($pm['name']);
         $modules[$pm['id_module']] = $p->displayName;
     }
     $data = array('action' => 'createAccount', 'data' => array('shopUrl' => $this->context->shop->getBaseURL(), 'email' => $email, 'lang' => $lang->iso_code, 'modules' => $modules, 'states' => $states));
     return CheckYourDataWSHelper::send(self::$dcUrl, $data);
 }
示例#10
0
 protected function displayPaymentModules()
 {
     $modules = PaymentModule::getInstalledPaymentModules();
     $output = '<fieldset><legend>' . $this->l('Payment modules AND COD') . '</legend>';
     $output .= '<table><tr><td>' . $this->l('Payment module') . '</td><td>' . $this->l('Is COD') . '</td></tr>';
     $codModules = Configuration::get($this->uppername . '_COD_MODULES');
     if ($codModules && strlen($codModules)) {
         $codModules = json_decode($codModules, true);
     }
     foreach ($modules as $module) {
         $instance = Module::getInstanceByName($module['name']);
         if ($instance->active) {
             if (isset($codModules[$instance->id])) {
                 $checked = " checked='checked'";
             } else {
                 $checked = "";
             }
             $output .= '<tr><td>' . $instance->displayName . '</td><td>
        <input type="checkbox" name="' . $this->uppername . '_COD_MODULES' . '[' . $instance->id . ']" ' . $checked . ' />
        </td></tr>';
         }
     }
     return $output . '</table></fieldset><br /><br />';
 }