<?php
class BranchMgmt
{
	public $branch_id;
	public $college_id;
	public $branch_name;

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

	function add()
	{
		$Qry1 = "";
		$Qry1 .= "college_id='" . Escape($_SESSION['VedantnrCollegeId']) . "',";
		$Qry1 .= "branch_name='" . Escape($this->branch_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 = "insert into cms_branchmaster set " . $Qry1 . " ";
			dbQuery($qry);
			$this->branch_id = dbInsertedId();
		}
	}

	function edit()
	{
		$Qry1 = "";
		$Qry1 .= "branch_name='" . Escape($this->branch_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_branchmaster set " . $Qry1 . " where branch_id=" . $this->branch_id;
			dbQuery($qry);
		}
	}

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

	function getbranch($branch_name, $branch_id)
	{

		$qry = "SELECT * FROM cms_branchmaster WHERE branch_name = '$branch_name' AND branch_id != $branch_id";
		$out = dbQuery($qry);
		if (dbRows($out) > 0) {
			return $out;
		}
		return $out;
	}

	
}
?>