Exemplo n.º 1
0
 /**
  * parseProductSelect
  */
 function parseProductSelect()
 {
     require_once 'models/ecommerce/ecommerce_product.php';
     $Product = new ecommerce_product();
     $Image = new ecommerce_product_image();
     $listing = $Product->listing('', 'name ASC');
     foreach ($listing as $item) {
         if ($item['publish'] == 0) {
             $item['class'] = 'notpublic';
         }
         $detail = $this->Node->listing("node_group = 'page' AND node_controller ~ 'product' AND content = '{$item['id']}'");
         if (count($detail) == 0) {
             $item['disabled'] = 'disabled';
         }
         $image = $Image->listing("node_id = {$item['id']}", "priority DESC, id ASC");
         if (count($image) > 0) {
             $item['image_src'] = $image[0]['src'];
         } else {
             $item['image_src'] = '/var/files/placeholder.png';
         }
         $this->tpl->assign("PRODUCT", $item);
         $this->tpl->parse("content.product_select_item");
     }
 }
Exemplo n.º 2
0
 /**
  * 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;
 }