Esempio n. 1
0
 function edit(Default_Model_Expenses $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(Zend_Registry::get('translate')->_('admin_date'));
     $productGroups = new Default_Model_ProductGroups();
     $select = $productGroups->getMapper()->getDbTable()->select()->where('idProduct=?', $model->getId());
     $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_expense'));
 }
Esempio n. 2
0
 public function save(Default_Model_Expenses $value)
 {
     $data = array('idMember' => Zend_Registry::get('user')->getId(), 'name' => $value->getName(), 'price' => $value->getPrice(), 'date' => $value->getDate(), 'type' => $value->getType(), 'deleted' => '0');
     $action_done = '';
     if (null === ($id = $value->getId())) {
         $data['created'] = new Zend_Db_Expr('NOW()');
         $id = $this->getDbTable()->insert($data);
         //logs	action done
         //$user_name = $value->getUserName()->getName().' '.$value->getUserName()->getSurname();
         $user_name = "User";
         $product_name = $value->getName();
         $action_done = ' ' . $user_name . ' a adaugat cheltuiala ' . $product_name . ' ';
         //$value->getIdUser() adaugat in baza de date ca 0
         Needs_Logs::DbLogTracking(Zend_Registry::get('user')->getId(), $id, 'products', 'adaugare', $action_done);
         //end logs action done
     } else {
         $data['modified'] = new Zend_Db_Expr('NOW()');
         $this->getDbTable()->update($data, array('id = ?' => $id));
         //logs	action done
         //$user_name = $value->getUserName()->getName().' '.$value->getUserName()->getSurname();
         $product_name = $value->getName();
         $user_name = "User";
         $action_done = '' . $user_name . ' a modificat cheltuiala ' . $product_name . ' ';
         Needs_Logs::DbLogTracking(Zend_Registry::get('user')->getId(), $id, 'products', 'editare', $action_done);
         //end logs action done
     }
     return $id;
 }