MMCT TEAM
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/cron/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/celkcksm/ecampus.ncriptech.com/application/controllers/cron/Admission.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Admission extends CI_Controller {

	public function __construct(){
		parent::__construct();
		$this->load->model(array('lms/book_model'=>'lmsbm','lms/rack_model'=>'rcm','lms/publisher_model'=>'pbm','lms/category_model'=>'cam','lms/author_model'=>'aum','lms/language_model'=>'lsmlm','lms/issues_model'=>'lsmism'));
	}


	public function import_admission_data_from_excel(){
		// Get the list of institutes
		$institutes = $this->um->get_institute(null, FALSE);

		// Check if institutes data is not empty
		if (!empty($institutes)) {
			foreach ($institutes as $key => $value) {
				
                $db_group = $value->user_code;
				$excel_format=$value->student_excel_format;

				$excel_temp_data=$this->um->get_excel_temp_students(array('data_imported'=>'no'),FALSE,$db_group);

				//print_obj($excel_temp_data);die;

				if(!empty($excel_temp_data)){
					$student_code_settings=$this->sm->get_system_settings(array('settings_inst_id'=>$inst_id,'settings_type'=>'student_code'),TRUE,$db_group);
					$count_data=1;
					foreach ($excel_temp_data as $k => $v) {
						$seat_booking_fee=$v->seat_booking_fee;
						$created_by=$this->um->_get_user(array('user_id'=>$v->created_by),TRUE,$db_group);
						// && !empty($v->last_name)
						if(!empty($v->first_name)){
							$inst_id=$v->inst_id;
							$inst_parent_id=$v->inst_parent_id;
							$user_id=$inst_id;
							$session=$v->course_session;
							$course=$v->course;
							$course_fee=$v->fee;
							$created_at=$v->created_at;
							$emp_id=$v->created_by;
							$admission_fees=$v->admission_fees;
							$is_lateral=$v->course_is_lateral;
							$total_students=$this->um->get_count_students(array('stu_inst_id'=>$inst_id));
							// $student_found=$this->um->get_duplicate_student(array('stu_email'=>$v->email),array('stu_ph_no'=>$v->phone_no),null,null,FALSE,$db_group);
							$phone_no=trim($v->phone_no);
							if($phone_no!='' || !empty($phone_no)){
								$student_found=$this->um->get_duplicate_student(array('stu_ph_no'=>$phone_no),null,null,null,FALSE,$db_group);
								$student_count=$student_found[0]->counted;
								$user_name=$v->phone_no;
							}else{
								$student_count=0;								
							}
							
							//print_obj($student_found);
							if($student_count==0){
								
								$course_data=$this->cm->get_course(array('course_id'=>$course,'course_inst_id'=>$inst_id),TRUE,$db_group);

								//print_obj($course_data);

								if(!empty($course_data)){
									$session_data=$this->sessm->get_session(array('session_id'=>$session,'session_inst_id'=>$inst_id),TRUE,$db_group);

									if(!empty($student_code_settings)){
										$student_code_settings=$student_code_settings->settings_value;
									}else{
										$student_code_settings=null;
									}

									//Store students record
									$student_data=array(
										'stu_roll_no'=>$v->college_roll_no,
										'stu_enrollment_no'=>$v->enrollment_no,
										'stu_reg_no'=>$v->reg_no,
										'stu_inst_id'=>$inst_id,
										'stu_inst_parent_id'=>$v->inst_parent_id,
										'stu_inst_type'=>$v->inst_type,
										'stu_first_name'=>$v->first_name,
										'stu_mid_name'=>$v->middle_name,
										'stu_last_name'=>$v->last_name,
										'stu_email'=>$v->email,
										'stu_ph_no'=>$v->phone_no,
										'stu_whatsapp_no'=>$v->whatsapp_no,
										'stu_aadhar'=>$v->aadhar,
										'stu_pan'=>$v->pan_no,
										'stu_dob'=>$v->dob,
										'stu_gender'=>$v->gender,
										'stu_religion'=>$v->religion,
										'stu_caste'=>$v->caste,
										'stu_blood_group'=>$v->blood_group,
										'stu_nationality'=>'176',
										'stu_has_illness'=>'no',
										'stu_father_first_name'=>$v->father_first_name,
										'stu_father_mid_name'=>$v->father_middle_name,
										'stu_father_last_name'=>$v->father_last_name,
										'stu_mother_first_name'=>$v->mother_first_name,
										'stu_mother_mid_name'=>$v->mother_middle_name,
										'stu_mother_last_name'=>$v->mother_last_name,
										'stu_method_subject'=>$v->method,
										'stu_2nd_method_subject'=>$v->second_method,
										'stu_cur_addr_country'=>'176',
										'stu_cur_state'=>$v->state,
										'stu_cur_city'=>$v->city,
										'stu_cur_district'=>$v->district,
										'stu_cur_pincode'=>$v->pincode,
										'stu_cur_ps'=>$v->police_station,
										'stu_cur_po'=>$v->po_box,
										'stu_cur_address_line'=>$v->address,
										'stu_school_name'=>$v->stu_school_name,
										'stu_school_yop'=>$v->school_yop,
										'stu_avail_hostel'=>'no',
										'stu_regster_mode'=>'new_admission',
										'created_by'=>$v->created_by,
										'created_at'=>$created_at
									);

									$student_id=$this->um->store_students($student_data,FALSE,$db_group);

									//print_obj($student_data);

									echo 'Student ID: ' . $student_id.'<br>';
									if($student_id){
										//Create student User
										$user_name=emp_code('STU' , $v->temp_id);
										$password=generate_password('Password@123%');
										$student_userdata=array(
											'user_name'=>$user_name,
											'user_code'=>$v->inst_code,
											'user_password'=>$password,
											'user_password_visible'=>encode_data($stu_password),
											'user_type'=>'student',
											'user_permissions'=>null,
											'user_status'=>'active',
											'created_by_type'=>'institute',
											'created_by'=>$inst_id,
											'created_at'=>$created_at
										);

										$student_user_id=$this->um->store_users($student_userdata,$db_group);

										if($student_user_id){
											
											$student_id_val=$total_students+1;

											$student_code_settings=$student_code_settings;
											$course_code=($is_lateral=='yes')?$course_data->course_code.'(L)':$course_data->course_code;
											$session_start_year=$session_data->session_start_year;
											$session_end_year=$session_data->session_end_year;
											$user_code=$v->inst_code;

											$code_data=compact('student_code_settings','course_code','session_start_year','session_end_year','user_code','student_id_val');

											$stu_user_code=generate_stu_code($code_data);

											$this->um->update_students(array('stu_user_id'=>$student_user_id,'stu_user_code'=>$stu_user_code),array('stu_id'=>$student_id),FALSE,$db_group);

											echo 'Student User ID:'.$student_user_id;

											//Store academic data
											if(!empty($v->tenth_board)){
												$student_academic_data=array(
													'acad_stu_id'=>$student_user_id,
													'acad_stu_inst_id'=>$inst_id,
													'acad_stu_inst_parent_id'=>$v->inst_parent_id,
													'acad_10th_board'=>$v->tenth_board,
													'acad_10th_yop'=>$v->tenth_passing_year,
													'acad_10th_total_marks'=>$v->tenth_passing_marks,
													'acad_10th_percentage'=>$v->tenth_percentage,
													'created_by'=>$v->created_by,
													'created_at'=>$created_at
												);

												$this->um->store_students_academics($student_academic_data,$db_group);
											}
											

											//Store student course fees data
											

											if(!empty($v->course_fees)){
												$stu_course_data=array(
													'session_id'=>$session,
													'session_inst_id'=>$inst_id,
													'session_stu_id'=>$student_user_id,
													'session_course_id'=>$course_data->course_id,
													'session_course_fees'=>$v->course_fees,
													'is_lateral'=>'no',
													'session_course_booking_fee'=>(!empty($v->seat_booking_fee))?$v->seat_booking_fee:0
												);

												$course_fees_id=$this->sessm->store_session_course_student_wise($stu_course_data,$db_group);
											}else{
 												$course_fees=$this->sessm->__get_session_course_student_wise(array('session_stu_id'=>$student_user_id),'session_course_id,session_course_fees',TRUE,$db_group);

												// if(empty($course_fees)){
												// 	$stu_course_data=array(
												// 		'session_id'=>$session,
												// 		'session_inst_id'=>$inst_id,
												// 		'session_stu_id'=>$student_user_id,
												// 		'session_course_id'=>$course_data->course_id,
												// 		'session_course_fees'=>$course_data->session_course_fees,
												// 		'is_lateral'=>'no',
												// 		'session_course_booking_fee'=>(!empty($v->seat_booking_fee))?$v->seat_booking_fee:0
												// 	);
	
												// 	$this->sessm->store_session_course_student_wise($stu_course_data,$db_group);
												// }
											}

											echo '<br>Course Fees ID:'.$course_fees_id.'<br>';

											$admission_code=ge_rand_code('ADM',$db_group);

											echo 'Admission code:'.$admission_code;

											if(!empty($seat_booking_fee) && $seat_booking_fee>0){
												$booking_code=ge_rand_code('SB');
												$student_profile_id=$student_id;
												$parent_inst_id=$inst_parent_id;
												$is_lateral='no';
												$created_by=$v->created_by;
												$pay_booking_agent='';
												$booking_subject_id='0';
												if($v->agent_code!=''){
													$agent_data=$this->um->get_agents(array('agent_code'=>$v->agent_code),'agent',TRUE,$db_group);
													$pay_booking_agent=$agent_data->agent_id;
												}else{
													$pay_booking_agent=0;
												}

												$booking_data_to_store=compact('student_user_id','student_profile_id','inst_id','parent_inst_id','session','course','booking_subject_id','booking_code','pay_booking_agent','created_by','is_lateral');

                                                $seat_booking_id=store_seat_booking_data($booking_data_to_store);

												echo '<br>Seatbooking ID:'.$seat_booking_id;

												if($seat_booking_id){
													$seat_booking_payment_data=array(
														'booking_pk_id'=>$seat_booking_id,
														'booking_inst_id'=>$inst_id,
														'booking_inst_parent_id'=>$parent_inst_id,
														'booking_stu_id'=>$student_user_id,
														'booking_course_id'=>$course,
														'booking_subject_id'=>0,
														'booking_sess_id'=>$session,
														'booking_payment'=>$v->seat_booking_fee,
														'booking_pay_mode'=>'old_payment_before_software',
														'booking_payment_bank'=>null,
														'booking_payment_checq_no'=>null,
														'booking_payment_checq_files_ids'=>null,
														'booking_payment_deposite_bank'=>null,
														'booking_payment_paid'=>'paid',
														'booking_payment_recieved_date'=>date('Y-m-d',strtotime($v->seat_booking_date)),
														'booking_payment_note'=>'Old Seat Booking Payments',
														'created_at'=>$v->seat_booking_date,
														'created_by'=>$v->created_by
													);

													$seat_booking_payment_id=$this->adm->store_seat_booking_payment_data($seat_booking_payment_data,$db_group);

													echo '<br>Seatbooking Payment ID:'.$seat_booking_payment_id;

													if($seat_booking_payment_id){
														$txn=ge_rand_code_v1('TXN'.$inst_id.$seat_booking_id);
														echo '<br>TXN:'.$txn;
														$seatbooking_payment_details=array(
															'details_type'=>'seat_booking',
															'details_type_text'=>'Seat Booking Fees for '.$course_data->course_name.' Session:'.$session_start_year.'-'.$session_end_year.'['.$booking_code.']',
															'details_payment_type'=>'seatbooking_fees',
															'details_payment_id'=>$seat_booking_payment_id,
															'details_type_id'=>$seat_booking_id,
															'details_inst_id'=>$inst_id,
															'details_parent_inst_id'=>$parent_inst_id,
															'details_stu_id'=>$student_user_id,
															'details_agent_id'=>($pay_booking_agent>0)?$pay_booking_agent:null,
															'details_sess_id'=>$session,
															'details_course_id'=>$course,
															'details_subject_id'=>0,
															'details_payment_platform'=>'old_payment_before_software',//need to update
															'details_amount'=>$v->seat_booking_fee,
															'details_discount_amount'=>'0',
															'details_txn_id'=>$txn,
															'details_utr_id'=>null,
															'details_cheque_no'=>null,
															'details_pay_checq_files_ids'=>null,
															'details_order_id'=>$booking_code.'_stuinst',
															'details_order_code'=>$booking_code,
															'details_accounting_type'=>'income',
															'details_status'=>'recieved',
															'details_msg'=>'Payment Recieved',
															'details_created_by_type'=>$created_by->user_type,
															'details_msg'=>'Old payment before software recieved',
															'details_created_by'=>$v->created_by,
															'details_created_at'=>date('Y-m-d',strtotime($v->seat_booking_date))
														);

														$seat_booking_payment_details_id=$this->fm->store_payment_details($seatbooking_payment_details,$db_group);

														echo '<br>Seatbooking Payment Details ID:'.$seat_booking_payment_details_id;
													}
												}
											}else{
												$seat_booking_id=0;
											}

											//die;

											if(!empty($v->agent_fee) && is_numeric($v->agent_fee) && $pay_booking_agent!=0){
												$details_to_store=array(
													'agent_id'=>$pay_booking_agent,
													'booking_id'=>$seat_booking_id,
													'booking_type'=>'seat_booking',
													'stu_id'=>$student_user_id,
													'booking_code'=>$booking_code.'_agt_'.date('Ymd'),
													'session_id'=>$session,
													'course_id'=>$course,
													'subject_id'=>0,
													'inst_id'=>$inst_id,
													'inst_parent_id'=>$parent_inst_id,
													'amount_value'=>$v->agent_fee,
													'amount_paid'=>'no',
													'amount_created_at'=>date('Y-m-d',strtotime($v->admission_date))
												);
	
												$agent_payment_id=$this->fm->store_agent_payment($details_to_store,FALSE,$db_group);

												echo '<br>Agent Payment ID:'.$agent_payment_id;
											}

											//Store Student admission record
											$admission_details=array(
												'admission_seat_booking_converted'=>(!empty($seat_booking_fee) && $seat_booking_fee>0)?'yes':'no',
												'admission_full_paid'=>'yes',
												'admission_data_active'=>'yes',
												'admission_completed'=>'yes',
												'admission_docs_completed'=>'yes',
												'admission_seat_booking_id'=>$seat_booking_id,
												'admission_stu_id'=>$student_user_id,
												'admission_inst_id'=>$inst_id,
												'admission_inst_parent_id'=>$inst_parent_id,
												'admission_sess_id'=>$session,
												'admission_course_id'=>$course,
												'admission_subject_id'=>'0',
												'admission_section_id'=>'0',
												'admission_type'=>'direct_admission',
												'admission_application_type'=>'new_admission',
												'admission_agent_id'=>'0',
												'admission_code'=>$admission_code,
												'admission_avail_hostel'=>'no',
												'admission_hostel_id'=>'0',
												'admission_date'=>(!empty($v->admission_date))?$v->admission_date:NULL,
												'admission_payment_can_be_scheduled'=>'yes',
												'is_old_data'=>'yes',
												'created_by'=>$inst_id,
												'created_at'=>$created_at
											);
										
											$admission_id=$this->adm->store_admission_data($admission_details,$db_group);

											echo '<br>Admission ID:'.$admission_id;

											//Create installments
											$admission_fees=$v->admission_fee;
											$first_installment=$v->first_installment;
											$second_installment=$v->second_installment;
											$third_installment=$v->third_installment;
											$fourth_installment=$v->fourth_installment;
											$fifth_installment=$v->fifth_installment;
											$sixth_installment=$v->sixth_installment;
											$seventh_installment=$v->seventh_installment;
											$eighth_installment=$v->eighth_installment;

											$nineth_installment=$v->nineth_installment;
											$tenth_installment=$v->tenth_installment;
											$eleventh_installment=$v->eleventh_installment;
											$twelfth_installment=$v->twelfth_installment;

											$details_msg='Payment Recieved';
											$user_type='institute';

											if($admission_fees>0){
												//Payment details
												$details_order_id=$admission_code.'_'.date('Y').'_'.generate_string(4).'_'.$admission_code.'_stuinst';
												$details_order_code=$admission_code;
												$txn_id=ge_rand_code_v1('TXN'.$inst_id.$user_id.$admission_id.$installment_no);
												$details_msg='';
												$admission_fees_payment_details=array(
													'details_type'=>'new_admission',
													'details_payment_type'=>'admission_fees',
													'details_type_text'=>'Admission Payment',
													'details_type_id'=>$admission_id,
													'details_payment_id'=>null,
													'details_created_at_actual'=>$created_at,
													'details_created_at'=>$created_at,
													'details_emp_id'=>$emp_id,
													'details_stu_id'=>$student_user_id,
													'details_agent_id'=>null,
													'details_inst_id'=>$inst_id, 
													'details_installment_id'=>$installment_id,          
													'details_parent_inst_id'=>$inst_parent_id,
													'details_sess_id'=>$session,
													'details_course_id'=>$course,
													'details_payment_platform'=>'old_payment_before_software',
													'details_amount'=>$admission_fees,
													'details_discount_amount'=>'0',
													'details_txn_id'=>$txn_id,
													'details_order_id'=>$details_order_id,
													'details_order_code'=>$details_order_code,
													'details_accounting_type'=>'income',
													'details_accounting_type_id'=>'1',
													'details_accounting_dr_cr'=>'credit',
													'details_accounting_type_p_id'=>'19',
													'details_status'=>'success',
													'details_pay_currency'=>'inr',
													'details_msg'=>$details_msg,
													'details_created_by_type'=>$user_type,
													'details_created_by'=>$user_id,            
													'details_updated_by_type'=>$user_type,
													'details_updated_by'=>$user_id,
													'details_updated_at'=>date('Y-m-d H:i:s')   
												);

												$admission_payment_id=$this->fm->store_payment_details($admission_fees_payment_details,$db_group);

												echo '<br>Admission Payment ID:'.$admission_payment_id;

											}

											if(!empty($first_installment) && !empty($v->first_installment_date)){
												$installment_no=1;
												$amount=$first_installment;
												$discount=$v->discount;
												$installment_date=$v->first_installment_date;
												$paid_full=in_array($v->first_installment_paid,array('y','Y','Yes','yes','YES','YEs','yEs','yeS'))?'yes':'no';
												$first_installment_data=compact('installment_no','student_user_id','inst_id','inst_parent_id','admission_id','session','course','amount','discount','installment_date','user_id','emp_id','created_at','details_msg','user_type','admission_code','paid_full');											
												store_installments($first_installment_data,$db_group);
											}

											if(!empty($second_installment) && !empty($v->second_installment_date)){
												$installment_no=2;
												$amount=$second_installment;
												$discount=0;
												$installment_date=$v->second_installment_date;
												$paid_full=in_array($v->second_installment_paid,array('y','Y','Yes','yes','YES','YEs','yEs','yeS'))?'yes':'no';
												$second_installment_data=compact('installment_no','student_user_id','inst_id','inst_parent_id','admission_id','session','course','amount','discount','installment_date','user_id','emp_id','created_at','details_msg','user_type','admission_code','paid_full');
												store_installments($second_installment_data,$db_group);
											}

											if(!empty($third_installment) && !empty($v->third_installment_date)){
												$installment_no=3;
												$amount=$third_installment;
												$discount=0;
												$installment_date=$v->third_installment_date;
												$paid_full=in_array($v->third_installment_paid,array('y','Y','Yes','yes','YES','YEs','yEs','yeS'))?'yes':'no';
												$third_installment_data=compact('installment_no','student_user_id','inst_id','inst_parent_id','admission_id','session','course','amount','discount','installment_date','user_id','emp_id','created_at','details_msg','user_type','admission_code','paid_full');
												store_installments($third_installment_data,$db_group);
											}

											if(!empty($fourth_installment) && !empty($v->fourth_installment_date)){
												$installment_no=4;
												$amount=$fourth_installment;
												$discount=0;
												$installment_date=$v->fourth_installment_date;
												$paid_full=in_array($v->fourth_installment_paid,array('y','Y','Yes','yes','YES','YEs','yEs','yeS'))?'yes':'no';
												$fourth_installment_data=compact('installment_no','student_user_id','inst_id','inst_parent_id','admission_id','session','course','amount','discount','installment_date','user_id','emp_id','created_at','details_msg','user_type','admission_code','paid_full');
												store_installments($fourth_installment_data,$db_group);
											}

											if(!empty($fifth_installment) && !empty($v->fifth_installment_date)){
												$installment_no=5;
												$amount=$fifth_installment;
												$discount=0;
												$installment_date=$v->fifth_installment_date;
												$paid_full=in_array($v->fifth_installment_paid,array('y','Y','Yes','yes','YES','YEs','yEs','yeS'))?'yes':'no';
												$fifth_installment_data=compact('installment_no','student_user_id','inst_id','inst_parent_id','admission_id','session','course','amount','discount','installment_date','user_id','emp_id','created_at','details_msg','user_type','admission_code','paid_full');
												store_installments($fifth_installment_data,$db_group);
											}

											if(!empty($sixth_installment) && !empty($v->sixth_installment_date)){
												$installment_no=6;
												$amount=$sixth_installment;
												$discount=0;
												$installment_date=$v->sixth_installment_date;
												$paid_full=in_array($v->sixth_installment_paid,array('y','Y','Yes','yes','YES','YEs','yEs','yeS'))?'yes':'no';
												$sixth_installment_data=compact('installment_no','student_user_id','inst_id','inst_parent_id','admission_id','session','course','amount','discount','installment_date','user_id','emp_id','created_at','details_msg','user_type','admission_code','paid_full');
												store_installments($sixth_installment_data,$db_group);
											}

											if(!empty($seventh_installment) && !empty($v->seventh_installment_date)){
												$installment_no=7;
												$amount=$seventh_installment;
												$discount=0;
												$installment_date=$v->seventh_installment_date;
												$paid_full=in_array($v->seventh_installment_paid,array('y','Y','Yes','yes','YES','YEs','yEs','yeS'))?'yes':'no';
												$seventh_installment_data=compact('installment_no','student_user_id','inst_id','inst_parent_id','admission_id','session','course','amount','discount','installment_date','user_id','emp_id','created_at','details_msg','user_type','admission_code','paid_full');
												store_installments($seventh_installment_data,$db_group);
											}

											if(!empty($eighth_installment) && !empty($v->eighth_installment_date)){
												$installment_no=8;
												$amount=$eighth_installment;
												$discount=0;
												$installment_date=$v->eighth_installment_date;
												$paid_full=in_array($v->eighth_installment_paid,array('y','Y','Yes','yes','YES','YEs','yEs','yeS'))?'yes':'no';
												$eighth_installment_data=compact('installment_no','student_user_id','inst_id','inst_parent_id','admission_id','session','course','amount','discount','installment_date','user_id','emp_id','created_at','details_msg','user_type','admission_code','paid_full');
												store_installments($eighth_installment_data,$db_group);
											}

											if($excel_format=='2'){
												if(!empty($nineth_installment) && !empty($v->nineth_installment_date)){
													$installment_no=8;
													$amount=$nineth_installment;
													$discount=0;
													$installment_date=$v->nineth_installment_date;
													$paid_full=in_array($v->nineth_installment_paid,array('y','Y','Yes','yes','YES','YEs','yEs','yeS'))?'yes':'no';
													$nineth_installment_data=compact('installment_no','student_user_id','inst_id','inst_parent_id','admission_id','session','course','amount','discount','installment_date','user_id','emp_id','created_at','details_msg','user_type','admission_code','paid_full');
													store_installments($nineth_installment_data,$db_group);
												}

												if(!empty($tenth_installment) && !empty($v->tenth_installment_date)){
													$installment_no=8;
													$amount=$tenth_installment;
													$discount=0;
													$installment_date=$v->tenth_installment_date;
													$paid_full=in_array($v->tenth_installment_paid,array('y','Y','Yes','yes','YES','YEs','yEs','yeS'))?'yes':'no';
													$tenth_installment_data=compact('installment_no','student_user_id','inst_id','inst_parent_id','admission_id','session','course','amount','discount','installment_date','user_id','emp_id','created_at','details_msg','user_type','admission_code','paid_full');
													store_installments($tenth_installment_data,$db_group);
												}

												if(!empty($eleventh_installment) && !empty($v->eleventh_installment_date)){
													$installment_no=8;
													$amount=$eleventh_installment;
													$discount=0;
													$installment_date=$v->eleventh_installment_date;
													$paid_full=in_array($v->eleventh_installment_paid,array('y','Y','Yes','yes','YES','YEs','yEs','yeS'))?'yes':'no';
													$eleventh_installment_data=compact('installment_no','student_user_id','inst_id','inst_parent_id','admission_id','session','course','amount','discount','installment_date','user_id','emp_id','created_at','details_msg','user_type','admission_code','paid_full');
													store_installments($eleventh_installment_data,$db_group);
												}

												if(!empty($twelfth_installment) && !empty($v->twelfth_installment_date)){
													$installment_no=8;
													$amount=$twelfth_installment;
													$discount=0;
													$installment_date=$v->twelfth_installment_date;
													$paid_full=in_array($v->twelfth_installment_paid,array('y','Y','Yes','yes','YES','YEs','yEs','yeS'))?'yes':'no';
													$twelfth_installment_data=compact('installment_no','student_user_id','inst_id','inst_parent_id','admission_id','session','course','amount','discount','installment_date','user_id','emp_id','created_at','details_msg','user_type','admission_code','paid_full');
													store_installments($twelfth_installment_data,$db_group);
												}
											}
										}

										//$this->um->delete_excel_temp_students(array('phone_no'=>$v->phone_no,'temp_id'=>$v->temp_id),$db_group);

										$this->um->update_excel_temp_students(array('data_imported'=>'yes'),array('temp_id'=>$v->temp_id),FALSE,$db_group);
									}else{
										echo 'data not imported for '.$v->first_name.' '.$v->last_name.'<br>';
									}


									//Store student payment record

									$count_data++;
								}else{
									echo 'Course not found';
								}							
							}else{
								echo 'Student already exists';
							}
						}
						
					}
				}

                
            }
		}
	}

	// public function update_empty_installments(){
	// 	$institutes = $this->um->get_institute(null, FALSE);

	// 	// Check if institutes data is not empty
	// 	if (!empty($institutes)) {
	// 		foreach ($institutes as $key => $value) {
	// 			$db_group = $value->user_code;

	// 			$excel_temp_data=$this->um->get_excel_temp_students(array('data_imported'=>'no'),FALSE,$db_group);

	// 			if(!empty($excel_temp_data)){
	// 				foreach ($excel_temp_data as $k => $v) {
	// 					$first_installment=$v->
	// 					if(empty($first_installment)){
	// 						$installment_no=1;
	// 						$amount=$first_installment;
	// 						$discount=$v->discount;
	// 						$installment_date=$v->first_installment_date;
	// 						$paid_full=in_array($v->first_installment_paid,array('y','Y','Yes','yes','YES','YEs','yEs','yeS'))?'yes':'no';
	// 						$first_installment_data=compact('installment_no','student_user_id','inst_id','inst_parent_id','admission_id','session','course','amount','discount','installment_date','user_id','emp_id','created_at','details_msg','user_type','admission_code','paid_full');											
	// 						store_installments($first_installment_data,$db_group);
	// 					}
	// 				}
	// 			}
	// 		}
	// 	}
	// }


	public function cron_test()
	{
		// Load the necessary models if not autoloaded
	
		// Get the list of institutes
		$institutes = $this->um->get_institute(null, false);
	
		// Check if institutes data is not empty
		if (!empty($institutes)) {
			foreach ($institutes as $key => $value) {
				$db_group = $value->user_code;
	
				// Store caste category and get the ID
				$caste_id = $this->cst->store_ucaste_category(array('caste_name' => 'cron_test'), $db_group);
	
				// Log the caste ID into a file
				if ($caste_id) {
					log_message('Cron info', "Caste ID: {$caste_id} created for user_code: {$db_group}");
				} else {
					log_message('Cron error', "Failed to create caste category for user_code: {$db_group}");
				}
			}
		} else {
			// Log if no institutes are found
			log_message('info', 'No institutes found for processing.');
		}
	}
	

	public function update_late_fees()
	{
		
	}
}

MMCT - 2023