<?php
class ResultMgmt
{
	public $result_id;
	public $college_id;
	public $year_id;
	public $branch_id;
	public $semester_id;
	public $exam_id;
	public $subject_id;
	public $student_id;
	public $test_type;
	public $obtain_mark;
	public $present;
	public $present_pr;
	public $obtain_marks_pr_ese;
	public $obtain_marks_pr_pa;
	public $result;
	public $login_id;
	public $createdon;

	public $setup_id;
	function add()
	{
		$Qry1 = "";
		$Qry1 .= "college_id='" . Escape($_SESSION['VedantnrCollegeId']) . "',";
		$Qry1 .= "year_id='" . Escape($this->year_id) . "',";
		$Qry1 .= "branch_id='" . Escape($this->branch_id) . "',";
		$Qry1 .= "semester_id='" . Escape($this->semester_id) . "',";
		$Qry1 .= "exam_id='" . Escape($this->exam_id) . "',";
		$Qry1 .= "subject_id='" . Escape($this->subject_id) . "',";
		$Qry1 .= "test_type='" . Escape($this->test_type) . "',";
		$Qry1 .= "student_id='" . Escape($this->student_id) . "',";
		$Qry1 .= "obtain_mark='" . Escape($this->obtain_mark) . "',";
		$Qry1 .= "present='" . Escape($this->present) . "',";
		$Qry1 .= "present_pr='" . Escape($this->present_pr) . "',";
		$Qry1 .= "obtain_marks_pr_ese='" . Escape($this->obtain_marks_pr_ese) . "',";
		$Qry1 .= "obtain_marks_pr_pa='" . Escape($this->obtain_marks_pr_pa) . "',";
		$Qry1 .= "result='" . Escape($this->result) . "',";
		$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_resultmaster set " . $Qry1 . " ";
			dbQuery($qry);
			$this->result_id = dbInsertedId();
		}
	}

	function edit()
	{
		$Qry1 = "";
		$Qry1 .= "branch_id='" . Escape($this->branch_id) . "',";
		$Qry1 .= "semester_id='" . Escape($this->semester_id) . "',";
		$Qry1 .= "exam_id='" . Escape($this->exam_id) . "',";
		$Qry1 .= "subject_id='" . Escape($this->subject_id) . "',";
		$Qry1 .= "student_id='" . Escape($this->student_id) . "',";
		$Qry1 .= "test_type='" . Escape($this->test_type) . "',";
		$Qry1 .= "obtain_mark='" . Escape($this->obtain_mark) . "',";
		$Qry1 .= "present='" . Escape($this->present) . "',";
		$Qry1 .= "present_pr='" . Escape($this->present_pr) . "',";
		$Qry1 .= "obtain_marks_pr_ese='" . Escape($this->obtain_marks_pr_ese) . "',";
		$Qry1 .= "obtain_marks_pr_pa='" . Escape($this->obtain_marks_pr_pa) . "',";
		$Qry1 .= "result='" . Escape($this->result) . "',";
		$Qry1 .= "createdon='" . Escape(date('Y-m-d h:i:s')) . "',";

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

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

	function deleteresult($condition)
	{
		$qry = "delete from cms_resultmaster where 1=1";
		if ($condition!= "") {
            $qry.= $condition;
        }
		dbQuery($qry);
	}
}
?>