public function viewAction()
 {
     if (defined('EMPTABCONFIGS')) {
         $empOrganizationTabs = explode(",", EMPTABCONFIGS);
         if (in_array('emp_salary', $empOrganizationTabs)) {
             $auth = Zend_Auth::getInstance();
             if ($auth->hasIdentity()) {
                 $loginUserId = $auth->getStorage()->read()->id;
             }
             $id = $this->getRequest()->getParam('userid');
             if ($id == '') {
                 $id = $loginUserId;
             }
             $callval = $this->getRequest()->getParam('call');
             if ($callval == 'ajaxcall') {
                 $this->_helper->layout->disableLayout();
             }
             $objName = 'empsalarydetails';
             $empsalarydetailsform = new Default_Form_empsalarydetails();
             $empsalarydetailsform->removeElement("submit");
             $elements = $empsalarydetailsform->getElements();
             if (count($elements) > 0) {
                 foreach ($elements as $key => $element) {
                     if ($key != "Cancel" && $key != "Edit" && $key != "Delete" && $key != "Attachments") {
                         $element->setAttrib("disabled", "disabled");
                     }
                 }
             }
             try {
                 if ($id && is_numeric($id) && $id > 0 && $id != $loginUserId) {
                     $employeeModal = new Default_Model_Employee();
                     $empdata = $employeeModal->getsingleEmployeeData($id);
                     if ($empdata == 'norows') {
                         $this->view->rowexist = "norows";
                         $this->view->empdata = "";
                     } else {
                         $this->view->rowexist = "rows";
                         if (!empty($empdata)) {
                             $empsalarydetailsModal = new Default_Model_Empsalarydetails();
                             $usersModel = new Default_Model_Users();
                             $currencymodel = new Default_Model_Currency();
                             $accountclasstypemodel = new Default_Model_Accountclasstype();
                             $bankaccounttypemodel = new Default_Model_Bankaccounttype();
                             $data = $empsalarydetailsModal->getsingleEmpSalaryDetailsData($id);
                             if (!empty($data)) {
                                 if (isset($data[0]['currencyid']) && $data[0]['currencyid'] != '') {
                                     $currencyArr = $currencymodel->getCurrencyDataByID($data[0]['currencyid']);
                                     if (sizeof($currencyArr) > 0) {
                                         $empsalarydetailsform->currencyid->addMultiOption($currencyArr[0]['id'], $currencyArr[0]['currencyname'] . ' ' . $currencyArr[0]['currencycode']);
                                     }
                                 }
                                 if (isset($data[0]['accountclasstypeid']) && $data[0]['accountclasstypeid'] != '') {
                                     $accountclasstypeArr = $accountclasstypemodel->getsingleAccountClassTypeData($data[0]['accountclasstypeid']);
                                     if (sizeof($accountclasstypeArr) > 0) {
                                         $empsalarydetailsform->accountclasstypeid->addMultiOption($accountclasstypeArr[0]['id'], $accountclasstypeArr[0]['accountclasstype']);
                                     }
                                 }
                                 if (isset($data[0]['bankaccountid']) && $data[0]['bankaccountid'] != '') {
                                     $bankaccounttypeArr = $bankaccounttypemodel->getsingleBankAccountData($data[0]['bankaccountid']);
                                     if ($bankaccounttypeArr != 'norows') {
                                         $empsalarydetailsform->bankaccountid->addMultiOption($bankaccounttypeArr[0]['id'], $bankaccounttypeArr[0]['bankaccounttype']);
                                     }
                                 }
                                 $empsalarydetailsform->populate($data[0]);
                                 if ($data[0]['accountholding'] != '') {
                                     $accountholding = sapp_Global::change_date($data[0]["accountholding"], 'view');
                                     $empsalarydetailsform->accountholding->setValue($accountholding);
                                 }
                             }
                             $this->view->controllername = $objName;
                             $this->view->data = $data;
                             $this->view->id = $id;
                             $this->view->form = $empsalarydetailsform;
                             $this->view->employeedata = $empdata[0];
                         }
                         $this->view->empdata = $empdata;
                     }
                 } else {
                     $this->view->rowexist = "norows";
                 }
             } catch (Exception $e) {
                 $this->view->rowexist = "norows";
             }
         } else {
             $this->_redirect('error');
         }
     } else {
         $this->_redirect('error');
     }
 }
Пример #2
0
 public function configuresiteAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $popConfigPermission = array();
     $msgarray = array();
     $wizardpreferenceform = new Default_Form_wizardpreference();
     $dateformatidmodel = new Default_Model_Dateformat();
     $timeformatidmodel = new Default_Model_Timeformat();
     $currencyidmodel = new Default_Model_Currency();
     $systempreferencemodel = new Default_Model_Sitepreference();
     $orginfomodel = new Default_Model_Organisationinfo();
     $identitycodesmodel = new Default_Model_Identitycodes();
     $employmentstatusmodel = new Default_Model_Employmentstatus();
     $statesmodel = new Default_Model_States();
     $citiesmodel = new Default_Model_Cities();
     $date_formats_arr = array();
     $time_formats_arr = array();
     $passworddataArr = array();
     $currencynameArr = array();
     $countryId = '';
     $stateId = '';
     $cityId = '';
     $new_stateId = '';
     $new_cityId = '';
     $empstatusids = '';
     $timezonemodel = new Default_Model_Timezone();
     $wizard_model = new Default_Model_Wizard();
     $wizardData = $wizard_model->getWizardData();
     /* START
      * Queries to check whether the configuration are already set.
      * If set then prepopulate the fields
      */
     $sitepreferencedata = $systempreferencemodel->SitePreferanceData();
     $orginfodata = $orginfomodel->getOrganisationInfo();
     $empstatusdata = $employmentstatusmodel->getEmploymentStatuslist();
     $identitycodedata = $identitycodesmodel->getIdentitycodesRecord();
     /*
      * END - Checking configuration is set or not.
      */
     $allTimezoneData = $timezonemodel->fetchAll('isactive=1', 'timezone')->toArray();
     if (sapp_Global::_checkprivileges(CURRENCY, $loginuserGroup, $loginuserRole, 'add') == 'Yes') {
         array_push($popConfigPermission, 'currency');
     }
     if (sapp_Global::_checkprivileges(TIMEZONE, $loginuserGroup, $loginuserRole, 'add') == 'Yes') {
         array_push($popConfigPermission, 'timezone');
     }
     try {
         if (!empty($orginfodata)) {
             $countryId = isset($orginfodata[0]['country']) ? $orginfodata[0]['country'] : "";
             $stateId = isset($orginfodata[0]['state']) ? $orginfodata[0]['state'] : "";
             $cityId = isset($orginfodata[0]['city']) ? $orginfodata[0]['city'] : "";
             $wizardpreferenceform->organisationid->setValue($orginfodata[0]['id']);
         } else {
             if (isset($wizardData['country']) && $wizardData['country'] != 'null') {
                 $countryId = $wizardData['country'];
             }
             if (isset($wizardData['state']) && $wizardData['state'] != 'null') {
                 $stateId = $wizardData['state'];
             }
             if (isset($wizardData['city']) && $wizardData['city'] != 'null') {
                 $cityId = $wizardData['city'];
             }
         }
         if (count($_POST) > 0) {
             $countryId = isset($_POST['perm_country']) ? $_POST['perm_country'] : "";
             $stateId = isset($_POST['perm_state']) ? $_POST['perm_state'] : "";
             $cityId = isset($_POST['perm_city']) ? $_POST['perm_city'] : "";
         }
         $date_formats_arr = $dateformatidmodel->getAllDateFormats();
         $time_formats_arr = $timeformatidmodel->fetchAll()->toArray();
         $defaultempstatusdata = $employmentstatusmodel->getCompleteStatuslist();
         $wizardpreferenceform->passwordid->addMultiOption('', 'Select Password Preference');
         $passworddataArr = $systempreferencemodel->getPasswordData();
         foreach ($passworddataArr as $passwordres) {
             $wizardpreferenceform->passwordid->addMultiOption($passwordres['id'], utf8_encode($passwordres['passwordtype']));
         }
         if (sizeof($allTimezoneData) > 0) {
             foreach ($allTimezoneData as $timezoneidres) {
                 $wizardpreferenceform->timezoneid->addMultiOption($timezoneidres['id'], utf8_encode($timezoneidres['timezone'] . ' [' . $timezoneidres['timezone_abbr'] . ']'));
             }
         } else {
             $msgarray['timezoneid'] = 'Time Zone is not configured yet.';
         }
         if (sizeof($defaultempstatusdata) > 0) {
             foreach ($defaultempstatusdata as $empstatusres) {
                 $wizardpreferenceform->workcodename->addMultiOption($empstatusres['id'], utf8_encode($empstatusres['employemnt_status']));
             }
         }
         /* Start  
          * To prepopulate the form if already configured
          */
         if (!empty($sitepreferencedata)) {
             if (isset($sitepreferencedata[0]['dateformatid'])) {
                 $wizardpreferenceform->setDefault('dateformatid', $sitepreferencedata[0]['dateformatid']);
             }
             if (isset($sitepreferencedata[0]['timeformatid'])) {
                 $wizardpreferenceform->setDefault('timeformatid', $sitepreferencedata[0]['timeformatid']);
             }
             if (isset($sitepreferencedata[0]['timezoneid'])) {
                 $wizardpreferenceform->setDefault('timezoneid', $sitepreferencedata[0]['timezoneid']);
             }
             if (isset($sitepreferencedata[0]['passwordid'])) {
                 $wizardpreferenceform->setDefault('passwordid', $sitepreferencedata[0]['passwordid']);
             }
             if (isset($sitepreferencedata[0]['currencyid'])) {
                 $wizardpreferenceform->currencyid->setValue($sitepreferencedata[0]['currencyid']);
                 $currencynameArr = $currencyidmodel->getCurrencyDataByID($sitepreferencedata[0]['currencyid']);
             }
             if (!empty($currencynameArr)) {
                 $wizardpreferenceform->currencyname->setValue($currencynameArr[0]['currencyname']);
                 $wizardpreferenceform->currencycode->setValue($currencynameArr[0]['currencycode']);
             }
         }
         if ($countryId != '') {
             $wizardpreferenceform->setDefault('perm_country', $countryId);
             $statesData = $statesmodel->getStatesList((int) $countryId);
             if (!empty($statesData)) {
                 foreach ($statesData as $res) {
                     if ($stateId == $res['id']) {
                         $new_stateId = $res['id'] . '!@#' . utf8_encode($res['state_name']);
                     }
                     $wizardpreferenceform->perm_state->addMultiOption($res['id'] . '!@#' . utf8_encode($res['state_name']), utf8_encode($res['state_name']));
                 }
                 if (count($_POST) == 0) {
                     $stateId = $new_stateId;
                 }
             }
         }
         if ($stateId != '') {
             $wizardpreferenceform->setDefault('perm_state', $stateId);
             $citiesData = $citiesmodel->getCitiesList((int) $stateId);
             foreach ($citiesData as $res) {
                 if ($cityId == $res['id']) {
                     $new_cityId = $res['id'] . '!@#' . utf8_encode($res['city_name']);
                 }
                 $wizardpreferenceform->perm_city->addMultiOption($res['id'] . '!@#' . utf8_encode($res['city_name']), utf8_encode($res['city_name']));
             }
             if (count($_POST) == 0) {
                 $cityId = $new_cityId;
             }
         }
         if ($cityId != '') {
             $wizardpreferenceform->setDefault('perm_city', $cityId);
         }
         if (!empty($identitycodedata)) {
             $wizardpreferenceform->empcodeid->setValue($identitycodedata[0]['id']);
             $wizardpreferenceform->employee_code->setValue($identitycodedata[0]['employee_code']);
         }
         if (sizeof($empstatusdata) > 0) {
             foreach ($empstatusdata as $empstats) {
                 $empstatusids .= $empstats['workcodename'] . ',';
             }
             $empstatusids = rtrim($empstatusids, ',');
         }
         /*
          * End - Prepopulating data
          */
         $wizardpreferenceform->setAttrib('action', DOMAIN . 'wizard/configuresite');
         $this->view->msgarray = $msgarray;
     } catch (Exception $e) {
         $this->view->nodata = "nodata";
     }
     $this->view->form = $wizardpreferenceform;
     $this->view->date_formats_arr = $date_formats_arr;
     $this->view->time_formats_arr = $time_formats_arr;
     $this->view->passworddata = $passworddataArr;
     $this->view->empstatusids = $empstatusids;
     if ($this->getRequest()->getPost()) {
         $result = $this->savesitepreference($wizardpreferenceform, $wizardData);
         $this->view->msgarray = $result;
     }
     $this->view->popConfigPermission = $popConfigPermission;
     $this->view->wizarddata = $wizardData;
     $this->view->messages = $this->_helper->flashMessenger->getMessages();
 }
Пример #3
0
 public function deleteAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $id = $this->_request->getParam('objid');
     $messages['message'] = '';
     $messages['msgtype'] = '';
     $actionflag = 3;
     if ($id) {
         $currencymodel = new Default_Model_Currency();
         $menumodel = new Default_Model_Menu();
         $currencydata = $currencymodel->getCurrencyDataByID($id);
         $data = array('isactive' => 0, 'modifieddate' => gmdate("Y-m-d H:i:s"));
         $where = array('id=?' => $id);
         $Id = $currencymodel->SaveorUpdateCurrencyData($data, $where);
         if ($Id == 'update') {
             $menuidArr = $menumodel->getMenuObjID('/currency');
             $menuID = $menuidArr[0]['id'];
             $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $id);
             $configmail = sapp_Global::send_configuration_mail('Currency', $currencydata[0]['currencyname']);
             $messages['message'] = 'Currency deleted successfully.';
             $messages['msgtype'] = 'success';
         } else {
             $messages['message'] = 'Currency cannot be deleted.';
             $messages['msgtype'] = 'error';
         }
     } else {
         $messages['message'] = 'Currency cannot be deleted.';
         $messages['msgtype'] = 'error';
     }
     $this->_helper->json($messages);
 }