public function genformAction()
 {
     $generic = new Model_Generic();
     $table = $this->_getParam('tbl');
     /***$protected_tables = array("users","merchandisers","outlets","agents","activity_logs","users_access");
     
     		if(in_array($table,$protected_tables) && $authsession->user_access != 1){
     			$this->_redirect('/index/');
     			//$this->view->disable_input = 1;
     		}
     
     		if(in_array($table,$protected_tables)){
     			$this->view->disable_input = 1;
     		}***/
     //process form
     if ($_POST) {
         $data = $_POST;
         $save = $generic->insertData($table, $data);
         $this->view->saveMsg = array('success', 'Successfully Saved.');
         $this->_redirect('/encoder/genform/tbl/' . $table);
     }
     $list = $generic->getData($table, null, "ID", null);
     $paginator = Zend_Paginator::factory($list);
     $curPage = $this->_getParam('page', 1);
     $paginator->setItemCountPerPage(10);
     $paginator->setCurrentPageNumber($curPage);
     $this->view->list = $paginator;
     $this->view->table = $table;
     $generic_call = $generic->genericForm($table);
     $this->view->genform = $generic_call;
 }
Exemplo n.º 2
0
 public function productscreateAction()
 {
     $generic = new Model_Generic();
     $generic_call = $generic->genericForm("Products");
     $this->view->genform = $generic_call;
     $product_data = array();
     if ($_POST) {
         foreach ($_POST as $key => $val) {
             if ($key != 'BrandID' && $key != 'CategoryID' && $key != 'Price' && $key != 'DiscPrice' && $key != 'WholePrice' && $key != 'DiscRate' && $key != 'Quantity' & $key != 'Minimum') {
                 $product_data[$key] = $val;
             }
         }
         //1. Create Product
         $product_data['URLSegment'] = Model_Page::urlFriendly($_POST['Name']);
         if (isset($_POST['ProductID'])) {
             //update
             $product_id = $_POST['ProductID'];
             unset($product_data['ProductID']);
             $generic->updateData("Products", $product_data, "ID=" . $product_id);
         } else {
             $product_id = $generic->insertData("Products", $product_data);
         }
         //2. Create Price Relations
         $price_data = array();
         $price_data['Created'] = $_POST['Created'];
         $price_data['LastEdited'] = $_POST['LastEdited'];
         $price_data['ProductID'] = $product_id;
         $price_data['Currency'] = 'USD';
         // we'll set this to USD for now
         $price_data['Price'] = $_POST['Price'];
         $price_data['WholePrice'] = $_POST['WholePrice'];
         $price_data['DiscPrice'] = $_POST['DiscPrice'];
         $price_data['DiscRate'] = $_POST['DiscRate'];
         if (isset($_POST['ProductID'])) {
             $generic->oldSkul("delete from Prices where ProductID =" . $product_id, false);
             $price = $generic->insertData("Prices", $price_data);
         } else {
             $price = $generic->insertData("Prices", $price_data);
         }
         //3. Create Store Data
         $store_data = array();
         $store_data['ProductID'] = $product_id;
         //$store_data['CategoryID'] = 0;
         $store_data['BrandID'] = $_POST['BrandID'];
         $store_data['Quantity'] = $_POST['Quantity'];
         $store_data['Minimum'] = $_POST['Minimum'];
         if (isset($_POST['ProductID'])) {
             $generic->oldSkul("delete from Store where ProductID =" . $product_id, false);
             $store = $generic->insertData("Store", $store_data);
         } else {
             $store = $generic->insertData("Store", $store_data);
         }
         //4. Create Category Relations
         //See productscategoriesAction
         $this->_redirect('/admin/productsdisplay/pid/' . $product_id . '/?sysmsg=success');
     }
     $this->view->data = array();
     $this->view->Brands = $generic->getData("Brands", "", "Name");
     $this->view->Categories = $generic->getData("Category", "", "Name asc");
 }