Beispiel #1
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;
 }
Beispiel #2
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;
 }
Beispiel #3
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['name'];
     $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)) {
         msg("Store has been added into the node", 'ok');
         return $store_homepage;
     } else {
         msg("Can't add store to node.");
         return false;
     }
 }
Beispiel #4
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'];
 }