<?php

class StudentMgmt
{
	public $student_id;
	public $branch_id;
	public $college_id;
	public $semester_id;
	public $msc_subject;
	public $student_formno;
	public $student_surname;
	public $student_firstname;
	public $student_lastname;
	public $student_category;
	public $student_admby;
	public $student_gender;
	public $student_bloodgroup;
	public $student_birthdate;
	public $student_cast;
	public $student_nationality;
	public $student_gturegno;
	public $student_admdate;
	public $student_lastcollege;
	public $student_techcerti;
	public $student_meritmarks;
	public $student_mobileother;

	//2/08
	public $student_addressat;
	public $student_addresspost;
	public $student_pincode;
	public $student_phoneo;
	public $student_phoner;

	public $student_mobileguardian;
	public $student_mobilestudents;
	public $student_mobileparents;
	public $student_emailid;
	public $student_acpdcapplformno;
	public $student_acpdcregno;
	public $student_acpdcmeritno;
	public $student_photo;
	public $student_remarks;
	public $student_active;

	public $leave_type;
	public $leave_date;
	public $leave_reason;
	public $leave_comment;

	public $tfw_scheme;
	public $fees_flag;

	public $login_id;
	public $createdon;

	public $shift;
	public $reshuffling_turn;
	public $challan_bank_no;

	public $student_centerno;
	public $student_yearofpassing;
	public $student_examseatno;
	public $student_nameboard;
	public $previous_school;
	public $percentage;
	public $grade;
	public $passing_month;
	public $maths_mark;
	public $sci_mark;
	public $eng_mark;
	public $total;
	public $twle_total_mark;
	public $obtain_mark;
	public $twle_percentage;
	public $twle_rank;
	public $twle_grade;
	public $twle_board;
	public $iti_tota_mark;
	public $iti_rank;
	public $iti_grade;
	public $iti_trade;
	public $iti_name;
	public $iti_seat_no;
	public $iti_year_pass;
	public $bank_name;
	public $bank_account_no;
	public $bank_ifsc_code;
	public $bank_address;
	public $bank_city;
	//priyanshi
	public $student_age;
	public $student_relation;
	public $student_nri;
	public $parent_occupation;
	public $parent_income;
	public $student_count;
	public $student_signature;
	public $transport_facility;
	public $scholarship_facility;
	public $student_adharno;
	public $dist_nameeng;
	public $taluko_nameeng;
	public $state_nameeng;

	public $student_pincode1;
	public $dist_nameeng1;
	public $taluko_nameeng1;
	public $state_nameeng1;

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

	//mansi
	public $branchyear_id;
	public $adm_conformation;
	public $updown_strdate;
	public $updown_enddate;
	public $hostel_admdate;
	public $hostel_candate;
	public $previous_school_address;
	public $notrials;
	public $twl_school_address;
	public $twlepassing_month;
	public $twl_notrials;
	public $gnm_passcol;
	public $uni_name;
	public $gnm_regname;
	public $reg_date;
	public $gnm_percentage;

	public $council_date;
	public $gnm_year;
	public $degdiploma_certino;
	public $reviling_date;
	public $reg_enddate;

	public $anm_passcol;
	public $anm_regname;
	public $anm_percentage;
	public $anm_year;
	//2-08
	public $anmdegdiploma_certino;
	public $anmreviling_date;
	public $anm_uniname;
	public $anmregistration_no1;
	public $anmregistration_no2;
	public $anmreg_date;
	public $anmcouncil_date;
	public $anmreg_enddate;

	public $bsc_passcol;
	public $bsc_regname;
	public $bsc_per;
	public $bsc_year;
	public $bscdegdiploma_certino;
	public $additional_regno;
	public $bsc_uniname;
	public $bscregistration_no1;
	public $bscregistration_no2;
	public $bscreg_date;
	public $bsccouncil_date;
	public $bscreg_enddate;
	//2-08
	public $bscreviling_date;


	public $pbbsc_passcol;
	public $pbbsc_regname;
	public $pbbsc_percentage;
	public $pbbsc_year;
	//2/08
	public $pbbscdegdiploma_certino;
	public $pbbsc_uniname;
	public $pbbscregistration_no1;
	public $pbbscregistration_no2;
	public $pbbscreg_date;
	public $pbbsccouncil_date;
	public $pbbscreg_enddate;

	public $student_father;
	public $student_guardian;
	public $student_birthdateplace;
	public $student_religion;
	public $student_subcast;
	public $marital_status;
	public $permanent_addressat;
	public $permanent_addresspost;
	public $parent_nationality;
	public $passport_validity;
	public $passport_no;
	public $issued_by;
	public $student_fathermobile;
	public $student_mothermobile;

	public $student_grno;
	public $pr_rank;
	public $twle_stream;

	public $registration_no1;
	public $registration_no2;


	public $gnm_month;
	public $anm_month;
	public $bsc_month;
	public $pbbsc_month;

	public $year_id;
	function UpdateSuspend()
	{

		global $SQLDateFormat;

		$sql = "UPDATE cms_studentmaster SET 
				student_active = 0, 
				leave_type = '" . $this->leave_type . "',
				leave_date = STR_TO_DATE('" . $this->leave_date . "','$SQLDateFormat'), 
				year_id  =year_id ,					
				leave_reason = '" . replaceHtmlEditor($this->leave_reason) . "', 	
				leave_comment = '" . replaceHtmlEditor($this->leave_comment) . "'
				WHERE student_id = '" . $this->student_id . "' AND college_id = '" . $_SESSION["VedantnrCollegeId"] . "' ";
		dbQuery($sql);
	}

	function UpdateCancel()
	{

		global $SQLDateFormat;

		$sql = "UPDATE cms_studentmaster SET 
				student_active = 0, 
				leave_type = '" . $this->leave_type . "',
				leave_date = STR_TO_DATE('" . $this->leave_date . "','$SQLDateFormat'), 	
				year_id  = year_id ,
				leave_reason = '" . replaceHtmlEditor($this->leave_reason) . "', 	
				leave_comment = '" . replaceHtmlEditor($this->leave_comment) . "'
				WHERE student_id = '" . $this->student_id . "' AND college_id = '" . $_SESSION["VedantnrCollegeId"] . "' ";
		dbQuery($sql);
	}

	function UpdateAlumini()
	{

		global $SQLDateFormat;

		$sql = "UPDATE cms_studentmaster SET 
				student_active = 0, 
				leave_type = '" . $this->leave_type . "',
				leave_date = STR_TO_DATE('" . $this->leave_date . "','$SQLDateFormat'), 	
				leave_reason = '" . replaceHtmlEditor($this->leave_reason) . "', 	
				
				leave_comment = '" . replaceHtmlEditor($this->leave_comment) . "'
				WHERE student_id = '" . $this->student_id . "' AND college_id = '" . $_SESSION["VedantnrCollegeId"] . "' ";
		dbQuery($sql);
	}
	function getRecordById($student_id)
	{
		$qry = "select * from cms_studentmaster where 1=1 ";

		if ($student_id != "") {
			$qry .= " and student_id=$student_id ";
		}

		$out = dbQuery($qry);

		if (dbRows($out) > 0) {
			$this->student_count = 1;

			$row = dbArray($out);
			dbResult($out);
		}
	}

	function getGturegnoRecord($gtuno)
	{
		$qry = "select 
				sm.student_id,
				sd.cur_branchid,
				sd.cur_semesterid,	
				sd.year_id,
				sd.cur_branchyearid,
				sm.allsemfees,
				sm.allsem_ctod,
				sm.student_gturegno,
				YEAR(sm.student_admdate) as adm_year,
				sm.student_techcerti,
				CONCAT(sm.student_surname , ' ' , sm.student_firstname , ' ' ,sm.student_lastname) AS studentname
				from 
					cms_studentmaster sm,
					cms_studentdetail sd			
				where
				sm.college_id  = '" . $_SESSION["VedantnrCollegeId"] . "' 
				AND sm.student_id=sd.student_id			
				AND sm.student_active=1";


		if ($gtuno != "") {
			$qry .= " AND student_gturegno='$gtuno' ";
		}

		//echo $qry;
		$out = dbQuery($qry);
		return $out;
	}

	function getGturegnoRecord1($gtuno)
	{
		$qry = "select 
				sm.student_id,
						
				sm.allsemfees,
				CONCAT(sm.student_surname , ' ' , sm.student_firstname , ' ' ,sm.student_lastname) AS studentname
					(SELECT branch_name 
	  FROM cms_branchmaster sec 
	  WHERE sec.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' and sec.branch_id = sd.cur_branchid) AS branch_name,
		  (SELECT year_name
		  FROM cms_yearmaster ym 
	   WHERE ym.year_id = sd.year_id) AS year_name,
	  (SELECT branchyear_name
		  FROM 	cms_branchyear bry 
	   WHERE bry.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' AND bry.branchyear_id = sd.cur_branchyearid) AS branchyear_name,
	   (SELECT semester_name
		  FROM cms_semestermaster sem 
	   WHERE sem.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' AND sem.semester_id = sd.cur_semesterid) AS semester_name		   	 
				from 
					cms_studentmaster sm,
					cms_studentdetail sd,	
				where
				sm.college_id = '" . $_SESSION["VedantnrCollegeId"] . "' 
				AND sm.student_id = sd.student_id
				AND sm.student_active = 1";


		if ($gtuno != "") {
			$qry .= " AND student_gturegno='$gtuno' ";
		}
		$out = dbQuery($qry);
		return $out;
	}

	function getCountRecords($limit = 0, $start = 0, $condition = "", $order_field = "", $order_type = "")
	{
		$this->student_count = 0;

		$qry = "SELECT Count(*) AS Count				   	 
		  	  FROM
			  	cms_studentmaster sm,
				cms_studentdetail sd
		  	  WHERE 			  					  
				sd.college_id  = '" . $_SESSION["VedantnrCollegeId"] . "' and 
				sm.college_id  = '" . $_SESSION["VedantnrCollegeId"] . "' and 					  
				sd.year_id	  = '" . $_SESSION["aYear"] . "' and
				sm.student_id   = sd.student_id ";


		if ($condition != "") {
			$qry .= $condition;
		}


		$out = dbQuery($qry);

		if (dbRows($out) > 0) {
			$row = dbArray($out);
			extract($row);
			$this->student_count = $Count;
			dbResult($out);
		}
		return $this->student_count;
	}

	function getAllRecordssemleft1($limit = 0, $start = 0, $condition = "", $order_field = "", $order_type = "")
	{
		$this->student_count = 0;

		$qry = "SELECT sm.*,sd.* FROM cms_studentmaster sm,cms_studentdetail sd 
				WHERE sm.student_id = sd.student_id 
				and sd.current_active= 1 
				and sm.scholarship_facility = 'on'
				and sm.college_id= '" . $_SESSION["VedantnrCollegeId"] . "'";


		if ($condition != "") {
			$qry .= $condition;
		}
		if ($order_field != "" && $order_type != "") {
			$qry .= " order by $order_field $order_type";
		}

		if (intval($limit) > 0 && intval($start) >= 0) {
			$qry .= " Limit $start ,$limit";
		}

		//echo  $qry;
		//exit;
		$out = dbQuery($qry);
		// dbNumRows($out);
		if (dbRows($out) > 0) {
			dbRows($out);
			$this->student_count = dbRows($out);
		}
		return $out;

	}


	function getAllRecordssemleft($limit = 0, $start = 0, $condition = "", $order_field = "", $order_type = "")
	{
		$this->student_count = 0;

		$qry = "SELECT sm.*,sd.* FROM cms_studentmaster sm,cms_studentdetail sd 
				WHERE sm.student_id = sd.student_id 				
				and sm.college_id= '" . $_SESSION["VedantnrCollegeId"] . "' 
			
			 and sd.current_active= 1 ";


		if ($condition != "") {
			$qry .= $condition;
		}
		if ($order_field != "" && $order_type != "") {
			$qry .= " order by $order_field $order_type";
		}
		if (intval($limit) > 0 && intval($start) >= 0) {
			$qry .= " Limit $start ,$limit";
		}

		//echo  $qry;
		//exit;
		$out = dbQuery($qry);
		if (dbRows($out) > 0) {
			dbRows($out);
			$this->student_count = dbRows($out);

		}
		return $out;
	}


	function getAllRecordssemright($limit = 0, $start = 0, $condition = "", $order_field = "", $order_type = "")
	{
		$this->student_count = 0;
		$qry = "SELECT sm.*,sd.* FROM cms_studentmaster sm,cms_studentdetail sd 
				WHERE sm.student_id = sd.student_id 
				and sd.current_active= 1 
				and sm.college_id= '" . $_SESSION["VedantnrCollegeId"] . "' 
				AND sd.year_id = 14";

		if ($condition != "") {
			$qry .= $condition;
		}
		if ($order_field != "" && $order_type != "") {
			$qry .= " order by $order_field $order_type";
		}
		if (intval($limit) > 0 && intval($start) >= 0) {
			$qry .= " Limit $start ,$limit";
		}
		//echo  $qry;
		//exit;
		$out = dbQuery($qry);
		// dbNumRows($out);
		if (dbRows($out) > 0) {
			dbRows($out);
			$this->student_count = dbRows($out);

		}
		return $out;
	}


	function getAllRecordsyearleft($limit = 0, $start = 0, $condition = "", $order_field = "", $order_type = "")
	{
		$this->student_count = 0;

		$qry = "SELECT sm.*,sd.* FROM cms_studentmaster sm,cms_studentdetail sd 
				WHERE sm.student_id = sd.student_id and 
				sm.college_id= '" . $_SESSION["VedantnrCollegeId"] . "' and 
				sd.current_active= 1 ";
		if ($condition != "") {
			$qry .= $condition;
		}
		if ($order_field != "" && $order_type != "") {
			$qry .= " order by $order_field $order_type";
		}
		if (intval($limit) > 0 && intval($start) >= 0) {
			$qry .= " Limit $start ,$limit";
		}
		//echo  $qry;
		//exit;
		$out = dbQuery($qry);
		if (dbRows($out) > 0) {
			$this->student_count = dbRows($out);
		}
		return $out;
	}

	function getAllRecordsyearright($limit = 0, $start = 0, $condition = "", $order_field = "", $order_type = "")
	{
		$this->student_count = 0;
		$qry = "SELECT sm.*,sd.* FROM cms_studentmaster sm,cms_studentdetail sd 
				WHERE sm.student_id = sd.student_id and 
				sd.college_id= '" . $_SESSION["VedantnrCollegeId"] . "' and 
				sd.current_active= 1 ";

		if ($condition != "") {
			$qry .= $condition;
		}
		if ($order_field != "" && $order_type != "") {
			$qry .= " order by $order_field $order_type";
		}
		if (intval($limit) > 0 && intval($start) >= 0) {
			$qry .= " Limit $start ,$limit";
		}
		//echo  $qry;exit;
		$out = dbQuery($qry);
		if (dbRows($out) > 0) {
			$this->student_count = dbRows($out);
		}
		return $out;
	}
	function getAllRecords($limit = 0, $start = 0, $condition = "", $order_field = "", $order_type = "")
	{
		//echo "nirav";
		$this->student_count = 0;

		$qry = "SELECT sm.*,sd.* FROM cms_studentmaster sm,cms_studentdetail sd 
				WHERE sm.student_id = sd.student_id 
				and sm.college_id= '" . $_SESSION["VedantnrCollegeId"] . "'";

		if ($condition != "") {
			$qry .= $condition;
		}
		if ($order_field != "" && $order_type != "") {
			$qry .= " order by $order_field $order_type";
		}

		if (intval($limit) > 0 && intval($start) >= 0) {
			$qry .= " Limit $start ,$limit";
		}

		//echo  $qry;
		//exit;
		$out = dbQuery($qry);
		// dbNumRows($out);
		if (dbRows($out) > 0) {
			dbRows($out);
			$this->student_count = dbRows($out);

		}
		return $out;
	}


	function checknewadmission($student_id)
	{
		$qry = "";
		$qry = "SELECT fees_flag 
					FROM `cms_studentmaster`
				where
					student_id='" . $student_id . "'
					AND college_id = " . $_SESSION['VedantnrCollegeId'];

		$out = dbQuery($qry);

		if (dbRows($out) > 0) {
			$resut = dbArray($out);
			return $resut["fees_flag"];
		} else {
			return "0";
		}
	}

	function getStudentRecords($limit = 0, $start = 0, $condition = "", $order_field = "", $order_type = "")
	{
		$this->student_count = 0;

		$qry = "SELECT sm.*,sd.studentdetail_id,
		sd.student_id,
		sd.cur_branchid,
		sd.cur_branchyearid,
		sd.college_id,
		sd.year_id	
		 FROM cms_studentmaster sm,cms_studentdetail sd 
				WHERE sm.student_id = sd.student_id 
				and sm.college_id= '" . $_SESSION["VedantnrCollegeId"] . "'";

		if ($condition != "") {
			$qry .= $condition;
		}

		if ($order_field != "" && $order_type != "") {
			$qry .= " order by $order_field $order_type";
		}

		if (intval($limit) > 0 && intval($start) >= 0) {
			$qry .= " Limit $start , $limit";
		}

		$out = dbQuery($qry);

		if (dbRows($out) > 0) {
			$this->student_count = dbRows($out);

		}

		return $out;
	}

	function getAllStudentRecords($limit = 0, $start = 0, $condition = "", $order_field = "", $order_type = "")
	{
		$this->student_count = 0;

		$qry = "SELECT 
	  			sm.*,	
				sd.cur_branchid,
				sd.year_id,
				sd.cur_branchyearid,
				sd.cur_semesterid,
				YEAR(sm.student_admdate) as ayear,	
	   			CONCAT(sm.student_surname , ' ' , sm.student_firstname , ' ' ,sm.student_lastname) AS student_name,
				
			  	(SELECT branch_name 
				FROM cms_branchmaster sec 
				WHERE sec.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' and sec.branch_id=sd.cur_branchid) AS branch_name,
	  		  	(SELECT year_name 
				FROM cms_yearmaster ym 
				WHERE ym.year_id=sd.year_id) AS year_name,
	  		  	(SELECT branchyear_name 
				FROM cms_branchyear bry 
				WHERE bry.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' and bry.branchyear_id=sd.cur_branchyearid) AS branchyear_name,
	  		  	(SELECT semester_name
			   	 FROM cms_semestermaster sem 
			     WHERE  sem.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' AND sem.semester_id = sd.cur_semesterid) AS semester_name
			  					   	 
		  	  FROM
			  	cms_studentmaster sm, 
				cms_studentdetail sd
		  	  WHERE 			  	
			  	sm.student_id = sd.student_id AND
				sd.current_active = 1 AND
				sm.student_active = 1 AND		  
				sm.college_id  = '" . $_SESSION["VedantnrCollegeId"] . "' ";

		if ($condition != "") {
			$qry .= $condition;
		}

		if ($order_field != "" && $order_type != "") {
			$qry .= " order by $order_field $order_type";
		}

		if (intval($limit) > 0 && intval($start) >= 0) {
			$qry .= " Limit $start , $limit";
		}
		//echo $qry;
		$out = dbQuery($qry);

		if (dbRows($out) > 0) {
			$this->student_count = dbRows($out);

		}
		//echo $qry;
		return $out;
	}

	function CountAllStudentRecords($limit = 0, $start = 0, $condition = "", $order_field = "", $order_type = "")
	{
		$this->student_count = 0;

		$qry = "SELECT Count(sm.student_id) AS Count,
		sm.student_gturegno
		  		FROM
			  		cms_studentmaster sm,
					cms_studentdetail sd
		  	  	WHERE 			  					  
					sd.college_id  = '" . $_SESSION["VedantnrCollegeId"] . "' and 
					sm.college_id  = '" . $_SESSION["VedantnrCollegeId"] . "' and 					  
					sm.student_id   = sd.student_id and 
					sm.branch_id   = sd.cur_branchid ";

		if ($condition != "") {
			$qry .= $condition;
		}

		$out = dbQuery($qry);

		if (dbRows($out) > 0) {
			$row = dbArray($out);
			extract($row);
			$this->student_count = $Count;
			dbResult($out);
		}
		return $this->student_count;
	}
	function studentGridFilter4($limit = 0, $start = 0, $condition = "", $order_field = "", $order_type = "")
	{
		$this->student_count = 0;


		$qry = "SELECT 
	  			sm.student_id,
				sm.student_gturegno,
				sm.shift,
				sm.student_techcerti,
				sd.cur_shift, 
				YEAR(sm.student_admdate) as adm_year,
				sm.student_admdate, 
				CONCAT(sm.student_surname , ' ' , sm.student_firstname , ' ' ,sm.student_lastname) AS studentname,
				sm.student_birthdate,
				sm.student_gender,
				sm.student_admby,
				sm.student_category,	
				sm.student_rollno,
				sm.student_mobilestudents,
				sm.student_mobileparents,  		  
			  sd.batch_id,
				 
				(SELECT branch_name 
				FROM cms_branchmaster sec 
				WHERE sec.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' and sec.branch_id = sd.cur_branchid) AS branch_name,
	  		  	(SELECT 
					semester_name
			   	 FROM 
				 	cms_semestermaster sem 
			     WHERE 
				 sem.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "'
				 AND sem.semester_id = sd.cur_semesterid) AS semester_name		   	 
		  	  FROM
			  	cms_studentmaster sm,
				cms_studentdetail sd				
		  	  WHERE								
				sm.college_id  = '" . $_SESSION["VedantnrCollegeId"] . "' 
				AND sm.student_id=sd.student_id
				AND sm.student_active=1 ";


		if ($condition != "") {
			$qry .= $condition;
		}

		if ($order_field != "" && $order_type != "") {
			$qry .= " order by $order_field $order_type";
		}

		if (intval($limit) > 0 && intval($start) >= 0) {
			$qry .= " Limit $start , $limit";
		}

		//print $qry;
		//echo $qry;


		$out = dbQuery($qry);

		if (dbRows($out) > 0) {
			$this->student_count = dbRows($out);

		}
		return $out;
	}
	function studentGridFilter($limit = 0, $start = 0, $condition = "", $order_field = "", $order_type = "")
	{
		$this->student_count = 0;


		$qry = "SELECT 
	  			sm.student_id,
				CONCAT(sm.student_surname , ' ' , sm.student_firstname , ' ' ,sm.student_lastname) AS student_name,
				sm.student_gturegno,
				sd.year_id,
				sd.cur_branchyearid,
				sd.cur_semesterid,
				(SELECT branch_name 
				FROM cms_branchmaster sec 
				WHERE sec.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' and sec.branch_id = sd.cur_branchid) AS branch_name,
	  		  	(SELECT year_name
			   	 FROM cms_yearmaster ym 
			     WHERE ym.year_id = sd.year_id) AS year_name,
				(SELECT branchyear_name
			   	 FROM 	cms_branchyear bry 
			     WHERE bry.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' AND bry.branchyear_id = sd.cur_branchyearid) AS branchyear_name,
				 (SELECT semester_name
			   	 FROM cms_semestermaster sem 
			     WHERE sem.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' AND sem.semester_id = sd.cur_semesterid) AS semester_name		   	 
		  	  FROM
			  	cms_studentmaster sm,
				cms_studentdetail sd				
		  	  WHERE								
				sm.college_id  = '" . $_SESSION["VedantnrCollegeId"] . "' 
				AND sm.student_id= sd.student_id
				AND sd.current_active=1 ";

		if ($condition != "") {
			$qry .= $condition;
		}

		if ($order_field != "" && $order_type != "") {
			$qry .= " order by $order_field $order_type";
		}

		if (intval($limit) > 0 && intval($start) >= 0) {
			$qry .= " Limit $start , $limit";
		}


		//echo $qry;

		//exit;
		$out = dbQuery($qry);

		if (dbRows($out) > 0) {
			$this->student_count = dbRows($out);
			return $out;
		}
		return $out;
	}

	function studentGridFilter3($limit = 0, $start = 0, $condition = "", $order_field = "", $order_type = "")
	{
		$this->student_count = 0;


		$qry = "SELECT 
	  		sm.student_id,
				sm.student_gturegno,
				sm.shift,
				sm.student_techcerti,
				sd.cur_shift, 
				YEAR(sm.student_admdate) as adm_year,
				sm.student_admdate, 
				CONCAT(sm.student_surname , ' ' , sm.student_firstname , ' ' ,sm.student_lastname) AS studentname,
				sm.student_birthdate,
				sm.student_gender,
				sm.student_admby,
				sm.student_category,	
				sm.student_mobilestudents,
				sm.student_mobileparents,  		  
			  sd.batch_id,
				 
				(SELECT branch_name 
				FROM cms_branchmaster sec 
				WHERE sec.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' and sec.branch_id=sd.cur_branchid) AS branch_name,
	  		  	(SELECT year_name 
				FROM cms_yearmaster ym 
				WHERE ym.year_id=sd.year_id) AS year_name,
	  		  	(SELECT branchyear_name 
				FROM cms_branchyear bry 
				WHERE bry.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' and bry.branchyear_id=sd.cur_branchyearid) AS branchyear_name,
	  		  	(SELECT semester_name
			   	 FROM cms_semestermaster sem 
			     WHERE  sem.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' AND sem.semester_id = sd.cur_semesterid) AS semester_name
			  				   	 
		  	  FROM
			  	cms_studentmaster sm,
				cms_studentdetail sd				
		  	  WHERE								
				sm.college_id  = '" . $_SESSION["VedantnrCollegeId"] . "' 
				AND sm.student_id=sd.student_id
				AND sm.student_active=1 ";


		if ($condition != "") {
			$qry .= $condition;
		}

		if ($order_field != "" && $order_type != "") {
			$qry .= " order by $order_field $order_type";
		}

		if (intval($limit) > 0 && intval($start) >= 0) {
			$qry .= " Limit $start , $limit";
		}

		//print $qry;
		//echo $qry;


		$out = dbQuery($qry);

		if (dbRows($out) > 0) {
			$this->student_count = dbRows($out);
			return $out;
		}
		return $out;
	}
	// for manage data after semester transfer ...
	// -------------- start ---------------------

	function CountstudentGridFilter_all($limit = 0, $start = 0, $condition = "", $order_field = "", $order_type = "")
	{
		$this->student_count = 0;

		$qry = "SELECT 
	  			Count(sm.student_id) AS Count		   	 
		  	  FROM
			  	cms_studentmaster sm,
				cms_studentdetail sd					
		  	  WHERE			
				sm.college_id  = '" . $_SESSION["VedantnrCollegeId"] . "'
				AND sm.student_id=sd.student_id 
				AND sm.student_active = 1";

		if ($condition != "") {
			$qry .= $condition;
		}

		$out = dbQuery($qry);

		if (dbRows($out) > 0) {
			$row = dbArray($out);
			extract($row);
			$this->student_count = $Count;
			dbResult($out);
		}
		return $this->student_count;
	}

	function studentGridFilter_all($limit = 0, $start = 0, $condition = "", $order_field = "", $order_type = "")
	{
		$this->student_count = 0;


		$qry = "SELECT 
            sm.student_id,
            sm.student_gturegno,
            sm.shift,
            sm.student_techcerti,
            sd.cur_shift, 
            YEAR(sm.student_admdate) as adm_year,
            sm.student_admdate, 
            CONCAT(sm.student_surname , ' ' , sm.student_firstname , ' ' ,sm.student_lastname) AS studentname,
            sm.student_birthdate,
            sm.student_gender,
            sm.student_admby,
            sm.student_category,    
            sm.student_mobileother,
            sm.student_fathermobile,               
			sd.year_id,
           sd.cur_branchyearid,
		   sd.cur_branchid,
		   sd.cur_semesterid,
		    (SELECT branch_name 
             FROM cms_branchmaster sec 
             WHERE sec.college_id = '" . $_SESSION["VedantnrCollegeId"] . "' and sec.branch_id = sd.cur_branchid) AS branch_name,
            
			(SELECT year_name 
             FROM cms_yearmaster year 
             WHERE year.year_id = sd.year_id) AS year_name,
			 
			
			 (SELECT semester_name 
             FROM cms_semestermaster sem 
             WHERE sem.college_id = '" . $_SESSION["VedantnrCollegeId"] . "' AND sem.semester_id = sd.cur_semesterid) AS semester_name,
			 
			 (SELECT branchyear_name 
             FROM cms_branchyear bry 
             WHERE bry.college_id = '" . $_SESSION["VedantnrCollegeId"] . "' AND bry.branchyear_id = sd.cur_branchyearid) AS branchyear_name
            
        FROM
            cms_studentmaster sm
        INNER JOIN
            cms_studentdetail sd ON sm.student_id = sd.student_id
        WHERE
            sm.college_id = '" . $_SESSION["VedantnrCollegeId"] . "' 
          
			AND sd.current_active = 1";



		if ($condition != "") {
			$qry .= $condition;
		}

		if ($order_field != "" && $order_type != "") {
			$qry .= " order by $order_field $order_type";
		}

		if (intval($limit) > 0 && intval($start) >= 0) {
			$qry .= " Limit $start , $limit";
		}


		//echo $qry;
		$out = dbQuery($qry);

		if (dbRows($out) > 0) {
			$this->student_count = dbRows($out);
			return $out;
		}
		return $out;

	}

	// ------------ end -------------- 

	function getStudentDailyPresent($limit = 0, $start = 0, $condition = "", $order_field = "", $order_type = "")
	{
		$this->student_count = 0;
		$qry = "SELECT 
	  			sm.student_id,
				sm.student_gturegno,
				sm.student_techcerti,
				YEAR(sm.student_admdate) as adm_year,
				sm.student_admdate, 
				CONCAT(sm.student_surname , ' ' , sm.student_firstname , ' ' ,sm.student_lastname) AS studentname,
				sm.student_birthdate,
				sm.student_gender,
				sm.student_admby,
				sm.student_category,	
				sm.student_mobilestudents,
				sm.student_mobileparents,  		  
			  	sd.batch_id,
				(SELECT branch_name 
				FROM cms_branchmaster sec 
				WHERE sec.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' and sec.branch_id = sd.cur_branchid) AS branch_name,
	  		  	(SELECT year_name
			   	 FROM cms_yearmaster ym 
			     WHERE ym.year_id = sd.year_id) AS year_name,
				(SELECT branchyear_name
			   	 FROM 	cms_branchyear bry 
			     WHERE bry.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' AND bry.branchyear_id = sd.cur_branchyearid) AS branchyear_name,
				 (SELECT semester_name
			   	 FROM cms_semestermaster sem 
			     WHERE sem.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' AND sem.semester_id = sd.cur_semesterid) AS semester_name		   	 
		  	   	 
		  	  FROM
			  	cms_studentmaster sm,
				cms_studentdetail sd				
		  	  WHERE								
				sm.college_id  = '" . $_SESSION["VedantnrCollegeId"] . "' 
				AND sm.student_id=sd.student_id
				AND sm.student_active=1 ";



		if ($condition != "") {
			$qry .= $condition;
		}

		if ($order_field != "" && $order_type != "") {
			$qry .= " order by $order_field $order_type";
		}

		if (intval($limit) > 0 && intval($start) >= 0) {
			$qry .= " Limit $start , $limit";
		}

		//print $qry;
		//echo $qry;
		//exit;

		$out = dbQuery($qry);

		if (dbRows($out) > 0) {
			$this->student_count = dbRows($out);
			return $out;
		}
		return $out;
	}
	//for present start
	function studentGridFilter1($limit = 0, $start = 0, $condition = "", $order_field = "", $order_type = "")
	{

		$sql = "select employee_id from cms_employeemaster where user_id ='" . $_SESSION["VedantnrUserId"] . "'";
		$sql_res = dbQuery($sql);
		$sql_rec = dbArray($sql_res);
		$faculty_id = $sql_rec[0];

		$this->student_count = 0;



		$qry = "SELECT 
	  			sm.student_id,
				sm.student_gturegno,
				sm.shift,
				sm.student_techcerti,
				sd.cur_shift, 
				YEAR(sm.student_admdate) as adm_year,
				sm.student_admdate, 
				CONCAT(sm.student_surname , ' ' , sm.student_firstname , ' ' ,sm.student_lastname) AS studentname,
				sm.student_birthdate,
				sm.student_gender,
				sm.student_admby,
				sm.student_category,	
				sm.student_mobilestudents,
				sm.student_mobileparents,  		  
			  	sd.batch_id,
				 
				(SELECT branch_name 
				FROM cms_branchmaster sec 
				WHERE sec.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' and sec.branch_id = sd.cur_branchid) AS branch_name,
	  		  	(SELECT 
					semester_name
			   	 FROM 
				 	cms_semestermaster sem 
			     WHERE 
				 sem.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "'
				 AND sem.semester_id = sd.cur_semesterid) AS semester_name		   	 
		  	  FROM
			  	cms_studentmaster sm,
				cms_studentdetail sd				
		  	  WHERE								
				sm.college_id  = '" . $_SESSION["VedantnrCollegeId"] . "' 
				AND sm.student_id=sd.student_id
				AND sm.student_active=1
				AND sd.current_active = 1 ";


		if ($faculty_id != "") {
			$qry .= " and FIND_IN_SET(sd.student_id,(select GROUP_CONCAT(`student_id`) AS student_id from cms_feesreceivemaster as fm where fm.`semester_id` = sd.cur_semesterid and fm.`branch_id` =sd.cur_branchid  and fm.`college_id` = '" . $_SESSION["VedantnrCollegeId"] . "' ))";
		}

		if ($condition != "") {
			$qry .= $condition;
		}

		if ($order_field != "" && $order_type != "") {
			$qry .= " order by $order_field $order_type";
		}

		if (intval($limit) > 0 && intval($start) >= 0) {
			$qry .= " Limit $start , $limit";
		}

		//print $qry;
		//echo $qry;
		//exit;

		$out = dbQuery($qry);

		if (dbRows($out) > 0) {
			$this->student_count = dbRows($out);
			return $out;
		}
		return $out;
	}
	//for present end

	function CountstudentGridFilter($limit = 0, $start = 0, $condition = "", $order_field = "", $order_type = "")
	{
		$this->student_count = 0;

		$qry = "SELECT 
	  			Count(sm.student_id) AS Count		   	 
		  	  FROM
			  	cms_studentmaster sm,
				cms_studentdetail sd					
		  	  WHERE								
				sm.college_id  = '" . $_SESSION["VedantnrCollegeId"] . "'
				AND sm.student_id=sd.student_id 
				AND sm.student_active = 1
				AND sd.current_active = 1";

		if ($condition != "") {
			$qry .= $condition;
		}

		$out = dbQuery($qry);

		if (dbRows($out) > 0) {
			$row = dbArray($out);
			extract($row);
			$this->student_count = $Count;
			dbResult($out);
		}
		return $this->student_count;
	}

	function updatefile1()
	{
		$qry = "update cms_studentmaster 
				set student_signature = '" . $this->student_signature . "'
             	where student_id =   '" . $this->student_id . "' ";

		dbQuery($qry);
	}

	function add()
	{

		global $SQLDateFormat;

		$Qry1 = "";

		$Qry1 .= "branch_id = '" . Escape($this->branch_id) . "',";
		$Qry1 .= "college_id = '" . Escape($this->college_id) . "',";
		$Qry1 .= "semester_id = '" . Escape($this->semester_id) . "',";
		$Qry1 .= "year_id = '" . Escape($this->year_id) . "',";
		//2-08
		$Qry1 .= "msc_subject ='" . Escape($this->msc_subject) . "',";
		$Qry1 .= "student_formno = '" . Escape($this->student_formno) . "',";
		$Qry1 .= "student_surname = '" . Escape($this->student_surname) . "',";
		$Qry1 .= "student_firstname = '" . Escape($this->student_firstname) . "',";
		$Qry1 .= "student_lastname ='" . Escape($this->student_lastname) . "',";
		$Qry1 .= "student_category ='" . Escape($this->student_category) . "',";
		$Qry1 .= "student_admby = '" . Escape($this->student_admby) . "',";
		$Qry1 .= "student_gender = '" . Escape($this->student_gender) . "',";
		$Qry1 .= "student_bloodgroup = '" . Escape($this->student_bloodgroup) . "',";
		$Qry1 .= "student_birthdate = STR_TO_DATE('" . Escape($this->student_birthdate) . "','$SQLDateFormat'),";
		$Qry1 .= "student_cast = '" . Escape($this->student_cast) . "',";
		$Qry1 .= "student_nationality = '" . Escape($this->student_nationality) . "',";
		$Qry1 .= "student_gturegno = '" . Escape($this->student_gturegno) . "',";
		$Qry1 .= "student_admdate = STR_TO_DATE('" . Escape($this->student_admdate) . "','$SQLDateFormat'),";
		$Qry1 .= "student_lastcollege = '" . Escape($this->student_lastcollege) . "',";



		$Qry1 .= "student_mobileother = '" . Escape($this->student_mobileother) . "',";
		$Qry1 .= "student_addressat = '" . Escape($this->student_addressat) . "',";
		$Qry1 .= "student_addresspost = '" . Escape($this->student_addresspost) . "',";
		$Qry1 .= "student_pincode = '" . Escape($this->student_pincode) . "',";
		$Qry1 .= "student_phoneo = '" . Escape($this->student_phoneo) . "',";
		$Qry1 .= "student_phoner = '" . Escape($this->student_phoner) . "',";
		$Qry1 .= "student_mobileguardian = '" . Escape($this->student_mobileguardian) . "',";

		$Qry1 .= "student_mobilestudents = '" . Escape($this->student_mobilestudents) . "',";
		$Qry1 .= "student_mobileparents = '" . Escape($this->student_mobileparents) . "',";
		$Qry1 .= "student_emailid = '" . Escape($this->student_emailid) . "',";

		//$Qry1 .= "student_photo = '"			.Escape($this->student_photo)."',";
		$Qry1 .= "student_remarks = '" . replaceHtmlEditor(Escape($this->student_remarks)) . "',";
		$Qry1 .= "tfw_scheme = '" . Escape($this->tfw_scheme) . "',";

		$Qry1 .= "login_id = '" . Escape($_SESSION['aUserId']) . "',";
		$Qry1 .= "createdon = '" . Escape(date('Y-m-d h:i:s')) . "',";

		$Qry1 .= "previous_school = '" . Escape($this->previous_school) . "',";
		$Qry1 .= "percentage = '" . Escape($this->percentage) . "',";
		$Qry1 .= "grade = '" . Escape($this->grade) . "',";
		$Qry1 .= "passing_month = '" . Escape($this->passing_month) . "',";

		$Qry1 .= "student_yearofpassing = '" . Escape($this->student_yearofpassing) . "',";
		$Qry1 .= "student_examseatno = '" . Escape($this->student_examseatno) . "',";
		$Qry1 .= "student_nameboard = '" . Escape($this->student_nameboard) . "',";
		$Qry1 .= "maths_mark = '" . Escape($this->maths_mark) . "',";
		$Qry1 .= "sci_mark = '" . Escape($this->sci_mark) . "',";
		$Qry1 .= "eng_mark = '" . Escape($this->eng_mark) . "',";

		$Qry1 .= "twle_total_mark = '" . Escape($this->twle_total_mark) . "',";
		$Qry1 .= "obtain_mark = '" . Escape($this->obtain_mark) . "',";
		$Qry1 .= "twle_percentage = '" . Escape($this->twle_percentage) . "',";
		$Qry1 .= "twle_rank = '" . Escape($this->twle_rank) . "',";
		$Qry1 .= "twle_grade = '" . Escape($this->twle_grade) . "',";
		$Qry1 .= "twle_board = '" . Escape($this->twle_board) . "',";
		$Qry1 .= "twle_biology = '" . Escape($this->twle_biology) . "',";
		$Qry1 .= "biology_practical = '" . Escape($this->biology_practical) . "',";
		$Qry1 .= "bsc_college = '" . Escape($this->bsc_college) . "',";
		$Qry1 .= "bsc_university = '" . Escape($this->bsc_university) . "',";
		$Qry1 .= "bscpassing_month = '" . Escape($this->bscpassing_month) . "',";
		$Qry1 .= "bscstudent_yearofpassing = '" . Escape($this->bscstudent_yearofpassing) . "',";
		$Qry1 .= "bsc_seatno = '" . Escape($this->bsc_seatno) . "',";
		$Qry1 .= "bsc_total = '" . Escape($this->bsc_total) . "',";
		$Qry1 .= "bsc_obtain = '" . Escape($this->bsc_obtain) . "',";
		$Qry1 .= "bsc_percentage = '" . Escape($this->bsc_percentage) . "',";
		$Qry1 .= "bsc_cgpa = '" . Escape($this->bsc_cgpa) . "',";
		$Qry1 .= "bsc_spi = '" . Escape($this->bsc_spi) . "',";
		$Qry1 .= "msc_college = '" . Escape($this->msc_college) . "',";
		$Qry1 .= "msc_university = '" . Escape($this->msc_university) . "',";
		$Qry1 .= "mscpassing_month = '" . Escape($this->mscpassing_month) . "',";
		$Qry1 .= "mscstudent_yearofpassing = '" . Escape($this->mscstudent_yearofpassing) . "',";
		$Qry1 .= "msc_seatno = '" . Escape($this->msc_seatno) . "',";
		$Qry1 .= "msc_total = '" . Escape($this->msc_total) . "',";
		$Qry1 .= "msc_obtain = '" . Escape($this->msc_obtain) . "',";
		$Qry1 .= "msc_percentage = '" . Escape($this->msc_percentage) . "',";
		$Qry1 .= "msc_cgpa = '" . Escape($this->msc_cgpa) . "',";
		$Qry1 .= "msc_spi = '" . Escape($this->msc_spi) . "',";
		$Qry1 .= "bed_college = '" . Escape($this->bed_college) . "',";
		$Qry1 .= "bed_university = '" . Escape($this->bed_university) . "',";
		$Qry1 .= "bedpassing_month = '" . Escape($this->bedpassing_month) . "',";
		$Qry1 .= "bedstudent_yearofpassing = '" . Escape($this->bedstudent_yearofpassing) . "',";
		$Qry1 .= "bed_seatno = '" . Escape($this->bed_seatno) . "',";
		$Qry1 .= "bed_total = '" . Escape($this->bed_total) . "',";
		$Qry1 .= "bed_obtain = '" . Escape($this->bed_obtain) . "',";
		$Qry1 .= "bed_percentage = '" . Escape($this->bed_percentage) . "',";
		$Qry1 .= "bed_cgpa = '" . Escape($this->bed_cgpa) . "',";
		$Qry1 .= "bed_spi = '" . Escape($this->bed_spi) . "',";

		$Qry1 .= "ba_core = '" . Escape($this->ba_core) . "',";
		$Qry1 .= "ba_el1 = '" . Escape($this->ba_el1) . "',";
		$Qry1 .= "ba_el2 = '" . Escape($this->ba_el2) . "',";
		$Qry1 .= "bsc_group = '" . Escape($this->bsc_group) . "',";
		$Qry1 .= "msc_group = '" . Escape($this->msc_group) . "',";

		$Qry1 .= "bank_name = '" . Escape($this->bank_name) . "',";
		$Qry1 .= "bank_account_no = '" . Escape($this->bank_account_no) . "',";
		$Qry1 .= "bank_ifsc_code = '" . Escape($this->bank_ifsc_code) . "',";
		$Qry1 .= "bank_city = '" . Escape($this->bank_city) . "',";
		$Qry1 .= "bank_address = '" . Escape($this->bank_address) . "',";

		$Qry1 .= "transport_facility = '" . Escape($this->transport_facility) . "',";
		$Qry1 .= "hostel_facility = '" . Escape($this->hostel_facility) . "',";
		$Qry1 .= "scholarship_facility = '" . Escape($this->scholarship_facility) . "',";
		$Qry1 .= "student_adharno = '" . Escape($this->student_adharno) . "',";
		$Qry1 .= "dist_nameeng = '" . Escape($this->dist_nameeng) . "',";
		$Qry1 .= "taluko_nameeng = '" . Escape($this->taluko_nameeng) . "',";
		$Qry1 .= "state_nameeng = '" . Escape($this->state_nameeng) . "',";



		$Qry1 .= "student_pincode1 = '" . Escape($this->student_pincode1) . "',";
		$Qry1 .= "dist_nameeng1= '" . Escape($this->dist_nameeng1) . "',";
		$Qry1 .= "taluko_nameeng1 = '" . Escape($this->taluko_nameeng1) . "',";
		$Qry1 .= "state_nameeng1 = '" . Escape($this->state_nameeng1) . "',";


		$Qry1 .= "student_mother = '" . Escape($this->student_mother) . "',";
		$Qry1 .= "allsemfees = '" . Escape($this->allsem) . "',";

		$Qry1 .= "regular = '" . Escape($this->regular) . "',";
		$Qry1 .= "allsem_transport = '" . Escape($this->allsem_transport) . "',";
		$Qry1 .= "allsem_ctod = '" . Escape($this->allsem_ctod) . "',";

		$Qry1 .= "student_ref = '" . Escape($this->student_ref) . "',";
		$Qry1 .= "scholarship_id = '" . Escape($this->scholarship_id) . "',";

		$Qry1 .= "twle_seat = '" . Escape($this->twle_seat) . "',";


		$Qry1 .= "twle_maths = '" . Escape($this->twle_maths) . "',";
		$Qry1 .= "twle_chemistry = '" . Escape($this->twle_chemistry) . "',";
		$Qry1 .= "twle_physics = '" . Escape($this->twle_physics) . "',";
		$Qry1 .= "twle_other = '" . Escape($this->twle_other) . "',";
		$Qry1 .= "chemistry_practical = '" . Escape($this->chemistry_practical) . "',";
		$Qry1 .= "physics_practical = '" . Escape($this->physics_practical) . "',";
		$Qry1 .= "other_practical = '" . Escape($this->other_practical) . "',";
		$Qry1 .= "sci_total = '" . Escape($this->sci_total) . "',";
		$Qry1 .= "sci_obtain = '" . Escape($this->sci_obtain) . "',";
		$Qry1 .= "sci_percentage = '" . Escape($this->sci_percentage) . "',";
		//mansi
		$Qry1 .= "branchyear_id = '" . Escape($this->branchyear_id) . "',";
		$Qry1 .= "adm_conformation = '" . Escape($this->adm_conformation) . "',";
		$Qry1 .= "reporting_date = STR_TO_DATE('" . Escape($this->reporting_date) . "','$SQLDateFormat'),";
		$Qry1 .= "updown_strdate = STR_TO_DATE('" . Escape($this->updown_strdate) . "','$SQLDateFormat'),";
		$Qry1 .= "updown_enddate = STR_TO_DATE('" . Escape($this->updown_enddate) . "','$SQLDateFormat'),";
		$Qry1 .= "hostel_admdate = STR_TO_DATE('" . Escape($this->hostel_admdate) . "','$SQLDateFormat'),";
		$Qry1 .= "hostel_candate = STR_TO_DATE('" . Escape($this->hostel_candate) . "','$SQLDateFormat'),";
		$Qry1 .= "previous_school_address = '" . Escape($this->previous_school_address) . "',";
		$Qry1 .= "notrials = '" . Escape($this->notrials) . "',";
		$Qry1 .= "twl_school_address = '" . Escape($this->twl_school_address) . "',";
		$Qry1 .= "twlepassing_month = '" . Escape($this->twlepassing_month) . "',";
		$Qry1 .= "twl_notrials = '" . Escape($this->twl_notrials) . "',";
		$Qry1 .= "gnm_passcol = '" . Escape($this->gnm_passcol) . "',";
		$Qry1 .= "uni_name = '" . Escape($this->uni_name) . "',";
		$Qry1 .= "gnm_regname = '" . Escape($this->gnm_regname) . "',";
		$Qry1 .= "reg_date = STR_TO_DATE('" . Escape($this->reg_date) . "','$SQLDateFormat'),";
		$Qry1 .= "gnm_percentage = '" . Escape($this->gnm_percentage) . "',";
		$Qry1 .= "council_date = STR_TO_DATE('" . Escape($this->council_date) . "','$SQLDateFormat'),";
		$Qry1 .= "gnm_year = '" . Escape($this->gnm_year) . "',";
		$Qry1 .= "degdiploma_certino = '" . Escape($this->degdiploma_certino) . "',";
		$Qry1 .= "reviling_date = STR_TO_DATE('" . Escape($this->reviling_date) . "','$SQLDateFormat'),";

		$Qry1 .= "reg_enddate = STR_TO_DATE('" . Escape($this->reg_enddate) . "','$SQLDateFormat'),";
		$Qry1 .= "anm_passcol = '" . Escape($this->anm_passcol) . "',";
		$Qry1 .= "anm_regname = '" . Escape($this->anm_regname) . "',";
		$Qry1 .= "anm_percentage = '" . Escape($this->anm_percentage) . "',";
		$Qry1 .= "anm_year = '" . Escape($this->anm_year) . "',";
		//2-08
		$Qry1 .= "anmdegdiploma_certino = '" . Escape($this->anmdegdiploma_certino) . "',";
		$Qry1 .= "anmreviling_date = STR_TO_DATE('" . Escape($this->anmreviling_date) . "','$SQLDateFormat'),";
		$Qry1 .= "anm_uniname = '" . Escape($this->anm_uniname) . "',";
		$Qry1 .= "anmregistration_no1 = '" . Escape($this->anmregistration_no1) . "',";
		$Qry1 .= "anmregistration_no2 = '" . Escape($this->anmregistration_no2) . "',";
		$Qry1 .= "anmreg_date = STR_TO_DATE('" . Escape($this->anmreg_date) . "','$SQLDateFormat'),";
		$Qry1 .= "anmcouncil_date = STR_TO_DATE('" . Escape($this->anmcouncil_date) . "','$SQLDateFormat'),";
		$Qry1 .= "anmreg_enddate = STR_TO_DATE('" . Escape($this->anmreg_enddate) . "','$SQLDateFormat'),";

		$Qry1 .= "bsc_passcol = '" . Escape($this->bsc_passcol) . "',";
		$Qry1 .= "bsc_regname = '" . Escape($this->bsc_regname) . "',";
		$Qry1 .= "bsc_per = '" . Escape($this->bsc_per) . "',";
		$Qry1 .= "bsc_year = '" . Escape($this->bsc_year) . "',";
		$Qry1 .= "bscdegdiploma_certino = '" . Escape($this->bscdegdiploma_certino) . "',";
		$Qry1 .= "additional_regno = '" . Escape($this->additional_regno) . "',";
		$Qry1 .= "bsc_uniname = '" . Escape($this->bsc_uniname) . "',";
		$Qry1 .= "bscregistration_no1 = '" . Escape($this->bscregistration_no1) . "',";
		$Qry1 .= "bscregistration_no2 = '" . Escape($this->bscregistration_no2) . "',";
		$Qry1 .= "bscreg_date = STR_TO_DATE('" . Escape($this->bscreg_date) . "','$SQLDateFormat'),";
		$Qry1 .= "bsccouncil_date = STR_TO_DATE('" . Escape($this->bsccouncil_date) . "','$SQLDateFormat'),";
		$Qry1 .= "bscreg_enddate = STR_TO_DATE('" . Escape($this->bscreg_enddate) . "','$SQLDateFormat'),";
		//2-08
		$Qry1 .= "bscreviling_date = STR_TO_DATE('" . Escape($this->bscreviling_date) . "','$SQLDateFormat'),";
		$Qry1 .= "pbbsc_passcol= '" . Escape($this->pbbsc_passcol) . "',";
		$Qry1 .= "pbbsc_regname= '" . Escape($this->pbbsc_regname) . "',";
		$Qry1 .= "pbbsc_percentage= '" . Escape($this->pbbsc_percentage) . "',";
		$Qry1 .= "pbbsc_year= '" . Escape($this->pbbsc_year) . "',";
		//2-08
		$Qry1 .= "pbbscdegdiploma_certino= '" . Escape($this->pbbscdegdiploma_certino) . "',";

		$Qry1 .= "pbbsc_uniname= '" . Escape($this->pbbsc_uniname) . "',";
		$Qry1 .= "pbbscregistration_no1= '" . Escape($this->pbbscregistration_no1) . "',";
		$Qry1 .= "pbbscregistration_no2= '" . Escape($this->pbbscregistration_no2) . "',";
		$Qry1 .= "pbbscreg_date=  STR_TO_DATE('" . Escape($this->pbbscreg_date) . "','$SQLDateFormat'),";
		$Qry1 .= "pbbsccouncil_date=  STR_TO_DATE('" . Escape($this->pbbsccouncil_date) . "','$SQLDateFormat'),";
		$Qry1 .= "pbbscreg_enddate=  STR_TO_DATE('" . Escape($this->pbbscreg_enddate) . "','$SQLDateFormat'),";

		$Qry1 .= "student_father = '" . Escape($this->student_father) . "',";
		$Qry1 .= "student_guardian = '" . Escape($this->student_guardian) . "',";
		$Qry1 .= "student_birthdateplace = '" . Escape($this->student_birthdateplace) . "',";
		$Qry1 .= "student_religion = '" . Escape($this->student_religion) . "',";
		$Qry1 .= "student_subcast = '" . Escape($this->student_subcast) . "',";
		$Qry1 .= "marital_status = '" . Escape($this->marital_status) . "',";
		$Qry1 .= "permanent_addressat = '" . Escape($this->permanent_addressat) . "',";
		$Qry1 .= "permanent_addresspost = '" . Escape($this->permanent_addresspost) . "',";

		$Qry1 .= "parent_nationality = '" . Escape($this->parent_nationality) . "',";
		$Qry1 .= "passport_validity = STR_TO_DATE('" . Escape($this->passport_validity) . "','$SQLDateFormat'),";
		$Qry1 .= "passport_no = '" . Escape($this->passport_no) . "',";
		$Qry1 .= "issued_by = STR_TO_DATE('" . Escape($this->issued_by) . "','$SQLDateFormat'),";
		$Qry1 .= "student_fathermobile = '" . Escape($this->student_fathermobile) . "',";
		$Qry1 .= "student_mothermobile = '" . Escape($this->student_mothermobile) . "',";
		$Qry1 .= "student_grno = '" . Escape($this->student_grno) . "',";
		$Qry1 .= "pr_rank = '" . Escape($this->pr_rank) . "',";
		$Qry1 .= "twle_stream = '" . Escape($this->twle_stream) . "',";
		$Qry1 .= "registration_no1 = '" . Escape($this->registration_no1) . "',";
		$Qry1 .= "registration_no2 = '" . Escape($this->registration_no2) . "',";

		$Qry1 .= "gnm_month = '" . Escape($this->gnm_month) . "',";
		$Qry1 .= "anm_month = '" . Escape($this->anm_month) . "',";
		$Qry1 .= "bsc_month = '" . Escape($this->bsc_month) . "',";
		$Qry1 .= "pbbsc_month = '" . Escape($this->pbbsc_month) . "',";

		//priyanshi

		$Qry1 .= "student_age = '" . Escape($this->student_age) . "',";
		$Qry1 .= "student_relation = '" . Escape($this->student_relation) . "',";
		$Qry1 .= "student_nri = '" . Escape($this->student_nri) . "',";
		$Qry1 .= "parent_occupation = '" . Escape($this->parent_occupation) . "',";
		$Qry1 .= "parent_income = '" . Escape($this->parent_income) . "',";
		if ($Qry1 != "") {
			$Qry1 = substr($Qry1, 0, strlen($Qry1) - 1);
			$qry = "INSERT INTO cms_studentmaster set " . $Qry1 . " ";

			dbQuery($qry);
			$this->student_id = dbInsertedId();
		}

	}
	function getDistinctCast($college_id = "")
	{
		$this->student_count = 0;
		$qry = "SELECT DISTINCT student_cast 
				FROM cms_studentmaster 
				WHERE college_id = '" . $_SESSION["VedantnrCollegeId"] . "' ";
		$qry .= " order by student_cast ASC ";

		$out = dbQuery($qry);

		if (dbRows($out) > 0) {
			$this->student_count = dbRows($out);
			return $out;
		}
		return $out;
	}
	function getDistinctBirthplace($college_id = "")
	{
		$this->student_count = 0;
		$qry = "SELECT DISTINCT student_birthplace FROM cms_studentmaster where college_id = '" . $_SESSION["VedantnrCollegeId"] . "' ";
		$qry .= " order by student_birthplace ASC ";
		$out = dbQuery($qry);

		if (dbRows($out) > 0) {
			$this->student_count = dbRows($out);
			return $out;
		}
		return $out;

	}

	function edit()
	{
		global $SQLDateFormat;

		$Qry1 = "";
		//$Qry1 .= "student_id='" . Escape($this->student_id) . "',";
		//$Qry1 .= "branch_id ='" . Escape($this->branch_id) . "',";
		$Qry1 .= "college_id ='" . Escape($this->college_id) . "',";
		//$Qry1 .= "semester_id ='" . Escape($this->semester_id) . "',";
		//$Qry1 .= "year_id = '" . Escape($this->year_id) . "',";
		//2-08
		$Qry1 .= "msc_subject ='" . Escape($this->msc_subject) . "',";

		$Qry1 .= "student_formno  ='" . Escape($this->student_formno) . "',";
		$Qry1 .= "student_surname 	='" . Escape($this->student_surname) . "',";
		$Qry1 .= "student_firstname 	='" . Escape($this->student_firstname) . "',";
		$Qry1 .= "student_lastname 	='" . Escape($this->student_lastname) . "',";
		$Qry1 .= "student_category 	='" . Escape($this->student_category) . "',";
		$Qry1 .= "student_admby 	='" . Escape($this->student_admby) . "',";
		$Qry1 .= "student_gender 	='" . Escape($this->student_gender) . "',";
		$Qry1 .= "student_bloodgroup 	='" . Escape($this->student_bloodgroup) . "',";
		$Qry1 .= "student_birthdate 	=STR_TO_DATE('" . Escape($this->student_birthdate) . "','$SQLDateFormat'),";
		$Qry1 .= "student_cast 	='" . Escape($this->student_cast) . "',";
		$Qry1 .= "student_nationality 	='" . Escape($this->student_nationality) . "',";
		$Qry1 .= "student_gturegno 	='" . Escape($this->student_gturegno) . "',";
		$Qry1 .= "student_admdate 	=STR_TO_DATE('" . Escape($this->student_admdate) . "','$SQLDateFormat'),";
		$Qry1 .= "student_lastcollege 	='" . Escape($this->student_lastcollege) . "',";

		$Qry1 .= "student_nameboard 	='" . Escape($this->student_nameboard) . "',";
		$Qry1 .= "student_examseatno 	='" . Escape($this->student_examseatno) . "',";

		$Qry1 .= "student_mobileother 	='" . Escape($this->student_mobileother) . "',";

		$Qry1 .= "student_yearofpassing 	='" . Escape($this->student_yearofpassing) . "',";
		$Qry1 .= "student_addressat = '" . Escape($this->student_addressat) . "',";
		$Qry1 .= "student_addresspost = '" . Escape($this->student_addresspost) . "',";
		$Qry1 .= "student_pincode 	='" . Escape($this->student_pincode) . "',";
		$Qry1 .= "student_phoneo 	='" . Escape($this->student_phoneo) . "',";
		$Qry1 .= "student_phoner 	='" . Escape($this->student_phoner) . "',";
		$Qry1 .= "student_mobileguardian = '" . Escape($this->student_mobileguardian) . "',";
		$Qry1 .= "student_mobilestudents 	='" . Escape($this->student_mobilestudents) . "',";
		$Qry1 .= "student_mobileparents 	='" . Escape($this->student_mobileparents) . "',";
		$Qry1 .= "student_emailid 	='" . Escape($this->student_emailid) . "',";


		//$Qry1 .= "student_photo 	='"	.Escape($this->student_photo)."',";
		$Qry1 .= "student_remarks 	='" . replaceHtmlEditor(Escape($this->student_remarks)) . "',";
		$Qry1 .= "transport_facility = '" . Escape($this->transport_facility) . "',";
		$Qry1 .= "tfw_scheme = '" . Escape($this->tfw_scheme) . "',";

		$Qry1 .= "login_id='" . Escape($_SESSION['aUserId']) . "',";
		$Qry1 .= "createdon='" . Escape(date('Y-m-d h:i:s')) . "',";

		$Qry1 .= "hostel_facility = '" . Escape($this->hostel_facility) . "',";


		$Qry1 .= "maths_mark = '" . Escape($this->maths_mark) . "',";
		$Qry1 .= "sci_mark = '" . Escape($this->sci_mark) . "',";
		$Qry1 .= "eng_mark = '" . Escape($this->eng_mark) . "',";

		$Qry1 .= "twle_total_mark = '" . Escape($this->twle_total_mark) . "',";

		$Qry1 .= "obtain_mark = '" . Escape($this->obtain_mark) . "',";
		$Qry1 .= "twle_percentage = '" . Escape($this->twle_percentage) . "',";
		$Qry1 .= "twle_rank = '" . Escape($this->twle_rank) . "',";
		$Qry1 .= "twle_grade = '" . Escape($this->twle_grade) . "',";
		$Qry1 .= "twle_board = '" . Escape($this->twle_board) . "',";
		$Qry1 .= "twle_biology = '" . Escape($this->twle_biology) . "',";
		$Qry1 .= "bsc_college = '" . Escape($this->bsc_college) . "',";
		$Qry1 .= "bsc_university = '" . Escape($this->bsc_university) . "',";
		$Qry1 .= "bscpassing_month = '" . Escape($this->bscpassing_month) . "',";
		$Qry1 .= "bscstudent_yearofpassing = '" . Escape($this->bscstudent_yearofpassing) . "',";
		$Qry1 .= "bsc_seatno = '" . Escape($this->bsc_seatno) . "',";
		$Qry1 .= "bsc_total = '" . Escape($this->bsc_total) . "',";
		$Qry1 .= "bsc_obtain = '" . Escape($this->bsc_obtain) . "',";
		$Qry1 .= "bsc_percentage = '" . Escape($this->bsc_percentage) . "',";
		$Qry1 .= "bsc_cgpa = '" . Escape($this->bsc_cgpa) . "',";
		$Qry1 .= "bsc_spi = '" . Escape($this->bsc_spi) . "',";
		$Qry1 .= "msc_college = '" . Escape($this->msc_college) . "',";
		$Qry1 .= "msc_university = '" . Escape($this->msc_university) . "',";
		$Qry1 .= "mscpassing_month = '" . Escape($this->mscpassing_month) . "',";
		$Qry1 .= "mscstudent_yearofpassing = '" . Escape($this->mscstudent_yearofpassing) . "',";
		$Qry1 .= "msc_seatno = '" . Escape($this->msc_seatno) . "',";
		$Qry1 .= "msc_total = '" . Escape($this->msc_total) . "',";
		$Qry1 .= "msc_obtain = '" . Escape($this->msc_obtain) . "',";
		$Qry1 .= "msc_percentage = '" . Escape($this->msc_percentage) . "',";
		$Qry1 .= "msc_cgpa = '" . Escape($this->msc_cgpa) . "',";
		$Qry1 .= "msc_spi = '" . Escape($this->msc_spi) . "',";
		$Qry1 .= "bed_college = '" . Escape($this->bed_college) . "',";
		$Qry1 .= "bed_university = '" . Escape($this->bed_university) . "',";
		$Qry1 .= "bedpassing_month = '" . Escape($this->bedpassing_month) . "',";
		$Qry1 .= "bedstudent_yearofpassing = '" . Escape($this->bedstudent_yearofpassing) . "',";
		$Qry1 .= "bed_seatno = '" . Escape($this->bed_seatno) . "',";
		$Qry1 .= "bed_total = '" . Escape($this->bed_total) . "',";
		$Qry1 .= "bed_obtain = '" . Escape($this->bed_obtain) . "',";
		$Qry1 .= "bed_percentage = '" . Escape($this->bed_percentage) . "',";
		$Qry1 .= "bed_cgpa = '" . Escape($this->bed_cgpa) . "',";
		$Qry1 .= "bed_spi = '" . Escape($this->bed_spi) . "',";

		$Qry1 .= "ba_core = '" . Escape($this->ba_core) . "',";
		$Qry1 .= "ba_el1 = '" . Escape($this->ba_el1) . "',";
		$Qry1 .= "ba_el2 = '" . Escape($this->ba_el2) . "',";
		$Qry1 .= "bsc_group = '" . Escape($this->bsc_group) . "',";
		$Qry1 .= "msc_group = '" . Escape($this->msc_group) . "',";

		$Qry1 .= "bank_name = '" . Escape($this->bank_name) . "',";
		$Qry1 .= "bank_account_no = '" . Escape($this->bank_account_no) . "',";
		$Qry1 .= "bank_ifsc_code = '" . Escape($this->bank_ifsc_code) . "',";
		$Qry1 .= "bank_city = '" . Escape($this->bank_city) . "',";
		$Qry1 .= "bank_address = '" . Escape($this->bank_address) . "',";


		$Qry1 .= "previous_school = '" . Escape($this->previous_school) . "',";
		$Qry1 .= "percentage = '" . Escape($this->percentage) . "',";
		$Qry1 .= "grade = '" . Escape($this->grade) . "',";
		$Qry1 .= "passing_month = '" . Escape($this->passing_month) . "',";
		$Qry1 .= "scholarship_facility = '" . Escape($this->scholarship_facility) . "',";
		$Qry1 .= "ip_address='" . Escape(getHostByName(php_uname('n'))) . "',";
		$Qry1 .= "student_adharno = '" . Escape($this->student_adharno) . "',";
		$Qry1 .= "dist_nameeng = '" . Escape($this->dist_nameeng) . "',";
		$Qry1 .= "taluko_nameeng = '" . Escape($this->taluko_nameeng) . "',";
		$Qry1 .= "state_nameeng = '" . Escape($this->state_nameeng) . "',";
		$Qry1 .= "student_pincode1 = '" . Escape($this->student_pincode1) . "',";
		$Qry1 .= "dist_nameeng1= '" . Escape($this->dist_nameeng1) . "',";
		$Qry1 .= "taluko_nameeng1 = '" . Escape($this->taluko_nameeng1) . "',";
		$Qry1 .= "state_nameeng1 = '" . Escape($this->state_nameeng1) . "',";
		$Qry1 .= "student_mother = '" . Escape($this->student_mother) . "',";
		$Qry1 .= "allsemfees = '" . Escape($this->allsem) . "',";
		$Qry1 .= "regular = '" . Escape($this->regular) . "',";
		$Qry1 .= "allsem_transport = '" . Escape($this->allsem_transport) . "',";
		$Qry1 .= "allsem_ctod = '" . Escape($this->allsem_ctod) . "',";
		$Qry1 .= "student_ref = '" . Escape($this->student_ref) . "',";
		$Qry1 .= "scholarship_id = '" . Escape($this->scholarship_id) . "',";
		$Qry1 .= "twle_seat = '" . Escape($this->twle_seat) . "',";
		$Qry1 .= "twle_maths = '" . Escape($this->twle_maths) . "',";
		$Qry1 .= "twle_chemistry = '" . Escape($this->twle_chemistry) . "',";
		$Qry1 .= "twle_physics = '" . Escape($this->twle_physics) . "',";
		$Qry1 .= "twle_other = '" . Escape($this->twle_other) . "',";
		$Qry1 .= "chemistry_practical = '" . Escape($this->chemistry_practical) . "',";
		$Qry1 .= "physics_practical = '" . Escape($this->physics_practical) . "',";
		$Qry1 .= "other_practical = '" . Escape($this->other_practical) . "',";
		$Qry1 .= "sci_total = '" . Escape($this->sci_total) . "',";
		$Qry1 .= "sci_obtain = '" . Escape($this->sci_obtain) . "',";
		$Qry1 .= "sci_percentage = '" . Escape($this->sci_percentage) . "',";
		$Qry1 .= "biology_practical = '" . Escape($this->biology_practical) . "',";

		//mansi
		$Qry1 .= "branchyear_id = '" . Escape($this->branchyear_id) . "',";
		$Qry1 .= "adm_conformation = '" . Escape($this->adm_conformation) . "',";
		$Qry1 .= "reporting_date = STR_TO_DATE('" . Escape($this->reporting_date) . "','$SQLDateFormat'),";
		$Qry1 .= "updown_strdate = STR_TO_DATE('" . Escape($this->updown_strdate) . "','$SQLDateFormat'),";
		$Qry1 .= "updown_enddate = STR_TO_DATE('" . Escape($this->updown_enddate) . "','$SQLDateFormat'),";
		$Qry1 .= "hostel_admdate = STR_TO_DATE('" . Escape($this->hostel_admdate) . "','$SQLDateFormat'),";
		$Qry1 .= "hostel_candate = STR_TO_DATE('" . Escape($this->hostel_candate) . "','$SQLDateFormat'),";
		$Qry1 .= "previous_school_address = '" . Escape($this->previous_school_address) . "',";
		$Qry1 .= "notrials = '" . Escape($this->notrials) . "',";
		$Qry1 .= "twl_school_address = '" . Escape($this->twl_school_address) . "',";
		$Qry1 .= "twlepassing_month = '" . Escape($this->twlepassing_month) . "',";
		$Qry1 .= "twl_notrials = '" . Escape($this->twl_notrials) . "',";
		$Qry1 .= "gnm_passcol = '" . Escape($this->gnm_passcol) . "',";
		$Qry1 .= "uni_name = '" . Escape($this->uni_name) . "',";
		$Qry1 .= "gnm_regname = '" . Escape($this->gnm_regname) . "',";
		$Qry1 .= "reg_date = STR_TO_DATE('" . Escape($this->reg_date) . "','$SQLDateFormat'),";
		$Qry1 .= "gnm_percentage = '" . Escape($this->gnm_percentage) . "',";
		$Qry1 .= "council_date = STR_TO_DATE('" . Escape($this->council_date) . "','$SQLDateFormat'),";
		$Qry1 .= "gnm_year = '" . Escape($this->gnm_year) . "',";
		$Qry1 .= "degdiploma_certino = '" . Escape($this->degdiploma_certino) . "',";
		$Qry1 .= "reviling_date = STR_TO_DATE('" . Escape($this->reviling_date) . "','$SQLDateFormat'),";
		$Qry1 .= "reg_enddate = STR_TO_DATE('" . Escape($this->reg_enddate) . "','$SQLDateFormat'),";

		$Qry1 .= "anm_passcol = '" . Escape($this->anm_passcol) . "',";
		$Qry1 .= "anm_regname = '" . Escape($this->anm_regname) . "',";
		$Qry1 .= "anm_percentage = '" . Escape($this->anm_percentage) . "',";
		$Qry1 .= "anm_year = '" . Escape($this->anm_year) . "',";
		//2-08
		$Qry1 .= "anmdegdiploma_certino = '" . Escape($this->anmdegdiploma_certino) . "',";
		$Qry1 .= "anmreviling_date = STR_TO_DATE('" . Escape($this->anmreviling_date) . "','$SQLDateFormat'),";
		$Qry1 .= "anm_uniname = '" . Escape($this->anm_uniname) . "',";
		$Qry1 .= "anmregistration_no1 = '" . Escape($this->anmregistration_no1) . "',";
		$Qry1 .= "anmregistration_no2 = '" . Escape($this->anmregistration_no2) . "',";
		$Qry1 .= "anmreg_date = STR_TO_DATE('" . Escape($this->anmreg_date) . "','$SQLDateFormat'),";
		$Qry1 .= "anmcouncil_date = STR_TO_DATE('" . Escape($this->anmcouncil_date) . "','$SQLDateFormat'),";
		$Qry1 .= "anmreg_enddate = STR_TO_DATE('" . Escape($this->anmreg_enddate) . "','$SQLDateFormat'),";


		$Qry1 .= "bsc_passcol = '" . Escape($this->bsc_passcol) . "',";
		$Qry1 .= "bsc_regname = '" . Escape($this->bsc_regname) . "',";
		$Qry1 .= "bsc_per = '" . Escape($this->bsc_per) . "',";
		$Qry1 .= "bsc_year = '" . Escape($this->bsc_year) . "',";
		$Qry1 .= "bscdegdiploma_certino = '" . Escape($this->bscdegdiploma_certino) . "',";
		$Qry1 .= "additional_regno = '" . Escape($this->additional_regno) . "',";
		$Qry1 .= "bsc_uniname = '" . Escape($this->bsc_uniname) . "',";
		$Qry1 .= "bscregistration_no1 = '" . Escape($this->bscregistration_no1) . "',";
		$Qry1 .= "bscregistration_no2 = '" . Escape($this->bscregistration_no2) . "',";
		$Qry1 .= "bscreg_date = STR_TO_DATE('" . Escape($this->bscreg_date) . "','$SQLDateFormat'),";
		$Qry1 .= "bsccouncil_date = STR_TO_DATE('" . Escape($this->bsccouncil_date) . "','$SQLDateFormat'),";
		$Qry1 .= "bscreg_enddate = STR_TO_DATE('" . Escape($this->bscreg_enddate) . "','$SQLDateFormat'),";
		//2-08
		$Qry1 .= "bscreviling_date = STR_TO_DATE('" . Escape($this->bscreviling_date) . "','$SQLDateFormat'),";
		$Qry1 .= "pbbsc_passcol= '" . Escape($this->pbbsc_passcol) . "',";
		$Qry1 .= "pbbsc_regname= '" . Escape($this->pbbsc_regname) . "',";
		$Qry1 .= "pbbsc_percentage= '" . Escape($this->pbbsc_percentage) . "',";
		$Qry1 .= "pbbsc_year= '" . Escape($this->pbbsc_year) . "',";
		//2-08
		$Qry1 .= "pbbscdegdiploma_certino= '" . Escape($this->pbbscdegdiploma_certino) . "',";
		$Qry1 .= "pbbsc_uniname= '" . Escape($this->pbbsc_uniname) . "',";
		$Qry1 .= "pbbscregistration_no1= '" . Escape($this->pbbscregistration_no1) . "',";
		$Qry1 .= "pbbscregistration_no2= '" . Escape($this->pbbscregistration_no2) . "',";
		$Qry1 .= "pbbscreg_date=  STR_TO_DATE('" . Escape($this->pbbscreg_date) . "','$SQLDateFormat'),";
		$Qry1 .= "pbbsccouncil_date=  STR_TO_DATE('" . Escape($this->pbbsccouncil_date) . "','$SQLDateFormat'),";
		$Qry1 .= "pbbscreg_enddate=  STR_TO_DATE('" . Escape($this->pbbscreg_enddate) . "','$SQLDateFormat'),";

		$Qry1 .= "student_father = '" . Escape($this->student_father) . "',";
		$Qry1 .= "student_guardian = '" . Escape($this->student_guardian) . "',";
		$Qry1 .= "student_birthdateplace = '" . Escape($this->student_birthdateplace) . "',";
		$Qry1 .= "student_religion = '" . Escape($this->student_religion) . "',";
		$Qry1 .= "student_subcast = '" . Escape($this->student_subcast) . "',";
		$Qry1 .= "marital_status = '" . Escape($this->marital_status) . "',";
		$Qry1 .= "permanent_addressat = '" . Escape($this->permanent_addressat) . "',";
		$Qry1 .= "permanent_addresspost = '" . Escape($this->permanent_addresspost) . "',";
		$Qry1 .= "parent_nationality = '" . Escape($this->parent_nationality) . "',";
		$Qry1 .= "passport_validity = STR_TO_DATE('" . Escape($this->passport_validity) . "','$SQLDateFormat'),";
		$Qry1 .= "passport_no = '" . Escape($this->passport_no) . "',";
		$Qry1 .= "issued_by = STR_TO_DATE('" . Escape($this->issued_by) . "','$SQLDateFormat'),";
		$Qry1 .= "student_fathermobile = '" . Escape($this->student_fathermobile) . "',";
		$Qry1 .= "student_mothermobile = '" . Escape($this->student_mothermobile) . "',";
		$Qry1 .= "student_grno = '" . Escape($this->student_grno) . "',";
		$Qry1 .= "pr_rank = '" . Escape($this->pr_rank) . "',";
		$Qry1 .= "twle_stream = '" . Escape($this->twle_stream) . "',";
		$Qry1 .= "registration_no1 = '" . Escape($this->registration_no1) . "',";
		$Qry1 .= "registration_no2 = '" . Escape($this->registration_no2) . "',";
		//priyanshi

		$Qry1 .= "student_age = '" . Escape($this->student_age) . "',";
		$Qry1 .= "student_relation = '" . Escape($this->student_relation) . "',";
		$Qry1 .= "student_nri = '" . Escape($this->student_nri) . "',";
		$Qry1 .= "parent_occupation = '" . Escape($this->parent_occupation) . "',";
		$Qry1 .= "parent_income = '" . Escape($this->parent_income) . "',";

		$Qry1 .= "gnm_month = '" . Escape($this->gnm_month) . "',";
		$Qry1 .= "anm_month = '" . Escape($this->anm_month) . "',";
		$Qry1 .= "bsc_month = '" . Escape($this->bsc_month) . "',";
		$Qry1 .= "pbbsc_month = '" . Escape($this->pbbsc_month) . "',";
		if ($Qry1 != "") {
			$Qry1 = substr($Qry1, 0, strlen($Qry1) - 1);
			$qry = "update cms_studentmaster set " . $Qry1 . " where student_id=" . $this->student_id;

			//	echo $qry; exit;
			dbQuery($qry);


			$qry2 = "UPDATE cms_feesreceivemaster SET branch_id= '" . Escape($this->branch_id) . "'
										 WHERE student_id ='" . Escape($this->student_id) . "' ";
			dbQuery($qry2);
		}

		$this->student_msg = "<strong>" . $this->bullet . " Student updated successfully.</strong>";

	}

	function delete()
	{
		$qry = "delete from  cms_studentmaster 
             	where student_id in (" . $this->deleteStudent_Id . ") 
							and college_id='" . $_SESSION["VedantnrCollegeId"] . "'";
		dbQuery($qry);
	}

	function updatePhoto()
	{
		$qry = "update cms_studentmaster 
						set student_photo = '" . $this->student_photo . "'
            where student_id =   " . $this->student_id . " and college_id='" . $_SESSION["VedantnrCollegeId"] . "'";

		dbQuery($qry);
	}

	function updateGTUNO()
	{
		$qry = "update cms_studentmaster 
						set student_gturegno = '" . $this->student_gturegno . "'
             	where student_id =   " . $this->student_id . " 
				and college_id='" . $_SESSION["VedantnrCollegeId"] . "'";
		dbQuery($qry);
	}
	function updateRollNo($condition)
	{
		$qry = "update cms_studentdetail 
						set student_rollno ='" . $this->student_rollno . "'
             	where student_id =   " . $this->student_id . " 
				 
				and college_id='" . $_SESSION["VedantnrCollegeId"] . "'";
		if ($condition != "") {
			$qry .= $condition;
		}
		dbQuery($qry);
	}

	function updatescholarship()
	{
		$qry = "update cms_studentmaster 
						set student_scholarship = '" . $this->scholarship_id . "'
             	where student_id =   " . $this->student_id . " and college_id='" . $_SESSION["VedantnrCollegeId"] . "'";

		//	echo 		 $qry; exit;
		dbQuery($qry);
	}



	function addinquiry()
	{

		global $SQLDateFormat;

		$Qry1 = "";

		$Qry1 .= "branch_id = '" . Escape($this->branch_id) . "',";
		$Qry1 .= "college_id = '" . Escape($this->college_id) . "',";
		$Qry1 .= "twle_seat = '" . Escape($this->twle_seat) . "',";
		$Qry1 .= "twle_total_mark = '" . Escape($this->twle_total_mark) . "',";
		$Qry1 .= "obtain_mark = '" . Escape($this->obtain_mark) . "',";
		$Qry1 .= "twle_percentage = '" . Escape($this->twle_percentage) . "',";
		$Qry1 .= "twle_maths ='" . Escape($this->twle_maths) . "',";
		$Qry1 .= "twle_chemistry ='" . Escape($this->twle_chemistry) . "',";
		$Qry1 .= "twle_physics = '" . Escape($this->twle_physics) . "',";
		$Qry1 .= "twle_other = '" . Escape($this->twle_other) . "',";
		$Qry1 .= "jee_seat = '" . Escape($this->jee_seat) . "',";
		$Qry1 .= "jee_physics = '" . replaceHtmlEditor(Escape($this->jee_physics)) . "',";
		$Qry1 .= "jee_chemistry = '" . Escape($this->jee_chemistry) . "',";
		$Qry1 .= "jee_maths = '" . Escape($this->jee_maths) . "',";
		$Qry1 .= "jee_total = '" . Escape($this->jee_total) . "',";
		$Qry1 .= "jee_obtain = '" . Escape($this->jee_obtain) . "',";
		$Qry1 .= "jee_percentage = '" . Escape($this->jee_percentage) . "',";
		$Qry1 .= "student_surname = '" . Escape($this->student_surname) . "',";
		$Qry1 .= "student_firstname = '" . Escape($this->student_firstname) . "',";
		$Qry1 .= "student_lastname = '" . Escape($this->student_lastname) . "',";
		$Qry1 .= "student_mother = '" . Escape($this->student_mother) . "',";
		//$Qry1 .= "student_photo = '"			.Escape($this->student_photo)."',";
		$Qry1 .= "student_gender = '" . Escape($this->student_gender) . "',";
		$Qry1 .= "student_category = '" . Escape($this->student_category) . "',";
		$Qry1 .= "student_address = '" . Escape($this->student_address) . "',";
		$Qry1 .= "student_birthdate = STR_TO_DATE('" . Escape($this->student_birthdate) . "','$SQLDateFormat'),";
		$Qry1 .= "student_phoneo = '" . Escape($this->student_phoneo) . "',";
		$Qry1 .= "student_phoner = '" . Escape($this->student_phoner) . "',";
		$Qry1 .= "reference = '" . Escape($this->reference) . "',";
		$Qry1 .= "login_id = '" . Escape($_SESSION['aUserId']) . "',";
		$Qry1 .= "createdon = '" . Escape(date('Y-m-d h:i:s')) . "',";


		if ($Qry1 != "") {
			$Qry1 = substr($Qry1, 0, strlen($Qry1) - 1);
			$qry = "insert into cms_studentmasterinquiry set " . $Qry1 . " ";

			dbQuery($qry);
			$this->student_id = dbInsertedId();
		}


	}


	function addinquirydiploma()
	{

		global $SQLDateFormat;

		$Qry1 = "";

		$Qry1 .= "branch_id = '" . Escape($this->branch_id) . "',";
		$Qry1 .= "college_id = '" . Escape($this->college_id) . "',";
		$Qry1 .= "university_name = '" . Escape($this->university_name) . "',";
		$Qry1 .= "passing_year = '" . Escape($this->passing_year) . "',";
		$Qry1 .= "reference = '" . Escape($this->reference) . "',";
		$Qry1 .= "enrollment_no = '" . Escape($this->enrollment_no) . "',";
		$Qry1 .= "sem_one ='" . Escape($this->sem_one) . "',";
		$Qry1 .= "sem_two ='" . Escape($this->sem_two) . "',";
		$Qry1 .= "sem_three = '" . Escape($this->sem_three) . "',";
		$Qry1 .= "sem_four = '" . Escape($this->sem_four) . "',";
		$Qry1 .= "sem_five = '" . Escape($this->sem_five) . "',";
		$Qry1 .= "sem_six = '" . Escape($this->sem_six) . "',";
		$Qry1 .= "enrollment_no_cgpa = '" . Escape($this->enrollment_no_cgpa) . "',";
		$Qry1 .= "cgpa = '" . Escape($this->cgpa) . "',";
		$Qry1 .= "enrollment_no_stpi = '" . Escape($this->enrollment_no_stpi) . "',";
		$Qry1 .= "stpi = '" . Escape($this->stpi) . "',";

		$Qry1 .= "student_surname = '" . Escape($this->student_surname) . "',";
		$Qry1 .= "student_firstname = '" . Escape($this->student_firstname) . "',";
		$Qry1 .= "student_lastname = '" . Escape($this->student_lastname) . "',";
		$Qry1 .= "student_mother = '" . Escape($this->student_mother) . "',";
		//$Qry1 .= "student_photo = '"			.Escape($this->student_photo)."',";
		$Qry1 .= "student_gender = '" . Escape($this->student_gender) . "',";
		$Qry1 .= "student_category = '" . Escape($this->student_category) . "',";
		$Qry1 .= "student_address = '" . Escape($this->student_address) . "',";
		$Qry1 .= "student_birthdate = STR_TO_DATE('" . Escape($this->student_birthdate) . "','$SQLDateFormat'),";
		$Qry1 .= "student_phoneo = '" . Escape($this->student_phoneo) . "',";
		$Qry1 .= "student_phoner = '" . Escape($this->student_phoner) . "',";
		$Qry1 .= "diploma_inquiry_no = '" . Escape($this->diploma_inquiry_no) . "',";
		$Qry1 .= "login_id = '" . Escape($_SESSION['aUserId']) . "',";
		$Qry1 .= "createdon = '" . Escape(date('Y-m-d h:i:s')) . "',";

		if ($Qry1 != "") {
			$Qry1 = substr($Qry1, 0, strlen($Qry1) - 1);
			$qry = "insert into cms_studentmasterinquirydiploma set " . $Qry1 . " ";
			//	 echo $qry; exit;

			dbQuery($qry);
			$this->student_id = dbInsertedId();
		}


	}


	function getdiplomainquiryNO()
	{
		$qry = "";
		$qry = "SELECT MAX(diploma_inquiry_no) + 1 as diploma_inquiry_no
		FROM `cms_studentmasterinquirydiploma`
		where
		1=1";
		//echo $qry; exit;
		$out = dbQuery($qry);

		if (dbRows($out) > 0) {
			$resut = dbArray($out);
			if ($resut["diploma_inquiry_no"] == "") {
				return "1";
			} else {
				return $resut["diploma_inquiry_no"];
			}
		}
		return out;
	}


	function inquiryCountstudentGridFilter_all($limit = 0, $start = 0, $condition = "", $order_field = "", $order_type = "")
	{
		$this->student_count = 0;

		$qry = "SELECT 
	  			Count(sm.student_inquiry_id) AS Count		   	 
		  	  FROM
			  	cms_studentmasterinquiry sm
				
		  	  WHERE			
				sm.college_id  = '" . $_SESSION["VedantnrCollegeId"] . "'
				 ";

		if ($condition != "") {
			$qry .= $condition;
		}

		$out = dbQuery($qry);

		if (dbRows($out) > 0) {
			$row = dbArray($out);
			extract($row);
			$this->student_count = $Count;
			dbResult($out);
		}
		return $this->student_count;
	}


	function viewstudentGridFilter_all($limit = 0, $start = 0, $condition = "", $order_field = "", $order_type = "")
	{
		$this->student_count = 0;


		$qry = "SELECT 
	  			sm.*,
				CONCAT(sm.student_surname , ' ' , sm.student_firstname , ' ' ,sm.student_lastname) AS studentname,			  
				(SELECT branch_name 
				FROM cms_branchmaster sec 
				WHERE sec.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' and sec.branch_id = sm.branch_id) AS branch_name
		  	  FROM
			  	cms_studentmasterinquiry sm						
		  	  WHERE								
				sm.college_id  = '" . $_SESSION["VedantnrCollegeId"] . "' ";

		if ($condition != "") {
			$qry .= $condition;
		}

		if ($order_field != "" && $order_type != "") {
			$qry .= " order by $order_field $order_type";
		}

		if (intval($limit) > 0 && intval($start) >= 0) {
			$qry .= " Limit $start , $limit";
		}

		//print $qry;
		//echo $qry;		


		$out = dbQuery($qry);

		if (dbRows($out) > 0) {
			$this->student_count = dbRows($out);
			return $out;
		}
		return $out;

	}

	function getStudentRecordsinquiry($limit = 0, $start = 0, $condition = "", $order_field = "", $order_type = "")
	{
		$this->student_count = 0;

		$qry = "SELECT * FROM cms_studentmasterinquiry ";

		if ($condition != "") {
			$qry .= $condition;
		}

		if ($order_field != "" && $order_type != "") {
			$qry .= " order by $order_field $order_type";
		}

		if (intval($limit) > 0 && intval($start) >= 0) {
			$qry .= " Limit $start , $limit";
		}
		//echo $qry;
		$out = dbQuery($qry);

		if (dbRows($out) > 0) {
			$this->student_count = dbRows($out);
			return $out;
		}

		return $out;
	}
	function getAllStudentRecordsicard($limit = 0, $start = 0, $condition = "", $order_field = "", $order_type = "")
	{
		$this->student_count = 0;

		$qry = "  SELECT DISTINCT
	  			sm.*,	
				sd.cur_branchid,
				sd.cur_semesterid,
				sd.batch_id,
				sd.cur_branchyearid,
				sd.year_id,
				(SELECT branch_name FROM cms_branchmaster sec WHERE sec.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' and sec.branch_id = sd.cur_branchid) AS branch_name,
	  		  	(SELECT year_name FROM cms_yearmaster ym WHERE  ym.year_id = sd.year_id) AS year_name,
				(SELECT semester_name FROM cms_semestermaster sem  WHERE  sem.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' AND sem.semester_id = sd.cur_semesterid) AS semester_name,
				(SELECT branchyear_name  FROM cms_branchyear bry  WHERE  bry.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' AND bry.branchyear_id = sd.cur_branchyearid) AS branchyear_name		    	 	   	 	
				   	 
		  	  FROM
			  	cms_studentmaster sm, 
					cms_studentdetail sd
		  	  WHERE 			  	
			  	sm.student_id = sd.student_id AND
			
				sm.student_active = 1 AND			  
				sm.college_id  = '" . $_SESSION["VedantnrCollegeId"] . "' ";

		if ($condition != "") {
			$qry .= $condition;
		}

		if ($order_field != "" && $order_type != "") {
			$qry .= " order by $order_field $order_type";
		}

		if (intval($limit) > 0 && intval($start) >= 0) {
			$qry .= " Limit $start , $limit";
		}
		//echo $qry;
		$out = dbQuery($qry);

		if (dbRows($out) > 0) {
			$this->student_count = dbRows($out);
			return $out;
		}
		//echo $qry;
		return $out;
	}


	function getStudentbranch($branch_id)
	{
		$qry = "SELECT branch_id FROM cms_studentmaster WHERE branch_id = $branch_id";
		//echo $qry;
		$out = dbQuery($qry);
		if (dbRows($out) > 0) {
			return $out;
		}
		return $out;
	}

	//for fees setup
	function getAllStudentfees($headNames, $condition)
	{
		$this->student_count = 0;

		$qry = "SELECT 
	  			sm.*,	
				CONCAT(sm.student_surname , ' ' , sm.student_firstname , ' ' ,sm.student_lastname) AS student_name,
				sd.mafifees_date,
				sd.mafifees_refname,
				sd.cur_branchid,
				sd.year_id,
				sd.cur_branchyearid,
				sd.cur_semesterid,
				
	   			sm.transport_facility,
			  	(SELECT branch_name 
				FROM cms_branchmaster sec 
				WHERE sec.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' and sec.branch_id=sd.cur_branchid) AS branch_name,
	  		  	(SELECT year_name 
				FROM cms_yearmaster ym 
				WHERE ym.year_id=sd.year_id) AS year_name,
	  		  	(SELECT branchyear_name 
				FROM cms_branchyear bry 
				WHERE bry.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' and bry.branchyear_id=sd.cur_branchyearid) AS branchyear_name,
	  		  	(SELECT semester_name
			   	 FROM cms_semestermaster sem 
			     WHERE  sem.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' AND sem.semester_id = sd.cur_semesterid) AS semester_name, ";

		foreach ($headNames as $head) {
			$qry .= "sd." . $head['fee_field'] . ", ";
			$qry .= "sd." . $head['mafi_field'] . ", ";
		}


		$qry = rtrim($qry, ", ");


		$qry .= " FROM cms_studentmaster sm, cms_studentdetail sd
						WHERE sm.student_id = sd.student_id 
						
						AND sd.current_active = 1 
						AND sm.student_active = 1 
						AND sm.college_id = '" . $_SESSION["VedantnrCollegeId"] . "'";

		if ($condition != "") {
			$qry .= $condition;
		}




		//echo $qry;exit;
		$out = dbQuery($qry);

		if (dbRows($out) > 0) {
			$this->student_count = dbRows($out);

		}
		//echo $qry;
		return $out;
	}


	function studentGridFilter5($limit = 0, $start = 0, $condition = "", $order_field = "", $order_type = "")
	{
		$this->student_count = 0;
		$qry = "SELECT 
	  			sm.student_id,
				CONCAT(sm.student_surname , ' ' , sm.student_firstname , ' ' ,sm.student_lastname) AS student_name,
				sm.student_gturegno,
				sd.year_id,
				sd.cur_branchyearid,
				sd.cur_semesterid,
				sd.batch_id,
				(SELECT branch_name 
				FROM cms_branchmaster sec 
				WHERE sec.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' and sec.branch_id = sd.cur_branchid) AS branch_name,
	  		  	(SELECT year_name
			   	 FROM cms_yearmaster ym 
			     WHERE ym.year_id = sd.year_id) AS year_name,
				(SELECT branchyear_name
			   	 FROM 	cms_branchyear bry 
			     WHERE bry.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' AND bry.branchyear_id = sd.cur_branchyearid) AS branchyear_name,
				 (SELECT semester_name
			   	 FROM cms_semestermaster sem 
			     WHERE sem.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' AND sem.semester_id = sd.cur_semesterid) AS semester_name		   	 
		  	  FROM
			  	cms_studentmaster sm,
				cms_studentdetail sd				
		  	  WHERE								
				sm.college_id  = '" . $_SESSION["VedantnrCollegeId"] . "' 
				AND sm.student_id= sd.student_id
				AND sd.current_active=1 ";

		//if($faculty_id!=""){
		//$qry.=" and FIND_IN_SET(sd.student_id,(select GROUP_CONCAT(`student_id`) AS student_id from cms_feesreceivemaster as fm where fm.`semester_id` = sd.cur_semesterid and fm.`branch_id` =sd.cur_branchid and fm.`division_id` = sd.cur_divison and fm.`college_id` = '".$_SESSION["VedantnrCollegeId"]."'  ))";
		//}

		if ($condition != "") {
			$qry .= $condition;
		}

		if ($order_field != "" && $order_type != "") {
			$qry .= " order by $order_field $order_type";
		}

		if (intval($limit) > 0 && intval($start) >= 0) {
			$qry .= " Limit $start , $limit";
		}
		//echo $qry;
		//exit;
		$out = dbQuery($qry);

		if (dbRows($out) > 0) {
			$this->student_count = dbRows($out);
			return $out;
		}
		return $out;
	}
	function getgturegno($student_gturegno, $student_id)
	{

		$qry = "SELECT * FROM cms_studentmaster WHERE student_gturegno = '$student_gturegno' AND student_id != '$student_id' ";

		//echo $qry;
		$out = dbQuery($qry);
		if (dbRows($out) > 0) {
			return $out;
		}
		return $out;
	}

	function getexamseatno($student_examseatno, $student_id)
	{

		$qry = "SELECT * FROM cms_studentmaster WHERE student_examseatno = '$student_examseatno' AND student_id != '$student_id' ";

		//echo $qry;
		$out = dbQuery($qry);
		if (dbRows($out) > 0) {
			return $out;
		}
		return $out;
	}


	function getstudentbranchsemester($branch_id, $semester_id)
	{

		$qry = "
				SELECT * FROM cms_studentmaster sm,cms_studentdetail sd WHERE
					sm.student_id = sd.student_id AND 
					sd.cur_branchid = '$branch_id' AND
					sd.cur_semesterid = '$semester_id' AND 
					sm.student_active = 1 ";
		//echo $qry;
		$out = dbQuery($qry);
		if (dbRows($out) > 0) {
			return $out;
		}
		return $out;
	}
	//student-search-data.php
	function getstudentsearch($where)
	{

		$qry = "SELECT 
		
	  		sm.student_id,
				sm.student_gturegno,
				sm.student_admdate, 
				CONCAT(sm.student_surname , ' ' , sm.student_firstname , ' ' ,sm.student_lastname) AS studentname,
				sm.student_birthdate,
				sm.student_gender,
				sm.student_admby,
				sm.student_category,	
				sm.student_mobilestudents,
				sm.student_mobileparents,
				sm.tfw_scheme,  		  
				sm.leave_type,
				(SELECT branch_name FROM cms_branchmaster sec WHERE sec.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' and sec.branch_id = sd.cur_branchid) AS branch_name,
	  		  	(SELECT year_name FROM cms_yearmaster ym WHERE  ym.year_id = sd.year_id) AS year_name,
				(SELECT semester_name FROM cms_semestermaster sem  WHERE  sem.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' AND sem.semester_id = sd.cur_semesterid) AS semester_name,
				(SELECT branchyear_name  FROM cms_branchyear bry  WHERE  bry.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "'AND bry.branchyear_id = sd.cur_branchyearid) AS branchyear_name		    	 
		  	  FROM
			  	cms_studentmaster sm,
				cms_studentdetail sd		
		  	  WHERE	sm.college_id  = '" . $_SESSION["VedantnrCollegeId"] . "' 
			  AND sm.student_id=sd.student_id    ";
		//echo $qry;

		if ($where != "") {
			$qry .= $where;
		}
		$out = dbQuery($qry);
		if (dbRows($out) > 0) {
			return $out;
		}
		return $out;
	}
	//student-gtu-data.php
	function getstudentgtu($where)
	{

		$qry = "SELECT 
		sm.student_id,
	  sm.student_gturegno,
	  CONCAT(sm.student_surname , ' ' , sm.student_firstname , ' ' ,sm.student_lastname) AS studentname,
	  (SELECT branch_name FROM cms_branchmaster sec WHERE sec.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' and sec.branch_id = sd.cur_branchid) AS branch_name,
		  (SELECT year_name FROM cms_yearmaster ym WHERE  ym.year_id = sd.year_id) AS year_name,
	  (SELECT semester_name FROM cms_semestermaster sem  WHERE  sem.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' AND sem.semester_id = sd.cur_semesterid) AS semester_name,
	  (SELECT branchyear_name  FROM cms_branchyear bry  WHERE  bry.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "'AND bry.branchyear_id = sd.cur_branchyearid) AS branchyear_name		    	 	   	 
	  FROM
		cms_studentmaster sm,
	  cms_studentdetail sd				
	  WHERE								
	  sm.college_id  = '" . $_SESSION["VedantnrCollegeId"] . "' 
	  AND sm.student_id=sd.student_id AND sd.current_active = 1";
		//echo $qry;

		if ($where != "") {
			$qry .= $where;
		}
		$out = dbQuery($qry);
		if (dbRows($out) > 0) {
			return $out;
		}
		return $out;
	}
	//student-roolno-data.php
	function getstudentrollno($where)
	{
		$qry = "SELECT 
		sm.student_id,
	  sm.student_gturegno,
	  CONCAT(sm.student_surname , ' ' , sm.student_firstname , ' ' ,sm.student_lastname) AS studentname,
		  sd.student_rollno,
	  (SELECT branch_name FROM cms_branchmaster sec WHERE sec.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' and sec.branch_id = sd.cur_branchid) AS branch_name,
		  (SELECT year_name FROM cms_yearmaster ym WHERE  ym.year_id = sd.year_id) AS year_name,
	  (SELECT semester_name FROM cms_semestermaster sem  WHERE  sem.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' AND sem.semester_id = sd.cur_semesterid) AS semester_name,
	  (SELECT branchyear_name  FROM cms_branchyear bry  WHERE  bry.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "'AND bry.branchyear_id = sd.cur_branchyearid) AS branchyear_name		    	 	   	 	
	  FROM
		cms_studentmaster sm,
	  cms_studentdetail sd				
	  WHERE								
	  sm.college_id  = '" . $_SESSION["VedantnrCollegeId"] . "' AND
	  sm.student_id = sd.student_id  AND 
	  sm.student_active=1 AND 
	  sd.current_active = 1";

		//echo $qry;

		if ($where != "") {
			$qry .= $where;
		}
		$out = dbQuery($qry);
		if (dbRows($out) > 0) {
			return $out;
		}
		return $out;
	}
	function UpdateStudentStatus($student_id, $backdate)
	{

		$qry = "Update cms_studentmaster set student_active='1',leave_type='',Back_from_detain= '$backdate' WHERE student_id in( " . Escape($student_id) . " ) ";

		//echo $qry;
		$out = dbQuery($qry);
		if (dbRows($out) > 0) {
			return $out;
		}
		return $out;
	}
	//fees-receipt-report.php
	function getstudentdata($condition)
	{

		$qry = "SELECT sd.student_id,cur_branchid,cur_branchyearid,cur_semesterid,sd.year_id FROM `cms_studentmaster` sm,cms_studentdetail sd where sm.student_id=sd.student_id ";

		//echo $qry;
		if ($condition != "") {
			$qry .= $condition;
		}
		$out = dbQuery($qry);
		if (dbRows($out) > 0) {
			return $out;
		}
		return $out;
	}


	function getstudentfeesdata($condition)
	{

		$qry = "SELECT
            sm. *,
            sd.cur_semesterid,
            sd.cur_branchid,
            CONCAT(student_surname,' ',student_firstname,' ',SUBSTR(student_lastname,1,1),'.') AS student_name,
            SUBSTR(student_gender,1,1) AS student_gender,
            
            (SELECT branch_name 
                    FROM cms_branchmaster bm 
                    WHERE bm.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' and sd.cur_branchid =bm.branch_id) AS branch_name,
            (SELECT year_name 
                    FROM cms_yearmaster ym  WHERE  sd.year_id  =ym.year_id) AS year_name,
            (SELECT branchyear_name
                    FROM cms_branchyear bry 
                    WHERE  bry.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' AND sd.cur_branchyearid = bry.branchyear_id) AS branchyear_name,
            (SELECT semester_name
                    FROM cms_semestermaster sem 
                    WHERE  sem.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' AND sd.cur_semesterid = sem.semester_id) AS semester_name                                                
    FROM
        cms_studentmaster sm,
        cms_studentdetail sd
    WHERE  
        sm.student_id = sd.student_id ";

		if ($condition != "") {
			$qry .= $condition;
		}
		//echo $qry;
		$out = dbQuery($qry);
		if (dbRows($out) > 0) {
			return $out;
		}
		return $out;
	}

	function getstudent360report($condition)
	{
		$qry = "SELECT
            sm. *,
            sd.cur_semesterid,
            sd.cur_branchid,
            CONCAT(student_surname,' ',student_firstname,' ',SUBSTR(student_lastname,1,1),'.') AS student_name,
            SUBSTR(student_gender,1,1) AS student_gender,
            
            (SELECT branch_name 
                    FROM cms_branchmaster bm 
                    WHERE bm.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' and sd.cur_branchid =bm.branch_id) AS branch_name,
            (SELECT year_name 
                    FROM cms_yearmaster ym  WHERE  sd.year_id  =ym.year_id) AS year_name,
            (SELECT branchyear_name
                    FROM cms_branchyear bry 
                    WHERE  bry.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' AND sd.cur_branchyearid = bry.branchyear_id) AS branchyear_name,
            (SELECT semester_name
                    FROM cms_semestermaster sem 
                    WHERE  sem.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' AND sd.cur_semesterid = sem.semester_id) AS semester_name                                                
    FROM
        cms_studentmaster sm,
        cms_studentdetail sd
    WHERE  
        sm.student_id = sd.student_id ";

		//echo $qry;

		if ($condition != "") {
			$qry .= $condition;
		}
		$out = dbQuery($qry);
		if (dbRows($out) > 0) {
			return $out;
		}
		return $out;
	}

	//report-student-list-result.php
	function getstudentlist($condition)
	{
		$qry = "SELECT 
		sm.student_id,
		sd.cur_semesterid,
		sd.cur_branchid,
		sd.cur_branchyearid,
		sd.year_id,	
		student_admdate,
		CONCAT(student_surname,' ',student_firstname,' ',student_lastname,'') AS student_name,
		sm.student_gturegno,
		SUBSTR(student_gender,1,1) AS student_gender,
		student_mobileother,
		student_fathermobile,
		student_category,
		sm.student_admby,
		sd.student_rollno,
		student_birthdate,
		(SELECT branch_name FROM cms_branchmaster sec WHERE sec.branch_id = sd.cur_branchid) AS branch_name,
		  (SELECT year_name FROM cms_yearmaster ym  WHERE ym.year_id = sd.year_id) AS year_name,
		(SELECT semester_name FROM cms_semestermaster sem  WHERE sem.semester_id = sd.cur_semesterid) AS semester_name,
		(SELECT branchyear_name FROM cms_branchyear bry 
			 WHERE   bry.branchyear_id = sd.cur_branchyearid) AS branchyear_name
	FROM
		cms_studentmaster sm,
		cms_studentdetail sd
		
	WHERE 
		sm.college_id  = '" . $_SESSION["VedantnrCollegeId"] . "' 
			AND sm.student_id=sd.student_id
			AND sm.student_active= 1";
		//echo $qry;

		if ($condition != "") {
			$qry .= $condition;
		}
		$out = dbQuery($qry);
		if (dbRows($out) > 0) {
			return $out;
		}
		return $out;
	}


	//report-student-summary-result.php
	function getstudentsummary($condition)
	{
		$qry = "SELECT 
				student_gender,
				count(student_gender)as count,
				sm.student_admby,
				COUNT(sm.student_admby) AS count,
				student_category,
				count(student_category)as count,
				tfw_scheme,
				count(tfw_scheme)as count,
				
				sd.cur_semesterid,
				sd.cur_branchid,
				sd.cur_branchyearid,
				sd.year_id,
				(SELECT branch_name FROM cms_branchmaster sec WHERE sec.branch_id = sd.cur_branchid) AS branch_name,
				(SELECT year_name FROM cms_yearmaster ym  WHERE ym.year_id = sd.year_id) AS year_name,
				(SELECT semester_name FROM cms_semestermaster sem  WHERE sem.semester_id = sd.cur_semesterid) AS semester_name,
				(SELECT branchyear_name FROM cms_branchyear bry 
					WHERE   bry.branchyear_id = sd.cur_branchyearid) AS branchyear_name
			FROM
				cms_studentmaster sm,
				cms_studentdetail sd
			WHERE 
				sm.student_active = 1 AND 
				sm.student_id = sd.student_id AND
				sd.college_id = '" . $_SESSION['VedantnrCollegeId'] . "'  ";
		//echo $qry;

		if ($condition != "") {
			$qry .= $condition;
		}
		$out = dbQuery($qry);
		if (dbRows($out) > 0) {
			return $out;
		}
		return $out;
	}


	function getstudentactivesummary($condition)
	{
		$qry = "SELECT 
				student_active ,
				count(student_active)as count,
				sd.cur_semesterid,
				sd.cur_branchid,
				sd.cur_branchyearid,
				sd.year_id,
				(SELECT branch_name FROM cms_branchmaster sec WHERE sec.branch_id = sd.cur_branchid) AS branch_name,
				(SELECT year_name FROM cms_yearmaster ym  WHERE ym.year_id = sd.year_id) AS year_name,
				(SELECT semester_name FROM cms_semestermaster sem  WHERE sem.semester_id = sd.cur_semesterid) AS semester_name,
				(SELECT branchyear_name FROM cms_branchyear bry 
					WHERE   bry.branchyear_id = sd.cur_branchyearid) AS branchyear_name
			FROM
				cms_studentmaster sm,
				cms_studentdetail sd
			WHERE 
				sm.student_id = sd.student_id AND
				sd.college_id = '" . $_SESSION['VedantnrCollegeId'] . "'  ";
		//echo $qry;

		if ($condition != "") {
			$qry .= $condition;
		}
		$out = dbQuery($qry);
		if (dbRows($out) > 0) {
			return $out;
		}
		return $out;
	}
	//report-student-birthday-result.php
	function getstudentbirthday($condition)
	{
		$qry = "
		SELECT 
			sm.student_id,
			sm.shift,
			sd.cur_semesterid,
			sd.cur_branchid,
			student_birthdate,
			CONCAT(student_surname, ' ', student_firstname, ' ', student_lastname, ' ') AS student_name,
			student_gturegno,
			SUBSTR(student_gender,1,1) AS student_gender,
			student_mobileother,
			student_fathermobile,
			sm.student_admby,
			sm.tfw_scheme ,
			(SELECT branch_name 
				FROM cms_branchmaster sec 
				WHERE sec.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' and sec.branch_id = sd.cur_branchid) AS branch_name,
	  		  	(SELECT year_name
			   	 FROM cms_yearmaster ym 
			     WHERE ym.year_id = sd.year_id) AS year_name,
				(SELECT branchyear_name
			   	 FROM 	cms_branchyear bry 
			     WHERE bry.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' AND bry.branchyear_id = sd.cur_branchyearid) AS branchyear_name,
				 (SELECT semester_name
			   	 FROM cms_semestermaster sem 
			     WHERE sem.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' AND sem.semester_id = sd.cur_semesterid) AS semester_name		   	 
		  	 
		FROM
			cms_studentmaster sm,
			cms_studentdetail sd
		
		WHERE 
			sm.student_active = 1 AND 
			sm.student_id = sd.student_id and
			sd.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "'";


		if ($condition != "") {
			$qry .= $condition;
		}
		//echo $qry;
		$out = dbQuery($qry);
		if (dbRows($out) > 0) {
			return $out;
		}
		return $out;
	}

	//report-student-selection.php
	function getstudentdisplay($condition)
	{
		$qry = "SELECT * FROM cms_displaytable WHERE 1=1 ";

		if ($condition != "") {
			$qry .= $condition;
		}
		//echo $qry;
		$out = dbQuery($qry);
		if (dbRows($out) > 0) {
			return $out;
		}
		return $out;
	}

	function getstudentselection($fields, $table_append, $condition)
	{
		$qry = "SELECT " . $fields . " FROM cms_studentmaster stu " . $table_append . " WHERE 1=1 ";
		if ($condition != "") {
			$qry .= $condition;
		}
		//echo $qry;
		//$out = dbQuery($qry);
		//if (dbRows($out) > 0) {
		//	return $out;
		//}
		return $qry;
	}

	//report-reshuffling-list.php
	function getstudentreshuffling($condition)
	{
		$qry = " SELECT 
			sm.student_id,
			leave_date,
			CONCAT(student_surname,' ',student_firstname,' ',student_lastname) AS student_name,
			sm.student_gturegno,
			sm.student_gender,
			sm.leave_comment,
			sd.cur_semesterid,
			sd.cur_branchid,
			sd.cur_branchyearid,
			sd.year_id,
			
			(SELECT branch_name FROM cms_branchmaster sec WHERE sec.branch_id = sd.cur_branchid) AS branch_name,
	  		(SELECT year_name FROM cms_yearmaster ym  WHERE ym.year_id = sd.year_id) AS year_name,
			(SELECT semester_name FROM cms_semestermaster sem  WHERE sem.semester_id = sd.cur_semesterid) AS semester_name,
			(SELECT branchyear_name FROM cms_branchyear bry 
			     WHERE   bry.branchyear_id = sd.cur_branchyearid) AS branchyear_name
		FROM
			cms_studentmaster sm,
			cms_studentdetail sd
		WHERE 
			sm.student_active = 0 AND 
			sm.leave_type = 'r' AND
			sm.student_id = sd.student_id AND
			sd.college_id = '" . $_SESSION['VedantnrCollegeId'] . "'  ";


		if ($condition != "") {
			$qry .= $condition;
		}
		//echo $qry;
		$out = dbQuery($qry);
		if (dbRows($out) > 0) {
			return $out;
		}
		return $out;
	}

	//report-suspend-list.php
	function getstudentsuspend($condition)
	{
		$qry = "SELECT 
			sm.student_id,
			leave_date,
			CONCAT(student_surname,' ',student_firstname,' ',student_lastname) AS student_name,
			student_gturegno,
			student_gender,
			sm.student_admby,
			student_mobileother,
			student_fathermobile, 
			sd.cur_semesterid,
			sd.cur_branchid,
			sd.cur_branchyearid,
			sd.year_id,
			(SELECT branch_name FROM cms_branchmaster sec WHERE sec.branch_id = sd.cur_branchid) AS branch_name,
	  		(SELECT year_name FROM cms_yearmaster ym  WHERE ym.year_id = sd.year_id) AS year_name,
			(SELECT semester_name FROM cms_semestermaster sem  WHERE sem.semester_id = sd.cur_semesterid) AS semester_name,
			(SELECT branchyear_name FROM cms_branchyear bry 
			     WHERE   bry.branchyear_id = sd.cur_branchyearid) AS branchyear_name
		FROM
			cms_studentmaster sm,
			cms_studentdetail sd
		WHERE 
			sm.student_active = 0 AND 
			sm.leave_type = 's' AND
			sm.college_id  = '" . $_SESSION["VedantnrCollegeId"] . "' 
				AND sm.student_id=sd.student_id";


		if ($condition != "") {
			$qry .= $condition;
		}
		//echo $qry;
		$out = dbQuery($qry);
		if (dbRows($out) > 0) {
			return $out;
		}
		return $out;
	}

	//

	//report-address-list.php
	function getstudentaddress($condition)
	{
		$qry = "SELECT 
			CONCAT(student_surname,' ',student_firstname,' ',student_lastname) AS student_name,
			student_addressat,
			student_addresspost,	
			student_pincode,
			taluko_nameeng,
			dist_nameeng,
			state_nameeng,			
			student_mobileother,
			student_fathermobile
		FROM
			cms_studentmaster sm,
			cms_studentdetail sd			
		WHERE 
			sm.student_id = sd.student_id AND
			sm.student_active = 1";


		if ($condition != "") {
			$qry .= $condition;
		}
		//echo $qry;
		$out = dbQuery($qry);
		if (dbRows($out) > 0) {
			return $out;
		}
		return $out;
	}

	//report-detain-list.php
	function getstudentdetain($condition)
	{
		$qry = "
		SELECT 
	  			sm.student_id,
				sm.student_gturegno,
				sm.student_admdate, 
				CONCAT(sm.student_surname , ' ' , sm.student_firstname , ' ' ,sm.student_lastname) AS studentname,
				sm.student_birthdate,
				sm.student_gender,
				sm.student_addressat,
				sm.student_addresspost,	
				sm.student_pincode,
				sm.taluko_nameeng,
				sm.dist_nameeng,
				sm.state_nameeng,		
				sm.student_admby,
				sm.student_category,	
				student_mobileother,
				student_fathermobile,
				sm.leave_type,
			  	(SELECT branch_name 
				FROM cms_branchmaster sec 
				WHERE sec.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' and sec.branch_id=sd.cur_branchid) AS branch_name,
	  		  		(SELECT year_name 
				FROM cms_yearmaster ym 
				WHERE ym.year_id=sd.year_id) AS year_name,
	  		  	(SELECT branchyear_name 
				FROM cms_branchyear bry 
				WHERE bry.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' and bry.branchyear_id=sd.cur_branchyearid) AS branchyear_name,
	  		  	(SELECT 
					semester_name
			   	 FROM 
				 	cms_semestermaster sem 
			     WHERE 
				 sem.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "'
				 AND sem.semester_id = sd.cur_semesterid) AS semester_name,
				 sd.year_id, 	
				(SELECT year_name 
				FROM cms_yearmaster yr 
				WHERE year_id   = sd.year_id) AS year_name		   	 
		  	  FROM
			  	cms_studentmaster sm,
				cms_studentdetail sd				
		  	  WHERE								
				sm.college_id  = '" . $_SESSION["VedantnrCollegeId"] . "' 
				AND sm.student_id=sd.student_id
				AND sm.student_active=0
				AND sm.leave_type='d'";

		if ($condition != "") {
			$qry .= $condition;
		}
		//echo $qry;
		$out = dbQuery($qry);
		if (dbRows($out) > 0) {
			return $out;
		}
		return $out;
	}


	//report-cancel-list.php
	function getstudentcancel($condition)
	{
		$qry = "
		SELECT 
	  			sm.student_id,
				sm.student_gturegno,
				sm.student_admdate, 
				CONCAT(sm.student_surname , ' ' , sm.student_firstname , ' ' ,sm.student_lastname) AS studentname,
				sm.student_birthdate,
				sm.student_gender,
				sm.student_admby,
				sm.student_category,	
				student_mobileother,
			student_fathermobile,
				sm.leave_type,
				(SELECT branch_name FROM cms_branchmaster sec WHERE sec.branch_id = sd.cur_branchid) AS branch_name,
	  		(SELECT year_name FROM cms_yearmaster ym  WHERE ym.year_id = sd.year_id) AS year_name,
			(SELECT semester_name FROM cms_semestermaster sem  WHERE sem.semester_id = sd.cur_semesterid) AS semester_name,
			(SELECT branchyear_name FROM cms_branchyear bry 
			     WHERE   bry.branchyear_id = sd.cur_branchyearid) AS branchyear_name   	 
		  	  FROM
			  	cms_studentmaster sm,
				cms_studentdetail sd				
		  	  WHERE								
				sm.college_id  = '" . $_SESSION["VedantnrCollegeId"] . "' 
				AND sm.student_id=sd.student_id
				AND sm.student_active=0
				AND sm.leave_type='c'";
		if ($condition != "") {
			$qry .= $condition;
		}
		//echo $qry;
		$out = dbQuery($qry);
		if (dbRows($out) > 0) {
			return $out;
		}
		return $out;
	}


	//report-yearwise-list.php
	function getstudentyearwiselist($condition)
	{
		$qry = "SELECT 
    CONCAT(sm.student_surname, ' ', sm.student_firstname, ' ', sm.student_lastname) AS student_name,
    sm.student_gturegno,
	(SELECT branch_name 
				FROM cms_branchmaster sec 
				WHERE sec.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' and sec.branch_id=sd.cur_branchid) AS branch_name,
	  		  	(SELECT year_name 
				FROM cms_yearmaster ym 
				WHERE ym.year_id=sd.year_id) AS year_name,
	  		  	(SELECT branchyear_name 
				FROM cms_branchyear bry 
				WHERE bry.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' and bry.branchyear_id=sd.cur_branchyearid) AS branchyear_name,
	  		  	(SELECT semester_name
			   	FROM cms_semestermaster sem 
				WHERE  sem.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' AND sem.semester_id = sd.cur_semesterid) AS semester_name	  		 	
		FROM 
		    cms_studentmaster sm,
		    cms_studentdetail sd 
			where 
			sm.student_id = sd.student_id";
		if ($condition != "") {
			$qry .= $condition;
		}
		//echo $qry;
		$out = dbQuery($qry);
		if (dbRows($out) > 0) {
			return $out;
		}
		return $out;
	}

	//report- student-hostel-facility.php
	function getstudentHostellist($condition)
	{
		$qry = "SELECT 
			sm.student_id,
			CONCAT(student_surname,' ',student_firstname,' ',student_lastname) AS student_name,
			student_gturegno,
			tf.transport_facility,
			sd.cur_semesterid,
			sd.cur_branchid,
			sd.cur_branchyearid,
			sd.year_id,
			(SELECT branch_name FROM cms_branchmaster sec WHERE sec.branch_id = sd.cur_branchid) AS branch_name,
	  		(SELECT year_name FROM cms_yearmaster ym  WHERE ym.year_id = sd.year_id) AS year_name,
			(SELECT semester_name FROM cms_semestermaster sem  WHERE sem.semester_id = sd.cur_semesterid) AS semester_name,
			(SELECT branchyear_name FROM cms_branchyear bry 
			     WHERE   bry.branchyear_id = sd.cur_branchyearid) AS branchyear_name
		FROM
			cms_studentmaster sm,
			cms_studentdetail sd,
			cms_transportfacility tf
		WHERE 
				sm.college_id  = '" . $_SESSION["VedantnrCollegeId"] . "' 
				AND sm.student_id=sd.student_id 
				AND sm.student_id=tf.student_id
				AND sm.student_active=1";
		if ($condition != "") {
			$qry .= $condition;
		}
		//echo $qry;
		$out = dbQuery($qry);
		if (dbRows($out) > 0) {
			return $out;
		}
		return $out;
	}

	//student-search-list.php
	function getstudentsearchlist($condition)
	{
		$qry = "SELECT DISTINCT(sm.student_gturegno),
	  			sm.student_id,
				sm.student_admdate, 
				CONCAT(sm.student_surname , ' ' , sm.student_firstname , ' ' ,sm.student_lastname) AS student_name,
				sm.student_birthdate,
				sm.student_gender,
				sm.student_admby,
				sm.student_category,	
				sm.student_mobileother,
				sm.student_fathermobile,
				sm.tfw_scheme,  		  
			  	sd.batch_id, 
				sm.leave_type,
				(SELECT branch_name FROM cms_branchmaster sec WHERE sec.branch_id = sd.cur_branchid) AS branch_name,
	  		(SELECT year_name FROM cms_yearmaster ym  WHERE ym.year_id = sd.year_id) AS year_name,
			(SELECT semester_name FROM cms_semestermaster sem  WHERE sem.semester_id = sd.cur_semesterid) AS semester_name,
			(SELECT branchyear_name FROM cms_branchyear bry 
			     WHERE   bry.branchyear_id = sd.cur_branchyearid) AS branchyear_name   	 
		  	  FROM
			  	cms_studentmaster sm,
				cms_studentdetail sd				
		  	  WHERE								
				sm.college_id  = '" . $_SESSION["VedantnrCollegeId"] . "' 
				AND sm.student_id=sd.student_id  ";
		if ($condition != "") {
			$qry .= $condition;
		}
		//echo $qry;
		$out = dbQuery($qry);
		if (dbRows($out) > 0) {
			return $out;
		}
		return $out;
	}

	//student-search-list.php
	//attendence-summary.php
	//attendence-list.php
	//continue-absent.php
	function getstudentattnd($condition)
	{
		$qry = "
		SELECT 
			sm.student_id,
			CONCAT(student_surname,' ',student_firstname) AS student_name,
			student_gturegno,
			student_gender,
			batch_id,
			student_mobilestudents,
			student_mobileparents
		FROM
			cms_studentmaster sm,
			cms_studentdetail sd
		WHERE sm.student_active = 1 AND sm.student_id = sd.student_id  AND sd.college_id = " . $_SESSION["VedantnrCollegeId"];
		if ($condition != "") {
			$qry .= $condition;
		}
		//echo $qry;
		$out = dbQuery($qry);
		if (dbRows($out) > 0) {
			return $out;
		}
		return $out;
	}
	//attendence-list.php

	function getstudentdaypresent($condition)
	{
		$qry = "SELECT 
		GROUP_CONCAT(day_present) AS day_present 
		FROM cms_presentmaster 
		WHERE day_working = 1 ";
		if ($condition != "") {
			$qry .= $condition;
		}
		//echo $qry;
		$out = dbQuery($qry);
		if (dbRows($out) > 0) {
			return $out;
		}
		return $out;
	}

	function getstudentdayworking($condition)
	{
		$qry = "SELECT 
		COUNT(*) AS count ,batch_id
		FROM cms_presentmaster 
		WHERE day_working = 1 ";
		if ($condition != "") {
			$qry .= $condition;
		}
		//echo $qry;
		$out = dbQuery($qry);
		if (dbRows($out) > 0) {
			return $out;
		}
		return $out;
	}

	function getstudentdayabsent($condition)
	{
		$qry = "
		SELECT
			GROUP_CONCAT(day_absent) AS day_absent
		FROM 
			cms_presentmaster 
		WHERE 
			day_working = 1 AND 
			college_id = " . $_SESSION["VedantnrCollegeId"];
		if ($condition != "") {
			$qry .= $condition;
		}
		//echo $qry;
		$out = dbQuery($qry);
		if (dbRows($out) > 0) {
			return $out;
		}
		return $out;
	}

	function getstudentdayworkingabsent($condition)
	{
		$qry = "
		SELECT 
			COUNT(*) AS count 
			FROM cms_presentmaster 
			WHERE
			day_working = 1 AND college_id = " . $_SESSION["VedantnrCollegeId"];

		if ($condition != "") {
			$qry .= $condition;
		}
		//echo $qry;
		$out = dbQuery($qry);
		if (dbRows($out) > 0) {
			return $out;
		}
		return $out;
	}

	//loginhome.php 
	function getuserstudent($condition)
	{
		$qry = "
					SELECT
					sm.student_id,
					sm.student_admby,
					sd.cur_branchid,
					sd.cur_semesterid,
					sd.batch_id,
					sd.cur_branchyearid,
					sm.student_gender,
					CONCAT(student_surname,' ',student_firstname,'. ',SUBSTR(student_lastname,1,1),'.') AS student_name,
					student_gturegno,
					student_mobilestudents,
					student_mobileparents,
					tfw_scheme,
					(SELECT branch_name 
				FROM cms_branchmaster sec 
				WHERE sec.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' and sec.branch_id = sd.cur_branchid) AS branch_name,
	  		  	(SELECT year_name
			   	 FROM cms_yearmaster ym 
			     WHERE ym.year_id = sd.year_id) AS year_name,
				(SELECT branchyear_name
			   	 FROM 	cms_branchyear bry 
			     WHERE bry.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' AND bry.branchyear_id = sd.cur_branchyearid) AS branchyear_name,
				 (SELECT semester_name
			   	 FROM cms_semestermaster sem 
			     WHERE sem.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' AND sem.semester_id = sd.cur_semesterid) AS semester_name		   	 
		  
					FROM
					cms_studentmaster sm,
					cms_studentdetail sd
					
					WHERE
					sm.student_id = sd.student_id AND
					sm.student_active = 1 AND
					sm.college_id='" . $_SESSION["VedantnrCollegeId"] . "'";

		if ($condition != "") {
			$qry .= $condition;
		}
		//echo $qry;
		$out = dbQuery($qry);
		if (dbRows($out) > 0) {
			return $out;
		}
		return $out;
	}
	//bonafied
	function getAllStudentbonafied($limit = 0, $start = 0, $condition = "", $order_field = "", $order_type = "")
	{
		$this->student_count = 0;

		$qry = "
		SELECT
			sm.*,
			sd.cur_semesterid,
			sd.cur_branchid,
			sd.cur_branchyearid,
			sd.year_id,
			CONCAT(sm.student_surname,' ',sm.student_firstname,' ',SUBSTR(sm.student_lastname,1,1),'.') AS student_name,
			SUBSTR(sm.student_gender,1,1) AS student_gender,
			sd.batch_id,
			(SELECT branch_name 
				FROM cms_branchmaster sec 
				WHERE sec.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' and sec.branch_id=sd.cur_branchid) AS branch_name,
	  		(SELECT year_name 
				FROM cms_yearmaster ym 
				WHERE ym.year_id=sd.year_id) AS year_name,
	  		(SELECT branchyear_name 
				FROM cms_branchyear bry 
				WHERE bry.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' and bry.branchyear_id=sd.cur_branchyearid) AS branchyear_name,
	  		(SELECT semester_name
			   	 FROM cms_semestermaster sem 
			     WHERE  sem.college_id   = '" . $_SESSION["VedantnrCollegeId"] . "' AND sem.semester_id = sd.cur_semesterid) AS semester_name
			
		FROM
			cms_studentmaster sm,
			cms_studentdetail sd
			
		WHERE  
			sm.student_id = sd.student_id";

		if ($condition != "") {
			$qry .= $condition;
		}

		if ($order_field != "" && $order_type != "") {
			$qry .= " order by $order_field $order_type";
		}

		if (intval($limit) > 0 && intval($start) >= 0) {
			$qry .= " Limit $start , $limit";
		}

		$out = dbQuery($qry);

		if (dbRows($out) > 0) {
			$this->student_count = dbRows($out);
			return $out;
		}
		//echo $qry;
		return $out;
	}
	//getstudent-unamepass.php
	function getuserpassword($condition)
	{
		$qry = "
		SELECT
			CONCAT(sm.student_surname,' ',sm.student_firstname) AS student_name,
			sm.student_id,
			sm.student_firstname,
			sm.student_birthdate,
			sm.student_gturegno,
			um.user_name,
			um.user_password
		FROM
			cms_studentmaster sm, cms_usermaster um,
			   cms_studentdetail sd	 
		WHERE 
			sm.student_id = sd.student_id  and 
			sm.student_active = 1 ";

		if ($condition != "") {
			$qry .= $condition;
		}
		//echo $qry;
		$out = dbQuery($qry);
		if (dbRows($out) > 0) {
			return $out;
		}
		return $out;
	}
}
?>