<?php
class assign_subject_masterMgmt
{
	public $assign_id;
	public $employee_id;
	public $subject_id;
	public $login_id;
	public $createdon;


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

		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;
	}


	function add()
	{
		$Qry1 = "";
		//$Qry1 .= "assign_id   ='"  .Escape($this->assign_id)."',";
		$Qry1 .= "employee_id   ='" . Escape($this->employee_id) . "',";
		$Qry1 .= "subject_id   ='" . Escape($this->subject_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 assign_subject_master set " . $Qry1 . " ";
			dbQuery($qry);
			$this->assign_id = dbInsertedId();
		}

	}

	function edit()
	{
		$Qry1 = "";
		$Qry1 .= "assign_id   ='" . Escape($this->assign_id) . "',";
		$Qry1 .= "employee_id   ='" . Escape($this->employee_id) . "',";
		$Qry1 .= "subject_id   ='" . Escape($this->subject_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 assign_subject_master set " . $Qry1 . " where  assign_id=" . $this->assign_id;
			dbQuery($qry);
		}

	}


	function delete()
	{
		$qry = "delete from assign_subject_master where assign_id in (" . $this->assign_id . ") ";
		dbQuery($qry);
	}
	function deleteAll($employee_id)
	{
		$qry = "delete from assign_subject_master where employee_id in (" . $employee_id . ") ";
		dbQuery($qry);
	}




}/* Code For EXTJS START \n{
xtype: 'textfield',
name: 'assign_id',
id:'assign_id',
allowBlank:false,
tabIndex:1,
labelSeparator:'',
fieldLabel :'assign_id:',
width:100
},
{
xtype: 'textfield',
name: 'employee_id',
id:'employee_id',
allowBlank:false,
tabIndex:2,
labelSeparator:'',
fieldLabel :'employee_id:',
width:100
},
{
xtype: 'textfield',
name: 'subject_id',
id:'subject_id',
allowBlank:false,
tabIndex:3,
labelSeparator:'',
fieldLabel :'subject_id:',
width:100
},
{
xtype: 'textfield',
name: 'login_id',
id:'login_id',
allowBlank:false,
tabIndex:4,
labelSeparator:'',
fieldLabel :'login_id:',
width:100
},
{
xtype: 'textfield',
name: 'createdon',
id:'createdon',
allowBlank:false,
tabIndex:5,
labelSeparator:'',
fieldLabel :'createdon:',
width:100
},
Code For EXTJS END */




/* Code For Save File START 


$objassign_subject_masterMgmt= new assign_subject_masterMgmt();
$objassign_subject_masterMgmt->assign_id=$_POST['assign_id'];
$objassign_subject_masterMgmt->employee_id=$_POST['employee_id'];
$objassign_subject_masterMgmt->subject_id=$_POST['subject_id'];
$objassign_subject_masterMgmt->login_id=$_POST['login_id'];
$objassign_subject_masterMgmt->createdon=$_POST['createdon'];
if($objassign_subject_masterMgmt->assign_id == "0" ||  $objassign_subject_masterMgmt->assign_id== ""){ 
$objassign_subject_masterMgmt->add(); 
} 
else{
if($_REQUEST[act] == "del")
 {$objassign_subject_masterMgmt->delete();
 }else
 {$objassign_subject_masterMgmt->edit();
}
echo'{"success":"true"}'; 
 }

Code For Save File END */

?>