Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function listproposalpelaksanaan_post()
- {
- $username = trim($this->post('username'));
- $level = trim($this->post('level'));
- $status = trim($this->post('status'));
- if ($username == '') {
- $response = [
- 'resp_error' => true,
- 'resp_msg' => 'Username tidak ditemukan.',
- ];
- } elseif ($level == '') {
- $response = [
- 'resp_error' => true,
- 'resp_msg' => 'Level tidak diketahui.',
- ];
- } elseif ($level == 'Member') {
- $response = [
- 'resp_error' => true,
- 'resp_msg' => 'Level tidak berhak mengakses data.',
- ];
- } else {
- if ($level == 'Member') {
- if ($status == 'all') {
- $listProposal = $this->db->order_by('propose_title', 'asc')->get_where('v_proposal', array('propose_status' => 3, 'user_username' => $username))->result();
- } elseif ($status == 'selesai') {
- $listProposal = $this->db->order_by('propose_title', 'asc')->get_where('v_proposal', array('propose_status' => 3, 'user_username' => $username,
- 'propose_kumpul' => 2, 'propose_report_status' => 2))->result();
- } elseif ($status == 1) {
- $listProposal = $this->db->order_by('propose_title', 'asc')->get_where('v_proposal', array('propose_status' => 3, 'user_username' => $username,
- 'propose_kumpul' => 1, 'propose_report_status' => 1))->result();
- } else {
- $listProposal = $this->db->order_by('propose_title', 'asc')->get_where('v_proposal', array('propose_status' => 3, 'user_username' => $username,
- 'propose_kumpul' => 2, 'propose_report_status' => 1))->result();
- }
- } elseif ($level == 'Admin') {
- if ($status == 'all') {
- $listProposal = $this->db->order_by('propose_title', 'asc')->get_where('v_proposal', array('propose_status' => 3))->result();
- } elseif ($status == 'selesai') {
- $listProposal = $this->db->order_by('propose_title', 'asc')->get_where('v_proposal', array('propose_status' => 3, 'propose_kumpul' => 2, 'propose_report_status' => 2))->result();
- } elseif ($status == 1) {
- $listProposal = $this->db->order_by('propose_title', 'asc')->get_where('v_proposal', array('propose_status' => 3, 'propose_kumpul' => 1, 'propose_report_status' => 1))->result();
- } else {
- $listProposal = $this->db->order_by('propose_title', 'asc')->get_where('v_proposal', array('propose_status' => 3, 'propose_kumpul' => 2, 'propose_report_status' => 1))->result();
- }
- } else {
- if ($status == 'all') {
- $this->db->select('p.*, s.skim_name, u.user_name');
- $this->db->from('lemlit_propose p');
- $this->db->join('lemlit_users u', 'p.user_username = u.user_username');
- $this->db->join('lemlit_skim s', 'p.skim_id = s.skim_id');
- $this->db->join('lemlit_reviewer t', 't.propose_id = p.propose_id');
- $this->db->where('t.user_username', $username);
- $this->db->where('p.propose_status', 3);
- $this->db->order_by('p.propose_title', 'asc');
- $listProposal = $this->db->get()->result();
- } elseif ($status == 'selesai') {
- $this->db->select('p.*, s.skim_name, u.user_name');
- $this->db->from('lemlit_propose p');
- $this->db->join('lemlit_users u', 'p.user_username = u.user_username');
- $this->db->join('lemlit_skim s', 'p.skim_id = s.skim_id');
- $this->db->join('lemlit_reviewer t', 't.propose_id = p.propose_id');
- $this->db->where('t.user_username', $username);
- $this->db->where('p.propose_status', 3);
- $this->db->where('p.propose_kumpul', 2);
- $this->db->where('p.propose_report_status', 2);
- $this->db->order_by('p.propose_title', 'asc');
- $listProposal = $this->db->get()->result();
- } elseif ($status == 1) {
- $this->db->select('p.*, s.skim_name, u.user_name');
- $this->db->from('lemlit_propose p');
- $this->db->join('lemlit_users u', 'p.user_username = u.user_username');
- $this->db->join('lemlit_skim s', 'p.skim_id = s.skim_id');
- $this->db->join('lemlit_reviewer t', 't.propose_id = p.propose_id');
- $this->db->where('t.user_username', $username);
- $this->db->where('p.propose_status', 3);
- $this->db->where('p.propose_kumpul', 1);
- $this->db->where('p.propose_report_status', 1);
- $this->db->order_by('p.propose_title', 'asc');
- $listProposal = $this->db->get()->result();
- } else {
- $this->db->select('p.*, s.skim_name, u.user_name');
- $this->db->from('lemlit_propose p');
- $this->db->join('lemlit_users u', 'p.user_username = u.user_username');
- $this->db->join('lemlit_skim s', 'p.skim_id = s.skim_id');
- $this->db->join('lemlit_reviewer t', 't.propose_id = p.propose_id');
- $this->db->where('t.user_username', $username);
- $this->db->where('p.propose_status', 3);
- $this->db->where('p.propose_kumpul', 2);
- $this->db->where('p.propose_report_status', 1);
- $this->db->order_by('p.propose_title', 'asc');
- $listProposal = $this->db->get()->result();
- }
- }
- if (count($listProposal) == 0) {
- $response = [
- 'resp_error' => false,
- 'resp_msg' => 'Belum Ada Proposal',
- ];
- } else {
- foreach ($listProposal as $r) {
- if ($r->propose_kumpul == 1) {
- $status = 'Belum Di Kumpulkan';
- } else {
- $status = 'Sudah Di Kumpulkan';
- }
- if (!empty($r->propose_report_file)) {
- $berkas = base_url('upload_file/laporan/' . $r->propose_report_file);
- } else {
- $berkas = '';
- }
- if (empty($r->propose_date_kumpul)) {
- $tgl_kumpul = '';
- } else {
- $tgl_kumpul = date('d-m-Y', strtotime($r->propose_date_kumpul));
- }
- if ($r->propose_report_status == 1) {
- $statusselesai = 'Belum Selesai';
- } else {
- $statusselesai = 'Selesai';
- }
- $response['items'][] = [
- 'resp_error' => false,
- 'id' => $r->propose_id,
- 'tanggal' => date("d-m-Y", strtotime($r->propose_date)),
- 'user_username' => $r->user_username,
- 'nama' => trim($r->user_name),
- 'judul' => trim($r->propose_title),
- 'kategori' => trim($r->skim_name),
- 'status' => $r->status_desc,
- 'tgl_kumpul' => $tgl_kumpul,
- 'statusberkas' => $status,
- 'statusselesai' => $statusselesai,
- 'berkas' => $berkas,
- ];
- }
- }
- }
- $this->response($response, 200);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement