264 lines
7.8 KiB
PHP
264 lines
7.8 KiB
PHP
<?php
|
|
|
|
use Restserver\Libraries\REST_Controller;
|
|
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
require APPPATH . 'libraries/REST_Controller.php';
|
|
require APPPATH . 'libraries/Format.php';
|
|
|
|
class ManageNotifikasi extends CI_Controller
|
|
{
|
|
function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->model('ModelNotifikasi', 'Notifikasi');
|
|
$this->load->library(['datatables', 'form_validation']);
|
|
$this->form_validation->set_error_delimiters('', '');
|
|
}
|
|
public function output_json($data, $encode = true)
|
|
{
|
|
if ($encode) $data = json_encode($data);
|
|
$this->output->set_content_type('application/json')->set_output($data);
|
|
}
|
|
|
|
public function save_reminder()
|
|
{
|
|
$tgl = $this->input->post("tanggal");
|
|
$reminder = $this->input->post("reminder");
|
|
$id_karyawan = $this->input->post("id_karyawan");
|
|
|
|
$data = [
|
|
'TGL_NOTIFIKASI' => $tgl,
|
|
'JENIS_NOTIFIKASI' => 4,
|
|
'KET_NOTIFIKASI' => $reminder
|
|
];
|
|
|
|
|
|
if ($this->Notifikasi->create('notifikasi', $data)) {
|
|
$id_notif = $this->Notifikasi->getIdNotif(4, $reminder);
|
|
$data = [
|
|
'KARYAWAN_ID' => $id_karyawan,
|
|
'NOTIFIKASI_ID' => $id_notif[0]['ID_NOTIFIKASI'],
|
|
'STATUS' => 0
|
|
];
|
|
if ($this->Notifikasi->create('log_notifikasi', $data)) {
|
|
$this->output_json(
|
|
[
|
|
'value' => 1,
|
|
'message' => 'Success'
|
|
]
|
|
);
|
|
} else {
|
|
$this->output_json(
|
|
[
|
|
'value' => 0,
|
|
'message' => 'error'
|
|
]
|
|
);
|
|
}
|
|
} else {
|
|
$this->output_json(
|
|
[
|
|
'value' => 0,
|
|
'message' => 'error'
|
|
]
|
|
);
|
|
}
|
|
}
|
|
|
|
public function getReminder()
|
|
{
|
|
$tgl = $this->input->post('tanggal');
|
|
$id_karyawan = $this->input->post('id_karyawan');
|
|
$data = $this->Notifikasi->getDataReminder($tgl, $id_karyawan);
|
|
if ($data != null) {
|
|
$this->output_json([
|
|
'value' => 1,
|
|
'dataReminder' => $data
|
|
]);
|
|
} else {
|
|
$this->output_json([
|
|
'value' => 0,
|
|
'message' => 'Error'
|
|
]);
|
|
}
|
|
}
|
|
|
|
public function flash_notif()
|
|
{
|
|
$id_karyawan = $this->input->post('id_karyawan');
|
|
|
|
$data = $this->Notifikasi->getDataFlashNotif($id_karyawan);
|
|
|
|
if ($data != null) {
|
|
$this->output_json([
|
|
'value' => 1,
|
|
'dataFlashNotif' => $data
|
|
]);
|
|
} else {
|
|
$this->output_json(
|
|
[
|
|
'value' => 0,
|
|
'message' => 'Tidak Ada Flash Notif',
|
|
]
|
|
);
|
|
}
|
|
}
|
|
|
|
public function update_log_flash_notif()
|
|
{
|
|
$id_log = $this->input->post('id_log_notifikasi');
|
|
$data = [
|
|
'STATUS' => 1
|
|
];
|
|
if ($this->Notifikasi->updateLogNotif($id_log, $data,)) {
|
|
$this->output_json(
|
|
[
|
|
'value' => 1,
|
|
'message' => 'Success'
|
|
]
|
|
);
|
|
} else {
|
|
$this->output_json(
|
|
[
|
|
'value' => 0,
|
|
'message' => 'error'
|
|
]
|
|
);
|
|
}
|
|
}
|
|
|
|
public function notif()
|
|
{
|
|
$jabatan = $this->input->post('jabatan');
|
|
$id_karyawan = $this->input->post('id_karyawan');
|
|
|
|
$data = null;
|
|
if ($jabatan == "ADMINISTRATOR" AND $id_karyawan!=50) {
|
|
$data = $this->Notifikasi->getDataNotif(5, 0, $id_karyawan);
|
|
} else if ($jabatan == "ADMIN SALES" OR $jabatan == "SALES") {
|
|
$data = $this->Notifikasi->getDataNotif_AllNotif7($id_karyawan);
|
|
} else if ($jabatan == "ADMIN UMUM") {
|
|
$data = $this->Notifikasi->getDataNotif_AllNotif6(6, $id_karyawan);
|
|
} else {
|
|
$data = $this->Notifikasi->getDataNotif_AllNotif6(6, $id_karyawan);
|
|
}
|
|
|
|
if ($data != null) {
|
|
$this->output_json(
|
|
[
|
|
'value' => 1,
|
|
'dataNotif' => $data
|
|
]
|
|
);
|
|
} else {
|
|
$this->output_json(
|
|
[
|
|
'value' => 0,
|
|
'message' => 'Tidak Ada Notifikasi'
|
|
]
|
|
);
|
|
}
|
|
}
|
|
|
|
public function baca_notif()
|
|
{
|
|
$id_log_notifikasi = $this->input->get('id_log_notifikasi');
|
|
$data = [
|
|
'STATUS' => 2
|
|
];
|
|
$action = $this->Notifikasi->updateLogNotif($id_log_notifikasi, $data);
|
|
|
|
$datLogNotifikasi = $this->Notifikasi->getData_LogNotifikasi_byNOTIFIKASI($id_log_notifikasi);
|
|
if ($datLogNotifikasi[0]['JENIS_NOTIFIKASI']==6) {
|
|
redirect('Authority/dataFormKaryawan_All_A1');
|
|
} else if ($datLogNotifikasi[0]['JENIS_NOTIFIKASI']==7) {
|
|
$id_sav = $datLogNotifikasi[0]['SAV_ID'];
|
|
redirect("ManageVisit/dataVisitUser_Sales_A2/$id_sav");
|
|
}
|
|
|
|
}
|
|
|
|
public function baca_notif_semua()
|
|
{
|
|
$id_karyawan = $this->session->userdata('id_karyawan');
|
|
$datLogNotifikasi = $this->Notifikasi->getData_LogNotifikasi_byKARYAWAN_status1($id_karyawan);
|
|
|
|
foreach ($datLogNotifikasi as $key) {
|
|
$update = [
|
|
'STATUS' => 2
|
|
];
|
|
$action = $this->Notifikasi->update('log_notifikasi', $update, 'ID_LOG_NOTIFIKASI', $key['ID_LOG_NOTIFIKASI']);
|
|
}
|
|
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
|
|
public function histori_notif() {
|
|
$id_karyawan = $this->session->userdata('id_karyawan');
|
|
$datHnf = $this->Notifikasi->getData_HistoriNotifikasi_byKARYAWAN_orderDESC_limit1($id_karyawan);
|
|
if ($datHnf==FALSE) {
|
|
$historiNotif = "Pop Up Notifikasi Hari Ini\nKosong..";
|
|
} else {
|
|
$ket = $datHnf[0]['KET_HNF'];
|
|
$historiNotif = "$ket";
|
|
}
|
|
|
|
$data = array(
|
|
'historiNotif' => $historiNotif,
|
|
);
|
|
$this->output_json($data);
|
|
}
|
|
|
|
public function tambahlaporan_A1() {
|
|
$id_bantuan = $this->input->post('id');
|
|
$jenis_bantuan = $this->input->post('jenis_bantuan');
|
|
$ket_bantuan = $this->input->post('ket_bantuan');
|
|
$id_karyawan = $this->session->userdata('id_karyawan');
|
|
$tgl = date('Y-m-d');
|
|
|
|
$datAdministrator = $this->Dashboard->getData_AdministratorAll();
|
|
$datKaryawan = $this->Dashboard->getData_Karyawan($id_karyawan);
|
|
$nama_panggilan_karyawan = $datKaryawan[0]['NAMA_PANGGILAN_KARYAWAN'];
|
|
if ($jenis_bantuan==0) {
|
|
$ket_notifikasi = "Laporan Bug dari $nama_panggilan_karyawan.";
|
|
} else if ($jenis_bantuan==1) {
|
|
$ket_notifikasi = "Request Menu dari $nama_panggilan_karyawan.";
|
|
}
|
|
|
|
$input = [
|
|
'TGL_BANTUAN' => $tgl,
|
|
'JENIS_BANTUAN' => $jenis_bantuan,
|
|
'KET_BANTUAN' => $ket_bantuan,
|
|
'KARYAWAN_ID' => $id_karyawan
|
|
];
|
|
$action = $this->Notifikasi->create('bantuan', $input);
|
|
|
|
foreach ($datAdministrator as $key) {
|
|
$input = [
|
|
'TGL_NOTIFIKASI' => $tgl,
|
|
'JENIS_NOTIFIKASI' => '5',
|
|
'KET_NOTIFIKASI' => $ket_notifikasi
|
|
];
|
|
$action = $this->Notifikasi->create('notifikasi', $input);
|
|
$id_notifikasi = $this->Dashboard->getID_NotifikasiMax();
|
|
$id_notifikasi = $id_notifikasi[0]['ID_NOTIFIKASI'];
|
|
$input = [
|
|
'KARYAWAN_ID' => $key['ID_KARYAWAN'],
|
|
'STATUS' => '0',
|
|
'NOTIFIKASI_ID' => $id_notifikasi
|
|
];
|
|
$action = $this->Notifikasi->create('log_notifikasi', $input);
|
|
}
|
|
|
|
if ($action) {
|
|
$this->session->set_flashdata('success', 'dikirimkan');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
} else {
|
|
$this->session->set_flashdata('failed', 'dikirimkan');
|
|
redirect($_SERVER['HTTP_REFERER']);
|
|
}
|
|
}
|
|
|
|
}
|