public function productsAction()
 {
     $form = new Form_Iadmin_Products();
     $item_pack_size = new Model_ItemPackSizes();
     $params = array();
     if ($this->_request->isPost()) {
         if ($form->isValid($this->_request->getPost())) {
             $item_name = $form->getValue('item_name');
             $item_category = $form->getValue('item_category');
             $item_unit = $form->getValue('item_unit');
             $item = $form->getValue('item');
             if (!empty($item_name)) {
                 $item_pack_size->form_values['item_name'] = $item_name;
                 $params['item_name'] = $item_name;
             }
             if (!empty($item_category)) {
                 $item_pack_size->form_values['item_category'] = $item_category;
                 $params['item_category'] = $item_category;
             }
             if (!empty($item_unit)) {
                 $item_pack_size->form_values['item_unit'] = $item_unit;
                 $params['item_unit'] = $item_unit;
             }
             if (!empty($item)) {
                 $item_pack_size->form_values['item'] = $item;
                 $params['item'] = $item_unit;
             }
         }
         $form->item_name->setValue($item_name);
         $form->item_category->setValue($item_category);
         $form->item_unit->setValue($item_unit);
         $form->item->setValue($item);
     }
     $sort = $this->_getParam("sort", "asc");
     $order = $this->_getParam("order", "stakeholder");
     $item_pack_size->form_values = $this->_request->getParams();
     $form->item_name->setValue($this->_getParam('item_name'));
     $form->item_category->setValue($this->_getParam('item_category'));
     $form->item_unit->setValue($this->_getParam('item_unit'));
     $form->item->setValue($this->_getParam('item'));
     $result = $item_pack_size->getAllProducts();
     //Paginate the contest results
     $paginator = Zend_Paginator::factory($result);
     $page = $this->_getParam("page", 1);
     $counter = $this->_getParam("counter", 10);
     $paginator->setCurrentPageNumber((int) $page);
     $paginator->setItemCountPerPage((int) $counter);
     $this->view->form = $form;
     $this->view->paginator = $paginator;
     $this->view->sort = $sort;
     $this->view->order = $order;
     $this->view->counter = $counter;
     $this->view->pagination_params = $params;
 }
예제 #2
0
 public function init()
 {
     //Generate Item Combo
     $item_pack_size = new Model_ItemPackSizes();
     $item_pack_size->form_values['item_category'] = '1';
     $result = $item_pack_size->getAllProducts();
     $this->_list["item_pack_size_id"][''] = "Select Product";
     if ($result) {
         foreach ($result as $row) {
             $this->_list["item_pack_size_id"][$row['pkId']] = $row['itemName'];
         }
     }
     foreach ($this->_hidden as $col => $name) {
         switch ($col) {
             case "vvm_type_id":
                 $this->addElement("hidden", $col);
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             default:
                 break;
         }
     }
     foreach ($this->_fields as $col => $name) {
         switch ($col) {
             case "vvm_type_name":
                 $this->addElement("text", $col, array("attribs" => array("class" => "form-control"), "allowEmpty" => false, "filters" => array("StringTrim", "StripTags"), "validators" => array()));
                 $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
                 break;
             default:
                 break;
         }
         if (in_array($col, array_keys($this->_list))) {
             $this->addElement("select", $col, array("attribs" => array("class" => "form-control"), "filters" => array("StringTrim", "StripTags"), "allowEmpty" => true, "required" => false, "registerInArrayValidator" => false, "multiOptions" => $this->_list[$col], "validators" => array(array("validator" => "Float", "breakChainOnFailure" => false, "options" => array("messages" => array("notFloat" => $name . " must be a valid option"))))));
             $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
         }
         if (in_array($col, array_keys($this->_radio))) {
             $this->addElement("radio", $col, array("attribs" => array(), "allowEmpty" => true, 'separator' => '', "filters" => array("StringTrim", "StripTags"), "validators" => array(), "multiOptions" => $this->_radio[$col]));
             $this->getElement($col)->removeDecorator("Label")->removeDecorator("HtmlTag");
         }
     }
 }