Skip to content

Instantly share code, notes, and snippets.

@aldiskatel
Created May 17, 2022 05:01
Show Gist options
  • Save aldiskatel/75cb138554fb5c7364d782759926859e to your computer and use it in GitHub Desktop.
Save aldiskatel/75cb138554fb5c7364d782759926859e to your computer and use it in GitHub Desktop.
<?php
defined('BASEPATH') or exit('No direct script access allowed');
use chriskacerguis\RestServer\RestController;
// require_once __DIR__ . '/vendor/autoload.php';
class Api extends RestController
{
function __construct()
{
// Construct the parent class
parent::__construct();
$this->load->model('api_model', 'model');
$this->load->helper('url');
$this->load->database();
}
public function index_get($value = '')
{
show_404();
}
public function login_post()
{
$usr = $this->input->post('username');
$pwd = $this->input->post('password');
$row = $this->model->find('t_akun', [
'username' => $usr,
'password' => md5($pwd)
]);
if ($row->num_rows() > 0) {
$this->response([
'status' => true,
'message' => 'Login berhasil.',
'user' => [
'id' => $row->row('id_akun'),
'name' => $row->row('nama')
]
], 200);
} else {
$this->response([
'status' => false,
'message' => 'Username atau password salah.'
], 200);
}
}
public function kirimAbsen_post()
{
$peg = $this->input->post('id_user');
$lat = $this->input->post('lat');
$lon = $this->input->post('long');
$ket = $this->input->post('keterangan');
$tgl = $this->input->post('tanggal');
$try = $this->model->save('t_absensi', [
'id_pegawai' => $peg,
'file' => $file,
'tanggal_kerja' => $tgl,
'keterangan' => $ket,
'lat' => $lat,
'lon' => $lon
]);
if ($try === true) {
$this->response([
'status' => true,
'message' => 'Absensi berhasil.'
], 200);
} else {
$this->response([
'status' => false,
'message' => 'Absensi gagal.'
], 200);
}
}
public function riwayatAbsen_post()
{
$peg = $this->input->post('id_user');
$row = $this->model->find('t_absensi', [
'id_pegawai' => $peg
]);
if ($row->num_rows() > 0) {
$this->response([
'status' => true,
'message' => $row->result_array()
], 200);
} else {
$this->response([
'status' => false,
'message' => 'Data absensi tidak ditemukan.'
], 200);
}
}
public function ajukanCuti_post()
{
$peg = $this->input->post('id_user');
$jns = $this->input->post('jenis_cuti');
$mul = $this->input->post('tanggal_mulai');
$sel = $this->input->post('tanggal_selesai');
$ket = $this->input->post('keterangan');
$try = $this->model->save('t_cuti', [
'id_pegawai' => $peg,
'jenis_cuti' => $jns,
'tanggal_mulai' => $mul,
'tanggal_selesai' => $sel,
'keterangan' => $ket
]);
if ($try === true) {
$this->response([
'status' => true,
'message' => 'Pengajuan cuti berhasil.'
], 200);
} else {
$this->response([
'status' => false,
'message' => 'Pengajuan cuti gagal.'
], 200);
}
}
public function daftarCuti_post()
{
$peg = $this->input->post('id_user');
$row = $this->model->find('t_cuti', [
'id_pegawai' => $peg
]);
if ($row->num_rows() > 0) {
$this->response([
'status' => true,
'message' => $row->result_array()
], 200);
} else {
$this->response([
'status' => false,
'message' => 'Data cuti tidak ditemukan.'
], 200);
}
}
public function suratCuti_post()
{
$key = $this->input->post('id_cuti');
$row = $this->model->find('t_cuti', [
'id_cuti' => $key
]);
if ($row->num_rows() > 0) {
$data = $this->db->query('
SELECT * FROM t_cuti
LEFT JOIN t_pegawai ON t_cuti.id_pegawai=t_pegawai.id_pegawai
LEFT JOIN t_unit ON t_pegawai.id_unit=t_unit.id_unit
LEFT JOIN t_jabatan ON t_pegawai.id_jabatan=t_jabatan.id_jabatan
LEFT JOIN t_pangkat ON t_pegawai.id_pangkat=t_pangkat.id_pangkat
LEFT JOIN t_golongan ON t_pegawai.id_golongan=t_golongan.id_golongan WHERE id_cuti='.$key
)->row();
$pdf = new \Mpdf\Mpdf();
$contents = '
<table style="width: 100%;">
<tr>
<td> <img src="https://joki.aldiskatel.net/lpmpkalsel/web/assets/images/twh.png" height="100" alt=""> </td>
<td style="text-align:center; font-weight: bold;">
KEMENTERIAN PENDIDIKAN DAN KEBUDAYAAN<br>
LEMBAGA PENJAMINAN MUTU PENDIDIKAN <br>
PROVINSI KALIMANTAN SELATAN<br>
Jalan Gotong Royong No. 85 Banjarbaru, Kalimantan Selatan<br>
Telp.(0511)4772384 Kode Pos 70711 <br>
Website : set.lpmpkalsel@kemdikbud.go.id <br>E-mail lpmpkalsel.kemdikbud.go.id
</td>
</tr>
</table>
<hr size="2px" color="black" style="margin-bottom: 1px;">
<hr size="2px" color="black" style="margin-top: 1px;">
<table style="width: 100%;">
<tr>
<td style="text-align: right;">Banjarbaru, '.date('d/m/Y').'</td>
</tr>
</table>
<table style="width: 100%;">
<tr>
<td colspan="5"> </td>
<td colspan="1"> </td>
</tr>
<tr>
<tr>
<td colspan="1"> </td>
<td colspan="5" style="text-align: center;"> <u>SURAT IZIN CUTI</u> </td>
</tr>
<tr>
<td colspan="1"> </td>
<td colspan="5" style="text-align: center;">NOMOR : B-.../KK.14.04-98/KP.03.02.2021 </td>
</tr>
<tr>
<td colspan="5"> </td>
<td colspan="1"> </td>
</tr>
<tr>
<td colspan="1"> </td>
<td colspan="5" style="text-align: left;">Diberikan cuti '.strtolower($data->jenis_cuti).' kepada : </td>
</tr>
<tr>
<td colspan="5"> </td>
<td colspan="1"> </td>
</tr>
<tr>
<td colspan="1" style="text-align: left;"> </td>
<td colspan="1" style="text-align: left;">Nama</td>
<td colspan="1" style="text-align: left; width: 1%;">:</td>
<td colspan="3" style="text-align: left;">'.$data->nama.'</td>
</tr>
<tr>
<td colspan="1" style="text-align: left;"> </td>
<td colspan="1" style="text-align: left;">NIP</td>
<td colspan="1" style="text-align: left; width: 1%;">:</td>
<td colspan="3" style="text-align: left;">'.$data->nip.'</td>
</tr>
<tr>
<td colspan="1" style="text-align: left;"> </td>
<td colspan="1" style="text-align: left;">Unit</td>
<td colspan="1" style="text-align: left; width: 1%;">:</td>
<td colspan="3" style="text-align: left;">'.$data->unit.'</td>
</tr>
<tr>
<td colspan="1" style="text-align: left;"> </td>
<td colspan="1" style="text-align: left;">Jabatan</td>
<td colspan="1" style="text-align: left; width: 1%;">:</td>
<td colspan="3" style="text-align: left;">'.$data->jabatan.'</td>
</tr>
<tr>
<td colspan="1" style="text-align: left;"> </td>
<td colspan="1" style="text-align: left;">Pangkat</td>
<td colspan="1" style="text-align: left; width: 1%;">:</td>
<td colspan="3" style="text-align: left;">'.$data->pangkat.'</td>
</tr>
<tr>
<td colspan="1" style="text-align: left;"> </td>
<td colspan="1" style="text-align: left;">Golongan</td>
<td colspan="1" style="text-align: left; width: 1%;">:</td>
<td colspan="3" style="text-align: left;">'.$data->golongan.'</td>
</tr>
<tr>
<td colspan="1" style="text-align: left;"> </td>
<td colspan="1" style="text-align: left;">Jenis Cuti</td>
<td colspan="1" style="text-align: left; width: 1%;">:</td>
<td colspan="3" style="text-align: left;">'.$data->jenis_cuti.'</td>
</tr>
<tr>
<td colspan="1" style="text-align: left;"> </td>
<td colspan="1" style="text-align: left;">Tanggal Mulai</td>
<td colspan="1" style="text-align: left; width: 1%;">:</td>
<td colspan="3" style="text-align: left;">'.$data->tanggal_mulai.'</td>
</tr>
<tr>
<td colspan="1" style="text-align: left;"> </td>
<td colspan="1" style="text-align: left;">Tanggal Selesai</td>
<td colspan="1" style="text-align: left; width: 1%;">:</td>
<td colspan="3" style="text-align: left;">'.$data->tanggal_selesai.'</td>
</tr>
<tr>
<td colspan="1" style="text-align: left;"> </td>
<td colspan="1" style="text-align: left;">Keterangan</td>
<td colspan="1" style="text-align: left; width: 1%;">:</td>
<td colspan="3" style="text-align: left;">'.$data->keterangan.'</td>
</tr>
<tr>
<td colspan="5"> </td>
<td colspan="1"> </td>
</tr>
<tr>
<td colspan="5"> </td>
<td colspan="1"> </td>
</tr>
<tr>
<td colspan="1"> </td>
<td colspan="5" style="text-align: left;">Selama '.date_diff(date_create($data->tanggal_selesai), date_create($data->tanggal_mulai))->format('%a').' hari kerja terhitung mulai tanggal '.date('d/m/Y', strtotime($data->tanggal_mulai)).' sampai tanggal '.date('d/m/Y', strtotime($data->tanggal_selesai)).' dengan ketentuan sebagai berikut : </td>
</tr>
<tr>
<td colspan="1"> </td>
<td colspan="5" style="text-align: left;">
<ol style="list-style-type: lower-alpha;">
<li>Sebelum menjalankan cuti wajib menyarankan pekerjaannya kepada atasan langsungnya.</li>
<li>Setelah menjalankan cuti wajib melaporkan diri kepada atasan langsungnya dan bekerja sambil sebagaimana biasa.</li>
</ol>
</td>
</tr>
<tr>
<td colspan="5"> </td>
<td colspan="1"> </td>
</tr>
<tr>
<td colspan="1"> </td>
<td colspan="5" style="text-align: left;">Demikian surat cuti ini dibuat untuk dapat dipergunakan sebagaimana mestinya. </td>
</tr>
</table>
<br><br><br>
<table style="width: 100%; text-align: right;">
<tr>
<td style="width: 60%;"></td>
<td style="width: 40%; text-align: center;">
Kepala LPMP<br>
Provinsi Kalimantan Selatan<br>
<br><br><br><br>
Yuli Haryanto, SE, M.Si
NIP. 197607012000031002
</td>
</tr>
</table>
';
$pdf->WriteHTML($contents);
$filepath = 'public/';
$filename = 'surat-cuti-' . $data->id_cuti . '.' . $data->id_pegawai . '.pdf';
// ob_clean();
$pdf->Output($filepath . $filename, 'F');
$this->response([
'status' => true,
'message' => base_url($filepath . $filename)
], 200);
} else {
$this->response([
'status' => false,
'message' => 'Data cuti tidak ditemukan.'
], 200);
}
}
public function penugasan_post()
{
$row = $this->model->find('t_penugasan');
if ($row->num_rows() > 0) {
$this->response([
'status' => true,
'message' => $row->result_array()
], 200);
} else {
$this->response([
'status' => false,
'message' => 'Data penugasan tidak ditemukan.'
], 200);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment