Esempio n. 1
0
 public static function _getAdapter($adapter, $options)
 {
     if (empty($adapter) || empty($options) || !is_array($options)) {
         return false;
     }
     if (!in_array($adapter, array('ldap', 'db', 'email'))) {
         return false;
     }
     if (!array_key_exists('username', $options) || !array_key_exists('user_password', $options)) {
         return false;
     }
     $username = $options['username'];
     $password = $options['user_password'];
     switch ($adapter) {
         case 'ldap':
             $auth = new Zend_Auth_Adapter_Ldap($options['ldap'], $username, $password);
             break;
         case 'db':
             $password = md5($password);
             $auth = new Zend_Auth_Adapter_DbTable($options['db'], 'main_users', 'employeeId', 'emppassword');
             $auth->setIdentity($username)->setCredential($password);
             break;
         case 'email':
             $password = md5($password);
             $auth = new Zend_Auth_Adapter_DbTable($options['db'], 'main_users', 'emailaddress', 'emppassword');
             $auth->setIdentity($username)->setCredential($password);
             break;
     }
     //To create organization image session
     $orgInfoModel = new Default_Model_Organisationinfo();
     $getorgData = $orgInfoModel->getorgrecords();
     if (!empty($getorgData)) {
         $id = $getorgData[0]['id'];
         $data = $orgInfoModel->getOrganisationData($id);
         $organizationImg = new Zend_Session_Namespace('organizationinfo');
         if (!empty($data['org_image'])) {
             $organizationImg->orgimg = $data['org_image'];
         }
     }
     return $auth;
 }
Esempio n. 2
0
 public function saveorginfo($form, $loginUserId, $wizardData)
 {
     $orgInfoModel = new Default_Model_Organisationinfo();
     $wizard_model = new Default_Model_Wizard();
     $id = $this->getRequest()->getParam('id');
     $imagerror = $this->_request->getParam('imgerr');
     $imagepath = $this->_request->getParam('org_image_value');
     $imgerrmsg = $this->_request->getParam('imgerrmsg');
     $pphnumber = $this->_request->getParam('phonenumber');
     $sphnumber = $this->_request->getParam('secondaryphone');
     $org_startdate = sapp_Global::change_date($this->_request->getParam('org_startdate'), 'database');
     $flag = 'true';
     if (isset($imagepath) && $imagepath != '') {
         $imageArr = explode('.', $imagepath);
         if (sizeof($imageArr) > 1) {
             $imagename = $imageArr[0];
             $imageext = $imageArr[1];
             $extArr = array('gif', 'jpg', 'jpeg', 'png');
             if (!in_array($imageext, $extArr)) {
                 $msgarray['org_image_value'] = 'Please upload an appropriate image file.';
                 $flag = 'false';
             }
         } else {
             $msgarray['org_image_value'] = 'Please upload an appropriate image file.';
             $flag = 'false';
         }
     }
     if ($imagerror == 'error') {
         if ($imgerrmsg != '' && $imgerrmsg != 'undefined') {
             $msgarray['org_image_value'] = $imgerrmsg;
         } else {
             $msgarray['org_image_value'] = 'Please upload an appropriate image file.';
         }
         $flag = 'false';
     }
     if ($pphnumber == $sphnumber && $sphnumber != '' && $pphnumber != '') {
         $msgarray['secondaryphone'] = 'Please enter different phone number.';
         $flag = 'false';
     }
     if ($form->isValid($this->_request->getPost()) && $flag != 'false') {
         $domain = $this->_request->getParam('domain');
         $domain = implode(',', $domain);
         $date = new Zend_Date();
         $data = array('organisationname' => trim($this->_request->getParam('organisationname')), 'domain' => trim($domain), 'website' => trim($this->_request->getParam('website')), 'org_image' => $imagepath, 'orgdescription' => trim($this->_request->getParam('orgdescription')), 'totalemployees' => trim($this->_request->getParam('totalemployees')), 'org_startdate' => $org_startdate != '' ? $org_startdate : NULL, 'phonenumber' => trim($this->_request->getParam('phonenumber')), 'secondaryphone' => trim($this->_request->getParam('secondaryphone')), 'faxnumber' => trim($this->_request->getParam('faxnumber')), 'country' => trim((int) $this->_request->getParam('country')), 'state' => trim(intval($this->_request->getParam('state'))), 'city' => trim(intval($this->_request->getParam('city'))), 'address1' => trim($this->_request->getParam('address1')), 'address2' => trim($this->_request->getParam('address2')), 'address3' => trim($this->_request->getParam('address3')), 'description' => trim($this->_request->getParam('description')), 'designation' => trim($this->_request->getParam('jobtitle_id', null)), 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
         $db = Zend_Db_Table::getDefaultAdapter();
         $db->beginTransaction();
         try {
             $path = IMAGE_UPLOAD_PATH;
             $imagepath = $this->_request->getParam('org_image_value');
             $filecopy = 'success';
             if ($imagepath != '') {
                 $filecopy = 'error';
                 if (file_exists(USER_PREVIEW_UPLOAD_PATH . '//' . $imagepath)) {
                     try {
                         if (copy(USER_PREVIEW_UPLOAD_PATH . '//' . $imagepath, $path . '//' . $imagepath)) {
                             $filecopy = 'success';
                         }
                         unlink(USER_PREVIEW_UPLOAD_PATH . '//' . $imagepath);
                     } catch (Exception $e) {
                         echo $msgarray['org_image_value'] = $e->getMessage();
                         exit;
                     }
                 }
             }
             $where = array('id=?' => $id);
             if ($imagepath == '') {
                 unset($data['org_image']);
             } else {
                 if ($filecopy == 'error') {
                     unset($data['org_image']);
                 }
             }
             if ($id != '') {
                 $where = array('id=?' => $id);
                 $actionflag = 2;
             } else {
                 $data['createdby'] = $loginUserId;
                 $data['createddate'] = gmdate("Y-m-d H:i:s");
                 $data['isactive'] = 1;
                 $where = '';
                 $actionflag = 1;
             }
             $Id = $orgInfoModel->SaveorUpdateData($data, $where);
             $menuID = ORGANISATIONINFO;
             try {
                 if ($Id != '' && $Id != 'update') {
                     $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $Id);
                 } else {
                     $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $id);
                 }
             } catch (Exception $e) {
                 echo $e->getMessage();
             }
             $wizardarray = array('org_details' => 2, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
             if ($wizardData['site_config'] == 2) {
                 $wizardarray['iscomplete'] = 2;
             }
             $wizard_model->SaveorUpdateWizardData($wizardarray, '');
             $location_data = array('country' => trim((int) $this->_request->getParam('country')), 'state' => trim(intval($this->_request->getParam('state'))), 'city' => trim(intval($this->_request->getParam('city'))), 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
             $LocationId = $wizard_model->SaveorUpdateWizardData($location_data, '');
             $db->commit();
             if ($filecopy == 'success') {
                 $this->_helper->getHelper("FlashMessenger")->addMessage("Organization information saved successfully.");
             } else {
                 $this->_helper->getHelper("FlashMessenger")->addMessage("Organization information saved successfully but failed to upload the logo.");
             }
             $this->_redirect('wizard/configureorganisation');
         } catch (Exception $e) {
             $db->rollBack();
             $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Something went wrong,please try again later."));
             $this->_redirect('wizard/configureorganisation');
         }
     } else {
         $messages = $form->getMessages();
         foreach ($messages as $key => $val) {
             foreach ($val as $key2 => $val2) {
                 $msgarray[$key] = $val2;
                 break;
             }
         }
         //echo '<pre>';print_r($messages);exit;
         return $msgarray;
     }
 }
 public function comeditAction()
 {
     if (defined('EMPTABCONFIGS')) {
         $empOrganizationTabs = explode(",", EMPTABCONFIGS);
         if (in_array('empcommunicationdetails', $empOrganizationTabs)) {
             $empDeptdata = array();
             $employeeData = array();
             $auth = Zend_Auth::getInstance();
             if ($auth->hasIdentity()) {
                 $loginUserId = $auth->getStorage()->read()->id;
                 $loginuserRole = $auth->getStorage()->read()->emprole;
                 $loginuserGroup = $auth->getStorage()->read()->group_id;
             }
             $id = $this->getRequest()->getParam('userid');
             if ($id == '') {
                 $id = $loginUserId;
             }
             $callval = $this->getRequest()->getParam('call');
             if ($callval == 'ajaxcall') {
                 $this->_helper->layout->disableLayout();
             }
             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)) {
                             $empDept = $empdata[0]['department_id'];
                             $empcommdetailsform = new Default_Form_empcommunicationdetails();
                             $empcommdetailsModal = new Default_Model_Empcommunicationdetails();
                             $usersModel = new Default_Model_Users();
                             $countriesModel = new Default_Model_Countries();
                             $statesmodel = new Default_Model_States();
                             $citiesmodel = new Default_Model_Cities();
                             $orgInfoModel = new Default_Model_Organisationinfo();
                             $msgarray = array();
                             $orgid = 1;
                             $countryId = '';
                             $stateId = '';
                             $cityId = '';
                             $deptModel = new Default_Model_Departments();
                             if ($empDept != '' && $empDept != 'NULL') {
                                 $empDeptdata = $deptModel->getEmpdepartmentdetails($empDept);
                                 if (!empty($empDeptdata)) {
                                     $countryId = $empDeptdata[0]['country'];
                                     $stateId = $empDeptdata[0]['state'];
                                     $cityId = $empDeptdata[0]['city'];
                                 }
                             } else {
                                 $empDeptdata = $orgInfoModel->getOrganisationDetails($orgid);
                                 if (!empty($empDeptdata)) {
                                     $countryId = $empDeptdata[0]['country'];
                                     $stateId = $empDeptdata[0]['state'];
                                     $cityId = $empDeptdata[0]['city'];
                                 }
                             }
                             if ($countryId != '') {
                                 $countryData = $countriesModel->getActiveCountryName($countryId);
                             }
                             if (!empty($countryData)) {
                                 $empDeptdata[0]['country'] = $countryData[0]['country'];
                             } else {
                                 $empDeptdata[0]['country'] = '';
                             }
                             if ($stateId != '') {
                                 $stateData = $statesmodel->getStateNameData($stateId);
                             }
                             if (!empty($stateData)) {
                                 $empDeptdata[0]['state'] = $stateData[0]['state'];
                             } else {
                                 $empDeptdata[0]['state'] = '';
                             }
                             if ($cityId != '') {
                                 $citiesData = $citiesmodel->getCitiesNameData($cityId);
                             }
                             if (!empty($citiesData)) {
                                 $empDeptdata[0]['city'] = $citiesData[0]['city'];
                             } else {
                                 $empDeptdata[0]['city'] = '';
                             }
                             $countrieslistArr = $countriesModel->getTotalCountriesList();
                             if (sizeof($countrieslistArr) > 0) {
                                 $empcommdetailsform->perm_country->addMultiOption('', 'Select Country');
                                 $empcommdetailsform->current_country->addMultiOption('', 'Select Country');
                                 foreach ($countrieslistArr as $countrieslistres) {
                                     $empcommdetailsform->perm_country->addMultiOption($countrieslistres['id'], utf8_encode($countrieslistres['country_name']));
                                     $empcommdetailsform->current_country->addMultiOption($countrieslistres['id'], utf8_encode($countrieslistres['country_name']));
                                 }
                             } else {
                                 $msgarray['perm_country'] = 'Countries are not configured yet.';
                                 $msgarray['current_country'] = 'Countries are not configured yet.';
                             }
                             $data = $empcommdetailsModal->getsingleEmpCommDetailsData($id);
                             if (!empty($data)) {
                                 $perm_country = $data[0]['perm_country'];
                                 if (isset($_POST['perm_country'])) {
                                     $perm_country = $_POST['perm_country'];
                                 }
                                 $perm_state = $data[0]['perm_state'];
                                 if (isset($_POST['perm_state'])) {
                                     $perm_state = $_POST['perm_state'];
                                 }
                                 $perm_city = $data[0]['perm_city'];
                                 if (isset($_POST['perm_city'])) {
                                     $perm_city = $_POST['perm_city'];
                                 }
                                 if ($perm_country != '') {
                                     $statePermlistArr = $statesmodel->getStatesList($perm_country);
                                     if (sizeof($statePermlistArr) > 0) {
                                         $empcommdetailsform->perm_state->addMultiOption('', 'Select State');
                                         foreach ($statePermlistArr as $statelistres) {
                                             $empcommdetailsform->perm_state->addMultiOption($statelistres['id'], $statelistres['state_name']);
                                         }
                                     }
                                 }
                                 if ($perm_state != '') {
                                     $cityPermlistArr = $citiesmodel->getCitiesList($perm_state);
                                     if (sizeof($cityPermlistArr) > 0) {
                                         $empcommdetailsform->perm_city->addMultiOption('', 'Select City');
                                         foreach ($cityPermlistArr as $cityPermlistres) {
                                             $empcommdetailsform->perm_city->addMultiOption($cityPermlistres['id'], $cityPermlistres['city_name']);
                                         }
                                     }
                                 }
                                 $current_country = $data[0]['current_country'];
                                 if (isset($_POST['current_country'])) {
                                     $current_country = $_POST['current_country'];
                                 }
                                 $current_state = $data[0]['current_state'];
                                 if (isset($_POST['current_state'])) {
                                     $current_state = $_POST['current_state'];
                                 }
                                 $current_city = $data[0]['current_city'];
                                 if (isset($_POST['current_city'])) {
                                     $current_city = $_POST['current_city'];
                                 }
                                 if ($current_country != '') {
                                     $statecurrlistArr = $statesmodel->getStatesList($current_country);
                                     if (sizeof($statecurrlistArr) > 0) {
                                         $empcommdetailsform->current_state->addMultiOption('', 'Select State');
                                         foreach ($statecurrlistArr as $statecurrlistres) {
                                             $empcommdetailsform->current_state->addMultiOption($statecurrlistres['id'], $statecurrlistres['state_name']);
                                         }
                                     }
                                 }
                                 if ($current_state != '') {
                                     $cityCurrlistArr = $citiesmodel->getCitiesList($current_state);
                                     if (sizeof($cityCurrlistArr) > 0) {
                                         $empcommdetailsform->current_city->addMultiOption('', 'Select City');
                                         foreach ($cityCurrlistArr as $cityCurrlistres) {
                                             $empcommdetailsform->current_city->addMultiOption($cityCurrlistres['id'], $cityCurrlistres['city_name']);
                                         }
                                     }
                                 }
                                 $empcommdetailsform->populate($data[0]);
                                 $empcommdetailsform->setDefault('perm_country', $perm_country);
                                 $empcommdetailsform->setDefault('perm_state', $perm_state);
                                 $empcommdetailsform->setDefault('perm_city', $perm_city);
                                 if ($data[0]['current_country'] != '') {
                                     $empcommdetailsform->setDefault('current_country', $current_country);
                                 }
                                 if ($data[0]['current_state'] != '') {
                                     $empcommdetailsform->setDefault('current_state', $current_state);
                                 }
                                 if ($data[0]['current_city'] != '') {
                                     $empcommdetailsform->setDefault('current_city', $current_city);
                                 }
                             }
                             $empcommdetailsform->setAttrib('action', DOMAIN . 'myemployees/comedit/userid/' . $id);
                             $empcommdetailsform->user_id->setValue($id);
                             if (!empty($empdata)) {
                                 $this->view->employeedata = $empdata[0];
                             } else {
                                 $this->view->employeedata = $empdata;
                             }
                             if (!empty($empDeptdata)) {
                                 $this->view->dataArray = $empDeptdata[0];
                             } else {
                                 $this->view->dataArray = $empDeptdata;
                             }
                             $this->view->form = $empcommdetailsform;
                             $this->view->data = $data;
                             $this->view->id = $id;
                             $this->view->msgarray = $msgarray;
                             $this->view->messages = $this->_helper->flashMessenger->getMessages();
                         }
                         $this->view->empdata = $empdata;
                     }
                 } else {
                     $this->view->rowexist = "norows";
                 }
             } catch (Exception $e) {
                 $this->view->rowexist = "norows";
             }
             if ($this->getRequest()->getPost()) {
                 $result = $this->comsave($empcommdetailsform, $id);
                 $this->view->msgarray = $result;
             }
         } else {
             $this->_redirect('error');
         }
     } else {
         $this->_redirect('error');
     }
 }
Esempio n. 4
0
 /**
  * 
  * Validate organisation start date and organisation head joing date....
  */
 public function validateorgheadjoiningdateAction()
 {
     $result = 'yes';
     $joiningdate = $this->_getParam('joiningdate', null);
     $joiningdate_obj = new DateTime($joiningdate);
     $joiningdate = $joiningdate_obj->format('Y-m-d');
     $orginfomodel = new Default_Model_Organisationinfo();
     $orgdetailsArr = $orginfomodel->getOrganisationInfo();
     if (!empty($orgdetailsArr)) {
         if ($orgdetailsArr[0]['org_startdate'] > $joiningdate) {
             $result = 'no';
         }
     }
     $this->_helper->_json(array('result' => $result));
 }
 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;
     }
 }
Esempio n. 6
0
 public function save($employeeform)
 {
     $emproleStr = '';
     $roleArr = array();
     $empgroupStr = '';
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $usersModel = new Default_Model_Usermanagement();
     $employeeModal = new Default_Model_Employee();
     $requimodel = new Default_Model_Requisition();
     $candidate_model = new Default_Model_Candidatedetails();
     $orgInfoModel = new Default_Model_Organisationinfo();
     $unitid = '';
     $deptid = '';
     $errorflag = 'true';
     $msgarray = array();
     $id = $this->_request->getParam('id');
     $businessunit_id = $this->_request->getParam('businessunit_id', null);
     $department_id = $this->_request->getParam('department_id', null);
     $reporting_manager = $this->_request->getParam('reporting_manager', null);
     $jobtitle_id = $this->_request->getParam('jobtitle_id', null);
     $position_id = $this->_request->getParam('position_id', null);
     $user_id = $this->_getParam('user_id', null);
     $prefix_id = $this->_getParam('prefix_id', null);
     $extension_number = $this->_getParam('extension_number', null);
     $office_number = $this->_request->getParam('office_number', null);
     $office_faxnumber = $this->_request->getParam('office_faxnumber', null);
     $date_of_joining = $this->_request->getParam('date_of_joining', null);
     $date_of_joining = sapp_Global::change_date($date_of_joining, 'database');
     $isvalidorgstartdate = $orgInfoModel->validateEmployeeJoiningDate($date_of_joining, $unitid, $deptid);
     if (!empty($isvalidorgstartdate)) {
         $msgarray['date_of_joining'] = 'Employee joining date should be greater than organization start date.';
         $errorflag = 'false';
     }
     if ($id) {
         $data = $employeeModal->getsingleEmployeeData($id);
         if (!empty($data) && $data[0]['is_orghead'] == 1) {
             $reporting_manager = $this->_request->getParam('reporting_manager', '0');
         }
     }
     if ($employeeform->isValid($this->_request->getPost()) && $errorflag == 'true') {
         $id = $this->_request->getParam('id');
         $emp_status_id = $this->_request->getParam('emp_status_id', null);
         $date_of_leaving = $this->_request->getParam('date_of_leaving', null);
         $date_of_leaving = sapp_Global::change_date($date_of_leaving, 'database');
         $years_exp = $this->_request->getParam('years_exp');
         //FOR USER table
         $employeeId = $this->_getParam('employeeId', null);
         $modeofentry = $this->_getParam('modeofentry', null);
         $hid_modeofentry = $this->_getParam('hid_modeofentry', null);
         $other_modeofentry = $this->_getParam('other_modeofentry', null);
         $firstname = trim($this->_getParam('firstname', null));
         $lastname = trim($this->_getParam('lastname', null));
         $userfullname = $firstname . ' ' . $lastname;
         $candidatereferredby = $this->_getParam('candidatereferredby', null);
         $rccandidatename = $this->_getParam('rccandidatename', null);
         $emprole = $this->_getParam('emprole', null);
         //roleid_group_id
         if ($emprole != "") {
             $roleArr = explode('_', $emprole);
             if (!empty($roleArr)) {
                 $emproleStr = $roleArr[0];
                 $empgroupStr = $roleArr[0];
             }
         }
         $emailaddress = $this->_getParam('emailaddress', null);
         $tmp_name = $this->_request->getParam('tmp_emp_name', null);
         $act_inact = $this->_request->getParam("act_inact", null);
         //end of user table
         $date = new Zend_Date();
         $menumodel = new Default_Model_Menu();
         $empstatusarray = array(8, 9, 10);
         $actionflag = '';
         $tableid = '';
         if ($modeofentry == 'Direct' || $hid_modeofentry == 'Direct') {
             $candidate_key = 'userfullname';
             $candidate_value = $userfullname;
             $emp_name = $userfullname;
             $candidate_flag = 'no';
         } else {
             $candidate_key = 'rccandidatename';
             $candidate_value = $rccandidatename;
             $emp_name = $tmp_name;
             $candidate_flag = 'yes';
         }
         $trDb = Zend_Db_Table::getDefaultAdapter();
         // starting transaction
         $trDb->beginTransaction();
         try {
             $emppassword = sapp_Global::generatePassword();
             $user_data = array('emprole' => $emproleStr, 'firstname' => $firstname != '' ? $firstname : NULL, 'lastname' => $lastname != '' ? $lastname : NULL, $candidate_key => $candidate_value, 'emailaddress' => $emailaddress, 'jobtitle_id' => $jobtitle_id, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"), 'emppassword' => md5($emppassword), 'employeeId' => $employeeId, 'modeofentry' => $id == '' ? $modeofentry : "", 'selecteddate' => $date_of_joining, 'candidatereferredby' => $candidatereferredby, 'userstatus' => 'old', 'other_modeofentry' => $other_modeofentry);
             if ($id != '') {
                 $where = array('user_id=?' => $user_id);
                 $actionflag = 2;
                 $user_where = "id = " . $user_id;
                 unset($user_data['candidatereferredby']);
                 unset($user_data['userstatus']);
                 unset($user_data['emppassword']);
                 unset($user_data['employeeId']);
                 unset($user_data['modeofentry']);
                 unset($user_data['other_modeofentry']);
             } else {
                 $user_data['createdby'] = $loginUserId;
                 $user_data['createddate'] = gmdate("Y-m-d H:i:s");
                 $user_data['isactive'] = 1;
                 if ($modeofentry != 'Direct') {
                     $user_data['userfullname'] = $emp_name;
                 }
                 $where = '';
                 $actionflag = 1;
                 $user_where = '';
                 $identity_code_model = new Default_Model_Identitycodes();
                 $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($usersModel->getMaxEmpId($emp_identity_code), 4, '0', STR_PAD_LEFT);
                 } else {
                     $emp_id = '';
                 }
                 $user_data['employeeId'] = $emp_id;
             }
             $user_status = $usersModel->SaveorUpdateUserData($user_data, $user_where);
             if ($id == '') {
                 $user_id = $user_status;
             }
             $data = array('user_id' => $user_id, 'reporting_manager' => $reporting_manager, 'emp_status_id' => $emp_status_id, 'businessunit_id' => $businessunit_id, 'department_id' => $department_id, 'jobtitle_id' => $jobtitle_id, 'position_id' => $position_id, 'prefix_id' => $prefix_id, 'extension_number' => $extension_number != '' ? $extension_number : NULL, 'office_number' => $office_number != '' ? $office_number : NULL, 'office_faxnumber' => $office_faxnumber != '' ? $office_faxnumber : NULL, 'date_of_joining' => $date_of_joining, 'date_of_leaving' => $date_of_leaving != '' ? $date_of_leaving : NULL, 'years_exp' => $years_exp == '' ? null : $years_exp, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
             if ($id == '') {
                 $data['createdby'] = $loginUserId;
                 $data['createddate'] = gmdate("Y-m-d H:i:s");
                 $data['isactive'] = 1;
             }
             $Id = $employeeModal->SaveorUpdateEmployeeData($data, $where);
             $statuswhere = array('id=?' => $user_id);
             if ($id != '') {
                 if (in_array($emp_status_id, $empstatusarray)) {
                     $isactivestatus = '';
                     if ($emp_status_id == 8) {
                         $isactivestatus = 2;
                     } else {
                         if ($emp_status_id == 9) {
                             $isactivestatus = 3;
                         } else {
                             if ($emp_status_id == 10) {
                                 $isactivestatus = 4;
                             }
                         }
                     }
                     $statusdata = array('isactive' => $isactivestatus);
                     $empstatusId = $usersModel->SaveorUpdateUserData($statusdata, $statuswhere);
                     $employeeModal->SaveorUpdateEmployeeData($statusdata, "user_id = " . $user_id);
                 } else {
                     $edata = $usersModel->getUserDataById($id);
                     $statusdata = array('isactive' => 1);
                     if ($edata['isactive'] != 0) {
                         if ($edata['emptemplock'] == 1) {
                             $statusdata = array('isactive' => 0);
                         }
                         $empstatusId = $usersModel->SaveorUpdateUserData($statusdata, $statuswhere);
                         $employeeModal->SaveorUpdateEmployeeData($statusdata, "user_id = " . $user_id);
                     }
                 }
             }
             if ($Id == 'update') {
                 $tableid = $id;
                 $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Employee details updated successfully."));
             } else {
                 //start of mailing
                 $base_url = 'http://' . $this->getRequest()->getHttpHost() . $this->getRequest()->getBaseUrl();
                 $view = $this->getHelper('ViewRenderer')->view;
                 $this->view->emp_name = $emp_name;
                 $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 of mailing
                 $tableid = $Id;
                 $this->_helper->getHelper("FlashMessenger")->addMessage(array("success" => "Employee details added successfully."));
                 //incrementing requisition id
                 if ($candidate_flag == 'yes') {
                     $cand_data = $candidate_model->getCandidateById($rccandidatename);
                     $candidate_model->SaveorUpdateCandidateData(array('cand_status' => 'Recruited', 'modifieddate' => gmdate("Y-m-d H:i:s")), " id = " . $rccandidatename);
                     $reqData = $requimodel->incrementfilledpositions($cand_data['requisition_id']);
                     if ($reqData['req_no_positions'] == $reqData['filled_positions']) {
                         $req_status = '6';
                         $data = array('req_status' => $req_status, 'modifiedby' => trim($loginUserId), 'modifiedon' => gmdate("Y-m-d H:i:s"));
                         $where = "id = " . $cand_data['requisition_id'];
                         $result = $requimodel->SaveorUpdateRequisitionData($data, $where);
                         $requimodel->change_to_requisition_closed($cand_data['requisition_id']);
                         $this->send_requi_mail($cand_data['requisition_id'], $requimodel, $usersModel, $loginUserId);
                     }
                 }
             }
             $menuidArr = $menumodel->getMenuObjID('/employee');
             $menuID = $menuidArr[0]['id'];
             $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $user_id);
             if ($act_inact == 1) {
                 if ($user_data['isactive'] == 1) {
                 } else {
                 }
             }
             $trDb->commit();
             // Send email to employee when his details are edited by other user.
             $options['subject'] = APPLICATION_NAME . ': Employee details updated';
             $options['header'] = 'Employee details updated';
             $options['toEmail'] = $emailaddress;
             $options['toName'] = $userfullname;
             $options['message'] = 'Dear ' . $userfullname . ', your employee details are updated.';
             $options['cron'] = 'yes';
             if (!empty($id)) {
                 sapp_Global::_sendEmail($options);
             }
             $this->_redirect('employee/edit/id/' . $user_id);
         } catch (Exception $e) {
             $trDb->rollBack();
             $msgarray['employeeId'] = "Something went wrong, please try again later.";
             return $msgarray;
         }
     } else {
         $messages = $employeeform->getMessages();
         foreach ($messages as $key => $val) {
             foreach ($val as $key2 => $val2) {
                 $msgarray[$key] = $val2;
                 break;
             }
         }
         if (isset($businessunit_id) && $businessunit_id != '') {
             $departmentsmodel = new Default_Model_Departments();
             $departmentlistArr = $departmentsmodel->getDepartmentList($businessunit_id);
             $employeeform->department_id->clearMultiOptions();
             $employeeform->reporting_manager->clearMultiOptions();
             $employeeform->department_id->addMultiOption('', 'Select Department');
             foreach ($departmentlistArr as $departmentlistresult) {
                 $employeeform->department_id->addMultiOption($departmentlistresult['id'], utf8_encode($departmentlistresult['deptname']));
             }
             if (isset($department_id) && $department_id != 0 && $department_id != '') {
                 $employeeform->setDefault('department_id', $department_id);
             }
         }
         if (isset($jobtitle_id) && $jobtitle_id != 0 && $jobtitle_id != '') {
             $positionsmodel = new Default_Model_Positions();
             $positionlistArr = $positionsmodel->getPositionList($jobtitle_id);
             $employeeform->position_id->clearMultiOptions();
             $employeeform->position_id->addMultiOption('', 'Select Position');
             foreach ($positionlistArr as $positionlistRes) {
                 $employeeform->position_id->addMultiOption($positionlistRes['id'], utf8_encode($positionlistRes['positionname']));
             }
             if (isset($position_id) && $position_id != 0 && $position_id != '') {
                 $employeeform->setDefault('position_id', $position_id);
             }
         }
         return $msgarray;
     }
 }
Esempio n. 7
0
    /**
     * 
     * @param type $options
     * @return string
     */
    public static function _checkMail($options = array())
    {
        $options['fromEmail'] = DONOTREPLYEMAIL;
        $options['fromName'] = SUPERADMIN_EMAIL;
        $orglogo = '';
        $imgsource = '';
        $Orgmodel = new Default_Model_Organisationinfo();
        $orglogoArr = $Orgmodel->getOrgLogo();
        if (!empty($orglogoArr)) {
            $orglogo = $orglogoArr['org_image'];
        }
        if ($orglogo != '') {
            $imgsource = DOMAIN . 'public/uploads/organisation/' . $orglogo;
        } else {
            $imgsource = MEDIA_PATH . 'images/mail_pngs/hrms_logo.png';
        }
        $header = "";
        $footer = "";
        $config = array('tls' => $options['tls'], 'auth' => $options['auth'], 'username' => $options['username'], 'password' => $options['password'], 'port' => $options['port']);
        $smtpServer = $options['server_name'];
        //end of sapplica mail configuration
        $transport = new Zend_Mail_Transport_Smtp($smtpServer, $config);
        Zend_Mail::setDefaultTransport($transport);
        $mail = new Zend_Mail('UTF-8');
        $htmlcontentdata = '
				<div style="width:100%;">
			            <div style="background-color:#eeeeee; width:80%; margin:0 auto; position:relative;">
			            <div><img src="' . $imgsource . '" onError="' . MEDIA_PATH . 'images/mail_pngs/hrms_logo.png" height="62" width="319" /></div>
			            <div style="padding:20px 20px 50px 20px;">
			                    <div>
			                        <h1 style="font-family:Arial, Helvetica, sans-serif; font-size:18px; font-weight:bold; border-bottom:1px dashed #999; padding-bottom:15px;">' . $options['header'] . '</h1>
			                    </div>
			                    
			                    <div style="font-family:Arial, Helvetica, sans-serif; font-size:16px; font-weight:normal; line-height:30px; margin:0 0 20px 0;">
			                        ' . $options['message'] . '
			                    </div>
			                    
			                    <div style="font-family:Arial, Helvetica, sans-serif; font-size:16px; font-weight:normal; line-height:30px;">
			                        Regards,<br />
			                        <b>' . APPLICATION_NAME . '</b>
			                    </div>
			            </div>
			            </div>
			    </div>';
        $mail->setSubject($options['subject']);
        $mail->setFrom($options['fromEmail'], $options['fromName']);
        $mail->addTo($options['toEmail'], $options['toName']);
        $mail->setBodyHtml($htmlcontentdata);
        if (array_key_exists('bcc', $options)) {
            $mail->addBcc($options['bcc']);
        }
        if (array_key_exists('cc', $options)) {
            $mail->addCc($options['cc']);
        }
        try {
            if (!empty($options['toEmail'])) {
                $a = @$mail->send();
                return 'success';
            }
        } catch (Exception $ex) {
            $a = "error";
        }
        return $a;
    }
Esempio n. 8
0
 public function savebusinessunitAction()
 {
     $ajaxContext = $this->_helper->getHelper('AjaxContext');
     $ajaxContext->addActionContext('savebusinessunit', 'json')->initContext();
     $this->_helper->layout->disableLayout();
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $businessunitsmodel = new Default_Model_Businessunits();
     $orgInfoModel = new Default_Model_Organisationinfo();
     $systempreferencemodel = new Default_Model_Sitepreference();
     $organisationData = $orgInfoModel->getOrganisationInfo();
     $sitePreferenceData = $systempreferencemodel->SitePreferanceData();
     $result['result'] = '';
     $result['id'] = '';
     $result['unitname'] = '';
     $result['address'] = '';
     $date = new Zend_Date();
     try {
         $unitname = trim($this->_request->getParam('bunit'));
         $address = $this->_request->getParam('streetAddress');
         $isUnitExist = $businessunitsmodel->checkDuplicateUnitName($unitname);
         if (!empty($isUnitExist)) {
             if ($isUnitExist[0]['count'] > 0) {
                 $result['msg'] = 'Name already exists.';
                 $result['id'] = '';
                 $result['unitname'] = '';
                 $result['address'] = '';
             } else {
                 $menumodel = new Default_Model_Menu();
                 $actionflag = '';
                 $tableid = '';
                 if (strlen(trim($unitname)) > 3) {
                     $unitCode = strtoupper(substr(trim($unitname), 0, 4));
                 } else {
                     $unitCode = strtoupper(trim($unitname));
                 }
                 $data = array('unitname' => $unitname, 'unitcode' => $unitCode, 'startdate' => NULL, 'country' => !empty($organisationData) ? $organisationData[0]['country'] : NULL, 'state' => !empty($organisationData) ? $organisationData[0]['state'] : NULL, 'city' => !empty($organisationData) ? $organisationData[0]['city'] : NULL, 'address1' => $address, 'timezone' => !empty($sitePreferenceData) ? $sitePreferenceData[0]['timezoneid'] : NULL, 'createdby' => $loginUserId, 'createddate' => $date->get('yyyy-MM-dd HH:mm:ss'), 'modifiedby' => $loginUserId, 'modifieddate' => $date->get('yyyy-MM-dd HH:mm:ss'));
                 $where = '';
                 $actionflag = 1;
                 $Id = $businessunitsmodel->SaveorUpdateBusinessUnits($data, $where);
                 if ($Id) {
                     $menuID = BUSINESSUNITS;
                     $logresult = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $Id);
                     $result['msg'] = 'success';
                     $result['id'] = $Id;
                     $result['unitname'] = $unitname;
                     $result['address'] = $address;
                 } else {
                     $result['msg'] = 'error';
                     $result['id'] = '';
                     $result['unitname'] = '';
                     $result['address'] = '';
                 }
             }
         }
     } catch (Exception $e) {
         $result['msg'] = $e->getMessage();
         $result['id'] = '';
         $result['unitname'] = '';
         $result['address'] = '';
     }
     $this->_helper->json($result);
 }
Esempio n. 9
0
 public static function _checkMail($options = array())
 {
     $options['fromEmail'] = !empty($options['fromEmail']) ? $options['fromEmail'] : SUPERADMIN_EMAIL;
     $options['fromName'] = !empty($options['fromName']) ? $options['fromName'] : DONOTREPLYNAME;
     $orglogo = '';
     $imgsource = '';
     $a = '';
     $Orgmodel = new Default_Model_Organisationinfo();
     $orglogoArr = $Orgmodel->getOrgLogo();
     if (!empty($orglogoArr)) {
         $orglogo = $orglogoArr['org_image'];
     }
     if (!empty($orglogo)) {
         $imgsource = DOMAIN . 'public/uploads/organisation/' . $orglogo;
     } else {
         $imgsource = MEDIA_PATH . 'images/mail_pngs/hrms_logo.png';
     }
     $header = "";
     $footer = "";
     if (!empty($options['server_name']) && !empty($options['auth']) && !empty($options['port'])) {
         if ($options['auth'] == 'true' && !empty($options['username']) && !empty($options['password'])) {
             $config = array('auth' => $options['auth'], 'username' => $options['username'], 'password' => $options['password'], 'port' => $options['port']);
         } else {
             if ($options['auth'] == 'false') {
                 $config = array('auth' => $options['auth'], 'port' => $options['port']);
             }
         }
         if (!empty($options['tls'])) {
             $config['tls'] = $options['tls'];
         }
         $smtpServer = $options['server_name'];
     }
     //end of sapplica mail configuration
     return self::send_php_mail($config, $smtpServer, $imgsource, $options);
 }
 public function viewAction()
 {
     $orgInfoModel = new Default_Model_Organisationinfo();
     $getorgData = $orgInfoModel->getorgrecords();
     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;
         }
         $permission = 'No';
         $id = $this->getRequest()->getParam('id');
         if (is_numeric($id) && $id > 0) {
             $callval = $this->getRequest()->getParam('call');
             if ($callval == 'ajaxcall') {
                 $this->_helper->layout->disableLayout();
             }
             $objName = 'businessunits';
             $businessunitsform = new Default_Form_businessunits();
             $deptModel = new Default_Model_Departments();
             $businessunitsform->removeElement("submit");
             $elements = $businessunitsform->getElements();
             if (count($elements) > 0) {
                 foreach ($elements as $key => $element) {
                     if ($key != "Cancel" && $key != "Edit" && $key != "Delete" && $key != "Attachments") {
                         $element->setAttrib("disabled", "disabled");
                     }
                 }
             }
             $businessunitsmodel = new Default_Model_Businessunits();
             $data = $businessunitsmodel->getSingleUnitData($id);
             if (!empty($data)) {
                 $businessunitsform->populate($data);
                 $countryId = $data['country'];
                 $stateId = $data['state'];
                 $cityId = $data['city'];
                 if ($countryId && $stateId) {
                     $statesmodel = new Default_Model_States();
                     $citiesmodel = new Default_Model_Cities();
                     $statesData = $statesmodel->getBasicStatesList($countryId);
                     $citiesData = $citiesmodel->getBasicCitiesList($stateId);
                     foreach ($statesData as $res) {
                         $businessunitsform->state->addMultiOption($res['state_id_org'], utf8_encode($res['state']));
                     }
                     foreach ($citiesData as $res) {
                         $businessunitsform->city->addMultiOption($res['city_org_id'], utf8_encode($res['city']));
                     }
                     $businessunitsform->setDefault('country', $countryId);
                     $businessunitsform->setDefault('state', $stateId);
                     $businessunitsform->setDefault('city', $cityId);
                 }
                 $st_date = sapp_Global::change_date($data["startdate"], 'view');
                 $businessunitsform->setDefault('start_date', $st_date);
                 $permission = sapp_Global::_checkprivileges(BUSINESSUNITS, $loginuserGroup, $loginuserRole, 'edit');
                 $deptData = $deptModel->getAllDeptsForUnit($id);
                 $this->view->deptData = sizeof($deptData);
                 $this->view->dataArray = $this->departmentGrid($id);
                 $this->view->ermsg = '';
             } else {
                 $this->view->ermsg = 'nodata';
             }
             $this->view->editpermission = $permission;
             $this->view->controllername = $objName;
             $this->view->id = $id;
             $this->view->form = $businessunitsform;
             $this->view->role = $loginuserRole;
         } else {
             $this->view->ermsg = 'nodata';
         }
     } else {
         $orgdata = 'noorgdata';
         $this->view->orgdata = $orgdata;
     }
 }
 public function addorgheadAction()
 {
     Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/");
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $org_id = $this->_request->getParam('orgid', null);
     $msgarray = array();
     $prevorgheadId = '';
     $posted_prevorghead_rm = '';
     try {
         $user_model = new Default_Model_Usermanagement();
         $orgInfoModel = new Default_Model_Organisationinfo();
         $countriesModel = new Default_Model_Countries();
         $statesmodel = new Default_Model_States();
         $citiesmodel = new Default_Model_Cities();
         $role_model = new Default_Model_Roles();
         $prefixModel = new Default_Model_Prefix();
         $identity_code_model = new Default_Model_Identitycodes();
         $jobtitlesModel = new Default_Model_Jobtitles();
         $employeeModal = new Default_Model_Employee();
         $positionsmodel = new Default_Model_Positions();
         $form = new Default_Form_Organisationhead();
         $form->setAttrib('action', BASE_URL . 'organisationinfo/addorghead/orgid/' . $org_id);
         $identity_codes = $identity_code_model->getIdentitycodesRecord();
         $role_data = $role_model->getRolesList_orginfo();
         $flag = 'true';
         $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';
         }
         $form->employeeId->setValue($emp_id);
         $form->emprole->addMultiOptions(array('' => 'Select Role') + $role_data);
         if (empty($role_data)) {
             $msgarray['emprole'] = 'Roles are not added yet.';
             $flag = 'false';
         }
         $prefixData = $prefixModel->getPrefixList();
         $form->prefix_id->addMultiOption('', 'Select Prefix');
         if (!empty($prefixData)) {
             foreach ($prefixData as $prefixres) {
                 $form->prefix_id->addMultiOption($prefixres['id'], $prefixres['prefix']);
             }
         } else {
             $msgarray['prefix_id'] = 'Prefixes are not configured yet.';
         }
         $jobtitleData = $jobtitlesModel->getJobTitleList();
         if (!empty($jobtitleData)) {
             foreach ($jobtitleData as $jobtitleres) {
                 $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.';
         }
         $form->position_id->addMultiOption('', 'Select a Position');
         if (isset($_POST['jobtitle_id']) && $_POST['jobtitle_id'] != '') {
             $jobtitle_id = $_POST['jobtitle_id'];
             $positionlistArr = $positionsmodel->getPositionList($jobtitle_id);
             if (sizeof($positionlistArr) > 0) {
                 foreach ($positionlistArr as $positionlistres) {
                     $form->position_id->addMultiOption($positionlistres['id'], $positionlistres['positionname']);
                 }
             }
         }
         if (isset($_POST['prevorghead_rm']) && $_POST['prevorghead_rm'] != '') {
             $posted_prevorghead_rm = $_POST['prevorghead_rm'];
         }
         $orgheadsData = $employeeModal->getEmployeesForOrgHead();
         $emp_data = $employeeModal->fetchRow("is_orghead = 1");
         if (!empty($emp_data)) {
             $user_data = $user_model->fetchRow("id = " . $emp_data->user_id);
             if (!empty($user_data)) {
                 $prevorgheadId = $user_data->id;
             } else {
                 $form->removeElement('prevorghead_rm');
             }
         } else {
             $form->removeElement('prevorghead_rm');
         }
         if ($this->getRequest()->getPost()) {
             if ($form->isValid($this->_request->getPost()) && $flag != 'false') {
                 $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_head', null), 'database');
                 $employeeId = $this->_request->getParam('employeeId', null);
                 $emprole = $this->_request->getParam('emprole', null);
                 $emailaddress = $this->_request->getParam('emailaddress', null);
                 $emppassword = sapp_Global::generatePassword();
                 $first_name = trim($this->_request->getParam('firstname_orghead', null));
                 $last_name = trim($this->_request->getParam('lastname_orghead', null));
                 //$userfullname = trim($this->_request->getParam('orghead',null));
                 $userfullname = $first_name . ' ' . $last_name;
                 $prefix_id = $this->_request->getParam('prefix_id', null);
                 $user_id = $this->_request->getParam('user_id', null);
                 $prevorghead_rm = $this->_request->getParam('prevorghead_rm', null);
                 $prevheadid = $this->_request->getParam('prevheadid', null);
                 $user_data = array('emprole' => $emprole, 'firstname' => $first_name, 'lastname' => $last_name, 'userfullname' => $userfullname, 'emailaddress' => $emailaddress, 'jobtitle_id' => $jobtitle_id, 'emppassword' => md5($emppassword), 'employeeId' => $employeeId, 'selecteddate' => $date_of_joining, 'userstatus' => 'old', 'modeofentry' => 'Direct', 'createdby' => $loginUserId, 'createddate' => gmdate("Y-m-d H:i:s"), 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"), 'isactive' => 1);
                 $emp_data = array('jobtitle_id' => $jobtitle_id, 'position_id' => $position_id, 'prefix_id' => $prefix_id, 'reporting_manager' => 0, 'date_of_joining' => $date_of_joining, 'createdby' => $loginUserId, 'createddate' => gmdate("Y-m-d H:i:s"), 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"), 'isactive' => 1, 'is_orghead' => 1);
                 $org_data = array('modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
                 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;
                 $db = Zend_Db_Table::getDefaultAdapter();
                 $db->beginTransaction();
                 try {
                     $user_id = $user_model->SaveorUpdateUserData($user_data, '');
                     $emp_data['user_id'] = $user_id;
                     $employeeModal->SaveorUpdateEmployeeData($emp_data, '');
                     if (isset($prevheadid) && $prevheadid != '') {
                         $org_data['orghead'] = $user_id;
                         $orgwhere = array('id=?' => $org_id);
                         $orgInfoModel->SaveorUpdateData($org_data, $orgwhere);
                         $orgInfoModel->changeOrgHead($prevheadid, $user_id, $prevorghead_rm);
                         $this->sendmailstoemployees($prevheadid, $user_id);
                     }
                     $tableid = $user_id;
                     $actionflag = 1;
                     $menuID = EMPLOYEE;
                     try {
                         $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid);
                     } catch (Exception $e) {
                         echo $e->getMessage();
                     }
                     $close = 'close';
                     $this->view->popup = $close;
                     $this->view->eventact = 'added';
                     $db->commit();
                 } catch (Exception $e) {
                     $db->rollBack();
                 }
             } else {
                 $messages = $form->getMessages();
                 foreach ($messages as $key => $val) {
                     foreach ($val as $key2 => $val2) {
                         $msgarray[$key] = $val2;
                         break;
                     }
                 }
             }
         }
         $this->view->prevorgheadId = $prevorgheadId;
         $this->view->form = $form;
         $this->view->msgarray = $msgarray;
         $this->view->orgheadsData = $orgheadsData;
         $this->view->posted_prevorghead_rm = $posted_prevorghead_rm;
     } catch (Exception $e) {
         echo $e->getMessage();
         die;
     }
 }
Esempio n. 12
0
 public function organisationinfo($paramsarray)
 {
     if (!empty($paramsarray)) {
         $servicetocall = $paramsarray['service'];
         $role_id = $paramsarray['role_id'];
         $group_id = $paramsarray['group_id'];
         $privilege_flag = sapp_Global::_check_menu_access(ORGANISATIONINFO, $group_id, $role_id);
         if ($privilege_flag == 'Yes') {
             $orgInfoModel = new Default_Model_Organisationinfo();
             $result = $orgInfoModel->getSelecteOrgRecords();
             if (!empty($result)) {
                 $data = array('status' => '1', 'message' => 'Success.', 'result' => $result);
             } else {
                 $data = array('status' => '0', 'message' => 'Organization is not added yet.', 'result' => '');
             }
         } else {
             $data = array('status' => '0', 'message' => 'No data found.', 'result' => '');
         }
         //echo"<pre>";print_r($getorgData[0]);exit;
         return $data;
     }
 }