Example #1
0
 public function shipping()
 {
     $this->load->appModel('Settings');
     $settings = $this->shippingweight_model_settings->getSettings($this->config->get('store_id'));
     if ($settings['enabled'] == 'on' || $settings['enabled']) {
         if ($this->config->get('is_admin')) {
             if (!empty($this->request->get['country_id'])) {
                 $this->load->model('localisation/geo_zone');
                 $zones = $this->model_localisation_geo_zone->getZoneToGeoZone($this->request->get['country_id']);
                 $data = $this->getBestOffer($zones);
             }
             if (empty($data) || !count($data)) {
                 return;
             }
             return array('shippingweight' => $data);
         } else {
             if (!$this->cart->hasShipping()) {
                 return;
             }
             $zones = $this->session->data['shipping']['geo_zone'];
             $data = $this->getBestOffer($zones, $this->cart->getWeight());
             if (empty($data)) {
                 return;
             }
             if (!empty($data['rate']) && $data['rate'] > 0.0) {
                 $data['price'] = $data['rate'];
                 $data['rate'] = Sumo\Formatter::currency($data['rate'] + $data['rate'] / 100 * $data['tax']);
             }
             return array('shippingweight' => $data);
         }
     }
 }
Example #2
0
 public function shipping()
 {
     $this->load->appModel('Settings');
     $settings = $this->shippingpickup_model_settings->getSettings($this->config->get('store_id'));
     if ($settings['enabled'] == 'on' || $settings['enabled']) {
         $data = array('rate' => '0.00', 'tax' => '0');
         if ($this->config->get('is_admin')) {
             return array('shippingpickup' => $data);
         } else {
             foreach ($this->session->data['shipping']['geo_zone'] as $geoList) {
                 if (isset($settings['zone'][$geoList['geo_zone_id']]) && $settings['zone'][$geoList['geo_zone_id']]['enabled'] == 'on') {
                     if (empty($data['price'])) {
                         $data['price'] = $data['rate'];
                     }
                     if (!empty($data['rate']) && $data['rate'] > 0.0) {
                         $data['rate'] = Sumo\Formatter::currency($data['rate'] + $data['rate'] / 100 * $data['tax']);
                     } else {
                         unset($data['rate']);
                     }
                     return array('shippingpickup' => $data);
                 }
             }
         }
     }
 }
Example #3
0
 public function payment()
 {
     $this->load->appModel('Settings');
     $settings = $this->banktransfer_model_settings->getSettings($this->config->get('store_id'));
     if ($settings['enabled'] == 'on' || $settings['enabled']) {
         if ($this->config->get('is_admin')) {
             $this->load->model('localisation/zone');
             $zones = $this->model_localisation_zone->getCountryToGeoZone($this->request->get['country_id']);
             $data = array();
             if (!empty($settings['general'])) {
                 if (strlen($settings['general']['extra']) > 0) {
                     $data = array('rate' => $settings['general']['extra'], 'tax' => $settings['general']['tax']);
                 }
             }
             foreach ($zones as $zone) {
                 if (isset($settings['zone'][$zone['geo_zone_id']]) && $settings['zone'][$zone['geo_zone_id']] == 'on' || $settings['zone'][$zone['geo_zone_id']] && strlen($settings['zone'][$zone['geo_zone_id']]['extra']) > 0) {
                     if (isset($data['rate']) && $data['rate'] > $settings['zone'][$zone['geo_zone_id']]['extra'] || !isset($data['rate'])) {
                         $data = array('rate' => $settings['zone'][$zone['geo_zone_id']]['extra'], 'tax' => $settings['zone'][$zone['geo_zone_id']]['tax']);
                     }
                 }
             }
             if (count($data)) {
                 return array('banktransfer' => $data);
             }
         } else {
             $data = array();
             if (isset($settings['general'])) {
                 if (strlen($settings['general']['extra']) > 0 && ($this->config->get('is_admin') || $this->cart->getTotal() >= $settings['general']['rate'])) {
                     $data = array('rate' => $settings['general']['extra'], 'tax' => $settings['general']['tax']);
                 }
             }
             foreach ($this->session->data['payment']['geo_zone'] as $zone) {
                 $settingsZone = $settings['zone'][$zone['geo_zone_id']];
                 if (!empty($settingsZone)) {
                     if (strlen($settingsZone['extra']) && strlen($settingsZone['rate'])) {
                         if (empty($settingsZone['rate']) || $this->cart->getTotal() >= $settingsZone['rate']) {
                             if (!isset($data['extra']) || $data['rate'] > $settingsZone['extra']) {
                                 $data = array('rate' => $settingsZone['extra'], 'tax' => $settingsZone['tax']);
                             }
                         }
                     }
                 }
             }
             if (count($data)) {
                 if (!empty($data['rate']) && $data['rate'] > 0.0) {
                     $data['price'] = $data['rate'] + $data['rate'] / 100 * $data['tax'];
                     $data['rate'] = Sumo\Formatter::currency($data['price']);
                 } else {
                     unset($data['rate']);
                 }
                 return array('banktransfer' => $data);
             }
         }
     }
 }
Example #4
0
 public function payment()
 {
     $this->load->appModel('Settings');
     $this->load->appModel('Api');
     $settings = $this->sisow_model_settings->getSettings($this->config->get('store_id'));
     try {
         $this->sisow_model_api->setMerchant($settings['merchant']['id'], $settings['merchant']['key']);
     } catch (\Exception $e) {
         // Empty/invalid key, return nothing
         return;
     }
     if ($this->config->get('is_admin')) {
     } else {
         $methods = $this->sisow_model_api->callMethods();
         if (!isset($methods['merchant']['active']) || !$methods['merchant']['active']) {
             return;
         }
         if (isset($methods['merchant']['payments']['payment'])) {
             $methods = $methods['merchant']['payments']['payment'];
         } else {
             return;
         }
         $total = $this->cart->getTotal();
         $check = $return = array();
         foreach ($methods as $method) {
             if (isset($settings[$method]) && isset($settings[$method]['enabled'])) {
                 $check[$method] = $settings[$method];
             }
         }
         foreach ($check as $id => $data) {
             foreach ($this->session->data['payment']['geo_zone'] as $zone) {
                 if (!empty($data['zone']) && $data['zone'] == $zone['geo_zone_id'] || empty($data['zone'])) {
                     $rate = '';
                     $price = $data['rate'];
                     if ($data['rate_type'] == 'f') {
                         if (!empty($data['rate'])) {
                             $price = $price * (1 + $settings['tax'] / 100);
                             $rate = Sumo\Formatter::currency($data['rate'] + $data['rate'] / 100 * $settings['tax']);
                         }
                     } else {
                         if (!empty($data['rate'])) {
                             $rate = $data['rate'] . '%';
                         }
                     }
                     $return[$id] = array('price' => $price, 'rate' => $rate, 'tax' => $settings['tax'], 'name' => '<img src="app/sisow/paylogos/' . $id . '.png" alt="' . $data['description'] . '">', 'description' => Sumo\Language::getVar('APP_SISOW_CATALOG_' . strtoupper($id) . '_DESCRIPTION'));
                 }
             }
         }
         if (count($return)) {
             return $return;
         }
         return;
     }
 }
Example #5
0
 public function payment()
 {
     $this->load->appModel('Settings');
     $this->load->appModel('Api');
     $settings = $this->multisafepay_model_settings->getSettings($this->config->get('store_id'));
     try {
         $this->multisafepay_model_api->setSettings($settings);
     } catch (\Exception $e) {
         // Empty/invalid key, return nothing
         return;
     }
     if ($this->config->get('is_admin')) {
     } else {
         $methods = $this->multisafepay_model_api->getGateways(false);
         if (isset($methods['gateways']['gateway'])) {
             $methods = $methods['gateways']['gateway'];
         } else {
             return;
         }
         $total = $this->cart->getTotal();
         $check = $return = array();
         foreach ($methods as $method) {
             $method['id'] = strtolower($method['id']);
             if (isset($settings[$method['id']])) {
                 $check[$method['id']] = array_merge($settings[$method['id']], $method);
             }
         }
         foreach ($check as $id => $data) {
             foreach ($this->session->data['payment']['geo_zone'] as $zone) {
                 if (!empty($data['zone']) && $data['zone'] == $zone['geo_zone_id'] || empty($data['zone'])) {
                     $rate = '';
                     if ($data['rate_type'] == 'f') {
                         if (!empty($data['rate'])) {
                             $rate = Sumo\Formatter::currency($data['rate'] + $data['rate'] / 100 * $settings['tax']);
                         }
                     } else {
                         if (!empty($data['rate'])) {
                             $rate = $data['rate'] . '%';
                         }
                     }
                     $return[$id] = array('rate' => $rate, 'tax' => $settings['tax'], 'name' => '<img src="app/multisafepay/catalog/view/img/' . $id . '.png">', 'description' => $data['description']);
                 }
             }
         }
         if (count($return)) {
             return $return;
         }
         return;
     }
 }
Example #6
0
 public function payment()
 {
     $this->load->appModel('Settings');
     $this->load->appModel('Api');
     $settings = $this->mollie_model_settings->getSettings($this->config->get('store_id'));
     try {
         $this->mollie_model_api->setKey($settings['general']['api_key']);
     } catch (\Exception $e) {
         // Empty/invalid key, return nothing
         return;
     }
     if ($this->config->get('is_admin')) {
     } else {
         $methods = $this->mollie_model_api->callMethods();
         $total = $this->cart->getTotal();
         $check = $return = array();
         foreach ($methods['data'] as $method) {
             if (isset($settings[$method['id']]) && isset($settings[$method['id']]['enabled'])) {
                 if ($total >= $method['amount']['minimum'] && $total <= $method['amount']['maximum']) {
                     $check[$method['id']] = array_merge($settings[$method['id']], $method);
                 }
             }
         }
         foreach ($check as $id => $data) {
             foreach ($this->session->data['payment']['geo_zone'] as $zone) {
                 if (!empty($data['zone']) && $data['zone'] == $zone['geo_zone_id'] || empty($data['zone'])) {
                     $rate = '';
                     $price = $data['rate'];
                     if ($data['rate_type'] == 'f') {
                         if (!empty($data['rate'])) {
                             $price = $price * (1 + $settings['tax'] / 100);
                             $rate = Sumo\Formatter::currency($data['rate'] + $data['rate'] / 100 * $settings['tax']);
                         }
                     } else {
                         if (!empty($data['rate'])) {
                             $rate = $data['rate'] . '%';
                         }
                     }
                     $return[$id] = array('rate' => $rate, 'rate_type' => $data['rate_type'], 'price' => $price, 'tax' => $settings['tax'], 'name' => '<img src="' . $data['image']['normal'] . '">', 'description' => Sumo\Language::getVar('APP_MOLLIE_CATALOG_' . strtoupper($id) . '_DESCRIPTION'));
                 }
             }
         }
         if (count($return)) {
             return $return;
         }
         return;
     }
 }
Example #7
0
 private function getBestOffer($zones)
 {
     $this->load->appModel('Settings');
     $settings = $this->shippingflat_model_settings->getSettings($this->config->get('store_id'));
     $possible = $prices = $return = array();
     $count = 1;
     $lowestRate = 999999999;
     foreach ($zones as $zoneList) {
         if (isset($settings['zone'][$zoneList['geo_zone_id']]) && !empty($settings['zone'][$zoneList['geo_zone_id']]['rate'])) {
             $rate = $settings['zone'][$zoneList['geo_zone_id']];
             if (empty($rate['price'])) {
                 $rate['price'] = $rate['rate'];
             }
             $rate['rate'] = Sumo\Formatter::currency($rate['rate'] + $rate['rate'] / 100 * $rate['tax']);
             $possible[$count] = $rate;
             $prices[$rate['rate']] = $count;
             if ($lowestRate >= $rate['rate']) {
                 $possible = $rate;
                 $lowestRate = $rate['rate'];
             }
         }
     }
     return $possible;
 }
Example #8
0
define('HTTPS_SERVER', $store['base_https'] . $config->get('admin_directory') . '/');
define('HTTP_STYLE_BASE', $store['base_https']);
// Language, CLEANUP REQUIRED!!!
$languages = array();
foreach (Sumo\Database::fetchAll("SELECT * FROM PREFIX_language ORDER BY language_id") as $list) {
    $languages[$list['language_id']] = $list;
}
Sumo\Language::setup($languages[$config->get('language_id')]);
$lang = $languages[$config->get('language_id')];
setlocale(LC_TIME, '');
$locale = setlocale(LC_TIME, $lang['locale']);
$config->set('locale', $lang['locale']);
Sumo\Logger::info('Locale: ' . ($locale ? 'set' : 'failed'));
Sumo\Logger::info('Language created');
// Formatter
Sumo\Formatter::setup($config);
// Cache
Sumo\Cache::setStore('admin');
// Mail
Sumo\Mail::setup($config);
Sumo\Mailer::setup($config);
// Url
$url = new Url($store['base_https'] . $config->get('admin_directory') . '/', $store['base_https'] . $config->get('admin_directory') . '/');
$registry->set('url', $url);
Sumo\Logger::info('URL created');
// Request
if (empty($_GET['route']) && !empty($_GET['_route_'])) {
    $_GET['route'] = str_replace($config->get('admin_directory') . '/', '', $_GET['_route_']);
}
$request = new Request();
$registry->set('request', $request);
Example #9
0
 public function payment()
 {
     $this->load->appModel('Settings');
     $settings = $this->cashondelivery_model_settings->getSettings($this->config->get('store_id'));
     if ($settings['enabled'] == 'on' || $settings['enabled']) {
         if ($this->config->get('is_admin')) {
             $this->load->model('localisation/zone');
             $zones = $this->model_localisation_zone->getCountryToGeoZone($this->request->get['country_id']);
             $total = $this->request->get['totalamount'];
             $data = array();
             if (!empty($settings['general'])) {
                 if (strlen($settings['general']['rate']) > 0) {
                     $minimum = 0;
                     $maximum = 100000;
                     if (!empty($settings['general']['minimum'])) {
                         $minimum = $settings['general']['minimum'] + $settings['general']['minimum'] / 100 * $settings['general']['tax'];
                     }
                     if (!empty($settings['general']['maximum'])) {
                         $maximum = $settings['general']['maximum'] + $settings['general']['maximum'] / 100 * $settings['general']['tax'];
                     }
                     if ($total >= $minimum && $total <= $maximum) {
                         $data = array('rate' => $settings['general']['rate'], 'tax' => $settings['general']['tax']);
                     }
                 }
             }
             foreach ($zones as $zone) {
                 if (isset($settings['zone'][$zone['geo_zone_id']]) && $settings['zone'][$zone['geo_zone_id']] == 'on' || $settings['zone'][$zone['geo_zone_id']] && strlen($settings['zone'][$zone['geo_zone_id']]['rate']) > 0) {
                     if (isset($data['rate']) && $data['rate'] > $settings['zone'][$zone['geo_zone_id']]['rate'] || !isset($data['rate'])) {
                         $data = array('rate' => $settings['zone'][$zone['geo_zone_id']]['rate'], 'tax' => $settings['zone'][$zone['geo_zone_id']]['tax']);
                     }
                 }
             }
             if (count($data)) {
                 if (!empty($data['rate']) && $data['rate'] > 0.0) {
                     $data['rate'] = Sumo\Formatter::currency($data['rate'] + $data['rate'] / 100 * $data['tax']);
                 } else {
                     unset($data['rate']);
                 }
                 return array('cashondelivery' => $data);
             }
             /*
             if (!empty($this->request->get['country_id']) && isset($settings['zone'][$this->request->get['country_id']])) {
                 $data = $settings['zone'][$this->request->get['country_id']];
             }
             else if (strlen($settings['general']['extra']) > 0) {
                 $data = $settings['general'];
             }
             
             if (!$data) {
                 return;
             }
             
             if (!empty($this->request->get['totalamount'])) {
                 if (!empty($data['rate'])) {
                     $total = $data['rate'];
                     if (!empty($data['tax'])) {
                         //$total += ($data['rate'] / 100 * $data['tax']);
                     }
                     if ($total >= $this->request->get['totalamount']) {
                         return array('cashondelivery' => array('rate' => $data['extra'], 'tax' => $data['tax']));
                     }
                 }
                 else {
                     return array('cashondelivery' => array('rate' => $data['extra'], 'tax' => $data['tax']));
                 }
             }
             else {
                 return array('cashondelivery' => array('rate' => $data['extra'], 'tax' => $data['tax']));
             }
             */
         } else {
             if (isset($settings['zone'][$this->session->data['payment']['geo_zone']]) && ($settings['zone'][$this->session->data['payment']['geo_zone']] == 'on' || $settings['zone'][$this->session->data['payment']['geo_zone']]) && strlen($settings['zone'][$this->session->data['payment']['geo_zone']]['rate']) > 0 && $this->cart->getTotal() >= $settings['zone'][$this->session->data['payment']['geo_zone']]['minimum'] && $this->cart->hasShipping()) {
                 $data['tax'] = $settings['zone'][$this->session->data['payment']['geo_zone']]['tax'];
                 $data['price'] = $settings['zone'][$this->session->data['payment']['geo_zone']]['extra'] + $settings['zone'][$this->session->data['payment']['geo_zone']]['extra'] / 100 * $data['tax'];
                 $data['rate'] = Sumo\Formatter::currency($data['price']);
                 return array('cashondelivery' => $data);
             } else {
                 if (isset($settings['general'])) {
                     if (strlen($settings['general']['rate']) > 0 && ($this->config->get('is_admin') || $this->cart->getTotal() >= $settings['general']['minimum'] && $this->cart->hasShipping())) {
                         $data['tax'] = $settings['general']['tax'];
                         $data['price'] = $settings['general']['rate'] + $settings['general']['rate'] / 100 * $data['tax'];
                         $data['rate'] = Sumo\Formatter::currency($data['price']);
                         return array('cashondelivery' => $data);
                     }
                 }
             }
         }
     }
 }
Example #10
0
 protected function getList()
 {
     $this->document->addBreadcrumbs(array('text' => Sumo\Language::getVar('SUMO_ADMIN_CATALOG_DASHBOARD'), 'href' => $this->url->link('catalog/dashboard')));
     $this->document->addBreadcrumbs(array('text' => Sumo\Language::getVar('SUMO_ADMIN_CATALOG_STOCK')));
     $filter_keys = array('name', 'quantity_from', 'quantity_to', 'quantity', 'category', 'store');
     $filter = array();
     $url = '';
     foreach ($filter_keys as $filter_key) {
         $filter[$filter_key] = isset($this->request->get[$filter_key]) ? $this->request->get[$filter_key] : '';
         if ($filter[$filter_key] != '') {
             $url .= '&' . $filter_key . '=' . $filter[$filter_key];
         }
     }
     // Limit?
     $limit = 25;
     if (isset($this->request->get['limit'])) {
         $limit = $this->request->get['limit'];
     }
     $page = 1;
     $start = 0;
     if (isset($this->request->get['page']) && $this->request->get['page'] > 0) {
         $page = (int) $this->request->get['page'];
         $start = ($page - 1) * $limit;
     }
     // We need this variable in all circumstances
     $this->data['products'] = array();
     // Get product list
     $this->load->appModel('Inventory');
     $this->load->model('catalog/product');
     $this->load->model('tool/image');
     $products = $this->inventory_model_inventory->getProducts(array_merge($filter, array('start' => $start, 'limit' => $limit)));
     $totalProducts = $this->inventory_model_inventory->getTotalProducts($filter);
     $totalProductsInView = $this->inventory_model_inventory->getTotalProductsInView($filter);
     foreach ($products as $k => $product) {
         $image = $this->model_tool_image->resize('no_image.jpg', 60, 60);
         if ($product['image'] && file_exists(DIR_IMAGE . $product['image'])) {
             $image = $this->model_tool_image->resize($product['image'], 60, 60);
         }
         $this->data['products'][] = array_merge($product, array('product_id' => $product['product_id'], 'stock_id' => $product['stock_id'], 'name' => $product['name'], 'model' => !empty($product['model_2']) ? $product['model_2'] : $product['model'], 'image' => $image, 'quantity' => $product['quantity'], 'price' => $product['price'], 'price_net' => $product['price'] + $product['price'] * $product['tax_percentage'] / 100, 'value' => $product['cost_price'], 'options' => $this->model_catalog_product->getProductOptions($product['product_id']), 'edit' => $this->url->link('catalog/product/update', 'token=' . $this->session->data['token'] . '&product_id=' . $product['product_id'])));
     }
     // The quantity filter is something a bit different
     $filter_quantity = $filter_quantity_type = '';
     if (!empty($filter['quantity_from'])) {
         $filter_quantity = $filter['quantity_from'];
         $filter_quantity_type = 'quantity_from';
     } elseif (!empty($filter['quantity_to'])) {
         $filter_quantity = $filter['quantity_to'];
         $filter_quantity_type = 'quantity_to';
     } elseif (!empty($filter['quantity'])) {
         $filter_quantity = $filter['quantity'];
         $filter_quantity_type = 'quantity';
     }
     // Get some stats
     $this->data = array_merge($this->data, array('filter_name' => $filter['name'], 'filter_category' => $filter['category'], 'filter_store' => $filter['store'], 'filter_quantity' => $filter_quantity, 'filter_quantity_type' => $filter_quantity_type, 'token' => $this->session->data['token'], 'limit' => $limit, 'token' => $this->session->data['token'], 'total_products' => $totalProducts, 'total_value' => Sumo\Formatter::currency($this->inventory_model_inventory->getTotalProductsValue($filter)), 'total_price' => Sumo\Formatter::currency($this->inventory_model_inventory->getTotalProductsPrice($filter)), 'url' => $this->url->link('app/inventory', 'token=' . $this->session->data['token'] . $url), 'reset' => $this->url->link('app/inventory', 'token=' . $this->session->data['token']), 'export' => $this->url->link('app/inventory/export', 'token=' . $this->session->data['token'] . $url)));
     // List some categories
     $categories = $this->inventory_model_inventory->getCategories();
     foreach ($categories as $store_id => $store_categories) {
         foreach ($store_categories as $k => $category) {
             for ($i = 0; $i < $category['level'] * 4; $i++) {
                 $categories[$store_id][$k]['name'] = '&nbsp;' . $categories[$store_id][$k]['name'];
             }
         }
     }
     // List some stores
     $this->load->model('settings/stores');
     $stores = $this->model_settings_stores->getStores();
     // Set pagination
     $pagination = new Sumo\Pagination();
     $pagination->total = $totalProductsInView;
     $pagination->limit = $limit;
     $pagination->page = $page;
     $pagination->url = $this->url->link('app/inventory', 'token=' . $this->session->data['token'] . $url . '&page={page}&limit=' . $limit);
     $this->data['pagination'] = $pagination->renderAdmin();
     $this->data['stores'] = $stores;
     $this->data['categories'] = isset($categories[$filter['store']]) ? $categories[$filter['store']] : array();
     $this->data['json_categories'] = json_encode($categories);
     $this->document->addStyle('view/css/pages/product.css');
     $this->document->addScript('../apps/inventory/admin/view/js/inventory.js');
     $this->template = 'index.tpl';
     $this->children = array('common/header', 'common/footer');
     $this->response->setOutput($this->render());
 }