public function init() { $this->setName('frmUserLeaveAccount'); $this->addElement('select', 'transactionType', array('label' => 'Transaction Type:', 'class' => 'text-input small-input', 'required' => true, 'decorators' => $this->elementDecorators, 'MultiOptions' => array('credit' => "Credit", 'debit' => "Debit"))); $model = new Application_Model_LeaveType(); $arrDesignation = $model->getLeaveTypes(); $this->addElement('select', 'leaveTypeId', array('label' => 'Leave Type:', 'id' => 'leaveTypeId', 'style' => 'width:193px', 'class' => 'text-input small-input', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select leave type.')))), 'decorators' => $this->elementDecorators, 'filtcoratoers' => array('StringTrim'), 'MultiOptions' => $arrDesignation)); $this->addElement('text', 'value', array('label' => 'Value:', 'autocomplete' => "off", 'class' => 'text-input small-input', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'You must enter number of leaves debit/credit'))), array('Float', false, array('messages' => 'Please enter float value'))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'))); $this->addElement('textarea', 'narration', array('label' => 'Narration:', 'class' => 'text-input textarea address', 'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please enter narration!')))), 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'))); $this->addElement('submit', 'submit', array('required' => false, 'class' => 'button', 'ignore' => true, 'label' => 'Submit', 'value' => 'submit', 'decorators' => $this->buttonDecorators)); }
public function editLeaveTypeAction() { $id = $this->_getParam('id'); $this->view->user_id = $id; $model1 = new Application_Model_LeaveType(); $model = $model1->find($id); if (false === $model) { $this->_flashMessenger->addMessage(array('error' => 'Invalid request! Please try again.')); $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/hr/leave-types')); } $options['title'] = $model->getTitle(); $options['code'] = $model->getCode(); $options['totalLeavesInYear'] = $model->getTotalLeavesInYear(); $request = $this->getRequest(); $form = new Application_Form_LeaveType(); $form->populate($options); $options = $request->getPost(); if ($request->isPost()) { if ($options['title'] == $model->getTitle()) { $form->getElement('title')->removeValidator("Db_NoRecordExists"); } if ($options['code'] == $model->getCode()) { $form->getElement('code')->removeValidator("Db_NoRecordExists"); } if ($form->isValid($options)) { $model->setOptions($options); $model->save(); $this->_flashMessenger->addMessage(array('success' => 'Leave type has been updated successfully!')); $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/hr/edit-leave-type/id/' . $id)); } else { $this->_flashMessenger->addMessage(array('error' => 'Unable to save the data. Please provide valid inputs and try again.')); $form->reset(); $form->populate($options); } } $this->view->form = $form; }
public function getLeaveTypes() { $obj = new Application_Model_LeaveType(); $entries = $obj->fetchAll(); $arrUserLevel = array(); foreach ($entries as $entry) { $arrUserLevel[$entry->getId()] = $entry->getTitle() . " [ " . $entry->getCode() . " ]"; } return $arrUserLevel; }