<?php
class cms_upload_filesMgmt
{
	public $upload_file_id;
	public $upload_id;
	public $title;
	public $active;
	public $login_id;
	public $createdon;


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

		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 .= "upload_file_id   ='" . Escape($this->upload_file_id) . "',";
		$Qry1 .= "upload_id   ='" . Escape($this->upload_id) . "',";
		$Qry1 .= "title   ='" . Escape($this->title) . "',";
		$Qry1 .= "active   ='" . Escape($this->active) . "',";
		$Qry1 .= "login_id   ='" . Escape($this->login_id) . "',";
		$Qry1 .= "createdon   ='" . Escape($this->createdon) . "',";
		if ($Qry1 != "") {
			$Qry1 = substr($Qry1, 0, strlen($Qry1) - 1);
			$qry = "insert into cms_upload_files set " . $Qry1 . " ";
			dbQuery($qry);
			$this->upload_file_id = dbInsertedId();
		}

	}

	function edit()
	{
		$Qry1 = "";
		$Qry1 .= "upload_file_id   ='" . Escape($this->upload_file_id) . "',";
		$Qry1 .= "upload_id   ='" . Escape($this->upload_id) . "',";
		$Qry1 .= "title   ='" . Escape($this->title) . "',";
		$Qry1 .= "active   ='" . Escape($this->active) . "',";
		$Qry1 .= "login_id   ='" . Escape($this->login_id) . "',";
		$Qry1 .= "createdon   ='" . Escape($this->createdon) . "',";
		if ($Qry1 != "") {
			$Qry1 = substr($Qry1, 0, strlen($Qry1) - 1);
			$qry = "update cms_upload_files set " . $Qry1 . " where  upload_file_id=" . $this->upload_file_id;
			dbQuery($qry);
		}

	}


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





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




/* Code For Save File START 


$objcms_upload_filesMgmt= new cms_upload_filesMgmt();
$objcms_upload_filesMgmt->upload_file_id=$_POST['upload_file_id'];
$objcms_upload_filesMgmt->upload_id=$_POST['upload_id'];
$objcms_upload_filesMgmt->title=$_POST['title'];
$objcms_upload_filesMgmt->active=$_POST['active'];
$objcms_upload_filesMgmt->login_id=$_POST['login_id'];
$objcms_upload_filesMgmt->createdon=$_POST['createdon'];
if($objcms_upload_filesMgmt->upload_file_id == "0" ||  $objcms_upload_filesMgmt->upload_file_id== ""){ 
$objcms_upload_filesMgmt->add(); 
} 
else{
if($_REQUEST[act] == "del")
 {$objcms_upload_filesMgmt->delete();
 }else
 {$objcms_upload_filesMgmt->edit();
}
echo'{"success":"true"}'; 
 }

Code For Save File END */

?>