<?php 
class CFieldInfo
{
	var $field_id;
	var $project_id;
	var $field_title;
	var $field_len;
	var $field_type;
	var $field_width;
	var $field_height;
	var $field_option;
	var $field_default;
	var $field_style;
	var $field_order;
	var $field_cols;
	var $is_query;
	var $field_desc;
};

class CModuleProjectFields extends CModuleBase
{
	function Init($project_id=0)
	{
		$sql = "select * from tb_project_fields where project_id=".$project_id." order by field_order";		
		$this->db->ExeQuerySql($sql);
	
		while($this->db->FetchRow())
		{			
			$field = new CFieldInfo();
			
			$field->field_id= $this->db->Get("field_id");
			$field->project_id= $this->db->Get("project_id");
			$field->field_title= $this->db->Get("field_title");
			$field->field_len= $this->db->Get("field_len");
			$field->field_type= $this->db->Get("field_type");
			$field->field_width= $this->db->Get("field_width");
			$field->field_height= $this->db->Get("field_height");
			$field->field_option= $this->db->Get("field_option");
			$field->field_default= $this->db->Get("field_default");
			$field->field_style= $this->db->Get("field_style");
			$field->field_order= $this->db->Get("field_order");
			$field->field_cols= $this->db->Get("field_cols");
			$field->is_query= $this->db->Get("is_query");
			$field->field_desc= $this->db->Get("field_desc");
			$this->modules[$this->GetSize()] = $field;
		} 
		$this->db->FreeResult();
	}
	
	function InitByIssueType($issue_type)
	{
		$sql = "select a.* from tb_project_fields a, tb_project_issue_type b where a.project_id=b.project_id and b.issue_type_id=".$issue_type." order by a.field_order";		
		//echo $sql;
		$this->db->ExeQuerySql($sql);
	
		while($this->db->FetchRow())
		{			
			$field = new CFieldInfo();
			
			$field->field_id= $this->db->Get("field_id");
			$field->project_id= $this->db->Get("project_id");
			$field->field_title= $this->db->Get("field_title");
			$field->field_len= $this->db->Get("field_len");
			$field->field_type= $this->db->Get("field_type");
			$field->field_width= $this->db->Get("field_width");
			$field->field_height= $this->db->Get("field_height");
			$field->field_option= $this->db->Get("field_option");
			$field->field_default= $this->db->Get("field_default");
			$field->field_style= $this->db->Get("field_style");
			$field->field_order= $this->db->Get("field_order");
			$field->field_cols= $this->db->Get("field_cols");
			$field->is_query= $this->db->Get("is_query");
			$field->field_desc= $this->db->Get("field_desc");
			$this->modules[$this->GetSize()] = $field;
		} 
		$this->db->FreeResult();
	}
	
	function InitModule($field_id)
	{
		$this->module = new CFieldInfo();
		$sql = "select * from tb_project_fields where field_id=".$field_id;		
		$this->db->ExeQuerySql($sql);
	
		if($this->db->FetchRow())
		{
			$this->module->field_id= $this->db->Get("field_id");
			$this->module->project_id= $this->db->Get("project_id");
			$this->module->field_title= $this->db->Get("field_title");
			$this->module->field_len= $this->db->Get("field_len");
			$this->module->field_type= $this->db->Get("field_type");
			$this->module->field_width= $this->db->Get("field_width");
			$this->module->field_height= $this->db->Get("field_height");
			$this->module->field_option= $this->db->Get("field_option");
			$this->module->field_default= $this->db->Get("field_default");
			$this->module->field_style= $this->db->Get("field_style");
			$this->module->field_order= $this->db->Get("field_order");
			$this->module->field_cols= $this->db->Get("field_cols");
			$this->module->is_query= $this->db->Get("is_query");
			$this->module->field_desc= $this->db->Get("field_desc");
		} 
		$this->db->FreeResult();
		
	}
};
?>
