adding pdf and phone number
This commit is contained in:
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
// header('Access-Control-Allow-Origin: *');
|
||||
// header('Access-Control-Allow-Methods: GET, POST, DELETE, PUT');
|
||||
// header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization');
|
||||
// header('Access-Control-Allow-Credentials: true');
|
||||
// header('Content-Type: application/json');
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
header('Access-Control-Allow-Methods: GET, POST, DELETE, PUT');
|
||||
header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization');
|
||||
header('Access-Control-Allow-Credentials: true');
|
||||
header('Content-Type: application/json');
|
||||
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
@ -58,8 +58,9 @@ class Api_server extends RestController
|
||||
if(count($cek_data) > 0){
|
||||
$this->response(['message' => 'NIK <i>'.$data['nik_karyawan'].'</i> telah terdaftar dalam sistem sebelumnya'], 400);
|
||||
}else{
|
||||
$this->model->qrcode_karyawan($data['nik_karyawan']);
|
||||
$this->model->insert('tb_karyawan',$data);
|
||||
$this->model->insert('tb_login',['username' => $data['nik_karyawan'],'password' => md5($data['nik_karyawan'])]);
|
||||
// $this->model->insert('tb_login',['username' => $data['nik_karyawan'],'password' => md5($data['nik_karyawan']),'nik_karyawan' => $data['nik_karyawan']]);
|
||||
$this->response(['message' => 'ok'], 200);
|
||||
}
|
||||
|
||||
@ -175,6 +176,19 @@ class Api_server extends RestController
|
||||
if (count($cek_data) > 0) {
|
||||
$cek_absensi = $this->model->tampil_data_where('tb_absensi',['bulan' => date('m'),'tahun' => date('Y')])->result();
|
||||
if(count($cek_absensi) > 0){
|
||||
$array_libur = ($cek_data[0]->detail != null) ? json_decode($cek_data[0]->detail,true) : null;
|
||||
$libur = false;
|
||||
$ket_libur = null;
|
||||
if ($array_libur != null){
|
||||
foreach ($array_libur as $key => $value) {
|
||||
if ($value['tanggal'] == date('Y-m-d')) {
|
||||
$libur = true;
|
||||
$ket_libur = $value['ket'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$array_absensi = json_decode($cek_absensi[0]->detail,true);
|
||||
$tanggal_ada = false;
|
||||
$nik_ada = false;
|
||||
@ -199,7 +213,11 @@ class Api_server extends RestController
|
||||
|
||||
}
|
||||
|
||||
if ($jam_keluar == true){
|
||||
if ($libur == true) {
|
||||
$this->response(['message' => $cek_data[0]->nama.' libur karena '. $ket_libur], 401);
|
||||
}
|
||||
|
||||
elseif ($jam_keluar == true){
|
||||
$this->response(['message' => $cek_data[0]->nama.' telah diabsensi masuk kerja dan pulang kerja pada hari ini'], 401);
|
||||
}
|
||||
elseif ($nik_ada == true) {
|
||||
@ -302,5 +320,20 @@ class Api_server extends RestController
|
||||
$this->response($cek_data, 200);
|
||||
}
|
||||
|
||||
function notifikasi_post(){
|
||||
$no_telpon = $this->post('no_telpon');
|
||||
|
||||
$cek_data = $this->model->tampil_data_keseluruhan('tb_notifikasi')->result();
|
||||
|
||||
if (count($cek_data) == 0) {
|
||||
$this->model->insert('tb_notifikasi',['no_telpon' => $no_telpon]);
|
||||
}else{
|
||||
$this->model->custom_query('UPDATE tb_notifikasi set no_telpon = '.$no_telpon);
|
||||
}
|
||||
|
||||
$this->response(['message' => $no_telpon], 200);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@ class Home extends CI_Controller {
|
||||
$row[] = $no;
|
||||
$row[] = $field->nik_karyawan;
|
||||
$row[] = $field->nama;
|
||||
$row[] = '<center><button type="button" onclick="detail_karyawan('.$field->nik_karyawan.','."'".$field->nama."'".')" class="btn btn-primary btn-circle btn-sm waves-effect waves-light"><i class="ico fa fa-edit"></i></button></center>';
|
||||
$row[] = '<center><button type="button" onclick="detail_karyawan('.$field->nik_karyawan.','."'".$field->nama."'".')" class="btn btn-primary btn-circle btn-sm waves-effect waves-light"><i class="ico fa fa-edit"></i></button> <button type="button" onclick="qrcode_karyawan('.$field->nik_karyawan.')" class="btn btn-info btn-circle btn-sm waves-effect waves-light"><i class="ico fa fa-qrcode"></i></button></center>';
|
||||
$data[] = $row;
|
||||
}
|
||||
|
||||
@ -274,6 +274,18 @@ class Home extends CI_Controller {
|
||||
|
||||
}
|
||||
|
||||
function notifikasi(){
|
||||
$cek_data = $this->model->tampil_data_keseluruhan('tb_notifikasi')->result();
|
||||
|
||||
if (count($cek_data) > 0) {
|
||||
$main['no_telpon'] = $cek_data[0]->no_telpon;
|
||||
}else{
|
||||
$main['no_telpon'] = '';
|
||||
}
|
||||
|
||||
$main['header'] = 'Halaman No Notifikasi';
|
||||
$this->load->view('home/menu/notifikasi', $main);
|
||||
}
|
||||
|
||||
function cetak($tahun = null, $bulan = null){
|
||||
if (is_numeric($bulan) && is_numeric($tahun)) {
|
||||
@ -413,6 +425,61 @@ class Home extends CI_Controller {
|
||||
redirect('/home/laporan');
|
||||
}
|
||||
}
|
||||
|
||||
function print_id_karyawan($nik_karyawan = null)
|
||||
{
|
||||
// print_r($this->uri->segment(3));
|
||||
|
||||
if ($nik_karyawan != null) {
|
||||
$cek_data = $this->model->tampil_data_where('tb_karyawan',array('nik_karyawan' => $nik_karyawan))->result();
|
||||
if (count($cek_data) > 0) {
|
||||
$this->model->qrcode_karyawan($nik_karyawan);
|
||||
$pdf = new TCPDF('P','mm',array(80,60));
|
||||
$pdf->setPrintHeader(false);
|
||||
$pdf->AddPage();
|
||||
// $pdf->Image(base_url('images/karyawan/'.$nik_karyawan.'.png'),5,7,30);
|
||||
|
||||
$html = '
|
||||
<style>
|
||||
|
||||
.ini {
|
||||
border-bottom: 1px dotted black;
|
||||
}
|
||||
|
||||
.ada {
|
||||
border-left: 1px solid black;border-bottom: 1px solid black;border-right: 1px solid black;border-top: 1px solid black;
|
||||
}
|
||||
|
||||
.tiada {
|
||||
border-left: 1px solid black;border-right: 1px solid black;border-top: 1px solid black;
|
||||
}
|
||||
|
||||
.tiada1 {
|
||||
border-left: 1px solid black;border-right: 1px solid black;
|
||||
}
|
||||
|
||||
</style>
|
||||
<table width="100%" style="font-size: 10px;">
|
||||
<tr>
|
||||
<td width="15%"></td>
|
||||
<td width="70%" align="center"><img src="'.base_url().'images/karyawan/'.$nik_karyawan.'.png" ></td>
|
||||
<td width="15%"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="15%"></td>
|
||||
<td width="70%" align="center">'.$cek_data[0]->nama.'</td>
|
||||
<td width="15%"></td>
|
||||
</tr>
|
||||
</table>
|
||||
';
|
||||
$pdf->writeHTML($html, true, false, true, false, '');
|
||||
$pdf->output();
|
||||
}else{
|
||||
redirect('/home');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function logout()
|
||||
{
|
||||
|
||||
@ -281,30 +281,30 @@ class Model extends CI_Model {
|
||||
return $ini;
|
||||
}
|
||||
|
||||
// function qrcode_buku($kode){
|
||||
// include "phpqrcode/qrlib.php";
|
||||
// $kode = $kode;
|
||||
function qrcode_karyawan($karyawan){
|
||||
include "phpqrcode/qrlib.php";
|
||||
|
||||
// // $PNG_TEMP_DIR = 'images/'.$kategori;
|
||||
|
||||
// $PNG_WEB_DIR = 'images/buku/';
|
||||
// $PNG_TEMP_DIR = 'images/'.$kategori;
|
||||
|
||||
$PNG_WEB_DIR = 'images/karyawan/';
|
||||
|
||||
// if (!file_exists($PNG_WEB_DIR))
|
||||
// mkdir($PNG_WEB_DIR);
|
||||
if (!file_exists($PNG_WEB_DIR))
|
||||
mkdir($PNG_WEB_DIR);
|
||||
|
||||
// $errorCorrectionLevel = 'H';
|
||||
$errorCorrectionLevel = 'H';
|
||||
|
||||
// $matrixPointSize = 10;
|
||||
$matrixPointSize = 10;
|
||||
|
||||
// $filename =$PNG_WEB_DIR.md5($kode).'.png';
|
||||
// QRcode::png($kode, $filename, $errorCorrectionLevel, $matrixPointSize, 2);
|
||||
$filename =$PNG_WEB_DIR.$karyawan.'.png';
|
||||
QRcode::png($karyawan, $filename, $errorCorrectionLevel, $matrixPointSize, 2);
|
||||
|
||||
// if (file_exists($PNG_WEB_DIR.md5($kode).'.png') > 0) {
|
||||
// return "ada";
|
||||
// }else{
|
||||
// return "tiada";
|
||||
// }
|
||||
// }
|
||||
if (file_exists($PNG_WEB_DIR.$karyawan.'.png') > 0) {
|
||||
return "ada";
|
||||
}else{
|
||||
return "tiada";
|
||||
}
|
||||
}
|
||||
|
||||
function cek_last_ai($tables){
|
||||
return $this->db->query("SELECT `AUTO_INCREMENT` as no
|
||||
|
||||
@ -4,8 +4,8 @@
|
||||
<button type="button" class="button-close fa fa-times js__menu_close"></button>
|
||||
<div class="user">
|
||||
<a href="#" class="avatar"><img src="<?=base_url()?>/assets/images/admin.png" alt=""><span class="status online"></span></a>
|
||||
<h5 class="name"></h5>
|
||||
<h5 class="position"></h5>
|
||||
<h5 class="name">Admin</h5>
|
||||
<h5 class="position">Admin</h5>
|
||||
<!-- /.name -->
|
||||
|
||||
</div>
|
||||
@ -30,6 +30,9 @@
|
||||
<li <?php if ($this->uri->segment(2) == "laporan"): ?>class="current"<?php endif ?>>
|
||||
<a class="waves-effect" href="<?=base_url()?>home/laporan"><i class="menu-icon zmdi zmdi-storage"></i><span>Laporan Absensi</span></a>
|
||||
</li>
|
||||
<li <?php if ($this->uri->segment(2) == "notifikasi"): ?>class="current"<?php endif ?>>
|
||||
<a class="waves-effect" href="<?=base_url()?>home/notifikasi"><i class="menu-icon fa fa-phone"></i><span>No Telpon Notifikasi</span></a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
<!-- /.menu js__accordion -->
|
||||
|
||||
@ -243,7 +243,7 @@
|
||||
|
||||
block_ui()
|
||||
},
|
||||
success: function (response) {
|
||||
success: function (response) {
|
||||
$('#sini_form')[0].reset();
|
||||
$('#table_list_karyawan').dataTable().fnDestroy();
|
||||
datatables()
|
||||
@ -263,10 +263,8 @@
|
||||
timer : 3000
|
||||
// dangerMode: true,
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
qrcode_karyawan(nik_karyawan)
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
// console.log(errorThrown)
|
||||
@ -574,6 +572,18 @@
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
async function qrcode_karyawan(nik_karyawan){
|
||||
let html = await `<div class="row small-spacing">
|
||||
<div class="col-lg-12 col-xs-12" style="overflow-x: auto; ">
|
||||
<iframe src="${url}home/print_id_karyawan/${nik_karyawan}" width="100%" height="450px"></iframe>
|
||||
</div>
|
||||
</div>`
|
||||
|
||||
await $("#sini_modalnya .modal-body").html(html)
|
||||
|
||||
await $('#sini_modalnya').modal('show');
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
@ -51,8 +51,8 @@
|
||||
</thead> -->
|
||||
|
||||
</table>
|
||||
<hr>
|
||||
<center><button type="button" class="btn btn-primary btn-sm waves-effect waves-light" onclick="cetak_laporan()">Cetak Laporan</button></center>
|
||||
<!-- <hr>
|
||||
<center><button type="button" class="btn btn-primary btn-sm waves-effect waves-light" onclick="cetak_laporan()">Cetak Laporan</button></center> -->
|
||||
</div>
|
||||
<!-- /.card-content -->
|
||||
</div>
|
||||
@ -240,7 +240,7 @@
|
||||
await $("#sini_modalnya .modal-header .modal-title").html(`Laporan Bulan ${$("#val_bulan").val()} , Tahun ${$("#val_tahun").val()}`)
|
||||
await $("#sini_modalnya .modal-dialog").attr('class','modal-dialog modal-lg')
|
||||
|
||||
console.log(``)
|
||||
// console.log(``)
|
||||
let html = await `<div class="row small-spacing">
|
||||
<div class="col-lg-12 col-xs-12" style="overflow-x: auto; ">
|
||||
<iframe src="${url}home/cetak/${$("#val_tahun").val()}/${$("#val_bulan").val()}" title="W3Schools Free Online Web Tutorials" width="100%" height="600px"></iframe>
|
||||
|
||||
@ -259,8 +259,19 @@
|
||||
},
|
||||
success: function (response) {
|
||||
$.unblockUI();
|
||||
console.log(response)
|
||||
|
||||
// console.log(response)
|
||||
swal({
|
||||
title : "Sukses",
|
||||
text: "Libur Berhasil Ditambah ",
|
||||
icon: "success",
|
||||
buttons: {
|
||||
cancel: false,
|
||||
confirm: true,
|
||||
},
|
||||
timer : 3000
|
||||
// dangerMode: true,
|
||||
})
|
||||
$('#sini_modalnya').modal('hide');
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
// console.log(errorThrown)
|
||||
@ -272,6 +283,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function qrcode_karyawan(nik_karyawan){
|
||||
let html = await `<div class="row small-spacing">
|
||||
<div class="col-lg-12 col-xs-12" style="overflow-x: auto; ">
|
||||
<iframe src="${url}home/print_id_karyawan/${nik_karyawan}" width="100%" height="450px"></iframe>
|
||||
</div>
|
||||
</div>`
|
||||
|
||||
await $("#sini_modalnya .modal-body").html(html)
|
||||
|
||||
await $('#sini_modalnya').modal('show');
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
147
application/views/home/menu/notifikasi.php
Normal file
147
application/views/home/menu/notifikasi.php
Normal file
@ -0,0 +1,147 @@
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
|
||||
<?php $this->load->view('home/head');?>
|
||||
|
||||
<link rel="stylesheet" href="<?=base_url()?>assets/plugin/datatables/media/css/dataTables.bootstrap.min.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<?php $this->load->view('home/header');?>
|
||||
|
||||
<div class="modal fade" id="sini_modalnya" role="dialog">
|
||||
<div class="modal-dialog ">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||
<h4 class="modal-title">Modal Header</h4>
|
||||
</div>
|
||||
<div class="modal-body row">
|
||||
<p>This is a small modal.</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="wrapper">
|
||||
<div class="main-content">
|
||||
<div class="row small-spacing">
|
||||
|
||||
<div class="col-lg-2 col-md-2 col-xs-12"></div>
|
||||
<input type="hidden" id="sini_no_telpon" value="<?=$no_telpon?>">
|
||||
<div class="col-lg-8 col-md-8 col-xs-12">
|
||||
<div class="box-content card">
|
||||
<h4 class="box-title" style="background: #0055FF ;cursor: pointer;" onclick="myFunction('div_notifikasi')">No Telpon Notifikasi</h4>
|
||||
<!-- /.box-title -->
|
||||
<div class="card-content" style="overflow-x: auto;" id="div_notifikasi">
|
||||
<form id="sini_form">
|
||||
<div class="form-group">
|
||||
<label for="exampleInputEmail1">No Telpon Notifikasi</label>
|
||||
<input type="text" class="form-control" id="no_telpon" name="no_telpon" placeholder="Masukkan No Telpon Notifikasi" maxlength="13" onkeypress="return isNumberKey(event)" value="<?=$no_telpon?>" >
|
||||
</div>
|
||||
|
||||
|
||||
<center><button type="button" class="btn btn-primary btn-sm waves-effect waves-light" onclick="tambah_notifikasi()">Tambah / Edit No Telpon</button></center>
|
||||
</form>
|
||||
</div>
|
||||
<!-- /.card-content -->
|
||||
</div>
|
||||
<!-- /.box-content -->
|
||||
</div>
|
||||
<div class="col-lg-2 col-md-2 col-xs-12"></div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<?php $this->load->view('home/footer');?>
|
||||
|
||||
</div>
|
||||
<!-- /.main-content -->
|
||||
</div><!--/#wrapper -->
|
||||
|
||||
<?php $this->load->view('home/script'); ?>
|
||||
|
||||
<!-- <script src="<?=base_url()?>assets/plugin/datatables/media/js/jquery.dataTables.min.js"></script> -->
|
||||
<!-- <script src="<?=base_url()?>assets/plugin/datatables/media/js/dataTables.bootstrap.min.js"></script> -->
|
||||
|
||||
<script async="">
|
||||
async function tambah_notifikasi(){
|
||||
|
||||
let no_telpon = $("#no_telpon").val();
|
||||
|
||||
if(no_telpon == ''){
|
||||
toastnya('Nomor Telpon Harus Terisi');
|
||||
$("#no_telpon").focus();
|
||||
}
|
||||
else if(no_telpon.length < 10){
|
||||
toastnya('Panjang Nomor Telpon Minimal 10 Karakter');
|
||||
$("#no_telpon").focus();
|
||||
}else{
|
||||
// console.log($("#sini_no_telpon").val())
|
||||
let ada_nom = ($("#sini_no_telpon").val() != '') ? true : false
|
||||
|
||||
|
||||
|
||||
swal({
|
||||
title : (ada_nom) ? `Update Nomor` : `Tambah Nomor`,
|
||||
text: (ada_nom) ? `Update Nomor Notifkasi Dari ${$("#sini_no_telpon").val()} kepada ${no_telpon}` : `Tambah Nomor ${no_telpon}`,
|
||||
icon: "info",
|
||||
buttons: {
|
||||
cancel: false,
|
||||
confirm: true,
|
||||
},
|
||||
// timer : 3000
|
||||
// dangerMode: true,
|
||||
})
|
||||
.then((hehe) => {
|
||||
if (hehe) {
|
||||
$.ajax({
|
||||
url: url+"api_server/notifikasi",
|
||||
type: 'post',
|
||||
data: {no_telpon : no_telpon},
|
||||
beforeSend: function(res) {
|
||||
|
||||
block_ui()
|
||||
},
|
||||
success: (response) => {
|
||||
console.log(response);
|
||||
$.unblockUI();
|
||||
$("#sini_no_telpon").val(no_telpon)
|
||||
swal({
|
||||
title : "Sukses",
|
||||
text: "No Telpon Notifikasi Berhasil Ditambah / Diupdate ",
|
||||
icon: "success",
|
||||
buttons: {
|
||||
cancel: false,
|
||||
confirm: true,
|
||||
},
|
||||
timer : 3000
|
||||
// dangerMode: true,
|
||||
})
|
||||
|
||||
},
|
||||
error: function(XMLHttpRequest, textStatus, errorThrown) {
|
||||
// console.log(errorThrown)
|
||||
bad_request(errorThrown,JSON.parse(XMLHttpRequest.responseText).message,'no_telpon')
|
||||
$.unblockUI();
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user