class form_job_installation { public $id; public $db_name; public $config; public $validation; public $reasons; public $suffix; public $data; public function __construct($context) { $this->id = $context['id']; $this->db_name = $context['db_name']; } public function set() { global $database; $id = $this->id; $db_name = $this->db_name; //get data $quote_id = common_quotes::get_quote_id($id); //$sql = "SELECT labours from quotes_labour where quote_id = '$id'"; //$datas = $database->getRow($sql); $datas_quote = common_labours::get_actual_labours($quote_id); $datas = common_labours::get_actual_install($quote_id); //bug::bug_array('',$datas); $array1=array(); $array2=array(); if(!empty($datas['labours'])){ //$this->data = json_encode(unserialize($datas['labours'])); $array1= unserialize($datas['labours']); } if(!empty($datas_quote['labours'])){ //$this->datas_quote = json_encode(unserialize($datas_quote['labours'])); $array2=unserialize($datas_quote['labours']); } if(!empty($array1) || !empty($array2)) { $data_merge = array_merge($array1,$array2); $this->data = json_encode($data_merge); } //get the labours if available if($_POST['Submit'] == "Save") { } $this->config['labour'] = array("id"=> $id,"value"=> $this->labour, "input_name" => "labour", "name" => "labour","rule" => "required"); $this->config['supplier'] = array("id"=> $id,"value"=> $this->supplier, "input_name" => "supplier", "name" => "Supplier","rule" => "required"); $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"); //self::run_validation(); } public function run_validation() { $id = $this->id; $static_function = (($_POST['Submit'] == "")) ? "initial" : "validate"; $this->validation['labour'] = validation::$static_function($this->config['labour']); $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->reasons = validation::formalise($this->validation); } public function form() { global $database; $data = $this->data; $datas_quote = $this->datas_quote; $id = $this->id; $results = common_labours::get_installation_labours_settings(); $config = $this->config; $validation = $this->validation; $ischild = common_jobs::get_parent_job_id($id); ?>