/** * main action */ public function mainAction() { // initialize require_once 'models/ecommerce/ecommerce_store.php'; $Store = new ecommerce_store(); // save if ($_POST['save']) { // set values if (!isset($_POST['store']['publish'])) { $_POST['store']['publish'] = 0; } $_POST['store']['modified'] = date('c'); // handle other_data $_POST['store']['other_data'] = serialize($_POST['store']['other_data']); // force numeric types $_POST['store']['coordinates_x'] = (int) $_POST['store']['coordinates_x']; $_POST['store']['coordinates_y'] = (int) $_POST['store']['coordinates_y']; $_POST['store']['latitude'] = (double) $_POST['store']['latitude']; $_POST['store']['longitude'] = (double) $_POST['store']['longitude']; // serialize street_view_options $_POST['store']['street_view_options'] = serialize($_POST['store']['street_view_options']); // remove if country_id isn't numeric if (!is_numeric($_POST['store']['country_id'])) { unset($_POST['store']['country_id']); } // update store if ($id = $Store->update($_POST['store'])) { msg("Store ID={$id} updated"); // update node info (if exists) $store_homepage = $Store->getStoreHomepage($_POST['store']['id']); if (is_array($store_homepage) && count($store_homepage) > 0) { $store_homepage['publish'] = $_POST['store']['publish']; require_once 'models/common/common_node.php'; $Node = new common_node(); $Node->nodeUpdate($store_homepage); } // forward to store list main page and exit onxshopGoTo("/backoffice/stores"); return true; } else { msg("Cannot update store details", 'error'); } } // store detail $store = $Store->detail($this->GET['id']); $store['publish'] = $store['publish'] == 1 ? 'checked="checked" ' : ''; $store['street_view_options'] = unserialize($store['street_view_options']); $this->tpl->assign('STORE', $store); $this->tpl->assign('STREET_VIEW_IMAGE_' . (int) $store['street_view_options']['image'], 'checked="checked"'); $this->parseTypeSelect($store['type_id']); return true; }
/** * main action */ public function mainAction() { // get selected store for detail $node_id = (int) $this->GET['node_id']; if ($node_id > 0) { $Node = new common_node(); $Store = new ecommerce_store(); $current_store = $Store->findStoreByNode($node_id); if ($current_store & is_numeric($current_store['id'])) { $distance = 0.2; $lat1 = (double) ((double) $current_store['latitude'] - $distance); $lat2 = (double) ((double) $current_store['latitude'] + $distance); $lng1 = (double) ((double) $current_store['longitude'] - $distance); $lng2 = (double) ((double) $current_store['longitude'] + $distance); $stores = $Store->listing("id != {$current_store['id']} AND publish = 1 AND " . "latitude BETWEEN {$lat1} AND {$lat2} AND longitude BETWEEN {$lng1} AND {$lng2}"); if (count($stores) > 0) { $distances = array(); foreach ($stores as $i => $store) { $distance = $this->distance($current_store['latitude'], $current_store['longitude'], $store['latitude'], $store['longitude']); $distances[$i] = $distance; } asort($distances, SORT_NUMERIC); $i = 0; foreach ($distances as $store_index => $distance) { $store = $stores[$store_index]; if ($distance < 1) { $distance = round($distance * 1000) . " meters"; } else { $distance = number_format($distance, 1) . " km"; } $store['distance'] = $distance; // get store page for url $page = $Store->getStoreHomepage($store['id']); $store['node_id'] = $page['id']; $this->tpl->assign("STORE", $store); $column = $i % 3 + 1; $this->tpl->parse("content.list.column{$column}"); $i++; if ($i == 9) { break; } // 9 sotres is enough } $this->tpl->parse("content.list"); } } } return true; }
/** * main action */ public function mainAction() { if ($this->GET['to']) { header("HTTP/1.1 301 Moved Permanently"); onxshopGoTo($this->GET['to']); } else { if (is_numeric($this->GET['product_id'])) { header("HTTP/1.1 301 Moved Permanently"); require_once 'models/common/common_node.php'; $Node = new common_node(); $product_homepage = $Node->getProductNodeHomepage($this->GET['product_id']); if (is_array($product_homepage)) { onxshopGoTo("/page/{$product_homepage['id']}"); } else { msg("Product no longer available"); onxshopGoTo("/"); } } else { if (is_numeric($this->GET['recipe_id'])) { header("HTTP/1.1 301 Moved Permanently"); require_once 'models/common/common_node.php'; $Node = new common_node(); $recipe_homepage = $Node->getRecipeNodeHomepage($this->GET['recipe_id']); if (is_array($recipe_homepage)) { onxshopGoTo("/page/{$recipe_homepage['id']}"); } else { msg("Recipe no longer available"); onxshopGoTo("/"); } } else { if (is_numeric($this->GET['store_id'])) { header("HTTP/1.1 301 Moved Permanently"); require_once 'models/ecommerce/ecommerce_store.php'; $Store = new ecommerce_store(); $store_homepage = $Store->getStoreHomepage($this->GET['store_id']); if (is_array($store_homepage)) { onxshopGoTo("/page/{$store_homepage['id']}"); } else { msg("Store no longer available"); onxshopGoTo("/"); } } } } } return true; }
/** * main action */ public function mainAction() { if ($_SESSION['client']['customer']['id'] > 0) { $store_id = (int) $_SESSION['client']['customer']['store_id']; if ($store_id > 0) { $Store = new ecommerce_store(); $store = $Store->detail($store_id); $store_page = $Store->getStoreHomepage($store_id); $this->tpl->assign("STORE_PAGE", $store_page); $this->tpl->assign("STORE", $store); $this->tpl->parse('content.authorised_selected'); } else { $this->tpl->parse('content.authorised_not_selected'); } } else { $this->tpl->parse('content.anonymouse'); } return true; }
/** * main action */ public function mainAction() { require_once 'models/common/common_node.php'; require_once 'models/common/common_scheduler.php'; require_once 'models/ecommerce/ecommerce_store.php'; $this->Node = new common_node(); $this->Scheduler = new common_scheduler(); $Store = new ecommerce_store(); $this->Node->setCacheable(false); $this->Scheduler->setCacheable(false); $Store->setCacheable(false); $store_id = $this->GET['store_id']; $node_detail = $Store->getStoreHomepage($store_id); if (!is_array($node_detail)) { msg("node_child: Node not found", 'error'); return false; } $this->parseList($node_detail['id']); return true; }
/** * move store node */ function moveStoreNode($store_id, $parent_id) { if (!is_numeric($store_id)) { return false; } if (!is_numeric($parent_id)) { return false; } $Node = new common_node(); $Store = new ecommerce_store(); /** * get current detail */ $store_homepage = $Store->getStoreHomepage($store_id); /** * modify node data */ $store_homepage['parent'] = $parent_id; if ($Node->nodeUpdate($store_homepage)) { msg("Store node has been updated", 'ok'); return $store_homepage; } else { msg("Can't update store node."); return false; } }