Files
simrs-jatim/keuangan/form_addtarifnonreg.php
2024-04-19 14:04:41 +07:00

458 lines
15 KiB
PHP

<?php
$ss = $db->query('SELECT * FROM m_shift order by idshift ASC');
$arr_shift = array(''=>'Pilih Shift');
foreach($ss->fetchAll() as $ds){
$arr_shift[$ds['idshift']] = $ds['nama_shift'];
}
$ss = $db->query('SELECT * FROM m_unit order by nama_unit ASC');
$arr_tempat = array(''=>'Pilih Tempat');
foreach($ss->fetchAll() as $ds){
$arr_tempat[$ds['kode_unit']] = $ds['nama_unit'];
}
$ss = $db->query('SELECT * FROM m_carabayar where aktif = 1 order by kode ASC');
$arr_carabayar = array(''=>'Pilih Carabayar');
foreach($ss->fetchAll() as $ds){
$arr_carabayar[$ds['kode']] = $ds['nama'];
}
$ss = $db->query('SELECT * FROM m_ruang where st_aktif = 1 order by no ASC');
$arr_ruang = array(''=>'Pilih Ruang/Klinik');
foreach($ss->fetchAll() as $ds){
if($ds['kelompok'] == 'IRJA') {
$arr_ruang[$ds['no']] = $ds['nama'];
}
else {
$arr_ruang[$ds['no']] = $ds['nama'].' '.$ds['kelas'];
}
}
array_push($form_plugin['ui_plugins_js'],$floatthead_js);
array_push($form_plugin['ui_plugins_js'],$sweetalert_js);
array_push($form_plugin['ui_plugins_js'],$jspm_js);
?>
<style type="text/css">
.tt-hint {
height: calc(1.8125rem + 2px) !important;
padding: .25rem .5rem !important;
font-size: .875rem !important;
}
</style>
<div class="container-fluid">
<div class="row">
<div class="col-md-6">
<div class="card">
<div class="card-header">Identitas Pasien</div>
<div class="card-body">
<form id="frm_identitas">
<input type="hidden" name="st_rajal" value="" id="st_rajal">
<input type="hidden" name="st_aps" value="" id="st_aps">
<input type="hidden" name="idxdaftar" value="" id="idxdaftar">
<input type="hidden" name="tempat" value="" id="tempat">
<input type="hidden" name="unit" value="<?php echo $_SESSION['KDUNIT']; ?>" id="unit">
<div class="form-group row">
<label class="col-sm-4">No Billing</label>
<div class="col-sm-8">
<input type="text" name="input[nobill]" value="" class="form-control form-control-sm mask-decimal" id="nobill">
</div>
</div>
<div class="form-group row">
<label class="col-sm-4">No MR</label>
<div class="col-sm-8">
<input type="text" name="input[nomr]" value="" class="form-control form-control-sm" id="nomr" readonly="true">
</div>
</div>
<div class="form-group row">
<label class="col-sm-4">Nama Pasien</label>
<div class="col-sm-8">
<input type="text" name="input[nama]" value="" class="form-control form-control-sm" id="nama" readonly="true">
</div>
</div>
<div class="form-group row">
<label class="col-sm-4">Alamat</label>
<div class="col-sm-8">
<input type="text" name="input[alamat]" value="" class="form-control form-control-sm" id="alamat" readonly="true">
</div>
</div>
<div class="form-group row">
<label class="col-sm-4">No Telepon</label>
<div class="col-sm-8">
<input type="text" name="input[no_telepon]" value="" class="form-control form-control-sm" id="no_telepon" readonly="true">
</div>
</div>
<div class="form-group row">
<label class="col-sm-4">Tempat Layanan</label>
<div class="col-sm-8">
<input type="text" name="input[tempat_layanan]" value="" class="form-control form-control-sm" id="tempat_layanan" readonly="true">
</div>
</div>
<div class="form-group row">
<label class="col-sm-4">DPJP</label>
<div class="col-sm-8">
<input type="text" name="dpjp" value="" class="form-control form-control-sm" id="dpjp" readonly="true">
</div>
</div>
</form>
</div>
<!-- <div class="card-footer text-right">
<button class="btn btn-primary" type="button" onclick="simpanIdentitas()"><i class="fa fa-hdd-o"></i> Tambah</button>
</div> -->
</div>
</div>
<div class="col-md-6">
<div class="card">
<div class="card-header">Tarif Tindakan</div>
<div class="card-body">
<form id="frm_tarif">
<input type="hidden" name="noitem" value="1" id="noitem">
<input type="hidden" name="id_tarif" value="" id="id_tarif">
<input type="hidden" name="petugas" value="<?php echo $_SESSION['NIP']; ?>" id="petugas">
<div class="form-group row">
<label class="col-sm-4">Jenis Cara Bayar</label>
<div class="col-sm-8">
<?php echo form_dropdown('jenis_bayar',$arr_carabayar,'','class="form-control form-control-sm" id="jenis_bayar"'); ?>
</div>
</div>
<div class="form-group row">
<label class="col-sm-4">Unit Layanan</label>
<div class="col-sm-8">
<?php echo form_dropdown('tempat_layanan_tarif',$arr_tempat,'','class="form-control form-control-sm" id="tempat_layanan_tarif"'); ?>
</div>
</div>
<div class="form-group row">
<label class="col-sm-4">Tempat Layanan</label>
<div class="col-sm-8">
<?php echo form_dropdown('ruang',$arr_ruang,'','class="form-control form-control-sm" id="ruang"'); ?>
</div>
</div>
<div class="form-group row">
<label class="col-sm-4">Tanggal</label>
<div class="col-sm-8">
<input type="text" name="tanggal" value="<?php echo date('Y-m-d'); ?>" class="form-control form-control-sm datepicker-default mask-date-default" id="tanggal">
</div>
</div>
<div class="form-group row">
<label class="col-sm-4">Kode Tarif</label>
<div class="col-sm-8">
<input type="text" name="kode_tarif" value="" class="form-control form-control-sm" id="kode_tarif">
</div>
</div>
<div class="form-group row">
<label class="col-sm-4">Uraian Tarif</label>
<div class="col-sm-8">
<input type="text" name="uraian_tarif" value="" class="form-control form-control-sm" id="uraian_tarif" readonly="true">
</div>
</div>
<div class="form-group row">
<label class="col-sm-4">Jumlah Tagihan</label>
<div class="col-sm-8">
<input type="text" name="jumlah_tagihan" value="" class="mask-decimal form-control form-control-sm" id="jumlah_tagihan">
<input type="hidden" name="jasa_sarana" value="" id="jasa_sarana">
<input type="hidden" name="jasa_pelayanan" value="" id="jasa_pelayanan">
<input type="hidden" name="jasa_anastesi" value="" id="jasa_anastesi">
</div>
</div>
<div id="dpjp_wrapper">
</div>
</form>
</div>
<div class="card-footer text-right">
<button class="btn btn-success" type="button" onclick="addItem()"><i class="fa fa-plus"></i> Tambah</button>
<button class="btn btn-primary" type="button" onclick="simpan()"><i class="fa fa-tasks"></i> Simpan</button>
</div>
</div>
</div>
</div>
<hr>
<div class="row"><div class="col-sm-12">
<form id="form_billing">
<div class="wrapper" style="overflow:auto;height:360px">
<table class="table table-bordered table-striped table-sm" id="table_tarif">
<thead>
<tr class="bg-success text-white">
<th style="width:5%">No</th>
<th style="width:10%">Kode Tarif</th>
<th style="width:25%">Uraian</th>
<th style="width:10%">Jumlah</th>
<th style="width:5%">Aksi</th>
</tr>
</thead>
<tbody>
</tbody>
<tfoot>
<tr class="table-info"><td colspan="3" class="text-right">Jumlah</td>
<td id="jumlah_total"></td>
<td></td>
</tr>
</tfoot>
</table>
</div>
</form>
</div></div>
</div>
</div>
</div>
<?php
$js_init = $jspm_rawprint;
$js_init .= $jspm_init;
$js_init .= '
$(document).ready(function() {
async function load_kode_tarif() {
const kode_tarif = await new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace("text"),
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
url : "'._BASE_.'keuangan/addtarif.php?page=load_kode_tarif&kode=%QUERY",
wildcard: "%QUERY"
}
});
$("#kode_tarif").typeahead({hint: true, highlight: true, minLength: 1 },{
name: "kode_tarif",
display: "text",
source: kode_tarif,
limit: 10
}).on("typeahead:selected typeahead:autocompleted typeahead:matched", function (ev, datum) {
$("#id_tarif").val(datum.id_tarif).prop("readonly",true);
$("#uraian_tarif").val(datum.uraian_tarif).prop("readonly",true);
$("#jasa_pelayanan").val(datum.jasa_pelayanan);
$("#jasa_sarana").val(datum.jasa_sarana);
$("#jasa_anastesi").val(datum.jasa_anastesi);
if(datum.jumlah > 0) {
$("#jumlah_tagihan").val(datum.jumlah).prop("readonly",true);
if(datum.dpjp != false) {
$("#dpjp_wrapper").html(datum.dpjp);
$("select").select2();
}
else {
$("#dpjp_wrapper").html("");
}
}
else {
$("#jumlah_tagihan").val(datum.jumlah).prop("readonly",false);
$("#dpjp_wrapper").html("");
}
});
}
load_kode_tarif();
$("#tempat_layanan_tarif").on("change",function(){
this_unit = $(this).find(":selected").val();
$("#unit").val(this_unit);
});
$("#tempat_layanan_tarif").trigger("change");
$("#ruang").on("change",function(){
this_ruang = $(this).find(":selected").val();
$("#tempat").val(this_ruang);
});
$("#ruang").trigger("change");
});
function printRaw(nonota) {
$.post("'._BASE_.'print_nota_nonregister.php",{nonota,raw:1},function(print_command){
jspm_print_raw(print_command);
});
}
function print_tindakan(nomor)
{
jspm_print("'._BASE_.'print_nota_nonregister.php?nonota="+nomor,"modal-preview","Nota Tagihan Non Register.pdf",0);
$("#modal-preview").on("hidden.bs.modal",function(e){ window.location.reload(); });
cek_tombol_cetak = $("#cetak_raw").length;
if(cek_tombol_cetak > 0) {
$("#cetak_raw").remove();
}
$("#modal-preview .modal-footer").append("<button type=\"button\" id=\"cetak_raw\" class=\"btn btn-primary\" onclick=\"printRaw("+nomor+")\"><i class=\"fa fa-print\"></i> Cetak</button>");
}
const Toast = Swal.mixin({
toast: true,
position: "top-end",
showConfirmButton: false,
timer: 3000
});
$("#nobill").trigger("focus");
$("#nobill").focus();
$("#nobill").on("keypress",function(e){
if(e.which == 13 || e.keyCode == 13)
{
e.preventDefault();
cari();
}
});
$("#kode_tarif").on("keypress",function(e){
if(e.which == 13 || e.keyCode == 13)
{
e.preventDefault();
}
});
function cari() {
$("#nomr,#nama,#alamat,#no_telepon").val("");
$.post("'._BASE_.'keuangan/addtarif.php?page=cari_nonreg",$("#frm_identitas").serialize(),function(data)
{
if(data.type != undefined) {
Toast.fire({title:data.message,type:data.type});
}
else {
$("#nomr").val(data.nomr).prop("readonly",true);
$("#nama").val(data.nama).prop("readonly",true);
$("#alamat").val(data.alamat).prop("readonly",true);
$("#no_telepon").val(data.notelp).prop("readonly",true);
$("#tempat_layanan").val(data.tempat_layanan).prop("readonly",true);
/*$("#kode_tarif").trigger("focus");*/
$("#tempat_layanan_tarif").trigger("focus");
$("#st_rajal").val(data.st_rajal);
$("#idxdaftar").val(data.idxdaftar);
$("#tempat").val(data.kode_tempat);
$("#dpjp").val(data.dpjp);
$("#st_aps").val(data.st_aps);
}
},"json");
}
function cari_tarif() {
$("#uraian_tarif,#jumlah_tagihan").val("");
$.post("'._BASE_.'keuangan/addtarif.php?page=cari_tarif",$("#frm_tarif").serialize(),function(data)
{
if(data.type != undefined) {
Toast.fire({title:data.message,type:data.type});
$("#jumlah_tagihan").prop("readonly",false);
}
else {
$("#id_tarif").val(data.tarif.id_tarif).prop("readonly",true);
$("#uraian_tarif").val(data.tarif.uraian_tarif).prop("readonly",true);
$("#jasa_pelayanan").val(data.tarif.jasa_pelayanan);
$("#jasa_sarana").val(data.tarif.jasa_sarana);
$("#jasa_anastesi").val(data.tarif.jasa_anastesi);
if(data.tarif.jumlah > 0) {
$("#jumlah_tagihan").val(data.tarif.jumlah).prop("readonly",true);
if(data.dpjp != false) {
$("#dpjp_wrapper").html(data.dpjp);
$("select").select2();
$("#dpjp_pelayanan").val(2).trigger("change");
}
else {
$("#dpjp_wrapper").html("");
}
}
else {
$("#jumlah_tagihan").val(data.tarif.jumlah).prop("readonly",false);
$("#dpjp_wrapper").html("");
}
}
},"json");
}
var arr_item = [];
var noitem = 1;
function addItem() {
id_tarif = $("#id_tarif").val();
dpjp = $("#dpjp_pelayanan").val();
if(dpjp == "") {
Toast.fire({title:"Pilih DPJP dahulu!",type:"error"});
}
else if(id_tarif != "") {
$.post("'._BASE_.'keuangan/addtarif.php?page=add_item",$("#frm_tarif").serialize(),function(data){
// if($.inArray(data.kode_tarif,arr_item) > -1 ) {
// Toast.fire({title:"Tarif sudah ditambahkan",type:"error"});
// }
// else {
$("#table_tarif tbody").append(data.rowitem);
arr_item.push(noitem);
noitem += 1;
$("#noitem").val(noitem);
/*$("#frm_tarif").trigger("reset");*/
$("#dpjp_wrapper").html("");
$("#id_tarif").val("");
hitung_total();
// }
},"json");
}
else {
Toast.fire({title:"Masukkan kode terif yang benar",type:"error"});
}
}
function hitung_total() {
total = 0;
$("#table_tarif .nominal_tarif").each(function(k,v){
total += parseFloat($(v).val());
});
$("#jumlah_total").html("<span class=\"\">Rp. "+accounting.formatMoney(total)+"</span>");
}
function remItem(elm) {
var item = $(elm).data("noitem");
for( i = 0; i < arr_item.length; i++) {
if(arr_item[i] == item) {
arr_item.splice(i,1);
}
}
$(elm).parent().parent().remove();
hitung_total();
}
function simpan() {
nama = $("#nama").val();
alamat = $("#alamat").val();
no_telepon = $("#no_telepon").val();
st_aps = $("#st_aps").val();
lolos_cek = true;
/* billing field */
tempat = $("#tempat").val();
unit = $("#unit").val();
tanggal = $("#tanggal").val();
carabayar = $("#jenis_bayar").find(":selected").val();
if(nama == "" || alamat == "" || no_telepon == "") {
Toast.fire({title:"Identitas belum terisi dengan lengkap",type:"error"});
}
else if(arr_item.length == 0) {
Toast.fire({title:"Belum terdapat tarif, tambahkan tarif terlebih dahulu",type:"error"});
}
else if(tempat == "") {
Toast.fire({title:"Belum memilih Tempat Layanan",type:"error"});
}
else if(unit == "") {
Toast.fire({title:"Belum memilih Unit Layanan",type:"error"});
}
else if(tanggal == "") {
Toast.fire({title:"Belum memilih Tanggal",type:"error"});
}
else if(carabayar == "") {
Toast.fire({title:"Belum memilih Cara Bayar",type:"error"});
}
else {
form_identitas = $("#frm_identitas").serialize();
form_billing = $("#form_billing").serialize();
$.post("'._BASE_.'keuangan/addtarif.php?page=billing_nonreg",form_identitas+"&"+form_billing+"&tanggal="+tanggal+"&jenis_bayar="+carabayar,function(data){
if(data.type == "error") {
Toast.fire({title:data.message,type:data.type});
}
else {
Toast.fire({title:data.message,type:data.type,onClose : function() {
print_tindakan(data.nonota);
reset_form();
}});
}
},"json");
}
}
function reset_form() {
$("#frm_identitas").trigger("reset");
$("#nama,#alamat,#no_telepon,#tempat_layanan").prop("readonly",false);
$("#frm_tarif").trigger("reset");
$("#jumlah_tagihan").prop("readonly",false);
$("#dpjp_wrapper").html("");
arr_item = [];
noitem = 1;
$("#table_tarif tbody").html("");
hitung_total();
}
';
?>