示例#1
0
 public function editpasswordAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $identity = $auth->getIdentity();
         $id = $identity->id;
         $email = $identity->emailaddress;
         $employeid = $identity->employeeId;
     }
     $password = trim($this->_request->getParam('password'));
     $newpassword = trim($this->_request->getParam('newpassword'));
     $confpassword = trim($this->_request->getParam('passwordagain'));
     $password = preg_replace('/\\s+/', ' ', $password);
     $newpassword = preg_replace('/\\s+/', ' ', $newpassword);
     $confpassword = preg_replace('/\\s+/', ' ', $confpassword);
     $pwd = md5($password);
     $newpwd = md5($newpassword);
     $confpwd = md5($confpassword);
     $loginmodel = new Default_Model_Users();
     $userpassword = $loginmodel->getLoggedInUserPwd($id, $email, $employeid);
     $sespwd = $userpassword['emppassword'];
     $changepasswordform = new Default_Form_changepassword();
     $sitepreferencemodel = new Default_Model_Sitepreference();
     $sitepreferenceArr = $sitepreferencemodel->SitePreferanceData();
     /*
         Pattern Used for alphanumeric expression 
     	   'pattern'=> '/^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]+)$/',
     		  -> Here the first bracket() inside the pattern specifies that atleast one number should be there in the expression.
     		  -> Second bracket() specifies that atleast one alphabet should be present in the expression.
     		  -> Third bracket() specifies the allowed set of characters in the expression.
     		  
     	Pattern Used for alphanumeric and special characters 
     	    'pattern'=> '/^(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[.\-#$@&\_*])([a-zA-Z0-9.\-#$@&\_*]+)$/',
     		  -> Here the first bracket() inside the pattern specifies that atleast one number should be there in the expression.
     		  -> Second bracket() specifies that atleast one alphabet should be present in the expression.
     		  -> Third bracket() specifies that atleast one special character should be present in the expression.
     		  -> Fourth bracket() specifies the allowed set of characters in the expression.
     
                 Pattern Used for numbers and special characters 
     	    'pattern'=> '/^(?=.*[0-9])(?=.*[.\-#$@&\_*])([0-9.\-#$@&\_*]+)$/',
     		  -> Here the first bracket() inside the pattern specifies that atleast one number should be there in the expression.
     		  -> Second bracket() specifies that atleast one special character should be present in the expression.
     		  -> Third bracket() specifies the allowed set of characters in the expression.				  
     */
     if (!empty($sitepreferenceArr)) {
         if ($sitepreferenceArr[0]['passwordid'] == 1) {
             $changepasswordform->newpassword->addValidator("regex", true, array('pattern' => '/^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]+)$/', 'messages' => array('regexNotMatch' => 'Please enter only alphanumeric characters.')));
             $changepasswordform->passwordagain->addValidator("regex", true, array('pattern' => '/^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]+)$/', 'messages' => array('regexNotMatch' => 'Please enter only alphanumeric characters.')));
         } else {
             if ($sitepreferenceArr[0]['passwordid'] == 2) {
                 $changepasswordform->newpassword->addValidator("regex", true, array('pattern' => '/^(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[.\\-#$@&\\_*])([a-zA-Z0-9.\\-#$@&\\_*]+)$/', 'messages' => array('regexNotMatch' => 'Please enter only characters,numbers and special characters.')));
                 $changepasswordform->passwordagain->addValidator("regex", true, array('pattern' => '/^(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[.\\-#$@&\\_*])([a-zA-Z0-9.\\-#$@&\\_*]+)$/', 'messages' => array('regexNotMatch' => 'Please enter only characters,numbers and special characters.')));
             } else {
                 if ($sitepreferenceArr[0]['passwordid'] == 3) {
                     $changepasswordform->newpassword->addValidator("regex", true, array('pattern' => '/^[0-9]+$/', 'messages' => array('regexNotMatch' => 'Please enter numbers only.')));
                     $changepasswordform->passwordagain->addValidator("regex", true, array('pattern' => '/^[0-9]+$/', 'messages' => array('regexNotMatch' => 'Please enter numbers only.')));
                 } else {
                     $changepasswordform->newpassword->addValidator("regex", true, array('pattern' => '/^(?=.*[0-9])(?=.*[.\\-#$@&\\_*])([0-9.\\-#$@&\\_*]+)$/', 'messages' => array('regexNotMatch' => 'Please enter only numbers and special characters.')));
                     $changepasswordform->passwordagain->addValidator("regex", true, array('pattern' => '/^(?=.*[0-9])(?=.*[.\\-#$@&\\_*])([0-9.\\-#$@&\\_*]+)$/', 'messages' => array('regexNotMatch' => 'Please enter only numbers and special characters.')));
                 }
             }
         }
     } else {
         $changepasswordform->newpassword->addValidator("regex", true, array('pattern' => '/^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]+)$/', 'messages' => array('regexNotMatch' => 'Please enter only alphanumeric characters.')));
         $changepasswordform->passwordagain->addValidator("regex", true, array('pattern' => '/^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9]+)$/', 'messages' => array('regexNotMatch' => 'Please enter only alphanumeric characters.')));
     }
     /* Logic ends for site preference password validation
           END
        */
     if ($this->getRequest()->getPost()) {
         if ($changepasswordform->isValid($this->_request->getPost()) && $sespwd == $pwd && $newpwd == $confpwd && $pwd != $newpwd) {
             $loginmodel->editadminPassword($newpwd, $id, $email, $employeid);
             $this->_helper->json(array('result' => 'saved', 'message' => "Password changed successfully."));
         } else {
             $messages = $changepasswordform->getMessages();
             if ($sespwd != $pwd && $password != '') {
                 $messages['password'] = array('Wrong password. Please enter correct password.');
             }
             if ($newpwd != $confpwd && $newpassword != '' && $confpassword != '') {
                 $messages['passwordagain'] = array('New password and confirm password did not match.');
             }
             if ($pwd == $newpwd && $newpassword != '' && $password != '') {
                 $messages['passwordagain'] = array('Please choose a different password.');
             }
             $messages['result'] = 'error';
             $this->_helper->json($messages);
         }
     }
 }
示例#2
0
 public function configuresiteAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     $popConfigPermission = array();
     $msgarray = array();
     $wizardpreferenceform = new Default_Form_wizardpreference();
     $dateformatidmodel = new Default_Model_Dateformat();
     $timeformatidmodel = new Default_Model_Timeformat();
     $currencyidmodel = new Default_Model_Currency();
     $systempreferencemodel = new Default_Model_Sitepreference();
     $orginfomodel = new Default_Model_Organisationinfo();
     $identitycodesmodel = new Default_Model_Identitycodes();
     $employmentstatusmodel = new Default_Model_Employmentstatus();
     $statesmodel = new Default_Model_States();
     $citiesmodel = new Default_Model_Cities();
     $date_formats_arr = array();
     $time_formats_arr = array();
     $passworddataArr = array();
     $currencynameArr = array();
     $countryId = '';
     $stateId = '';
     $cityId = '';
     $new_stateId = '';
     $new_cityId = '';
     $empstatusids = '';
     $timezonemodel = new Default_Model_Timezone();
     $wizard_model = new Default_Model_Wizard();
     $wizardData = $wizard_model->getWizardData();
     /* START
      * Queries to check whether the configuration are already set.
      * If set then prepopulate the fields
      */
     $sitepreferencedata = $systempreferencemodel->SitePreferanceData();
     $orginfodata = $orginfomodel->getOrganisationInfo();
     $empstatusdata = $employmentstatusmodel->getEmploymentStatuslist();
     $identitycodedata = $identitycodesmodel->getIdentitycodesRecord();
     /*
      * END - Checking configuration is set or not.
      */
     $allTimezoneData = $timezonemodel->fetchAll('isactive=1', 'timezone')->toArray();
     if (sapp_Global::_checkprivileges(CURRENCY, $loginuserGroup, $loginuserRole, 'add') == 'Yes') {
         array_push($popConfigPermission, 'currency');
     }
     if (sapp_Global::_checkprivileges(TIMEZONE, $loginuserGroup, $loginuserRole, 'add') == 'Yes') {
         array_push($popConfigPermission, 'timezone');
     }
     try {
         if (!empty($orginfodata)) {
             $countryId = isset($orginfodata[0]['country']) ? $orginfodata[0]['country'] : "";
             $stateId = isset($orginfodata[0]['state']) ? $orginfodata[0]['state'] : "";
             $cityId = isset($orginfodata[0]['city']) ? $orginfodata[0]['city'] : "";
             $wizardpreferenceform->organisationid->setValue($orginfodata[0]['id']);
         } else {
             if (isset($wizardData['country']) && $wizardData['country'] != 'null') {
                 $countryId = $wizardData['country'];
             }
             if (isset($wizardData['state']) && $wizardData['state'] != 'null') {
                 $stateId = $wizardData['state'];
             }
             if (isset($wizardData['city']) && $wizardData['city'] != 'null') {
                 $cityId = $wizardData['city'];
             }
         }
         if (count($_POST) > 0) {
             $countryId = isset($_POST['perm_country']) ? $_POST['perm_country'] : "";
             $stateId = isset($_POST['perm_state']) ? $_POST['perm_state'] : "";
             $cityId = isset($_POST['perm_city']) ? $_POST['perm_city'] : "";
         }
         $date_formats_arr = $dateformatidmodel->getAllDateFormats();
         $time_formats_arr = $timeformatidmodel->fetchAll()->toArray();
         $defaultempstatusdata = $employmentstatusmodel->getCompleteStatuslist();
         $wizardpreferenceform->passwordid->addMultiOption('', 'Select Password Preference');
         $passworddataArr = $systempreferencemodel->getPasswordData();
         foreach ($passworddataArr as $passwordres) {
             $wizardpreferenceform->passwordid->addMultiOption($passwordres['id'], utf8_encode($passwordres['passwordtype']));
         }
         if (sizeof($allTimezoneData) > 0) {
             foreach ($allTimezoneData as $timezoneidres) {
                 $wizardpreferenceform->timezoneid->addMultiOption($timezoneidres['id'], utf8_encode($timezoneidres['timezone'] . ' [' . $timezoneidres['timezone_abbr'] . ']'));
             }
         } else {
             $msgarray['timezoneid'] = 'Time Zone is not configured yet.';
         }
         if (sizeof($defaultempstatusdata) > 0) {
             foreach ($defaultempstatusdata as $empstatusres) {
                 $wizardpreferenceform->workcodename->addMultiOption($empstatusres['id'], utf8_encode($empstatusres['employemnt_status']));
             }
         }
         /* Start  
          * To prepopulate the form if already configured
          */
         if (!empty($sitepreferencedata)) {
             if (isset($sitepreferencedata[0]['dateformatid'])) {
                 $wizardpreferenceform->setDefault('dateformatid', $sitepreferencedata[0]['dateformatid']);
             }
             if (isset($sitepreferencedata[0]['timeformatid'])) {
                 $wizardpreferenceform->setDefault('timeformatid', $sitepreferencedata[0]['timeformatid']);
             }
             if (isset($sitepreferencedata[0]['timezoneid'])) {
                 $wizardpreferenceform->setDefault('timezoneid', $sitepreferencedata[0]['timezoneid']);
             }
             if (isset($sitepreferencedata[0]['passwordid'])) {
                 $wizardpreferenceform->setDefault('passwordid', $sitepreferencedata[0]['passwordid']);
             }
             if (isset($sitepreferencedata[0]['currencyid'])) {
                 $wizardpreferenceform->currencyid->setValue($sitepreferencedata[0]['currencyid']);
                 $currencynameArr = $currencyidmodel->getCurrencyDataByID($sitepreferencedata[0]['currencyid']);
             }
             if (!empty($currencynameArr)) {
                 $wizardpreferenceform->currencyname->setValue($currencynameArr[0]['currencyname']);
                 $wizardpreferenceform->currencycode->setValue($currencynameArr[0]['currencycode']);
             }
         }
         if ($countryId != '') {
             $wizardpreferenceform->setDefault('perm_country', $countryId);
             $statesData = $statesmodel->getStatesList((int) $countryId);
             if (!empty($statesData)) {
                 foreach ($statesData as $res) {
                     if ($stateId == $res['id']) {
                         $new_stateId = $res['id'] . '!@#' . utf8_encode($res['state_name']);
                     }
                     $wizardpreferenceform->perm_state->addMultiOption($res['id'] . '!@#' . utf8_encode($res['state_name']), utf8_encode($res['state_name']));
                 }
                 if (count($_POST) == 0) {
                     $stateId = $new_stateId;
                 }
             }
         }
         if ($stateId != '') {
             $wizardpreferenceform->setDefault('perm_state', $stateId);
             $citiesData = $citiesmodel->getCitiesList((int) $stateId);
             foreach ($citiesData as $res) {
                 if ($cityId == $res['id']) {
                     $new_cityId = $res['id'] . '!@#' . utf8_encode($res['city_name']);
                 }
                 $wizardpreferenceform->perm_city->addMultiOption($res['id'] . '!@#' . utf8_encode($res['city_name']), utf8_encode($res['city_name']));
             }
             if (count($_POST) == 0) {
                 $cityId = $new_cityId;
             }
         }
         if ($cityId != '') {
             $wizardpreferenceform->setDefault('perm_city', $cityId);
         }
         if (!empty($identitycodedata)) {
             $wizardpreferenceform->empcodeid->setValue($identitycodedata[0]['id']);
             $wizardpreferenceform->employee_code->setValue($identitycodedata[0]['employee_code']);
         }
         if (sizeof($empstatusdata) > 0) {
             foreach ($empstatusdata as $empstats) {
                 $empstatusids .= $empstats['workcodename'] . ',';
             }
             $empstatusids = rtrim($empstatusids, ',');
         }
         /*
          * End - Prepopulating data
          */
         $wizardpreferenceform->setAttrib('action', DOMAIN . 'wizard/configuresite');
         $this->view->msgarray = $msgarray;
     } catch (Exception $e) {
         $this->view->nodata = "nodata";
     }
     $this->view->form = $wizardpreferenceform;
     $this->view->date_formats_arr = $date_formats_arr;
     $this->view->time_formats_arr = $time_formats_arr;
     $this->view->passworddata = $passworddataArr;
     $this->view->empstatusids = $empstatusids;
     if ($this->getRequest()->getPost()) {
         $result = $this->savesitepreference($wizardpreferenceform, $wizardData);
         $this->view->msgarray = $result;
     }
     $this->view->popConfigPermission = $popConfigPermission;
     $this->view->wizarddata = $wizardData;
     $this->view->messages = $this->_helper->flashMessenger->getMessages();
 }
示例#3
0
 public function 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);
 }