Exemple #1
0
 public function updateDevoteesList($id, $data)
 {
     $return = "";
     $bootstrap = Zend_Controller_Front::getInstance()->getParam("bootstrap");
     $db = $bootstrap->getPluginResource('db')->getDbAdapter();
     $db->beginTransaction();
     $mstUser = new Application_Model_DbTable_Mstuser();
     $prevUser = $mstUser->getDevoteeList($id, 'CHECKED');
     $logObj = Zend_Json::encode($prevUser);
     try {
         if ($data) {
             //-Delete Devotees-------------
             $uVsDevotees = new Application_Model_DbTable_MstUserVsDevotee();
             $where = $uVsDevotees->getAdapter()->quoteInto('user_id = ?', $id);
             $uVsDevotees->delete($where);
             //-Insert Now
             foreach ($data as $r) {
                 if ($r != 0) {
                     $data = array('user_id' => $id, 'did' => $r);
                     $uVsDevotees->insert($data);
                 }
             }
             Rgm_UserServices::log($id, 'mst_user', 'Devotees list changed', $logObj);
             $db->commit();
             $return = "";
         }
     } catch (Zend_Db_Adapter_Exception $e) {
         $db->rollBack();
         $return = $e->getMessages();
     } catch (Zend_Exception $e) {
         $db->rollBack();
         $return = $e->getMessages();
     } catch (Exception $e) {
         $db->rollBack();
         $return = $e->getMessages();
     }
     return $return;
 }
 public function processAction()
 {
     if (!($form = $this->getCurrentSubForm())) {
         return $this->_forward('addnewdevotee');
     }
     if (!$this->subFormIsValid($form, $this->getRequest()->getPost())) {
         $this->view->form = $this->getForm()->prepareSubForm($form);
         return $this->render('addnewdevotee');
     }
     $form = $this->getNextSubForm();
     if ($form) {
         $this->view->form = $this->getForm()->prepareSubForm($form);
         return $this->render('addnewdevotee');
     }
     Zend_Debug::dump($this->getSessionNamespace());
     $this->view->info = $this->getSessionNamespace();
     $form = new Application_Form_Devotees_AddNewDevotee();
     $form->setName('addnewdevotee');
     $d = new Application_Model_DbTable_Devotee();
     $auth = Zend_Auth::getInstance();
     $authArray = $auth->getIdentity();
     $userid = $authArray['user_id'];
     $u = new Application_Model_DbTable_Mstuser();
     $user = $u->getBasicInfo($userid);
     /*
     This section takes data from the session in
     which data is submitted through subforms of 
     AddNewDevotee form
     */
     $this->info = $this->getSessionNamespace();
     $dev_data = array();
     foreach ($this->info as $info) {
         foreach ($info as $form => $data) {
             foreach ($data as $key => $value) {
                 $dev_data[$key] = $value;
                 // this line gives us devotee data to be inserted in the table.
             }
         }
     }
     /*
     below mentioned is a code
     for renaming the photo
     */
     $fullFilePath = $form->uplphoto->getFileName();
     $fullfilename = pathinfo($fullFilePath);
     $dev_photo_name = $this->getlastdid() . '_' . rand(0, 100) . '.' . $fullfilename['extension'];
     /*
     Below is the data to
     be inserted in devotee table
     */
     //-------------------Date of Birth--------------------------------------
     //if(array_key_exists('birth_day',$dev_data)&&
     //   array_key_exists('birth_month',$dev_data)&&
     //   array_key_exists('birth_year',$dev_data)){
     $birthdatearray = array('year' => $dev_data['birth_year'], 'month' => $dev_data['birth_month'], 'day' => $dev_data['birth_day']);
     //}
     $birthdate = new Zend_Date($birthdatearray);
     //-------------------Date of Begining of chanting------------------------
     //if(array_key_exists('bgn_chan_from_day',$dev_data)&&
     //   array_key_exists('bgn_chan_from_month',$dev_data)&&
     //   array_key_exists('bgn_chan_from_year',$dev_data)){
     $bgn_chan_from_datearray = array('year' => $dev_data['bgn_chan_from_year'], 'month' => $dev_data['bgn_chan_from_month'], 'day' => $dev_data['bgn_chan_from_year']);
     //}
     $bgn_chan_from_date = new Zend_Date($bgn_chan_from_datearray);
     //-------------------Date of Begining of 16 rounds chanting---------------
     //if(array_key_exists('chan_16_rounds_year',$dev_data)&&
     //   array_key_exists('chan_16_rounds_month',$dev_data)&&
     //   array_key_exists('chan_16_rounds_year',$dev_data)){
     $chan_16_rounds_datearray = array('year' => $dev_data['chan_16_rounds_year'], 'month' => $dev_data['chan_16_rounds_month'], 'day' => $dev_data['chan_16_rounds_day']);
     //}
     $chan_16_rounds_date = new Zend_Date($chan_16_rounds_datearray);
     //-------------------Date of harinam initiation---------------------------
     //if(array_key_exists('harinam_initiatn_day',$dev_data)&&
     //   array_key_exists('harinam_initiatn_month',$dev_data)&&
     //   array_key_exists('harinam_initiatn_year',$dev_data)){
     $harinam_initiatn_datearray = array('year' => $dev_data['harinam_initiatn_year'], 'month' => $dev_data['harinam_initiatn_month'], 'day' => $dev_data['harinam_initiatn_day']);
     //}
     $harinam_initiatn_date = new Zend_Date($harinam_initiatn_datearray);
     //-------------------Date of brahman initiation------------------------
     //if(array_key_exists('date_of_brahman_initiation',$dev_data)&&
     //   array_key_exists('brahman_initiation_month',$dev_data)&&
     //   array_key_exists('brahman_initiation_year',$dev_data)){
     $brahman_initiation_datearray = array('year' => $dev_data['brahman_initiation_year'], 'month' => $dev_data['brahman_initiation_month'], 'day' => $dev_data['date_of_brahman_initiation']);
     //}
     $brahman_initiation_date = new Zend_Date($brahman_initiation_datearray);
     //-------------------Date of sanyas_initiation------------------------
     //if(array_key_exists('sanyas_initiation_day',$dev_data)&&
     //   array_key_exists('sanyas_initiation_month',$dev_data)&&
     //   array_key_exists('sanyas_initiation_year',$dev_data)){
     $sanyas_initiation_datearray = array('year' => $dev_data['sanyas_initiation_year'], 'month' => $dev_data['sanyas_initiation_month'], 'day' => $dev_data['sanyas_initiation_day']);
     //}
     $sanyas_initiation_date = new Zend_Date($sanyas_initiation_datearray);
     $devotee_data = array('pics' => $dev_photo_name, 'first_name' => $dev_data['first_name'], 'middle_name' => $dev_data['middle_name'], 'last_name' => $dev_data['last_name'], 'do_birth' => $birthdate->toString('yyyyMMddHHmmss'), 'gender' => $dev_data['gender'], 'country_id' => $dev_data['cc'], 'center_id' => $dev_data['center'], 'counselor_id' => $dev_data['counselor'], 'mobile' => $dev_data['mobile'], 'email' => $dev_data['email'], 'pres_phone' => $dev_data['phone_number'], 'devotee_status' => $dev_data['active_status'], 'asram_status_id' => $dev_data['marital_status'], 'mother_tongue_id' => $dev_data['mother_tongue'], 'counselee_status' => $dev_data['counselee_status'], 'blood_group' => $dev_data['bld_grp'], 'religion_id' => $dev_data['previous_religion'], 'native_place' => $dev_data['native_place'], 'native_state_id' => $dev_data['native_state'], 'pres_add1' => $dev_data['present_addline1'], 'pres_add2' => $dev_data['present_addline2'], 'pres_locality_id' => $dev_data['present_locality'], 'pres_pin' => $dev_data['present_zip_code'], 'pres_city_id' => $dev_data['present_city'], 'pres_state_id' => $dev_data['present_state'], 'pres_country_id' => $dev_data['present_country'], 'perm_add1' => $dev_data['permenant_addline1'], 'perm_add2' => $dev_data['permenant_addline2'], 'perm_locality_id' => $dev_data['permenant_locality'], 'perm_pin' => $dev_data['permenant_zip_code'], 'perm_city_id' => $dev_data['permenant_city'], 'perm_state_id' => $dev_data['permenant_state'], 'perm_country_id' => $dev_data['permenant_country'], 'perm_phone' => $dev_data['phone_number'], 'father_name' => $dev_data['father_name'], 'mother_name' => $dev_data['mother_name'], 'isgurukuli' => $dev_data['gurukuli'], 'edu_cat_id' => $dev_data['highest_education'], 'education_qualification' => $dev_data['education_description'], 'occupation_id' => $dev_data['occupation'], 'designation' => $dev_data['designation'], 'merits' => $dev_data['merits_awards'], 'skill_set' => $dev_data['skill_sets'], 'off_name' => $dev_data['office_name'], 'off_add1' => $dev_data['office_address_line1'], 'off_add2' => $dev_data['office_address_line2'], 'off_locality_id' => $dev_data['office_locality'], 'off_city_id' => $dev_data['office_city'], 'off_state_id' => $dev_data['office_state'], 'off_country_id' => $dev_data['office_country'], 'off_pin' => $dev_data['office_zip_code'], 'off_phone' => $dev_data['office_phone'], 'chanting_started' => $bgn_chan_from_date->toString('yyyyMMddHHmmss'), 'chk_chant_start' => $dev_data['bgn_chan_from_na'], 'no_of_rounds' => $dev_data['no_rou_pres_chanting'], 'chanting_16_started' => $chan_16_rounds_date->toString('yyyyMMddHHmmss'), 'intro_by' => $dev_data['intro_by'], 'intro_year' => $dev_data['year_introduction'], 'intro_center' => $dev_data['intro_center'], 'chk_date_harinam' => $dev_data['harinam_initiatn_na'], 'do_harinaminit' => $harinam_initiatn_date->toString('yyyyMMddHHmmss'), 'chk_date_brahmin' => $dev_data['brahman_initiated_na'], 'do_brahmininit' => $brahman_initiation_date->toString('yyyyMMddHHmmss'), 'ini_guru_id' => $dev_data['sanyas_spiritual_master'], 'chk_date_sanyas' => $dev_data['sanyas_initiation_day'], 'do_sanyasinit' => $sanyas_initiation_date->toString('yyyyMMddHHmmss'), 'sanyas_name' => $dev_data['sanyas_name'], 'sanyas_title' => $dev_data['sanyas_title'], 'sanyas_guru_id' => $dev_data['sanyas_spiritual_master'], 'spiritualname_sanyas_id' => $dev_data['sanyas_name'], 'remarks' => $dev_data['remarks'], 'user_id' => $user['id'], 'isactive' => $user['is_active'], 'entered_date' => Zend_Date::now()->toString('yyyyMMddHHmmss'), 'dolm' => $user['dolm'], 'modibyuid' => $user['modi_by_uid'], 'entered_by_uid' => $user['entered_by_uid'], 'do_verify' => Zend_Date::now()->toString('yyyyMMddHHmmss'));
     $did = $d->insert($devotee_data);
     $this->view->lastrecordinserted = $did;
     $this->render('verification');
     //Clear the session data
     Zend_Session::namespaceUnset($this->_namespace);
 }
Exemple #3
0
 private function isTemporaryPwd($userId)
 {
     $user = new Application_Model_DbTable_Mstuser();
     return $user->isTemporaryPwd($userId);
 }
 public function editbasicAction()
 {
     $do = 'editbasic';
     $message = '';
     if ($this->getRequest()->getParam('do')) {
         $do = $this->getRequest()->getParam('do');
     }
     $id = $this->_getParam('id', 0);
     $u = new Application_Model_DbTable_Mstuser();
     $user = $u->getBasicInfo($id);
     $this->view->u = $user;
     $this->view->id = $id;
     $form = new Admin_Form_User_EditBasic();
     $form->setName('edituserbasic');
     $htmlStringBg = '';
     if ($do == 'editbasic') {
         $form->getElement('id')->setValue($id);
         $form->getElement('userId')->setValue($user['login']);
         $form->getElement('role')->setValue($user['role_id']);
         $form->getElement('email')->setValue($user['email']);
         $form->getElement('country')->setValue($user['country_id']);
         $form->getElement('mobile')->setValue($user['mobile']);
         $form->getElement('active')->setValue($user['is_active']);
         $form->getElement('temporaryPwd')->setValue($user['is_temporary_pwd']);
         $form->getElement('blocked')->setValue($user['is_blocked']);
         $form->getElement('blockedReason')->setValue($user['blocked_reason']);
         $form->getElement('remarks')->setValue($user['remarks']);
     } else {
         if ($do == 'savebasic') {
             if ($form->isValid($this->getRequest()->getPost())) {
                 /*Save the info*/
                 $data = array('login' => $this->getRequest()->getPost('userId'), 'role_id' => $this->getRequest()->getPost('role'), 'email' => $this->getRequest()->getPost('email'), 'mobile' => $this->getRequest()->getPost('mobile'), 'is_temporary_pwd' => $this->getRequest()->getPost('temporaryPwd'), 'country_id' => $this->getRequest()->getPost('country'), 'remarks' => $this->getRequest()->getPost('remarks'), 'is_active' => $this->getRequest()->getPost('active'), 'is_blocked' => $this->getRequest()->getPost('blocked'), 'blocked_reason' => $this->getRequest()->getPost('blockedReason'));
                 $id = $this->getRequest()->getParam('id');
                 $userModel = new Admin_Model_User();
                 $message = $userModel->updateBasicInfo($id, $data);
                 if ($message == '') {
                     //Successfull
                     $message = 'Successfully updated.';
                     $user = $u->getBasicInfo($id);
                     //Refresh the background page
                     $this->view->u = $user;
                     $htmlStringBg = $this->view->render('user/viewbasic.ajax.phtml');
                 }
             }
         }
     }
     $this->view->form = $form;
     $htmlString = $this->view->render('user/editbasic.phtml');
     $rs = new stdClass();
     $rs->do = $do;
     $rs->debug = $this->getRequest()->getPost();
     $rs->message = $message;
     $rs->htmlBody = $htmlString;
     $rs->htmlBodyBg = $htmlStringBg;
     $this->_helper->json($rs);
 }
Exemple #5
0
 public function hasAccessToMethod($method)
 {
     if ($this->_roleId == Rgm_Constants::ROLE_ADMIN) {
         return true;
     }
     $user = new Application_Model_DbTable_Mstuser();
     return $user->hasAccessToMethod($method, $this->_userId);
 }
 public function accountsettingsAction()
 {
     $this->getHelper("layout")->setLayout('layout_no_sidebar');
     $messages = '';
     $form = new Application_Form_AccountSetings();
     $form->setAction('accountsettings');
     $form->setMethod('post');
     $this->view->form = $form;
     //Save button pushed in accountsetting page
     if ($this->getRequest()->isPost() && $this->getRequest()->getPost('pageId') == 'accountsetings') {
         $valid = true;
         //Validate the form
         if (!$form->isValid($this->getRequest()->getPost())) {
             return;
         }
         //Validate the Security Question
         $country = $this->getRequest()->getPost('country');
         if ($country == 0 || $country == '') {
             $form->getElement('country')->addError('Select country');
             $valid = false;
         }
         $securityQ01 = $this->getRequest()->getPost('securityQ01');
         if ($securityQ01 == 0 || $securityQ01 == '') {
             $form->getElement('securityQ01')->addError('Select a security question');
             $valid = false;
         }
         $securityQ02 = $this->getRequest()->getPost('securityQ02');
         if ($securityQ02 == 0 || $securityQ02 == '') {
             $form->getElement('securityQ02')->addError('Select a security question');
             $valid = false;
         }
         if ($securityQ01 != 0 && $securityQ01 != '' && $securityQ01 == $securityQ02) {
             $form->getElement('securityQ01')->addError('Both security questions are identical. Select different one');
             $form->getElement('securityQ02')->addError('Both security questions are identical. Select different one');
             $valid = false;
         }
         if (!$valid) {
             return;
         }
         //Update the useraccount now
         $fName = $this->getRequest()->getPost('fName');
         $mName = $this->getRequest()->getPost('mName');
         $lName = $this->getRequest()->getPost('lName');
         $email = $this->getRequest()->getPost('email');
         $mobile = $this->getRequest()->getPost('mobile');
         $userName = $this->getRequest()->getPost('userName');
         $securityA01 = $this->getRequest()->getPost('securityA01');
         $securityA02 = $this->getRequest()->getPost('securityA02');
         $auth = Zend_Auth::getInstance();
         $authArray = $auth->getIdentity();
         $userid = $authArray['user_id'];
         $mstUser = new Application_Model_DbTable_Mstuser();
         $prevData = Zend_Json::encode($mstUser->findById($userid));
         $data = array('fName' => $fName, 'mName' => $mName, 'lName' => $lName, 'email' => $email, 'country_id' => $country, 'login' => $userName, 'mobile' => $mobile, 'security_question_id01' => $securityQ01, 'security_answer01' => $securityA01, 'security_question_id02' => $securityQ02, 'security_answer02' => $securityA02);
         $result = $mstUser->updatePreliminaryInfo($userid, $data);
         if ($result) {
             if ($result['result'] == 'ok') {
                 $messages = 'Changes saved successfully.';
             } else {
                 if ($result['result'] == 'DUPLICATE_LOGIN') {
                     $messages = 'User id already exists in the database.';
                     $form->getElement('userName')->addError($messages);
                 } else {
                     $messages = 'Error occured while saveing the changes.';
                 }
             }
         }
         Rgm_UserServices::log($userid, 'mst_user', 'Preliminary Information Changed', $prevData);
     } else {
         //Populate the form with default values
         $auth = Zend_Auth::getInstance();
         $authArray = $auth->getIdentity();
         $userid = $authArray['user_id'];
         $mstUser = new Application_Model_DbTable_Mstuser();
         if ($user = $mstUser->findById($userid)) {
             $form->getElement('fName')->setValue($user->first_name);
             $form->getElement('mName')->setValue($user->middle_name);
             $form->getElement('lName')->setValue($user->last_name);
             $form->getElement('userName')->setValue($user->login);
             $form->getElement('email')->setValue($user->email);
             $form->getElement('country')->setValue($user->country_id);
             $form->getElement('mobile')->setValue($user->mobile);
             $form->getElement('securityQ01')->setValue($user->security_question_id01);
             $form->getElement('securityA01')->setValue($user->security_answer01);
             $form->getElement('securityQ02')->setValue($user->security_question_id02);
             $form->getElement('securityA02')->setValue($user->security_answer02);
         }
     }
     $this->view->messages = $messages;
 }