/**
  * 
  * Show analytics of employees reporting to manager 
  */
 public function employeereportAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     if ($loginuserGroup == MANAGER_GROUP || $loginuserGroup == MANAGEMENT_GROUP || $loginuserRole == SUPERADMINROLE) {
         $norec_arr = array();
         $form = new Default_Form_Employeereport();
         $requi_model = new Default_Model_Requisition();
         $employmentstatusModel = new Default_Model_Employmentstatus();
         $role_model = new Default_Model_Roles();
         $departmentsmodel = new Default_Model_Departments();
         $bu_model = new Default_Model_Businessunits();
         $roles_arr = $role_model->getRolesList_EMP();
         $job_data = $requi_model->getJobTitleList();
         $employmentStatusData = $employmentstatusModel->getempstatuslist();
         if (count($job_data) == 0) {
             $norec_arr['jobtitle_id'] = "Job titles are not configured yet.";
             $norec_arr['position_id'] = "Positions are not configured yet.";
         }
         if (count($employmentStatusData) == 0) {
             $norec_arr['emp_status_id'] = "Employment status is not configured yet.";
         }
         $form->jobtitle_id->addMultiOptions(array('' => 'Select Job Title') + $job_data);
         if (count($employmentStatusData) > 0) {
             $form->emp_status_id->addMultiOption('', 'Select Employment Status');
             foreach ($employmentStatusData as $employmentStatusres) {
                 $form->emp_status_id->addMultiOption($employmentStatusres['workcodename'], $employmentStatusres['statusname']);
             }
         }
         if (sizeof($roles_arr) > 0) {
             $form->emprole->addMultiOptions(array('' => 'Select Role') + $roles_arr);
         } else {
             $norec_arr['emprole'] = 'Roles are not added yet.';
         }
         $bu_arr = $bu_model->getBU_report();
         if (!empty($bu_arr)) {
             foreach ($bu_arr as $bu) {
                 $form->businessunit_id->addMultiOption($bu['id'], utf8_encode($bu['bu_name']));
             }
         } else {
             $norec_arr['businessunit_id'] = 'Business Units are not added yet.';
         }
         // Show count of employees reporting to manager
         // Get employees data reporting to manager
         $myEmployees_model = new Default_Model_Myemployees();
         $employee_model = new Default_Model_Employee();
         //$this->_helper->layout->setLayout("analyticslayout");
         $this->view->count_emp_reporting = $employee_model->getCountEmpReporting($myEmployees_model->getLoginUserId());
         $this->view->form = $form;
         $this->view->messages = $norec_arr;
         $this->view->ermsg = '';
     } else {
         $this->render('error/error.phtml');
     }
 }
 public function editAction()
 {
     $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;
     }
     $id = $this->getRequest()->getParam('id');
     $callval = $this->getRequest()->getParam('call');
     if ($callval == 'ajaxcall') {
         $this->_helper->layout->disableLayout();
     }
     $announcementsForm = new Default_Form_Announcements();
     $announcementsModel = new Default_Model_Announcements();
     try {
         if ($id) {
             if (is_numeric($id) && $id > 0) {
                 $data = $announcementsModel->getAnnouncementsDatabyID($id);
                 if (isset($data[0]['status']) && $data[0]['status'] == 1 || $loginuserRole == SUPERADMINROLE || $loginuserGroup == HR_GROUP || $loginuserGroup == MANAGEMENT_GROUP) {
                     $bu_model = new Default_Model_Businessunits();
                     $bu_arr = $bu_model->getBU_report();
                     if (!empty($bu_arr)) {
                         foreach ($bu_arr as $bu) {
                             if ($loginuserGroup == HR_GROUP && $bu['id'] == $loginuserbusinessunit_id) {
                                 $announcementsForm->businessunit_id->addMultiOption($bu['id'], utf8_encode($bu['bu_name']));
                             }
                             if ($loginuserGroup != HR_GROUP) {
                                 $announcementsForm->businessunit_id->addMultiOption($bu['id'], utf8_encode($bu['bu_name']));
                             }
                         }
                     }
                     $dept_model = new Default_Model_Departments();
                     $dept_data = $dept_model->getDepartmentWithCodeList_bu($data[0]['businessunit_id']);
                     if (!empty($dept_data)) {
                         foreach ($dept_data as $dept) {
                             $announcementsForm->department_id->addMultiOption($dept['id'], $dept['unitcode'] . " " . $dept['deptname']);
                         }
                     }
                     if (!empty($data)) {
                         $data = $data[0];
                         $announcementsForm->populate($data);
                         $announcementsForm->post_description->setValue($data['description']);
                         $announcementsForm->businessunit_id->setValue(explode(',', $data['businessunit_id']));
                         if ($data['department_id']) {
                             $announcementsForm->department_id->setValue(explode(',', $data['department_id']));
                         }
                         $announcementsForm->setAttrib('action', BASE_URL . 'announcements/edit/id/' . $id);
                         if ($data['attachments']) {
                             $new = array();
                             $ori = array();
                             $attachments = json_decode($data['attachments'], true);
                             foreach ($attachments as $k => $v) {
                                 $new[] = $v["new_name"];
                                 $ori[] = $v["original_name"];
                             }
                             $msg['file_original_names'] = implode(',', $ori);
                             $msg['file_new_names'] = implode(',', $new);
                             $this->view->msgarray = $msg;
                         }
                         $this->view->data = $data;
                     } else {
                         $this->view->ermsg = 'norecord';
                     }
                 } else {
                     $this->_redirect('announcements');
                 }
             } else {
                 $this->view->ermsg = 'norecord';
             }
         } else {
             $this->view->ermsg = '';
         }
     } catch (Exception $e) {
         $this->view->ermsg = 'nodata';
     }
     $this->view->form = $announcementsForm;
     if ($this->getRequest()->getPost()) {
         $result = $this->save($announcementsForm);
         $this->view->msgarray = $result;
     }
     $this->render('form');
 }
 public function employeereportAction()
 {
     $norec_arr = array();
     $form = new Default_Form_Employeereport();
     $requi_model = new Default_Model_Requisition();
     $employmentstatusModel = new Default_Model_Employmentstatus();
     $role_model = new Default_Model_Roles();
     $departmentsmodel = new Default_Model_Departments();
     $bu_model = new Default_Model_Businessunits();
     $roles_arr = $role_model->getRolesList_EMP();
     $job_data = $requi_model->getJobTitleList();
     $employmentStatusData = $employmentstatusModel->getempstatuslist();
     if (count($job_data) == 0) {
         $norec_arr['jobtitle_id'] = "Job titles are not configured yet.";
         $norec_arr['position_id'] = "Positions are not configured yet.";
     }
     if (count($employmentStatusData) == 0) {
         $norec_arr['emp_status_id'] = "Employment status is not configured yet.";
     }
     $form->jobtitle_id->addMultiOptions(array('' => 'Select Job Title') + $job_data);
     if (count($employmentStatusData) > 0) {
         $form->emp_status_id->addMultiOption('', 'Select Employment Status');
         foreach ($employmentStatusData as $employmentStatusres) {
             $form->emp_status_id->addMultiOption($employmentStatusres['workcodename'], $employmentStatusres['statusname']);
         }
     }
     if (sizeof($roles_arr) > 0) {
         $form->emprole->addMultiOptions(array('' => 'Select Role') + $roles_arr);
     } else {
         $norec_arr['emprole'] = 'Roles are not added yet.';
     }
     $bu_arr = $bu_model->getBU_report();
     if (!empty($bu_arr)) {
         foreach ($bu_arr as $bu) {
             $form->businessunit_id->addMultiOption($bu['id'], utf8_encode($bu['bu_name']));
         }
     } else {
         $norec_arr['businessunit_id'] = 'Business Units are not added yet.';
     }
     $this->view->form = $form;
     $this->view->messages = $norec_arr;
 }
 public function addAction()
 {
     $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;
     }
     $msgarray = array();
     $callval = $this->getRequest()->getParam('call');
     if ($callval == 'ajaxcall') {
         $this->_helper->layout->disableLayout();
     }
     $addEmpLeavesForm = new Default_Form_addemployeeleaves();
     $bu_model = new Default_Model_Businessunits();
     $bu_arr = $bu_model->getBU_report();
     if (!empty($bu_arr)) {
         foreach ($bu_arr as $bu) {
             $addEmpLeavesForm->businessunit_id->addMultiOption($bu['id'], utf8_encode($bu['bu_name']));
         }
     } else {
         $msgarray['businessunit_id'] = 'Business Units are not added yet.';
     }
     $addEmpLeavesForm->alloted_year->setValue(date('Y'));
     $addEmpLeavesForm->setAttrib('action', BASE_URL . 'addemployeeleaves/add');
     $this->view->form = $addEmpLeavesForm;
     $this->view->msgarray = $msgarray;
     $this->view->ermsg = '';
     if ($this->getRequest()->getPost()) {
         $result = $this->saveEmployeeLeaves($addEmpLeavesForm, $loginUserId);
         $this->view->msgarray = $result;
     }
 }