<?php
class RouteMgmt
{
	public $route_id;
	public $route_name;


	public $route_area;
	public $route_fees;


	function getAllRecords($limit = 0, $start = 0, $condition = "", $order_field = "", $order_type = "")
	{
		$qry = "";
		$qry = "SELECT * FROM cms_routemaster";

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

		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 addroute()
	{
		$Qry1 = "";
		$Qry1 .= "route_name='" . Escape($this->route_name) . "',";
		$Qry1 .= "route_area='" . Escape($this->route_area) . "',";
		$Qry1 .= "route_fees='" . Escape($this->route_fees) . "',";

		if ($Qry1 != "") {
			$Qry1 = substr($Qry1, 0, strlen($Qry1) - 1);
			$qry = "insert into cms_routemaster set " . $Qry1 . " ";
			//    echo $qry; exit;
			dbQuery($qry);
			$this->lec_id = dbInsertedId();
		}
	}

	function editroute()
	{
		$Qry1 = "";
		$Qry1 .= "route_name='" . Escape($this->route_name) . "',";
		$Qry1 .= "route_area='" . Escape($this->route_area) . "',";
		$Qry1 .= "route_fees='" . Escape($this->route_fees) . "',";

		if ($Qry1 != "") {
			$Qry1 = substr($Qry1, 0, strlen($Qry1) - 1);
			$qry = "update cms_routemaster set " . $Qry1 . " where route_id=" . $this->route_id;
			dbQuery($qry);
		}
	}

	function deleteroute()
	{
		$qry = "delete from cms_routemaster where route_id in (" . $this->route_id . ") ";
		dbQuery($qry);
	}


	function addtime()
	{
		$Qry1 = "";
		$Qry1 .= "time_start_name='" . Escape($this->time_start_name) . "',";
		$Qry1 .= "time_end_name='" . Escape($this->time_end_name) . "',";
		$Qry1 .= "lec_id='" . Escape($this->lec_id) . "',";

		if ($Qry1 != "") {
			$Qry1 = substr($Qry1, 0, strlen($Qry1) - 1);
			$qry = "insert into cms_timemaster set " . $Qry1 . " ";
			dbQuery($qry);
			$this->time_id = dbInsertedId();
		}
	}
	function edittime()
	{
		$Qry1 = "";
		$Qry1 .= "time_start_name='" . Escape($this->time_start_name) . "',";
		$Qry1 .= "time_end_name='" . Escape($this->time_end_name) . "',";
		$Qry1 .= "lec_id='" . Escape($this->lec_id) . "',";
		if ($Qry1 != "") {
			$Qry1 = substr($Qry1, 0, strlen($Qry1) - 1);
			$qry = "update cms_timemaster set " . $Qry1 . " where time_id=" . $this->time_id;
			dbQuery($qry);
		}
	}

	function deletetime()
	{
		$qry = "delete from cms_timemaster where time_id in (" . $this->time_id . ") ";
		dbQuery($qry);
	}
	function addroom()
	{
		$Qry1 = "";
		$Qry1 .= "room_name='" . Escape($this->room_name) . "',";

		if ($Qry1 != "") {
			$Qry1 = substr($Qry1, 0, strlen($Qry1) - 1);
			$qry = "insert into cms_roommaster set " . $Qry1 . " ";
			dbQuery($qry);
			$this->room_id = dbInsertedId();
		}
	}
	function editroom()
	{
		$Qry1 = "";
		$Qry1 .= "room_name='" . Escape($this->room_name) . "',";

		if ($Qry1 != "") {
			$Qry1 = substr($Qry1, 0, strlen($Qry1) - 1);
			$qry = "update cms_roommaster set " . $Qry1 . " where room_id=" . $this->room_id;
			dbQuery($qry);
		}
	}

	function deleteroom()
	{
		$qry = "delete from cms_roommaster where room_id in (" . $this->room_id . ") ";
		dbQuery($qry);
	}

	function addsmesterallocate()
	{
		$Qry1 = "";
		$Qry1 .= "branch_id='" . Escape($this->branch_id) . "',";
		$Qry1 .= "semester_id='" . Escape($this->semester_id) . "',";
		$Qry1 .= "div_id='" . Escape($this->div_id) . "',";
		$Qry1 .= "lec_id='" . Escape($this->lec_id) . "',";
		$Qry1 .= "time_start_name='" . Escape($this->time_start_name) . "',";
		$Qry1 .= "time_end_name='" . Escape($this->time_end_name) . "',";

		if ($Qry1 != "") {
			$Qry1 = substr($Qry1, 0, strlen($Qry1) - 1);
			$qry = "insert into cms_semester_allocate_time set " . $Qry1 . " ";
			dbQuery($qry);
			$this->room_id = dbInsertedId();
		}

	}
	function editsmesterallocate()
	{
		$Qry1 = "";
		$Qry1 .= "branch_id='" . Escape($this->branch_id) . "',";
		$Qry1 .= "semester_id='" . Escape($this->semester_id) . "',";
		$Qry1 .= "div_id='" . Escape($this->div_id) . "',";
		$Qry1 .= "lec_id='" . Escape($this->lec_id) . "',";
		$Qry1 .= "time_start_name='" . Escape($this->time_start_name) . "',";
		$Qry1 .= "time_end_name='" . Escape($this->time_end_name) . "',";


		if ($Qry1 != "") {
			$Qry1 = substr($Qry1, 0, strlen($Qry1) - 1);
			$qry = "update cms_semester_allocate_time set " . $Qry1 . " where semester_allocate_time_id=" . $this->semester_allocate_time_id;
			dbQuery($qry);
		}
	}

	function deletesmesterallocate()
	{
		$qry = "delete from cms_semester_allocate_time where semester_allocate_time_id in (" . $this->semester_allocate_time_id . ") ";
		dbQuery($qry);
	}

}
?>