class form_staff { public $id; public $db_name; public $depts; public function __construct($context) { $this->id = $context['id']; $this->db_name = $context['db_name']; } public function set() { global $database; $id = $this->id; $db_name = $this->db_name; $this->department = array(); if(!empty($id)) { $users_details = common_users::get_details($id); $users_details = cleanup::refilter_empty($users_details); $this->id = $users_details['id']; $this->username = $users_details['username']; $this->account_id = $users_details['account_id']; $this->password = $users_details['password']; $this->status = $users_details['status']; $this->email = $users_details['email']; $this->employee_id = $users_details['employee_id']; $this->first_name = $users_details['first_name']; $this->last_name = $users_details['last_name']; $this->phone = $users_details['phone']; $this->mobile = $users_details['mobile']; $this->job_title = $users_details['job_title']; $this->next_of_kin = $users_details['next_of_kin']; $this->next_of_kin_phone = $users_details['next_of_kin_phone']; $this->next_of_kin2 = $users_details['next_of_kin2']; $this->next_of_kin_phone2 = $users_details['next_of_kin_phone2']; $this->start_date = $users_details['start_date']; $this->birthday = $users_details['birthday']; $this->address = $users_details['address']; $this->suburb = $users_details['suburb']; $this->state = $users_details['state']; $this->post_code = $users_details['post_code']; $this->group_id = $users_details['group_id']; $this->start_shift_time = $users_details['start_shift_time']; $this->end_shift_time = $users_details['end_shift_time']; $split_start_time = explode(":",$this->start_shift_time); $split_end_time = explode(":",$this->end_shift_time); $this->start_shift_hour = $split_start_time[0]; $this->start_shift_min = $split_start_time[1]; $this->end_shift_hour = $split_end_time[0]; $this->end_shift_min = $split_end_time[1]; $this->hour_label = $users_details['hour_label']; $this->last_login = $users_details['last_login']; $this->failed_logins = $users_details['failed_logins']; $this->date_format = $users_details['date_format']; $this->hash = $users_details['hash']; $this->creator = $users_details['creator']; $this->date_created = $users_details['date_created']; $this->submitter = $users_details['submitter']; $this->date_submitted = $users_details['date_submitted']; $this->department = $users_details['department_ids']; $this->start_date = dates::change_to_nice($this->start_date); $this->birthday = dates::change_to_nice($this->birthday); } if($_POST['Submit'] == "Save") { $this->username = mysql_real_escape_string($_POST['username']); $this->employee_id = mysql_real_escape_string($_POST['employee_id']); $this->first_name = mysql_real_escape_string($_POST['first_name']); $this->last_name = mysql_real_escape_string($_POST['last_name']); $this->email = mysql_real_escape_string($_POST['email']); $this->phone = mysql_real_escape_string($_POST['phone']); $this->mobile = mysql_real_escape_string($_POST['mobile']); $this->address = mysql_real_escape_string($_POST['address']); $this->suburb = mysql_real_escape_string($_POST['suburb']); $this->country = mysql_real_escape_string($_POST['country']); $this->state = mysql_real_escape_string($_POST['state']); $this->post_code = mysql_real_escape_string($_POST['post_code']); $this->start_date = mysql_real_escape_string($_POST['start_date']); $this->group_id = mysql_real_escape_string($_POST['group_id']); $this->start_shift_hour = mysql_real_escape_string($_POST['start_shift_hour']); $this->end_shift_hour = mysql_real_escape_string($_POST['end_shift_hour']); $this->start_shift_min = mysql_real_escape_string($_POST['start_shift_min']); $this->end_shift_min = mysql_real_escape_string($_POST['end_shift_min']); $this->job_title = mysql_real_escape_string($_POST['job_title']); $this->next_of_kin1 = mysql_real_escape_string($_POST['next_of_kin1']); $this->next_of_kin_phone1 = mysql_real_escape_string($_POST['next_of_kin_phone1']); $this->next_of_kin2 = mysql_real_escape_string($_POST['next_of_kin2']); $this->next_of_kin_phone2 = mysql_real_escape_string($_POST['next_of_kin_phone2']); $this->birthday = mysql_real_escape_string($_POST['birthday']); $this->department = (count($_POST['department']) == 0) ? array() : $_POST['department']; } $this->config['employee_id'] = array("id"=> $id,"value"=> $this->employee_id, "input_name" => "employee_id", "name" => "Employee Number","rule" => "required|employee_id_exist"); $this->config['username'] = array("id"=> $id,"value"=> $this->username, "input_name" => "username", "name" => "User Name","rule" => "required|username_exist"); $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" => "valid_email"); $this->config['phone'] = array("id"=> $id,"value"=> $this->phone, "input_name" => "phone", "name" => "Phone","rule" => "required|numeric"); $this->config['mobile'] = array("id"=> $id,"value"=> $this->mobile, "input_name" => "mobile", "name" => "Mobile","rule" => "numeric"); $this->config['group_id'] = array("id"=> $id,"value"=> $this->group_id, "input_name" => "group_id", "name" => "Group","rule" => "required|numeric"); $this->config['start_shift_hour'] = array("id"=> $id,"value"=> $this->start_shift_hour, "input_name" => "start_shift_hour", "name" => "Start Shift Time","rule" => "required_include_zero"); $this->config['end_shift_hour'] = array("id"=> $id,"value"=> $this->end_shift_hour, "input_name" => "end_shift_hour", "name" => "End Shift Time","rule" => "required_include_zero"); $this->config['start_shift_min'] = array("id"=> $id,"value"=> $this->start_shift_min, "input_name" => "start_shift_min", "name" => "Start Shift Minute","rule" => "required_include_zero"); $this->config['end_shift_min'] = array("id"=> $id,"value"=> $this->end_shift_min, "input_name" => "end_shift_min", "name" => "End Shift Minute","rule" => "required_include_zero"); $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['start_date'] = array("id"=> $id,"value"=> $this->start_date, "input_name" => "start_date", "name" => "Start Date","rule" => ""); $this->config['job_title'] = array("id"=> $id,"value"=> $this->job_title, "input_name" => "job_title", "name" => "Job Title","rule" => ""); $this->config['next_of_kin1'] = array("id"=> $id,"value"=> $this->next_of_kin1, "input_name" => "next_of_kin1", "name" => "Next Of Kin","rule" => ""); $this->config['next_of_kin_phone1'] = array("id"=> $id,"value"=> $this->next_of_kin_phone1, "input_name" => "next_of_kin_phone1", "name" => "Next Of Kin Phone","rule" => ""); $this->config['next_of_kin2'] = array("id"=> $id,"value"=> $this->next_of_kin2, "input_name" => "next_of_kin2", "name" => "Next Of Kin 2","rule" => ""); $this->config['next_of_kin_phone2'] = array("id"=> $id,"value"=> $this->next_of_kin_phone2, "input_name" => "next_of_kin_phone2", "name" => "Next Of Kin Phone 2","rule" => "numeric"); $this->config['birthday'] = array("id"=> $id,"value"=> $this->birthday, "input_name" => "birthday", "name" => "Birthday","rule" => ""); self::run_validation(); } public function run_validation() { $id = $this->id; $static_function = (($_POST['Submit'] == "")) ? "initial" : "validate"; $this->validation['employee_id'] = validation::$static_function($this->config['employee_id']); $this->validation['username'] = validation::$static_function($this->config['username']); $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['phone'] = validation::$static_function($this->config['phone']); $this->validation['mobile'] = validation::$static_function($this->config['mobile']); $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['start_date'] = validation::$static_function($this->config['start_date']); $this->validation['job_title'] = validation::$static_function($this->config['job_title']); $this->validation['group_id'] = validation::$static_function($this->config['group_id']); $this->validation['start_shift_hour'] = validation::$static_function($this->config['start_shift_hour']); $this->validation['end_shift_hour'] = validation::$static_function($this->config['end_shift_hour']); $this->validation['start_shift_min'] = validation::$static_function($this->config['start_shift_min']); $this->validation['end_shift_min'] = validation::$static_function($this->config['end_shift_min']); $this->validation['next_of_kin1'] = validation::$static_function($this->config['next_of_kin1']); $this->validation['next_of_kin_phone1'] = validation::$static_function($this->config['next_of_kin_phone1']); $this->validation['next_of_kin2'] = validation::$static_function($this->config['next_of_kin2']); $this->validation['next_of_kin_phone2'] = validation::$static_function($this->config['next_of_kin_phone2']); $this->validation['birthday'] = validation::$static_function($this->config['birthday']); $this->reasons = validation::formalise($this->validation); } public function form() { global $database; $id = $this->id; $config = $this->config; $validation = $this->validation; $company = $this->company; $my_group = $_SESSION['user']['groups']; $my_branch = $_SESSION['user']['branch_id']; $my_username = $_SESSION['user']['id']; $options = array("class" => "medium"); ?>