<?php
require "commonincludefiles.php";
require "data/sendingsms_studentpresant.php";
error_reporting(1);
if ($_SESSION["VedantnrCollegeId"] != "" && isset($_SESSION["VedantnrCollegeId"])) {
	$objStudent = new StudentMgmt();
	$objStudent->college_id = $_SESSION["VedantnrCollegeId"];
	$objStudent->branch_id = $_REQUEST["branch_hidden"];
	$objStudent->year_id = $_REQUEST["year_hidden"];
	$objStudent->semester_id = $_REQUEST["semester_hidden"];
	$objStudent->msc_subject = $_REQUEST["msc_subject"];
	
	$objStudent->student_formno = $_REQUEST["student_formno"];
	$objStudent->student_surname = $_REQUEST["student_surname"];
	$objStudent->student_firstname = $_REQUEST["student_firstname"];
	$objStudent->student_lastname = $_REQUEST["student_lastname"];
	$objStudent->student_category = $_REQUEST["student_category"];
	$objStudent->student_admby = $_REQUEST["student_admby"];
	$objStudent->student_gender = $_REQUEST["student_gender"];
	$objStudent->student_bloodgroup = $_REQUEST["student_bloodgroup"];
	$objStudent->student_birthdate = $_REQUEST["student_birthdate"];
	$objStudent->student_cast = $_REQUEST["student_cast"];
	$objStudent->student_nationality = $_REQUEST["student_nationality"];
	$objStudent->student_gturegno = $_REQUEST["student_gturegno"];
	$objStudent->student_admdate = $_REQUEST["student_admdate"];
	$objStudent->student_lastcollege = $_REQUEST["student_lastcollege"];


	$objStudent->student_mobileother = $_REQUEST["student_mobileother"];
	//2/08
	$objStudent->student_addressat = $_REQUEST["student_addressat"];
	$objStudent->student_addresspost = $_REQUEST["student_addresspost"];
	$objStudent->student_pincode = $_REQUEST["student_pincode"];
	$objStudent->student_phoneo = $_REQUEST["student_phoneo"];
	$objStudent->student_phoner = $_REQUEST["student_phoner"];
	$objStudent->student_mobileguardian = $_REQUEST["student_mobileguardian"];

	$objStudent->student_mobilestudents = $_REQUEST["student_mobilestudents"];
	$objStudent->student_mobileparents = $_REQUEST["student_mobileparents"];
	$objStudent->student_emailid = $_REQUEST["student_emailid"];
	//$objStudent->student_photo = $_REQUEST["student_photo"];
	$objStudent->student_remarks = $_REQUEST["student_remarks"];
	$objStudent->tfw_scheme = ($_REQUEST["tfw_scheme"] == "on") ? '1' : '0';


	$objStudent->previous_school = $_REQUEST["previous_school"];
	$objStudent->percentage = $_REQUEST["percentage"];
	$objStudent->grade = $_REQUEST["grade"];
	$objStudent->passing_month = $_REQUEST["passing_month"];
	$objStudent->student_yearofpassing = $_REQUEST["student_yearofpassing"];
	$objStudent->student_examseatno = $_REQUEST["student_examseatno"];
	$objStudent->student_nameboard = $_REQUEST["student_nameboard"];
	$objStudent->maths_mark = $_REQUEST["maths_mark"];
	$objStudent->sci_mark = $_REQUEST["sci_mark"];
	$objStudent->eng_mark = $_REQUEST["eng_mark"];
	$objStudent->twle_total_mark = $_REQUEST["twle_total_mark"];
	$objStudent->obtain_mark = $_REQUEST["obtain_mark"];
	$objStudent->twle_percentage = $_REQUEST["twle_percentage"];
	$objStudent->twle_rank = $_REQUEST["twle_rank"];
	$objStudent->twle_grade = $_REQUEST["twle_grade"];
	$objStudent->twle_board = $_REQUEST["twle_board"];
	$objStudent->bank_name = $_REQUEST["bank_name"];
	$objStudent->bank_account_no = $_REQUEST["bank_account_no"];
	$objStudent->bank_ifsc_code = $_REQUEST["bank_ifsc_code"];
	$objStudent->bank_address = $_REQUEST["bank_address"];
	$objStudent->bank_city = $_REQUEST["bank_city"];
	
	$objStudent->transport_facility = $_REQUEST["transport_facility"];
	$objStudent->scholarship_facility = $_REQUEST["scholarship_facility"];
	$objStudent->student_adharno = $_REQUEST["student_adharno"];
	$objStudent->dist_nameeng = $_REQUEST["dist_nameeng"];
	$objStudent->taluko_nameeng = $_REQUEST["taluko_nameeng"];
	$objStudent->state_nameeng = $_REQUEST["state_nameeng"];

	$objStudent->student_pincode1 = $_REQUEST["student_pincode1"];
	$objStudent->dist_nameeng1 = $_REQUEST["dist_nameeng1"];
	$objStudent->taluko_nameeng1 = $_REQUEST["taluko_nameeng1"];
	$objStudent->state_nameeng1 = $_REQUEST["state_nameeng1"];

	$objStudent->student_mother = $_REQUEST["student_mother"];
	$objStudent->allsem = $_REQUEST["allsem"];
	$objStudent->regular = $_REQUEST["regular"];
	$objStudent->allsem_transport = $_REQUEST["allsem_transport"];
	$objStudent->allsem_ctod = $_REQUEST["allsem_ctod"];
	$objStudent->student_ref = $_REQUEST["student_ref"];
	$objStudent->hostel_facility = $_REQUEST["hostel_facility"];
	$objStudent->scholarship_id = $_REQUEST["schlorship_hidden"];
	$objStudent->twle_seat = $_REQUEST["twle_seat"];
	$objStudent->twle_maths = $_REQUEST["twle_maths"];
	$objStudent->twle_chemistry = $_REQUEST["twle_chemistry"];
	$objStudent->twle_physics = $_REQUEST["twle_physics"];
	$objStudent->twle_other = $_REQUEST["twle_other"];
	$objStudent->chemistry_practical = $_REQUEST["chemistry_practical"];
	$objStudent->physics_practical = $_REQUEST["physics_practical"];
	$objStudent->other_practical = $_REQUEST["other_practical"];
	$objStudent->sci_total = $_REQUEST["sci_total"];
	$objStudent->sci_obtain = $_REQUEST["sci_obtain"];
	$objStudent->sci_percentage = $_REQUEST["sci_percentage"];
	$objStudent->bsc_college = $_REQUEST["bsc_college"];
	$objStudent->bsc_university = $_REQUEST["bsc_university"];
	$objStudent->bscpassing_month = $_REQUEST["bscpassing_month"];
	$objStudent->bscstudent_yearofpassing = $_REQUEST["bscstudent_yearofpassing"];
	$objStudent->bsc_seatno = $_REQUEST["bsc_seatno"];
	$objStudent->bsc_total = $_REQUEST["bsc_total"];
	$objStudent->bsc_obtain = $_REQUEST["bsc_obtain"];
	$objStudent->bsc_percentage = $_REQUEST["bsc_percentage"];
	$objStudent->bsc_cgpa = $_REQUEST["bsc_cgpa"];
	$objStudent->bsc_spi = $_REQUEST["bsc_spi"];
	$objStudent->msc_college = $_REQUEST["msc_college"];
	$objStudent->msc_university = $_REQUEST["msc_university"];
	$objStudent->mscpassing_month = $_REQUEST["mscpassing_month"];
	$objStudent->mscstudent_yearofpassing = $_REQUEST["mscstudent_yearofpassing"];
	$objStudent->msc_seatno = $_REQUEST["msc_seatno"];
	$objStudent->msc_total = $_REQUEST["msc_total"];
	$objStudent->msc_obtain = $_REQUEST["msc_obtain"];
	$objStudent->msc_percentage = $_REQUEST["msc_percentage"];
	$objStudent->msc_cgpa = $_REQUEST["msc_cgpa"];
	$objStudent->msc_spi = $_REQUEST["msc_spi"];
	$objStudent->bed_college = $_REQUEST["bed_college"];
	$objStudent->bed_university = $_REQUEST["bed_university"];
	$objStudent->bedpassing_month = $_REQUEST["bedpassing_month"];
	$objStudent->bedstudent_yearofpassing = $_REQUEST["bedstudent_yearofpassing"];
	$objStudent->bed_seatno = $_REQUEST["bed_seatno"];
	$objStudent->bed_total = $_REQUEST["bed_total"];
	$objStudent->bed_obtain = $_REQUEST["bed_obtain"];
	$objStudent->bed_percentage = $_REQUEST["bed_percentage"];
	$objStudent->bed_cgpa = $_REQUEST["bed_cgpa"];
	$objStudent->bed_spi = $_REQUEST["bed_spi"];
	$objStudent->twle_biology = $_REQUEST["twle_biology"];
	$objStudent->biology_practical = $_REQUEST["biology_practical"];
	$objStudent->ba_core = $_REQUEST["ba_core"];
	$objStudent->ba_el1 = $_REQUEST["ba_el1"];
	$objStudent->ba_el2 = $_REQUEST["ba_el2"];
	$objStudent->bsc_group = $_REQUEST["bsc_group"];
	$objStudent->msc_group = $_REQUEST["msc_group"];


	//mansi
	$objStudent->branchyear_id = $_REQUEST["branchyear_hidden"];
	
	$objStudent->adm_conformation = $_REQUEST["adm_conformation"];
	$objStudent->reporting_date = $_REQUEST["reporting_date"];
	$objStudent->student_grno = $_REQUEST["student_grno"];
	$objStudent->twlepassing_month = $_REQUEST["twlepassing_month"];
	$objStudent->pr_rank = $_REQUEST["pr_rank"];
	$objStudent->twle_stream = $_REQUEST["twle_stream"];
	$objStudent->updown_strdate = $_REQUEST["updown_strdate"];
	$objStudent->updown_enddate = $_REQUEST["updown_enddate"];
	$objStudent->hostel_admdate = $_REQUEST["hostel_admdate"];
	$objStudent->hostel_candate = $_REQUEST["hostel_candate"];
	$objStudent->previous_school_address = $_REQUEST["previous_school_address"];
	$objStudent->notrials = $_REQUEST["notrials"];
	$objStudent->twl_school_address = $_REQUEST["twl_school_address"];
	$objStudent->twl_notrials = $_REQUEST["twl_notrials"];
	$objStudent->gnm_passcol = $_REQUEST["gnm_passcol"];
	$objStudent->uni_name = $_REQUEST["uni_name"];
	$objStudent->gnm_regname = $_REQUEST["gnm_regname"];
	$objStudent->reg_date = $_REQUEST["reg_date"];
	$objStudent->gnm_percentage = $_REQUEST["gnm_percentage"];
	$objStudent->council_date = $_REQUEST["council_date"];
	$objStudent->gnm_year = $_REQUEST["gnm_year"];
	$objStudent->degdiploma_certino = $_REQUEST["degdiploma_certino"];
	$objStudent->reviling_date = $_REQUEST["reviling_date"];
	$objStudent->reg_enddate = $_REQUEST["reg_enddate"];
	$objStudent->anm_passcol = $_REQUEST["anm_passcol"];
	$objStudent->anm_regname = $_REQUEST["anm_regname"];
	$objStudent->anm_percentage = $_REQUEST["anm_percentage"];
	$objStudent->anm_year = $_REQUEST["anm_year"];
	//2-08
	$objStudent->anmdegdiploma_certino = $_REQUEST["anmdegdiploma_certino"];
	$objStudent->anmreviling_date = $_REQUEST["anmreviling_date"];
	
	$objStudent->anm_uniname = $_REQUEST["anm_uniname"];
	$objStudent->anmregistration_no1 = $_REQUEST["anmregistration_no1"];
	$objStudent->anmregistration_no2 = $_REQUEST["anmregistration_no2"];
	$objStudent->anmreg_date = $_REQUEST["anmreg_date"];
	$objStudent->anmcouncil_date = $_REQUEST["anmcouncil_date"];
	$objStudent->anmreg_enddate = $_REQUEST["anmreg_enddate"];
	$objStudent->bsc_passcol = $_REQUEST["bsc_passcol"];
	$objStudent->bsc_regname = $_REQUEST["bsc_regname"];
	$objStudent->bsc_per = $_REQUEST["bsc_per"];
	$objStudent->bsc_year = $_REQUEST["bsc_year"];
	$objStudent->bscdegdiploma_certino = $_REQUEST["bscdegdiploma_certino"];
	$objStudent->additional_regno = $_REQUEST["additional_regno"];
	$objStudent->bsc_uniname = $_REQUEST["bsc_uniname"];
	$objStudent->bscregistration_no1 = $_REQUEST["bscregistration_no1"];
	$objStudent->bscregistration_no2 = $_REQUEST["bscregistration_no2"];
	$objStudent->bscreg_date = $_REQUEST["bscreg_date"];
	$objStudent->bsccouncil_date = $_REQUEST["bsccouncil_date"];
	$objStudent->bscreg_enddate = $_REQUEST["bscreg_enddate"];
	//02-08
	$objStudent->bscreviling_date = $_REQUEST["bscreviling_date"];
	$objStudent->pbbsc_passcol = $_REQUEST["pbbsc_passcol"];
	$objStudent->pbbsc_regname = $_REQUEST["pbbsc_regname"];
	$objStudent->pbbsc_percentage = $_REQUEST["pbbsc_percentage"];
	$objStudent->pbbsc_year = $_REQUEST["pbbsc_year"];
	//2/08
	$objStudent->pbbscdegdiploma_certino = $_REQUEST["pbbscdegdiploma_certino"];
	
	$objStudent->pbbsc_uniname = $_REQUEST["pbbsc_uniname"];
	$objStudent->pbbscregistration_no1 = $_REQUEST["pbbscregistration_no1"];
	$objStudent->pbbscregistration_no2 = $_REQUEST["pbbscregistration_no2"];
	$objStudent->pbbscreg_date = $_REQUEST["pbbscreg_date"];
	$objStudent->pbbsccouncil_date = $_REQUEST["pbbsccouncil_date"];
	$objStudent->pbbscreg_enddate = $_REQUEST["pbbscreg_enddate"];
	$objStudent->student_father = $_REQUEST["student_father"];
	$objStudent->student_guardian = $_REQUEST["student_guardian"];
	$objStudent->student_birthdateplace = $_REQUEST["student_birthdateplace"];
	$objStudent->student_religion = $_REQUEST["student_religion"];
	$objStudent->student_subcast = $_REQUEST["student_subcast"];
	$objStudent->marital_status = $_REQUEST["marital_status"];
	$objStudent->permanent_addressat = $_REQUEST["permanent_addressat"];
	$objStudent->permanent_addresspost = $_REQUEST["permanent_addresspost"];
	$objStudent->same_as_present = $_REQUEST["same_as_present"];
	$objStudent->parent_nationality = $_REQUEST["parent_nationality"];
	$objStudent->passport_validity = $_REQUEST["passport_validity"];
	$objStudent->passport_no = $_REQUEST["passport_no"];
	$objStudent->issued_by = $_REQUEST["issued_by"];
	$objStudent->student_fathermobile = $_REQUEST["student_fathermobile"];
	$objStudent->student_mothermobile = $_REQUEST["student_mothermobile"];
	$objStudent->registration_no1 = $_REQUEST["registration_no1"];
	$objStudent->registration_no2 = $_REQUEST["registration_no2"];


	$objStudent->gnm_month = $_REQUEST["gnm_month"];
	$objStudent->anm_month = $_REQUEST["anm_month"];
	$objStudent->bsc_month = $_REQUEST["bsc_month"];
	$objStudent->pbbsc_month = $_REQUEST["pbbsc_month"];
	
	// priyanshi
	$objStudent->student_age = $_REQUEST["student_age"];
	$objStudent->student_relation = $_REQUEST["student_relation"];
	$objStudent->student_nri = $_REQUEST["student_nri"];
	$objStudent->parent_occupation = $_REQUEST["parent_occupation"];
	$objStudent->parent_income = $_REQUEST["parent_income"];

	// edit mode 
	if ($_REQUEST["ID"] > 0 && isset($_REQUEST["ID"])) {
		$objStudent->student_id = $_REQUEST["ID"];
		$objStudent->edit();
	} else if ($_REQUEST["ID"] == 0 && isset($_REQUEST["ID"])) {
		$objStudent->add();
		$msgprefix = "Dear Parents, ";
		$msgsuffix = " From Image ETI.";
		$student_surname = $_REQUEST["student_surname"];
		$student_firstname = $_REQUEST["student_firstname"];
		$student_lastname = $_REQUEST["student_lastname"];
		$branch_disp = $_REQUEST["branch_disp"];
		$student_mobilestudents = $_REQUEST["student_mobilestudents"];
		$mobileno_parents = $_REQUEST["student_mobileparents"];
	}

	if ($objStudent->student_id > 0) {
		$student_id = $objStudent->student_id;
		/* START DATA SAVE IN DETAIL */
		$objStudDetail = new StudentDetailMgmt();
		$objStudDetail->student_id = $student_id;

		$objStudDetail->cur_branchid = $_REQUEST["branch_hidden"];
		$objStudDetail->cur_semesterid = $_REQUEST["semester_hidden"];
		$objStudDetail->cur_branchyearid = $_REQUEST["branchyear_hidden"];
		$objStudDetail->year_id = $_REQUEST["year_hidden"];

		$objStudDetail->current_active = 1;

		if ($_REQUEST["ID"] == 0) {
			$objStudDetail->AddNewSemester();
		} else {
			$objStudDetail->EditNewSemester();
		}
	}


	if ($objStudent->student_id > 0) {
		$student_id = $objStudent->student_id;
		/* START DATA SAVE IN DETAIL */
		$objtransportfacilityMgmt = new transportfacilityMgmt();
		$objtransportfacilityMgmt->student_id = $student_id;

		$objtransportfacilityMgmt->transport_facility = ($_REQUEST["transport_facility"] == "Updown Facility") ? "0" : ($_REQUEST["transport_facility"] == "Hostel Facility"? "1 " : "");

		$objtransportfacilityMgmt->hostel_admdate = $_REQUEST["hostel_admdate"];
		$objtransportfacilityMgmt->hostel_candate = $_REQUEST["hostel_candate"];
		$objtransportfacilityMgmt->updown_strdate = $_REQUEST["updown_strdate"];
		$objtransportfacilityMgmt->updown_enddate = $_REQUEST["updown_enddate"];

		

		if ($_REQUEST["ID"] == 0) {
			$objtransportfacilityMgmt->Add();
		} else {
			$objtransportfacilityMgmt->Edit();
		}
	}
	// if ($objStudent->student_id > 0) {
	// 	$student_id = $objStudent->student_id;
	// 	/* START DATA SAVE IN DETAIL */
	// 	$objAttachement = new AttachementMgmt();
	// 	$objAttachement->student_id = $student_id;
	// 	$objAttachement->last_marksheet = ($_REQUEST["last_marksheet"]== "on") ? '1' : '0';
	// 	$objAttachement->last_marksheetone = ($_REQUEST["last_marksheetone"]== "on") ? '1' : '0';
	// 	$objAttachement->last_marksheettow = ($_REQUEST["last_marksheettow"]== "on") ? '1' : '0';
	// 	$objAttachement->last_marksheetthree = ($_REQUEST["last_marksheetthree"]== "on") ? '1' : '0';;
	// 	$objAttachement->twl_marksheet = ($_REQUEST["twl_marksheet"]== "on") ? '1' : '0';
	// 	$objAttachement->twl_marksheetone = ($_REQUEST["twl_marksheetone"]== "on") ? '1' : '0';
	// 	$objAttachement->twl_marksheettwo = ($_REQUEST["twl_marksheettwo"]== "on") ? '1' : '0';
	// 	$objAttachement->twl_marksheetthree = ($_REQUEST["twl_marksheetthree"]== "on") ? '1' : '0';
	// 	$objAttachement->school_leaving = ($_REQUEST["school_leaving"]== "on") ? '1' : '0';
	// 	$objAttachement->hsc_credit = ($_REQUEST["hsc_credit"]== "on") ? '1' : '0';
	// 	$objAttachement->cast_certificate = ($_REQUEST["cast_certificate"]== "on") ? '1' : '0';
	// 	$objAttachement->income_certi =($_REQUEST["income_certi"]== "on") ? '1' : '0';
	// 	$objAttachement->add_proof = ($_REQUEST["add_proof"]== "on") ? '1' : '0';
	// 	$objAttachement->adhar_photo = ($_REQUEST["adhar_photo"]== "on") ? '1' : '0';
	// 	$objAttachement->character_certi = ($_REQUEST["character_certi"]== "on") ? '1' : '0';;
	// 	$objAttachement->gap_certi = ($_REQUEST["gap_certi"]== "on") ? '1' : '0';
	// 	$objAttachement->bank_passbook = ($_REQUEST["bank_passbook"]== "on") ? '1' : '0';
	// 	$objAttachement->graduation_marksheet = ($_REQUEST["graduation_marksheet"]== "on") ? '1' : '0';
	// 	$objAttachement->course_comp = ($_REQUEST["course_comp"]== "on") ? '1' : '0';
	// 	$objAttachement->midwifery_certi = ($_REQUEST["midwifery_certi"]== "on") ? '1' : '0';;
	// 	$objAttachement->conduct_certi = ($_REQUEST["conduct_certi"]== "on") ? '1' : '0';
	// 	$objAttachement->statecouncil_certi = ($_REQUEST["statecouncil_certi"]== "on") ? '1' : '0';
	// 	$objAttachement->councilrenewal_certi = ($_REQUEST["councilrenewal_certi"]== "on") ? '1' : '0';
	// 	$objAttachement->tenth_trial_certi = ($_REQUEST["tenth_trial_certi"]== "on") ? '1' : '0';
	// 	$objAttachement->twl_trial_certi = ($_REQUEST["twl_trial_certi"]== "on") ? '1' : '0';
	// 	$objAttachement->addmission_order_certi = ($_REQUEST["addmission_order_certi"]== "on") ? '1' : '0';
	
	// 	if ($_REQUEST["ID"] == 0) {
	// 		$objAttachement->Add();
	// 	} else {
	// 		$objAttachement->Edit();
	// 	}
	// }

	/* END DATA SAVE IN DETAIL */

	/*upload Photo*/
			if ($_REQUEST["path"] != NULL) {
				$FileName = $_REQUEST["path"];
			} else {
				$FileName = $_REQUEST["student_photo"];

				}
			if ($FileName != "" && $FileName != "default.gif") {
				$Ext = substr($FileName, strrpos($FileName, ".") + 1);
				$Ext = strtolower($Ext);
				$thumbimg = "student_" . $student_id . "." . $Ext;
				$thumbimg_path = $StudentPath  . $student_id."/Attachement/".$thumbimg; 

					if (file_exists($thumbimg_path)) {
					unlink($thumbimg_path);
				}
				copy($StudentPath . $FileName, $thumbimg_path);
				$file_path = realpath($thumbimg_path);
				chmod($file_path, 0777);

					if (file_exists($StudentPath . $FileName)) {
					unlink($StudentPath . $FileName);
				}

					$objStudent->student_photo = $thumbimg;
				$objStudent->updatePhoto();
			}

	

	echo '{"success":"true"}';
}
else{
	echo '{"success":"False","msg":"Session Expired"}';
}
?>