Ejemplo n.º 1
0
 public function updateBasicInfo($id, $data)
 {
     $mstuser = new Application_Model_DbTable_Mstuser();
     $uRowSet = $mstuser->find($id);
     $return = "";
     if ($uRowSet) {
         //Get bootstrap
         $bootstrap = Zend_Controller_Front::getInstance()->getParam("bootstrap");
         $db = $bootstrap->getPluginResource('db')->getDbAdapter();
         $db->beginTransaction();
         $mstUser = new Application_Model_DbTable_Mstuser();
         $prevUser = $mstUser->getBasicInfo($id);
         $logObj = Zend_Json::encode($prevUser);
         try {
             $uRow = $uRowSet->getRow(0);
             $uRow->login = $data['login'];
             $uRow->role_id = $data['role_id'];
             $uRow->is_temporary_pwd = $data['is_temporary_pwd'];
             $uRow->remarks = $data['remarks'];
             $uRow->is_active = $data['is_active'];
             $uRow->is_blocked = $data['is_blocked'];
             $uRow->blocked_reason = $data['blocked_reason'];
             if ($data['is_blocked'] == 'Y') {
                 $uRow->blocked_date = date('Y-m-d H:i:s');
             }
             $uRow->dolm = date('Y-m-d H:i:s');
             $auth = Zend_Auth::getInstance();
             if ($auth->hasIdentity()) {
                 $authArray = $auth->getIdentity();
                 $userid = $authArray['user_id'];
                 $uRow->modi_by_uid = $userid;
             }
             $uRow->save();
             //--------------Update The Devotee-----------------
             $d = new Application_Model_DbTable_Devotee();
             $did = $uRow->did;
             $dRowSet = $d->find($did);
             if ($dRowSet) {
                 $dRow = $dRowSet->getRow(0);
                 $dRow->email = $data['email'];
                 $dRow->mobile = $data['mobile'];
                 $dRow->country_id = $data['country_id'];
                 $dRow->dolm = date('Y-m-d H:i:s');
                 $auth = Zend_Auth::getInstance();
                 if ($auth->hasIdentity()) {
                     $authArray = $auth->getIdentity();
                     $userid = $authArray['user_id'];
                     $dRow->modibyuid = $userid;
                 }
                 $dRow->save();
             }
             //--------------------UPDATE THE RESOURCES------------------------
             //Check If the Role Has been changed and if changed reassign the resources as per role.
             if ($prevUser['role_id'] != $data['role_id']) {
                 //MstUserVsDatabase.php
                 //-Delete Database-------------
                 $uVsDb = new Application_Model_DbTable_MstUserVsDatabase();
                 $where = $uVsDb->getAdapter()->quoteInto('user_id = ?', $id);
                 $uVsDb->delete($where);
                 //---------------------------------------------------------------
                 //MstUserMethodVsUser.php
                 //-Delete prev methods
                 $uVsMethod = new Application_Model_DbTable_MstUserMethodVsUser();
                 $where = $uVsMethod->getAdapter()->quoteInto('user_id = ?', $id);
                 $uVsMethod->delete($where);
                 //insert new actions from MstUserRoleVsMethod.php
                 $rVsMethod = new Application_Model_DbTable_MstUserRoleVsMethod();
                 $select = $rVsMethod->select();
                 $select->from($rVsMethod, array('method_id'))->where('role_id = ?', $data['role_id']);
                 $rows = $rVsMethod->fetchAll($select);
                 foreach ($rows as $r) {
                     $data = array('user_id' => $id, 'method_id' => $r->method_id);
                     $uVsMethod->insert($data);
                 }
                 //------------------------------------------------------------------
                 //MstUserVsGuru.php.php
                 //-Delete prev gures
                 $uVsGuru = new Application_Model_DbTable_MstUserVsGuru();
                 $where = $uVsGuru->getAdapter()->quoteInto('user_id = ?', $id);
                 $uVsGuru->delete($where);
                 //MstUserVsDevotee.php
                 //-Delete prev devotees
                 $uVsDev = new Application_Model_DbTable_MstUserVsDevotee();
                 $where = $uVsDev->getAdapter()->quoteInto('user_id = ?', $id);
                 $uVsDev->delete($where);
                 //MstUserVsCounselor.php
                 //-Delete prev counselors
                 $uVsCon = new Application_Model_DbTable_MstUserVsCounselor();
                 $where = $uVsCon->getAdapter()->quoteInto('user_id = ?', $id);
                 $uVsCon->delete($where);
                 //MstUserVsCounselor.php
                 //-Delete prev centers
                 $uVsCen = new Application_Model_DbTable_MstUserVsCenter();
                 $where = $uVsCen->getAdapter()->quoteInto('user_id = ?', $id);
                 $uVsCen->delete($where);
                 //MstUserVsAstcounselor.php
                 //-Delete prev mentors
                 $uVsMen = new Application_Model_DbTable_MstUserVsAstcounselor();
                 $where = $uVsMen->getAdapter()->quoteInto('user_id = ?', $id);
                 $uVsMen->delete($where);
             }
             Rgm_UserServices::log($id, 'mst_user', 'Primary Info Updated', $logObj);
             $db->commit();
         } catch (Exception $e) {
             $db->rollBack();
             $return = $e->getMessages();
         }
     } else {
         $return = "User not found in the database.";
     }
     return $return;
 }
Ejemplo n.º 2
0
 public function updatePreliminaryInfo($id, $data)
 {
     $row = $this->fetchRow($this->select()->where('id = ?', $id));
     if ($row) {
         $this->_db->beginTransaction();
         try {
             //-------Check for duplicate login--------------
             $select = $this->_db->select()->from('mst_user', array('count' => new Zend_Db_Expr('COUNT(id)')))->where('login = ?', $data['login'])->where('id <> ?', $id);
             if ($this->_db->fetchOne($select) > 0) {
                 $this->_db->rollBack();
                 return array('user' => null, 'result' => 'DUPLICATE_LOGIN');
             }
             $row->login = $data['login'];
             $row->security_question_id01 = $data['security_question_id01'];
             $row->security_answer01 = $data['security_answer01'];
             $row->security_question_id02 = $data['security_question_id02'];
             $row->security_answer02 = $data['security_answer02'];
             $row->is_temporary_pwd = 'N';
             $row->dolm = date('Y-m-d H:i:s');
             $row->last_pwd_changed_date = date('Y-m-d H:i:s');
             $auth = Zend_Auth::getInstance();
             if ($auth->hasIdentity()) {
                 $authArray = $auth->getIdentity();
                 $userid = $authArray['user_id'];
                 $row->modi_by_uid = $userid;
             }
             $row->save();
             //--------------Update The Devotee-----------------
             $d = new Application_Model_DbTable_Devotee();
             $dRowSet = $d->find($row->did);
             if ($dRowSet) {
                 $dRow = $dRowSet->getRow(0);
                 $dRow->first_name = $data['fName'];
                 $dRow->middle_name = $data['mName'];
                 $dRow->last_name = $data['lName'];
                 $dRow->country_id = $data['country_id'];
                 $dRow->email = $data['email'];
                 $dRow->mobile = $data['mobile'];
                 $dRow->save();
             }
             $this->_db->commit();
             return array('user' => $row, 'result' => 'ok');
         } catch (Exception $e) {
             $this->_db->rollBack();
             return array('user' => null, 'result' => $e->getMessage());
         }
     }
 }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
 public function devoteelistAction()
 {
     $search = $this->getRequest()->getParam('s');
     $dev = new Application_Model_DbTable_Devotee();
     $rs = new stdClass();
     $rs->result = $dev->listIndentificationInfo($search);
     $this->_helper->json($rs);
 }