id = $context['id']; $this->quote_id = $context['quote_id']; $this->db_name = $context['db_name']; } public function set() { global $database; //$suffix="1"; //print $suffix; $id = $this->id; $db_name = $this->db_name; if(!empty($id)) { $results = common_materials::get_quote_materials_by_id($id); //bug::bug_array("results",$results); $this->id = $results['id']; $this->quote_id = $results['quote_id']; $this->item = $results['item']; $this->materials = stripslashes($results['materials']); $this->supplier = stripslashes($results['supplier']); $this->quantity = $results['quantity']; $this->price = $results['price']; $this->total = $results['total']; $this->material_no = $results['material_no']; } if($_POST['Submit'] == "Save") { $this->quote_id = $this->quote_id; $this->item = mysql_real_escape_string($_POST['item']); $this->materials = mysql_real_escape_string($_POST['materials']); $this->supplier = mysql_real_escape_string($_POST['supplier']); $this->quantity = mysql_real_escape_string($_POST['quantity']); $this->price = mysql_real_escape_string($_POST['price']); $this->total = mysql_real_escape_string($_POST['total']); } $this->config['item'] = array("id"=> $id,"value"=> $this->item, "input_name" => "item", "name" => "Item","rule" => "required|alpha_numeric"); $this->config['materials'] = array("id"=> $id,"value"=> $this->materials, "input_name" => "materials", "name" => "Materials","rule" => "required"); $this->config['supplier'] = array("id"=> $id,"value"=> $this->supplier, "input_name" => "supplier", "name" => "Supplier","rule" => ""); $this->config['quantity'] = array("id"=> $id,"value"=> $this->quantity, "input_name" => "quantity", "name" => "Quantity","rule" => "required|numeric"); $this->config['price'] = array("id"=> $id,"value"=> $this->price, "input_name" => "price", "name" => "Price","rule" => "required|numeric"); $this->config['total'] = array("id"=> $id,"value"=> $this->total, "input_name" => "total", "name" => "Total","rule" => "required|numeric"); $this->config['id'] = array("id"=> $id,"value"=> $this->material_no, "input_name" => "id", "name" => "Material","rule" => "not_zero"); self::run_validation(); } public function run_validation() { $id = $this->id; $static_function = (($_POST['Submit'] == "")) ? "initial" : "validate"; $this->validation['item'] = validation::$static_function($this->config['item']); $this->validation['materials'] = validation::$static_function($this->config['materials']); $this->validation['supplier'] = validation::$static_function($this->config['supplier']); $this->validation['quantity'] = validation::$static_function($this->config['quantity']); $this->validation['price'] = validation::$static_function($this->config['price']); $this->validation['total'] = validation::$static_function($this->config['total']); $this->validation['id'] = validation::$static_function($this->config['id']); $this->reasons = validation::formalise($this->validation); } public function form() { global $database; $id = $this->id; $config = $this->config; $validation = $this->validation; $text_options = array("class" => "medium"); $text_options_small = array("class" => "small"); $text_area_options = array("class" => "medium"); $select_options = array("class" => "medium form"); $text_options_small_readonly['class'] = "small"; $text_options_small_readonly['attr'] = "readonly"; ?>
Code Material Description Supplier Quantity Price Total