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); ?>
'; foreach($results as $rs){ //1st $labour = $rs['labour_name']; $units = $rs['units']; $rate = $rs['rate']; $id = $rs['id']; $pid = $rs['parent_id']; $fieldtype = $rs['fieldtype']; $validation['input_name'] = str_replace('/','-',str_replace(' ','_',$labour)).'_labour' ; //$config['value'] =''; //$options['class'] = "labourclass"; //$options['attr'] = 'readonly'; //$options['style'] = 'width:70px; readonly:readonly'; $options_large = array("class" => "large"); if($rate == 0)$rate=''; ?> getAll($sql1); $subresults = common_production_department::get_active_departments(); bug::bug_array('',$subresults); foreach($subresults as $subs){ //2nd foreach $slabour = $subs['department_name']; $sid = $subs['id']; //production department ?> 0){ foreach($subresults2 as $subs2){ //3rd foreach $slabour2 = $subs2['labour_name']; $sunits2 = $subs2['units']; $srate2 = $subs2['rate']; $sid2 = $subs2['id']; $sfieldtype = $subs2['fieldtype']; ?> getAll($sql3); $subresults3 = common_labours::get_labours_settings($id); //bug::bug_array('',$subresults3); foreach($subresults3 as $sub3){ $l_name=$sub3['labour_name']; $d_rate=$sub3['rate']; $f_type=$sub3['fieldtype']; $i_id=$sub3['id']; ?>
Labour Estimated Cost Actual
"readonly") ; } $validation['input_name'] = str_replace('/','-',str_replace(' ','_',$labour)).'_actual' ; $validation['input_name'] ='install_estimated_51'; $config['value'] = common_jobs::get_job_installation_estimated(51,$this->id); echo '$'.forms::input_text($config,$validation,$options,true); //}?> $ "readonly") ; } $validation['input_name'] ='install_actual_51'; $config['value'] = common_jobs::get_job_installation_actual(51,$this->id); echo forms::input_text($config,$validation,$options,true); //} ?>
getAll($sql2); $subresults2 = common_production_department::get_active_subdepartments($sid); ?>  
$ id); $validation['input_name'] = str_replace('/','-',str_replace(' ','_',$l_name)).'_labour_'.$i_id ; $validation['input_name']='install_estimated_'.$i_id.'_'.str_replace('/','-',str_replace(' ','',$l_name)); $options['style'] = 'width:70px;'; if($type=='estimated') { $options['attr'] = '' ; } else { $options['attr'] = array("readonly"=>"readonly") ; } echo forms::input_text($config,$validation,$options,true);?> $ id); if($f_type=="input_rate"){ $options['class'] = "labourclass"; if($type=='actual') { $options['attr'] = '' ; } else { $options['attr'] = array("readonly"=>"readonly") ; } $options['style'] = 'width:70px;'; $validation['input_name'] = str_replace('/','-',str_replace(' ','_',$l_name)).'_actual_'.$i_id ; $validation['input_name']='install_actual_'.$i_id.'_'.str_replace('/','-',str_replace(' ','',$l_name)); echo forms::input_text($config,$validation,$options,true); }?>