<?php } else { ?> <a href="admin/settings/<?php echo $modules_name; ?> /form/<?php echo $row->id; ?> " class="btn btn-info" ><span class="glyphicon glyphicon-search" ></span> View</a> <?php } ?> <?php if ($perm->can_delete == 'y') { $regist = new Register_data(); $regist->where('hotel_id = ' . $row->id)->get(1); if (@$regist->id < 1) { ?> <a href="admin/settings/<?php echo $modules_name; ?> /delete/<?php echo $row->id; ?> " class="btn btn-danger btn_delete"><span class="glyphicon glyphicon-trash" ></span> Delete</a> <?php } } ?> </td>
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->rest_type = 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/register_datas/index?org_id=' . $org_id); }
public function ajax_rest_with_list() { $org_id = @$_POST['org_id']; $register_data_id = @$_POST['register_data_id']; $rest_with_id = @$_POST['rest_with_id']; $rest_list = new Register_data(); $rest_list->where('org_id = ' . $org_id); if ($register_data_id > 0) { $rest_list->where(' id <> ' . $register_data_id); } $select = '<select name="rest_with" class="form-control-other" style="padding-left:0px;">'; $select .= '<option value="null" selected="selected">ไม่ระบุ</option>'; $select .= $rest_with_id == '0' ? '<option value="0" selected="selected">พักคนเดียว</option>' : '<option value="0">พักคนเดียว</option>'; foreach ($rest_list as $key => $value) { $checked = $value->id == $rest_with_id ? 'checked="checked"' : ''; $select .= '<option value="' . $value->id . '" ' . $selected . '>' . $value->titulation->titulation_title . $value->firstname . ' ' . $value->lastname . '</option>'; } $select .= '</select>'; echo $select; }
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"); } } } }