id = $context['id']; $this->form_type = $context['form_type']; } public function set() { global $database; $id = $this->id; $this->state = $_SESSION['settings']['default_state']; if(!empty($id)) { $client = common_ref_client::get_client($id); $this->company_name = $client['company_name']; $this->client_type = $client['client_type']; $this->primary_location_id = $client['primary_location_id']; $this->primary_contact_id = $client['primary_contact_id']; $primary_location_id = $client['primary_location_id']; $primary_contact_id = $client['primary_contact_id']; $primary_location = common_ref_client::get_client_location($primary_location_id); $this->address = $primary_location['address']; $this->post_code = $primary_location['post_code']; $this->state = $primary_location['state']; $this->suburb = $primary_location['suburb']; $this->country = $primary_location['country']; $this->phone = $primary_location['business_phone']; $this->fax = $primary_location['fax']; $this->alt_contact = $primary_location['alt_contact']; $this->alt_phone = $primary_location['alt_phone']; $primary_contact = common_ref_client::get_contact($primary_contact_id); $this->job_title = $primary_contact['job_title']; $this->title = $primary_contact['title']; $this->first_name = $primary_contact['first_name']; $this->last_name = $primary_contact['last_name']; $this->mobile_phone = $primary_contact['mobile_phone']; $this->email = $primary_contact['email']; } if($_POST['Submit'] == "Save") { $this->company_name = $_POST['company_name']; $this->fax = $_POST['fax']; $this->job_title = $_POST['job_title']; $this->mobile_phone = $_POST['mobile_phone']; $this->alt_contact = $_POST['alt_contact']; $this->alt_phone = $_POST['alt_phone']; $this->address = $_POST['address']; $this->post_code = $_POST['post_code']; $this->state = $_POST['state']; $this->suburb = $_POST['suburb']; $this->phone = $_POST['phone']; $this->title = $_POST['title']; $this->first_name = $_POST['first_name']; $this->last_name = $_POST['last_name']; $this->email = $_POST['email']; } $this->config['fax'] = array("id"=> $id,"value"=> $this->fax, "input_name" => "fax", "name" => "Fax","rule" => ""); $this->config['job_title'] = array("id"=> $id,"value"=> $this->job_title, "input_name" => "job_title", "name" => "Job Title","rule" => ""); $this->config['mobile_phone'] = array("id"=> $id,"value"=> $this->mobile_phone, "input_name" => "mobile_phone", "name" => "Mobile Phone","rule" => ""); $this->config['alt_contact'] = array("id"=> $id,"value"=> $this->alt_contact, "input_name" => "alt_contact", "name" => "Alternate Contact","rule" => ""); $this->config['alt_phone'] = array("id"=> $id,"value"=> $this->alt_phone, "input_name" => "alt_phone", "name" => "Alternate Phone","rule" => ""); $this->config['company_name'] = array("id"=> $id,"value"=> $this->company_name, "input_name" => "company_name", "name" => "Company Name","rule" => "required|company_name"); $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['phone'] = array("id"=> $id,"value"=> $this->phone, "input_name" => "phone", "name" => "Phone","rule" => "required"); $this->config['title'] = array("id"=> $id,"value"=> $this->title, "input_name" => "title", "name" => "Title","rule" => ""); $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['email'] = array("id"=> $id,"value"=> $this->email, "input_name" => "email", "name" => "Email","rule" => ""); 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['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['phone'] = validation::$static_function($this->config['phone']); $this->validation['fax'] = validation::$static_function($this->config['fax']); $this->validation['title'] = validation::$static_function($this->config['title']); $this->validation['first_name'] = validation::$static_function($this->config['first_name']); $this->validation['last_name'] = validation::$static_function($this->config['last_name']); $this->validation['email'] = validation::$static_function($this->config['email']); $this->validation['job_title'] = validation::$static_function($this->config['job_title']); $this->validation['mobile_phone'] = validation::$static_function($this->config['mobile_phone']); $this->validation['alt_contact'] = validation::$static_function($this->config['alt_contact']); $this->validation['alt_phone'] = validation::$static_function($this->config['alt_phone']); $this->reasons = validation::formalise($this->validation); } public function form() { global $database; $id = $this->id; $form_type = $this->form_type; $config = $this->config; $validation = $this->validation; $options = array("class" => "medium"); $options_select = array("class" => "medium form"); $table_class = (empty($form_type)) ? "tab_form" : ""; $client_type = $this->client_type; ?>
Client Name :