Exemplo n.º 1
0
 public function saveProductsOrderAction()
 {
     $ordersString = $this->getRequest()->getParam('order');
     $idGroup = $this->getRequest()->getParam('id');
     $products = explode(',', $ordersString);
     $arrayAll = array();
     //Needs_Tools::DeleteLegaturibyGroup( $groupId );
     $modelGroupAll = new Default_Model_ProductGroups();
     $selectAll = $modelGroupAll->getMapper()->getDbTable()->select()->where('idGroup = ?', $idGroup);
     $resultsAll = $modelGroupAll->fetchAll($selectAll);
     foreach ($resultsAll as $value) {
         $arrayAll[] = $value->getIdProduct();
         //all the products that are currently in the table
     }
     $resultDiff = array_diff($arrayAll, $products);
     foreach ($resultDiff as $deleteProd) {
         Needs_Tools::DeleteLegaturi($deleteProd);
         //here we delete the prods that were before in the table, but are not anymore in the new list of prods
     }
     foreach ($products as $key => $value) {
         $model = new Default_Model_ProductGroups();
         $select = $model->getMapper()->getDbTable()->select()->where('idProduct = ?', $value)->where('idGroup = ?', $idGroup);
         $model->fetchRow($select);
         if ($model->getId() != NULL) {
             $id = $model->getId();
             $model->find($id);
             $model->setOrder($key);
             $model->saveOrder();
         }
     }
 }
Exemplo n.º 2
0
 function edit(Default_Model_RecurrentExpenses $model)
 {
     $expenseId = new Zend_Form_Element_Hidden('expenseId');
     $expenseId->setValue($model->getId());
     $this->addElement($expenseId);
     $this->name->setValue($model->getName());
     $this->name->setLabel(Zend_Registry::get('translate')->_('admin_name'));
     $this->price->setValue($model->getPrice());
     $this->price->setLabel(Zend_Registry::get('translate')->_('admin_price'));
     $this->date->setValue(date('m/d/Y', strtotime($model->getDate())));
     $this->date->setLabel('Date');
     $productGroups = new Default_Model_ProductGroups();
     $select = $productGroups->getMapper()->getDbTable()->select()->where('idProduct=?', $model->getId())->where('repeated=?', 1);
     $result = $productGroups->fetchAll($select);
     if (NULL != $result) {
         foreach ($result as $value) {
             $options[$value->getId()] = $value->getIdGroup();
         }
     }
     $this->idGroup->setValue($options);
     $this->idGroup->setLabel(Zend_Registry::get('translate')->_('category'));
     $this->submit->setValue(Zend_Registry::get('translate')->_('admin_edit_recurrent_expense'));
 }