public function delete($id = null) { $org_id = $current_user->org_id; if ($this->perm->can_delete == 'y') { if ($id) { $data = new Register_data($id); if ($data->firstname == '') { $org_id = $data->org_id; $action = 'DELETE'; save_logs($this->menu_id, $action, @$data->id, $action . ' ' . $data->register_code . ' ' . $data->firstname . ' ' . $data->lastname . ' Register Data'); $this->db->query("DELETE FROM register_datas WHERE id=" . $id); } else { $data->titulation_id = null; $data->titulation_other = null; $data->firstname = null; $data->lastname = null; $data->gender = null; $data->position = null; $data->org_other = null; $data->position = null; $data->mobile_no = null; $data->email = null; $data->food_type = null; $data->hotel_id = null; $data->checkin_date = null; $data->checkout_date = null; $data->rest_with = null; $data->ip_address = $_SERVER['REMOTE_ADDR']; $data->updat_by = $this->current_user->id; $data->update_date = date("Y-m-d H:i:s"); $org_id = $data->org_id; $action = 'Clear'; save_logs($this->menu_id, $action, @$data->id, $action . ' ' . $data->register_code . ' ' . $data->firstname . ' ' . $data->lastname . ' Register Data'); $data->save(); } } } redirect("admin/" . $this->modules_name . "/index?rest_type=" . $data->rest_type); }
public function save($id = false) { $configurations = new Configuration(1); if ($configurations->public_status != 'y') { $this->offline(); } else { if ($_POST) { $sql = "select count(*)max_register_number from register_datas where firstname='" . trim(@$_POST['firstname']) . "' AND lastname='" . trim(@$_POST['lastname']) . "'"; $max_register_number = $this->db->query($sql)->result(); $max_register_number = @$max_register_number[0]; $max_register_number = $max_register_number->max_register_number; if ($max_register_number > 0) { set_notify('error', 'ชื่อ - นามสกล ของคุณมีอยู่แล้วในระบบ'); $this->form(); } else { $id = ''; $data = new Register_data($id); $data->register_type = 2; $data->titulation_id = strip_tags($_POST["titulation_id"]); $data->titulation_other = strip_tags($_POST["titulation_other"]); $data->firstname = strip_tags(trim($_POST["firstname"])); $data->lastname = strip_tags(trim($_POST["lastname"])); $data->gender = strip_tags($_POST["gender"]); $data->position = strip_tags($_POST["position"]); $data->org_id = $_POST['org_id']; $data->org_other = strip_tags($_POST["org_other"]); $data->position = strip_tags($_POST['position']); $data->mobile_no = strip_tags($_POST["mobile_no"]); $data->email = strip_tags($_POST["email"]); $data->rest_type = $_POST['rest_type']; if ($data->rest_type != 'y' && $data->rest_type != 'n') { $org = new Organization($_POST['org_id']); if ($org->org_type_id > 0) { $data->rest_type = $org->org_type_id == 2 ? 'y' : 'n'; } else { $data->rest_type = $data->rest_type == 2 ? 'y' : 'n'; } } $data->food_type = $_POST['food_type']; /* if ($data -> rest_type == 'y') { $data -> hotel_id = $_POST['hotel_id']; $checkin_date = $_POST['checkin_year'] . '-' . $_POST['checkin_month'] . '-' . $_POST['checkin_day'] . ' ' . $_POST['checkin_hour'] . ":" . $_POST['checkin_minute']; $data -> checkin_date = $checkin_date; $checkout_date = $_POST['checkout_year'] . '-' . $_POST['checkout_month'] . '-' . $_POST['checkout_day'] . ' ' . $_POST['checkout_hour'] . ":" . $_POST['checkout_minute']; ; $data -> checkout_date = $checkout_date; $data -> rest_with = null; //$data->rest_with = $_POST['rest_with']; } else { $data -> hotel_id = null; $data -> checkin_date = null; $data -> checkout_date = null; $data -> rest_with = null; } * */ $data->ip_address = $_SERVER['REMOTE_ADDR']; $data->register_date = date("Y-m-d H:i:s"); $data->create_by = 0; $data->create_date = date("Y-m-d H:i:s"); if ($data->register_code == '') { $register_code = $data->rest_type == 'y' ? 'E02' : 'E01'; $sql = "select max(register_number)max_register_number from register_datas where rest_type='" . $data->rest_type . "' AND register_type = 2 "; $max_register_number = $this->db->query($sql)->result(); $max_register_number = @$max_register_number[0]; $max_register_number = $max_register_number->max_register_number; $register_code .= str_pad($max_register_number + 1, 2, "0", STR_PAD_LEFT); $data->register_code = $register_code; $data->register_number = $max_register_number + 1; } $data->save(); $action = 'CREATE'; save_logs($this->menu_id, $action, @$data->id, $action . ' ' . $data->firstname . ' ' . $data->lastname . ' Register Public'); set_notify('success', 'ลงทะเบียนเสร็จเรียบร้อย'); redirect("register/success"); } } } }