<?php 
class CActionConfigFields extends CActionBase
{
	function doAction()
	{
		$ret = 0;
		$job = $_POST["job"];
		switch($job)
		{
			case "add":
				$ret = $this->Add();
			break;
			case "mod":
				$ret = $this->Mod();
			break;
			case "del":
				$ret = $this->Del();
			break;
		}
		
		return $ret;
	}	
	
	function Add()
	{
		$field_id=$this->db->GetMaxField('tb_project_fields', 'field_id')+1;;
		$project_id=$_POST["project_id"];
		$field_title=$_POST["field_title"];
		$field_len=$_POST["field_len"];
		$field_type=$_POST["field_type"];
		$field_width=$_POST["field_width"];
		$field_height=$_POST["field_height"];
		$field_option=$_POST["field_option"];
		$field_default=$_POST["field_default"];
		$field_style=$_POST["field_style"];
		$field_order=$_POST["field_order"];
		$field_cols=$_POST["field_cols"];
		$is_query=$_POST["is_query"];
		$field_desc=$_POST["field_desc"];

		$sql = "insert into tb_project_fields (field_id,project_id,field_title,";
		$sql = $sql . "field_len,field_type,field_width,field_height,";
		$sql = $sql . "field_option,field_default,field_style,field_order,";
		$sql = $sql . "field_cols,is_query,field_desc) values (";
		$sql = $sql . $field_id . ",";
		$sql = $sql . $project_id . ",";
		$sql = $sql . "'" .$field_title . "',";
		$sql = $sql . $field_len . ",";
		$sql = $sql . $field_type . ",";
		$sql = $sql . $field_width . ",";
		$sql = $sql . $field_height . ",";
		$sql = $sql . "'".$field_option."',";
		$sql = $sql . "'".$field_default."',";
		$sql = $sql . "'".$field_style."',";
		$sql = $sql . $field_order . ",";
		$sql = $sql . $field_cols . ",";
		$sql = $sql . $is_query . ",";
		$sql = $sql . "'".$field_desc."'";
		$sql = $sql . ")";
		
		$this->db->ExeSql($sql);
		
		return 0;
	}
	
	function Mod()
	{
		$field_id=$_POST["field_id"];
		$field_title=$_POST["field_title"];
		$field_len=$_POST["field_len"];
		$field_type=$_POST["field_type"];
		$field_width=$_POST["field_width"];
		$field_height=$_POST["field_height"];
		$field_option=$_POST["field_option"];
		$field_default=$_POST["field_default"];
		$field_style=$_POST["field_style"];
		$field_order=$_POST["field_order"];
		$field_cols=$_POST["field_cols"];
		$is_query=$_POST["is_query"];
		$field_desc=$_POST["field_desc"];
		
		$sql = "update tb_project_fields set ";
		$sql = $sql . "field_title='".$field_title . "',";
		$sql = $sql . "field_len=".$field_len . ",";
		$sql = $sql . "field_type=".$field_type . ",";
		$sql = $sql . "field_width=".$field_width . ",";
		$sql = $sql . "field_height=".$field_height . ",";
		$sql = $sql . "field_option='".$field_option . "',";
		$sql = $sql . "field_default='".$field_default . "',";
		$sql = $sql . "field_style='".$field_style . "',";
		$sql = $sql . "field_order=".$field_order . ",";
		$sql = $sql . "field_cols=".$field_cols . ",";
		$sql = $sql . "is_query=".$is_query . ",";
		$sql = $sql . "field_desc='".$field_desc . "' ";
		$sql = $sql . " where field_id=".$field_id;
		$this->db->ExeSql($sql);
		
		return 0;
	}
	
	function Del()
	{
		$field_id = $_POST["field_id"];
		$sql = "delete from tb_project_fields where field_id=".$field_id;
		$this->db->ExeSql($sql);
		
		return 0;
	}
	
};
?>
