Example #1
0
 /**
  * main action
  */
 public function mainAction()
 {
     $Store = new ecommerce_store();
     $Taxonomy_Tree = new common_taxonomy_tree();
     $node_id = (int) $this->GET['node_id'];
     $store = $Store->findStoreByNode($node_id);
     $taxonomy = $Taxonomy_Tree->getRelatedTaxonomy($store['id'], "ecommerce_store_taxonomy");
     if ($store) {
         /**
          * get store taxonomy print out
          */
         $_Onxshop_Request = new Onxshop_Request("component/ecommerce/store_taxonomy~store_id={$store['id']}~");
         $this->tpl->assign("STORE_TAXONOMY", $_Onxshop_Request->getContent());
         /**
          * text depending if my selected store
          */
         if ($_SESSION['client']['customer']['store_id'] == $store['id']) {
             $this->tpl->assign('MY_SELECTED_STORE', 'My selected store');
         } else {
             $this->tpl->assign('MY_SELECTED_STORE', 'Save as my own store');
         }
         /**
          * assign and parse
          */
         $this->tpl->assign("STORE", $store);
         $this->tpl->parse("content.store");
     } else {
         $this->tpl->parse("content.no_store");
     }
     return true;
 }
 /**
  * getCategories
  */
 static function getCategories($store_id)
 {
     if (!is_numeric($store_id)) {
         return false;
     }
     require_once 'models/ecommerce/ecommerce_store.php';
     $Store = new ecommerce_store();
     return $Store->getRelatedTaxonomy($store_id);
 }
Example #3
0
 /**
  * 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;
 }
Example #4
0
 /**
  * main action
  */
 public function mainAction()
 {
     set_time_limit(0);
     $Store = new ecommerce_store();
     /**
      * Get the list
      */
     $date_from = $this->GET['date_from'];
     $date_to = $this->GET['date_to'];
     $records = $Store->getDataForNoticesReport($date_from, $date_to);
     $this->commonCSVAction($records, 'store_notices');
     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;
 }
Example #6
0
 /**
  * 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;
 }
 /**
  * get data
  */
 public function getData()
 {
     /**
      * initialize
      */
     require_once 'models/ecommerce/ecommerce_store.php';
     $Store = new ecommerce_store();
     /**
      * get stores
      */
     $records = $Store->listing("type_id = 1 AND publish = 1");
     $data = array();
     foreach ($records as $record) {
         $data[] = $this->formatItem($record);
     }
     return $data;
 }
 /**
  * main action
  */
 public function mainAction()
 {
     set_time_limit(0);
     $Store = new ecommerce_store();
     /**
      * Get the list
      */
     $date_from = date("Y-m-d", strtotime("first day of last month"));
     $date_to = date("Y-m-d", strtotime("first day of this month"));
     if (isset($this->GET['date_from'])) {
         $date_from = $this->GET['date_from'];
     }
     if (isset($this->GET['date_to'])) {
         $date_to = $this->GET['date_to'];
     }
     $records = $Store->getDataForNoticesReport($date_from, $date_to);
     $this->commonCSVAction($records, 'store_notices-' . $date_to);
     return true;
 }
Example #9
0
 /**
  * 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;
 }
Example #10
0
 /**
  * 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;
 }
Example #11
0
 /**
  * insert store to node
  */
 function insertNewStoreToNode($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 store detail
      */
     $store_detail = $Store->detail($store_id);
     /**
      * prepare node data
      */
     $store_node['title'] = $store_detail['title'];
     $store_node['parent'] = $parent_id;
     $store_node['parent_container'] = 0;
     $store_node['node_group'] = 'page';
     $store_node['node_controller'] = 'store';
     $store_node['content'] = $store_id;
     //$store_node['layout_style'] = $Node->conf['page_store_layout_style'];
     //this need to be updated on each store update
     $store_node['priority'] = $store_detail['priority'];
     $store_node['publish'] = $store_detail['publish'];
     /**
      * insert node
      */
     if ($store_homepage = $Node->nodeInsert($store_node)) {
         return $store_homepage;
     } else {
         msg("Can't add store to node.");
         return false;
     }
 }
Example #12
0
 /**
  * load store details
  */
 protected function getStoreDetails(&$page)
 {
     $store_id = $page['content'];
     if (!is_numeric($store_id)) {
         return false;
     }
     require_once "models/ecommerce/ecommerce_store.php";
     $Store = new ecommerce_store();
     $store = $Store->detail($store_id);
     $excerpt = strip_tags($store['description']);
     if (strlen($store['description']) > 0) {
         $excerpt .= "<br/>";
     }
     if (strlen($store['address']) > 0) {
         $excerpt .= nl2br($store['address']);
     }
     if (strlen($store['opening_hours']) > 0) {
         $excerpt .= "<br/><br/>" . nl2br($store['opening_hours']);
     }
     $page['excerpt'] = $this->highlightKeywords($excerpt, $this->keywords);
     $page['type_priority'] = 200;
     $page['priority'] = $store['priority'];
 }
Example #13
0
 /**
  * parseStoreSelect
  */
 protected function parseStoreSelect($selected_id, $template_block_path = 'content.form')
 {
     require_once 'models/ecommerce/ecommerce_store.php';
     $Store = new ecommerce_store();
     $provinces = $this->getTaxonomyBranch($GLOBALS['onxshop_conf']['global']['province_taxonomy_tree_id']);
     foreach ($provinces as $province) {
         $this->tpl->assign("PROVINCE_NAME", $province['label']['title']);
         $counties = $this->getTaxonomyBranch($province['id']);
         foreach ($counties as $county) {
             $county['selected'] = $selected_id == $county['id'] ? 'selected="selected"' : '';
             $this->tpl->assign("COUNTY", $county);
             // get all stores in this count
             $store_list = $Store->getFilteredStoreList($county['id'], false, 1, false, false, 1000);
             //limit to 1000 records per county and type_id=1
             foreach ($store_list as $store_item) {
                 if ($store_item['publish']) {
                     $this->tpl->assign('STORE', $store_item);
                     $this->tpl->parse("{$template_block_path}.store.county_dropdown.province.store");
                 }
             }
         }
         $this->tpl->parse("{$template_block_path}.store.county_dropdown.province");
     }
     $this->tpl->parse("{$template_block_path}.store.county_dropdown");
     $this->tpl->parse("{$template_block_path}.store");
 }
Example #14
0
 /**
  * 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;
     }
 }
Example #15
0
 /**
  * parseStoreSelect
  */
 protected function parseStoreSelect($selected_id)
 {
     require_once 'models/ecommerce/ecommerce_store.php';
     $Store = new ecommerce_store();
     $provinces = $this->getTaxonomyBranch(self::TAXONOMY_TREE_PROVINCE_ID);
     foreach ($provinces as $province) {
         $this->tpl->assign("PROVINCE_NAME", $province['label']['title']);
         $counties = $this->getTaxonomyBranch($province['id']);
         foreach ($counties as $county) {
             $county['selected'] = $selected_id == $county['id'] ? 'selected="selected"' : '';
             $this->tpl->assign("COUNTY", $county);
             // get all stores in this count
             $store_list = $Store->getFilteredStoreList($county['id'], false, 0, false, false, 1000);
             //limit to 1000 records per county
             foreach ($store_list as $store_item) {
                 $this->tpl->assign('STORE', $store_item);
                 $this->tpl->parse("content.form.require_user_details.store.county_dropdown.province.store");
             }
         }
         $this->tpl->parse("content.form.require_user_details.store.county_dropdown.province");
     }
     $this->tpl->parse("content.form.require_user_details.store.county_dropdown");
     $this->tpl->parse("content.form.require_user_details.store");
 }
Example #16
0
 /**
  * main action
  */
 public function mainAction()
 {
     // initialize filter variables
     $taxonomy_id = $this->GET['taxonomy_tree_id'];
     if (isset($_POST['store-list-filter'])) {
         $_SESSION['bo']['store-list-filter'] = $_POST['store-list-filter'];
     }
     $keyword = $_SESSION['bo']['store-list-filter']['keyword'];
     $type_id = $_SESSION['bo']['store-list-filter']['type_id'];
     // initialize sorting variables
     if ($this->GET['store-list-sort-by']) {
         $_SESSION['bo']['store-list-sort-by'] = $this->GET['store-list-sort-by'];
     }
     if ($this->GET['store-list-sort-direction']) {
         $_SESSION['bo']['store-list-sort-direction'] = $this->GET['store-list-sort-direction'];
     }
     if ($_SESSION['bo']['store-list-sort-by']) {
         $order_by = $_SESSION['bo']['store-list-sort-by'];
     } else {
         $order_by = 'modified';
     }
     if ($_SESSION['bo']['store-list-sort-direction']) {
         $order_dir = $_SESSION['bo']['store-list-sort-direction'];
     } else {
         $order_dir = 'DESC';
     }
     // initialize pagination variables
     if (is_numeric($this->GET['limit_from'])) {
         $from = $this->GET['limit_from'];
     } else {
         $from = 0;
     }
     if (is_numeric($this->GET['limit_per_page'])) {
         $per_page = $this->GET['limit_per_page'];
     } else {
         $per_page = 25;
     }
     // get the list
     require_once 'models/ecommerce/ecommerce_store.php';
     $Store = new ecommerce_store();
     $store_list = $Store->getFilteredStoreList($taxonomy_id, $keyword, $type_id, $order_by, $order_dir, $per_page, $from);
     $count = $Store->getFilteredStoreCount($taxonomy_id, $keyword, $type_id);
     if (!is_array($store_list)) {
         return false;
     }
     if (count($store_list) == 0) {
         $this->tpl->parse('content.empty_list');
         return true;
     }
     // display pagination
     $_Onxshop_Request = new Onxshop_Request("component/pagination~link=/request/bo/component/ecommerce/store_list:limit_from={$from}:limit_per_page={$per_page}:count={$count}~");
     $this->tpl->assign('PAGINATION', $_Onxshop_Request->getContent());
     // parse items
     foreach ($store_list as $item) {
         $item['modified'] = date("d/m/Y H:i", strtotime($item['modified']));
         $this->tpl->assign('ITEM', $item);
         if ($item['image_src']) {
             $this->tpl->parse('content.list.item.image');
         }
         $even_odd = 'odd' != $even_odd ? 'odd' : 'even';
         $publish = $item['publish'] ? '' : 'disabled';
         $this->tpl->assign('CLASS', "class='{$even_odd} {$publish} fullstore'");
         $this->tpl->parse('content.list.item');
     }
     $this->tpl->parse('content.list');
     return true;
 }