Ejemplo n.º 1
0
 public function empaddorremoveleaves($empleavesform, $userid, $used_leaves, $leavetransfercount, $isleavetrasnferset, $currentyearleavecount)
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     if ($empleavesform->isValid($this->_request->getPost())) {
         $employeeleavesModel = new Default_Model_Employeeleaves();
         $id = $this->_request->getParam('id');
         //Id hidden field in form....
         $user_id = $userid;
         $emp_leave_limit = $this->_request->getParam('leave_limit');
         if ($leavetransfercount != '' && $currentyearleavecount == '') {
             $emp_leave_limit = $emp_leave_limit + $leavetransfercount;
         } else {
             $emp_leave_limit = $emp_leave_limit + $currentyearleavecount;
         }
         $isleavetrasnfer = 0;
         if ($isleavetrasnferset == 1) {
             $isleavetrasnfer = 1;
         }
         $date = new Zend_Date();
         $menumodel = new Default_Model_Menu();
         $actionflag = '';
         $tableid = '';
         $Id = $employeeleavesModel->SaveorUpdateEmployeeLeaves($user_id, $emp_leave_limit, $isleavetrasnfer, $loginUserId);
         if ($id) {
             $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Employee Leave details updated successfully."));
             $actionflag = 2;
             $tableid = $id;
         } else {
             $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Employee Leave details added successfully."));
             $actionflag = 1;
             $tableid = $Id;
         }
         $menuidArr = $menumodel->getMenuObjID('/employee');
         $menuID = $menuidArr[0]['id'];
         $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid);
         $this->_redirect('mydetails/leaves/');
     } else {
         $messages = $empleavesform->getMessages();
         foreach ($messages as $key => $val) {
             foreach ($val as $key2 => $val2) {
                 $msgarray[$key] = $val2;
                 break;
             }
         }
         return $msgarray;
     }
 }
Ejemplo n.º 2
0
 public function viewpopupAction()
 {
     Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/");
     $id = $this->getRequest()->getParam('id');
     if ($id == '') {
         $id = $loginUserId;
     }
     $callval = $this->getRequest()->getParam('call');
     if ($callval == 'ajaxcall') {
         $this->_helper->layout->disableLayout();
     }
     $objName = 'empleaves';
     $empleavesform = new Default_Form_empleaves();
     $employeeleavesModal = new Default_Model_Employeeleaves();
     $leavemanagementModel = new Default_Model_Leavemanagement();
     $empleavesform->removeElement("submit");
     $elements = $empleavesform->getElements();
     if (count($elements) > 0) {
         foreach ($elements as $key => $element) {
             if ($key != "Cancel" && $key != "Edit" && $key != "Delete" && $key != "Attachments") {
                 $element->setAttrib("disabled", "disabled");
             }
         }
     }
     $data = $employeeleavesModal->getsingleEmpleavesrow($id);
     if (!empty($data)) {
         $leaveTypeCount = $leavemanagementModel->getEmployeeUsedLeavesName($data['user_id'], $data['alloted_year']);
     }
     if (!empty($data)) {
         $empleavesform->populate($data);
         $empleavesform->leave_limit->setValue($data['emp_leave_limit']);
     }
     $this->view->controllername = $objName;
     $this->view->leaveTypeCount = $leaveTypeCount;
     $this->view->id = $id;
     $this->view->form = $empleavesform;
 }
 public function viewAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
         $loginuserbusinessunit_id = $auth->getStorage()->read()->businessunit_id;
     }
     $objName = 'addemployeeleaves';
     $id = $this->getRequest()->getParam('id');
     $msgarray = array();
     $callval = $this->getRequest()->getParam('call');
     if ($callval == 'ajaxcall') {
         $this->_helper->layout->disableLayout();
     }
     try {
         if ($id && is_numeric($id) && $id > 0) {
             $addemployeeleavesModel = new Default_Model_Addemployeeleaves();
             $addEmpLeavesForm = new Default_Form_addemployeeleaves();
             $employeeleavesModel = new Default_Model_Employeeleaves();
             $empModel = new Default_Model_Employee();
             $currentYearData = $employeeleavesModel->getsingleEmployeeleaveData($id);
             $permission = sapp_Global::_checkprivileges(176, $loginuserGroup, $loginuserRole, 'edit');
             $this->view->editpermission = $permission;
             $empDetails = $empModel->getEmp_from_summary($id);
             if (!empty($empDetails)) {
                 $addEmpLeavesForm->businessunit_id->setValue($empDetails['businessunit_id']);
                 $addEmpLeavesForm->department_id->setValue($empDetails['department_id']);
                 $addEmpLeavesForm->user_id->setValue($empDetails['user_id']);
                 $addEmpLeavesForm->leave_limit->setAttrib("disabled", "disabled");
                 if (!empty($currentYearData)) {
                     $addEmpLeavesForm->leave_limit->setValue($currentYearData[0]['emp_leave_limit']);
                 }
                 $addEmpLeavesForm->alloted_year->setValue(date('Y'));
                 $this->view->form = $addEmpLeavesForm;
                 $this->view->empdetails = $empDetails;
                 $this->view->msgarray = $msgarray;
                 $this->view->ermsg = '';
                 $this->view->controllername = $objName;
                 $this->view->id = $id;
             } else {
                 $this->view->ermsg = "norows";
             }
         } else {
             $this->view->ermsg = "norows";
         }
     } catch (Exception $e) {
         $this->view->ermsg = "norows";
     }
 }