id = $context['id']; } public function set() { global $database; $id = $this->id; if(!empty($id)) { $query = " SELECT * FROM contacts WHERE id = '$id' LIMIT 1"; $result = $database->getRow($query); $this->job_title = $result['job_title']; $this->title = $result['title']; $this->first_name = $result['first_name']; $this->last_name = $result['last_name']; $this->business_phone = $result['business_phone']; $this->home_phone = $result['home_phone']; $this->mobile_phone = $result['mobile_phone']; $this->fax = $result['fax']; $this->email = $result['email']; $this->contact_type_id = $result['contact_type_id']; $this->client_id = $result['client_id']; } if($_POST['Submit'] == "Save") { $this->job_title = $_POST['job_title']; $this->title = $_POST['title']; $this->first_name = $_POST['first_name']; $this->last_name = $_POST['last_name']; $this->mobile_phone = $_POST['mobile_phone']; $this->business_phone = $_POST['business_phone']; $this->home_phone = $_POST['home_phone']; $this->fax = $_POST['fax']; $this->email = $_POST['email']; $this->contact_type_id = $_POST['contact_type_id']; $this->client_id = $_POST['client_id']; } $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['job_title'] = array("id"=> $id,"value"=> $this->job_title, "input_name" => "job_title", "name" => "Job Title","rule" => ""); $this->config['title'] = array("id"=> $id,"value"=> $this->title, "input_name" => "title", "name" => "Title","rule" => ""); $this->config['business_phone'] = array("id"=> $id,"value"=> $this->business_phone, "input_name" => "business_phone", "name" => "Business Phone","rule" => ""); $this->config['home_phone'] = array("id"=> $id,"value"=> $this->home_phone, "input_name" => "home_phone", "name" => "Home Phone","rule" => ""); $this->config['mobile_phone'] = array("id"=> $id,"value"=> $this->mobile_phone, "input_name" => "mobile_phone", "name" => "Mobile Phone","rule" => ""); $this->config['fax'] = array("id"=> $id,"value"=> $this->fax, "input_name" => "fax", "name" => "Fax","rule" => ""); $this->config['email'] = array("id"=> $id,"value"=> $this->email, "input_name" => "email", "name" => "Email","rule" => "required|valid_email"); $this->config['contact_type_id'] = array("id"=> $id,"value"=> $this->contact_type_id, "input_name" => "contact_type_id", "name" => "Contact Type","rule" => "required"); self::run_validation(); } public function run_validation() { $static_function = (($_POST['Submit'] == "")) ? "initial" : "validate"; $this->validation['first_name'] = validation::$static_function($this->config['first_name']); $this->validation['last_name'] = validation::$static_function($this->config['last_name']); $this->validation['job_title'] = validation::$static_function($this->config['job_title']); $this->validation['title'] = validation::$static_function($this->config['title']); $this->validation['business_phone'] = validation::$static_function($this->config['business_phone']); $this->validation['home_phone'] = validation::$static_function($this->config['home_phone']); $this->validation['mobile_phone'] = validation::$static_function($this->config['mobile_phone']); $this->validation['fax'] = validation::$static_function($this->config['fax']); $this->validation['email'] = validation::$static_function($this->config['email']); $this->validation['contact_type_id'] = validation::$static_function($this->config['contact_type_id']); $this->reasons = validation::formalise($this->validation); } public function form() { global $database; $id = $this->id; $client_id = $this->client_id; $config = $this->config; $validation = $this->validation; $options = array("class" => "medium"); $results_list['results'] = common_ref_global_client::get_all_contact_types(); $results_list['chosen'] = $this->contact_type_id; $options_select = array( "class" => "medium form" ); $allow_company_field = $results_list['results'][$this->contact_type_id]['allow_company_field']; $table = $results_list['results'][$this->contact_type_id]['table']; ?>
Contact Type: