ubah ke docker mode
This commit is contained in:
No files matched your search
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\User;
|
||||
use App\Pegawai;
|
||||
use App\Periksa;
|
||||
use App\ResultSample;
|
||||
|
||||
use Session;
|
||||
use Auth;
|
||||
use Validator;
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
public function login() {
|
||||
$data = [];
|
||||
$previlage = Session('previlage');
|
||||
if ($previlage == '' OR $previlage === null) {
|
||||
$getdomain = url()->current();
|
||||
$data['getdomain'] = $getdomain;
|
||||
return view('login', $data);
|
||||
} else {
|
||||
return redirect('/');
|
||||
}
|
||||
}
|
||||
public function authenticate(Request $request) {
|
||||
$validator = Validator::make($request->all(), [
|
||||
'username' => 'required',
|
||||
'password' => 'required',
|
||||
]);
|
||||
|
||||
if($validator->fails()) {
|
||||
Session::flash('message', 'Username dan Password Harus diisi');
|
||||
return back();
|
||||
} else {
|
||||
$username = $request->username;
|
||||
$password = $request->password;
|
||||
$firebaseid = $request->firebaseid;
|
||||
if (is_null($firebaseid)){ $firebaseid = ''; }
|
||||
$auth = Auth::attempt([
|
||||
'username' => $username,
|
||||
'password' => $password
|
||||
]);
|
||||
|
||||
if(!$auth) {
|
||||
$cekada = User::whereNotNull('username')->count();
|
||||
if ($cekada == 0){
|
||||
User::create([
|
||||
'nama' => 'Administrator',
|
||||
'username' => 'admin',
|
||||
'password' => bcrypt('semangat'),
|
||||
'previlage' => 'developer'
|
||||
]);
|
||||
}
|
||||
Session::flash('message', 'Username atau password anda salah');
|
||||
return back();
|
||||
}
|
||||
$user = Auth::user();
|
||||
$photo = $user->getPhoto->xfile ?? '/doctor.png';
|
||||
if ($firebaseid != ''){
|
||||
User::where('username', $request->username)->update([
|
||||
'firebase' => $firebaseid
|
||||
]);
|
||||
}
|
||||
|
||||
Session::put('id', $user->id);
|
||||
Session::put('nama', $user->nama);
|
||||
Session::put('username', $user->username);
|
||||
Session::put('previlage', $user->previlage);
|
||||
Session::put('photo', $photo);
|
||||
Session::save();
|
||||
User::where('id', $user->id)->update([
|
||||
'active_status' => 1,
|
||||
]);
|
||||
return redirect('/');
|
||||
}
|
||||
}
|
||||
public function cekandroid($firebaseid){
|
||||
$cekperiksa = Periksa::all();
|
||||
if (!empty($cekperiksa)){
|
||||
$tahun = date('y');
|
||||
$getdata = ResultSample::where('accession_number', 'LIKE', $tahun.'.%')->get();
|
||||
foreach($getdata as $rows){
|
||||
$norm = $rows->patient_id;
|
||||
$nama2 = $rows->patient_name_last;
|
||||
$nama1 = $rows->patient_name_first;
|
||||
$nama = $nama1.' '.$nama2;
|
||||
$alamat = $rows->address_street;
|
||||
$nofoto = $rows->accession_number;
|
||||
|
||||
Pasien::updateOrCreate(
|
||||
[
|
||||
'norm' => $norm,
|
||||
],
|
||||
[
|
||||
'nama' => $nama,
|
||||
'jk' => $jk,
|
||||
'tgl_lahir' => $tgllahir,
|
||||
'kota' => config('global.subdomainapps'),
|
||||
'telpon' => $telpon,
|
||||
'alamat' => $alamat,
|
||||
'nik' => $nik,
|
||||
'bpjs' => $bpjs,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
$cekuser = User::where('firebase', $firebaseid)->count();
|
||||
if ($cekuser != 0){
|
||||
$user = User::where('firebase', $firebaseid)->first();
|
||||
$photo = $user->getPhoto->xfile ?? '/doctor.png';
|
||||
Session::put('id', $user->id);
|
||||
Session::put('nama', $user->nama);
|
||||
Session::put('username', $user->username);
|
||||
Session::put('previlage', $user->previlage);
|
||||
Session::put('photo', $photo);
|
||||
Session::save();
|
||||
User::where('id', $user->id)->update([
|
||||
'active_status' => 1,
|
||||
]);
|
||||
return redirect('/');
|
||||
|
||||
} else {
|
||||
Session::flash('message', 'Firebase ID Not Saved, Please Login');
|
||||
Session::flash('status', $firebaseid);
|
||||
return redirect('/login');
|
||||
}
|
||||
}
|
||||
public function logout(Request $request) {
|
||||
Auth::logout();
|
||||
$request->session()->regenerate();
|
||||
$request->session()->flush();
|
||||
session()->flush();
|
||||
return redirect('/');
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,264 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Poli;
|
||||
use App\Periksa;
|
||||
use App\Dokter;
|
||||
use App\Ruangan;
|
||||
use App\Subjawaban;
|
||||
use App\Jawaban;
|
||||
use App\Pasien;
|
||||
use App\User;
|
||||
use App\Jadwalperiksa;
|
||||
use Carbon\Carbon;
|
||||
use DateTime;
|
||||
use Session;
|
||||
|
||||
class ListController extends Controller
|
||||
{
|
||||
public function index() {
|
||||
if (Session::get('previlage') == ''){
|
||||
return redirect('/login');
|
||||
} else {
|
||||
$polis = Poli::all();
|
||||
$ruangans = Ruangan::all();
|
||||
$dokters = Dokter::all();
|
||||
$answers = Jawaban::all();
|
||||
$details = Subjawaban::all();
|
||||
$ruangpolis = Ruangan::groupBy('poli')->select('poli')->get();
|
||||
$data = [];
|
||||
$i = 0;
|
||||
foreach ($ruangpolis as $ruangpoli) {
|
||||
$j = 0;
|
||||
$ruangpoli = $ruangpoli->poli;
|
||||
$rooms = Ruangan::where('poli', $ruangpoli)->get();
|
||||
foreach ($rooms as $room) {
|
||||
$data['ruangans'][$i][$j]['id'] = $room->id;
|
||||
$data['ruangans'][$i][$j]['ruangan'] = $room->ruangan;
|
||||
$j++;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
$x = 0;
|
||||
foreach ($ruangpolis as $ruangpoli) {
|
||||
$data['ruangpolis'][$x] = $ruangpoli->poli;
|
||||
$x++;
|
||||
}
|
||||
|
||||
$data['polis'] = $polis;
|
||||
$data['dokters'] = $dokters;
|
||||
$data['answers'] = $answers;
|
||||
$data['details'] = $details;
|
||||
|
||||
return view('admin.list', $data);
|
||||
}
|
||||
|
||||
}
|
||||
public function getList(Request $request) {
|
||||
$jenis = $request->input('jenis');
|
||||
$mulai = $request->input('mulai');
|
||||
$akhir = $request->input('akhir');
|
||||
$lokasi = $request->input('poli');
|
||||
$valcari = $request->input('valcari');
|
||||
$master = $request->input('master');
|
||||
if ($jenis == 'verificationppds'){
|
||||
$valcari = $request->input('poli');
|
||||
}
|
||||
$total = 0;
|
||||
$data = $this->getDataBasedOnMaster($master, $jenis, $mulai, $akhir, $valcari);
|
||||
if (!empty($data)){
|
||||
$dataArray = $data->get()->toArray();
|
||||
$total = count($dataArray);
|
||||
$arraylist = array_map(function ($list) use ($master) {
|
||||
$tgl = $list['tgllahirpasien'];
|
||||
$poli_id = $list['poli_id'];
|
||||
$foto = $list['foto'];
|
||||
$baca = $list['baca'];
|
||||
$export = $list['export'];
|
||||
$nofoto = $list['nofoto'];
|
||||
$noregister = $list['noregister'];
|
||||
$usia = $list['usia'];
|
||||
$urgensi = $list['urgensi'];
|
||||
$reques = $list['reques'];
|
||||
$ruangan = $list['ruangan'];
|
||||
$daftar = $list['daftar'];
|
||||
$status = $list['status'];
|
||||
$asalpasien = $list['asalpasien'];
|
||||
$dokter_id = $list['dokter_id'];
|
||||
$ppdssenior = $list['ppdssenior'];
|
||||
$middleppds = $list['middleppds'];
|
||||
$ppdsjunior = $list['ppdsjunior'];
|
||||
$middleppds2= $list['ppdsmiddle2'];
|
||||
$ppdsjunior2= $list['ppdsjunior2'];
|
||||
$pasiedin = $list['pasien_id'];
|
||||
$keterangan = $list['keterangan'];
|
||||
$kesimpulan = $list['kesimpulan'];
|
||||
$verifikasi = $list['verifikasi'];
|
||||
$nama = $list['nmpasien'];
|
||||
$jk = $list['jkpasien'];
|
||||
$telpon = $list['tlppasien'];
|
||||
$alamat = $list['alamatpasien'];
|
||||
$tgllahir = $list['tgllahirpasien'];
|
||||
$ktp = $list['ktp'];
|
||||
$bpjs = $list['bpjs'];
|
||||
$nmpendaftar= $list['pendaftar'];
|
||||
if ($nmpendaftar == 'supervisor' OR $nmpendaftar == 'admin' OR $nmpendaftar == 'analis' OR $nmpendaftar == 'ppds' OR $nmpendaftar == 'developer'){
|
||||
$nmpendaftar = $list['nmpendaftar'];
|
||||
} else {
|
||||
$nmpendaftar = 'SIMRS';
|
||||
}
|
||||
$from = $verifikasi ? \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $verifikasi) : null;
|
||||
$to = $verifikasi ? \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $verifikasi)->toString() : '';
|
||||
if ($from && $from->isValid()) {
|
||||
$durasi = $verifikasi ? \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $verifikasi)->diffForHumans($from) : 'On Progress';
|
||||
} else {
|
||||
$durasi = 'On Progress';
|
||||
}
|
||||
if ($middleppds2 != 0){
|
||||
$ppdsas = 'Middle';
|
||||
$otherppds = $list['nmppdsmiddle2'];
|
||||
} else {
|
||||
$ppdsas = 'Junior';
|
||||
$otherppds = $ppdsjunior2;
|
||||
$otherppds = $list['nmppdsjunior2'];
|
||||
}
|
||||
|
||||
$arrdaftar = explode(" ", $daftar);
|
||||
$tgldaftar = $arrdaftar[0];
|
||||
$jamdaftar = $arrdaftar[1];
|
||||
$daftar = $tgldaftar;
|
||||
$tglfoto = $foto ?: date("Y-m-d H:i:s");
|
||||
$datatampilan = $this->setStatusStyles($status, $nofoto, $noregister, $nama, $telpon, $jk, $usia, $urgensi, $reques, $ruangan, $daftar, $asalpasien);
|
||||
return [
|
||||
'asalpasien' => $list['asalpasien'],
|
||||
'tlsnofoto' => $datatampilan['nofoto'],
|
||||
'tlsnoregister' => $datatampilan['noregister'],
|
||||
'tlsnama' => $datatampilan['nama'],
|
||||
'tlsjk' => $datatampilan['jk'],
|
||||
'tlsusia' => $datatampilan['usia'],
|
||||
'tlsurgensi' => ($list['urgensi'] == 'CITO') ? '<span style="background-color: red;">C I T O</span>' : $datatampilan['urgensi'],
|
||||
'tlsreques' => $datatampilan['reques'],
|
||||
'tlsruangan' => $list['ruangan'],
|
||||
'tlsdaftar' => $datatampilan['daftar'],
|
||||
'tlsstatus' => $datatampilan['status'],
|
||||
'id' => $list['id'],
|
||||
'nofoto' => $nofoto,
|
||||
'noregister' => $noregister,
|
||||
'nama' => $nama,
|
||||
'jk' => $jk,
|
||||
'usia' => $usia,
|
||||
'urgensi' => $urgensi,
|
||||
'poli' => $reques,
|
||||
'idpasien' => $pasiedin,
|
||||
'ruangan' => $ruangan,
|
||||
'daftar' => $list['daftar'],
|
||||
'daftartgl' => $daftar,
|
||||
'daftarjam' => $jamdaftar,
|
||||
'status' => $status,
|
||||
'dokter' => $master != 'kiriman' ? $list['nmdokter'] : '',
|
||||
'ppds1' => $master != 'kiriman' ? $list['nmppdssenior'] : '',
|
||||
'ppds2' => $master != 'kiriman' ? $list['nmmiddleppds'] : '',
|
||||
'ppds3' => $master != 'kiriman' ? $list['nmppdsjunior'] : '',
|
||||
'keterangan' => $keterangan,
|
||||
'kesimpulan' => $kesimpulan,
|
||||
'noloket' => $list['noloket'],
|
||||
'idruangan' => $list['ruangan_id'],
|
||||
'iddokter' => $list['dokter_id'],
|
||||
'ppdssenior' => $list['ppdssenior'],
|
||||
'middleppds' => $list['middleppds'],
|
||||
'ppdsjunior' => $list['ppdsjunior'],
|
||||
'diagnosa' => $list['diagnosa'],
|
||||
'diagnosa2' => $list['diagnosa2'],
|
||||
'kd_spesimen' => $list['kd_spesimen'],
|
||||
'nm_spesimen' => $list['nm_spesimen'],
|
||||
'berat' => $list['berat'],
|
||||
'klinis' => $list['klinis'],
|
||||
'klinisi' => $list['klinisi'],
|
||||
'filefoto' => $list['filefoto'],
|
||||
'dlp' => $list['dlp'],
|
||||
'analis' => $list['analis'],
|
||||
'excutor' => $list['excutor'],
|
||||
'modality' => $list['modality'],
|
||||
'viewfoto' => $list['foto'],
|
||||
'tglfoto' => $tglfoto,
|
||||
'nmppdssenior' => $list['nmppdssenior'],
|
||||
'nmmiddleppds' => $list['nmmiddleppds'],
|
||||
'nmppdsjunior' => $list['nmppdsjunior'],
|
||||
'nmppdsmiddle2' => $list['nmppdsmiddle2'],
|
||||
'nmppdsjunior2' => $list['nmppdsjunior2'],
|
||||
'nmanalis' => $list['nmanalis'],
|
||||
'nmexcutor' => $list['nmexcutor'],
|
||||
'telpon' => $list['tlppasien'],
|
||||
'asuransi' => $list['asuransi'],
|
||||
'tgllahir' => $list['tgllahirpasien'],
|
||||
'alamat' => $list['alamatpasien'],
|
||||
'poli_id' => $list['poli_id'],
|
||||
'nmpendaftar' => $nmpendaftar,
|
||||
'timestamp1' => $from ? $from->toString() : null,
|
||||
'timestamp2' => $to,
|
||||
'durasi' => $durasi,
|
||||
'ppdsas' => $ppdsas,
|
||||
'otherppds' => $otherppds,
|
||||
'ktp' => $ktp,
|
||||
'bpjs' => $bpjs,
|
||||
];
|
||||
}, $dataArray);
|
||||
}
|
||||
$response = [
|
||||
'message' => 'List Laporan',
|
||||
'data' => $arraylist,
|
||||
'total' => $total
|
||||
];
|
||||
return response()->json($response, 200);
|
||||
}
|
||||
public function listDetail(Request $request) {
|
||||
$id = $request->input('id');
|
||||
$periksa = DB::table('periksa')->where('id', $id)->first();
|
||||
echo json_encode($periksa);
|
||||
}
|
||||
public function delete(Request $request) {
|
||||
$id = $request->input('val01');
|
||||
$alasan = $request->input('val02');
|
||||
$tabel = $request->input('val03');
|
||||
if ($alasan == ''){
|
||||
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Gagal', 'message' => 'Mohon isi semua form']);
|
||||
return back();
|
||||
} else {
|
||||
if ($tabel == 'aktif'){
|
||||
$alasan = 'Dibatalkan dengan alasan '.$alasan;
|
||||
$input = Periksa::where('id', $id)->update([
|
||||
'noloket' => null,
|
||||
'status' => $alasan
|
||||
]);
|
||||
$pesan = 'Order Expertise Canceled';
|
||||
} else if ($tabel == 'arsip'){
|
||||
$total = 0;
|
||||
$input = Periksa::whereIn('id', $id)->update([
|
||||
'status'=> 'Arsip'
|
||||
]);
|
||||
if ($input){
|
||||
$total++;
|
||||
}
|
||||
$pesan = 'Expertise Archieved '.$total;
|
||||
} else {
|
||||
$alasan = 'Dibatalkan dengan alasan '.$alasan;
|
||||
$input = Jadwalperiksa::where('id', $id)->update([
|
||||
'noloket' => null,
|
||||
'status' => $alasan
|
||||
]);
|
||||
$pesan = 'Schedulling Canceled';
|
||||
}
|
||||
if ($input){
|
||||
return response()->json(['icon' => 'success', 'warna' => '#5ba035', 'status' => 'Sukses', 'message' => $pesan]);
|
||||
return back();
|
||||
}else {
|
||||
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Gagal', 'message' => 'System Down, please try again in a few years...']);
|
||||
return back();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
@@ -0,0 +1,225 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Filetemp;
|
||||
use App\User;
|
||||
use App\Periksa;
|
||||
use App\Pasien;
|
||||
use GuzzleHttp\Client;
|
||||
use Validator;
|
||||
use DateTime;
|
||||
use Carbon\Carbon;
|
||||
use Session;
|
||||
|
||||
class PasienController extends Controller
|
||||
{
|
||||
public function index() {
|
||||
if (Session::get('previlage') == ''){
|
||||
return redirect('/login');
|
||||
} else {
|
||||
$data = [];
|
||||
return view('admin.pasien', $data);
|
||||
}
|
||||
}
|
||||
public function store(Request $request) {
|
||||
$validator = Validator::make($request->all(), [
|
||||
'nama' => 'required',
|
||||
'jk' => 'required',
|
||||
'tgl_lahir' => 'required',
|
||||
'kota' => 'required',
|
||||
'alamat' => 'required',
|
||||
'telpon' => 'required'
|
||||
]);
|
||||
$old_date = $request->input('tgl_lahir');
|
||||
$date = date("Y-m-d", strtotime($old_date));
|
||||
if($validator->fails()) {
|
||||
return response()->json(['status' => 'error', 'message' => 'Please fill input field or fill with right input']);
|
||||
} else {
|
||||
$norm = $request->input('norm');
|
||||
$norm = strtoupper($norm);
|
||||
Pasien::create([
|
||||
'norm' => $norm,
|
||||
'nama' => $request->input('nama'),
|
||||
'jk' => $request->input('jk'),
|
||||
'tgl_lahir' => $date,
|
||||
'telpon' => $request->input('telpon'),
|
||||
'kota' => $request->input('kota'),
|
||||
'alamat' => $request->input('alamat')
|
||||
]);
|
||||
Session::flash('message', 'Data berhasil disimpan');
|
||||
Session::flash('alert-class', 'alert-success');
|
||||
return back();
|
||||
}
|
||||
}
|
||||
public function getPasien(Request $request) {
|
||||
$id = $request->input('id');
|
||||
$result = DB::table('pasien')->where('id', $id)->first();
|
||||
$tgllahir = $result->tgl_lahir;
|
||||
$arrtgl = explode('-', $tgllahir);
|
||||
$yy = $arrtgl[0];
|
||||
$mm = $arrtgl[1];
|
||||
$dd = $arrtgl[2];
|
||||
$tgllahir = $dd.'-'.$mm.'-'.$yy;
|
||||
$arrayfnk[] = array(
|
||||
'telpon' => $result->telpon,
|
||||
'nama' => $result->nama,
|
||||
'tgl_lahir' => $result->tgl_lahir,
|
||||
'alamat' => $result->alamat,
|
||||
'id' => $result->id,
|
||||
'norm' => $result->norm,
|
||||
'jk' => $result->jk,
|
||||
'kota' => $result->kota,
|
||||
'nik' => $result->nik,
|
||||
'bpjs' => $result->bpjs,
|
||||
);
|
||||
echo json_encode($arrayfnk);
|
||||
}
|
||||
public function getPatienalllist(Request $request) {
|
||||
$data = Pasien::all();
|
||||
echo json_encode($data);
|
||||
}
|
||||
public function getPasienbynorm(Request $request) {
|
||||
$norm = $request->input('id');
|
||||
$getdatalokal = Pasien::where('norm', $norm)->first();
|
||||
if (isset($getdatalokal->nama)){
|
||||
$tgl_lahir = $getdatalokal->tgl_lahir;
|
||||
$arrdate = explode('-', $tgl_lahir);
|
||||
$yy = $arrdate[0];
|
||||
$mm = $arrdate[1];
|
||||
$dd = $arrdate[2];
|
||||
$tgl_lahir = $dd.'-'.$mm.'-'.$yy;
|
||||
return response()->json([
|
||||
'id' => $getdatalokal->id,
|
||||
'norm' => $getdatalokal->norm,
|
||||
'telpon' => $getdatalokal->telpon,
|
||||
'nama' => $getdatalokal->nama,
|
||||
'tgl_lahir' => $getdatalokal->tgl_lahir,
|
||||
'jk' => $getdatalokal->jk,
|
||||
'alamat' => $getdatalokal->alamat,
|
||||
'kota' => $getdatalokal->kota,
|
||||
'nik' => $getdatalokal->nik,
|
||||
'bpjs' => $getdatalokal->bpjs,
|
||||
]);
|
||||
} else {
|
||||
try {
|
||||
$client = new Client();
|
||||
$res = $client->request('GET', 'http://10.10.123.51:8000/mr/'.$norm);
|
||||
$response_data = json_decode($res->getBody()->getContents());
|
||||
if (isset($response_data[0])) {
|
||||
$hasil = $response_data[0];
|
||||
$nama = $hasil->Nama;
|
||||
$alamat = $hasil->Alamat;
|
||||
$telpon = $hasil->Telp;
|
||||
$kota = $hasil->Kota;
|
||||
$kelamin = $hasil->JenisKelamin;
|
||||
$tgllahir = $hasil->tanggal_lahir;
|
||||
$nik = $hasil->nik;
|
||||
$bpjs = $hasil->bpjs;
|
||||
if ($kelamin == 'WANITA'){
|
||||
$kelamin = 'P';
|
||||
} else { $kelamin = 'L'; }
|
||||
return response()->json([
|
||||
'id' => 'new',
|
||||
'norm' => $norm,
|
||||
'telpon' => $telpon,
|
||||
'nama' => $nama,
|
||||
'tgl_lahir' => $tgllahir,
|
||||
'jk' => $kelamin,
|
||||
'alamat' => $alamat,
|
||||
'kota' => $kota,
|
||||
'nik' => $nik,
|
||||
'bpjs' => $bpjs,
|
||||
]);
|
||||
} else {
|
||||
return response()->json([
|
||||
'id' => '',
|
||||
'telpon' => '000000000',
|
||||
'norm' => $norm,
|
||||
'nama' => '',
|
||||
'tgl_lahir' => date("d-m-Y"),
|
||||
'jk' => 'L',
|
||||
'alamat' => 'Malang',
|
||||
'kota' => 'Malang',
|
||||
'nik' => '',
|
||||
'bpjs' => '',
|
||||
]);
|
||||
}
|
||||
}catch (Exception $e) {
|
||||
return response()->json([
|
||||
'id' => '',
|
||||
'telpon' => '000000000',
|
||||
'norm' => $norm,
|
||||
'nama' => '',
|
||||
'tgl_lahir' => date("d-m-Y"),
|
||||
'jk' => 'L',
|
||||
'alamat' => $e->getMessage(),
|
||||
'kota' => 'Malang',
|
||||
'nik' => '',
|
||||
'bpjs' => '',
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public function update(Request $request) {
|
||||
$validator = Validator::make($request->all(), [
|
||||
'nama' => 'required',
|
||||
'jk' => 'required',
|
||||
'tgl_lahir' => 'required',
|
||||
'kota' => 'required',
|
||||
'telpon' => 'required',
|
||||
'alamat' => 'required'
|
||||
]);
|
||||
|
||||
if($validator->fails()) {
|
||||
return response()->json(['status' => 'error', 'message' => 'Please fill input field or fill with right input']);
|
||||
} else {
|
||||
$id = $request->input('id_pasien');
|
||||
$old_date = $request->input('tgl_lahir');
|
||||
$date = date("Y-m-d", strtotime($old_date));
|
||||
$norm = $request->input('norm');
|
||||
$norm = strtoupper($norm);
|
||||
$siapa = Session('nama');
|
||||
$kapan = date('Y-m-d H:i:s');
|
||||
$keterangan = 'Diupdate Oleh '.$siapa.' Pada '.$kapan;
|
||||
try {
|
||||
Pasien::updateOrCreate(
|
||||
[
|
||||
'norm' => $norm,
|
||||
],
|
||||
[
|
||||
'nama' => $request->input('nama'),
|
||||
'jk' => $request->input('jk'),
|
||||
'tgl_lahir' => $date,
|
||||
'telpon' => $request->input('telpon'),
|
||||
'kota' => $request->input('kota'),
|
||||
'alamat' => $request->input('alamat'),
|
||||
'keterangan' => $keterangan
|
||||
]
|
||||
);
|
||||
Session::flash('message', 'Data berhasil disimpan');
|
||||
Session::flash('alert-class', 'alert-success');
|
||||
return back();
|
||||
} catch (\Exception $e) {
|
||||
Session::flash('message', $e->getMessage());
|
||||
Session::flash('alert-class', 'alert-succdangeress');
|
||||
return back();
|
||||
}
|
||||
}
|
||||
}
|
||||
public function delete(Request $request) {
|
||||
$id = $request->pasien_id;
|
||||
$pasien = Pasien::find($id);
|
||||
$hapus = $pasien->delete();
|
||||
if ($hapus) {
|
||||
return response()->json(['icon' => 'success', 'warna' => '#5ba035', 'status' => 'Success', 'message' => 'Data Deleted..!!!']);
|
||||
return back();
|
||||
} else {
|
||||
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Error.!!', 'message' => 'System Down, please try again in a few years....']);
|
||||
return back();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,576 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Poli;
|
||||
use App\Ruangan;
|
||||
use App\Organisms;
|
||||
use App\XFiles;
|
||||
use App\SIMBHPJenis;
|
||||
use App\SIMBHPReport;
|
||||
use App\User;
|
||||
|
||||
use Validator;
|
||||
use Session;
|
||||
|
||||
class PoliController extends Controller
|
||||
{
|
||||
public function index() {
|
||||
if (Session::get('previlage') == ''){
|
||||
return redirect('/login');
|
||||
} else {
|
||||
$data = [];
|
||||
$data['polis'] = Poli::all();
|
||||
$data['ruangans'] = Ruangan::all();
|
||||
return view('admin.poli', $data);
|
||||
}
|
||||
}
|
||||
public function viewGudangIndex() {
|
||||
if (Session::get('previlage') == ''){
|
||||
return redirect('/login');
|
||||
} else {
|
||||
$tasks = [];
|
||||
$homebase = url("/");
|
||||
$sekarang = date("Y-m-d");
|
||||
$pegawais = User::select('id', 'nama', 'previlage')->orderBy('nama', 'ASC')->get();
|
||||
$cdatane = SIMBHPJenis::all();
|
||||
$cjenis = count($cdatane);
|
||||
if ($cjenis == 0){
|
||||
$tasks['jjenis'][0]['jenis'] = 'Belum Ada Jenis Barang';
|
||||
$tasks['jjenis'][0]['satuan'] = '';
|
||||
} else {
|
||||
$i = 0;
|
||||
foreach($cdatane as $rdata){
|
||||
$tasks['jjenis'][$i]['jenis'] = $rdata->jenis;
|
||||
$tasks['jjenis'][$i]['satuan'] = $rdata->satuan;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
$getdebet = SIMBHPReport::select(DB::raw('SUM(pemasukan) as pemasukan'))->groupBy('marking')->first();
|
||||
if (isset($getdebet->pemasukan)){
|
||||
$totpemasukan = $getdebet->pemasukan;
|
||||
} else { $totpemasukan = 0 ;}
|
||||
$getkredit = SIMBHPReport::select(DB::raw('SUM(pengeluaran) as pengeluaran'))->groupBy('marking')->first();
|
||||
if (isset($getkredit->pengeluaran)){
|
||||
$totpepengeluaran = $getkredit->pengeluaran;
|
||||
} else { $totpepengeluaran = 0 ;}
|
||||
|
||||
$tasks['masuk'] = $totpemasukan;
|
||||
$tasks['keluar'] = $totpepengeluaran;
|
||||
$tasks['pegawai'] = $pegawais;
|
||||
$tasks['tahunne'] = date("Y");
|
||||
$tasks['tanggal'] = $sekarang;
|
||||
$tasks['sidebar'] = 'simbhp';
|
||||
$previlage = Session('previlage');
|
||||
return view('admin.gudang', $tasks);
|
||||
}
|
||||
}
|
||||
public function storePoli(Request $request) {
|
||||
$validator = Validator::make($request->all(), [
|
||||
'poli' => 'required',
|
||||
'poli' => 'required',
|
||||
'modaliti' => 'required'
|
||||
]);
|
||||
if($validator->fails()) {
|
||||
return response()->json(['status' => 'error', 'message' => 'Please fill input field or fill with right input']);
|
||||
} else {
|
||||
$poli = $request->input('poli');
|
||||
$subpoli = $request->input('subpoli');
|
||||
$subsubpoli = $request->input('subsubpoli');
|
||||
$modaliti = $request->input('modaliti');
|
||||
Poli::create([
|
||||
'poli' => $request->input('poli'),
|
||||
'subpoli' => $request->input('subpoli'),
|
||||
'subsubpoli'=> $request->input('subsubpoli'),
|
||||
'modaliti' => $request->input('modaliti'),
|
||||
'modaliti2' => $request->input('modaliti2')
|
||||
]);
|
||||
$tulis = 'Data '.$poli.' '.$subpoli.' '.$subsubpoli.' Saved..!!';
|
||||
return response()->json(['status' => 'success', 'message' => $tulis]);
|
||||
}
|
||||
}
|
||||
public function getListPoli() {
|
||||
$results = Poli::orderBy('subpoli', 'ASC')->get();
|
||||
echo json_encode($results);
|
||||
}
|
||||
public function updatePoli(Request $request) {
|
||||
$validator = Validator::make($request->all(), [
|
||||
'id' => 'required',
|
||||
'poli' => 'required',
|
||||
'subpoli' => 'required',
|
||||
'modaliti' => 'required'
|
||||
]);
|
||||
if($validator->fails()) {
|
||||
return response()->json(['status' => 'error', 'message' => 'Please fill input field or fill with right input']);
|
||||
} else {
|
||||
$id = $request->input('id');
|
||||
$poli = $request->input('poli');
|
||||
$subpoli = $request->input('subpoli');
|
||||
$subsubpoli = $request->input('subsubpoli');
|
||||
Poli::where('id', $id)->update([
|
||||
'poli' => $poli,
|
||||
'subpoli' => $subpoli,
|
||||
'subsubpoli'=> $subsubpoli,
|
||||
'modaliti' => $request->input('modaliti'),
|
||||
'modaliti2' => $request->input('modaliti2')
|
||||
]);
|
||||
$tulis = 'Data '.$poli.' '.$subpoli.' '.$subsubpoli.' Updated..!!';
|
||||
return response()->json(['status' => 'success', 'message' => $tulis]);
|
||||
}
|
||||
}
|
||||
public function deletePoli(Request $request) {
|
||||
$id = $request->id;
|
||||
$poli = Poli::find($id);
|
||||
$poli->delete();
|
||||
return back();
|
||||
}
|
||||
public function storeRuangan(Request $request) {
|
||||
$validator = Validator::make($request->all(), [
|
||||
'poli' => 'required',
|
||||
'ruangan' => 'required'
|
||||
]);
|
||||
if($validator->fails()) {
|
||||
return response()->json(['status' => 'error', 'message' => 'Please fill input field or fill with right input']);
|
||||
} else {
|
||||
Ruangan::create([
|
||||
'poli' => $request->input('poli'),
|
||||
'ruangan' => $request->input('ruangan')
|
||||
]);
|
||||
Session::flash('message', 'Data berhasil disimpan');
|
||||
Session::flash('alert-class', 'alert-success');
|
||||
return back();
|
||||
}
|
||||
}
|
||||
public function getListRuangan(Request $request) {
|
||||
$results = Ruangan::all();
|
||||
echo json_encode($results);
|
||||
}
|
||||
public function updateRuangan(Request $request) {
|
||||
$validator = Validator::make($request->all(), [
|
||||
'id' => 'required',
|
||||
'poli' => 'required',
|
||||
'ruangan' => 'required'
|
||||
]);
|
||||
if($validator->fails()) {
|
||||
return response()->json(['status' => 'error', 'message' => 'Please fill input field or fill with right input']);
|
||||
} else {
|
||||
$id = $request->input('id');
|
||||
Ruangan::where('id', $id)->update([
|
||||
'poli' => $request->input('poli'),
|
||||
'ruangan' => $request->input('ruangan')
|
||||
]);
|
||||
}
|
||||
}
|
||||
public function deleteRuangan(Request $request) {
|
||||
$id = $request->id;
|
||||
$ruangan = Ruangan::find($id);
|
||||
$ruangan->delete();
|
||||
return back();
|
||||
}
|
||||
public function jsonRekapbhp() {
|
||||
$tahun = date("Y");
|
||||
$thnlalu = $tahun - 1;
|
||||
$totale = 0;
|
||||
$arraysurat = [];
|
||||
$getdata = SIMBHPJenis::all();
|
||||
if (!empty($getdata)){
|
||||
foreach($getdata as $hasil){
|
||||
$jenis = $hasil->kodejenis;
|
||||
$satuan = $hasil->satuan;
|
||||
$tlsjenis = $hasil->jenis;;
|
||||
$getdebet = SIMBHPReport::select(DB::raw('SUM(pemasukan) as pemasukan'))->where('jenis', $tlsjenis)->groupBy('jenis')->first();
|
||||
if (isset($getdebet->pemasukan)){
|
||||
$totpemasukan = $getdebet->pemasukan;
|
||||
} else { $totpemasukan = 0 ;}
|
||||
$getkredit = SIMBHPReport::select(DB::raw('SUM(pengeluaran) as pengeluaran'))->where('jenis', $tlsjenis)->groupBy('jenis')->first();
|
||||
if (isset($getkredit->pengeluaran)){
|
||||
$totpepengeluaran = $getkredit->pengeluaran;
|
||||
} else { $totpepengeluaran = 0 ;}
|
||||
|
||||
$saldoakhir = $totpemasukan - $totpepengeluaran;
|
||||
$arraysurat[] = array(
|
||||
'id' => $hasil->id,
|
||||
'satuan' => $satuan,
|
||||
'jenis' => $jenis,
|
||||
'tlsjenis' => $tlsjenis,
|
||||
'saldo' => number_format( $saldoakhir , 0 , '.' , ',' ),
|
||||
);
|
||||
}
|
||||
}
|
||||
echo json_encode($arraysurat);
|
||||
}
|
||||
public function jsonReportbhp(Request $request) {
|
||||
$bulan = $request->input('val01');
|
||||
$tahun = $request->input('val02');
|
||||
$hasil = [];
|
||||
if ($tahun == 'ALL'){
|
||||
$bulan = date("m");
|
||||
$tahun = date("Y");
|
||||
$getdata = SIMBHPReport::where('bulan', $bulan)->where('tahun', $tahun)->orderBy('id', 'DESC')->get();
|
||||
} else {
|
||||
if ($bulan == 'ALL'){
|
||||
$getdata = SIMBHPReport::where('tahun', $tahun)->orderBy('id', 'DESC')->get();
|
||||
} else {
|
||||
$getdata = SIMBHPReport::where('bulan', $bulan)->where('tahun', $tahun)->orderBy('id', 'DESC')->get();
|
||||
}
|
||||
|
||||
}
|
||||
foreach($getdata as $rdata){
|
||||
$dd = $rdata->tanggal;
|
||||
$mm = $rdata->bulan;
|
||||
$yy = $rdata->tahun;
|
||||
$pengeluaran= $rdata->pengeluaran;
|
||||
$pemasukan = $rdata->pemasukan;
|
||||
if ($mm < 10){
|
||||
$tgllengkap = $dd.'-0'.$mm.'-'.$yy;
|
||||
} else {
|
||||
$tgllengkap = $dd.'-'.$mm.'-'.$yy;
|
||||
}
|
||||
if ($pengeluaran == '' OR $pengeluaran == 0) {$total = $pemasukan;}
|
||||
else { $total = $pengeluaran; }
|
||||
|
||||
$hasil[] = array(
|
||||
'id' => $rdata->id,
|
||||
'tanggal' => $rdata->tanggal,
|
||||
'bulan' => $rdata->bulan,
|
||||
'tahun' => $rdata->tahun,
|
||||
'deskripsi' => $rdata->deskripsi,
|
||||
'pemasukan' => number_format( $pemasukan , 0 , '.' , ',' ),
|
||||
'pengeluaran' => number_format( $pengeluaran , 0 , '.' , ',' ),
|
||||
'jenis' => $rdata->jenis,
|
||||
'keterangan' => $rdata->keterangan,
|
||||
'tgllengkap' => $tgllengkap,
|
||||
'total' => $total,
|
||||
);
|
||||
}
|
||||
echo json_encode($hasil);
|
||||
}
|
||||
public function jsonReportbhpPaginated(Request $request) {
|
||||
$tanggal = $request->input('tanggal');
|
||||
$deskripsi = $request->input('deskripsi');
|
||||
$kategori = $request->input('kategori');
|
||||
$lm = 10;
|
||||
$limit = ($request->input('limit') == null ? $lm : $request->input('limit'));
|
||||
$order = ($request->input('order') == null ? 'id desc' : $request->input('order'));
|
||||
$data = new SIMBHPReport;
|
||||
if ($kategori != null AND $kategori != '') $data = $data->where('jenis', $kategori);
|
||||
if ($tanggal != null AND $tanggal != '') $data = $data->where('created_at', 'LIKE', '%'.$tanggal.'%');
|
||||
if ($deskripsi != null AND $deskripsi != '') $data = $data->where('deskripsi', 'LIKE', '%'.$deskripsi.'%');
|
||||
$data = $data->orderByRaw($order)->paginate($limit);
|
||||
$hasil = [];
|
||||
$totaldata = $data->total();
|
||||
$debet = 0;
|
||||
$kredit = 0;
|
||||
if (!empty($data)){
|
||||
foreach($data as $rdata){
|
||||
$dd = $rdata->tanggal;
|
||||
$mm = $rdata->bulan;
|
||||
$yy = $rdata->tahun;
|
||||
$pengeluaran = $rdata->pengeluaran;
|
||||
$pemasukan = $rdata->pemasukan;
|
||||
$deskripsi = $rdata->deskripsi;
|
||||
$jenis = $rdata->jenis;
|
||||
$debet = $debet + $pemasukan;
|
||||
$kredit = $kredit + $pengeluaran;
|
||||
$cekjenis = SIMBHPJenis::where('kodejenis', $jenis)->first();
|
||||
if (isset($cekjenis->id)){
|
||||
$kodejenis = $cekjenis->kodejenis;
|
||||
$jenis = $cekjenis->jenis;
|
||||
$satuan = $cekjenis->satuan;
|
||||
} else {
|
||||
$kodejenis = $jenis;
|
||||
$jenis = '';
|
||||
$satuan = '';
|
||||
}
|
||||
|
||||
if ($jenis != ''){
|
||||
$deskripsi = '<strong>'.$jenis.'</strong><br />'.$deskripsi;
|
||||
}
|
||||
|
||||
if ($mm < 10){
|
||||
$tgllengkap = $yy.'-0'.$mm.'-'.$dd;
|
||||
} else {
|
||||
$tgllengkap = $yy.'-'.$mm.'-'.$dd;
|
||||
}
|
||||
if ($pengeluaran == '' OR $pengeluaran == 0) {
|
||||
$total = $pemasukan;
|
||||
$jentrans = 'PEMASUKAN';
|
||||
}
|
||||
else {
|
||||
$total = $pengeluaran;
|
||||
$jentrans = 'PENGELUARAN';
|
||||
}
|
||||
|
||||
$hasil[] = array(
|
||||
'id' => $rdata->id,
|
||||
'tanggal' => $rdata->tanggal,
|
||||
'bulan' => $rdata->bulan,
|
||||
'tahun' => $rdata->tahun,
|
||||
'tlsdeskripsi' => $deskripsi,
|
||||
'deskripsi' => $rdata->deskripsi,
|
||||
'pemasukan' => number_format( $pemasukan , 0 , '.' , ',' ),
|
||||
'pengeluaran' => number_format( $pengeluaran , 0 , '.' , ',' ),
|
||||
'jenis' => $kodejenis,
|
||||
'keterangan' => $rdata->keterangan,
|
||||
'tgllengkap' => $tgllengkap,
|
||||
'created_at' => $rdata->created_at,
|
||||
'nominal' => $total.' '.$satuan,
|
||||
'jentrans' => $jentrans,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$response = [
|
||||
'message' => 'List Data',
|
||||
'data' => $hasil,
|
||||
'totaldata' => $totaldata
|
||||
];
|
||||
return response()->json($response, 200);
|
||||
}
|
||||
public function exAddbarang(Request $request) {
|
||||
$deskripsi = $request->input('set01');
|
||||
$pos = $request->input('set02');
|
||||
$tanggal = $request->input('set03');
|
||||
$jumlah = $request->input('set04');
|
||||
$jenis = $request->input('set05');
|
||||
$postujuan = $request->input('set06');
|
||||
$alasan = $request->input('set07');
|
||||
$nama = Session('nama');
|
||||
if ($tanggal == '' OR is_null($tanggal)){
|
||||
$tanggal = date("d-m-Y");
|
||||
}
|
||||
$total = (int)str_replace(',','',$jumlah);
|
||||
if ($jenis == 'jenis'){ $jumlah = '-';}
|
||||
if ($deskripsi != '' and $pos != '' and $tanggal != '' and $jumlah != '' and $jenis != ''){
|
||||
if ($jenis == 'jenis'){
|
||||
$jenis = $request->input('set02');
|
||||
$satuan = $request->input('set03');
|
||||
$idne = $request->input('set04');
|
||||
$kodejenis = preg_replace('/\s+/', '', $jenis);
|
||||
if ($idne == 'new' OR $idne == ''){
|
||||
$ceksudah = SIMBHPJenis::where('kodejenis', $kodejenis)->where('satuan', $satuan)->count();
|
||||
if ($ceksudah != 0){
|
||||
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Gagal', 'message' => $jenis.' Sudah Ada, Silahkan Masukkan Jenis Barang Lain']);
|
||||
return back();
|
||||
} else {
|
||||
$input = SIMBHPJenis::create([
|
||||
'kodejenis' => $kodejenis,
|
||||
'jenis' => $jenis,
|
||||
'satuan' => $satuan,
|
||||
]);
|
||||
if ($input){
|
||||
return response()->json(['status' => 'Success', 'message' => 'Data '.$jenis.' Sukses Ditambahkan']);
|
||||
return back();
|
||||
} else {
|
||||
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Gagal', 'message' => $jenis.' Gagal di masukkan, silahkan ulangi beberapa saat lagi']);
|
||||
return back();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$ceksudah = SIMBHPJenis::where('id', '!=', $idne)->where('kodejenis', $kodejenis)->where('satuan', $satuan)->count();
|
||||
if ($ceksudah != 0){
|
||||
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Gagal', 'message' => $jenis.' Sudah Ada, Silahkan Masukkan Jenis Barang Lain']);
|
||||
return back();
|
||||
} else {
|
||||
$input = SIMBHPJenis::where('id', $idne)->update([
|
||||
'kodejenis' => $kodejenis,
|
||||
'jenis' => $jenis,
|
||||
'satuan' => $satuan,
|
||||
]);
|
||||
if ($input){
|
||||
return response()->json(['status' => 'Success', 'message' => 'Data '.$jenis.' Sukses Diupdate']);
|
||||
return back();
|
||||
} else {
|
||||
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Gagal', 'message' => $jenis.' Gagal di masukkan, silahkan ulangi beberapa saat lagi']);
|
||||
return back();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$ahrf = explode("-", $tanggal);
|
||||
$tahun = $ahrf[0];
|
||||
if(isset($ahrf[1])){
|
||||
$wulan = (int)$ahrf[1];
|
||||
} else { $wulan = date("m"); $wulan = (int)$wulan; }
|
||||
if(isset($ahrf[2])){
|
||||
$dino = (int)$ahrf[2];
|
||||
} else { $dino = date("d"); }
|
||||
if ($jenis == 'pemasukan'){
|
||||
$bayar = SIMBHPReport::create([
|
||||
'tanggal' => $dino,
|
||||
'bulan' => $wulan,
|
||||
'tahun' => $tahun,
|
||||
'deskripsi' => $deskripsi,
|
||||
'pemasukan' => $total,
|
||||
'pengeluaran' => null,
|
||||
'jenis' => $pos,
|
||||
'keterangan' => '',
|
||||
'marking' => '',
|
||||
]);
|
||||
} else if ($jenis == 'pengeluaran'){
|
||||
$getnama = User::where('id', $deskripsi)->first();
|
||||
$nama = $getnama->nama ?? 'Unkown';
|
||||
$deskripsi = 'Diterima oleh '.$nama;
|
||||
$getdebet = SIMBHPReport::select(DB::raw('SUM(pemasukan) as pemasukan'))->where('jenis', $pos)->groupBy('jenis')->first();
|
||||
if (isset($getdebet->pemasukan)){
|
||||
$totpemasukan = $getdebet->pemasukan;
|
||||
} else { $totpemasukan = 0 ;}
|
||||
$getkredit = SIMBHPReport::select(DB::raw('SUM(pengeluaran) as pengeluaran'))->where('jenis', $pos)->groupBy('jenis')->first();
|
||||
if (isset($getkredit->pengeluaran)){
|
||||
$totpepengeluaran = $getkredit->pengeluaran;
|
||||
} else { $totpepengeluaran = 0 ;}
|
||||
$totpepengeluaran = $totpepengeluaran + $total;
|
||||
if ($totpepengeluaran > $totpemasukan){
|
||||
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Gagal', 'message' => 'Nominal Melebihi Stok']);
|
||||
return back();
|
||||
} else {
|
||||
$bayar = SIMBHPReport::create([
|
||||
'tanggal' => $dino,
|
||||
'bulan' => $wulan,
|
||||
'tahun' => $tahun,
|
||||
'deskripsi' => $deskripsi,
|
||||
'pemasukan' => null,
|
||||
'pengeluaran' => $total,
|
||||
'jenis' => $pos,
|
||||
'keterangan' => '',
|
||||
'marking' => '',
|
||||
]);
|
||||
}
|
||||
|
||||
} else if ($jenis == 'editor'){
|
||||
if ($alasan == ''){
|
||||
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Gagal', 'message' => 'Alasan Perubahan Data Wajib Di Isi!!!']);
|
||||
return back();
|
||||
} else {
|
||||
$getdebet = SIMBHPReport::select(DB::raw('SUM(pemasukan) as pemasukan'))->where('jenis', $pos)->groupBy('jenis')->first();
|
||||
if (isset($getdebet->pemasukan)){
|
||||
$totpemasukan = $getdebet->pemasukan;
|
||||
} else { $totpemasukan = 0 ;}
|
||||
$getkredit = SIMBHPReport::select(DB::raw('SUM(pengeluaran) as pengeluaran'))->where('jenis', $pos)->groupBy('jenis')->first();
|
||||
if (isset($getkredit->pengeluaran)){
|
||||
$totpepengeluaran = $getkredit->pengeluaran;
|
||||
} else { $totpepengeluaran = 0 ;}
|
||||
$totpepengeluaran = $totpepengeluaran + $total;
|
||||
|
||||
$rdatalama = SIMBHPReport::where('id', $postujuan)->first();
|
||||
$ldeskripsi = $rdatalama->deskripsi;
|
||||
$lpemasukan = $rdatalama->pemasukan;
|
||||
$lpengeluaran = $rdatalama->pengeluaran;
|
||||
$ljenis = $rdatalama->jenis;
|
||||
$marking = $rdatalama->marking;
|
||||
if ($lpengeluaran == '' OR $lpengeluaran == 0) {
|
||||
$ltotal = number_format( $lpemasukan , 0 , '.' , ',' );
|
||||
if ($marking != ''){
|
||||
SIMBHPReport::where('marking', $marking)->whereNotIn('id', [$postujuan])->update([
|
||||
'tanggal' => $dino,
|
||||
'bulan' => $wulan,
|
||||
'tahun' => $tahun,
|
||||
'pengeluaran' => $total
|
||||
]);
|
||||
}
|
||||
$bayar = SIMBHPReport::where('id', $postujuan)->update([
|
||||
'tanggal' => $dino,
|
||||
'bulan' => $wulan,
|
||||
'tahun' => $tahun,
|
||||
'deskripsi' => $deskripsi,
|
||||
'jenis' => $pos,
|
||||
'pemasukan' => $total,
|
||||
'keterangan' => $alasan,
|
||||
'updated_at' => date("Y-m-d H:i:s")
|
||||
]);
|
||||
} else {
|
||||
$totpepengeluaran = $totpepengeluaran + $total;
|
||||
if ($totpepengeluaran > $totpemasukan){
|
||||
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Gagal', 'message' => 'Nominal Melebihi Stok']);
|
||||
return back();
|
||||
} else {
|
||||
$ltotal = number_format( $lpengeluaran , 0 , '.' , ',' );
|
||||
if ($marking != ''){
|
||||
SIMBHPReport::where('marking', $marking)->whereNotIn('id', [$postujuan])->update([
|
||||
'tanggal' => $dino,
|
||||
'bulan' => $wulan,
|
||||
'tahun' => $tahun,
|
||||
'pemasukan' => $total
|
||||
]);
|
||||
}
|
||||
$bayar = SIMBHPReport::where('id', $postujuan)->update([
|
||||
'tanggal' => $dino,
|
||||
'bulan' => $wulan,
|
||||
'tahun' => $tahun,
|
||||
'deskripsi' => $deskripsi,
|
||||
'jenis' => $pos,
|
||||
'pengeluaran' => $total,
|
||||
'keterangan' => $alasan,
|
||||
'updated_at' => date("Y-m-d H:i:s")
|
||||
]);
|
||||
}
|
||||
}
|
||||
$baris1 = '<table class="table table-bordered table-striped"><tr><td colspan=2><p align=center><b>Data Lama</b></p></td><td colspan=2><p align=center><b>Data Perubahan</b></p></td></tr>';
|
||||
$baris2 = '<tr><td>Deskripsi</td><td>'.$ldeskripsi.'</td><td><font color=red>Diubah Menjadi</font></td><td>'.$deskripsi.'</td></tr>';
|
||||
$baris3 = '<tr><td>Jenis</td><td>'.$ljenis.'</td><td><font color=red>Diubah Menjadi</font></td><td>'.$pos.'</td></tr>';
|
||||
$baris4 = '<tr><td>Total</td><td>'.$ltotal.'</td><td><font color=red>Diubah Menjadi</font></td><td>'.$jumlah.'</td></tr>';
|
||||
$baris5 = '<tr><td><b>Dengan Alasan</b></td><td colspan=3>'.$alasan.'</td</tr>';
|
||||
$baris6 = '<tr><td><b>Eksekutor</b></td><td colspan=3>'.Session('nama').'</td</tr></table>';
|
||||
$perubahan = $baris1.$baris2.$baris3.$baris4.$baris5.$baris6;
|
||||
Xfiles::create([
|
||||
'xmarking' => 'SIMBHP-'.$postujuan.'-'.time(),
|
||||
'xtabel' => 'History SIMBHP',
|
||||
'xjenis' => '',
|
||||
'xfile' => $perubahan
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
if ($alasan == ''){
|
||||
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Gagal', 'message' => 'Alasan Perubahan Data Wajib Di Isi!!!']);
|
||||
return back();
|
||||
}
|
||||
else {
|
||||
$rdatalama = SIMBHPReport::where('id', $postujuan)->first();
|
||||
$ldeskripsi = $rdatalama->deskripsi;
|
||||
$lpemasukan = $rdatalama->pemasukan;
|
||||
$lpengeluaran = $rdatalama->pengeluaran;
|
||||
$ljenis = $rdatalama->jenis;
|
||||
$marking = $rdatalama->marking;
|
||||
if ($lpengeluaran == '' or $lpengeluaran == 0) {
|
||||
$ltotal = number_format( $lpemasukan , 0 , '.' , ',' );
|
||||
} else {
|
||||
$ltotal = number_format( $lpengeluaran , 0 , '.' , ',' );
|
||||
}
|
||||
$baris1 = '<table class="table table-bordered table-striped"><tr><td colspan=2><p align=center><b>Data Lama</b></p></td><td colspan=2><p align=center><b>Data Perubahan</b></p></td></tr>';
|
||||
$baris2 = '<tr><td>Deskripsi</td><td>'.$ldeskripsi.'</td><td colspan=2><font color=red>DIHAPUS</font></td></tr>';
|
||||
$baris3 = '<tr><td>Jenis</td><td>'.$ljenis.'</td><td colspan=2><font color=red>DIHAPUS</font></td></tr>';
|
||||
$baris4 = '<tr><td>Total</td><td>'.$ltotal.'</td><td colspan=2><font color=red>DIHAPUS</font></td></tr>';
|
||||
$baris5 = '<tr><td><b>Dengan Alasan</b></td><td colspan=3>'.$alasan.'</td</tr>';
|
||||
$baris6 = '<tr><td><b>Eksekutor</b></td><td colspan=3>'.Session('nama').'</td</tr></table>';
|
||||
$perubahan = $baris1.$baris2.$baris3.$baris4.$baris5.$baris6;
|
||||
|
||||
Xfiles::create([
|
||||
'xmarking' => 'SIMBHP-'.$postujuan.'-'.time(),
|
||||
'xtabel' => 'History SIMBHP',
|
||||
'xjenis' => '',
|
||||
'xfile' => $perubahan
|
||||
]);
|
||||
if ($marking != ''){
|
||||
$bayar = SIMBHPReport::where('marking', $marking)->delete();
|
||||
} else {
|
||||
$bayar = SIMBHPReport::where('id', $postujuan)->delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($bayar){
|
||||
return response()->json(['status' => 'Success', 'message' => 'Transaksi '.$jenis.' Sukses Dilaksanakan']);
|
||||
return back();
|
||||
} else {
|
||||
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Gagal', 'message' => 'Update Gagal, Pastikan Data Yang anda Isi Sudah Sesuai']);
|
||||
return back();
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Gagal', 'message' => 'Pastikan Formnya Anda Isi dengan Lengkap']);
|
||||
return back();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,446 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Poli;
|
||||
use App\Logbook;
|
||||
use App\User;
|
||||
use App\Periksa;
|
||||
use App\Dokter;
|
||||
use App\Pasien;
|
||||
use App\Jadwalperiksa;
|
||||
use App\Riwayat;
|
||||
use App\RekapAntibiotik;
|
||||
use DateTime;
|
||||
use Carbon\Carbon;
|
||||
use Session;
|
||||
|
||||
class ReportController extends Controller
|
||||
{
|
||||
public function index() {
|
||||
if (Session::get('previlage') == ''){
|
||||
return redirect('/login');
|
||||
} else {
|
||||
return view('admin.report');
|
||||
}
|
||||
}
|
||||
public function rekapPeriksa(Request $request) {
|
||||
set_time_limit(0);
|
||||
$bulan = $request->input('bulan');
|
||||
$tahun = $request->input('tahun');
|
||||
if ($bulan == 'ALL' OR $bulan == 'Pick Month') {
|
||||
$orderbydate = Periksa::selectRaw('SUM(id) as jumlah, DATE(daftar) as day')->whereYear('daftar', $tahun)->groupBy(DB::raw('daftar'))->orderBy('daftar', 'ASC')->get();
|
||||
$bulan = '';
|
||||
} else {
|
||||
$tglcari = $tahun . '-' . str_pad($bulan, 2, '0', STR_PAD_LEFT);
|
||||
$orderbydate = Periksa::selectRaw('SUM(id) as jumlah, DATE(daftar) as day')->where('day', 'LIKE', '%' . $tglcari . '%')->groupBy(DB::raw('daftar'))->orderBy('daftar', 'ASC')->get();
|
||||
$bulanNames = [
|
||||
'01' => 'BULAN JANUARI',
|
||||
'02' => 'BULAN FEBRUARI',
|
||||
'03' => 'BULAN MARET',
|
||||
'04' => 'BULAN APRIL',
|
||||
'05' => 'BULAN MEI',
|
||||
'06' => 'BULAN JUNI',
|
||||
'07' => 'BULAN JULI',
|
||||
'08' => 'BULAN AGUSTUS',
|
||||
'09' => 'BULAN SEPTEMBER',
|
||||
'10' => 'BULAN OKTOBER',
|
||||
'11' => 'BULAN NOVEMBER',
|
||||
'12' => 'BULAN DESEMBER',
|
||||
];
|
||||
$bulan = $bulanNames[$bulan] ?? $bulan;
|
||||
}
|
||||
$data = [];
|
||||
$data['bulan'] = $bulan;
|
||||
$data['tahun'] = $tahun;
|
||||
$data['orderbydate']= $orderbydate;
|
||||
$generatetabel = view('cetak.rekap_periksa_table', $data)->render();
|
||||
echo $generatetabel;
|
||||
}
|
||||
protected static function getPasienData($result) {
|
||||
return [
|
||||
'nama' => $result->nmpasien,
|
||||
'tgl' => $result->tgllahirpasien,
|
||||
'jk' => $result->jkpasien,
|
||||
];
|
||||
}
|
||||
protected static function updateTotals($totals, $asuransi, $urgensi, $jk) {
|
||||
if ($jk == 'L') {
|
||||
$totals['m']++;
|
||||
} else {
|
||||
$totals['f']++;
|
||||
}
|
||||
|
||||
if ($asuransi == 'JKN') {
|
||||
$totals['jkn']++;
|
||||
} elseif ($asuransi == 'Umum') {
|
||||
$totals['umum']++;
|
||||
} elseif ($asuransi == 'TAG') {
|
||||
$totals['tag']++;
|
||||
} elseif ($asuransi == 'GCU') {
|
||||
$totals['gcu']++;
|
||||
} elseif ($asuransi == 'Billing') {
|
||||
$totals['bill']++;
|
||||
} else {
|
||||
$totals['swasta']++;
|
||||
}
|
||||
|
||||
if ($urgensi == 'Elective') {
|
||||
$totals['electiv']++;
|
||||
} else {
|
||||
$totals['cito']++;
|
||||
}
|
||||
|
||||
return $totals;
|
||||
}
|
||||
protected static function mapResultToArray($result) {
|
||||
$nmpasien = $result->nmpasien;
|
||||
$tgl = $result->tgllahirpasien;
|
||||
$jk = $result->jkpasien;
|
||||
$jenis = $result->reques;
|
||||
$tlppasien = $result->tlppasien;
|
||||
$nofoto = $result->nofoto;
|
||||
$verifikasi = $result->verifikasi;
|
||||
$tanggal = $result->daftar;
|
||||
$tanggalfoto = $result->foto;
|
||||
$asuransi = $result->asuransi;
|
||||
$urgensi = $result->urgensi;
|
||||
$from = \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $result->daftar);
|
||||
if (is_null($verifikasi)){
|
||||
$verifikasi = '';
|
||||
$to = '';
|
||||
$durasi = 'On Progress';
|
||||
} else {
|
||||
$to = \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $verifikasi);
|
||||
$durasi = $to->diffForHumans($from);
|
||||
}
|
||||
$arrayttllhr = explode("-", $tgl);
|
||||
if (isset($arrayttllhr[2])){
|
||||
$yy = $arrayttllhr[0];
|
||||
$mm = $arrayttllhr[1];
|
||||
$dd = $arrayttllhr[2];
|
||||
$tgllahir = $dd.'-'.$mm.'-'.$yy;
|
||||
} else { $tgllahir = $tgl; }
|
||||
$arrayttl = explode(" ", $tanggal);
|
||||
$tanggal = $arrayttl[0];
|
||||
if ($jk == 'L') {
|
||||
$l = '1';
|
||||
$p = '';
|
||||
} else {
|
||||
$l = '';
|
||||
$p = '1';
|
||||
}
|
||||
if ($asuransi == 'JKN') {
|
||||
$jkn = '1';
|
||||
$umm = '';
|
||||
$swasta = '';
|
||||
$gcu = '';
|
||||
$tag = '';
|
||||
$bill = '';
|
||||
} else if ($asuransi == 'Umum') {
|
||||
$jkn = '';
|
||||
$umm = '1';
|
||||
$swasta = '';
|
||||
$gcu = '';
|
||||
$tag = '';
|
||||
$bill = '';
|
||||
} else if ($asuransi == 'TAG') {
|
||||
$jkn = '';
|
||||
$umm = '';
|
||||
$swasta = '';
|
||||
$gcu = '';
|
||||
$bill = '';
|
||||
$tag = '1';
|
||||
} else if ($asuransi == 'GCU') {
|
||||
$jkn = '';
|
||||
$umm = '';
|
||||
$swasta = '';
|
||||
$gcu = '1';
|
||||
$tag = '';
|
||||
$bill = '';
|
||||
} else if ($asuransi == 'Billing') {
|
||||
$jkn = '';
|
||||
$umm = '';
|
||||
$swasta = '';
|
||||
$gcu = '';
|
||||
$bill = '1';
|
||||
$tag = '';
|
||||
} else {
|
||||
$jkn = '';
|
||||
$umm = '';
|
||||
$swasta = '1';
|
||||
$gcu = '';
|
||||
$tag = '';
|
||||
$bill = '';
|
||||
}
|
||||
if ($urgensi == 'Elective') {
|
||||
$ele = '1';
|
||||
$cito = '';
|
||||
} else {
|
||||
$ele = '';
|
||||
$cito = '1';
|
||||
}
|
||||
$getjennofoto = explode("-", $nofoto);
|
||||
$jenis = $getjennofoto[0].' '.$jenis;
|
||||
return [
|
||||
'id' => $result->id,
|
||||
'filefoto' => '<a href="' . url('/') . '/hasil/' . $result->nofoto . '" target="_blank">' . $result->nofoto . '</a>',
|
||||
'l' => $l,
|
||||
'p' => $p,
|
||||
'jenis' => $jenis,
|
||||
'jkn' => $jkn,
|
||||
'umm' => $umm,
|
||||
'gcu' => $gcu,
|
||||
'tag' => $tag,
|
||||
'swasta' => $swasta,
|
||||
'billing' => $bill,
|
||||
'ele' => $ele,
|
||||
'cito' => $cito,
|
||||
'asuransi' => $asuransi,
|
||||
'nofoto' => $result->nofoto,
|
||||
'noregister' => $result->noregister,
|
||||
'nmpasien' => $nmpasien,
|
||||
'usia' => $result->usia,
|
||||
'kesimpulan' => $result->kesimpulan,
|
||||
'ruangan' => $result->ruangan,
|
||||
'daftar' => $result->daftar,
|
||||
'created_at' => $result->created_at,
|
||||
'nmdokter' => $result->nmdokter,
|
||||
'nmppdssenior' => $result->nmppdssenior,
|
||||
'nmmiddleppds' => $result->nmmiddleppds,
|
||||
'nmppdsjunior' => $result->nmppdsjunior,
|
||||
'nmppdsmiddle2' => $result->nmppdsmiddle2,
|
||||
'nmppdsjunior2' => $result->nmppdsjunior2,
|
||||
'diagnosa2' => $result->diagnosa2,
|
||||
'nmanalis' => $result->nmanalis,
|
||||
'nmexcutor' => $result->nmexcutor,
|
||||
'alamatpasien' => $result->alamatpasien,
|
||||
'tgllahirpasien'=> $tgl,
|
||||
'jkpasien' => $jk,
|
||||
'tlppasien' => $tlppasien,
|
||||
'modality' => $result->modality,
|
||||
'dlp' => $result->dlp,
|
||||
'kd_spesimen' => $result->kd_spesimen,
|
||||
'nm_spesimen' => $result->nm_spesimen,
|
||||
'status' => $result->status,
|
||||
'asalpasien' => $result->asalpasien,
|
||||
'nmrs' => $result->nmrs,
|
||||
'berat' => $result->berat,
|
||||
'klinisi' => $result->klinisi,
|
||||
'klinis' => $result->klinis,
|
||||
'telpon' => $tlppasien,
|
||||
'verifikasi' => $result->verifikasi,
|
||||
'noloket' => $result->noloket,
|
||||
'foto' => $result->foto,
|
||||
'export' => $result->export,
|
||||
'nmdrafter' => $result->nmdrafter,
|
||||
'tgldraft' => $result->tgldraft,
|
||||
'baca' => $result->baca,
|
||||
'nmpembaca' => $result->nmpembaca,
|
||||
'tgladendum' => $result->tgladendum,
|
||||
'nmadendum' => $result->nmadendum,
|
||||
'durasi' => $durasi,
|
||||
];
|
||||
}
|
||||
protected static function getTotalRow($totals) {
|
||||
return [
|
||||
'id' => '',
|
||||
'filefoto' => '',
|
||||
'noregister'=> '',
|
||||
'nama' => '<strong>Total</strong>',
|
||||
'l' => $totals['m'],
|
||||
'p' => $totals['f'],
|
||||
'jkn' => $totals['jkn'],
|
||||
'umm' => $totals['umum'],
|
||||
'gcu' => $totals['gcu'],
|
||||
'tag' => $totals['tag'],
|
||||
'swasta' => $totals['swasta'],
|
||||
'billing' => $totals['bill'],
|
||||
'ele' => $totals['electiv'],
|
||||
'cito' => $totals['cito'],
|
||||
];
|
||||
}
|
||||
public function report(Request $request) {
|
||||
$bulan = $request->input('bulan');
|
||||
$tahun = $request->input('tahun');
|
||||
$homebase = url("/");
|
||||
$arraylist = [];
|
||||
$limit = $request->input('limit') ?? 500;
|
||||
$page = $request->input('pagenum') ?? 1;
|
||||
$order = $request->input('order') ?? 'id desc';
|
||||
$filterscount = $request->input('filterscount') ?? 0;
|
||||
if ($bulan === 'pertanggal' || $bulan === 'terjadwal') {
|
||||
$results = DB::table($bulan === 'terjadwal' ? 'jadwalperiksan' : 'periksa')->when($bulan === 'terjadwal', function ($query) use ($tahun) {
|
||||
return $query->whereNull('jadwalperiksan.status')
|
||||
->where('jadwalperiksan.daftar', 'LIKE', "%$tahun%");
|
||||
}, function ($query) use ($tahun) {
|
||||
return $query->where('periksa.daftar', 'LIKE', "$tahun%");
|
||||
})->get();
|
||||
$totals = ['m' => 0, 'f' => 0, 'jkn' => 0, 'umum' => 0, 'tag' => 0, 'gcu' => 0, 'bill' => 0, 'swasta' => 0, 'electiv' => 0, 'cito' => 0];
|
||||
foreach ($results as $result) {
|
||||
$asuransi = $result->asuransi;
|
||||
$urgensi = $result->urgensi;
|
||||
$totals = self::updateTotals($totals, $asuransi, $urgensi, $result->jkpasien);
|
||||
$arraylist[] = self::mapResultToArray($result);
|
||||
}
|
||||
if ($bulan === 'pertanggal') {
|
||||
$arraylist[] = self::getTotalRow($totals);
|
||||
}
|
||||
echo json_encode($arraylist);
|
||||
} else {
|
||||
if ($bulan == 'ALL' || $bulan == 'Pick Month') {
|
||||
$results = DB::table('periksa')->where('daftar', 'LIKE', $tahun.'%')->get();
|
||||
} else {
|
||||
$tglcari = $tahun.'-'.$bulan;
|
||||
$results = DB::table('periksa')->where('daftar', 'LIKE', $tglcari.'%')->get();
|
||||
}
|
||||
$totals = ['m' => 0, 'f' => 0, 'jkn' => 0, 'umum' => 0, 'tag' => 0, 'gcu' => 0, 'bill' => 0, 'swasta' => 0, 'electiv' => 0, 'cito' => 0];
|
||||
foreach ($results as $result) {
|
||||
$asuransi = $result->asuransi;
|
||||
$urgensi = $result->urgensi;
|
||||
$totals = self::updateTotals($totals, $asuransi, $urgensi, $result->jkpasien);
|
||||
$arraylist[] = self::mapResultToArray($result);
|
||||
}
|
||||
$arraylist[] = self::getTotalRow($totals);
|
||||
echo json_encode($arraylist);
|
||||
}
|
||||
}
|
||||
public function genRekapAntibiotik(Request $request) {
|
||||
$data = [];
|
||||
$bulan = $request->input('bulan');
|
||||
$tahun = $request->input('tahun');
|
||||
if ($tahun == '' OR is_null($tahun)){
|
||||
$getarray = explode('?', $bulan);
|
||||
$bulan = $getarray[0] ?? date('m');
|
||||
$tahun = $getarray[1] ?? date('Y');
|
||||
$bulan = str_replace('bulan=', '', $bulan);
|
||||
$tahun = str_replace('tahun=', '', $tahun);
|
||||
}
|
||||
if ($bulan == '' OR $bulan == 'ALL' OR $bulan == 'Pick Month') {
|
||||
$orderbydate = Periksa::whereYear('daftar', $tahun)->get();
|
||||
$jsonantibiotik = RekapAntibiotik::whereIn('orderid', $orderbydate->pluck('id'))->get()->groupBy('orderid');
|
||||
} else {
|
||||
$orderbydate = Periksa::whereMonth('daftar', $bulan)->whereYear('daftar', $tahun)->get();
|
||||
$jsonantibiotik = RekapAntibiotik::whereIn('orderid', $orderbydate->pluck('id'))->get()->groupBy('orderid');
|
||||
}
|
||||
return view('admin.rekapantibiotik', compact('orderbydate', 'jsonantibiotik', 'bulan', 'tahun'));
|
||||
}
|
||||
public function genGlassReport(Request $request) {
|
||||
$data = [];
|
||||
$bulan = $request->input('bulan');
|
||||
$tahun = $request->input('tahun');
|
||||
if ($tahun == '' OR is_null($tahun)){
|
||||
$getarray = explode('?', $bulan);
|
||||
$bulan = $getarray[0] ?? date('m');
|
||||
$tahun = $getarray[1] ?? date('Y');
|
||||
$bulan = str_replace('bulan=', '', $bulan);
|
||||
$tahun = str_replace('tahun=', '', $tahun);
|
||||
}
|
||||
if ($bulan == '' OR $bulan == 'ALL' OR $bulan == 'Pick Month') {
|
||||
$orderbydate = Periksa::whereYear('daftar', $tahun)->get();
|
||||
$jsonantibiotik = array(
|
||||
'Oxacillin-OX',
|
||||
'Cefoxitin-FOX',
|
||||
'Benzylpenicillin-P',
|
||||
'Ampicillin-AM',
|
||||
'Azithromycin-AZM',
|
||||
'Erythromycin-ERY',
|
||||
'Cefazolin-CZO',
|
||||
'Cefepime-FEP',
|
||||
'Cefixime-CFM',
|
||||
'Cefotaxime-CTX',
|
||||
'Cefuroxime-CXM',
|
||||
'Ceftazidime-CAZ',
|
||||
'Ceftriaxone-CRO',
|
||||
'Ceftazidime/Avibactam-CZA',
|
||||
'Piperacilin/Tazobactam-TZP',
|
||||
'Ampicillin/Sulbactam-SAM',
|
||||
'Amoxicillin/Clavulanate-AMC',
|
||||
'Cefoperazon/Sulbactam-SCF',
|
||||
'Aztreonam-ATM',
|
||||
'Ceftaroline-CPT',
|
||||
'Ciprofloxacin-CIP',
|
||||
'Levofloxacin-LEV',
|
||||
'Moxifloxacin-MFX',
|
||||
'Clindamycin-CLI',
|
||||
'Colistin-CS', //tidak ada
|
||||
'Tetracyclin-TCY',
|
||||
'Tigecycline-TGC', //double
|
||||
'Gentamicin-GM',
|
||||
'Amikacin-AN',
|
||||
'Meropenem-MEM',
|
||||
'Imipenem-IPM',
|
||||
'Doripenem-DOR',
|
||||
'Ertapenem-ETP',
|
||||
'Minocycline-MNO',
|
||||
'Doxycycline-DOX',
|
||||
'Spectinomycin-SPT',
|
||||
'Tigecycline-TGC', //sama-ini
|
||||
'Trimethoprim/Sulfamethoxazole-SXT',
|
||||
'Fosfomycin-FOS',
|
||||
'Vancomycin-VAN',
|
||||
'Linezolid-LNZ',
|
||||
'Fluconazole', //tidak ada
|
||||
'Voriconazole', //tidak ada
|
||||
'Caspofungin', //tidak ada
|
||||
'Micafungin', //tidak ada
|
||||
'Amphotericin B', //tidak ada
|
||||
'Flucytosine' //tidak ada
|
||||
);
|
||||
} else {
|
||||
$orderbydate = Periksa::whereMonth('daftar', $bulan)->whereYear('daftar', $tahun)->get();
|
||||
$jsonantibiotik = array(
|
||||
'Oxacillin-OX',
|
||||
'Cefoxitin-FOX',
|
||||
'Benzylpenicillin-P',
|
||||
'Ampicillin-AM',
|
||||
'Azithromycin-AZM',
|
||||
'Erythromycin-ERY',
|
||||
'Cefazolin-CZO',
|
||||
'Cefepime-FEP',
|
||||
'Cefixime-CFM',
|
||||
'Cefotaxime-CTX',
|
||||
'Cefuroxime-CXM',
|
||||
'Ceftazidime-CAZ',
|
||||
'Ceftriaxone-CRO',
|
||||
'Ceftazidime/Avibactam-CZA',
|
||||
'Piperacilin/Tazobactam-TZP',
|
||||
'Ampicillin/Sulbactam-SAM',
|
||||
'Amoxicillin/Clavulanate-AMC',
|
||||
'Cefoperazon/Sulbactam-SCF',
|
||||
'Aztreonam-ATM',
|
||||
'Ceftaroline-CPT',
|
||||
'Ciprofloxacin-CIP',
|
||||
'Levofloxacin-LEV',
|
||||
'Moxifloxacin-MFX',
|
||||
'Clindamycin-CLI',
|
||||
'Colistin-CS',
|
||||
'Tetracyclin-TCY',
|
||||
'Tigecycline-TGC',
|
||||
'Gentamicin-GM',
|
||||
'Amikacin-AN',
|
||||
'Meropenem-MEM',
|
||||
'Imipenem-IPM',
|
||||
'Doripenem-DOR',
|
||||
'Ertapenem-ETP',
|
||||
'Minocycline-MNO',
|
||||
'Doxycycline-DOX',
|
||||
'Spectinomycin-SPT',
|
||||
'Tigecycline-TGC',
|
||||
'Trimethoprim/Sulfamethoxazole-SXT',
|
||||
'Fosfomycin-FOS',
|
||||
'Vancomycin-VAN',
|
||||
'Linezolid-LNZ',
|
||||
'Fluconazole',
|
||||
'Voriconazole',
|
||||
'Caspofungin',
|
||||
'Micafungin',
|
||||
'Amphotericin B',
|
||||
'Flucytosine'
|
||||
);
|
||||
}
|
||||
return view('admin.glassreport', compact('orderbydate', 'jsonantibiotik', 'bulan', 'tahun'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,263 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Defuse\Crypto\Crypto;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use App\Models\User;
|
||||
use Mail;
|
||||
use QrCode;
|
||||
use PDFCREATOR;
|
||||
|
||||
define( 'API_ACCESS_SEND', 'AAAA6YBXh1k:APA91bFL0q7QAXQGohXMpTwHco79f13C8PFk1Oo8kKhg1JerOulT9-37dxyP8X5ibABI0NuQ4ZsVxKQKCt7HuR7lUdJJuB-hTVnBmOUIBYfBlHb-Lcp6aGkj4erfF7J__A5hufXjF8Vt' );
|
||||
|
||||
class SendMail extends Controller
|
||||
{
|
||||
protected static $pass = 'S1v3pY0uB3e';
|
||||
protected static function enkrip($string){
|
||||
return Crypto::encryptWithPassword($string,self::$pass);
|
||||
}
|
||||
public static function dekrip($enc){
|
||||
try{
|
||||
return Crypto::decryptWithPassword($enc,self::$pass);
|
||||
}catch (\Exception $e){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static function kirim($to_name,$to_email,$forget=false){
|
||||
$date=date('YmdHis');
|
||||
$cekdata = User::where('email', $to_email)->orderBy('id', 'DESC')->first();
|
||||
if (isset($cekdata->id)){
|
||||
if($forget){
|
||||
$string_enc = $to_email.'|'.$date.'|FOR';
|
||||
$url = url('/verifikasiemail').'?key='.self::enkrip($string_enc);
|
||||
$subject = 'Ubah Password ('.$cekdata->fakpanjang.')';
|
||||
$subjectmail = 'Ubah Password';
|
||||
$note = 'Anda telah melakukan permohonan ubah password. Silahkan klik link berikut untuk melanjutkan proses.';
|
||||
DB::table('password_resets')->insert([
|
||||
'email' => $to_email,
|
||||
'token' => self::enkrip($string_enc),
|
||||
'created_at'=> date("Y-m-d H:i:s")
|
||||
]);
|
||||
}else{
|
||||
$string_enc = $to_email.'|'.$date.'|VER';
|
||||
$url = url('/verifikasiemail').'?key='.self::enkrip($string_enc);
|
||||
$subject = 'Verifikasi Email ('.$cekdata->fakpanjang.')';
|
||||
$subjectmail = 'Verifikasi Email';
|
||||
$note = 'Email anda telah terdaftar di Aplikasi ('.$cekdata->fakpanjang.') Email ini dapat digunakan jika anda lupa password. Selanjutnya dimohon Bapak/Ibu membuat password untuk login ke aplikasi dengan cara Klik Tombol di bawah ini.';
|
||||
}
|
||||
$data = array(
|
||||
'nama_lengkap' => $to_name,
|
||||
'fakultas' => $cekdata->fakpanjang,
|
||||
'url_verifikasi' => $url,
|
||||
'forget' => $forget,
|
||||
'subject' => $subjectmail,
|
||||
'note' => $note,
|
||||
);
|
||||
if ($to_email != '[email protected]'){
|
||||
Mail::send('mail/user', $data, function($message) use ($to_name, $to_email, $subject) {
|
||||
$message->to($to_email, $to_name)->subject($subject);
|
||||
$message->from('[email protected]','Mail Admin');
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
public static function kirimUser($to_name,$to_email,$to_username,$password,$ubahpass=false){
|
||||
$date=date('YmdHis');
|
||||
$cekdata = User::where('email', $to_email)->first();
|
||||
if (isset($cekdata->id)){
|
||||
if($ubahpass){
|
||||
$subject = 'Password User Diubah ('.$cekdata->fakpanjang.')';
|
||||
$note = 'Password anda telah diubah oleh admin dengan password berikut:';
|
||||
}else{
|
||||
$subject = 'User Didaftarkan ('.$cekdata->fakpanjang.')';
|
||||
$note = 'Email anda telah terdaftar di Aplikasi ('.$cekdata->fakpanjang.'). Email ini dapat digunakan jika anda lupa password. Untuk login silahkan akses dengan user <b>'.$to_username.'</b> atau email ini dan dengan password berikut:';
|
||||
}
|
||||
$data = array(
|
||||
'nama_lengkap' => $to_name,
|
||||
'password' => $password,
|
||||
'subject' => $subject,
|
||||
'note' => $note,
|
||||
);
|
||||
if ($to_email != '[email protected]'){
|
||||
Mail::send('mail/useradmin', $data, function($message) use ($to_name, $to_email, $subject) {
|
||||
$message->to($to_email, $to_name)->subject($subject);
|
||||
$message->from('[email protected]','Mail Admin');
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
public static function notif($to_name,$to_email,$subject,$note){
|
||||
$data = array(
|
||||
'nama_lengkap' => $to_name,
|
||||
'subject' => $subject,
|
||||
'note' => $note,
|
||||
);
|
||||
if ($to_email != '[email protected]'){
|
||||
Mail::send('mail/notif', $data, function($message) use ($to_name, $to_email, $subject) {
|
||||
$message->to($to_email, $to_name)->subject($subject);
|
||||
$message->from('[email protected]','Mail Admin');
|
||||
});
|
||||
}
|
||||
$jtokencari = User::where('email', $to_email)->whereNotNull('firebaseid')->get();
|
||||
if (!empty($jtokencari)){
|
||||
foreach ( $jtokencari as $rtokencari ){
|
||||
$firebaseid = $rtokencari->firebase;
|
||||
$msg = array (
|
||||
'message' => $subject,
|
||||
'title' => Session('namaapps01'),
|
||||
'subtitle' => Session('fakpanjang'),
|
||||
'tickerText'=> 'Notification Centre',
|
||||
'image' => '',
|
||||
'vibrate' => 1,
|
||||
'sound' => 1,
|
||||
'largeIcon' => 'large_icon',
|
||||
'smallIcon' => 'small_icon'
|
||||
);
|
||||
$fields = array
|
||||
(
|
||||
'to' => $firebaseid,
|
||||
'priority' => 'high',
|
||||
'notification' => [
|
||||
"title" => Session('namaapps01'),
|
||||
"sound" => "default",
|
||||
"body" => $subject
|
||||
],
|
||||
'data' => $msg
|
||||
|
||||
);
|
||||
$headers = array
|
||||
(
|
||||
'Authorization: key=' . API_ACCESS_SEND,
|
||||
'Content-Type: application/json'
|
||||
);
|
||||
$url = 'https://fcm.googleapis.com/fcm/send';
|
||||
$ch = curl_init();
|
||||
|
||||
// Set the url, number of POST vars, POST data
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
// Disabling SSL Certificate support temporarly
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
|
||||
|
||||
// Execute post
|
||||
$result = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
}
|
||||
}
|
||||
}
|
||||
public static function mobilenotif($to_name,$to_email,$subject,$note){
|
||||
$pesan = '';
|
||||
$tuliskirim = $note;
|
||||
if ($to_name == 'all'){
|
||||
$getppds = User::where('previlage', $to_email)->whereNotNull('firebase')->get();
|
||||
if (!empty($getppds)){
|
||||
|
||||
foreach($getppds as $rowsppds){
|
||||
$firebaseid = $rowsppds->firebase;
|
||||
$msg = array (
|
||||
'message' => $tuliskirim,
|
||||
'title' => 'LIS',
|
||||
'subtitle' => 'Laboratory Information System',
|
||||
'tickerText'=> 'Pasien Terkirim ke PACS',
|
||||
'image' => '',
|
||||
'vibrate' => 1,
|
||||
'sound' => 1,
|
||||
'largeIcon' => 'large_icon',
|
||||
'smallIcon' => 'small_icon'
|
||||
);
|
||||
$fields = array
|
||||
(
|
||||
'to' => $firebaseid,
|
||||
'priority' => 'high',
|
||||
'notification' => [
|
||||
"title" => 'LIS-RSSA Notification Control',
|
||||
"sound" => "default",
|
||||
"body" => $tuliskirim
|
||||
],
|
||||
'data' => $msg
|
||||
);
|
||||
$headers = array
|
||||
(
|
||||
'Authorization: key=' . API_ACCESS_KEY,
|
||||
'Content-Type: application/json'
|
||||
);
|
||||
$url = 'https://fcm.googleapis.com/fcm/send';
|
||||
$ch = curl_init();
|
||||
// Set the url, number of POST vars, POST data
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
// Disabling SSL Certificate support temporarly
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
|
||||
// Execute post
|
||||
$result = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
$pesan = $pesan.'<br />Notif To : '.$rowsppds->nama;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$msg = array (
|
||||
'message' => $tuliskirim,
|
||||
'title' => 'LIS',
|
||||
'subtitle' => 'Laboratory Information System',
|
||||
'tickerText'=> 'Adendum Saved',
|
||||
'image' => '',
|
||||
'vibrate' => 1,
|
||||
'sound' => 1,
|
||||
'largeIcon' => 'large_icon',
|
||||
'smallIcon' => 'small_icon'
|
||||
);
|
||||
$fields = array
|
||||
(
|
||||
'to' => $to_email,
|
||||
'priority' => 'high',
|
||||
'notification' => [
|
||||
"title" => 'LIS-RSSA Notification Control',
|
||||
"sound" => "default",
|
||||
"body" => $tuliskirim
|
||||
],
|
||||
'data' => $msg
|
||||
|
||||
);
|
||||
$headers = array
|
||||
(
|
||||
'Authorization: key=' . API_ACCESS_KEY,
|
||||
'Content-Type: application/json'
|
||||
);
|
||||
$url = 'https://fcm.googleapis.com/fcm/send';
|
||||
$ch = curl_init();
|
||||
|
||||
// Set the url, number of POST vars, POST data
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
// Disabling SSL Certificate support temporarly
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
|
||||
|
||||
// Execute post
|
||||
$result = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
}
|
||||
return $pesan;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,336 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use App\Jawaban;
|
||||
use App\Subjawaban;
|
||||
use App\SiraB;
|
||||
use App\Organisms;
|
||||
|
||||
use Validator;
|
||||
use Picqer\Barcode\BarcodeGeneratorPNG;
|
||||
use Session;
|
||||
|
||||
class TemplateController extends Controller
|
||||
{
|
||||
public function index() {
|
||||
if (Session::get('previlage') == ''){
|
||||
return redirect('/login');
|
||||
} else {
|
||||
$data = [];
|
||||
$getsirab = Organisms::whereNotIn('kelompok', ['biakankultur', 'mikroorganisme', 'listkodespesimen'])->select('kelompok')->groupBy('kelompok')->orderBy('kelompok', 'ASC')->get();
|
||||
$data['parameters'] = $getsirab;
|
||||
return view('admin.template', $data);
|
||||
}
|
||||
}
|
||||
public function viewSIRAb() {
|
||||
$previlage = Session('previlage');
|
||||
if ($previlage == 'developer' OR $previlage == 'supervisor') {
|
||||
$data = [];
|
||||
return view('admin.sirab', $data);
|
||||
} else {
|
||||
$data = [];
|
||||
$data['kalimatheader'] = 'Access Denied';
|
||||
$data['kalimatbody'] = 'Laman khusus SPV';
|
||||
return view('errors.error', $data);
|
||||
}
|
||||
}
|
||||
public function backup() {
|
||||
$previlage = Session('previlage');
|
||||
if ($previlage == 'developer' OR $previlage == 'supervisor') {
|
||||
$data = [];
|
||||
$data['alldata'] = Storage::allFiles('/usr/share/nginx/html/rispacs/public/backupdata');
|
||||
return view('backup', $data);
|
||||
} else {
|
||||
$data = [];
|
||||
$data['kalimatheader'] = 'Access Denied';
|
||||
$data['kalimatbody'] = 'Laman khusus SPV';
|
||||
return view('errors.error', $data);
|
||||
}
|
||||
}
|
||||
public function getListJawaban() {
|
||||
$results = DB::table('jawaban')->get();
|
||||
$arraylist = [];
|
||||
$arraylist[]= array(
|
||||
'id' => 'new',
|
||||
'jawaban' => '<span class="badge badge-primary">Add New</span>'
|
||||
);
|
||||
foreach ($results as $result) {
|
||||
$arraylist[] = array(
|
||||
'id' => $result->id,
|
||||
'jawaban' => $result->jawaban,
|
||||
);
|
||||
}
|
||||
|
||||
echo json_encode($arraylist);
|
||||
}
|
||||
public function updateJawaban(Request $request) {
|
||||
$validator = Validator::make($request->all(), [
|
||||
'val01' => 'required',
|
||||
'val02' => 'required'
|
||||
]);
|
||||
|
||||
if($validator->fails()) {
|
||||
return response()->json(['status' => 'error', 'message' => 'Please fill input field or fill with right input']);
|
||||
} else {
|
||||
$id = $request->input('val02');
|
||||
if ($id != 'new'){
|
||||
Jawaban::where('id', $id)->update(['jawaban' => $request->input('val01')]);
|
||||
}
|
||||
else {
|
||||
Jawaban::create(['jawaban' => $request->input('val01')]);
|
||||
}
|
||||
return response()->json(['status' => 'Success !!', 'message' => 'Category Saved..!!']);
|
||||
}
|
||||
}
|
||||
public function deleteJawaban(Request $request) {
|
||||
try {
|
||||
$id = $request->id;
|
||||
if ($id == 'sirab'){
|
||||
$data = SiraB::find($request->idsirab);
|
||||
} else if ($id == 'mikroorganisme'){
|
||||
$data = Organisms::find($request->idsirab);
|
||||
} else {
|
||||
$data = Jawaban::find($id);
|
||||
}
|
||||
$data->delete();
|
||||
if ($data){
|
||||
return response()->json(['icon' => 'success', 'warna' => '#5ba035', 'status' => 'Success', 'message' => 'Deleted']);
|
||||
return back();
|
||||
} else {
|
||||
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Failed', 'message' => 'Unkown Error']);
|
||||
return back();
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Failed', 'message' => $e->getMessage()]);
|
||||
return back();
|
||||
}
|
||||
|
||||
}
|
||||
public function getListSubjawaban(Request $request) {
|
||||
$idkat = $request->input('val01');
|
||||
$kategori = $request->input('val02');
|
||||
if ($idkat == 'new') {
|
||||
$arraylist = [];
|
||||
$arraylist[]= array(
|
||||
'id' => 'gakboleh',
|
||||
'kategori' => '-',
|
||||
'judul' => '<span class="badge badge-danger">Please Select Category First</span>',
|
||||
'isine' => '-',
|
||||
'kesimpulan'=> '-'
|
||||
);
|
||||
} else {
|
||||
$arraylist = [];
|
||||
$arraylist[]= array(
|
||||
'id' => 'new',
|
||||
'kategori' => '-',
|
||||
'judul' => '<span class="badge badge-custom">Add New Expertise Themplate</span>',
|
||||
'isine' => '-',
|
||||
'kesimpulan'=> '-'
|
||||
);
|
||||
$results = Subjawaban::where('kategori', $idkat)->get();
|
||||
|
||||
foreach ($results as $result) {
|
||||
$isine = $result->subjawaban;
|
||||
$kesimpulan = $result->kesimpulan;
|
||||
$isine = $isine.' '.$kesimpulan;
|
||||
$arraylist[] = array(
|
||||
'id' => $result->id,
|
||||
'kategori' => $kategori,
|
||||
'judul' => $result->judul,
|
||||
'isine' => $isine,
|
||||
'kesimpulan'=> ''
|
||||
);
|
||||
}
|
||||
}
|
||||
echo json_encode($arraylist);
|
||||
}
|
||||
public function updateSubjawaban(Request $request) {
|
||||
$validator = Validator::make($request->all(), [
|
||||
'val01' => 'required',
|
||||
'val02' => 'required',
|
||||
'val03' => 'required',
|
||||
'val04' => 'required'
|
||||
]);
|
||||
if($validator->fails()) {
|
||||
return response()->json(['status' => 'Error !!', 'message' => 'Please fill input field or fill with right input']);
|
||||
} else {
|
||||
$id = $request->input('val02');
|
||||
if ($id != 'new'){
|
||||
Subjawaban::where('id', $id)->update([
|
||||
'judul' => $request->input('val03'),
|
||||
'subjawaban'=> $request->input('val04'),
|
||||
'kesimpulan'=> ''
|
||||
]);
|
||||
}
|
||||
else {
|
||||
Subjawaban::create([
|
||||
'kategori' => $request->input('val01'),
|
||||
'judul' => $request->input('val03'),
|
||||
'subjawaban'=> $request->input('val04'),
|
||||
'kesimpulan'=> ''
|
||||
]);
|
||||
}
|
||||
return response()->json(['status' => 'Success !!', 'message' => 'Template Saved..!!']);
|
||||
|
||||
}
|
||||
}
|
||||
public function deleteSubjawaban(Request $request) {
|
||||
$id = $request->id;
|
||||
$subjawaban = Subjawaban::find($id);
|
||||
|
||||
$subjawaban->delete();
|
||||
|
||||
return back();
|
||||
}
|
||||
public function showImage($imageName){
|
||||
// Menentukan path gambar di storage
|
||||
$filePath = public_path("{$imageName}");
|
||||
|
||||
// Cek apakah file ada
|
||||
if (!file_exists($filePath)) {
|
||||
abort(404); // Jika file tidak ditemukan, tampilkan error 404
|
||||
}
|
||||
|
||||
// Ambil konten file gambar
|
||||
$imageContent = file_get_contents($filePath);
|
||||
|
||||
// Tentukan MIME type untuk gambar PNG
|
||||
$mimeType = mime_content_type($filePath);
|
||||
|
||||
// Kirim gambar sebagai response dengan header untuk mencegah cache
|
||||
return response($imageContent, 200)
|
||||
->header('Content-Type', $mimeType) // Tentukan MIME type gambar
|
||||
->header('Cache-Control', 'no-store, no-cache, must-revalidate') // Tidak cache di browser
|
||||
->header('Pragma', 'no-cache') // Tidak menggunakan cache pada browser lama
|
||||
->header('Expires', '0'); // Jangan pernah kadaluarsa
|
||||
}
|
||||
public function exUploadKOP(Request $request) {
|
||||
if($request->hasFile('file')) {
|
||||
$ImageExt = $request->file('file')->getClientOriginalExtension();
|
||||
$file_tmp = $request->file('file');
|
||||
$data = file_get_contents($file_tmp);
|
||||
if ($ImageExt == 'png'){
|
||||
try {
|
||||
$unggah = Storage::disk('langsungpublic')->put('kopsurat.png', $data);
|
||||
|
||||
if ($unggah){
|
||||
return response()->json(['icon' => 'success', 'warna' => '#5ba035', 'status' => 'Success', 'message' => 'Pictures Saved, please refresh to apply the change']);
|
||||
return back();
|
||||
} else {
|
||||
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Failed', 'message' => 'Unkown Error']);
|
||||
return back();
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Failed', 'message' => $e->getMessage()]);
|
||||
return back();
|
||||
}
|
||||
} else {
|
||||
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Failed', 'message' => 'Only Accept PNG File']);
|
||||
return back();
|
||||
}
|
||||
} else {
|
||||
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Failed', 'message' => 'No File Selected']);
|
||||
return back();
|
||||
}
|
||||
}
|
||||
public function showBarcode($nofoto){
|
||||
$generator = new BarcodeGeneratorPNG();
|
||||
$barcodeImage = $generator->getBarcode($nofoto, $generator::TYPE_CODE_128);
|
||||
return response($barcodeImage, 200)->header('Content-Type', 'image/png');
|
||||
}
|
||||
public function exSIRAb(Request $request) {
|
||||
try {
|
||||
$id = $request->id;
|
||||
$tabel = $request->tabel;
|
||||
$pesan = 'Unkown Error';
|
||||
if ($tabel == 'Organisme'){
|
||||
if ($id == 'new'){
|
||||
$ceksudah = Organisms::where('name', $request->name)->where('category', $request->category)->where('kelompok', $request->kelompok)->count();
|
||||
if ($ceksudah == 0){
|
||||
$data = new Organisms;
|
||||
$inputData = $request->except(['id', 'tabel', '_token']);
|
||||
$data->fill($inputData);
|
||||
$data->save();
|
||||
} else {
|
||||
$pesan = $request->name.' ('.$request->category.') Sudah ada, Mohon ubah Data sebelum simpan kembali';
|
||||
}
|
||||
} else {
|
||||
$ceksudah = Organisms::where('id', '!=', $id)->where('name', $request->name)->where('category', $request->category)->where('kelompok', $request->kelompok)->count();
|
||||
if ($ceksudah == 0){
|
||||
$data = Organisms::find($id);
|
||||
$inputData = $request->except(['id', 'tabel', '_token']);
|
||||
$data->update($inputData);
|
||||
} else {
|
||||
$pesan = $request->name.' ('.$request->category.') Sudah ada, Mohon ubah Data sebelum simpan kembali';
|
||||
}
|
||||
}
|
||||
if ($data){
|
||||
return response()->json(['icon' => 'success', 'warna' => '#5ba035', 'status' => 'Success', 'message' => 'Saved']);
|
||||
return back();
|
||||
} else {
|
||||
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Failed', 'message' => 'Unkown Error']);
|
||||
return back();
|
||||
}
|
||||
} else if ($tabel == 'Parameter'){
|
||||
$getdatalama = Organisms::where('kelompok', $request->kelompok)->first();
|
||||
$category = $getdatalama->category ?? $request->kelompok;
|
||||
|
||||
if ($id == 'new'){
|
||||
$ceksudah = Organisms::where('name', $request->name)->where('category', $category)->where('kelompok', $request->kelompok)->count();
|
||||
if ($ceksudah == 0){
|
||||
$data = Organisms::create([
|
||||
'name' => $request->name,
|
||||
'category' => $category,
|
||||
'kelompok' => $request->kelompok
|
||||
]);
|
||||
} else {
|
||||
$pesan = $request->name.' ('.$request->category.') Sudah ada, Mohon ubah Data sebelum simpan kembali';
|
||||
}
|
||||
} else {
|
||||
$ceksudah = Organisms::where('id', '!=', $id)->where('name', $request->name)->where('category', $category)->where('kelompok', $request->kelompok)->count();
|
||||
if ($ceksudah == 0){
|
||||
$data = Organisms::where('id', $id)->update([
|
||||
'name' => $request->name,
|
||||
'category' => $category,
|
||||
'kelompok' => $request->kelompok
|
||||
]);
|
||||
} else {
|
||||
$pesan = $request->name.' ('.$request->category.') Sudah ada, Mohon ubah Data sebelum simpan kembali';
|
||||
}
|
||||
}
|
||||
if ($data){
|
||||
return response()->json(['icon' => 'success', 'warna' => '#5ba035', 'status' => 'Success', 'message' => 'Saved']);
|
||||
return back();
|
||||
} else {
|
||||
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Failed', 'message' => 'Unkown Error']);
|
||||
return back();
|
||||
}
|
||||
} else {
|
||||
if ($id == 'new'){
|
||||
$data = new SiraB;
|
||||
$inputData = $request->except(['id', 'tabel', '_token']);
|
||||
$data->fill($inputData);
|
||||
$data->save();
|
||||
} else {
|
||||
$data = SiraB::find($id);
|
||||
$inputData = $request->except(['id', 'tabel', '_token']);
|
||||
$data->update($inputData);
|
||||
}
|
||||
if ($data){
|
||||
return response()->json(['icon' => 'success', 'warna' => '#5ba035', 'status' => 'Success', 'message' => 'Saved']);
|
||||
return back();
|
||||
} else {
|
||||
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Failed', 'message' => 'Unkown Error']);
|
||||
return back();
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Failed', 'message' => $e->getMessage()]);
|
||||
return back();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,299 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\User;
|
||||
use App\Setting;
|
||||
use App\Dokter;
|
||||
use App\Worklist;
|
||||
use App\XFiles;
|
||||
use Validator;
|
||||
use Session;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
public function index() {
|
||||
$cekkelompok= Session('previlage');
|
||||
if (Session::get('previlage') == ''){
|
||||
return redirect('/login');
|
||||
} else {
|
||||
if ($cekkelompok == 'supervisor' OR $cekkelompok == 'admin' OR $cekkelompok == 'developer'){
|
||||
$users = User::all();
|
||||
} else {
|
||||
$users = User::where('previlage', $cekkelompok)->get();
|
||||
}
|
||||
$getsetting = Setting::where('id', '1')->first();
|
||||
$data = [];
|
||||
$data['users'] = $users;
|
||||
$data['pacsaddr'] = $getsetting->pacs ?? '';
|
||||
$data['zfpaddr'] = $getsetting->zfp ?? '';
|
||||
$data['port'] = $getsetting->port ?? '';
|
||||
$data['portzfp'] = $getsetting->portzfp ?? '';
|
||||
$data['username'] = $getsetting->username ?? '';
|
||||
$data['password'] = $getsetting->password ?? '';
|
||||
return view('admin.user', $data);
|
||||
}
|
||||
}
|
||||
public function exSetting(Request $request) {
|
||||
$validator = Validator::make($request->all(), [
|
||||
'val01' => 'required',
|
||||
'val02' => 'required',
|
||||
'val03' => 'required',
|
||||
'val04' => 'required',
|
||||
'val05' => 'required',
|
||||
'val06' => 'required',
|
||||
]);
|
||||
|
||||
if($validator->fails()) {
|
||||
return response()->json(['status' => 'error', 'message' => 'Please fill input field or fill with right input']);
|
||||
} else {
|
||||
$update = Setting::where('id', '1')->update([
|
||||
'pacs' => $request->input('val01'),
|
||||
'zfp' => $request->input('val02'),
|
||||
'port' => $request->input('val03'),
|
||||
'portzfp' => $request->input('val06'),
|
||||
'username' => $request->input('val04'),
|
||||
'password' => $request->input('val05')
|
||||
]);
|
||||
if ($update) {
|
||||
return response()->json(['icon' => 'success', 'warna' => '#5ba035', 'status' => 'Success', 'message' => 'Setting Saved..!!!']);
|
||||
return back();
|
||||
}
|
||||
else {
|
||||
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Error.!!', 'message' => 'System Down, please try again in a few years....']);
|
||||
return back();
|
||||
}
|
||||
}
|
||||
}
|
||||
public function exSettingworklist(Request $request) {
|
||||
$idne = $request->input('val01');
|
||||
if ($idne == 'delete'){
|
||||
$delete = Worklist::where('id', $request->input('val02'))->delete();
|
||||
if ($delete) {
|
||||
return response()->json(['icon' => 'success', 'warna' => '#5ba035', 'status' => 'Success', 'message' => 'Worklist Deleted..!!!']);
|
||||
return back();
|
||||
}
|
||||
else {
|
||||
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Error.!!', 'message' => 'System Down, please try again in a few years....']);
|
||||
return back();
|
||||
}
|
||||
} else {
|
||||
$validator = Validator::make($request->all(), [
|
||||
'val01' => 'required',
|
||||
'val02' => 'required',
|
||||
'val03' => 'required',
|
||||
'val04' => 'required',
|
||||
'val05' => 'required',
|
||||
]);
|
||||
|
||||
if($validator->fails()) {
|
||||
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Error.!!', 'message' => 'Please fill input field or fill with right input']);
|
||||
} else {
|
||||
|
||||
if ($idne == 'new'){
|
||||
$input = Worklist::create([
|
||||
'aetitle' => $request->input('val05'),
|
||||
'portnumber' => $request->input('val04'),
|
||||
'ipaddress' => $request->input('val02'),
|
||||
'location' => $request->input('val03'),
|
||||
'modaliti' => $request->input('val06')
|
||||
]);
|
||||
} else {
|
||||
$input = Worklist::where('id', $idne)->update([
|
||||
'aetitle' => $request->input('val05'),
|
||||
'portnumber' => $request->input('val04'),
|
||||
'ipaddress' => $request->input('val02'),
|
||||
'location' => $request->input('val03'),
|
||||
'modaliti' => $request->input('val06')
|
||||
]);
|
||||
}
|
||||
if ($input) {
|
||||
return response()->json(['icon' => 'success', 'warna' => '#5ba035', 'status' => 'Success', 'message' => 'Worklist Saved..!!!']);
|
||||
return back();
|
||||
}
|
||||
else {
|
||||
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Error.!!', 'message' => 'System Down, please try again in a few years....']);
|
||||
return back();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public function exTtd(Request $request) {
|
||||
$iduser = Session('id');
|
||||
$marking = Session('username').'-Photo-'.$iduser;
|
||||
$update = XFiles::updateOrCreate(
|
||||
[
|
||||
'xmarking' => $marking,
|
||||
],
|
||||
[
|
||||
'xjenis' => 'Tandatangan',
|
||||
'xtabel' => Session('username'),
|
||||
'xfile' => $request->input('val01')
|
||||
]
|
||||
);
|
||||
if ($update) {
|
||||
User::where('id', $iduser)->update([
|
||||
'tandatangan' => $marking,
|
||||
]);
|
||||
return response()->json(['icon' => 'success', 'warna' => '#5ba035', 'status' => 'Success', 'message' => 'Signature Saved..!!!']);
|
||||
return back();
|
||||
}
|
||||
else {
|
||||
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Error.!!', 'message' => 'System Down, please try again in a few years....']);
|
||||
return back();
|
||||
}
|
||||
}
|
||||
public function store(Request $request) {
|
||||
$validator = Validator::make($request->all(), [
|
||||
'nama' => 'required',
|
||||
'username' => 'required',
|
||||
'password' => 'required',
|
||||
'previlage' => 'required',
|
||||
]);
|
||||
|
||||
if($validator->fails()) {
|
||||
Session::flash('message', 'Please fill input field or fill with right input');
|
||||
Session::flash('alert-class', 'alert-danger');
|
||||
return back();
|
||||
} else {
|
||||
$username = $request->input('username');
|
||||
$previlage = $request->input('previlage');
|
||||
$nama = $request->input('nama');
|
||||
$cekuser = User::where('username', $username)->count();
|
||||
if ($cekuser == 0){
|
||||
if ($previlage == 'supervisor' OR $previlage == 'developer'){
|
||||
$iduser = User::insertGetId([
|
||||
'nama' => $request->input('nama'),
|
||||
'username' => $request->input('username'),
|
||||
'password' => bcrypt($request->input('password')),
|
||||
'previlage' => $request->input('previlage')
|
||||
]);
|
||||
Dokter::create([
|
||||
'id' => $iduser,
|
||||
'nama' => $request->input('nama'),
|
||||
'kota' => config('global.kota'),
|
||||
'alamat' => config('global.addressapps')
|
||||
]);
|
||||
} else {
|
||||
$user = User::create([
|
||||
'nama' => $request->input('nama'),
|
||||
'username' => $request->input('username'),
|
||||
'password' => bcrypt($request->input('password')),
|
||||
'previlage' => $request->input('previlage')
|
||||
]);
|
||||
}
|
||||
Session::flash('message', 'Username for '.$nama.' Saved');
|
||||
Session::flash('alert-class', 'alert-success');
|
||||
return back();
|
||||
} else {
|
||||
Session::flash('message', 'Username already used, please use another username');
|
||||
Session::flash('alert-class', 'alert-danger');
|
||||
return back();
|
||||
}
|
||||
}
|
||||
}
|
||||
public function getUser(Request $request) {
|
||||
$id = $request->input('id');
|
||||
$result = User::where('id', $id)->first();
|
||||
echo json_encode($result);
|
||||
}
|
||||
public function getWorklist() {
|
||||
$arrworklist = [];
|
||||
$getworklist = Worklist::orderBy('location', 'ASC')->get();
|
||||
foreach ($getworklist as $rowida) {
|
||||
$arrworklist[] = array(
|
||||
'id' => $rowida->id,
|
||||
'aetitle' => $rowida->aetitle,
|
||||
'portnumber' => $rowida->portnumber,
|
||||
'ipaddress' => $rowida->ipaddress,
|
||||
'location' => $rowida->location,
|
||||
'modaliti' => $rowida->modaliti,
|
||||
);
|
||||
}
|
||||
echo json_encode($arrworklist);
|
||||
}
|
||||
public function update(Request $request) {
|
||||
$validator = Validator::make($request->all(), [
|
||||
'nama' => 'required',
|
||||
'username' => 'required',
|
||||
'previlage' => 'required'
|
||||
]);
|
||||
|
||||
if($validator->fails()) {
|
||||
return response()->json(['status' => 'error', 'message' => 'Please fill input field or fill with right input']);
|
||||
} else {
|
||||
$id = $request->input('id_user');
|
||||
$password = $request->input('password');
|
||||
if ($password == ''){
|
||||
$update = User::where('id', $id)->update([
|
||||
'nama' => $request->input('nama'),
|
||||
'username' => $request->input('username'),
|
||||
'previlage' => $request->input('previlage')
|
||||
]);
|
||||
} else {
|
||||
$update = User::where('id', $id)->update([
|
||||
'nama' => $request->input('nama'),
|
||||
'username' => $request->input('username'),
|
||||
'password' => bcrypt($request->input('password')),
|
||||
'previlage' => $request->input('previlage')
|
||||
]);
|
||||
}
|
||||
|
||||
if ($update){
|
||||
Session::flash('message', 'Updated');
|
||||
Session::flash('alert-class', 'alert-success');
|
||||
|
||||
return back();
|
||||
} else {
|
||||
Session::flash('message', 'Update Failed, Please Try Again in a few year');
|
||||
Session::flash('alert-class', 'alert-success');
|
||||
|
||||
return back();
|
||||
}
|
||||
}
|
||||
}
|
||||
public function updateFoto(Request $request) {
|
||||
$iduser = Session('id');
|
||||
$marking = Session('username').'-Photo-'.$iduser;
|
||||
if($request->hasFile('file')) {
|
||||
$ImageExt = $request->file('file')->getClientOriginalExtension();
|
||||
$file_tmp = $request->file('file');
|
||||
$data = file_get_contents($file_tmp);
|
||||
$photo = 'data:image/' . $ImageExt . ';base64,' . base64_encode($data);
|
||||
$iduser = Session('id');
|
||||
$update = XFiles::updateOrCreate(
|
||||
[
|
||||
'xmarking' => $marking,
|
||||
],
|
||||
[
|
||||
'xtabel' => Session('username'),
|
||||
'xjenis' => 'Photo',
|
||||
'xfile' => $photo
|
||||
]
|
||||
);
|
||||
if ($update) {
|
||||
User::where('id', $iduser)->update([
|
||||
'photo' => $marking,
|
||||
]);
|
||||
return response()->json(['icon' => 'success', 'warna' => '#5ba035', 'status' => 'Success', 'message' => 'Photo Profile Saved, please relogin to apply the change']);
|
||||
return back();
|
||||
}
|
||||
else {
|
||||
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Error.!!', 'message' => 'System Down, please try again in a few years....']);
|
||||
return back();
|
||||
}
|
||||
} else {
|
||||
return response()->json(['icon' => 'error', 'warna' => '#bf441d', 'status' => 'Error.!!', 'message' => 'No File Selected']);
|
||||
return back();
|
||||
}
|
||||
}
|
||||
public function delete(Request $request) {
|
||||
$id = $request->user_id;
|
||||
$user = User::find($id);
|
||||
XFiles::where('xtabel', $user->username)->delete();
|
||||
$user->delete();
|
||||
return back();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Ratchet\MessageComponentInterface;
|
||||
use Ratchet\ConnectionInterface;
|
||||
use App\Iseng;
|
||||
|
||||
class WebSocketController extends Controller implements MessageComponentInterface{
|
||||
private $connections = [];
|
||||
|
||||
/**
|
||||
* When a new connection is opened it will be passed to this method
|
||||
* @param ConnectionInterface $conn The socket/connection that just connected to your application
|
||||
* @throws \Exception
|
||||
*/
|
||||
function onOpen(ConnectionInterface $conn){
|
||||
$this->connections[$conn->resourceId] = compact('conn') + ['user_id' => null];
|
||||
}
|
||||
|
||||
/**
|
||||
* This is called before or after a socket is closed (depends on how it's closed). SendMessage to $conn will not result in an error if it has already been closed.
|
||||
* @param ConnectionInterface $conn The socket/connection that is closing/closed
|
||||
* @throws \Exception
|
||||
*/
|
||||
function onClose(ConnectionInterface $conn){
|
||||
$disconnectedId = $conn->resourceId;
|
||||
unset($this->connections[$disconnectedId]);
|
||||
foreach($this->connections as &$connection)
|
||||
$connection['conn']->send(json_encode([
|
||||
'offline_user' => $disconnectedId,
|
||||
'from_user_id' => 'server control',
|
||||
'from_resource_id' => null
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
* If there is an error with one of the sockets, or somewhere in the application where an Exception is thrown,
|
||||
* the Exception is sent back down the stack, handled by the Server and bubbled back up the application through this method
|
||||
* @param ConnectionInterface $conn
|
||||
* @param \Exception $e
|
||||
* @throws \Exception
|
||||
*/
|
||||
function onError(ConnectionInterface $conn, \Exception $e){
|
||||
$userId = $this->connections[$conn->resourceId]['user_id'];
|
||||
echo "An error has occurred with user $userId: {$e->getMessage()}\n";
|
||||
unset($this->connections[$conn->resourceId]);
|
||||
$conn->close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggered when a client sends data through the socket
|
||||
* @param \Ratchet\ConnectionInterface $conn The socket/connection that sent the message to your application
|
||||
* @param string $msg The message received
|
||||
* @throws \Exception
|
||||
*/
|
||||
function onMessage(ConnectionInterface $conn, $msg){
|
||||
$msg = json_decode($msg, true);
|
||||
$konten = $msg['content'];
|
||||
Iseng::insert([
|
||||
'msg' => $konten
|
||||
]);
|
||||
|
||||
// if(is_null($this->connections[$conn->resourceId]['user_id'])){
|
||||
// $this->connections[$conn->resourceId]['user_id'] = $msg;
|
||||
// $onlineUsers = [];
|
||||
// foreach($this->connections as $resourceId => &$connection){
|
||||
// $connection['conn']->send(json_encode([$conn->resourceId => $msg]));
|
||||
// if($conn->resourceId != $resourceId)
|
||||
// $onlineUsers[$resourceId] = $connection['user_id'];
|
||||
// }
|
||||
// $conn->send(json_encode(['online_users' => $onlineUsers]));
|
||||
// } else{
|
||||
// $fromUserId = $this->connections[$conn->resourceId]['user_id'];
|
||||
// $msg = json_decode($msg, true);
|
||||
// $this->connections[$msg['to']]['conn']->send(json_encode([
|
||||
// 'msg' => $msg['content'],
|
||||
// 'from_user_id' => $fromUserId,
|
||||
// 'from_resource_id' => $conn->resourceId
|
||||
// ]));
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http;
|
||||
|
||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||
|
||||
class Kernel extends HttpKernel
|
||||
{
|
||||
/**
|
||||
* The application's global HTTP middleware stack.
|
||||
*
|
||||
* These middleware are run during every request to your application.
|
||||
*
|
||||
* @var array<int, class-string|string>
|
||||
*/
|
||||
protected $middleware = [
|
||||
// \App\Http\Middleware\TrustHosts::class,
|
||||
\App\Http\Middleware\TrustProxies::class,
|
||||
\Illuminate\Http\Middleware\HandleCors::class,
|
||||
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||
\App\Http\Middleware\TrimStrings::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware groups.
|
||||
*
|
||||
* @var array<string, array<int, class-string|string>>
|
||||
*/
|
||||
protected $middlewareGroups = [
|
||||
'web' => [
|
||||
\App\Http\Middleware\EncryptCookies::class,
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
|
||||
'api' => [
|
||||
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
|
||||
\Illuminate\Routing\Middleware\ThrottleRequests::class.':api',
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's middleware aliases.
|
||||
*
|
||||
* Aliases may be used instead of class names to conveniently assign middleware to routes and groups.
|
||||
*
|
||||
* @var array<string, class-string|string>
|
||||
*/
|
||||
protected $middlewareAliases = [
|
||||
'project.ipg' => \App\Http\Middleware\Login::class,
|
||||
'auth' => \App\Http\Middleware\Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
|
||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
|
||||
'precognitive' => \Illuminate\Foundation\Http\Middleware\HandlePrecognitiveRequests::class,
|
||||
'signed' => \App\Http\Middleware\ValidateSignature::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Auth\Middleware\Authenticate as Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class Authenticate extends Middleware
|
||||
{
|
||||
/**
|
||||
* Get the path the user should be redirected to when they are not authenticated.
|
||||
*/
|
||||
protected function redirectTo(Request $request): ?string
|
||||
{
|
||||
return $request->expectsJson() ? null : route('login');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
|
||||
|
||||
class EncryptCookies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the cookies that should not be encrypted.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class Login
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
$response = $next($request);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function terminate($request, $response)
|
||||
{
|
||||
if (! \Auth::check())
|
||||
return;
|
||||
|
||||
$user = \Auth::user();
|
||||
|
||||
if (!$user->session_id) {
|
||||
$user->session_id = \Session::getId();
|
||||
$user->last_activity = Carbon::now();
|
||||
$user->save();
|
||||
}
|
||||
else {
|
||||
$last_session = \Session::getHandler()->read($user->session_id);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
|
||||
|
||||
class PreventRequestsDuringMaintenance extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be reachable while maintenance mode is enabled.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class RedirectIfAuthenticated
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
|
||||
*/
|
||||
public function handle(Request $request, Closure $next, string ...$guards): Response
|
||||
{
|
||||
$guards = empty($guards) ? [null] : $guards;
|
||||
|
||||
foreach ($guards as $guard) {
|
||||
if (Auth::guard($guard)->check()) {
|
||||
return redirect(RouteServiceProvider::HOME);
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
|
||||
|
||||
class TrimStrings extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the attributes that should not be trimmed.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
'current_password',
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Middleware\TrustHosts as Middleware;
|
||||
|
||||
class TrustHosts extends Middleware
|
||||
{
|
||||
/**
|
||||
* Get the host patterns that should be trusted.
|
||||
*
|
||||
* @return array<int, string|null>
|
||||
*/
|
||||
public function hosts(): array
|
||||
{
|
||||
return [
|
||||
$this->allSubdomainsOfApplicationUrl(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Middleware\TrustProxies as Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class TrustProxies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The trusted proxies for this application.
|
||||
*
|
||||
* @var array<int, string>|string|null
|
||||
*/
|
||||
protected $proxies;
|
||||
|
||||
/**
|
||||
* The headers that should be used to detect proxies.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $headers =
|
||||
Request::HEADER_X_FORWARDED_FOR |
|
||||
Request::HEADER_X_FORWARDED_HOST |
|
||||
Request::HEADER_X_FORWARDED_PORT |
|
||||
Request::HEADER_X_FORWARDED_PROTO |
|
||||
Request::HEADER_X_FORWARDED_AWS_ELB;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Routing\Middleware\ValidateSignature as Middleware;
|
||||
|
||||
class ValidateSignature extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the query string parameters that should be ignored.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
// 'fbclid',
|
||||
// 'utm_campaign',
|
||||
// 'utm_content',
|
||||
// 'utm_medium',
|
||||
// 'utm_source',
|
||||
// 'utm_term',
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
||||
|
||||
class VerifyCsrfToken extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be excluded from CSRF verification.
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $except = [
|
||||
'registerpasien', 'registerjson', 'ekstrakhasil', 'prosesbatal', 'cekaksess'
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user