<?php
class FeesheadMgmt
{
	public $head_id;
	public $fees_type;
	public $college_id;
	public $head_name;

	function getAllRecords($limit = 0, $start = 0, $condition = "", $order_field = "", $order_type = "")
	{
		$qry = "";
		$qry = "SELECT * FROM cms_feeshead WHERE 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) {
			return $out;
		}
		return $out;
	}

	function add()
	{
		$Qry1 = "";
		$Qry1 .= "college_id='" . Escape($_SESSION['VedantnrCollegeId']) . "',";
		$Qry1 .= "fees_type='" . Escape($this->fees_type) . "',";
		$Qry1 .= "head_name='" . Escape($this->head_name) . "',";
		$Qry1 .= "login_id='" . Escape($_SESSION['aUserId']) . "',";
		$Qry1 .= "createdon='" . Escape(date('Y-m-d h:i:s')) . "',";
		$Qry1 .= "head_active='1',";
		if ($Qry1 != "") {
			$Qry1 = substr($Qry1, 0, strlen($Qry1) - 1);
			$qry = "insert into cms_feeshead set " . $Qry1 . " ";
			dbQuery($qry);
			$this->head_id = dbInsertedId();
		}
	}

	function edit()
	{
		$Qry1 = "";
		$Qry1 .= "fees_type='" . Escape($this->fees_type) . "',";
		$Qry1 .= "head_name='" . Escape($this->head_name) . "',";
		$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 = "update cms_feeshead set " . $Qry1 . " where head_id=" . $this->head_id;
			dbQuery($qry);
		}
	}

	function delete()
	{
		$qry = "delete from cms_feeshead where head_id in (" . $this->head_id . ") ";
		dbQuery($qry);
	}

	function getfeeshead($head_name,$head_id)
	{

		$qry ="SELECT * FROM cms_feeshead WHERE head_name = '$head_name' AND head_id != '$head_id' and college_id = '".$_SESSION['VedantnrCollegeId'] ."'";
			

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

	function gethead($condition)
	{

		$qry ="SELECT Distinct(fees_type) FROM cms_feeshead WHERE head_name != 'ACPDC Adm Fee' ORDER BY head_id ASC";


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