Server IP : 103.191.208.50 / Your IP : 216.73.216.53 Web Server : LiteSpeed System : Linux orion.herosite.pro 4.18.0-553.53.1.lve.el8.x86_64 #1 SMP Wed May 28 17:01:02 UTC 2025 x86_64 User : celkcksm ( 1031) PHP Version : 7.4.33 Disable Function : show_source, system, shell_exec, passthru, popen, exec MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home/celkcksm/ecampus.ncriptech.com/application/controllers/admin/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php defined('BASEPATH') OR exit('No direct script access allowed'); /** * */ class Accounts extends BaseAdminController { public $db_group=''; function __construct() { parent::__construct(); $userdata=$this->data['userdata']; $this->db_group=$userdata->user_code; } function index(){ if(!session_userdata('isAdminLoggedin')){ $this->data['page_title']='Login'; if(!empty($this->data['system_links'])){ $instdata=$this->um->_get_user(array('user_id'=>$this->data['system_links']->link_inst_id)); if($instdata->user_type=='institute'){ $inst_data=$this->um->get_user(array('user_id'=>$instdata->user_id),'institute'); $inst_name=$inst_data->user_profile_name; }else if($instdata->user_type=='institute_branch'){ $inst_data=$this->um->get_user(array('user_id'=>$instdata->user_id),'institute_branch'); $inst_name=$inst_data->branch_name; } }else{ $inst_name=''; } $this->data['inst_name']=$inst_name; $this->theme->title($this->data['page_title'])->load('accounts/vw_login', $this->data); } else{ redirect($this->data['base_url'].'/dashboard'); } } public function indexAccount(){ if(session_userdata('isAdminLoggedin')){ $this->data['page_title']='My Profile'; $check_institute=check_institute($this->data['userdata']); $_countries=array(); $countries=$this->sm->_get_countries(null,FALSE); $states=$this->sm->_get_states(null,FALSE); if(!empty($states)){ foreach ($states as $key => $value) { $_states[]=array( 'state_id'=>$value->state_id, 'state_name'=>$value->state_name, 'cur_selected'=>($this->data['userdata']->stu_cur_state==$value->state_id)?'selected':'', 'perma_selected'=>($this->data['userdata']->stu_perma_state==$value->state_id)?'selected':'' ); } } $this->data['states']=$_states; if($check_institute['user_type']=='student'){ $student_id=$this->data['userdata']->user_id; $_religions=array(); $_caste_category=array(); $_blood_groups=array(); $_occupations=array(); $blood_groups=$this->sm->_get_blood_groups(null,FALSE); $occupations=$this->sm->_get_occupations(null,FALSE); $religions=$this->cst->get_religion(null,FALSE); if(!empty($occupations)){ foreach ($occupations as $key => $value) { $_occupations[]=array( 'occupation_id'=>$value->occupation_id, 'occupation_name'=>$value->occupation_name, 'father_occupation'=>($this->data['userdata']->stu_father_occupation==$value->occupation_id)?'selected':'', 'mother_occupation'=>($this->data['userdata']->stu_mother_occupation==$value->occupation_id)?'selected':'', 'guardian_occupation'=>($this->data['userdata']->stu_guardian_occupation==$value->occupation_id)?'selected':'' ); } } $this->data['occupations']=$_occupations; if(!empty($countries)){ foreach ($countries as $key => $value) { $_countries[]=array( 'country_id'=>$value->country_id, 'country_nationality'=>$value->country_nationality, 'selected'=>($this->data['userdata']->stu_nationality==$value->country_id)?'selected':'' ); } } $this->data['countries']=$_countries; if(!empty($blood_groups)){ foreach ($blood_groups as $key => $value) { $_blood_groups[]=array( 'blood_group_id'=>$value->blood_group_id, 'blood_group_name'=>$value->blood_group_name, 'selected'=>($this->data['userdata']->stu_blood_group==$value->blood_group_name)?'selected':'' ); } } $this->data['blood_groups']=$_blood_groups; $caste_category=$this->cst->get_caste_category(null,FALSE); if(!empty($caste_category)){ foreach ($caste_category as $key => $value) { $_caste_category[]=array( 'caste_id'=>$value->caste_id, 'caste_name'=>$value->caste_name, 'selected'=>($this->data['userdata']->stu_caste==$value->caste_id)?'selected':'' ); } } $this->data['caste_category']=$_caste_category; if(!empty($religions)){ foreach ($religions as $key => $value) { $_religions[]=array( 'reiligion_id'=>$value->reiligion_id, 'religion_name'=>$value->religion_name, 'selected'=>($this->data['userdata']->stu_religion==$value->reiligion_id)?'selected':'' ); } } $this->data['religions']=$_religions; $this->data['genders']=array( 'Male'=>($this->data['userdata']->stu_gender=='male')?'selected':'', 'Female'=>($this->data['userdata']->stu_gender=='female')?'selected':'', 'Other'=>($this->data['userdata']->stu_gender=='other')?'selected':'', ); $this->data['academic_details']=$this->um->get_students_academics(array('acad_stu_id'=>$student_id)); $aadhar_file=$this->sm->get_file(array('storage_type'=>'aadhar_card','storage_type_id'=>$student_id)); $madhyamik_admit_card_file=$this->sm->get_file(array('storage_type'=>'madhyamik_admit_card','storage_type_id'=>$student_id)); $madhyamik_result_card_file=$this->sm->get_file(array('storage_type'=>'madhyamik_result_card','storage_type_id'=>$student_id)); $madhyamik_rank_card_file=$this->sm->get_file(array('storage_type'=>'madhyamik_rank_card','storage_type_id'=>$student_id)); $twelfth_result_card_file=$this->sm->get_file(array('storage_type'=>'12th_result_card','storage_type_id'=>$student_id)); $grad_result_card_file=$this->sm->get_file(array('storage_type'=>'grad_result_card','storage_type_id'=>$student_id)); $post_grad_result_card_file=$this->sm->get_file(array('storage_type'=>'post_grad_result_card','storage_type_id'=>$student_id)); $other_certificate_card_file=$this->sm->get_file(array('storage_type'=>'other_certificate_card','storage_type_id'=>$student_id)); $student_profile_photo_file=$this->sm->get_file(array('storage_type'=>'student_profile_photo','storage_type_id'=>$student_id)); $student_signature_photo_file=$this->sm->get_file(array('storage_type'=>'student_signature_photo','storage_type_id'=>$student_id)); $madhyamik_registration_card_file=$this->sm->get_file(array('storage_type'=>'madhyamik_registration_card','storage_type_id'=>$student_id)); //print_obj($aadhar_file);die; if(!empty($aadhar_file)){ //echo FCPATH.$aadhar_file->media_disk_path;die; if(file_exists(FCPATH.$aadhar_file->media_disk_path)){ $aadhar_card=($aadhar_file->media_mime=='application/pdf')?base_url('uploads/app/pdf.png'):base_url($aadhar_file->media_disk_path_relative); }else{ $aadhar_card=$this->data['no_image']; } }else{ $aadhar_card=$this->data['no_image']; } if(!empty($madhyamik_result_card_file)){ if(file_exists(FCPATH.$madhyamik_result_card_file->media_disk_path)){ $madhyamik_result_card=($madhyamik_result_card_file->media_mime=='application/pdf')?base_url('uploads/app/pdf.png'):base_url($madhyamik_result_card_file->media_disk_path_relative); }else{ $madhyamik_result_card=$this->data['no_image']; } }else{ $madhyamik_result_card=$this->data['no_image']; } if(!empty($other_certificate_card_file)){ if(file_exists(FCPATH.$other_certificate_card_file->media_disk_path)){ $other_certificate_card=($other_certificate_card_file->media_mime=='application/pdf')?base_url('uploads/app/pdf.png'):base_url($other_certificate_card_file->media_disk_path_relative); }else{ $other_certificate_card=$this->data['no_image']; } }else{ $other_certificate_card=$this->data['no_image']; } if(!empty($twelfth_result_card_file)){ if(file_exists(FCPATH.$twelfth_result_card_file->media_disk_path)){ $twelft_result=($twelfth_result_card_file->media_mime=='application/pdf')?base_url('uploads/app/pdf.png'):base_url($twelfth_result_card_file->media_disk_path_relative); }else{ $twelft_result=$this->data['no_image']; } }else{ $twelft_result=$this->data['no_image']; } if(!empty($grad_result_card_file)){ if(file_exists(FCPATH.$grad_result_card_file->media_disk_path)){ $grad_result=($grad_result_card_file->media_mime=='application/pdf')?base_url('uploads/app/pdf.png'):base_url($grad_result_card_file->media_disk_path_relative); }else{ $grad_result=$this->data['no_image']; } }else{ $grad_result=$this->data['no_image']; } if(!empty($post_grad_result_card_file)){ if(file_exists(FCPATH.$post_grad_result_card_file->media_disk_path)){ $post_grad_result=($post_grad_result_card_file->media_mime=='application/pdf')?base_url('uploads/app/pdf.png'):base_url($post_grad_result_card_file->media_disk_path_relative); }else{ $post_grad_result=$this->data['no_image']; } }else{ $post_grad_result=$this->data['no_image']; } if(!empty($madhyamik_registration_card_file)){ if(file_exists(FCPATH.$madhyamik_registration_card_file->media_disk_path)){ $reg_card_10th=($madhyamik_registration_card_file->media_mime=='application/pdf')?base_url('uploads/app/pdf.png'):base_url($madhyamik_registration_card_file->media_disk_path_relative); }else{ $reg_card_10th=$this->data['no_image']; } }else{ $reg_card_10th=$this->data['no_image']; } if(!empty($student_profile_photo_file)){ if(file_exists(FCPATH.$student_profile_photo_file->media_disk_path)){ $profile_photo=($student_profile_photo_file->media_mime=='application/pdf')?base_url('uploads/app/pdf.png'):base_url($student_profile_photo_file->media_disk_path_relative); }else{ $profile_photo=$this->data['no_image']; } }else{ $profile_photo=$this->data['no_image']; } if(!empty($student_signature_photo_file)){ if(file_exists(FCPATH.$student_signature_photo_file->media_disk_path)){ $signature_photo=($student_signature_photo_file->media_mime=='application/pdf')?base_url('uploads/app/pdf.png'):base_url($student_signature_photo_file->media_disk_path_relative); }else{ $signature_photo=$this->data['no_image']; } }else{ $signature_photo=$this->data['no_image']; } if(!empty($madhyamik_admit_card_file)){ if(file_exists(FCPATH.$madhyamik_admit_card_file->media_disk_path)){ $admit_card_10th=($madhyamik_admit_card_file->media_mime=='application/pdf')?base_url('uploads/app/pdf.png'):base_url($madhyamik_admit_card_file->media_disk_path_relative); }else{ $admit_card_10th=$this->data['no_image']; } }else{ $admit_card_10th=$this->data['no_image']; } $seat_booking_data=$this->adm->get_seat_bookings_data(array('booking_stu_profile_id'=>$this->data['userdata']->stu_id)); //print_obj($seat_booking_data);die; //echo $student_id;die; if(!empty($seat_booking_data)){ $session_course_data=$this->sessm->get_session_courses(array('session_id'=>$seat_booking_data->booking_sess_id,'session_course_id'=>$seat_booking_data->booking_course_id,'session_inst_id'=>$seat_booking_data->booking_inst_id)); $payment_details=$this->fm->get_payment_details(array('details_stu_id'=>$student_id,'details_type'=>'seat_booking','details_payment_type'=>'seatbooking_fees','details_order_code'=>$seat_booking_data->booking_code)); $_seat_booking_data=array( 'student_code'=>$seat_booking_data->stu_user_code, 'booking_id'=>$seat_booking_data->booking_id, 'booking_code'=>$seat_booking_data->booking_code, 'course_name'=>$seat_booking_data->course_name, 'course_fees'=>(!empty($session_course_data))?number_format($session_course_data->session_course_fees,2):'', 'booking_payment'=>number_format($seat_booking_data->booking_payment), 'paid_amount'=>(!empty($payment_details) && $seat_booking_data->booking_payment_paid=='yes')?number_format($payment_details->details_amount,2):'0.00', 'details_id'=>(!empty($payment_details))?$payment_details->details_id:'', 'session_data'=>$seat_booking_data->session_start_year.'-'.$seat_booking_data->session_end_year, 'booking_data'=>date('d-m-Y',strtotime($seat_booking_data->created_at)), 'payment_date'=>(!empty($payment_details))?date('d-m-Y',strtotime($payment_details->details_created_at)):'--', 'payment_paid'=>$seat_booking_data->booking_payment_paid ); }else{ $_seat_booking_data=array(); } //print_obj($_SESSION);die; if(session_userdata('payment_error')){ $this->data['payment_error']=session_userdata('payment_error'); }else{ $this->data['payment_error']=''; } //print_obj($this->data);die; $this->data['aadhar_card']=$aadhar_card; $this->data['profile_photo']=$profile_photo; $this->data['signature_photo']=$signature_photo; $this->data['admit_card_10th']=$admit_card_10th; $this->data['reg_card_10th']=$reg_card_10th; $this->data['madhyamik_result_card']=$madhyamik_result_card; $this->data['twelft_result']=$twelft_result; $this->data['grad_result']=$grad_result; $this->data['post_grad_result']=$post_grad_result; $this->data['other_certificate_card']=$other_certificate_card; $this->data['booking_data']=$_seat_booking_data; $this->data['tenth_boards']= $this->config->item('tenth_boards'); $this->data['twelfth_boards']= $this->config->item('twelfth_boards'); //print_obj($_seat_booking_data);die; $profile='accounts/vw_student_profile'; }else if($check_institute['user_type']=='agent'){ $agent_id=$this->data['userdata']->user_id; $this->data['agent_data']=$this->data['userdata']; //print_obj($this->data['agent_data']);die; $aadhar_file=$this->sm->get_file(array('storage_type'=>'aadhar_card','storage_type_of'=>'agent','storage_type_id'=>$agent_id)); $profile_photo_file=$this->sm->get_file(array('storage_type'=>'profile_photo','storage_type_of'=>'agent','storage_type_id'=>$agent_id)); $pan_card_file=$this->sm->get_file(array('storage_type'=>'pan_card','storage_type_of'=>'agent','storage_type_id'=>$agent_id)); if(!empty($aadhar_file)){ if(file_exists(FCPATH.$aadhar_file->media_disk_path)){ $aadhar_card=($aadhar_file->media_mime=='application/pdf')?base_url('uploads/app/pdf.png'):base_url($aadhar_file->media_disk_path_relative); }else{ $aadhar_card=$this->data['no_image']; } }else{ $aadhar_card=$this->data['no_image']; } if(!empty($profile_photo_file)){ if(file_exists(FCPATH.$profile_photo_file->media_disk_path)){ $profile_photo=($profile_photo_file->media_mime=='application/pdf')?base_url('uploads/app/pdf.png'):base_url($profile_photo_file->media_disk_path_relative); }else{ $profile_photo=$this->data['no_image']; } }else{ $profile_photo=$this->data['no_image']; } if(!empty($pan_card_file)){ if(file_exists(FCPATH.$pan_card_file->media_disk_path)){ $pan_card=($pan_card_file->media_mime=='application/pdf')?base_url('uploads/app/pdf.png'):base_url($pan_card_file->media_disk_path_relative); }else{ $pan_card=$this->data['no_image']; } }else{ $pan_card=$this->data['no_image']; } $this->data['aadhar_card']=$aadhar_card; $this->data['profile_photo']=$profile_photo; $this->data['pan_card']=$pan_card; $profile='accounts/vw_agent_profile'; } else{ $profile='accounts/vw_profile'; } //print_obj($this->data);die; $this->theme->title($this->data['page_title'])->load($profile, $this->data); }else{ redirect($this->data['base_url']); } } public function indexAccountBooking(){ $segment_1=$this->uri->segment(1,0); $segment_3=$this->uri->segment(3,0); if($segment_3!='0'){ $booking_code=decode_data($segment_3); $invd=$this->fm->get_seat_booking_payment_details(array('booking_code'=>$booking_code)); if(!empty($invd)){ $student_data=$this->um->get_user(array('stu_id'=>$invd->booking_stu_profile_id),'student'); $session_data=array( 'isAdminLoggedin'=>true, 'admin_id'=>encode_data($student_data->user_id), 'admin_type'=>$student_data->user_type, 'loggedin_time'=>time() ); //print_obj($session_data);die; session_set_userdata($session_data); redirect($this->data['base_url'].'/account'); }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } } public function onLogin_v1(){ if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){ $username = post_data('username'); $password = post_data('password'); $code = post_data('url_code'); $userdata = $this->um->_get_user(array('user_name'=>$username)); if($userdata!='' && ($userdata->user_status=='active')){ if(in_array($userdata->user_type, array('institute','institute_branch','agent','student','employee'))){ $system_links=$this->sm->_get_system_links(array('link_code'=>$code,'link_status'=>'active')); if(!empty($system_links)){ if($userdata->user_type=='institute'){ $inst_data=$this->um->get_user(array('user_id'=>$userdata->user_id),'institute'); $user_code=$inst_data->user_code; }else if($userdata->user_type=='institute_branch'){ $branch_inst_data=$this->um->get_user(array('user_id'=>$userdata->user_id),'institute_branch'); $inst_data=$this->um->get_user(array('user_id'=>$branch_inst_data->branch_parent_inst_id),'institute'); $user_code=strtolower($branch_inst_data->branch_code); }else if($userdata->user_type=='agent'){ $agent_data=$this->um->get_user(array('user_id'=>$userdata->user_id),'agent'); $inst_type=$agent_data->agent_inst_type; $inst_data=$this->um->get_user(array('user_id'=>$agent_data->agent_inst_id),$inst_type); if($inst_data->user_type=='institute_branch'){ $user_code=strtolower($inst_data->branch_code); }else if($inst_data->user_type=='institute'){ $user_code=$inst_data->user_code; } }else if($userdata->user_type=='student'){ $stu_data=$this->um->get_user(array('user_id'=>$userdata->user_id),'student'); $inst_type=$stu_data->stu_inst_type; $inst_data=$this->um->get_user(array('user_id'=>$stu_data->stu_inst_id),$inst_type); if($inst_data->user_type=='institute_branch'){ $user_code=strtolower($inst_data->branch_code); }else if($inst_data->user_type=='institute'){ $user_code=$inst_data->user_code; } }else if($userdata->user_type=='employee'){ $employee_data=$this->um->get_user(array('user_id'=>$userdata->user_id),'employee'); $inst_type=$employee_data->emp_inst_type; $inst_data=$this->um->get_user(array('user_id'=>$employee_data->emp_inst_id),$inst_type); if($inst_data->user_type=='institute_branch'){ $user_code=strtolower($inst_data->branch_code); }else if($inst_data->user_type=='institute'){ $user_code=$inst_data->user_code; } } if($user_code==$code){ if($userdata->is_deleted=='no'){ if(password_verify($password,$userdata->user_password)){ $session_data=array( 'isAdminLoggedin'=>true, 'admin_id'=>encode_data($userdata->user_id), 'admin_type'=>$userdata->user_type, 'admin_db_group'=>encode_data($userdata->user_code), 'loggedin_time'=>time(), ); session_set_userdata($session_data); if($userdata->user_type=='student'){ $redirect_to='account'; }else{ $redirect_to='dashboard'; } $log_user_type=$userdata->user_type; $log_user_id=$userdata->user_id; $log_details_type='user_login'; $log_details=json_encode(array('user_name'=>$username)); $log_data=compact('log_user_type','log_user_id','log_details_type','log_details'); create_log($log_data); $return['redirect'] = $this->data['base_url'].'/'.$redirect_to; $return['success']='Loggedin successfully'; }else{ $return['error']='Credentials are invalid'; $return['hash']=$this->security->get_csrf_hash(); } }else{ $return['error']='You account has been deleted.Please Contact college.'; } }else{ $return['error']='Application URL is not valid.'; } }else{ $return['error']='Application is not active for your ID'; } }else{ if(password_verify($password,$userdata->user_password)){ $session_data=array( 'isAdminLoggedin'=>true, 'admin_id'=>encode_data($userdata->user_id), 'admin_type'=>$userdata->user_type, 'loggedin_time'=>time() ); session_set_userdata($session_data); $return['redirect'] = $this->data['base_url'].'/dashboard'; $return['success']='Loggedin successfully'; }else{ $return['error']='Credentials are invalid'; $return['hash']=$this->security->get_csrf_hash(); } } }else if($userdata!='' && ($userdata->user_status=='inactive')){ $return['error']='Your id is deactivated.'; }else{ $return['redirect'] = $this->data['base_url'].'/dashboard'; $return['error']='Credentials are invalid'; } json_headers($return); }else{ redirect($this->data['base_url']); } } public function onLogin() { // Check if the request is AJAX and POST if ($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD') === 'POST') { // Load form validation library $this->load->library('form_validation'); // Set validation rules $this->form_validation->set_rules('username', 'Username', 'required|trim'); $this->form_validation->set_rules('password', 'Password', 'required|trim'); $this->form_validation->set_rules('url_code', 'Application Code', 'required|trim'); if ($this->form_validation->run() === FALSE) { // Validation failed $return = [ 'error' => validation_errors('<p>', '</p>'), 'hash' => $this->security->get_csrf_hash(), ]; json_headers($return); return; } // Retrieve sanitized POST data $username = post_data('username'); $password = post_data('password'); $code = post_data('url_code'); // Fetch user data $userdata = $this->um->_get_user(['user_name' => $username]); if (empty($userdata)) { // User not found $return = [ 'error' => 'Invalid credentials. Please try again.', 'hash' => $this->security->get_csrf_hash(), ]; json_headers($return); return; } if ($userdata->user_status !== 'active') { // Inactive user $return = [ 'error' => 'Your account is inactive. Please contact support.', ]; json_headers($return); return; } if (!password_verify($password, $userdata->user_password)) { // Incorrect password $return = [ 'error' => 'Invalid credentials. Please try again.', 'hash' => $this->security->get_csrf_hash(), ]; json_headers($return); return; } // Validate user type and application code if (in_array($userdata->user_type, ['institute', 'institute_branch', 'agent', 'student', 'employee'])) { $system_links = $this->sm->_get_system_links(['link_code' => $code, 'link_status' => 'active']); if (empty($system_links)) { $return = ['error' => 'Application is not active for your ID.']; json_headers($return); return; } $user_code = $this->getUserCode($userdata, $code); if ($user_code !== $code) { $return = ['error' => 'Application URL is not valid.']; json_headers($return); return; } } // Set session data $session_data = [ 'isAdminLoggedin' => true, 'admin_id' => encode_data($userdata->user_id), 'admin_type' => $userdata->user_type, 'admin_db_group' => ($userdata->user_code!=null)?encode_data($userdata->user_code):encode_data(DB_GROUP), 'loggedin_time' => time(), ]; session_set_userdata($session_data); // Log activity $log_data = [ 'log_user_type' => $userdata->user_type, 'log_user_id' => $userdata->user_id, 'log_details_type' => 'user_login', 'log_details' => json_encode(['user_name' => $username]), ]; create_log($log_data); $redirect_to = ($userdata->user_type === 'student') ? 'account' : (($userdata->user_type === 'agent')?'payments/agents/'.encode_data($userdata->user_id):'dashboard'); $return = [ 'redirect' => $this->data['base_url'] . '/' . $redirect_to, 'success' => 'Logged in successfully.', ]; json_headers($return); } else { // Invalid request redirect($this->data['base_url']); } } /** * Helper function to get user code based on user type. */ private function getUserCode($userdata, $code) { switch ($userdata->user_type) { case 'institute': $inst_data = $this->um->get_user(['user_id' => $userdata->user_id], 'institute'); return $inst_data->user_code ?? null; case 'institute_branch': $branch_inst_data = $this->um->get_user(['user_id' => $userdata->user_id], 'institute_branch'); $inst_data = $this->um->get_user(['user_id' => $branch_inst_data->branch_parent_inst_id], 'institute'); return strtolower($branch_inst_data->branch_code ?? ''); case 'agent': $agent_data = $this->um->get_user(['user_id' => $userdata->user_id], 'agent'); $inst_data = $this->um->get_user(['user_id' => $agent_data->agent_inst_id], $agent_data->agent_inst_type); return ($inst_data->user_type === 'institute_branch') ? strtolower($inst_data->branch_code) : $inst_data->user_code; case 'student': $stu_data = $this->um->get_user(['user_id' => $userdata->user_id], 'student'); $inst_data = $this->um->get_user(['user_id' => $stu_data->stu_inst_id], $stu_data->stu_inst_type); return ($inst_data->user_type === 'institute_branch') ? strtolower($inst_data->branch_code) : $inst_data->user_code; case 'employee': $employee_data = $this->um->get_user(['user_id' => $userdata->user_id], 'employee'); $inst_data = $this->um->get_user(['user_id' => $employee_data->emp_inst_id], $employee_data->emp_inst_type); return ($inst_data->user_type === 'institute_branch') ? strtolower($inst_data->branch_code) : $inst_data->user_code; default: return null; } } public function onLogout(){ if(session_userdata('admin_id') && session_userdata('isAdminLoggedin')==TRUE) { $userdata = $this->um->_get_user(array('user_id'=>decode_data(session_userdata('admin_id')))); $log_user_type=$userdata->user_type; $log_user_id=$userdata->user_id; $log_details_type='user_logout'; $log_details=json_encode(array('user_name'=>$userdata->user_name)); $log_data=compact('log_user_type','log_user_id','log_details_type','log_details'); create_log($log_data); $this->session->sess_destroy(); redirect($this->data['base_url'].'/signin'); }else{ redirect($this->data['base_url'].'/signin'); } } public function onUpdateUserdata(){ if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){ if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){ $userdata=$this->data['userdata']; $db_group=$userdata->user_code; $institute_data=check_institute($userdata); $inst_id=$institute_data['institute_id']; //$user_type=$institute_data['inst_type']; $inst_code=$institute_data['inst_code']; $user_type=$institute_data['user_type']; if($user_type=='institute'){ $user_id=decode_data(post_data('stu_id')); }else{ $user_id=$userdata->user_id; } $data_type_to_change=post_data('data_type_to_change'); //print_obj($institute_data);die; if($user_type=='student'){ $institute_user_data=$this->um->_get_user(array('user_id'=>$this->data['userdata']->stu_inst_id)); if($institute_user_data->user_type=='institute'){ $institute_data=$this->um->get_institute(array('user_pk_id'=>$institute_user_data->user_id)); $parent_inst_id=$institute_data->user_pk_id; $storage_dir='institutes/'.$institute_data->user_code.'/students/'.date('Y'); }else if($institute_user_data->user_type=='institute_branch'){ $institute_branch_data=$this->um->get_institute_branch(array('branch_user_id'=>$institute_user_data->user_id)); $parent_inst_id=$institute_branch_data->branch_parent_inst_id; $institute_data=$this->um->get_institute(array('user_pk_id'=>$parent_inst_id)); $storage_dir='institutes/'.$inst_data->user_code.'/students/'.date('Y'); } if($userdata->stu_mid_name!=''){ $stu_name=ucwords($userdata->stu_first_name.' '.$userdata->stu_mid_name.' '.$userdata->stu_last_name); }else{ $stu_name=ucwords($userdata->stu_first_name.' '.$userdata->stu_last_name); } if($data_type_to_change=='access_data'){ $old_password=post_data('old_password'); $password=post_data('password'); if(!empty($password)){ if(password_verify($old_password,$userdata->user_password)){ if(!password_verify($password,$userdata->user_password)){ $pass=password_hash($password, PASSWORD_BCRYPT, array('cost'=>12)); $pass_visible=encode_data($password); $updated=$this->um->update_users(array('user_password'=>$pass,'user_password_visible'=>$pass_visible,'updated_at'=>date('Y-m-d'),'updated_by'=>$userdata->user_id),array('user_id'=>$user_id)); if($updated){ $mail_data['inst_id']=$inst_id; $mail_data['mail_from']='webmaster'; $mail_data['to_email']=$institute_data->user_email; $mail_data['mail_from_name']=$stu_name; $mail_data['mail_subject']='Cloud Campus Password Update'; $mail_data['mail_type']='text'; $mail_data['mail_data']='Your Cloud Campus Password has been updated recently. If it is not you then contact the Cloud Campus Administrator.'; $mail_data['mail_log']='true'; $mail_data['inst_parent_id']=$parent_inst_id; $mail_data['notify_type']='stu_doc_uploaded'; $mail_data['notify_type_data']=$stu_name; $mail_data['notify_type_id']=$userdata->stu_user_id; $mail_data['notify_has_attachment']='no'; $mail_data['notify_status']='unread'; $mail_data['log_type']='email_log'; $mail_data['log_user_type']='student'; $mail_data['log_user_id']=$userdata->user_id; $mail_msg=$this->onSendMail($mail_data); $return['success']='Password updated successfully'; }else{ $return['error']='Password not updated'; } }else{ $return['error']='New password can not be same as old password'; } }else{ $return['error']='Old password not matched'; } }else{ $return['error']='Password not given to change.'; } }else if($data_type_to_change=='basic_data'){ $stu_first_name=post_data('stu_first_name'); $stu_middle_name=post_data('stu_middle_name'); $stu_last_name=post_data('stu_last_name'); $stu_dob=post_data('stu_dob'); $stu_gender=post_data('stu_gender'); $stu_religion=post_data('stu_religion'); $stu_caste=post_data('stu_caste'); $stu_blood_grp=post_data('stu_blood_grp'); $stu_aadhar_no=post_data('stu_aadhar_no'); $stu_ph_no=post_data('stu_ph_no'); $stu_whatsapp_no=post_data('stu_whatsapp_no'); $stu_email_address=post_data('stu_email_address'); $stu_has_illness=post_data('stu_has_illness'); $stu_illness_remarks=post_data('stu_illness_remarks'); $stu_identiy_mark=post_data('stu_identiy_mark'); $stu_nationality=post_data('stu_nationality'); $stu_father_first_name=post_data('stu_father_first_name'); $stu_father_mid_name=post_data('stu_father_mid_name'); $stu_father_last_name=post_data('stu_father_last_name'); $stu_father_occupation=post_data('stu_father_occupation'); $stu_father_mobile=post_data('stu_father_mobile'); $stu_father_email_address=post_data('stu_father_email_address'); $stu_father_income=post_data('stu_father_income'); $stu_father_is_guardian=post_data('stu_father_is_guardian'); $stu_mother_first_name=post_data('stu_mother_first_name'); $stu_mother_mid_name=post_data('stu_mother_mid_name'); $stu_mother_last_name=post_data('stu_mother_last_name'); $stu_mother_occupation=post_data('stu_mother_occupation'); $stu_mother_mobile=post_data('stu_mother_mobile'); $stu_mother_email_address=post_data('stu_mother_email_address'); $stu_mother_income=post_data('stu_mother_income'); $stu_mother_is_guardian=post_data('stu_mother_is_guardian'); $stu_guardian_first_name=post_data('stu_guardian_first_name'); $stu_guardian_mid_name=post_data('stu_guardian_mid_name'); $stu_guardian_last_name=post_data('stu_guardian_last_name'); $stu_guardian_occupation=post_data('stu_guardian_occupation'); $stu_guardian_ph_no=post_data('stu_guardian_ph_no'); $stu_guardian_email=post_data('stu_guardian_email'); $stu_guardian_income=post_data('stu_guardian_income'); $stu_c_o=post_data('stu_c_o'); $stu_city_village=post_data('stu_city_village'); $stu_district=post_data('stu_district'); $stu_p_o=post_data('stu_p_o'); $stu_p_s=post_data('stu_p_s'); $stu_state=post_data('stu_state'); $stu_pincode=post_data('stu_pincode'); $stu_address_landmark=post_data('stu_address_landmark'); $address_same_as=post_data('address_same_as'); $stu_perma_c_o=post_data('stu_perma_c_o'); $stu_perma_city_village=post_data('stu_perma_city_village'); $stu_perma_district=post_data('stu_perma_district'); $stu_perma_p_o=post_data('stu_perma_p_o'); $stu_perma_p_s=post_data('stu_perma_p_s'); $stu_perma_state=post_data('stu_perma_state'); $stu_perma_pincode=post_data('stu_perma_pincode'); $stu_perma_address_landmark=post_data('stu_perma_address_landmark'); $student_email_found=$this->um->get_duplicate_student(array('stu_email'=>$stu_email_address,'stu_user_id!='=>$user_id),null,null,null,FALSE); $student_phone_found=$this->um->get_duplicate_student(array('stu_ph_no'=>$stu_ph_no,'stu_user_id!='=>$user_id),null,null,null,FALSE); if($student_email_found[0]->counted==0 && $student_phone_found[0]->counted==0){ $student_data=array( 'stu_first_name'=>$stu_first_name, 'stu_mid_name'=>$stu_middle_name, 'stu_last_name'=>$stu_last_name, 'stu_email'=>$stu_email_address, 'stu_ph_no'=>$stu_ph_no, 'stu_whatsapp_no'=>$stu_whatsapp_no, 'stu_aadhar'=>$stu_aadhar_no, 'stu_dob'=>date('Y-m-d',strtotime($stu_dob)), 'stu_gender'=>$stu_gender, 'stu_religion'=>$stu_religion, 'stu_caste'=>$stu_caste, 'stu_blood_group'=>$stu_blood_grp, 'stu_nationality'=>$stu_nationality, 'stu_has_illness'=>$stu_has_illness, 'stu_illness_remarks'=>$stu_illness_remarks, 'stu_identity_marks'=>$stu_identiy_mark, 'stu_father_first_name'=>$stu_father_first_name, 'stu_father_mid_name'=>$stu_father_mid_name, 'stu_father_last_name'=>$stu_father_last_name, 'stu_father_ph_no'=>$stu_father_mobile, 'stu_father_email'=>$stu_father_email_address, 'stu_father_income'=>$stu_father_income, 'stu_father_occupation'=>$stu_father_occupation, 'stu_mother_first_name'=>$stu_mother_first_name, 'stu_mother_mid_name'=>$stu_mother_mid_name, 'stu_mother_last_name'=>$stu_mother_last_name, 'stu_mother_ph_no'=>$stu_mother_mobile, 'stu_mother_email'=>$stu_mother_email_address, 'stu_mother_income'=>$stu_mother_income, 'stu_mother_occupation'=>$stu_mother_occupation, 'stu_guardian_first_name'=>$stu_guardian_first_name, 'stu_guardian_mid_name'=>$stu_guardian_mid_name, 'stu_guardian_last_name'=>$stu_guardian_last_name, 'stu_guardian_ph_no'=>$stu_guardian_ph_no, 'stu_guardian_email'=>$stu_guardian_email, 'stu_guardian_income'=>$stu_guardian_income, 'stu_guardian_occupation'=>$stu_guardian_occupation, 'stu_cur_addr_co'=>$stu_c_o, 'stu_cur_addr_country'=>$stu_nationality, 'stu_cur_state'=>$stu_state, 'stu_cur_city'=>$stu_city_village, 'stu_cur_district'=>$stu_district, 'stu_cur_pincode'=>$stu_pincode, 'stu_cur_ps'=>$stu_p_s, 'stu_cur_po'=>$stu_p_o, 'stu_cur_address_line'=>'', 'stu_cur_address_landmark'=>$stu_address_landmark, 'stu_perma_addr_co'=>$stu_perma_c_o, 'stu_perma_addr_country'=>$stu_nationality, 'stu_perma_state'=>$stu_perma_state, 'stu_perma_city'=>$stu_perma_city_village, 'stu_perma_district'=>$stu_perma_district, 'stu_perma_pincode'=>$stu_perma_pincode, 'stu_perma_ps'=>$stu_perma_p_s, 'stu_perma_po'=>$stu_perma_p_o, 'stu_perma_address_line'=>'', 'stu_perma_address_landmark'=>$stu_perma_address_landmark, 'stu_same_address'=>$address_same_as, 'stu_regster_mode'=>'new_admission', 'updated_by'=>$this->data['userdata']->user_id, 'updated_at'=>date('Y-m-d') ); $updated=$this->um->update_students($student_data,array('stu_user_id'=>$user_id),FALSE,$db_group); if($updated){ $mail_data['inst_id']=$userdata->stu_inst_id; $mail_data['mail_from']='webmaster'; $mail_data['to_email']=$institute_data->user_email; $mail_data['mail_from_name']=$stu_name; $mail_data['mail_subject']=$stu_name.' has uploaded profile details.'; $mail_data['mail_type']='text'; $mail_data['mail_data']=$stu_name.' has uploaded profile details.'; $mail_data['mail_log']='true'; $mail_data['inst_parent_id']=$parent_inst_id; $mail_data['notify_type']='stu_profile_details_uploaded'; $mail_data['notify_type_data']=$stu_name; $mail_data['notify_type_id']=$userdata->stu_user_id; $mail_data['notify_has_attachment']='no'; $mail_data['notify_status']='unread'; $mail_data['log_type']='email_log'; $mail_data['log_user_type']='student'; $mail_data['log_user_id']=$userdata->user_id; $mail_msg=$this->onSendMail($mail_data); $return['success']='Data has been updated successfully.'; }else{ $return['error']='There was an error occurred'; } }else{ $return['error']='Email or phone no already exists'; } }else if($data_type_to_change=='academic_data'){ $stu_10th_board=post_data('stu_10th_board'); $stu_10th_yop=post_data('stu_10th_year_of_passing'); $stu_10th_total_marks=post_data('stu_10th_total_marks'); $stu_10th_percentage_marks=post_data('stu_10th_percentage_marks'); $stu_10th_division=post_data('stu_10th_division'); $stu_10th_subjects=post_data('stu_10th_subjects'); $stu_10_2_board=post_data('stu_10_2_board'); $stu_10_2_yop=post_data('stu_10_2_year_of_passing'); $stu_10_2_total_marks=post_data('stu_10_2_total_marks'); $stu_10_2_percentage_marks=post_data('stu_10_2_percentage_marks'); $stu_10_2_division=post_data('stu_10_2_division'); $stu_10_2_subjects=post_data('stu_10_2_subjects'); $stu_grad_board=post_data('stu_grad_board'); $stu_grad_yop=post_data('stu_grad_year_of_passing'); $stu_grad_total_marks=post_data('stu_grad_total_marks'); $stu_grad_percentage_marks=post_data('stu_grad_percentage_marks'); $stu_grad_division=post_data('stu_grad_division'); $stu_grad_subjects=post_data('stu_grad_subjects'); $stu_post_grad_board=post_data('stu_post_grad_board'); $stu_post_grad_yop=post_data('stu_post_grad_year_of_passing'); $stu_post_grad_total_marks=post_data('stu_post_grad_total_marks'); $stu_post_grad_percentage_marks=post_data('stu_post_grad_percentage_marks'); $stu_post_grad_division=post_data('stu_post_grad_division'); $stu_post_grad_subjects=post_data('stu_post_grad_subjects'); $stu_other_grad_board=post_data('stu_other_grad_board'); $stu_other_grad_yop=post_data('stu_other_grad_year_of_passing'); $stu_other_grad_total_marks=post_data('stu_other_grad_total_marks'); $stu_other_grad_percentage_marks=post_data('stu_other_grad_percentage_marks'); $stu_other_grad_division=post_data('stu_other_grad_division'); $stu_other_grad_subjects=post_data('stu_other_grad_subjects'); $academic_data=array( 'acad_stu_id'=>$user_id, 'acad_stu_inst_id'=>$institute_data->user_pk_id, 'acad_stu_inst_parent_id'=>$parent_inst_id, 'acad_10th_board'=>$stu_10th_board, 'acad_10th_yop'=>$stu_10th_yop, 'acad_10th_total_marks'=>$stu_10th_total_marks, 'acad_10th_percentage'=>$stu_10th_percentage_marks, 'acad_10th_division'=>$stu_10th_division, 'acad_10th_subjects'=>$stu_10th_subjects, 'acad_12th_board'=>$stu_10_2_board, 'acad_12th_yop'=>$stu_10_2_yop, 'acad_12th_total_marks'=>$stu_10_2_total_marks, 'acad_12th_percentage'=>$stu_10_2_percentage_marks, 'acad_12th_division'=>$stu_10_2_division, 'acad_12th_subjects'=>$stu_10_2_subjects, 'acad_grad_board'=>$stu_grad_board, 'acad_grad_yop'=>$stu_grad_yop, 'acad_grad_total_marks'=>$stu_grad_total_marks, 'acad_grad_percentage'=>$stu_grad_percentage_marks, 'acad_grad_division'=>$stu_grad_division, 'acad_grad_subjects'=>$stu_grad_subjects, 'acad_pgd_board'=>$stu_post_grad_board, 'acad_pgd_yop'=>$stu_post_grad_yop, 'acad_pgd_total_marks'=>$stu_post_grad_total_marks, 'acad_pgd_percentage'=>$stu_post_grad_percentage_marks, 'acad_pgd_division'=>$stu_post_grad_division, 'acad_pgd_subjects'=>$stu_post_grad_subjects, 'acad_others_board'=>$stu_other_grad_board, 'acad_others_yop'=>$stu_other_grad_yop, 'acad_others_total_marks'=>$stu_other_grad_total_marks, 'acad_others_percentage'=>$stu_other_grad_percentage_marks, 'acad_others_division'=>$stu_other_grad_division, 'acad_others_subjects'=>$stu_other_grad_subjects, 'created_by'=>$this->data['userdata']->user_id, 'created_at'=>date('Y-m-d') ); $academic_details_found=$this->um->get_students_academics(array('acad_stu_id'=>$user_id)); if(!empty($academic_details_found)){ $added=$this->um->update_students_academics($academic_data,array('acad_stu_id'=>$user_id)); }else{ $added=$this->um->store_students_academics($academic_data); } if($added){ $mail_data['inst_id']=$userdata->stu_inst_id; $mail_data['mail_from']='webmaster'; $mail_data['to_email']=$institute_data->user_email; $mail_data['mail_from_name']=$stu_name; $mail_data['mail_subject']=$stu_name.' has uploaded academic details.'; $mail_data['mail_type']='text'; $mail_data['mail_data']=$stu_name.' has uploaded academic details.'; $mail_data['mail_log']='true'; $mail_data['inst_parent_id']=$parent_inst_id; $mail_data['notify_type']='stu_academic_details_uploaded'; $mail_data['notify_type_data']=$stu_name; $mail_data['notify_type_id']=$userdata->stu_user_id; $mail_data['notify_has_attachment']='no'; $mail_data['notify_status']='unread'; $mail_data['log_type']='email_log'; $mail_data['log_user_type']='student'; $mail_data['log_user_id']=$userdata->user_id; $mail_msg=$this->onSendMail($mail_data); $return['success']='Data has been saved successfully.'; }else{ $return['error']='Academic details not added'; } }else if($data_type_to_change=='document_data'){ $storage_dir='students'; if(isset($_FILES['stu_addhar_card_file']) && $_FILES['stu_addhar_card_file']['name']!=''){ $aadhar_card_file=array( 'file_size'=>'0.05', 'file_name'=>'stu_addhar_card_file', 'file_types'=>'png,jpg,jpeg,pdf', 'file_type_of'=>'student', 'file_storage_type'=>'aadhar_card', 'file_storage_dir'=>$storage_dir, 'file_storage_type_id'=>$user_id, 'file_parent_id'=>$inst_id, 'file_compress'=>false, 'file_operation_type'=>'update', 'file_uploaded_by'=>$user_id ); $aadhar_card_file_id=$this->onUploadFiles($aadhar_card_file); if(!is_numeric($aadhar_card_file_id)){ $file_error[]='AADHAR Card '.$aadhar_card_file_id; } } if(isset($_FILES['stu_madhyamik_admit_card_file']) && $_FILES['stu_madhyamik_admit_card_file']['name']!=''){ $profile_picture_file=array( 'file_size'=>'0.05', 'file_name'=>'stu_madhyamik_admit_card_file', 'file_types'=>'png,jpg,jpeg,webp,pdf', 'file_type_of'=>'student', 'file_storage_type'=>'madhyamik_admit_card', 'file_storage_dir'=>$storage_dir, 'file_storage_type_id'=>$user_id, 'file_parent_id'=>$inst_id, 'file_compress'=>false, 'file_operation_type'=>'update', 'file_uploaded_by'=>$user_id ); $profile_file_id=$this->onUploadFiles($profile_picture_file); if(!is_numeric($profile_file_id)){ $file_error[]='10th Admit Card '.$profile_file_id; } } if(isset($_FILES['stu_madhyamik_reg_card_file']) && $_FILES['stu_madhyamik_reg_card_file']['name']!=''){ $madhyamik_registration_file=array( 'file_size'=>'0.05', 'file_name'=>'stu_madhyamik_reg_card_file', 'file_types'=>'png,jpg,jpeg,webp,pdf', 'file_type_of'=>'student', 'file_storage_type'=>'madhyamik_registration_card', 'file_storage_dir'=>$storage_dir, 'file_storage_type_id'=>$user_id, 'file_parent_id'=>$inst_id, 'file_compress'=>false, 'file_operation_type'=>'update', 'file_uploaded_by'=>$user_id ); $madhyamik_registration_file_id=$this->onUploadFiles($madhyamik_registration_file); if(!is_numeric($madhyamik_registration_file_id)){ $file_error[]='10th Admit Card '.$madhyamik_registration_file_id; } } if(isset($_FILES['stu_madhyamik_result_file']) && $_FILES['stu_madhyamik_result_file']['name']!=''){ $madhyamik_result_card_file=array( 'file_size'=>'0.05', 'file_name'=>'stu_madhyamik_result_file', 'file_types'=>'png,jpg,jpeg,pdf', 'file_type_of'=>'student', 'file_storage_type'=>'madhyamik_result_card', 'file_storage_dir'=>$storage_dir, 'file_storage_type_id'=>$user_id, 'file_parent_id'=>$inst_id, 'file_compress'=>false, 'file_operation_type'=>'update', 'file_uploaded_by'=>$user_id ); $madhyamik_result_card_file_id=$this->onUploadFiles($madhyamik_result_card_file); if(!is_numeric($madhyamik_result_card_file_id)){ $file_error[]='10th Result Card '.$madhyamik_result_card_file_id; } } if(isset($_FILES['stu_12th_result_file']) && $_FILES['stu_12th_result_file']['name']!=''){ $twelfth_result_card_file=array( 'file_size'=>'0.05', 'file_name'=>'stu_12th_result_file', 'file_types'=>'png,jpg,jpeg,pdf', 'file_type_of'=>'student', 'file_storage_type'=>'12th_result_card', 'file_storage_dir'=>$storage_dir, 'file_storage_type_id'=>$user_id, 'file_parent_id'=>$inst_id, 'file_compress'=>false, 'file_operation_type'=>'update', 'file_uploaded_by'=>$user_id ); $twelfth_result_card_file_id=$this->onUploadFiles($twelfth_result_card_file); if(!is_numeric($twelfth_result_card_file_id)){ $file_error[]='12th Result Card '.$twelfth_result_card_file_id; } } if(isset($_FILES['stu_grad_result_file']) && $_FILES['stu_grad_result_file']['name']!=''){ $grad_result_file=array( 'file_size'=>'0.05', 'file_name'=>'stu_grad_result_file', 'file_types'=>'png,jpg,jpeg,pdf', 'file_type_of'=>'student', 'file_storage_type'=>'grad_result_card', 'file_storage_dir'=>$storage_dir, 'file_storage_type_id'=>$user_id, 'file_parent_id'=>$inst_id, 'file_compress'=>false, 'file_operation_type'=>'update', 'file_uploaded_by'=>$user_id ); $grad_result_file_id=$this->onUploadFiles($grad_result_file); if(!is_numeric($grad_result_file_id)){ $file_error[]='Graduation Result '.$grad_result_file_id; } } if(isset($_FILES['stu_post_grad_result_file']) && $_FILES['stu_post_grad_result_file']['name']!=''){ $post_grad_result_file=array( 'file_size'=>'0.05', 'file_name'=>'stu_post_grad_result_file', 'file_types'=>'png,jpg,jpeg,pdf', 'file_type_of'=>'student', 'file_storage_type'=>'post_grad_result_card', 'file_storage_dir'=>$storage_dir, 'file_storage_type_id'=>$user_id, 'file_parent_id'=>$inst_id, 'file_compress'=>false, 'file_operation_type'=>'update', 'file_uploaded_by'=>$user_id ); $post_grad_result_card_id=$this->onUploadFiles($post_grad_result_file); if(!is_numeric($post_grad_result_card_id)){ $file_error[]='Post Graduation Result '.$post_grad_result_card_id; } } if(isset($_FILES['stu_other_certificate_file']) && $_FILES['stu_other_certificate_file']['name']!=''){ $stu_other_certificate_file=array( 'file_size'=>'0.05', 'file_name'=>'stu_other_certificate_file', 'file_types'=>'png,jpg,jpeg,pdf', 'file_type_of'=>'student', 'file_storage_type'=>'other_certificate_card', 'file_storage_dir'=>$storage_dir, 'file_storage_type_id'=>$user_id, 'file_parent_id'=>$inst_id, 'file_compress'=>false, 'file_operation_type'=>'update', 'file_uploaded_by'=>$user_id ); $stu_other_certificate_file_id=$this->onUploadFiles($stu_other_certificate_file); if(!is_numeric($stu_other_certificate_file_id)){ $file_error[]='Other Certificate File '.$stu_other_certificate_file_id; } } if(isset($_FILES['stu_profile_photo_file']) && $_FILES['stu_profile_photo_file']['name']!=''){ $profile_picture_file=array( 'file_size'=>'0.05', 'file_name'=>'stu_profile_photo_file', 'file_types'=>'png,jpg,jpeg,webp,pdf', 'file_type_of'=>'student', 'file_storage_type'=>'student_profile_photo', 'file_storage_dir'=>$storage_dir, 'file_storage_type_id'=>$user_id, 'file_parent_id'=>$inst_id, 'file_compress'=>false, 'file_operation_type'=>'update', 'file_uploaded_by'=>$user_id ); $profile_file_id=$this->onUploadFiles($profile_picture_file); if(!is_numeric($profile_file_id)){ $file_error[]='Profile Picture '.$profile_file_id; } } if(isset($_FILES['stu_post_signature_file']) && $_FILES['stu_post_signature_file']['name']!=''){ $signature_file=array( 'file_size'=>'0.05', 'file_name'=>'stu_post_signature_file', 'file_types'=>'png,jpg,jpeg,pdf', 'file_type_of'=>'student', 'file_storage_type'=>'student_signature_photo', 'file_storage_dir'=>$storage_dir, 'file_storage_type_id'=>$user_id, 'file_parent_id'=>$inst_id, 'file_compress'=>false, 'file_operation_type'=>'update', 'file_uploaded_by'=>$user_id ); $signature_file_id=$this->onUploadFiles($signature_file); if(!is_numeric($signature_file_id)){ $file_error[]='Signature '.$signature_file_id; } } if(!empty($file_error)){ $return['error']=$file_error; }else{ $mail_data['inst_id']=$inst_id; $mail_data['mail_from']='webmaster'; $mail_data['to_email']=$institute_data->user_email; $mail_data['mail_from_name']=$stu_name; $mail_data['mail_subject']=$stu_name.' has uploaded documents.'; $mail_data['mail_type']='text'; $mail_data['mail_data']=$stu_name.' has uploaded documents.'; $mail_data['mail_log']='true'; $mail_data['inst_parent_id']=$parent_inst_id; $mail_data['notify_type']='stu_doc_uploaded'; $mail_data['notify_type_data']=$stu_name; $mail_data['notify_type_id']=$userdata->stu_user_id; $mail_data['notify_has_attachment']='no'; $mail_data['notify_status']='unread'; $mail_data['log_type']='email_log'; $mail_data['log_user_type']='student'; $mail_data['log_user_id']=$userdata->user_id; $mail_msg=$this->onSendMail($mail_data); $return['success']='Documents updated successfully.'; } } }else if($user_type=='institute'){ $student_data=$this->um->get_user(array('stu_id'=>$user_id),'student'); if($data_type_to_change=='access_data'){ $stu_id=post_data('stu_id'); if(!empty($stu_id)){ $password=post_data('password'); if(!empty($password)){ if(!empty($student_data)){ $student_user_id=$student_data->stu_user_id; if(!password_verify($password,$student_data->user_password)){ $pass=(!empty($password))?password_hash($password, PASSWORD_BCRYPT, array('cost'=>12)):password_hash('Password@123', PASSWORD_BCRYPT, array('cost'=>12)); $updated=$this->um->update_users(array('user_password'=>$pass,'user_password_visible'=>encode_data($password),'updated_by_type'=>$user_type,'updated_by'=>$user_id,'updated_at'=>date('Y-m-d')),array('user_id'=>$student_user_id),FALSE,$db_group); if($updated){ $log_user_type=$user_type; $log_user_id=$user_id; $log_details_type='student_password_change'; $log_data=array( 'student_user_id'=>$student_user_id, 'student_user_name'=>$student_data->user_name, 'student_new_password'=>$password ); $log_details=json_encode($log_data); $log_data=compact('log_user_type','log_user_id','log_details_type','log_details'); create_log($log_data); $return['success']='Password updated successfully'; }else{ $return['error']='Password can not be updated'; } }else{ $return['error']='New password can not be same as old password'; } }else{ $return['error']='Student data not found in the system.'; } }else{ $return['error']='Password not given to change.'; } }else{ $return['error']='Data manipulation not allowed.'; } }else if($data_type_to_change=='basic_data'){ $stu_first_name=post_data('stu_first_name'); $stu_middle_name=post_data('stu_middle_name'); $stu_last_name=post_data('stu_last_name'); $stu_dob=post_data('stu_dob'); $stu_gender=post_data('stu_gender'); $stu_religion=post_data('stu_religion'); $stu_caste=post_data('stu_caste'); $stu_blood_grp=post_data('stu_blood_grp'); $stu_aadhar_no=post_data('stu_aadhar_no'); $stu_ph_no=post_data('stu_ph_no'); $stu_whatsapp_no=post_data('stu_whatsapp_no'); $stu_email_address=post_data('stu_email_address'); $stu_has_illness=post_data('stu_has_illness'); $stu_illness_remarks=post_data('stu_illness_remarks'); $stu_identiy_mark=post_data('stu_identiy_mark'); $stu_nationality=post_data('stu_nationality'); $stu_father_first_name=post_data('stu_father_first_name'); $stu_father_mid_name=post_data('stu_father_mid_name'); $stu_father_last_name=post_data('stu_father_last_name'); $stu_father_occupation=post_data('stu_father_occupation'); $stu_father_mobile=post_data('stu_father_mobile'); $stu_father_email_address=post_data('stu_father_email_address'); $stu_father_income=post_data('stu_father_income'); $stu_father_is_guardian=post_data('stu_father_is_guardian'); $stu_mother_first_name=post_data('stu_mother_first_name'); $stu_mother_mid_name=post_data('stu_mother_mid_name'); $stu_mother_last_name=post_data('stu_mother_last_name'); $stu_mother_occupation=post_data('stu_mother_occupation'); $stu_mother_mobile=post_data('stu_mother_mobile'); $stu_mother_email_address=post_data('stu_mother_email_address'); $stu_mother_income=post_data('stu_mother_income'); $stu_mother_is_guardian=post_data('stu_mother_is_guardian'); $stu_guardian_first_name=post_data('stu_guardian_first_name'); $stu_guardian_mid_name=post_data('stu_guardian_mid_name'); $stu_guardian_last_name=post_data('stu_guardian_last_name'); $stu_guardian_occupation=post_data('stu_guardian_occupation'); $stu_guardian_ph_no=post_data('stu_guardian_ph_no'); $stu_guardian_email=post_data('stu_guardian_email'); $stu_guardian_income=post_data('stu_guardian_income'); $stu_c_o=post_data('stu_c_o'); $stu_city_village=post_data('stu_city_village'); $stu_district=post_data('stu_district'); $stu_p_o=post_data('stu_p_o'); $stu_p_s=post_data('stu_p_s'); $stu_state=post_data('stu_state'); $stu_pincode=post_data('stu_pincode'); $stu_address_landmark=post_data('stu_address_landmark'); $address_same_as=post_data('address_same_as'); $stu_perma_c_o=post_data('stu_perma_c_o'); $stu_perma_city_village=post_data('stu_perma_city_village'); $stu_perma_district=post_data('stu_perma_district'); $stu_perma_p_o=post_data('stu_perma_p_o'); $stu_perma_p_s=post_data('stu_perma_p_s'); $stu_perma_state=post_data('stu_perma_state'); $stu_perma_pincode=post_data('stu_perma_pincode'); $stu_perma_address_landmark=post_data('stu_perma_address_landmark'); $student_email_found=[]; if(!empty($stu_email_address)){ $student_email_found=$this->um->get_duplicate_student(array('stu_email'=>$stu_email_address,'stu_user_id!='=>$user_id),null,null,null,FALSE); } $student_phone_found=$this->um->get_duplicate_student(array('stu_ph_no'=>$stu_ph_no,'stu_user_id!='=>$student_data->stu_user_id),null,null,null,FALSE); if($student_phone_found[0]->counted==0){ $student_data=array( 'stu_first_name'=>$stu_first_name, 'stu_mid_name'=>$stu_middle_name, 'stu_last_name'=>$stu_last_name, 'stu_email'=>$stu_email_address, 'stu_ph_no'=>$stu_ph_no, 'stu_whatsapp_no'=>$stu_whatsapp_no, 'stu_aadhar'=>$stu_aadhar_no, 'stu_dob'=>date('Y-m-d',strtotime($stu_dob)), 'stu_gender'=>$stu_gender, 'stu_religion'=>$stu_religion, 'stu_caste'=>$stu_caste, 'stu_blood_group'=>$stu_blood_grp, 'stu_nationality'=>$stu_nationality, 'stu_has_illness'=>$stu_has_illness, 'stu_illness_remarks'=>$stu_illness_remarks, 'stu_identity_marks'=>$stu_identiy_mark, 'stu_father_first_name'=>$stu_father_first_name, 'stu_father_mid_name'=>$stu_father_mid_name, 'stu_father_last_name'=>$stu_father_last_name, 'stu_father_ph_no'=>$stu_father_mobile, 'stu_father_email'=>$stu_father_email_address, 'stu_father_income'=>$stu_father_income, 'stu_father_occupation'=>$stu_father_occupation, 'stu_mother_first_name'=>$stu_mother_first_name, 'stu_mother_mid_name'=>$stu_mother_mid_name, 'stu_mother_last_name'=>$stu_mother_last_name, 'stu_mother_ph_no'=>$stu_mother_mobile, 'stu_mother_email'=>$stu_mother_email_address, 'stu_mother_income'=>$stu_mother_income, 'stu_mother_occupation'=>$stu_mother_occupation, 'stu_guardian_first_name'=>$stu_guardian_first_name, 'stu_guardian_mid_name'=>$stu_guardian_mid_name, 'stu_guardian_last_name'=>$stu_guardian_last_name, 'stu_guardian_ph_no'=>$stu_guardian_ph_no, 'stu_guardian_email'=>$stu_guardian_email, 'stu_guardian_income'=>$stu_guardian_income, 'stu_guardian_occupation'=>$stu_guardian_occupation, 'stu_cur_addr_co'=>$stu_c_o, 'stu_cur_addr_country'=>$stu_nationality, 'stu_cur_state'=>$stu_state, 'stu_cur_city'=>$stu_city_village, 'stu_cur_district'=>$stu_district, 'stu_cur_pincode'=>$stu_pincode, 'stu_cur_ps'=>$stu_p_s, 'stu_cur_po'=>$stu_p_o, 'stu_cur_address_line'=>'', 'stu_cur_address_landmark'=>$stu_address_landmark, 'stu_perma_addr_co'=>$stu_perma_c_o, 'stu_perma_addr_country'=>$stu_nationality, 'stu_perma_state'=>$stu_perma_state, 'stu_perma_city'=>$stu_perma_city_village, 'stu_perma_district'=>$stu_perma_district, 'stu_perma_pincode'=>$stu_perma_pincode, 'stu_perma_ps'=>$stu_perma_p_s, 'stu_perma_po'=>$stu_perma_p_o, 'stu_perma_address_line'=>'', 'stu_perma_address_landmark'=>$stu_perma_address_landmark, 'stu_same_address'=>$address_same_as, 'updated_by'=>$this->data['userdata']->user_id, 'updated_at'=>date('Y-m-d') ); $updated=$this->um->update_students($student_data,array('stu_id'=>$user_id)); if($updated){ /*$mail_data['inst_id']=$inst_id; $mail_data['mail_from']='webmaster'; $mail_data['to_email']=$institute_data->user_email; $mail_data['mail_from_name']=$stu_name; $mail_data['mail_subject']=$stu_name.' has uploaded profile details.'; $mail_data['mail_type']='text'; $mail_data['mail_data']=$stu_name.' has uploaded profile details.'; $mail_data['mail_log']='true'; $mail_data['inst_parent_id']=$parent_inst_id; $mail_data['notify_type']='stu_profile_details_uploaded'; $mail_data['notify_type_data']=$stu_name; $mail_data['notify_type_id']=$userdata->stu_user_id; $mail_data['notify_has_attachment']='no'; $mail_data['notify_status']='unread'; $mail_msg=$this->onSendMail($mail_data);*/ $return['success']='Data has been updated successfully.'; }else{ $return['error']='There was an error occurred'; } }else{ $return['error']='Email or phone no already exists'; } }else if($data_type_to_change=='academic_data'){ $stu_10th_board=post_data('stu_10th_board'); $stu_10th_yop=post_data('stu_10th_year_of_passing'); $stu_10th_total_marks=post_data('stu_10th_total_marks'); $stu_10th_percentage_marks=post_data('stu_10th_percentage_marks'); $stu_10th_division=post_data('stu_10th_division'); $stu_10th_subjects=post_data('stu_10th_subjects'); $stu_10_2_board=post_data('stu_10_2_board'); $stu_10_2_yop=post_data('stu_10_2_year_of_passing'); $stu_10_2_total_marks=post_data('stu_10_2_total_marks'); $stu_10_2_percentage_marks=post_data('stu_10_2_percentage_marks'); $stu_10_2_division=post_data('stu_10_2_division'); $stu_10_2_subjects=post_data('stu_10_2_subjects'); $stu_grad_board=post_data('stu_grad_board'); $stu_grad_yop=post_data('stu_grad_year_of_passing'); $stu_grad_total_marks=post_data('stu_grad_total_marks'); $stu_grad_percentage_marks=post_data('stu_grad_percentage_marks'); $stu_grad_division=post_data('stu_grad_division'); $stu_grad_subjects=post_data('stu_grad_subjects'); $stu_post_grad_board=post_data('stu_post_grad_board'); $stu_post_grad_yop=post_data('stu_post_grad_year_of_passing'); $stu_post_grad_total_marks=post_data('stu_post_grad_total_marks'); $stu_post_grad_percentage_marks=post_data('stu_post_grad_percentage_marks'); $stu_post_grad_division=post_data('stu_post_grad_division'); $stu_post_grad_subjects=post_data('stu_post_grad_subjects'); $stu_other_grad_board=post_data('stu_other_grad_board'); $stu_other_grad_yop=post_data('stu_other_grad_year_of_passing'); $stu_other_grad_total_marks=post_data('stu_other_grad_total_marks'); $stu_other_grad_percentage_marks=post_data('stu_other_grad_percentage_marks'); $stu_other_grad_division=post_data('stu_other_grad_division'); $stu_other_grad_subjects=post_data('stu_other_grad_subjects'); $academic_data=array( 'acad_stu_id'=>$student_data->stu_user_id, 'acad_stu_inst_id'=>$student_data->stu_inst_id, 'acad_stu_inst_parent_id'=>$parent_inst_id, 'acad_10th_board'=>$stu_10th_board, 'acad_10th_yop'=>$stu_10th_yop, 'acad_10th_total_marks'=>$stu_10th_total_marks, 'acad_10th_percentage'=>$stu_10th_percentage_marks, 'acad_10th_division'=>$stu_10th_division, 'acad_10th_subjects'=>$stu_10th_subjects, 'acad_12th_board'=>$stu_10_2_board, 'acad_12th_yop'=>$stu_10_2_yop, 'acad_12th_total_marks'=>$stu_10_2_total_marks, 'acad_12th_percentage'=>$stu_10_2_percentage_marks, 'acad_12th_division'=>$stu_10_2_division, 'acad_12th_subjects'=>$stu_10_2_subjects, 'acad_grad_board'=>$stu_grad_board, 'acad_grad_yop'=>$stu_grad_yop, 'acad_grad_total_marks'=>$stu_grad_total_marks, 'acad_grad_percentage'=>$stu_grad_percentage_marks, 'acad_grad_division'=>$stu_grad_division, 'acad_grad_subjects'=>$stu_grad_subjects, 'acad_pgd_board'=>$stu_post_grad_board, 'acad_pgd_yop'=>$stu_post_grad_yop, 'acad_pgd_total_marks'=>$stu_post_grad_total_marks, 'acad_pgd_percentage'=>$stu_post_grad_percentage_marks, 'acad_pgd_division'=>$stu_post_grad_division, 'acad_pgd_subjects'=>$stu_post_grad_subjects, 'acad_others_board'=>$stu_other_grad_board, 'acad_others_yop'=>$stu_other_grad_yop, 'acad_others_total_marks'=>$stu_other_grad_total_marks, 'acad_others_percentage'=>$stu_other_grad_percentage_marks, 'acad_others_division'=>$stu_other_grad_division, 'acad_others_subjects'=>$stu_other_grad_subjects, 'created_by'=>$this->data['userdata']->user_id, 'created_at'=>date('Y-m-d') ); $academic_details_found=$this->um->get_students_academics(array('acad_stu_id'=>$student_data->stu_user_id)); if(!empty($academic_details_found)){ $added=$this->um->update_students_academics($academic_data,array('acad_stu_id'=>$student_data->stu_user_id)); }else{ $added=$this->um->store_students_academics($academic_data); } if($added){ /*$mail_data['inst_id']=$student_data->stu_inst_id; $mail_data['mail_from']='webmaster'; $mail_data['to_email']=$institute_data->user_email; $mail_data['mail_from_name']=$stu_name; $mail_data['mail_subject']=$stu_name.' has uploaded academic details.'; $mail_data['mail_type']='text'; $mail_data['mail_data']=$stu_name.' has uploaded academic details.'; $mail_data['mail_log']='true'; $mail_data['inst_parent_id']=$parent_inst_id; $mail_data['notify_type']='stu_academic_details_uploaded'; $mail_data['notify_type_data']=$stu_name; $mail_data['notify_type_id']=$student_data->stu_user_id; $mail_data['notify_has_attachment']='no'; $mail_data['notify_status']='unread'; $mail_msg=$this->onSendMail($mail_data);*/ $return['success']='Data has been saved successfully.'; }else{ $return['error']='Academic details not added'; } }else if($data_type_to_change=='document_data'){ $storage_dir='students'; if(isset($_FILES['stu_addhar_card_file']) && $_FILES['stu_addhar_card_file']['name']!=''){ $aadhar_card_file=array( 'file_size'=>'0.05', 'file_name'=>'stu_addhar_card_file', 'file_types'=>'png,jpg,jpeg,pdf', 'file_type_of'=>'student', 'file_storage_type'=>'aadhar_card', 'file_storage_dir'=>$storage_dir, 'file_storage_type_id'=>$student_data->stu_user_id, 'file_parent_id'=>$inst_id, 'file_compress'=>false, 'file_operation_type'=>'update', 'file_uploaded_by'=>$student_data->stu_user_id ); $aadhar_card_file_id=$this->onUploadFiles($aadhar_card_file); if(!is_numeric($aadhar_card_file_id)){ $file_error[]='AADHAR Card '.$aadhar_card_file_id; } } if(isset($_FILES['stu_madhyamik_admit_card_file']) && $_FILES['stu_madhyamik_admit_card_file']['name']!=''){ $profile_picture_file=array( 'file_size'=>'0.05', 'file_name'=>'stu_madhyamik_admit_card_file', 'file_types'=>'png,jpg,jpeg,webp,pdf', 'file_type_of'=>'student', 'file_storage_type'=>'madhyamik_admit_card', 'file_storage_dir'=>$storage_dir, 'file_storage_type_id'=>$student_data->stu_user_id, 'file_parent_id'=>$inst_id, 'file_compress'=>false, 'file_operation_type'=>'update', 'file_uploaded_by'=>$student_data->stu_user_id ); $profile_file_id=$this->onUploadFiles($profile_picture_file); if(!is_numeric($profile_file_id)){ $file_error[]='10th Admit Card '.$profile_file_id; } } if(isset($_FILES['stu_madhyamik_reg_card_file']) && $_FILES['stu_madhyamik_reg_card_file']['name']!=''){ $madhyamik_registration_file=array( 'file_size'=>'0.05', 'file_name'=>'stu_madhyamik_reg_card_file', 'file_types'=>'png,jpg,jpeg,webp,pdf', 'file_type_of'=>'student', 'file_storage_type'=>'madhyamik_registration_card', 'file_storage_dir'=>$storage_dir, 'file_storage_type_id'=>$student_data->stu_user_id, 'file_parent_id'=>$inst_id, 'file_compress'=>false, 'file_operation_type'=>'update', 'file_uploaded_by'=>$student_data->stu_user_id ); $madhyamik_registration_file_id=$this->onUploadFiles($madhyamik_registration_file); if(!is_numeric($madhyamik_registration_file_id)){ $file_error[]='10th Admit Card '.$madhyamik_registration_file_id; } } if(isset($_FILES['stu_madhyamik_result_file']) && $_FILES['stu_madhyamik_result_file']['name']!=''){ $madhyamik_result_card_file=array( 'file_size'=>'0.05', 'file_name'=>'stu_madhyamik_result_file', 'file_types'=>'png,jpg,jpeg,pdf', 'file_type_of'=>'student', 'file_storage_type'=>'madhyamik_result_card', 'file_storage_dir'=>$storage_dir, 'file_storage_type_id'=>$student_data->stu_user_id, 'file_parent_id'=>$inst_id, 'file_compress'=>false, 'file_operation_type'=>'update', 'file_uploaded_by'=>$student_data->stu_user_id ); $madhyamik_result_card_file_id=$this->onUploadFiles($madhyamik_result_card_file); if(!is_numeric($madhyamik_result_card_file_id)){ $file_error[]='10th Result Card '.$madhyamik_result_card_file_id; } } if(isset($_FILES['stu_12th_result_file']) && $_FILES['stu_12th_result_file']['name']!=''){ $twelfth_result_card_file=array( 'file_size'=>'0.05', 'file_name'=>'stu_12th_result_file', 'file_types'=>'png,jpg,jpeg,pdf', 'file_type_of'=>'student', 'file_storage_type'=>'12th_result_card', 'file_storage_dir'=>$storage_dir, 'file_storage_type_id'=>$student_data->stu_user_id, 'file_parent_id'=>$inst_id, 'file_compress'=>false, 'file_operation_type'=>'update', 'file_uploaded_by'=>$student_data->stu_user_id ); $twelfth_result_card_file_id=$this->onUploadFiles($twelfth_result_card_file); if(!is_numeric($twelfth_result_card_file_id)){ $file_error[]='12th Result Card '.$twelfth_result_card_file_id; } } if(isset($_FILES['stu_grad_result_file']) && $_FILES['stu_grad_result_file']['name']!=''){ $grad_result_file=array( 'file_size'=>'0.05', 'file_name'=>'stu_grad_result_file', 'file_types'=>'png,jpg,jpeg,pdf', 'file_type_of'=>'student', 'file_storage_type'=>'grad_result_card', 'file_storage_dir'=>$storage_dir, 'file_storage_type_id'=>$student_data->stu_user_id, 'file_parent_id'=>$inst_id, 'file_compress'=>false, 'file_operation_type'=>'update', 'file_uploaded_by'=>$student_data->stu_user_id ); $grad_result_file_id=$this->onUploadFiles($grad_result_file); if(!is_numeric($grad_result_file_id)){ $file_error[]='Graduation Result '.$grad_result_file_id; } } if(isset($_FILES['stu_post_grad_result_file']) && $_FILES['stu_post_grad_result_file']['name']!=''){ $post_grad_result_file=array( 'file_size'=>'0.05', 'file_name'=>'stu_post_grad_result_file', 'file_types'=>'png,jpg,jpeg,pdf', 'file_type_of'=>'student', 'file_storage_type'=>'post_grad_result_card', 'file_storage_dir'=>$storage_dir, 'file_storage_type_id'=>$student_data->stu_user_id, 'file_parent_id'=>$inst_id, 'file_compress'=>false, 'file_operation_type'=>'update', 'file_uploaded_by'=>$student_data->stu_user_id ); $post_grad_result_card_id=$this->onUploadFiles($post_grad_result_file); if(!is_numeric($post_grad_result_card_id)){ $file_error[]='Post Graduation Result '.$post_grad_result_card_id; } } if(isset($_FILES['stu_other_certificate_file']) && $_FILES['stu_other_certificate_file']['name']!=''){ $stu_other_certificate_file=array( 'file_size'=>'0.05', 'file_name'=>'stu_other_certificate_file', 'file_types'=>'png,jpg,jpeg,pdf', 'file_type_of'=>'student', 'file_storage_type'=>'other_certificate_card', 'file_storage_dir'=>$storage_dir, 'file_storage_type_id'=>$student_data->stu_user_id, 'file_parent_id'=>$inst_id, 'file_compress'=>false, 'file_operation_type'=>'update', 'file_uploaded_by'=>$student_data->stu_user_id ); $stu_other_certificate_file_id=$this->onUploadFiles($stu_other_certificate_file); if(!is_numeric($stu_other_certificate_file_id)){ $file_error[]='Other Certificate File '.$stu_other_certificate_file_id; } } if(isset($_FILES['stu_profile_photo_file']) && $_FILES['stu_profile_photo_file']['name']!=''){ $profile_picture_file=array( 'file_size'=>'0.05', 'file_name'=>'stu_profile_photo_file', 'file_types'=>'png,jpg,jpeg,webp,pdf', 'file_type_of'=>'student', 'file_storage_type'=>'student_profile_photo', 'file_storage_dir'=>$storage_dir, 'file_storage_type_id'=>$student_data->stu_user_id, 'file_parent_id'=>$inst_id, 'file_compress'=>false, 'file_operation_type'=>'update', 'file_uploaded_by'=>$student_data->stu_user_id ); $profile_file_id=$this->onUploadFiles($profile_picture_file); if(!is_numeric($profile_file_id)){ $file_error[]='Profile Picture '.$profile_file_id; } } if(isset($_FILES['stu_post_signature_file']) && $_FILES['stu_post_signature_file']['name']!=''){ $signature_file=array( 'file_size'=>'0.05', 'file_name'=>'stu_post_signature_file', 'file_types'=>'png,jpg,jpeg,pdf', 'file_type_of'=>'student', 'file_storage_type'=>'student_signature_photo', 'file_storage_dir'=>$storage_dir, 'file_storage_type_id'=>$student_data->stu_user_id, 'file_parent_id'=>$inst_id, 'file_compress'=>false, 'file_operation_type'=>'update', 'file_uploaded_by'=>$student_data->stu_user_id ); $signature_file_id=$this->onUploadFiles($signature_file); if(!is_numeric($signature_file_id)){ $file_error[]='Signature '.$signature_file_id; } } if(!empty($file_error)){ $return['error']=$file_error; }else{ /*$mail_data['inst_id']=$inst_id; $mail_data['mail_from']='webmaster'; $mail_data['to_email']=$institute_data->user_email; $mail_data['mail_from_name']=$stu_name; $mail_data['mail_subject']=$stu_name.' has uploaded documents.'; $mail_data['mail_type']='text'; $mail_data['mail_data']=$stu_name.' has uploaded documents.'; $mail_data['mail_log']='true'; $mail_data['inst_parent_id']=$parent_inst_id; $mail_data['notify_type']='stu_doc_uploaded'; $mail_data['notify_type_data']=$stu_name; $mail_data['notify_type_id']=$userdata->stu_user_id; $mail_data['notify_has_attachment']='no'; $mail_data['notify_status']='unread'; $mail_msg=$this->onSendMail($mail_data); */ $return['success']='Documents updated successfully.'; } } } return json_headers($return); }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } } public function onUpdateUserFile(){ if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){ if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){ $student_id=$this->data['userdata']->user_id; $data_file_type=post_data('data_file_type'); $storage_type=post_data('storage_type'); $institute_user_data=$this->um->_get_user(array('user_id'=>$this->data['userdata']->stu_inst_id)); if($institute_user_data->user_type=='institute'){ $institute_data=$this->um->get_institute(array('user_pk_id'=>$institute_user_data->user_id)); $parent_inst_id=$institute_data->user_pk_id; $storage_dir='institutes/'.$institute_data->user_code.'/students/'.date('Y'); }else if($institute_user_data->user_type=='institute_branch'){ $institute_branch_data=$this->um->get_institute_branch(array('branch_user_id'=>$institute_user_data->user_id)); $parent_inst_id=$institute_branch_data->branch_parent_inst_id; $institute_data=$this->um->get_institute(array('user_pk_id'=>$parent_inst_id)); $storage_dir='institutes/'.$inst_data->user_code.'/students/'.date('Y'); } $file_found=$this->sm->get_file(array('storage_type'=>$storage_type,'storage_type_id'=>$student_id)); if(isset($_FILES[$data_file_type]) && $_FILES[$data_file_type]['name']!=''){ $grad_result=array( 'file_size'=>'5', 'file_name'=>$data_file_type, 'file_types'=>'png,jpg,jpeg,pdf', 'file_storage_type'=>$storage_type, 'file_storage_dir'=>$storage_dir, 'file_storage_type_id'=>$user_id, 'file_parent_id'=>$this->data['userdata']->stu_inst_id, 'file_compress'=>false, 'file_operation_type'=>'update', 'file_uploaded_by'=>$this->data['userdata']->user_id ); if(!empty($file_found)){ @unlink(FCPATH.$file_found->media_disk_path); $this->sm->delete_file(array('storage_type'=>$storage_type,'storage_type_id'=>$student_id,'storage_id'=>$file_found->storage_id)); } $grad_result_file=$this->onUploadFiles($grad_result); if($grad_result_file){ $return['success']='File updated'; }else{ $return['error']='File not updated.'.$grad_result_file; } }else{ $return['error']='No file selected to update'; } return json_headers($return); }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } } //Student installments public function indexStudentInstallments(){ if(session_userdata('admin_id') && session_userdata('isAdminLoggedin')==TRUE){ $userdata=$this->data['userdata']; $db_group=$userdata->user_code; $this->data['page_title']='Installments'; if($userdata->user_type=='student'){ if(session_userdata('txn_id')){ $this->data['txn-data']='Payment has been recieved'; $this->session->unset_userdata('txn_id'); } $adm_data=$this->adm->get_admission_data(array('admission_stu_id'=>$userdata->user_id)); $session_course_data=$this->sessm->get_session_course(array('session_id'=>$adm_data->admission_sess_id,'session_inst_id'=>$adm_data->admission_inst_id,'session_course_id'=>$adm_data->admission_course_id)); $session_course_student_data=$this->sessm->get_session_course_student_wise(array('session_id'=>$adm_data->admission_sess_id,'session_inst_id'=>$adm_data->admission_inst_id,'session_course_id'=>$adm_data->admission_course_id,'session_stu_id'=>$adm_data->admission_stu_id)); $_get_payments_details_total=$this->fm->_get_payments_details_total(array('details_stu_id'=>$adm_data->admission_stu_id,'details_sess_id'=>$adm_data->admission_sess_id,'details_course_id'=>$adm_data->admission_course_id,'details_inst_id'=>$adm_data->admission_inst_id,'details_type!='=>'agent_payment'),$db_group); //print_obj($adm_data); if(!empty($_get_payments_details_total)){ $paid_amount=$_get_payments_details_total[0]->total; }else{ $paid_amount=0; } if(!empty($session_course_student_data) && $session_course_student_data->session_course_fees>0){ $course_fees=$session_course_student_data->session_course_fees; }else{ if(!empty($session_course_data)){ $course_fees=$session_course_data->session_course_fees; }else{ $course_fees=0; } } $admission_fees_data=$this->fm->get_payment_details(array('details_type'=>'new_admission','details_payment_type'=>'admission_fees','details_stu_id'=>$adm_data->admission_stu_id,'details_inst_id'=>$adm_data->admission_inst_id,'details_course_id'=>$adm_data->admission_course_id,'details_sess_id'=>$adm_data->admission_sess_id)); if(!empty($admission_fees_data)){ $admission_fees=$admission_fees_data->details_amount; }else{ $admission_fees=0; } $seat_book_data=$this->adm->get_seat_booking_payment_data(array('booking_pk_id'=>$adm_data->admission_seat_booking_id,'booking_inst_id'=>$adm_data->admission_inst_id),TRUE,$db_group); if(!empty($seat_book_data) && $seat_book_data->booking_payment_paid=='yes'){ $seatbook_amount=$seat_book_data->booking_payment; $remaining_amount=($course_fees>0 && $course_fees>=$seatbook_amount)?($course_fees-$seatbook_amount):'0'; }else{ $seatbook_amount='0'; } $late_fees_total=$this->fm->get_late_fees_total(array('late_fee_inst_id'=>$adm_data->admission_inst_id,'late_fee_stu_id'=>$adm_data->admission_stu_id,'late_fee_admission_id'=>$adm_data->admission_id,'late_fee_session_id'=>$adm_data->admission_sess_id,'late_fee_course_id'=>$adm_data->admission_course_id),$db_group); //print_obj($late_fees_total); $discount_fees_total=$this->fm->get_discount_fees_total(array('discount_fee_inst_id'=>$adm_data->admission_inst_id,'discount_fee_stu_id'=>$adm_data->admission_stu_id,'discount_fee_admission_id'=>$adm_data->admission_id,'discount_fee_session_id'=>$adm_data->admission_sess_id,'discount_fee_course_id'=>$adm_data->admission_course_id),$db_group); //$remaining_amount=($course_fees-$discount_fees_total)-($paid_amount-$late_fees_total); $course_fees=$course_fees-$discount_fees_total; $remaining_amount=($course_fees+$late_fees_total)-$paid_amount; $this->data['admission_data']=array( 'admission_course'=>$adm_data->course_name, 'admission_session_years'=>$adm_data->session_start_year.'-'.$adm_data->session_end_year, 'course_fees'=>number_format($course_fees,2), 'course_remaining_amount'=>$remaining_amount, 'paid_amount'=>number_format($paid_amount,2) ); $this->theme->title($this->data['page_title'])->load('accounts/vw_installments', $this->data); }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } } public function onSearchStudentInstallments(){ if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){ if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){ $userdata=$this->data['userdata']; $db_group=$userdata->user_code; $param['column_order'] = array( null, 'course_name' ); $param['column_search'] = array('course_name'); $param['order'] = array('installment_id' => 'ASC'); $posts=$this->input->post(); $param['inst_id']=$userdata->stu_inst_id; $param['stu_id']=$userdata->user_id; $list = $this->fm->_get_installments($posts,$param,$this->db_group,FALSE,FALSE); //print_obj($list);die; $data = array(); $no = isset($posts['start'])?$posts['start']:0; $action=''; $next=1; $date_now = date('Y-m-d');//new DateTime(); foreach ($list as $fees){ $no++; $row = array(); $admission_data=$this->adm->get_admission_data(array('admission_id'=>$fees->installment_admission_id)); $installment_date = date('Y-m-d',strtotime($fees->installment_date));//new DateTime($fes->installment_datee); //$balance=$this->fm->get_installments_balance_last(array('inst_installment_id'=>$fees->installment_id,'inst_stu_id'=>$fees->installment_stu_id,'inst_session_id'=>$fees->installment_sess_id)); $balance_last_data=$this->fm->_get_installments_balance_last(array('inst_installment_id'=>$fees->installment_id,'inst_stu_id'=>$fees->installment_stu_id,'inst_session_id'=>$fees->installment_sess_id)); //print_obj($balance_last_data); if(!empty($balance_last_data->inst_payment_balance)){ $total_paid=$this->fm->get_installments_paid_total(array('inst_installment_id'=>$fees->installment_id,'inst_stu_id'=>$fees->installment_stu_id,'inst_session_id'=>$fees->installment_sess_id)); if(!empty($total_paid[0]->total)){ $paid_amount=number_format($total_paid[0]->total,2); }else{ $paid_amount=number_format($balance_last_data->inst_payment_total,2); } $paid_date=date('d-m-Y',strtotime($balance_last_data->created_at)); }else{ $get_fees_details=$this->fm->get_fees_details(array('payment_stu_id'=>$userdata->user_id,'payment_inst_id'=>$userdata->stu_inst_id,'payment_session_id'=>$fees->installment_sess_id,'payment_installment_id'=>$fees->installment_id)); if(!empty($get_fees_details)){ $paid_amount=number_format($get_fees_details->payment_fees_admission_amount,2); $paid_date=date('d-m-Y',strtotime($get_fees_details->created_at)); }else{ $paid_amount='0.00'; $paid_date=''; } } if(!empty($balance_last_data->inst_payment_balance) && $balance_last_data->inst_payment_balance>0){ $order_id=$admission_data->admission_code.'_'.$fees->installment_sess_year.'_'.$fees->installment_no.'_'.generate_string(4).'_'.$fees->installment_unique_code.'_stu_bal'; }else{ $order_id=$admission_data->admission_code.'_'.$fees->installment_sess_year.'_'.$fees->installment_no.'_'.generate_string(4).'_'.$fees->installment_unique_code.'_stu'; } // if(!empty($balance_last_data->inst_payment_balance) && $balance_last_data->inst_payment_balance>0){ // $order_id='ADM_'.$fees->installment_sess_year.'_'.$fees->installment_no.'_'.generate_string(4).'_'.$fees->installment_unique_code.'_stu_bal'; // }else{ // $order_id='ADM_'.$fees->installment_sess_year.'_'.$fees->installment_no.'_'.generate_string(4).'_'.$fees->installment_unique_code.'_stu'; // } if(!empty($balance_last_data->inst_payment_balance) && $balance_last_data->inst_payment_balance>0){ $penalty_applied=FALSE; $total_due=$balance_last_data->inst_payment_balance; $balance=$balance_last_data->inst_payment_balance; }else{ if($date_now>$installment_date){ $penalty_applied=TRUE; $total_due=$fees->installment_value+$fees->installment_value_penalty; $balance=$fees->installment_value+$fees->installment_value_penalty; }else if($date_now==$installment_date){ $penalty_applied=FALSE; $total_due=$fees->installment_value; $balance=$fees->installment_value; }else{ $penalty_applied=FALSE; $total_due=$fees->installment_value; $balance=$fees->installment_value; } } //print_obj($balance_last_data); $installment_value=number_format($fees->installment_value,2); $installment_value_penalty=number_format($fees->installment_value_penalty,2); $balance=number_format($balance,2); if($fees->installment_paid_full=='no'){ if($no==1){ $_payment_data=$this->fm->get_payment_details(array('details_type'=>'new_admission','details_payment_type'=>'installment_fees','details_stu_id'=>$fees->installment_stu_id,'details_inst_id'=>$fees->installment_inst_id,'details_sess_id'=>$fees->installment_sess_id,'details_sess_year'=>$fees->installment_sess_year,'details_course_id'=>$fees->installment_course_id,'details_installment_id'=>$fees->installment_id)); if(!empty($balance_last_data->inst_payment_balance) && $balance_last_data->inst_payment_balance>0){ //$paybtn='<button class="btn btn-xs btn-dark btn_view_bill" data-payment_id="'.encode_data($_payment_data->details_id).'" data-bill_type="installment_fees" data-target="#paymentBillModal" data-toggle="modal">Bill '.$fees->installment_id.'</button>'; $paybtn='<a class="btn btn-xs btn-dark btn_view_bill" data-payment_id="'.encode_data($_payment_data->details_id).'" data-bill_type="installment_fees" href="'.$this->data['base_url'].'/bills?type=installments_part_bill_own&code='.encode_data($_payment_data->details_id).'" target="__blank">Bill '.$fees->installment_id.'</a>'; //' <button type="button" class="btn btn-xs btn-info btn_pay_fees" data-installment_id="'.encode_data($fees->installment_id).'" data-order_id="'.$order_id.'">Pay Balance 1-1</button>'; }else{ //$paybtn='<button type="button" class="btn btn-xs btn-info btn_pay_fees" data-installment_id="'.encode_data($fees->installment_id).'" data-order_id="'.$order_id.'">Pay Now 1-1</button>'; $paybtn=''; } //$balance=$installment_value; }else{ if($next==$no){ if(!empty($balance_last_data->inst_payment_balance) && $balance_last_data->inst_payment_balance>0){ $_payment_data=$this->fm->get_payment_details(array('details_type'=>'new_admission','details_payment_type'=>'installment_fees','details_stu_id'=>$fees->installment_stu_id,'details_inst_id'=>$fees->installment_inst_id,'details_sess_id'=>$fees->installment_sess_id,'details_sess_year'=>$fees->installment_sess_year,'details_course_id'=>$fees->installment_course_id,'details_installment_id'=>$fees->installment_id)); //print_obj($_payment_data); /* if(empty($balance_last_data->inst_payment_balance)){ $paybtn='<button class="btn btn-xs btn-dark btn_view_bill" data-payment_id="'.encode_data($_payment_data->details_id).'" data-bill_type="installment_fees" data-target="#paymentBillModal" data-toggle="modal">Bill </button> <button type="button" class="btn btn-xs btn-info btn_pay_fees" data-installment_id="'.encode_data($fees->installment_id).'" data-order_id="'.$order_id.'">Pay Balance</button>'; }else{ $paybtn='<button class="btn btn-xs btn-dark btn_view_bills" data-installment_id="'.encode_data($fees->installment_id).'" data-student_id="'.encode_data($fees->installment_stu_id).'">Bills +</button> <button type="button" class="btn btn-xs btn-info btn_pay_fees" data-installment_id="'.encode_data($fees->installment_id).'" data-order_id="'.$order_id.'">Pay Balance</button>'; }*/ //$balance=number_format($balance_last_data->inst_payment_balance,2); }else{ $paybtn='<button type="button" class="btn btn-xs btn-info btn_pay_fees" data-installment_id="'.encode_data($fees->installment_id).'" data-order_id="'.$order_id.'">Pay Now 2</button>'; //$balance=$installment_value; //$paybtn=''; } }else{ if(!empty($balance_last_data->inst_payment_balance) && $balance_last_data->inst_payment_balance>0){ $paybtn='<label class="label label-danger">Partially Paid</label>'; //$balance=$balance_last_data->inst_payment_balance; }else{ $paybtn=''; //$balance=$installment_value; } } } }else{ $next+=1; //$paybtn='<button type="button" class="btn btn-xs btn-dark btn_view_bill" data-booking_code="'.$admission_data->admission_code.'" data-payment_id="'.encode_data($fees->installment_id).'" data-bill_type="new_admission" data-toggle="modal" data-target="#paymentBillModal">Bill</button>'; $balance='0'; $_payment_data=$this->fm->get_payment_details(array('details_type'=>'new_admission','details_payment_type'=>'installment_fees','details_stu_id'=>$fees->installment_stu_id,'details_inst_id'=>$fees->installment_inst_id,'details_sess_id'=>$fees->installment_sess_id,'details_sess_year'=>$fees->installment_sess_year,'details_course_id'=>$fees->installment_course_id,'details_installment_id'=>$fees->installment_id)); if(empty($balance_last_data->inst_payment_balance)){ if(!empty($_payment_data)){ // $paybtn='<button class="btn btn-xs btn-dark btn_view_bill" data-payment_id="'.encode_data($_payment_data->details_id).'" data-bill_type="installment_fees" data-target="#paymentBillModal" data-toggle="modal">Bill</button>'; $paybtn='<a class="btn btn-xs btn-dark btn_view_bill" data-payment_id="'.encode_data($_payment_data->details_id).'" data-bill_type="installment_fees" href="'.$this->data['base_url'].'/bills?type=installments_part_bill_own&code='.encode_data($_payment_data->details_id).'" target="__blank">Bills</a>'; }else{ $paybtn=''; } }else{ // $paybtn='<button class="btn btn-xs btn-dark btn_view_bills" data-installment_id="'.encode_data($fees->installment_id).'" data-student_id="'.encode_data($fees->installment_stu_id).'">Bills</button>'; $paybtn='<a class="btn btn-xs btn-dark btn_view_bill" data-payment_id="'.encode_data($_payment_data->details_id).'" data-bill_type="installment_fees" href="'.$this->data['base_url'].'/bills?type=installments_part_bill_own&code='.encode_data($_payment_data->details_id).'" target="__blank">Bills</a>'; // $balance_installments=$this->fm->get_payment_details(array('details_installment_id'=>$fees->installment_id),FALSE); // if(!empty($balance_installments)){ // foreach ($balance_installments as $bk => $bv) { // $html='<tr>'; // $html.='<td>'.number_format($bv->details_amount,2).'</td>'; // $html.='</tr>'; // } // } // $paybtn=$html; } //$paybtn='<label class="label label-success">Paid</label>'; } $subject=(!empty($fees->subject_name))?$fees->subject_name:'N/A'; $sessions=$fees->session_start_year.'-'.$fees->session_end_year; //$row[] = $no; $row[] = $fees->installment_sess_year.'['.$sessions.']'; //$row[] = 'Course:'.$fees->course_name.'<br>Subject:'.$subject; $row[] = '<span class="label label-success "><i class="fa fa-inr"></i> '.$installment_value.'</span>'; $row[] = ($penalty_applied==TRUE)?'<span class="label label-success "><i class="fa fa-inr"></i> '.$installment_value_penalty.'</span>':'N/A'; $row[] = '<span class="label label-success "><i class="fa fa-inr"></i> '.number_format($total_due,2).'</span>'; $row[] = '<span class="label label-success "><i class="fa fa-inr"></i> '.$paid_amount.'</span>'; $row[] = (!empty($balance_last_data) && $balance_last_data->inst_balance_paid=='no')?'<span class="label label-danger "><i class="fa fa-inr"></i> '.number_format($balance_last_data->inst_payment_balance,2).'</span>':'<span class="label label-danger "><i class="fa fa-inr"></i> '.$balance.'</span>'; $row[] = date('d-m-Y',strtotime($fees->installment_date)); $row[] = $paid_date; $row[] = $paybtn; $data[] = $row; } $output = array( "draw" => isset($posts['draw'])?$posts['draw']:'', "recordsTotal" => $this->fm->_get_installments($posts,$param,$this->db_group,TRUE), "recordsFiltered" => $this->fm->_get_installments($posts,$param,$this->db_group,TRUE), "data" => $data, ); echo json_encode($output); }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } } public function onLoadBalanceBills(){ if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){ if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){ $installment_id=post_data('installment_id'); $student_id=post_data('student_id'); $installment_id=decode_data($installment_id); $student_id=decode_data($student_id); //echo $installment_id; $bdata=$this->fm->get_payment_details(array('details_installment_id'=>$installment_id),FALSE); if(!empty($bdata)){ foreach ($bdata as $key => $value) { $invd=$this->fm->get_installment(array('installment_id'=>$value->details_installment_id)); $balance_data[]=array( 'details_id'=>encode_data($value->details_id), 'details_payment_type'=>$value->details_payment_type, 'details_academic_year'=>$invd->installment_sess_year, 'details_installment'=>number_format($invd->installment_value,2), 'details_payment'=>number_format($value->details_amount,2), 'details_late_fee'=>number_format($invd->installment_value_penalty,2), 'details_installment_date'=>date('d-m-Y',strtotime($invd->installment_date)), 'details_payment_date'=>date('d-m-Y',strtotime($value->details_created_at)) ); } } $this->data['balance_data']=$balance_data; //print_obj($this->data['balance_data']);die; $return['html']=$this->theme->view('_pages/accounts/vw_installments_balance',$this->data,true); json_headers($return); }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } } public function onInitializeInstallmentPayment(){ if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){ if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){ $installment_id=post_data('installment_id'); $pay_amount=post_data('payment_amount'); if(!empty($installment_id)){ $installment_id=decode_data($installment_id); if(is_numeric($installment_id)){ if(is_double($pay_amount) || is_numeric($pay_amount)){ $installment_data=$this->fm->get_installment(array('installment_id'=>$installment_id)); //print_obj($installment_data);die; if(!empty($installment_data)){ if($pay_amount>0){ $date_now = new DateTime(); $installment_date = new DateTime($installment_data->installment_date); $installment_balance_data=$this->fm->get_installments_balance(array('inst_id'=>$installment_data->installment_inst_id,'inst_stu_id'=>$installment_data->installment_stu_id,'inst_course_id'=>$installment_data->installment_course_id,'inst_installment_id'=>$installment_data->installment_id,'inst_session_id'=>$installment_data->installment_sess_id)); // print_obj($installment_balance_data);die; if($date_now>$installment_date){ $penalty_applied=TRUE; if(!empty($installment_balance_data)){ $total_due=$installment_balance_data->inst_payment_balance+$installment_data->installment_value_penalty; }else{ $total_due=$installment_data->installment_value+$installment_data->installment_value_penalty; } }else if($date_now==$installment_date){ $penalty_applied=FALSE; if(!empty($installment_balance_data)){ $total_due=$installment_balance_data->inst_payment_balance; }else{ $total_due=$installment_data->installment_value; } }else{ $penalty_applied=FALSE; if(!empty($installment_balance_data)){ $total_due=$installment_balance_data->inst_payment_balance; }else{ $total_due=$installment_data->installment_value; } } if(!empty($installment_balance_data)){ if($pay_amount<$installment_balance_data->inst_payment_balance){ $return['error']='You need to pay the balance in full.'; }else if($pay_amount==$installment_balance_data->inst_payment_balance){ if($pay_amount<=$total_due){ $balance=$total_due-$pay_amount; $return['success']='Payment can be proceessed'; }else if($pay_amount>$total_due){ $return['error']='Pay amount can not be grteater than the total amount due'; } }else if($pay_amount>$installment_balance_data->inst_payment_balance){ $return['error']='Pay amount can not be grteater than the total amount due'; } }else{ if($pay_amount<=$total_due){ $balance=$total_due-$pay_amount; $return['success']='Payment can be proceessed'; }else if($pay_amount>$total_due){ $return['error']='Pay amount can not be grteater than the total amount due'; } } }else{ $return['error']='Zero based amount can not be proceessed.'; } }else{ $return['error']='Installment data not found'; } }else{ $return['error']='Amount is not valid.'; } }else{ $return['error']='Data mnipulation is not allowed'; } }else{ $return['error']='data manipulation is not allowed'; } return json_headers($return); }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } } public function onInitializeSeatBookingPayment(){ if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){ if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){ $student_id=$this->data['userdata']->stu_id; $student_user_id=$this->data['userdata']->user_id; $seat_bookingdata=$this->data['seat_booking_data']; if(!empty($seat_bookingdata)){ $return['booking_code']=$seat_bookingdata->booking_code.'_stu'; $return['booking_value']=$seat_bookingdata->booking_payment; $return['success']='Payment can be proceessed'; }else{ $return['error']='Booking data not found in the system.'; } return json_headers($return); }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } } //Hostel Payments public function indexStudentHostelInstallments(){ if(session_userdata('admin_id') && session_userdata('isAdminLoggedin')==TRUE){ $userdata=$this->data['userdata']; $this->data['page_title']='Hostel Fees'; if($userdata->user_type=='student'){ if(session_userdata('txn_id')){ $this->data['txn-data']='Payment has been recieved'; //$this->session->unset_userdata('txn_id'); } $admission_fees=array(); $hostel_admission_fees=$this->hm->__get_hostel_admission_fees_assign_data(array('assign_stu_id'=>$userdata->user_id,'assign_hostel_inst_id'=>$userdata->stu_inst_id,'assign_hostel_id'=>$userdata->stu_avail_hostel_id)); //print_obj($hostel_admission_fees); if(!empty($hostel_admission_fees)){ $total_fees=$hostel_admission_fees->admission_fees_value+$hostel_admission_fees->admission_caution_fees_value; $_hpd=$this->fm->get_payment_details(array('details_type'=>'hostel_fees_payment','details_payment_type'=>'hostel_admission_fees_payment','details_installment_id'=>$hostel_admission_fees->assigned_id,'details_stu_id'=>$hostel_admission_fees->assign_stu_id,'details_type_id'=>$hostel_admission_fees->assign_hostel_id)); // print_obj($_hpd);die; //$hostel_admission_fees->assigned_id $admission_fees=array( 'assigned_id'=>encode_data($hostel_admission_fees->assigned_id), 'hostel_name'=>$hostel_admission_fees->hostel_name, 'academic_session'=>$hostel_admission_fees->session_start_year.'-'.$hostel_admission_fees->session_end_year, 'admission_fees'=>number_format($hostel_admission_fees->admission_fees_value,2), 'admission_fees_value'=>$hostel_admission_fees->admission_fees_value, 'admission_caution_fees_value'=>$hostel_admission_fees->admission_caution_fees_value, 'total_fees'=>$total_fees, 'caution_fees'=>number_format($hostel_admission_fees->admission_caution_fees_value,2), 'fees_total'=>number_format($total_fees,2), 'assign_fees_paid'=>$hostel_admission_fees->assign_fees_paid, 'paid_date'=>date('d-m-Y',strtotime($hostel_admission_fees->assign_fees_paid_date)), 'payment_id'=>(!empty($_hpd))?encode_data($_hpd->details_id):'', 'payment_order_id'=>'ORDHT'.date('Ymd').'_0_0_0_'.$hostel_admission_fees->assign_unique_payid.'_admfee_hostel' ); } $this->data['hostel_admission_fees']=$admission_fees; $this->theme->title($this->data['page_title'])->load('accounts/vw_hostel_installments', $this->data); }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } } public function onInitializeHostelFeesPayment(){ if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){ if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){ $payment_id=post_data('payment_id'); $pay_amount=post_data('payment_amount'); $payment_id=decode_data($payment_id); $payment_data=$this->fm->get_hostel_fees_payment(array('payment_id'=>$payment_id)); if(!empty($payment_data)){ $date_now = date('Y-m-d');// new DateTime(); $due_date = date('Y-m-d',strtotime($payment_data->due_at));//new DateTime($payment_data->due_at); if($date_now>$due_date){ $penalty_applied=TRUE; $total_due=$payment_data->payment_value+$payment_data->payment_late_value; }else if($date_now==$due_date){ $penalty_applied=FALSE; $total_due=$payment_data->payment_value; }else{ $penalty_applied=FALSE; $total_due=$payment_data->payment_value; } if($pay_amount<=$total_due){ $return['success']='Payment can be proceessed'; }else if($pay_amount>$total_due){ $return['error']='Pay amount can not be grteater than the total amount due'; }else if ($pay_amount==0) { $return['error']='Payment can not be done with zero amount.'; } $return['total_due']=$total_due; $return['fee']=$payment_data->payment_value; $return['late_fee']=$payment_data->payment_late_value; $return['late_fee_applied']=$penalty_applied; }else{ $return['error']='Hostel fees data not found'; } return json_headers($return); }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } } public function onInitializeHostelAdmissionFeesPayment(){ if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){ if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){ $payment_id=post_data('payment_id'); $pay_amount=post_data('payment_amount'); $payment_id=decode_data($payment_id); $payment_data=$this->hm->__get_hostel_admission_fees_assign_data(array('assigned_id'=>$payment_id)); if(!empty($payment_data)){ $total_amount=$payment_data->admission_fees_value+$payment_data->admission_caution_fees_value; if($total_amount==$pay_amount){ $return['success']='Payment can be proceessed'; }else{ $return['error']='Payment can not be proceessed.'; } }else{ $return['error']='Hostel admission fees data not found'; } return json_headers($return); }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } } public function onSearchStudentHostelFees(){ if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){ if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){ $userdata=$this->data['userdata']; $param['column_order'] = array( null, 'payment_month' ); $param['column_search'] = array('payment_month'); $param['order'] = array('payment_id' => 'ASC'); $posts=$this->input->post(); $param['inst_id']=$userdata->stu_inst_id; $param['stu_id']=$userdata->user_id; $list = $this->fm->_get_hostel_fees_payment($posts,$param,FALSE,FALSE); //print_obj($list);die; $data = array(); $no = isset($posts['start'])?$posts['start']:0; $action=''; $next=1; $date_now = new DateTime(); $this->fm->delete_hostel_fees_payment(array('payment_hostel_inst_id'=>$userdata->stu_inst_id,'payment_hostel_stu_id'=>$userdata->user_id,'payment_status'=>'to_be_deleted')); foreach ($list as $fees){ $no++; $row = array(); $due_date = new DateTime($fees->due_at); $unique_order_id=generate_string(4); $order_id='ORDHT'.date('Ymd').'_'.$fees->payment_year.'_'.$fees->payment_month.'_0_'.$fees->payment_unique_code.'_stu_hostel'; // $order_id='ORDHT'.date('Ymd').'_'.$fees->payment_year.'_'.$fees->payment_month.'_'.gen_code(2).'_'.$fees->payment_id.'_stu_hostel'; if($date_now>$due_date){ $penalty_applied=TRUE; $total_due=$fees->payment_value+$fees->payment_late_value; }else if($date_now==$due_date){ $penalty_applied=FALSE; $total_due=$fees->payment_value; }else{ $penalty_applied=FALSE; $total_due=$fees->payment_value; } if($fees->payment_status=='not paid'){ if($no==1){ $hostel_admission_fees=$this->hm->__get_hostel_admission_fees_assign_data(array('assign_stu_id'=>$fees->payment_hostel_stu_id,'assign_hostel_inst_id'=>$fees->payment_hostel_inst_id,'assign_hostel_id'=>$fees->payment_hostel_id)); if($hostel_admission_fees->assign_fees_paid=='yes'){ $paybtn='<button type="button" class="btn btn-xs btn-info btn_pay_hostel_fees" data-payment_id="'.encode_data($fees->payment_id).'" data-order_id="'.$order_id.'" data-hostel_name="'.$fees->hostel_name.'" data-month="'.ucwords($fees->payment_month).'" data-year="'.$fees->payment_year.'">Pay Now</button>'; }else if($hostel_admission_fees->assign_fees_paid=='no'){ $paybtn='<span class="badge badge-sm badge-danger">Admission payment <br>not recieved yet</span>'; } }else{ if($next==$no){ $paybtn='<button type="button" class="btn btn-xs btn-info btn_pay_hostel_fees" data-payment_id="'.encode_data($fees->payment_id).'" data-order_id="'.$order_id.'" data-hostel_name="'.$fees->hostel_name.'" data-month="'.ucwords($fees->payment_month).'" data-year="'.$fees->payment_year.'">Pay Now</button>'; }else{ $paybtn=''; } } }else{ $next+=1; $paybtn='<button class="btn btn-xs btn-dark btn_view_bill" data-payment_id="'.encode_data($fees->payment_id).'" data-bill_type="hostel_fees_payment" data-target="#paymentBillModal" data-toggle="modal">Bill</button>'; } $row[] = $no; $row[] = $fees->session_start_year.'-'.$fees->session_end_year; $row[] = ucwords($fees->payment_month); $row[] = $fees->payment_year; $row[] = '<span class="label label-success "><i class="fa fa-inr"></i> '.number_format($fees->payment_value,2).'</span>'; $row[] = ($penalty_applied==TRUE)?'<span class="label label-success "><i class="fa fa-inr"></i> '.number_format($fees->payment_late_value,2).'</span>':''; $row[] = '<span class="label label-success "><i class="fa fa-inr"></i> '.number_format($total_due,2).'</span>'; $row[] = date('d-m-Y',strtotime($fees->due_at)); $row[] = ($fees->payment_status=='paid')?date('d-m-Y',strtotime($fees->recieved_at)):'<span class="label label-danger ">'.ucwords($fees->payment_status).'</span>'; $row[] = $paybtn; $data[] = $row; } $output = array( "draw" => isset($posts['draw'])?$posts['draw']:'', "recordsTotal" => $this->fm->_get_hostel_fees_payment($posts,$param,TRUE), "recordsFiltered" => $this->fm->_get_hostel_fees_payment($posts,$param,TRUE), "data" => $data, ); echo json_encode($output); }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } } //College Profile public function indexCollegeProfile(){ if(session_userdata('admin_id') && session_userdata('isAdminLoggedin')==TRUE){ $_states=array(); $institute_data=check_institute($this->data['userdata']); //print_obj($institute_data);die; if($institute_data['inst_type']=='institute'){ $inst_id=$institute_data['institute_id']; $college_data_found=$this->um->get_user(array('user_pk_id'=>$inst_id),'institute'); $college_img_data=$this->sm->get_file(array('storage_type'=>'college_logo','storage_type_id'=>$inst_id)); //print_obj($college_img_data);die; if(!empty($college_img_data) && is_file(FCPATH.$college_img_data->media_disk_path)){ $college_logo=base_url($college_img_data->media_disk_path_relative); }else{ $college_logo=$this->data['no_image']; } $college_imgseal_data=$this->sm->get_file(array('storage_type'=>'college_seal_logo','storage_type_id'=>$inst_id)); if(!empty($college_imgseal_data) && is_file(FCPATH.$college_imgseal_data->media_disk_path)){ $college_seal_logo=base_url($college_imgseal_data->media_disk_path_relative); }else{ $college_seal_logo=$this->data['no_image']; } $college_signature_data=$this->sm->get_file(array('storage_type'=>'college_authorize_signature_logo','storage_type_id'=>$inst_id)); if(!empty($college_signature_data) && is_file(FCPATH.$college_signature_data->media_disk_path)){ $college_authorized_signature_logo=base_url($college_signature_data->media_disk_path_relative); // print_obj($college_authorized_signature_logo); // die(); }else{ $college_authorized_signature_logo=$this->data['no_image']; } $college_imgprincipal_sign_data=$this->sm->get_file(array('storage_type'=>'principal_signature','storage_type_id'=>$inst_id)); if(!empty($college_imgprincipal_sign_data) && is_file(FCPATH.$college_imgprincipal_sign_data->media_disk_path)){ $principal_sign=base_url($college_imgprincipal_sign_data->media_disk_path_relative); //print_obj(is_file(FCPATH.$college_imgprincipal_sign_data->media_disk_path)); // die(); }else{ $principal_sign=$this->data['no_image']; } $states=$this->sm->_get_states(array('state_country_id'=>'1'),FALSE); if(!empty($states)){ foreach ($states as $key => $value) { $_states[]=array( 'state_id'=>$value->state_id, 'state_name'=>$value->state_name, 'selected'=>(!empty($college_data_found) && ($value->state_id==$college_data_found->user_state))?'selected':'' ); } } //print_obj($college_data_found);die; $this->data['college_id']=encode_data($college_data_found->user_pk_id); $this->data['college_logo']=$college_logo; $this->data['college_data']=$college_data_found; $this->data['college_seal_logo']=$college_seal_logo; $this->data['principal_sign']=$principal_sign; $this->data['college_authorized_signature_logo']=$college_authorized_signature_logo; $this->data['states']=$_states; $this->data['page_title']='College Profile'; $this->theme->title($this->data['page_title'])->load('accounts/vw_college_profile', $this->data); } }else{ redirect($this->data['base_url']); } } public function onUpdateCollegeProfile(){ if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){ if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){ $college_id=post_data('_college'); $college_name=post_data('college_name'); $college_email=post_data('college_email'); $college_phone=post_data('college_phone'); $college_pan=post_data('college_pan'); $college_gst_no=post_data('college_gst_no'); $college_tan_no=post_data('college_tan_no'); $college_estd_year=post_data('college_estd_year'); $college_country=post_data('college_country'); $college_state=post_data('college_state'); $college_city=post_data('college_city'); $college_address=post_data('college_address'); $college_website=post_data('college_website'); $college_affiliation=post_data('college_affiliation'); $college_affiliation_no=post_data('college_affiliation_no'); $college_trust_name=post_data('college_trust_name'); $college_trust_pan_no=post_data('college_trust_pan_no'); $college_trust_contact_no=post_data('college_trust_contact_no'); $college_old_password=post_data('college_old_password'); $college_new_password=post_data('college_new_password'); $msg=''; if(!empty($college_id)){ $institute_data=check_institute($this->data['userdata']); $college_id=decode_data($college_id); if($institute_data['inst_type']=='institute'){ $college_data_found=$this->um->get_user(array('user_pk_id'=>$college_id),'institute'); }else if($institute_data['inst_type']=='institute_branch'){ $college_data_found=$this->um->get_user(array('branch_user_id'=>$college_id),'institute_branch'); } if(!empty($college_data_found)){ if($institute_data['inst_type']=='institute'){ $user_code=cleanString($college_data_found->user_code); $storage_dir='institutes/'.$user_code; $college_data_to_update=array( 'user_profile_name'=>$college_name, 'user_email'=>$college_email, 'user_contact_no'=>$college_phone, 'user_pan_no'=>$college_pan, 'user_tan_no'=>$college_tan_no, 'user_gst_no'=>$college_gst_no, 'user_estd_year'=>$college_estd_year, 'user_website'=>$college_website, 'user_affiliation'=>$college_affiliation, 'user_affiliation_no'=>$college_affiliation_no, 'user_address_1'=>$college_address, 'user_country'=>$college_country, 'user_state'=>$college_state, 'user_city'=>$college_city, 'user_trust_name'=>$college_trust_name, 'user_trust_pan_no'=>$college_trust_pan_no, 'user_trust_contact_no'=>$college_trust_contact_no ); $updated=$this->um->update_institute($college_data_to_update,array('user_pk_id'=>$college_id)); if($updated){ if(!empty($college_new_password)){ if(password_verify($college_old_password,$college_data_found->user_password)){ $password=password_hash($college_new_password, PASSWORD_BCRYPT, array('cost'=>12)); $college_user_data=array( 'user_name'=>$college_email, 'user_password'=>$password, 'user_type'=>'institute', 'updated_by_type'=>'self', 'updated_by'=>$user_id, 'updated_at'=>date('Y-m-d H:i:s') ); $this->um->update_users($college_user_data,array('user_id'=>$college_data->user_pk_id,'user_type'=>'institute')); $msg=''; }else{ $msg='Old password not matched.'; } } if(isset($_FILES['college_logo']) && $_FILES['college_logo']['name']!=''){ $college_logo=$this->sm->get_file(array('storage_type'=>'college_logo','storage_type_id'=>$college_id)); if(!empty($college_logo)){ if(is_dir(FCPATH.$college_logo->media_disk_path)){ @unlink($college_logo->media_disk_path); } $this->sm->delete_file(array('storage_type'=>'college_logo','storage_type_id'=>$college_id)); $file_operation_type='update'; }else{ $file_operation_type='new'; } $college_logo_data=array( 'file_size'=>'1', 'file_name'=>'college_logo', 'file_types'=>'png,jpg,jpeg', 'file_storage_dir'=>$storage_dir, 'file_storage_type'=>'college_logo', 'file_storage_type_id'=>$college_id, 'file_parent_id'=>$college_id, 'file_resize'=>false, 'file_resize_width'=>'200', 'file_resize_height'=>'200', 'file_compress'=>false, 'file_operation_type'=>$file_operation_type, 'file_uploaded_by'=>$this->data['userdata']->user_id ); $this->onUploadFiles($college_logo_data); } if(isset($_FILES['college_seal_logo']) && $_FILES['college_seal_logo']['name']!=''){ $college_seal_logo=$this->sm->get_file(array('storage_type'=>'college_seal_logo','storage_type_id'=>$college_id)); if(!empty($college_seal_logo)){ if(is_dir(FCPATH.$college_seal_logo->media_disk_path)){ @unlink($college_seal_logo->media_disk_path); } $this->sm->delete_file(array('storage_type'=>'college_seal_logo','storage_type_id'=>$college_id)); $file_operation_type='update'; }else{ $file_operation_type='new'; } $college_logo_data=array( 'file_size'=>'1', 'file_name'=>'college_seal_logo', 'file_types'=>'png,jpg,jpeg', 'file_storage_dir'=>$storage_dir, 'file_storage_type'=>'college_seal_logo', 'file_storage_type_id'=>$college_id, 'file_parent_id'=>$college_id, 'file_resize'=>false, 'file_resize_width'=>'200', 'file_resize_height'=>'200', 'file_compress'=>false, 'file_operation_type'=>$file_operation_type, 'file_uploaded_by'=>$this->data['userdata']->user_id ); $this->onUploadFiles($college_logo_data); } if(isset($_FILES['college_authorize_signature_logo']) && $_FILES['college_authorize_signature_logo']['name']!=''){ $college_authorize_signature_logo=$this->sm->get_file(array('storage_type'=>'college_authorize_signature_logo','storage_type_id'=>$college_id)); if(!empty($college_authorize_signature_logo)){ if(is_dir(FCPATH.$college_authorize_signature_logo->media_disk_path)){ @unlink($college_authorize_signature_logo->media_disk_path); } $this->sm->delete_file(array('storage_type'=>'college_authorize_signature_logo','storage_type_id'=>$college_id)); $file_operation_type='update'; }else{ $file_operation_type='new'; } $college_logo_data=array( 'file_size'=>'1', 'file_name'=>'college_authorize_signature_logo', 'file_types'=>'png,jpg,jpeg', 'file_storage_dir'=>$storage_dir, 'file_storage_type'=>'college_authorize_signature_logo', 'file_storage_type_id'=>$college_id, 'file_parent_id'=>$college_id, 'file_resize'=>false, 'file_resize_width'=>'200', 'file_resize_height'=>'200', 'file_compress'=>false, 'file_operation_type'=>$file_operation_type, 'file_uploaded_by'=>$this->data['userdata']->user_id ); $this->onUploadFiles($college_logo_data); } //principal_signature if(isset($_FILES['principal_signature']) && $_FILES['principal_signature']['name']!=''){ $principal_signature=$this->sm->get_file(array('storage_type'=>'principal_signature','storage_type_id'=>$college_id)); if(!empty($principal_signature)){ if(is_dir(FCPATH.$principal_signature->media_disk_path)){ @unlink($principal_signature->media_disk_path); } $this->sm->delete_file(array('storage_type'=>'principal_signature','storage_type_id'=>$college_id)); $file_operation_type='update'; }else{ $file_operation_type='new'; } $college_logo_data=array( 'file_size'=>'1', 'file_name'=>'principal_signature', 'file_types'=>'png,jpg,jpeg', 'file_storage_dir'=>$storage_dir, 'file_storage_type'=>'principal_signature', 'file_storage_type_id'=>$college_id, 'file_parent_id'=>$college_id, 'file_resize'=>false, 'file_resize_width'=>'200', 'file_resize_height'=>'200', 'file_compress'=>false, 'file_operation_type'=>$file_operation_type, 'file_uploaded_by'=>$this->data['userdata']->user_id ); $this->onUploadFiles($college_logo_data); } if(isset($_FILES['letter_head']) && $_FILES['letter_head']['name']!=''){ $letter_head=$this->sm->get_file(array('storage_type'=>'letter_head','storage_type_id'=>$college_id)); if(!empty($letter_head)){ if(is_dir(FCPATH.$letter_head->media_disk_path)){ @unlink($letter_head->media_disk_path); } $this->sm->delete_file(array('storage_type'=>'letter_head','storage_type_id'=>$college_id)); $file_operation_type='update'; }else{ $file_operation_type='new'; } $college_logo_data=array( 'file_size'=>'1', 'file_name'=>'letter_head', 'file_types'=>'png,jpg,jpeg', 'file_storage_dir'=>$storage_dir, 'file_storage_type'=>'letter_head', 'file_storage_type_id'=>$college_id, 'file_parent_id'=>$college_id, 'file_resize'=>false, 'file_resize_width'=>'200', 'file_resize_height'=>'200', 'file_compress'=>false, 'file_operation_type'=>$file_operation_type, 'file_uploaded_by'=>$this->data['userdata']->user_id ); $this->onUploadFiles($college_logo_data); } $return['success']='Account has been updated.'.$msg; }else{ $return['error']='Some error occurred.Try after sometime.'; } }else if($institute_data['inst_type']=='institute_branch'){ } }else{ $return['error']='College data not found'; } }else{ $return['error']='Data manipulation is not allowed.'; } json_headers($return); }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } } //System Settings public function onUpdateSystemSettings_old(){ if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){ if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){ $userdata=$this->data['userdata']; if(in_array($userdata->user_type, array('institute','institute_branch'))){ $stu_code_format=post_data('account_stu_code_format'); $paytm=post_data('paytm_payment_gateway'); $paytm_mode=post_data('paytm_payment_gateway_mode'); $paytm_test_mid=post_data('paytm_payment_gateway_test_mid'); $paytm_test_mkey=post_data('paytm_payment_gateway_test_key'); $paytm_live_mid=post_data('paytm_payment_gateway_live_mid'); $paytm_live_mkey=post_data('paytm_payment_gateway_live_key'); $webmaster_email=post_data('account_webmaster_email'); $info_email=post_data('account_info_email'); $email_protocol=post_data('account_mail_protocol'); $email_port=post_data('account_email_port'); $email_server=post_data('account_email_server'); $email_password=post_data('account_email_password'); $payment_settings_array=array( 'PAYMENT_MODE'=>$paytm_mode, 'PAYMENT_TEST_MERCHANT_MID'=>$paytm_test_mid, 'PAYMENT_TEST_MERCHANT_KEY'=>$paytm_test_mkey, 'PAYMENT_TEST_CHANNEL_ID'=>'WEB', 'PAYMENT_TEST_INDUSTRY_TYPE_ID'=>'Retail', 'PAYMENT_TEST_MERCHANT_WEBSITE'=>'WEBSTAGING', 'PAYMENT_PROD_MERCHANT_MID'=>$paytm_live_mid, 'PAYMENT_PROD_MERCHANT_KEY'=>$paytm_live_mkey, 'PAYMENT_PROD_CHANNEL_ID'=>'WEB', 'PAYMENT_PROD_INDUSTRY_TYPE_ID'=>'ECommerce', 'PAYMENT_PROD_MERCHANT_WEBSITE'=>'DEFAULT' ); $payment_settings= serialize($payment_settings_array); $payment_gateway_settings=$this->sm->get_system_settings(array('settings_inst_id'=>$userdata->user_id,'settings_type'=>'payment_gateway')); if(!empty($payment_gateway_settings)){ $this->sm->update_system_settings(array('settings_inst_id'=>$userdata->user_id,'settings_type'=>'payment_gateway','settings_type_key'=>$paytm,'settings_value'=>$payment_settings),array('settings_inst_id'=>$userdata->user_id,'settings_type'=>'payment_gateway','settings_type_key'=>$paytm)); }else{ $this->sm->store_system_settings(array('settings_inst_id'=>$userdata->user_id,'settings_type'=>'payment_gateway','settings_type_key'=>$paytm,'settings_value'=>$payment_settings)); } $student_code_settings=$this->sm->get_system_settings(array('settings_inst_id'=>$userdata->user_id,'settings_type'=>'student_code')); if(!empty($student_code_settings)){ $this->sm->update_system_settings(array('settings_inst_id'=>$userdata->user_id,'settings_type'=>'student_code','settings_type_key'=>'STUDENT CODE','settings_value'=>$stu_code_format),array('settings_inst_id'=>$userdata->user_id,'settings_type'=>'payment_gateway','settings_type_key'=>'STUDENT CODE')); }else{ $this->sm->store_system_settings(array('settings_inst_id'=>$userdata->user_id,'settings_type'=>'student_code','settings_type_key'=>'STUDENT CODE','settings_value'=>$stu_code_format)); } $email_settings_array=array( 'MAIL_PROTOCOL'=>$email_protocol, 'MAIL_PORT'=>$email_port, 'MAIL_PASSWORD'=>$email_password, 'MAIL_SERVER'=>$email_server, 'INFO_EMAIL'=>$info_email, 'WEBMASTER_EMAIL'=>$webmaster_email ); $email_settings_data=serialize($email_settings_array); $email_settings=$this->sm->get_system_settings(array('settings_inst_id'=>$userdata->user_id,'settings_type'=>'email_settings')); if(!empty($email_settings)){ $this->sm->update_system_settings(array('settings_inst_id'=>$userdata->user_id,'settings_type'=>'email_settings','settings_type_key'=>'EMAIL SETTINGS','settings_value'=>$email_settings_data),array('settings_inst_id'=>$userdata->user_id,'settings_type'=>'email_settings','settings_type_key'=>'EMAIL SETTINGS')); }else{ $this->sm->store_system_settings(array('settings_inst_id'=>$userdata->user_id,'settings_type'=>'email_settings','settings_type_key'=>'EMAIL SETTINGS','settings_value'=>$email_settings_data)); } $return['success']='Settings updated'; }else{ $return['error']='You are not permitted for this operation'; } json_headers($return); }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } } public function onUpdateSystemSettings(){ if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){ if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){ $userdata=$this->data['userdata']; if(in_array($userdata->user_type, array('institute','institute_branch'))){ $stu_code_format=post_data('account_stu_code_format'); $webmaster_email=post_data('account_webmaster_email'); $info_email=post_data('account_info_email'); $email_protocol=post_data('account_mail_protocol'); $email_port=post_data('account_email_port'); $email_server=post_data('account_email_server'); $email_password=post_data('account_email_password'); $payment_gateway=$this->input->post('payment_gateway'); //print_obj($payment_gateway);die; if(!empty($payment_gateway)){ foreach ($payment_gateway as $key => $value) { $gateway_data_to_store=array( $key=>$value ); $payment_settings= serialize($gateway_data_to_store); if(isset($value['PAYMENT_GATEWAY'])){ $this->sm->update_payment_gateway_institutes_settings(array('payment_gateway_id'=>$value['PAYMENT_GATEWAY'],'payment_gateway_inst_id'=>$userdata->user_id,'payment_gateway_status'=>'yes'),array('payment_gateway_id'=>$value['PAYMENT_GATEWAY'],'payment_gateway_inst_id'=>$userdata->user_id)); //$gateway_data=$this->sm->get_payment_gateway_settings(array('gateway_id'=>$value['PAYMENT_GATEWAY'])); $gateway_data=$this->sm->get_payment_gateway_settings(array('payment_gateway_id'=>$value['PAYMENT_GATEWAY'])); //print_obj($gateway_data);die; if(!empty($gateway_data)){ //$this->sm->update_payment_gateway_institutes_settings(array('payment_gateway_id'=>$value['PAYMENT_GATEWAY'],'payment_gateway_inst_id'=>$userdata->user_id,'payment_gateway_status'=>'yes'),array('payment_gateway_id'=>$value['PAYMENT_GATEWAY'],'payment_gateway_inst_id'=>$userdata->user_id)); $this->sm->delete_payment_gateway_institutes_settings(array('payment_gateway_id'=>$value['PAYMENT_GATEWAY'],'payment_gateway_inst_id'=>$userdata->user_id)); } $this->sm->store_payment_gateway_institutes_settings(array('payment_gateway_id'=>$value['PAYMENT_GATEWAY'],'payment_gateway_inst_id'=>$userdata->user_id,'payment_gateway_status'=>'yes')); $payment_gateway_settings=$this->sm->get_system_settings(array('settings_inst_id'=>$userdata->user_id,'settings_type'=>'payment_gateway','settings_type_id'=>$value['PAYMENT_GATEWAY'])); //print_obj($payment_gateway_settings);die; if(!empty($payment_gateway_settings)){ // $this->sm->update_system_settings(array('settings_inst_id'=>$userdata->user_id,'settings_type'=>'payment_gateway','settings_type_key'=>$gateway_data->gateway_name,'settings_type_id'=>$value['PAYMENT_GATEWAY'],'settings_value'=>$payment_settings),array('settings_inst_id'=>$userdata->user_id,'settings_type'=>'payment_gateway','settings_type_id'=>$value['PAYMENT_GATEWAY'])); $this->sm->delete_system_settings(array('settings_inst_id'=>$userdata->user_id,'settings_type'=>'payment_gateway','settings_type_key'=>$gateway_data->gateway_name,'settings_type_id'=>$value['PAYMENT_GATEWAY'])); } //else{ $this->sm->store_system_settings(array('settings_inst_id'=>$userdata->user_id,'settings_type_id'=>$value['PAYMENT_GATEWAY'],'settings_type'=>'payment_gateway','settings_type_key'=>$gateway_data->gateway_name,'settings_value'=>$payment_settings)); //} } } } $student_code_settings=$this->sm->get_system_settings(array('settings_inst_id'=>$userdata->user_id,'settings_type'=>'student_code')); if(!empty($student_code_settings)){ $this->sm->update_system_settings(array('settings_inst_id'=>$userdata->user_id,'settings_type'=>'student_code','settings_type_key'=>'STUDENT CODE','settings_value'=>$stu_code_format),array('settings_inst_id'=>$userdata->user_id,'settings_type'=>'payment_gateway','settings_type_key'=>'STUDENT CODE')); }else{ $this->sm->store_system_settings(array('settings_inst_id'=>$userdata->user_id,'settings_type'=>'student_code','settings_type_key'=>'STUDENT CODE','settings_value'=>$stu_code_format)); } $email_settings_array=array( 'MAIL_PROTOCOL'=>$email_protocol, 'MAIL_PORT'=>$email_port, 'MAIL_PASSWORD'=>$email_password, 'MAIL_SERVER'=>$email_server, 'INFO_EMAIL'=>$info_email, 'WEBMASTER_EMAIL'=>$webmaster_email ); $email_settings_data=serialize($email_settings_array); $email_settings=$this->sm->get_system_settings(array('settings_inst_id'=>$userdata->user_id,'settings_type'=>'email_settings')); if(!empty($email_settings)){ $this->sm->update_system_settings(array('settings_inst_id'=>$userdata->user_id,'settings_type'=>'email_settings','settings_type_key'=>'EMAIL SETTINGS','settings_value'=>$email_settings_data),array('settings_inst_id'=>$userdata->user_id,'settings_type'=>'email_settings','settings_type_key'=>'EMAIL SETTINGS')); }else{ $this->sm->store_system_settings(array('settings_inst_id'=>$userdata->user_id,'settings_type'=>'email_settings','settings_type_key'=>'EMAIL SETTINGS','settings_value'=>$email_settings_data)); } $booking_fee_settings=$this->sm->get_system_settings(array('settings_inst_id'=>$userdata->user_id,'settings_type'=>'booking_fee_mandatory')); if(!empty($booking_fee_settings)){ $this->sm->update_system_settings(array('settings_inst_id'=>$userdata->user_id,'settings_type'=>'booking_fee_mandatory','settings_type_key'=>'BOOKING FEE MANDATORY','settings_value'=>post_data('account_seat_booking_payment_mandate')),array('settings_inst_id'=>$userdata->user_id,'settings_type'=>'booking_fee_mandatory')); }else{ $this->sm->store_system_settings(array('settings_inst_id'=>$userdata->user_id,'settings_type'=>'booking_fee_mandatory','settings_type_key'=>'BOOKING FEE MANDATORY','settings_value'=>post_data('account_seat_booking_payment_mandate'))); } $return['success']='Settings updated'; }else{ $return['error']='You are not permitted for this operation'; } json_headers($return); }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } } public function onCheckSendMail(){ if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){ if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){ $from_email=post_data('from_email'); $to_email=post_data('to_email'); $port=post_data('port'); $host=post_data('mail_host'); $password=post_data('mail_password'); $mail_data['protocol']='smtp'; $mail_data['smtp_host']=$host;//'mail.ncriptech.com'; $mail_data['password']=$password;//'#RK4uHziO=?-'; $mail_data['port']=$port;//'465'; $mail_data['from']=$from_email; $mail_data['from_name']='CMS'; $mail_data['to']=$to_email; $mail_data['subject']='Testing mail'; $mail_data['data']='Test mail'; //print_obj($mail_data); $mail_sent=send_system_mail($mail_data,'text'); //print_obj($mail_sent);die; if($mail_sent=='true'){ $return['success']='Test mail sent'; }else{ $return['error']=$mail_sent; } json_headers($return); }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } } }