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 function deleteAction() { $userId = NULL; $auth = Zend_Auth::getInstance(); $authAccount = $auth->getStorage()->read(); if (null != $authAccount) { if (null != $authAccount->getId()) { $userId = $authAccount->getId(); } } $id = $this->getRequest()->getParam('id'); $model = new Default_Model_RecurrentExpenses(); if ($model->find($id)) { if ($expenseId = $model->delete()) { //Needs_Tools::DeleteLegaturi( $expenseId ); $this->_flashMessenger->addMessage("<div class='success canhide'><p>Recurrent expense was deleted successfully!<a href='javascript:;'></a></p></div>"); } else { $this->_flashMessenger->addMessage("<div class='failure canhide'><p>Recurrent expense was not deleted!<a href='javascript:;'></a></p></div>"); } $this->_redirect('recurrent-expenses'); } }
public static function showRecurrentIncomeDashboardbyDate($from = '', $to = '') { $resultInfo = array(); $idUser = Zend_Registry::get('user')->getId(); $expenses = new Default_Model_RecurrentExpenses(); $select = $expenses->getMapper()->getDbTable()->select()->from(array('p' => 'recurrent_expenses'), array('price' => 'SUM(p.price)'))->where('NOT p.deleted')->where('p.idMember = ? ', $idUser)->where('p.type=?', 1); if ($from != '') { $select->where('p.date>=?', date('Y-m-d', strtotime($from))); } if ($to != '') { $select->where('p.date<=?', date('Y-m-d', strtotime($to))); } $result = $expenses->fetchRow($select); $amount = $result->getPrice(); return $amount; }
public function delete(Default_Model_RecurrentExpenses $value) { $id = $value->getId(); $data = array('deleted' => '1'); $this->getDbTable()->update($data, array('id = ?' => $id)); //logs action done //$user_name = $value->getUserName()->getName().' '.$value->getUserName()->getSurname(); $product_name = $value->getName(); $action_done = ' User deleted the expense ' . $product_name . ' '; Needs_Logs::DbLogTracking(0, $id, 'expenses', 'stergere', $action_done); //end logs action done return $id; }
public function saveRecurrentexpenseincomePriceAction() { $return = ''; $id = (int) $this->getRequest()->getParam('id'); if ($id) { $post = $this->getRequest()->getPost(); $model = new Default_Model_RecurrentExpenses(); $model->find($id); $model->setPrice($post['update_value']); if ($model->save()) { $return = $post['update_value']; } else { $return = "Error modifying value"; } } echo number_format($return, 2); }