class form_materials { public $id; public $db_name; public $config; public $validation; public $reasons; public $materials; public $supplier; public $quantity; public $price; public $total; public $suffix; public function __construct($context = array()) { $this->id = $context['id']; $this->db_name = $context['db_name']; } public function set() { global $database; $id = $this->id; $db_name = $this->db_name; if(!empty($id)) { /*$get_material = " SELECT * FROM $db_name"."quotes_material WHERE id = '$id' LIMIT 1 "; $results = $database->getRow($get_material);*/ $results = common_materials::get_quote_materials_by_id($id); $this->id = $results['id']; $this->materials = $results['item']; $this->materials = $results['materials']; $this->supplier = $results['supplier']; $this->quantity = $results['quantity']; $this->price = $results['price']; $this->total = $results['total']; } if($_POST['Submit'] == "Save") { foreach($_POST AS $name => $value) { $splitter = explode("_",$name); $post_name = $splitter[0]; $suffix = $splitter[1]; if($post_name == "materials") { $this->item = mysql_real_escape_string($_POST['item_'.$suffix]); $this->materials = mysql_real_escape_string($_POST['materials_'.$suffix]); $this->supplier = mysql_real_escape_string($_POST['supplier_'.$suffix]); $this->quantity = mysql_real_escape_string($_POST['quantity_'.$suffix]); $this->price = mysql_real_escape_string($_POST['price_'.$suffix]); $this->total = mysql_real_escape_string($_POST['total_'.$suffix]); $this->material_no = mysql_real_escape_string($_POST['id_'.$suffix]); } } } $this->config['item'] = array("id"=> $id,"value"=> $this->item, "input_name" => "item", "name" => "Item","rule" => ""); $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['material_no'] = array("id"=> $id,"value"=> $this->material_no, "input_name" => "id", "name" => "Material","rule" => ""); 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['material_no'] = validation::$static_function($this->config['material_no']); $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"; /** Kai 07/11/2012*/ /** disable costing changes fater quote approved, only admin level user to update*/ $display_info = false; $group_id = $_SESSION['user']['group_id']; $admin_groups = array(31,42); if(in_array($group_id, $admin_groups)){ $display_info = false; }else{ $get_job_details = "SELECT * FROM jobs WHERE status <>53 AND quote_id =".$this->id; $job_details = $database->getAll($get_job_details); /** Kai 15/11/2012*/ if(empty($job_details)){ $display_info=false; }else{ // /** this query is to get job with id and direction states that Decision will go to Production in order to make sure that quote can be edit before production*/ // $get_job_decisions = "SELECT * FROM project_workflow WHERE foreign_id = ".$job_details[0]['id']." AND project_workflow.table = 'jobs' AND direction = 'yes'"; // $job_decisions = $database->getAll($get_job_decisions); // /** this array includes workflow ids that leds to the productions, which means after this stage, quote is not able to edit*/ // $decisions = array(35,373,419,433); // if(!empty($job_decisions)){ // /** no more edit after decisions above have been decided*/ // foreach($job_decisions as $jd){ // if(in_array($jd['workflow_id'],$decisions)) // $display_info = true; // } // }else{ // $display_info = false; // } /** Kai 22/11/2012*/ $get_current_job_tasks = " SELECT project_tasks.*,project_workflow.table,project_workflow.foreign_id FROM project_tasks, project_workflow WHERE project_tasks.project_workflow_id = project_workflow.id AND project_tasks.status=0 AND project_workflow.foreign_id=".$job_details[0]['id']." AND project_workflow.table = 'jobs' "; $current_job_tasks = $database->getRow($get_current_job_tasks); if(in_array($current_job_tasks['workflow_task_id'],array(36,594,699,751))){ $display_info = true; //bug::bug_array('current workflow_task_id',$current_job_tasks['workflow_task_id']); }else{ $get_finished_job_tasks = " SELECT project_tasks.*,project_workflow.table,project_workflow.foreign_id FROM project_tasks, project_workflow WHERE project_tasks.project_workflow_id = project_workflow.id AND project_tasks.status=1 AND project_workflow.foreign_id=".$job_details[0]['id']." AND project_workflow.table = 'jobs' "; $finished_job_tasks = $database->getAll($get_finished_job_tasks); foreach($finished_job_tasks as $tasks){ if(in_array($tasks['workflow_task_id'],array(36,594,699,751))){ $display_info = true; //bug::bug_array('finished workflow_task_id',$current_job_tasks['workflow_task_id']); } } } //bug::bug_array('Finished job tasks',$current_job_tasks); /** Changes end, Kai 22/11/2012*/ } } ?>
Code | Material Description | Supplier | Quantity | Total Available | Price | Total | Not Inventory | |
Add Material![]() |