class form_quote_generate
{
public $id;
public $config;
public $validation;
public $reasons;
public $sign_counter;
public $department;
public $status_table;
public $status_id;
public function __construct($context)
{
$this->id = $context['id'];
$this->status_table = $context['status_table'];
$this->status_id = $context['status'];
$this->department_id = $context['department_id'];
$this->sign_counter = 0;
}
public function set()
{
global $database;
$id = $this->id;
//$database->debug = true;
$this->client_type = 1;
if(!empty($id))
{
// $client = common_ref_client::get_client($id);
//$this->suggestion = $client['suggestion'];
//$this->description = $client['description'];
$request = common_jobs::get_jobs_details($id);
$this->company_id = $request['client_id'];
$this->primary_location_id = $request['primary_location_id'];
$location_details = common_ref_client::get_client_location($this->primary_location_id);
$this->address = $location_details['address'];
$this->suburb = $location_details['suburb'];
$this->state = $location_details['state'];
$this->post_code = $location_details['post_code'];
$this->phone = $request['phone'];
//print_r($client);
//print_r($request);
$this->job_number = $request['job_number'];
$this->company = $request['company_name'];
$this->address = $request['address'];
$this->job_name = $request['job_name'];
$this->description = $request['description'];
$this->phone = $request['phone'];
$this->sitesurvey_notes = $request['sitesurvey_notes'];
$this->qualification_notes = $request['qualification_notes'];
$this->production_notes = $request['production_notes'];
$this->management_notes = $request['management_notes'];
$this->finance_notes = $request['finance_notes'];
$this->visualmockup_notes = $request['visualmockup_notes'];
$this->flag = $request['flag'];
/*$this->jobtypes = explode(",",$request['jobtype']);
//print_r($this->jobtypes);
foreach($this->jobtypes as $k => $val){
//echo $new= split('_',$val);
//$this->jobid[]= $new[1];
//echo $val;
if (preg_match("/jobtype/i", $val)) {
echo $val;
//$this->$val = 'yes';
$this->config{$val} = array("id"=> $id,"value"=> $pp, "input_name" => $val, "name" => $val,"rule" => "");
}
if (preg_match("/signtype/i", $val)) {
echo $val;
//$this->$val = '1';
$this->config{$val} = array("id"=> $id,"value"=> $pp, "input_name" => $val, "name" => $val,"rule" => "");
}
}
*/
$this->jobtypes= unserialize($request['jobtype']);
foreach($this->jobtypes as $k ){
//foreach( $k as $j => $l){
//echo $l .'
' ;
//}
//echo $k.'
';
$newk = explode('=>',$k);
//$newk[0] = $newk[1];
$this->$newk[0] = $newk[1];
$this->config{$newk[0]} = array("id"=> $id,"value"=> $newk[1], "input_name" => $newk[0], "name" => $newk[0],"rule" => "");
}
//print_r($this->jobtypes);
}
if($_POST['Submit'] == "Save")
{
//$this->client_type = $_POST['client_type'];
$this->company_name = $_POST['company_name'];
$this->company_id = $_POST['company_id'];
$this->address = $_POST['address'];
$this->job_number = $_POST['job_number'];
$this->description = $_POST['description'];
$this->job_type = $_POST['jobtype'];
$this->company = $_POST['company'];
$this->sitesurvey_notes =$_POST['sitesurvey_notes'];
$this->qualification_notes =$_POST['qualification_notes'];
$this->production_notes =$_POST['production_notes'];
$this->management_notes =$_POST['management_notes'];
$this->finance_notes =$_POST['finance_notes'];
$this->visualmockup_notes =$_POST['visualmockup_notes'];
$this->flag =$_POST['flag'];
foreach($_POST as $post => $pp){
if (preg_match("/jobtype/i", $post)) {
//echo $post;
$this->$post = $pp;
}
}
foreach($_POST as $sign => $ss){
if (preg_match("/signtype/i", $sign)) {
//echo $post;
$this->$sign = $ss;
}
}
if($this->sign_counter > 0){
$this->reasons .= "Required at least one";
}
//$this->suggestion = $_POST['suggestion'];
//$this->description = $_POST['description'];
}
$this->config['company_name'] = array("id"=> $id,"value"=> $this->company_name, "input_name" => "company_name", "name" => "Company Name","rule" => "");
$this->config['company'] = array("id"=> $id,"value"=> $this->company, "input_name" => "company", "name" => "Company Name","rule" => "required");
$this->config['company_id'] = array("id"=> $id,"value"=> $this->company_id, "input_name" => "company_id", "name" => "Company ID","rule" => "");
$this->config['address'] = array("id"=> $id,"value"=> $this->address, "input_name" => "address", "name" => "Address","rule" => "required");
$this->config['job_number'] = array("id"=> $id,"value"=> $this->job_number, "input_name" => "job_number", "name" => "Job Number","rule" => "required");
$this->config['description'] = array("id"=> $id,"value"=> $this->description, "input_name" => "description", "name" => "Description","rule" => "required");
$this->config['jobtype_id'] = array("id"=> $id,"value"=> $this->jobtype_id, "input_name" => "jobtype_id", "name" => "Job Type ID","rule" => "");
$this->config['sitesurvey_notes'] = array("id"=> $id,"value"=> $this->sitesurvey_notes, "input_name" => "sitesurvey_notes", "name" => "Site Survey Notes","rule" => "");
$this->config['qualification_notes'] = array("id"=> $id,"value"=> $this->qualification_notes, "input_name" => "qualification_notes", "name" => "Qualification Notes","rule" => "");
$this->config['production_notes'] = array("id"=> $id,"value"=> $this->production_notes, "input_name" => "production_notes", "name" => "Production Notes","rule" => "");
$this->config['management_notes'] = array("id"=> $id,"value"=> $this->management_notes, "input_name" => "management_notes", "name" => "Management Notes","rule" => "");
$this->config['finance_notes'] = array("id"=> $id,"value"=> $this->finance_notes, "input_name" => "finance_notes", "name" => "Finance Notes","rule" => "");
$this->config['visualmockup_notes'] = array("id"=> $id,"value"=> $this->visualmockup_notes, "input_name" => "visualmockup_notes", "name" => "Visual Art Mockup Notes","rule" => "");
foreach($_POST as $post => $pp){
if (preg_match("/jobtype/i", $post)) {
//echo $post;
$this->config{$post} = array("id"=> $id,"value"=> $pp, "input_name" => $post, "name" => $post,"rule" => "");
}
}
foreach($_POST as $sign => $ss){
if (preg_match("/signtype/i", $sign)) {
//echo $post;
$this->config{$sign} = array("id"=> $id,"value"=> $ss, "input_name" => $sign, "name" => $sign,"rule" => "required");
}
}
self::run_validation();
}
public function run_validation()
{
$static_function = (($_POST['Submit'] == "")) ? "initial" : "validate";
$this->validation['company_name'] = validation::$static_function($this->config['company_name']);
$this->validation['company'] = validation::$static_function($this->config['company']);
$this->validation['company_id'] = validation::$static_function($this->config['company_id']);
$this->validation['address'] = validation::$static_function($this->config['address']);
$this->validation['job_number'] = validation::$static_function($this->config['job_number']);
$this->validation['description'] = validation::$static_function($this->config['description']);
$this->validation['sitesurvey_notes'] = validation::$static_function($this->config['sitesurvey_notes']);
$this->validation['qualification_notes'] = validation::$static_function($this->config['qualification_notes']);
$this->validation['production_notes'] = validation::$static_function($this->config['production_notes']);
$this->validation['management_notes'] = validation::$static_function($this->config['management_notes']);
$this->validation['finance_notes'] = validation::$static_function($this->config['finance_notes']);
$this->validation['visualmockup_notes'] = validation::$static_function($this->config['visualmockup_notes']);
foreach($_POST as $post => $pp){
if (preg_match("/jobtype/i", $post)) {
//echo $post;
$this->validation{$post} = validation::$static_function($this->config{$post});
}
}
foreach($_POST as $sign => $ss){
if (preg_match("/signtype/i", $sign)) {
//echo $post;
$this->sign_counter++;
$this->validation{$sign} = validation::$static_function($this->config{$sign});
}
}
$this->validation['jobtype_id'] = validation::$static_function($this->config['jobtype_id']);
$this->reasons = validation::formalise($this->validation);
}
public function form(){
global $database;
$id = $this->id;
$status_table = $this->status_table;
$status_id = $this->status_id;
$department_id = $this->department_id;
$flag = $this->flag;
$company = $this->company;
$job_number = $this->job_number;
$company_id = $this->company_id;
$address = $this->address;
$job_name = $this->job_name;
$description = $this->description;
$phone = $this->phone;
$fax = $this->fax;
$jobtypes=$this->jobtypes;
//print_r( $jobtypes);
foreach($jobtypes as $k ){
//foreach( $k as $j => $l){
//echo $l .'
' ;
//}
//echo $k.'
';
$newk = explode('=>',$k);
//$newk[0] = $newk[1];
$this->$newk[0] = $newk[1];
$config{$newk[0]} = array("id"=> $id,"value"=> $newk[1], "input_name" => $newk[0], "name" => $newk[0],"rule" => "");
}
?>