Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Close Ticket
- public function closeticket_post()
- {
- $username = trim($this->post('username'));
- $nama = trim($this->post('nama'));
- $level = trim($this->post('level'));
- $ticket_id = trim($this->post('ticket_id'));
- if ($username == '') {
- $response = [
- 'resp_error' => true,
- 'resp_msg' => 'Username kosong.',
- ];
- } elseif ($ticket_id == '') {
- $response = [
- 'resp_error' => true,
- 'resp_msg' => 'ID Ticket kosong.',
- ];
- } else {
- if (!empty($_FILES['attachment']['name'])) {
- $jam = time();
- $config['file_name'] = 'Ticket_' . $jam . '.jpg';
- $config['upload_path'] = './img/image_ticket/';
- $config['allowed_types'] = 'jpg|png|gif|jpeg';
- $config['overwrite'] = true;
- $this->load->library('upload', $config);
- $this->upload->do_upload('attachment');
- $config['image_library'] = 'gd2';
- $config['source_image'] = $this->upload->upload_path . $this->upload->file_name;
- $config['maintain_ratio'] = true;
- $this->load->library('image_lib', $config);
- $this->image_lib->resize();
- } elseif (empty($_FILES['attachment']['name'])) {
- $config['file_name'] = '';
- }
- if ($level == 'Member') {
- $message = '';
- $ticket_status = 'Closed';
- $detail_level = 'Member';
- } else {
- $ticket_status = 'Closed';
- $detail_level = 'Admin';
- // Insert ke Tabel Ticket
- $dataTicket = $this->db->get_where('v_ticket', array('ticket_id' => $ticket_id))->row();
- $footer = $this->db->get_where('lemlit_content', array('content_id' => 3))->row();
- $dataFooter = $footer->content_desc;
- $closed = $this->db->get_where('lemlit_content', array('content_id' => 4))->row();
- $dataclosed = $closed->content_desc;
- // Kirim Email
- $sender_email = 'no-reply.simpel@umk.ac.id';
- $sender_name = 'no-reply';
- $subject = '[Ticket ID : #' . $ticket_id . ' ] ' . $dataTicket->ticket_subject;
- $email = $dataTicket->user_email;
- $message = $dataclosed .
- "<p>
- Hormat Kami,<br>
- " . $namapetugas . "<br>
- " . $level . "<br>" . $dataFooter;
- $this->load->library('email');
- $this->email->set_mailtype("html");
- $this->email->from($sender_email, $sender_name);
- $this->email->to($email);
- $this->email->subject($subject);
- $this->email->message($message);
- $this->email->send();
- $dataDetail = array(
- 'ticket_id' => $ticket_id,
- 'user_username' => $username,
- 'detail_level' => $detail_level,
- 'detail_message' => $message,
- 'detail_date_post' => date('Y-m-d'),
- 'detail_time_post' => date('Y-m-d H:i:s'),
- );
- $this->db->insert('lemlit_ticket_detail', $dataDetail);
- }
- // Update Ticket
- $dataUpdateTicket = array(
- 'user_username' => $username,
- 'ticket_status' => $ticket_status,
- 'ticket_update' => date('Y-m-d H:i:s'),
- );
- $this->db->where('ticket_id', $ticket_id);
- $this->db->update('lemlit_ticket', $dataUpdateTicket);
- $resp = ['resp_error' => false, 'resp_msg' => "success"];
- }
- $this->response($resp, 200);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement