public function editAction() { $orgInfoModel = new Default_Model_Organisationinfo(); $getorgData = $orgInfoModel->getorgrecords(); $popConfigPermission = array(); if (!empty($getorgData)) { $orgdata = ''; $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; $loginUserRole = $auth->getStorage()->read()->emprole; $loginUserGroup = $auth->getStorage()->read()->group_id; } if (sapp_Global::_checkprivileges(TIMEZONE, $loginUserGroup, $loginUserRole, 'add') == 'Yes') { array_push($popConfigPermission, 'timezone'); } if (sapp_Global::_checkprivileges(COUNTRIES, $loginUserGroup, $loginUserRole, 'add') == 'Yes') { array_push($popConfigPermission, 'country'); } if (sapp_Global::_checkprivileges(STATES, $loginUserGroup, $loginUserRole, 'add') == 'Yes') { array_push($popConfigPermission, 'state'); } if (sapp_Global::_checkprivileges(CITIES, $loginUserGroup, $loginUserRole, 'add') == 'Yes') { array_push($popConfigPermission, 'city'); } if (sapp_Global::_checkprivileges(EMPLOYEE, $loginUserGroup, $loginUserRole, 'add') == 'Yes') { array_push($popConfigPermission, 'employee'); } $msgarray = array(); $flag = 'true'; $id = $this->getRequest()->getParam('id'); $callval = $this->getRequest()->getParam('call'); $deptModel = new Default_Model_Departments(); $deptform = new Default_Form_departments(); $statesmodel = new Default_Model_States(); $citiesmodel = new Default_Model_Cities(); $countriesModel = new Default_Model_Countries(); $statesmodel = new Default_Model_States(); $citiesmodel = new Default_Model_Cities(); $timezonemodel = new Default_Model_Timezone(); $businessunitsmodel = new Default_Model_Businessunits(); $orgInfoModel = new Default_Model_Organisationinfo(); $employeeModal = new Default_Model_Employee(); $allTimezoneData = $timezonemodel->fetchAll('isactive=1', 'timezone')->toArray(); $allCountriesData = $countriesModel->fetchAll('isactive=1', 'country')->toArray(); $allStatesData = $statesmodel->fetchAll('isactive=1', 'state')->toArray(); $allCitiesData = $citiesmodel->fetchAll('isactive=1', 'city')->toArray(); $allBusinessunitsData = $businessunitsmodel->fetchAll('isactive=1', 'unitname')->toArray(); $deptData = array(); $deptform->setAttrib('action', DOMAIN . 'departments/edit'); $country = $getorgData[0]['country']; if (isset($_POST['country'])) { $country = $_POST['country']; } $state = $getorgData[0]['state']; if (isset($_POST['state'])) { $state = $_POST['state']; } $city = $getorgData[0]['city']; if (isset($_POST['city'])) { $city = $_POST['city']; } $address = $getorgData[0]['address1']; if (isset($country) && $country != 0 && $country != '') { $deptform->setDefault('country', $country); $statesData = $statesmodel->getBasicStatesList($country); foreach ($statesData as $res) { $deptform->state->addMultiOption($res['state_id_org'], utf8_encode($res['state'])); } if (isset($state) && $state != 0 && $state != '') { $deptform->setDefault('state', $state); } } if (isset($state) && $state != 0 && $state != '') { $citiesData = $citiesmodel->getBasicCitiesList($state); foreach ($citiesData as $res) { $deptform->city->addMultiOption($res['city_org_id'], utf8_encode($res['city'])); } if (isset($city) && $city != 0 && $city != '') { $deptform->setDefault('city', $city); } } if (isset($address) && $address != '') { $deptform->address1->setValue($address); } if (is_numeric($id) && $id > 0) { $data = $deptModel->getSingleDepartmentData($id); if (!empty($data)) { $deptform->setAttrib('action', DOMAIN . 'departments/edit/id/' . $id); $managementUsersData = $deptModel->getDepartmenttHead($data['depthead']); foreach ($managementUsersData as $mgmtdata) { $deptform->depthead->addMultiOption($mgmtdata['user_id'], $mgmtdata['userfullname']); } $deptform->populate($data); $deptform->setDefault('depthead', $data['depthead']); $deptform->submit->setLabel('Update'); $deptform->state->clearMultiOptions(); $deptform->city->clearMultiOptions(); $deptform->state->addMultiOption('', utf8_encode("Select State")); $deptform->city->addMultiOption('', utf8_encode("Select City")); $countryId = $data['country']; if (isset($_POST['country'])) { $countryId = $_POST['country']; } $stateId = $data['state']; if (isset($_POST['state'])) { $stateId = $_POST['state']; } $cityId = $data['city']; if (isset($_POST['city'])) { $cityId = $_POST['city']; } if ($countryId != '') { $statesData = $statesmodel->getBasicStatesList($countryId); foreach ($statesData as $res) { $deptform->state->addMultiOption($res['state_id_org'], utf8_encode($res['state'])); } $deptform->setDefault('country', $countryId); $deptform->setDefault('state', $stateId); } if ($stateId != '') { $citiesData = $citiesmodel->getBasicCitiesList($stateId); foreach ($citiesData as $res) { $deptform->city->addMultiOption($res['city_org_id'], utf8_encode($res['city'])); } $deptform->setDefault('city', $cityId); } if ($data["startdate"] != '') { $st_date = sapp_Global::change_date($data["startdate"], 'view'); $deptform->setDefault('start_date', $st_date); } $this->view->ermsg = ''; $this->view->datarr = $data; } else { $this->view->ermsg = 'nodata'; } } else { if ($id != '') { $this->view->ermsg = 'nodata'; } else { $managementUsersData = $deptModel->getDepartmenttHead(''); foreach ($managementUsersData as $mgmtdata) { $deptform->depthead->addMultiOption($mgmtdata['user_id'], $mgmtdata['userfullname']); } } } $this->view->deptData = sizeof($deptData); $this->view->form = $deptform; if (!empty($allBusinessunitsData) && !empty($allCountriesData) && !empty($allStatesData) && !empty($allCitiesData) && !empty($allTimezoneData)) { $this->view->configuremsg = ''; } else { $this->view->configuremsg = 'notconfigurable'; } if (empty($allCountriesData)) { $msgarray['country'] = 'Countries are not configured yet.'; $flag = 'false'; } if (empty($allStatesData)) { $msgarray['state'] = 'States are not configured yet.'; $flag = 'false'; } if (empty($allCitiesData)) { $msgarray['city'] = 'Cities are not configured yet.'; $flag = 'false'; } if (empty($allBusinessunitsData)) { $msgarray['unitid'] = 'Business units are not added yet.'; $flag = 'false'; } if (empty($allTimezoneData)) { $msgarray['timezone'] = 'Time zones are not configured yet.'; $flag = 'false'; } $this->view->msgarray = $msgarray; if ($this->getRequest()->getPost()) { $deptname = trim($this->_request->getParam('deptname')); $unitid = $this->_request->getParam('unitid'); if ($deptname != '' && $unitid != '') { if (!preg_match('/^[a-zA-Z.\\- ?]+$/', $deptname)) { $msgarray['deptname'] = "Please enter valid department name."; $flag = 'false'; } else { $checkExists = $deptModel->checkExistance($deptname, $unitid, $id); if ($checkExists != 0) { $msgarray['deptname'] = "Department name already exists."; $flag = 'false'; } } } else { $flag = 'false'; } $start_date = $this->_request->getParam('start_date', null); $start_date = sapp_Global::change_date($start_date, 'database'); if ($deptform->isValid($this->_request->getPost()) && $flag == 'true') { $deptname = $this->_request->getParam('deptname'); $deptcode = $this->_request->getParam('deptcode'); $description = $this->_request->getParam('description'); $country = $this->_request->getParam('country'); $state = intval($this->_request->getParam('state')); $city = $this->_request->getParam('city'); $address1 = $this->_request->getParam('address1'); $address2 = $this->_request->getParam('address2'); $address3 = $this->_request->getParam('address3'); $unitid = $this->_request->getParam('unitid'); $timezone = $this->_request->getParam('timezone'); $depthead = $this->_request->getParam('depthead'); $deptcodeExistance = $deptModel->checkCodeDuplicates($deptcode, $id); if (!$deptcodeExistance) { $date = new Zend_Date(); $menumodel = new Default_Model_Menu(); $actionflag = ''; $tableid = ''; $data = array('deptname' => trim($deptname), 'deptcode' => trim($deptcode), 'description' => trim($description), 'startdate' => $start_date != '' ? $start_date : NULL, 'country' => trim($country), 'state' => trim($state), 'city' => trim($city), 'address1' => trim($address1), 'address2' => trim($address2), 'address3' => trim($address3), 'timezone' => trim($timezone), 'unitid' => $unitid, 'depthead' => trim($depthead), 'modifiedby' => $loginUserId, 'modifieddate' => $date->get('yyyy-MM-dd HH:mm:ss')); if ($id != '') { $where = array('id=?' => $id); $actionflag = 2; } else { $data['createdby'] = $loginUserId; $data['createddate'] = $date->get('yyyy-MM-dd HH:mm:ss'); $data['isactive'] = 1; $where = ''; $actionflag = 1; } $Id = $deptModel->SaveorUpdateDepartmentsUnits($data, $where); /* Updating business unit and department for org head*/ $emp_data = array('businessunit_id' => $unitid, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); $emp_where = array('user_id=?' => $depthead); if ($Id == 'update') { $tableid = $id; $emp_data['department_id'] = $id; $this->_helper->getHelper("FlashMessenger")->addMessage("Department updated successfully."); } else { $tableid = $Id; $emp_data['department_id'] = $Id; $this->_helper->getHelper("FlashMessenger")->addMessage("Department added successfully."); } $employeeModal->SaveorUpdateEmployeeData($emp_data, $emp_where); $menuidArr = $menumodel->getMenuObjID('/departments'); $menuID = $menuidArr[0]['id']; $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid); $this->_redirect('departments'); } else { $msgarray['message'] = 'A Department, with the given code, already exists.'; $msgarray['msgtype'] = 'error'; $this->view->messages = $msgarray; } } else { $messages = $deptform->getMessages(); foreach ($messages as $key => $val) { foreach ($val as $key2 => $val2) { $msgarray[$key] = $val2; break; } if (empty($allCountriesData)) { $msgarray['country'] = 'Countries are not configured yet.'; } if (empty($allStatesData)) { $msgarray['state'] = 'States are not configured yet.'; } if (empty($allCitiesData)) { $msgarray['city'] = 'Cities are not configured yet.'; } if (empty($allBusinessunitsData)) { $msgarray['unitid'] = 'Business units are not added yet.'; } if (empty($allTimezoneData)) { $msgarray['timezone'] = 'Time zones are not configured yet.'; } } $this->view->msgarray = $msgarray; } } } else { $orgdata = 'noorgdata'; $this->view->orgdata = $orgdata; } $this->view->popConfigPermission = $popConfigPermission; }
public function editpopupAction() { Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/"); $orgInfoModel = new Default_Model_Organisationinfo(); $getorgData = $orgInfoModel->getorgrecords(); $deptModel = new Default_Model_Departments(); if (!empty($getorgData)) { $orgdata = ''; $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; } $msgarray = array(); $flag = 'true'; $bunitid = $this->getRequest()->getParam('unitId'); $id = intVal($this->getRequest()->getParam('id')); $countriesModel = new Default_Model_Countries(); $statesmodel = new Default_Model_States(); $citiesmodel = new Default_Model_Cities(); $timezonemodel = new Default_Model_Timezone(); $businessunitsmodel = new Default_Model_Businessunits(); $allTimezoneData = $timezonemodel->fetchAll('isactive=1', 'timezone')->toArray(); $allCountriesData = $countriesModel->fetchAll('isactive=1', 'country')->toArray(); $allStatesData = $statesmodel->fetchAll('isactive=1', 'state')->toArray(); $allCitiesData = $citiesmodel->fetchAll('isactive=1', 'city')->toArray(); $allBusinessunitsData = $businessunitsmodel->fetchAll('isactive=1', 'unitname')->toArray(); $deptModel = new Default_Model_Departments(); $deptform = new Default_Form_departments(); $deptform->setAction(BASE_URL . 'departments/editpopup/id/' . $id . '/unitId/' . $bunitid); $country = $getorgData[0]['country']; if (isset($_POST['country'])) { $country = $_POST['country']; } $state = $getorgData[0]['state']; if (isset($_POST['state'])) { $state = $_POST['state']; } $city = $getorgData[0]['city']; if (isset($_POST['city'])) { $city = $_POST['city']; } $address = $getorgData[0]['address1']; //department head data $managementUsersData = $deptModel->getDepartmenttHead(''); foreach ($managementUsersData as $mgmtdata) { $deptform->depthead->addMultiOption($mgmtdata['user_id'], $mgmtdata['userfullname']); } if (isset($country) && $country != 0 && $country != '') { $deptform->setDefault('country', $country); $statesData = $statesmodel->getBasicStatesList($country); foreach ($statesData as $res) { $deptform->state->addMultiOption($res['state_id_org'], utf8_encode($res['state'])); } if (isset($state) && $state != 0 && $state != '') { $deptform->setDefault('state', $state); } } if (isset($state) && $state != 0 && $state != '') { $citiesData = $citiesmodel->getBasicCitiesList($state); foreach ($citiesData as $res) { $deptform->city->addMultiOption($res['city_org_id'], utf8_encode($res['city'])); } if (isset($city) && $city != 0 && $city != '') { $deptform->setDefault('city', $city); } } if (isset($address) && $address != '') { $deptform->address1->setValue($address); } $close = ''; $controllername = 'departments'; $deptData = array(); if ($id) { $data = $deptModel->getSingleDepartmentData($id); if (!empty($data)) { $deptform->populate($data); $deptform->submit->setLabel('Update'); $st_date = sapp_Global::change_date($data['startdate'], 'view'); $deptform->setDefault('start_date', $st_date); $deptform->setDefault('start_date', $st_date); $deptform->state->clearMultiOptions(); $deptform->city->clearMultiOptions(); $countryId = $data['country']; if (isset($_POST['country'])) { $countryId = $_POST['country']; } $stateId = $data['state']; if (isset($_POST['state'])) { $stateId = $_POST['state']; } $cityId = $data['city']; if (isset($_POST['city'])) { $cityId = $_POST['city']; } if ($countryId != '') { $statesmodel = new Default_Model_States(); $statesData = $statesmodel->getBasicStatesList($countryId); foreach ($statesData as $res) { $deptform->state->addMultiOption($res['state_id_org'], utf8_encode($res['state'])); } } if ($stateId != '') { $citiesmodel = new Default_Model_Cities(); $citiesData = $citiesmodel->getBasicCitiesList($stateId); foreach ($citiesData as $res) { $deptform->city->addMultiOption($res['city_org_id'], utf8_encode($res['city'])); } } $deptform->setDefault('country', $countryId); $deptform->setDefault('state', $stateId); $deptform->setDefault('city', $cityId); $this->view->ermsg = ''; $this->view->datarr = $data; } else { $this->view->ermsg = 'nodata'; } } $bname = $deptModel->getbusinessunitname($bunitid); $this->view->bunitname = $bname; $this->view->deptData = sizeof($deptData); $this->view->form = $deptform; $this->view->unitid = $bunitid; $this->view->controllername = $controllername; if (!empty($allBusinessunitsData) && !empty($allCountriesData) && !empty($allStatesData) && !empty($allCitiesData) && !empty($allTimezoneData)) { $this->view->configuremsg = ''; } else { $this->view->configuremsg = 'notconfigurable'; } if (empty($allCountriesData)) { $msgarray['country'] = 'Countries are not configured yet.'; $flag = 'false'; } if (empty($allStatesData)) { $msgarray['state'] = 'States are not configured yet.'; $flag = 'false'; } if (empty($allCitiesData)) { $msgarray['city'] = 'Cities are not configured yet.'; $flag = 'false'; } if (empty($allTimezoneData)) { $msgarray['timezone'] = 'Time zones are not configured yet.'; $flag = 'false'; } $this->view->msgarray = $msgarray; if ($this->getRequest()->getPost()) { if ($deptform->isValid($this->_request->getPost()) && $flag == 'true') { $deptname = $this->_request->getParam('deptname'); $deptcode = $this->_request->getParam('deptcode'); $description = $this->_request->getParam('description'); $start_date = $this->_request->getParam('start_date', null); $start_date = sapp_Global::change_date($start_date, 'database'); $country = $this->_request->getParam('country'); $state = intval($this->_request->getParam('state')); $city = intval($this->_request->getParam('city')); $address1 = $this->_request->getParam('address1'); $address2 = $this->_request->getParam('address2'); $address3 = $this->_request->getParam('address3'); $unitid = $this->_request->getParam('unitid'); $timezone = $this->_request->getParam('timezone'); $depthead = $this->_request->getParam('depthead'); if (!isset($unitid) || $unitid == '') { $unitid = $bunitid; } $deptcodeExistance = $deptModel->checkCodeDuplicates($deptcode, $id); if (!$deptcodeExistance) { $date = new Zend_Date(); $actionflag = ''; $tableid = ''; $data = array('deptname' => trim($deptname), 'deptcode' => trim($deptcode), 'description' => trim($description), 'startdate' => $start_date != '' ? $start_date : NULL, 'country' => trim($country), 'state' => trim($state), 'city' => trim($city), 'address1' => trim($address1), 'address2' => trim($address2), 'address3' => trim($address3), 'timezone' => trim($timezone), 'unitid' => $unitid, 'depthead' => trim($depthead), 'modifiedby' => $loginUserId, 'modifieddate' => $date->get('yyyy-MM-dd HH:mm:ss')); if ($id != '') { $where = array('id=?' => $id); $actionflag = 2; } else { $data['createdby'] = $loginUserId; $data['createddate'] = $date->get('yyyy-MM-dd HH:mm:ss'); $data['isactive'] = 1; $where = ''; $actionflag = 1; } $Id = $deptModel->SaveorUpdateDepartmentsUnits($data, $where); if ($Id == 'update') { $this->view->eventact = 'updated'; $tableid = $id; } else { $this->view->eventact = 'added'; $tableid = $Id; } $menuID = DEPARTMENTS; $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid); Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/"); $close = 'close'; $this->view->popup = $close; $this->view->controllername = $controllername; } else { $msgarray['message'] = 'A Department, with the given code, already exists.'; $msgarray['msgtype'] = 'error'; $this->view->messages = $msgarray; } } else { $messages = $deptform->getMessages(); foreach ($messages as $key => $val) { foreach ($val as $key2 => $val2) { $msgarray[$key] = $val2; break; } if (empty($allCountriesData)) { $msgarray['country'] = 'Countries are not configured yet.'; } if (empty($allStatesData)) { $msgarray['state'] = 'States are not configured yet.'; } if (empty($allCitiesData)) { $msgarray['city'] = 'Cities are not configured yet.'; } if (empty($allTimezoneData)) { $msgarray['timezone'] = 'Time zones are not configured yet.'; } } $this->view->msgarray = $msgarray; } } } else { $orgdata = 'noorgdata'; $this->view->orgdata = $orgdata; } }
public function addemppopupAction() { $flag = 'true'; $controllername = 'employee'; $msgarray = array(); $emptyFlag = 0; Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/"); $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; } $deptidforhead = $this->_getParam('deptidforhead', null); $report_opt = array(); $emp_form = new Default_Form_employee(); $user_model = new Default_Model_Usermanagement(); $role_model = new Default_Model_Roles(); $prefixModel = new Default_Model_Prefix(); $identity_code_model = new Default_Model_Identitycodes(); $jobtitlesModel = new Default_Model_Jobtitles(); $deptModel = new Default_Model_Departments(); $positionsmodel = new Default_Model_Positions(); $employeeModal = new Default_Model_Employee(); $usersModel2 = new Default_Model_Users(); $employmentstatusModel = new Default_Model_Employmentstatus(); $emp_form->setAction(BASE_URL . 'employee/addemppopup/deptidforhead/' . $deptidforhead); $emp_form->removeElement('department_id'); $emp_form->removeElement('modeofentry'); $identity_codes = $identity_code_model->getIdentitycodesRecord(); $emp_identity_code = isset($identity_codes[0]) ? $identity_codes[0]['employee_code'] : ""; if ($emp_identity_code != '') { $emp_id = $emp_identity_code . str_pad($user_model->getMaxEmpId($emp_identity_code), 4, '0', STR_PAD_LEFT); } else { $emp_id = ''; $msgarray['employeeId'] = 'Identity codes are not configured yet.'; $flag = 'false'; } $emp_form->employeeId->setValue($emp_id); $role_data = $role_model->getRolesList_Dept($deptidforhead); //in add screen $deptidforhead is null and we can get only Management role,In edit screen getting all roles $emp_form->emprole->addMultiOptions(array('' => 'Select Role') + $role_data); if (empty($role_data)) { $msgarray['emprole'] = 'Roles are not configured yet.'; $flag = 'false'; } $prefixData = $prefixModel->getPrefixList(); $emp_form->prefix_id->addMultiOption('', 'Select Prefix'); if (!empty($prefixData)) { foreach ($prefixData as $prefixres) { $emp_form->prefix_id->addMultiOption($prefixres['id'], $prefixres['prefix']); } } else { $msgarray['prefix_id'] = 'Prefixes are not configured yet.'; //$flag = 'false'; } $jobtitleData = $jobtitlesModel->getJobTitleList(); if (!empty($jobtitleData)) { foreach ($jobtitleData as $jobtitleres) { $emp_form->jobtitle_id->addMultiOption($jobtitleres['id'], $jobtitleres['jobtitlename']); } } else { $msgarray['jobtitle_id'] = 'Job titles are not configured yet.'; $msgarray['position_id'] = 'Positions are not configured yet.'; //$flag = 'false'; } if (isset($_POST['jobtitle_id']) && $_POST['jobtitle_id'] != '') { $positionlistArr = $positionsmodel->getPositionList($_POST['jobtitle_id']); if (sizeof($positionlistArr) > 0) { $emp_form->position_id->addMultiOption('', 'Select Position'); foreach ($positionlistArr as $positionlistres) { $emp_form->position_id->addMultiOption($positionlistres['id'], $positionlistres['positionname']); } } } $employmentStatusData = $employmentstatusModel->getempstatusActivelist(); $emp_form->emp_status_id->addMultiOption('', 'Select Employment Status'); if (!empty($employmentStatusData)) { foreach ($employmentStatusData as $employmentStatusres) { $emp_form->emp_status_id->addMultiOption($employmentStatusres['workcodename'], $employmentStatusres['statusname']); } } else { $msgarray['emp_status_id'] = 'Employment status is not configured yet.'; $emptyFlag++; } $reportingManagerData = $usersModel2->getReportingManagerList_employees('', '', MANAGEMENT_GROUP); if (!empty($reportingManagerData)) { $report_opt = $reportingManagerData; if (isset($_POST['reporting_manager']) && $_POST['reporting_manager'] != '') { $emp_form->setDefault('reporting_manager', $_POST['reporting_manager']); } } else { $msgarray['reporting_manager'] = 'Reporting managers are not added yet.'; $flag = 'false'; } if ($this->getRequest()->getPost()) { if ($emp_form->isValid($this->_request->getPost()) && $flag == 'true') { $jobtitle_id = $this->_request->getParam('jobtitle_id', null); $position_id = $this->_request->getParam('position_id', null); $date_of_joining = sapp_Global::change_date($this->_request->getParam('date_of_joining', null), 'database'); $date_of_leaving = $this->_request->getParam('date_of_leaving', null); $date_of_leaving = sapp_Global::change_date($date_of_leaving, 'database'); $employeeId = $this->_getParam('employeeId', null); $emprole = $this->_getParam('emprole', null); $reporting_manager = $this->_getParam('reporting_manager', null); $emailaddress = $this->_getParam('emailaddress', null); $emppassword = sapp_Global::generatePassword(); $firstname = trim($this->_getParam('firstname', null)); $lastname = trim($this->_getParam('lastname', null)); $userfullname = $firstname . ' ' . $lastname; //$userfullname = trim($this->_request->getParam('userfullname',null)); $prefix_id = $this->_getParam('prefix_id', null); $user_id = $this->_getParam('user_id', null); $emp_status_id = $this->_getParam('emp_status_id', null); $user_data = array('emprole' => $emprole, 'firstname' => $firstname != '' ? $firstname : NULL, 'lastname' => $lastname != '' ? $lastname : NULL, 'userfullname' => $userfullname, 'emailaddress' => $emailaddress, 'jobtitle_id' => $jobtitle_id, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"), 'emppassword' => md5($emppassword), 'employeeId' => $employeeId, 'modeofentry' => 'Direct', 'selecteddate' => $date_of_joining, 'userstatus' => 'old'); $emp_data = array('user_id' => $user_id, 'jobtitle_id' => $jobtitle_id, 'position_id' => $position_id, 'prefix_id' => $prefix_id, 'department_id' => $deptidforhead, 'reporting_manager' => $reporting_manager, 'date_of_joining' => $date_of_joining, 'date_of_leaving' => $date_of_leaving != '' ? $date_of_leaving : NULL, 'emp_status_id' => $emp_status_id, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); $user_data['createdby'] = $loginUserId; $user_data['createddate'] = gmdate("Y-m-d H:i:s"); $user_data['isactive'] = 1; if ($emp_identity_code != '') { $emp_id = $emp_identity_code . str_pad($user_model->getMaxEmpId($emp_identity_code), 4, '0', STR_PAD_LEFT); } else { $emp_id = ''; } $user_data['employeeId'] = $emp_id; $user_id = $user_model->SaveorUpdateUserData($user_data, ''); $emp_data['user_id'] = $user_id; $emp_data['createdby'] = $loginUserId; $emp_data['createddate'] = gmdate("Y-m-d H:i:s"); $emp_data['isactive'] = 1; $employeeModal->SaveorUpdateEmployeeData($emp_data, ''); //end of saving into employee table. $tableid = $user_id; $actionflag = 1; $menuID = ORGANISATIONINFO; try { $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid); } catch (Exception $e) { } //$managementUsersData = $deptModel->getDeptHeads(); $managementUsersData = $deptModel->getDepartmenttHead(''); $opt = ''; foreach ($managementUsersData as $record) { $opt .= sapp_Global::selectOptionBuilder($record['id'], $record['userfullname']); } $this->view->managementUsersData = $opt; /* Send Mail to the user */ $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl(); $view = $this->getHelper('ViewRenderer')->view; $this->view->emp_name = $userfullname; $this->view->password = $emppassword; $this->view->emp_id = $employeeId; $this->view->base_url = $base_url; $text = $view->render('mailtemplates/newpassword.phtml'); $options['subject'] = APPLICATION_NAME . ' login Credentials'; $options['header'] = 'Greetings from Sentrifugo'; $options['toEmail'] = $emailaddress; $options['toName'] = $this->view->emp_name; $options['message'] = $text; $result = sapp_Global::_sendEmail($options); /* END */ $this->view->eventact = 'added'; $close = 'close'; $this->view->popup = $close; } else { $messages = $emp_form->getMessages(); foreach ($messages as $key => $val) { foreach ($val as $key2 => $val2) { $msgarray[$key] = $val2; break; } } $this->view->msgarray = $msgarray; } } $this->view->msgarray = $msgarray; $this->view->report_opt = $report_opt; $this->view->controllername = $controllername; $this->view->departmentid = $deptidforhead; $this->view->emp_form = $emp_form; }