<?php
class CollegeMgmt
{
	public $college_id;
	public $college_name;
	public $college_address;
	public $college_phone;
	public $college_email;
	public $college_url;
	public $college_logo;
	public $login_id;
	public $createdon;

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

		$out = dbQuery($qry);

		if (dbRows($out) > 0) {
			return $out;
		}
		return $out;
	}

	function add()
	{
		global $SQLDateFormat;
		$Qry1 = "";
		$Qry1 .= "college_name = '" . Escape($this->college_name) . "',";
		$Qry1 .= "college_address = '" . Escape($this->college_address) . "',";
		$Qry1 .= "college_phone = '" . Escape($this->college_phone) . "',";
		$Qry1 .= "college_email = '" . Escape($this->college_email) . "',";
		$Qry1 .= "college_url = '" . Escape($this->college_url) . "',";
		$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_collegemaster SET " . $Qry1 . " ";
			dbQuery($qry);
			$this->college_id = dbInsertedId();
		}
	}

	function edit()
	{
		global $SQLDateFormat;
		$Qry1 = "";
		$Qry1 .= "college_name = '" . Escape($this->college_name) . "',";
		$Qry1 .= "college_address = '" . Escape($this->college_address) . "',";
		$Qry1 .= "college_phone = '" . Escape($this->college_phone) . "',";
		$Qry1 .= "college_email = '" . Escape($this->college_email) . "',";
		$Qry1 .= "college_url = '" . Escape($this->college_url) . "',";
		$Qry1 .= "createdon = '" . Escape(date('Y-m-d h:i:s')) . "',";

		if ($Qry1 != "") {
			$Qry1 = substr($Qry1, 0, strlen($Qry1) - 1);
			$qry = "UPDATE cms_collegemaster SET " . $Qry1 . " WHERE college_id = '" . $_SESSION["VedantnrCollegeId"] . "' ";
			dbQuery($qry);
		}
	}

	function delete()
	{
		$qry = "DELETE FROM cms_collegemaster where college_id='" . $_SESSION["VedantnrCollegeId"] . "'";
		dbQuery($qry);
	}

	function updatePhoto()
	{
		$qry = "
				UPDATE 
					cms_collegemaster 
				SET 
					college_logo = '" . $this->college_logo . "' 
				WHERE 
					college_id = " . $this->college_id;
		dbQuery($qry);
	}
}
?>