id = $context['id']; $this->status_table = $context['status_table']; $this->status_id = $context['status']; $this->department_id = $context['dept_id']; $this->sign_counter = 0; } public function set() { global $database; $id = $this->id; $status_id = $this->status_id; //$database->debug = true; $this->client_type = 1; if(!empty($id)) { $request = common_quotes::get_quotes_details($id); //bug::bug_array('',$request); $this->company_id = $request['client_id']; $this->client_id = $request['client_id']; $this->qid = $request['id']; $this->company_name = common_clients::get_client_name($request['client_id']); $this->primary_location_id = $request['primary_location_id']; $this->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->first_name = $request['first_name']; $this->last_name = $request['last_name']; $this->phone = $request['phone']; $this->email = $request['email']; $this->job_tag = $request['job_tag']; $this->job_number = $request['job_number']; $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->status = $request['dqstatus']; $this->jobtypes= unserialize($request['jobtype']); foreach($this->jobtypes as $k ) { $newk = explode('=>',$k); $this->$newk[0] = $newk[1]; $this->config{$newk[0]} = array("id"=> $id,"value"=> $newk[1], "input_name" => $newk[0], "name" => $newk[0],"rule" => ""); } } if($_POST['Submit'] == "Save") { $this->address = $this->address; $this->post_code = $this->post_code; $this->state = $this->state; $this->suburb = $this->suburb; $this->country = $this->country; $this->phone = $this->phone; $this->first_name = $_POST['first_name']; $this->last_name = $_POST['last_name']; $this->email = $_POST['email']; $this->client_id = $_POST['client_id']; $this->location_id = $_POST['location_id']; $this->primary_location_id = $this->primary_location_id; $this->job_number = $this->job_number; $this->job_tag = $this->job_tag; $this->description = $this->description; $this->job_type = $_POST['jobtype']; $this->company = $this->company; $this->sitesurvey_notes =$this->sitesurvey_notes; $this->qualification_notes =$this->qualification_notes; $this->production_notes =$this->production_notes; $this->management_notes =$this->management_notes; $this->finance_notes =$this->finance_notes; $this->visualmockup_notes =$this->visualmockup_notes; $this->flag =$this->flag; $this->status = $request['status']; 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->config['address'] = array("id"=> $id,"value"=> $this->address, "input_name" => "address", "name" => "Address","rule" => "required"); $this->config['post_code'] = array("id"=> $id,"value"=> $this->post_code, "input_name" => "post_code", "name" => "Post Code","rule" => "required|integer|exact_length[4]"); $this->config['state'] = array("id"=> $id,"value"=> $this->state, "input_name" => "state", "name" => "State","rule" => "required"); $this->config['suburb'] = array("id"=> $id,"value"=> $this->suburb, "input_name" => "suburb", "name" => "Suburb","rule" => "required"); $this->config['first_name'] = array("id"=> $id,"value"=> $this->first_name, "input_name" => "first_name", "name" => "First Name","rule" => "required"); $this->config['last_name'] = array("id"=> $id,"value"=> $this->last_name, "input_name" => "last_name", "name" => "Last Name","rule" => "required"); $this->config['phone'] = array("id"=> $id,"value"=> $this->phone, "input_name" => "phone", "name" => "Phone","rule" => "required"); $this->config['email'] = array("id"=> $id,"value"=> $this->email, "input_name" => "email", "name" => "Email","rule" => "valid_email"); $this->config['location_id'] = array("id"=> $id,"value"=> $this->location_id, "input_name" => "location_id", "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" => ""); $this->config['client_id'] = array("id"=> $id,"value"=> $this->client_id, "input_name" => "client_id", "name" => "Client","rule" => "required"); $this->config['status'] = array("id"=> $id,"value"=> $this->status, "input_name" => "status", "name" => "Status","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"; /*if(isset($_POST['Submit'])) { if($this->create_new_client == 1) { if($this->client_type == 1) $this->validation['new_company_name'] = validation::$static_function($this->config['new_company_name']); $this->validation['location_id'] = validation::initial($this->config['location_id']); } else { $this->validation['new_company_name'] = validation::initial($this->config['new_company_name']); $this->validation['client_id'] = validation::$static_function($this->config['client_id']); $this->validation['location_id'] = validation::$static_function($this->config['location_id']); } } else { $this->validation['new_company_name'] = validation::$static_function($this->config['new_company_name']); $this->validation['client_id'] = validation::$static_function($this->config['client_id']); $this->validation['location_id'] = validation::$static_function($this->config['location_id']); } */ $this->validation['job_number'] = validation::$static_function($this->config['job_number']); $this->validation['description'] = validation::$static_function($this->config['description']); $this->validation['client_id'] = validation::initial($this->config['client_id']); $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']); /* $this->validation['address'] = validation::$static_function($this->config['address']); $this->validation['post_code'] = validation::$static_function($this->config['post_code']); $this->validation['state'] = validation::$static_function($this->config['state']); $this->validation['suburb'] = validation::$static_function($this->config['suburb']); $this->validation['first_name'] = validation::$static_function($this->config['first_name']); $this->validation['last_name'] = validation::$static_function($this->config['last_name']); $this->validation['phone'] = validation::$static_function($this->config['phone']); $this->validation['email'] = validation::$static_function($this->config['email']); */ 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->validation['status'] = validation::$static_function($this->config['status']); $this->reasons = validation::formalise($this->validation); } public function view() { global $database; $id = $this->id; $qid = $this->qid; $flag = $this->flag; $status_table = $this->status_table; $status_id = $this->status; $department_id = $this->department_id; $location_id = $this->location_id; $primary_location_id = $this->primary_location_id; $client_id = $this->client_id; $qualification_notes = $this->qualification_notes; $company_name = $this->company_name; $job_number = $this->job_number; $company_id = $this->company_id; $address = $this->address; $suburb = $this->suburb; $state = $this->state; $post_code = $this->post_code; $job_name = $this->job_name; $description = $this->description; $description = nl2br( stripslashes( htmlentities( $description, ENT_QUOTES, 'UTF-8' ) ) ); $phone = $this->phone; $fax = $this->fax; $jobtypes=$this->jobtypes; foreach($jobtypes as $k ){ $newk = explode('=>',$k); $this->$newk[0] = $newk[1]; $config{$newk[0]} = array("id"=> $id,"value"=> $newk[1], "input_name" => $newk[0], "name" => $newk[0],"rule" => ""); } $options = array("class" => "medium"); ?>
Job Number :

Client :
Address: , , ,
Phone:
   
Description:  

"; $reasons .= trim($this->reasons); $qualification_notes = $this->qualification_notes; $sitesurvey_notes = $this->sitesurvey_notes; $visualmockup_notes = $this->visualmockup_notes; $flag = $this->flag; $job_tag = $this->job_tag; $status = explode(':',$_POST['status']); $department_id= $status[1]; $status_id= $status[2]; $submitter = $_SESSION['user']['id']; $current_date_time = date('Y-m-d G:i:s'); $jobtypes = $this->jobtypes; $sitesurvey = false; $visual = false; switch($status[0]){ case 1: //Action ID $notes = strlen(trim($qualification_notes)); if(!$notes){ $reasons .= 'Qualification Notes is required.
Click here to fill out appropriate Notes.'; } break; case 16: $notes = strlen(trim($sitesurvey_notes)); if(!$notes){ $reasons .= 'Site Survey Notes is required.
Click here to fill out appropriate Notes.'; } break; case 19: $notes = strlen(trim($visualmockup_notes)); if(!$notes){ $reasons .= 'Visual Art Mockup Notes is required.
Click here to fill out appropriate Notes.'; } break; } $check_reasons = strip_tags($reasons); $results = false; if($check_reasons == "") { $database->StartTrans(); if($status[2]==31 ) { //status=31, Deposit of Invoice Completed, triggers this quote to become a job //print_r($_POST); $action=2; //add to jobs table, this request is now a job!!! $sql =" INSERT INTO jobs (SELECT * FROM quotes WHERE id = '$qid') "; $database->query($sql); logs::submit_logs(array("table" => "jobs", "action_type" => 1,"foreign_id" => $qid, "description" => "Created")); //update request to tag it as job $update = " UPDATE quotes SET job_tag='1' WHERE id='$qid' "; $database->query($update); logs::submit_logs(array("table" => "quotes", "action_type" => 2,"foreign_id" => $qid, "description" => "Modified")); $sql=" UPDATE departments_quotes set action_id =2 where id='$quote_id' "; $database->query($sql); logs::submit_logs(array("table" => "departments_quotes", "action_type" => 2,"foreign_id" => $id, "description" => "Modified")); $sql = " INSERT INTO departments_jobs SET department_id='$department_id', job_id='$qid', `user_id` = '$submitter', status='$status_id', action_id='2', `date_submitted` = '$current_date_time' "; $database->query($sql); logs::submit_logs(array("table" => "departments_jobs", "action_type" => 1,"foreign_id" => $qid, "description" => "Created")); //============================= }else{ if($status[0] == 6){ $quote_id2 = $quote_id + 1; $sql=" UPDATE departments_quotes set action_id =1 where id='$quote_id' or id = '$quote_id2' "; }else{ $sql=" UPDATE departments_quotes set action_id =1 where id='$quote_id' "; } $database->query($sql); logs::submit_logs(array("table" => "departments_quotes", "action_type" => 2,"foreign_id" => $id, "description" => "Modified")); foreach($jobtypes as $k ){ $newk = explode('=>',$k); //echo $newk[0]; if($newk[0] == 'signtype_2'){ $sitesurvey = true; $department_id = 2; //Installation department (table department) $status_id = 9; //Pending Site Survey (table clients_requests_status } if($newk[0] == 'signtype_1'){ $visual = true; $department_id = 3; //Design department (table department) $status_id = 10; //Pending Visual Art Mockup (table clients_requests_status } //$this->$newk[0] = $newk[1]; //$config{$newk[0]} = array("id"=> $id,"value"=> $newk[1], "input_name" => $newk[0], "name" => $newk[0],"rule" => ""); } $sql = " INSERT INTO departments_quotes SET department_id='$department_id', quote_id='$qid', `user_id` = '$submitter', status='$status_id', `date_submitted` = '$current_date_time' "; $database->query($sql); $new_id = $database->insert_id(); if($sitesurvey && $flag==0){ /*$sql = " INSERT INTO departments_quotes SET department_id= '$department_id', quote_id='$qid', `user_id` = '$submitter', status='$status_id', `date_submitted` = '$current_date_time' "; $database->query($sql);*/ //update the flag $sql = " UPDATE quotes SET flag ='1' WHERE id = '$qid' "; $database->query($sql); logs::submit_logs(array("table" => "departments_quotes", "action_type" => 1,"foreign_id" => $qid, "description" => "Created")); logs::submit_logs(array("table" => "departments_quotes", "action_type" => 2,"foreign_id" => $qid, "description" => "Modified")); logs::submit_logs(array("table" => "quotes", "action_type" => 2,"foreign_id" => $qid, "description" => "Modified")); } } $results = $database->CompleteTrans(); } if(!$results) { confirmation::error_temp("Performing this task".$reasons,"Request","quote"); return false; } else { confirmation::Success_temp("Edit a Client Request","Request","quote"); return true; } } }