<?php
class cms_semester_setupMgmt
{
	public $semester_setup_id;
	public $semester_id;
	public $college_id;
	public $term_month;
	public $year_id;
	public $login_id;
	public $createdon;


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

		$qry = "SELECT 
						ss.*,
						sm.semester_name 
					FROM 
						cms_semester_setup ss,
						cms_semestermaster sm
					WHERE 
						ss.semester_id = sm.semester_id 
						AND ss.college_id = " . $_SESSION['VedantnrCollegeId'];

		//$qry="SELECT * FROM cms_semester_setup";

		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()
	{
		$Qry1 = "";
		$Qry1 .= "semester_setup_id   ='" . Escape($this->semester_setup_id) . "',";
		$Qry1 .= "semester_id   ='" . Escape($this->semester_id) . "',";
		$Qry1 .= "college_id='" . Escape($_SESSION['VedantnrCollegeId']) . "',";
		$Qry1 .= "term_month   ='" . Escape($this->term_month) . "',";
		$Qry1 .= "year_id='" . Escape($this->year_id) . "',";
		$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_semester_setup set " . $Qry1 . " ";
			dbQuery($qry);
			$this->semester_setup_id = dbInsertedId();
		}

	}

	function edit()
	{
		$Qry1 = "";
		$Qry1 .= "semester_setup_id   ='" . Escape($this->semester_setup_id) . "',";
		$Qry1 .= "semester_id   ='" . Escape($this->semester_id) . "',";
		$Qry1 .= "college_id='" . Escape($_SESSION['VedantnrCollegeId']) . "',";
		$Qry1 .= "term_month   ='" . Escape($this->term_month) . "',";
		$Qry1 .= "year_id='" .Escape($this->year_id) . "',";
		$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_semester_setup set " . $Qry1 . " where  semester_setup_id=" . $this->semester_setup_id;
			dbQuery($qry);
		}

	}


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

	function getsemestersetup($term_month,$semester_name,$semester_setup_id)
	{

		$qry = "SELECT * FROM cms_semester_setup WHERE semester_id = '$semester_name' AND 
		term_month = '$term_month'  AND semester_setup_id != '$semester_setup_id' ";

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



}/* Code For EXTJS START \n{
xtype: 'textfield',
name: 'semester_setup_id',
id:'semester_setup_id',
allowBlank:false,
tabIndex:1,
labelSeparator:'',
fieldLabel :'semester_setup_id:',
width:100
},
{
xtype: 'textfield',
name: 'semester_id',
id:'semester_id',
allowBlank:false,
tabIndex:2,
labelSeparator:'',
fieldLabel :'semester_id:',
width:100
},
{
xtype: 'textfield',
name: 'college_id',
id:'college_id',
allowBlank:false,
tabIndex:3,
labelSeparator:'',
fieldLabel :'college_id:',
width:100
},
{
xtype: 'textfield',
name: 'term_month',
id:'term_month',
allowBlank:false,
tabIndex:4,
labelSeparator:'',
fieldLabel :'term_month:',
width:100
},
{
xtype: 'textfield',
name: 'year_id',
id:'year_id',
allowBlank:false,
tabIndex:5,
labelSeparator:'',
fieldLabel :'year_id:',
width:100
},
{
xtype: 'textfield',
name: 'login_id',
id:'login_id',
allowBlank:false,
tabIndex:6,
labelSeparator:'',
fieldLabel :'login_id:',
width:100
},
{
xtype: 'textfield',
name: 'createdon',
id:'createdon',
allowBlank:false,
tabIndex:7,
labelSeparator:'',
fieldLabel :'createdon:',
width:100
},
Code For EXTJS END */




/* Code For Save File START 


$objcms_semester_setupMgmt= new cms_semester_setupMgmt();
$objcms_semester_setupMgmt->semester_setup_id=$_POST['semester_setup_id'];
$objcms_semester_setupMgmt->semester_id=$_POST['semester_id'];
$objcms_semester_setupMgmt->college_id=$_POST['college_id'];
$objcms_semester_setupMgmt->term_month=$_POST['term_month'];
$objcms_semester_setupMgmt->year_id=$_POST['year_id'];
$objcms_semester_setupMgmt->login_id=$_POST['login_id'];
$objcms_semester_setupMgmt->createdon=$_POST['createdon'];
if($objcms_semester_setupMgmt->semester_setup_id == "0" ||  $objcms_semester_setupMgmt->semester_setup_id== ""){ 
$objcms_semester_setupMgmt->add(); 
} 
else{
if($_REQUEST[act] == "del")
 {$objcms_semester_setupMgmt->delete();
 }else
 {$objcms_semester_setupMgmt->edit();
}
echo'{"success":"true"}'; 
 }

Code For Save File END */

?>