function input($user_id = null) { if (!$this->ion_auth->logged_in()) { //redirect them to the login page redirect('auth/login', 'refresh'); } $this->data['user_id'] = $user_id; $this->data['superior'] = !empty($user_id) ? get_superior($user_id) : ''; $this->data['date_exit'] = !empty($user_id) ? getValue('date_exit', 'users_exit', array('user_id' => 'where/' . $user_id)) : ''; $sess_id = $this->data['sess_id'] = $this->session->userdata('user_id'); $sess_nik = $this->data['sess_nik'] = get_nik($sess_id); $this->data['all_users'] = getAll('users', array('active' => 'where/1', 'username' => 'order/asc'), array('!=id' => '1')); $this->get_user_atasan(); $this->data['subordinate'] = getAll('users', array('superior_id' => 'where/' . get_nik($sess_id))); $this->data['exit_type'] = getAll('exit_type', array('is_deleted' => 'where/0')); $this->_render_page('form_exit/input', $this->data); }
function do_approve($id, $type) { if (!$this->ion_auth->logged_in()) { redirect('auth/login', 'refresh'); } else { $is_app = getValue('is_app_' . $type, 'users_resignment', array('id' => 'where/' . $id)); $num_rows = getAll('users_resignment_wawancara', array('user_resignment_id' => 'where/' . $id))->num_rows(); $user_resignment_id = getValue('user_id', 'users_resignment', array('id' => 'where/' . $id)); $date_resignment = getValue('date_resign', 'users_resignment', array('id' => 'where/' . $id)); $user_exit_id_num_rows = getAll('users_exit', array('user_id' => 'where/' . $user_resignment_id))->num_rows(); //print_mz($user_exit_id_num_rows); $user_id = get_nik($this->session->userdata('user_id')); $date_now = date('Y-m-d'); if ($type == 'hrd') { $data1 = array('user_resignment_id' => $id, 'alasan_resign_id' => implode(',', $this->input->post('alasan_resign_id')), 'desc_resign' => $this->input->post('desc_resign'), 'procedure_resign' => $this->input->post('procedure_resign'), 'kepuasan_resign' => $this->input->post('kepuasan_resign'), 'saran_resign' => $this->input->post('saran_resign'), 'rework_resign' => $this->input->post('rework_resign')); $data2 = array('is_app_' . $type => 1, 'app_status_id_' . $type => $this->input->post('app_status_' . $type), 'user_app_' . $type => $user_id, 'date_app_' . $type => $date_now, 'note_' . $type => $this->input->post('note_' . $type)); if ($num_rows > 0) { $this->db->where('user_resignment_id', $id)->update('users_resignment_wawancara', $data1); if (!empty(get_superior($user_resignment_id))) { $this->approval->request_exit($user_resignment_id); } } else { if (!empty(get_superior($user_resignment_id))) { $this->approval->request_exit($user_resignment_id); } $this->db->insert('users_resignment_wawancara', $data1); if ($user_exit_id_num_rows > 0) { $data_exit = array('date_exit' => $date_resignment, 'exit_type_id' => 3, 'is_resignment' => 1); if (!empty(get_superior($user_resignment_id))) { $this->approval->request_exit($user_resignment_id); } $this->db->where('user_id', $user_resignment_id)->update('users_exit', $data_exit); } else { $data_exit = array('id_comp_session' => 1, 'user_id' => $user_resignment_id, 'date_exit' => $date_resignment, 'exit_type_id' => 3, 'is_resignment' => 1); $this->db->insert('users_exit', $data_exit); $exit_id = $this->db->insert_id(); if (!empty(get_superior($user_resignment_id))) { $this->approval->request_exit($user_resignment_id); } } } $this->form_resignment_model->update($id, $data2); } else { $data = array('is_app_' . $type => 1, 'app_status_id_' . $type => $this->input->post('app_status_' . $type), 'user_app_' . $type => $user_id, 'date_app_' . $type => $date_now, 'note_' . $type => $this->input->post('note_' . $type)); $this->form_resignment_model->update($id, $data); } $approval_status = $this->input->post('app_status_' . $type); if ($is_app == 0) { $this->approval->approve('resignment', $id, $approval_status, $this->detail_email($id)); } else { $this->approval->update_approve('resignment', $id, $approval_status, $this->detail_email($id)); } if ($type !== 'hrd' && $approval_status == 1) { $lv = substr($type, -1) + 1; $lv_app = 'lv' . $lv; $user_app = $lv < 4 ? getValue('user_app_' . $lv_app, 'users_resignment', array('id' => 'where/' . $id)) : 0; if (!empty($user_app)) { if (!empty(getEmail($user_app))) { $this->send_email(getEmail($user_app), 'Pengajuan Permohonan Resignment', $isi_email); } $this->approval->request('lv1', 'resignment', $resignment_id, $user_id, $this->detail_email($resignment_id)); } else { if (!empty(getEmail($this->approval->approver('resignment')))) { $this->send_email(getEmail($this->approval->approver('resignment')), 'Pengajuan Permohonan Resignment', $isi_email); } $this->approval->request('hrd', 'resignment', $resignment_id, $user_id, $this->detail_email($resignment_id)); } } redirect('form_resignment/detail/' . $id, 'refresh'); } }
function is_authorized($sess_id, $user_cuti_id) { //print_mz(get_superior($sess_id)); $CI =& get_instance(); if ($CI->ion_auth->is_admin() || ($sess_id = $user_cuti_id || ($sess_id = get_id(get_superior($user_cuti_id)) || ($sess_id = get_id(get_superior(get_id(get_superior($user_cuti_id)))))))) { return TRUE; } else { return FALSE; } }
function send_approval_request($id) { $user_id = $this->session->userdata('user_id'); $username = $this->db->where('id', $user_id)->get('users')->row('username'); $url = base_url() . 'form_cuti/approval_'; if (is_have_superior($user_id)) { $data = array('sender_id' => get_nik($user_id), 'receiver_id' => $this->form_cuti_model->get_superior_id($user_id)->row('superior_id'), 'sent_on' => date('Y-m-d-H-i-s', strtotime('now')), 'subject' => 'Pengajuan Permohonan Cuti', 'email_body' => $username . ' mengajukan permohonan cuti, untuk melihat detail silakan <a href=' . $url . 'spv/' . $id . '>Klik Disini</a>', 'is_read' => 0); $this->db->insert('email', $data); $current_superior = get_id($this->form_cuti_model->get_superior_id($user_id)->row('superior_id')); } else { $current_superior = 0; } if (!empty(get_superior($current_superior))) { $data = array('sender_id' => get_nik($user_id), 'receiver_id' => get_superior($current_superior), 'sent_on' => date('Y-m-d-H-i-s', strtotime('now')), 'subject' => 'Pengajuan Permohonan Cuti', 'email_body' => $username . ' mengajukan permohonan cuti, untuk melihat detail silakan <a href=' . $url . 'kbg/' . $id . '>Klik Disini</a>', 'is_read' => 0); $this->db->insert('email', $data); } $data = array('sender_id' => get_nik($user_id), 'receiver_id' => 1, 'sent_on' => date('Y-m-d-H-i-s', strtotime('now')), 'subject' => 'Pengajuan Permohonan Cuti', 'email_body' => $username . ' mengajukan permohonan cuti, untuk melihat detail silakan <a href=' . $url . 'hrd/' . $id . '>Klik Disini</a>', 'is_read' => 0); $this->db->insert('email', $data); }
function send_approval_request($id) { $user_id = $this->session->userdata('user_id'); $url = base_url() . 'form_training/approval_'; if (is_have_superior($user_id)) { $data = array('sender_id' => get_nik($user_id), 'receiver_id' => get_superior($user_id), 'sent_on' => date('Y-m-d-H-i-s', strtotime('now')), 'subject' => 'Pengajuan Training', 'email_body' => get_name($user_id) . ' mengajukan permohonan pelatihan, untuk melihat detail silakan <a href=' . $url . 'spv/' . $id . '>Klik Disini</a>', 'is_read' => 0); $this->db->insert('email', $data); } else { $current_superior = 0; } $data = array('sender_id' => get_nik($user_id), 'receiver_id' => 1, 'sent_on' => date('Y-m-d-H-i-s', strtotime('now')), 'subject' => 'Pengajuan Training', 'email_body' => get_name($user_id) . ' mengajukan permohonan training, untuk melihat detail silakan <a href=' . $url . 'hrd/' . $id . '>Klik Disini</a>', 'is_read' => 0); $this->db->insert('email', $data); }
public function request_exit($id) { $CI =& get_instance(); $url = base_url() . 'form_exit/input/' . $id; $atasan = get_superior($id); $data = array('sender_id' => get_nik($id), 'receiver_id' => $atasan, 'sent_on' => date('Y-m-d-H-i-s', strtotime('now')), 'subject' => 'Permintaan Rekomendasi Karyawan Keluar (Resign)', 'email_body' => get_name($id) . " mengajukan permintaan rekomendasi karyawan keluar (resign), silakan klik tautan berikut untuk menginput data <a href={$url}>{$url}</a><br/>", 'is_read' => 0); $CI->db->insert('email', $data); }