/** * parse country list */ public function parseCountryList($template_block = 'content.country') { require_once 'models/international/international_country.php'; $Country = new international_country(); $countries = $Country->listing(); foreach ($countries as $c) { if ($c['id'] == $_POST['formdata']['country_id']) { $c['selected'] = "selected='selected'"; } else { $c['selected'] = ''; } $this->tpl->assign('COUNTRY', $c); $this->tpl->parse("{$template_block}.item"); } $this->tpl->parse($template_block); }
/** * Get home country id */ protected function getHomeCountryId() { $conf = international_country::initConfiguration(); return $conf['default_id']; }
/** * Return true if delivery to given country is VAT eligible * * @param int $country_id Country Id to check EU status * @return boolean */ function isVatEligibleByCountry($country_id) { $order_conf = ecommerce_order::initConfiguration(); $exclude_vat = false; require_once 'models/international/international_country.php'; if (is_numeric($country_id)) { $Country = new international_country(); $country_data = $Country->detail($country_id); $exclude_vat = $order_conf['non_eu_zero_vat'] && !$country_data['eu_status']; } return !$exclude_vat; }
/** * getCountryName */ public function getCountryName($country_id) { if (!is_numeric($country_id)) { return false; } require_once 'models/international/international_country.php'; $Country = new international_country(); $country_detail = $Country->detail($country_id); if (is_array($country_detail)) { return $country_detail['name']; } else { return false; } }
/** * main action */ public function mainAction() { /** * if submitted search display save button */ if (isset($_POST['search'])) { $this->parseGroups(); $this->tpl->parse('content.form.save'); } /** * Store submited data to the SESSION */ if (isset($_POST['customer-filter'])) { $_SESSION['bo']['customer-filter'] = $_POST['customer-filter']; $_SESSION['bo']['customer-filter']['group_id'] = ''; } else { if (is_numeric($_SESSION['bo']['customer-filter']['group_id'])) { /** * update incase group_id selected */ $group_id = $_SESSION['bo']['customer-filter']['group_id']; if ($group_filter = $this->getGroupFilter($group_id)) { $_SESSION['bo']['customer-filter'] = $group_filter; $_SESSION['bo']['customer-filter']['group_id'] = $group_id; } } } /** * populate filter in case it's empty */ if (!is_array($_SESSION['bo']['customer-filter'])) { $_SESSION['bo']['customer-filter'] = array(); $_SESSION['bo']['customer-filter']['invoice_status'] = 0; $_SESSION['bo']['customer-filter']['account_type'] = -1; } /** * copy customer-filter to local variable */ $customer_filter = $_SESSION['bo']['customer-filter']; /** * if submitted save, only process save action and don't display form (exit here) */ if (isset($_POST['save'])) { return $this->saveGroupFilter($customer_filter); } /** * assign to template variable */ if ($group_detail = $this->getGroupDetail($customer_filter['group_id'])) { $customer_filter['group_name'] = $group_detail['name']; } else { if (trim($customer_filter['group_name']) == '') { $customer_filter['group_name'] = 'Your new group name'; } } $this->tpl->assign('CUSTOMER_FILTER', $customer_filter); /** * With orders and account type options */ $this->tpl->assign("SELECTED_invoice_status_{$customer_filter['invoice_status']}", "selected='selected'"); $this->tpl->assign("SELECTED_account_type_{$customer_filter['account_type']}", "selected='selected'"); /** * Country list */ require_once 'models/international/international_country.php'; $Country = new international_country(); $countries = $Country->listing(); foreach ($countries as $item) { if ($item['id'] == $customer_filter['country_id']) { $item['selected'] = "selected='selected'"; } else { $item['selected'] = ''; } $this->tpl->assign('ITEM', $item); $this->tpl->parse('content.form.country.item'); } $this->tpl->parse('content.form.country'); /** * product list */ require_once 'models/ecommerce/ecommerce_product.php'; $Product = new ecommerce_product(); $product_list = $Product->listing('publish = 1', 'name ASC'); if (is_array($product_list) && count($product_list) > 0) { foreach ($product_list as $item) { if (is_array($_SESSION['bo']['customer-filter']['product_bought'])) { if (in_array($item['id'], $customer_filter['product_bought'])) { $item['checked'] = "checked='checked'"; } else { $item['selected'] = ''; } } else { $item['selected'] = ''; } $this->tpl->assign('ITEM', $item); $this->tpl->parse('content.form.product.item'); } $this->tpl->parse('content.form.product'); } $this->tpl->parse('content.form'); return true; }
/** * main action */ public function mainAction() { $customer_id = $_SESSION['client']['customer']['id']; if (!is_numeric($customer_id)) { msg("Address management requires active customer ID"); return true; } /** * initialize */ require_once 'models/client/client_customer.php'; require_once 'models/client/client_address.php'; require_once 'models/international/international_country.php'; $Customer = new client_customer(); $Address = new client_address(); $Country = new international_country(); $Customer->setCacheable(false); $Address->setCacheable(false); /** * add address */ if ($_POST['add_address']) { $_POST['client']['address']['customer_id'] = $customer_id; if ($address_id = $Address->insert($_POST['client']['address'])) { msg('New address added to your list.'); } else { msg('Address is not valid', 'error'); } } /** * select address */ if ($_POST['select_address']) { $customer_detail = $Customer->detail($customer_id); $customer_detail["{$this->GET['type']}_address_id"] = $_POST['select_address']; if ($Customer->update($customer_detail)) { $_SESSION['client']['customer'] = $customer_detail; onxshopGoTo($_SESSION['referer'], 2); } else { msg("Cannot select this address", 'error'); } } /** * remove address */ if (is_numeric($_POST['remove_address'])) { $address_id_to_remove = $_POST['remove_address']; $address_detail = $Address->detail($address_id_to_remove); if ($address_detail['customer_id'] == $customer_id) { if ($Address->deleteAddress($address_id_to_remove)) { msg('Address has been removed'); } else { msg('Cannot remove address', 'error'); } } else { msg("This is not your address!", 'error'); } } /** * address list */ $addresses = $Address->listing("customer_id = {$customer_id} AND is_deleted IS NOT TRUE", "id DESC"); $current_invoices = $_SESSION['client']['customer']['invoices_address_id']; $current_delivery = $_SESSION['client']['customer']['delivery_address_id']; foreach ($addresses as $addr) { $country_detail = $Country->detail($addr['country_id']); $addr['country'] = $country_detail; $this->tpl->assign('address', $addr); if ($addr['line_2'] != '') { $this->tpl->parse('content.address.line_2'); } if ($addr['line_3'] != '') { $this->tpl->parse('content.address.line_3'); } if ($this->GET['type'] != '') { $this->tpl->parse('content.address.select'); } else { if ($addr['id'] != $current_invoices && $addr['id'] != $current_delivery) { $this->tpl->parse('content.address.delete'); } } if ($current_invoices == $addr['id']) { $this->tpl->parse('content.address.is_invoices'); } if ($current_delivery == $addr['id']) { $this->tpl->parse('content.address.is_delivery'); } $this->tpl->parse('content.address'); } /** * country list */ $countries = $Country->listing("", "name ASC"); if (!isset($_POST['client']['address']['country_id'])) { $_POST['client']['address']['country_id'] = $Country->conf['default_id']; } foreach ($countries as $c) { if ($c['publish'] == 1) { if ($c['id'] == $_POST['client']['address']['country_id']) { $c['selected'] = "selected='selected'"; } else { $c['selected'] = ''; } $this->tpl->assign('country', $c); $this->tpl->parse('content.country.item'); } } $this->tpl->parse('content.country'); /** * assign to template */ $this->tpl->assign('client', $_POST['client']); return true; }
/** * generateCountryList */ public function generateCountryList() { /** * country list */ require_once 'models/international/international_country.php'; $Country = new international_country(); $countries = $Country->listing("", "name ASC"); if (!isset($_POST['client']['address']['delivery']['country_id'])) { $_POST['client']['address']['delivery']['country_id'] = $Country->conf['default_id']; } // address will be caught through relation //delivery foreach ($countries as $c) { if ($c['publish'] == 1) { if ($c['id'] == $_POST['client']['address']['delivery']['country_id']) { $c['selected'] = "selected='selected'"; } else { $c['selected'] = ''; } $this->tpl->assign('COUNTRY', $c); $this->tpl->parse('content.country_delivery.item'); } } $this->tpl->parse('content.country_delivery'); }
/** * get detail * * @param integer $id * client ID * * @return array * SQL row with client informations */ function getDetail($id) { $address = $this->detail($id); require_once 'models/international/international_country.php'; if (is_numeric($address['country_id'])) { $Country = new international_country(); $country_data = $Country->detail($address['country_id']); $address['country'] = $country_data; } return $address; }
protected function getCountryName($country_id) { require_once 'models/international/international_country.php'; $Country = new international_country(); $country = $Country->detail($country_id); return $country['name']; }