public function editProductsAction() { $productsString = $this->getRequest()->getParam('products'); $idGroup = $this->getRequest()->getParam('id'); $products = explode(',', $productsString); foreach ($products as $key => $idProductGroups) { //all products that need to be in the table $modelGroup = new Default_Model_ProductGroups(); $modelGroup->setIdProduct($idProductGroups); $modelGroup->setIdGroup($idGroup); $modelGroupFind = new Default_Model_ProductGroups(); $selectFind = $modelGroupFind->getMapper()->getDbTable()->select()->where('idProduct = ?', $idProductGroups)->where('idGroup = ?', $idGroup); $modelGroupFind->fetchRow($selectFind); if ($modelGroupFind->getId() == NULL) { //existing product added in the database $modelGroup->setOrder($key); $modelGroup->save(); } } }
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')); }
public static function DeleteLegaturibyGroup($groupId) { $productGroups = new Default_Model_ProductGroups(); $where = $productGroups->getMapper()->getDbTable()->getAdapter()->quoteInto('idGroup = ?', $groupId); return $productGroups->getMapper()->getDbTable()->delete($where); }