Commit 06298898 by Triyah Fatmawati

Fix ambil file surat eoffice

parent fe0db369
......@@ -20,7 +20,7 @@ public function index(Request $request) {
$filter_periode = DB::table('ms_periode')->orderBy('periode','asc')->get();
Session::put('periode', $request->periode);
Session::put('periode', $request->periode);
if(empty(Session::get('periode'))) {
$periode = DB::table('ms_periode')->where('is_aktif', 1)->first();
......@@ -65,9 +65,8 @@ public function index(Request $request) {
public function getFileName($tahun, $nosurat){
$client = new Client();
// $response = $client->request('GET', 'https://e-office.unesa.ac.id/api/show-surat-keluar/'.$tahun.'/'.$nosurat);
// $data = json_decode($response->getBody(), true);
$data = null;
$response = $client->request('GET', 'https://e-office.unesa.ac.id/api/show-surat-keluar/'.$tahun.'/'.$nosurat);
$data = json_decode($response->getBody(), true);
if (is_null($data)) {
$namafile = '';
......
......@@ -17,8 +17,8 @@ public function index($tahun){
->whereHas('penelaah', function($query) use ($tahun) {
$query->where('tahun', $tahun);
})
->orderBy('nip', 'asc')
->orderBy('created_at','desc')
->orderBy('nip', 'asc')
->get();
if($penelaah){
......@@ -51,10 +51,10 @@ public function index1($tahun){
->whereHas('penelaah', function($query) use ($tahun) {
$query->whereYear('created_at', $tahun);
})
->orderBy('nip', 'asc')
->orderBy('created_at','desc')
->orderBy('nip', 'asc')
->get();
if($penelaah){
foreach ($penelaah as $key => $pen) {
$dataTelaah[] = [
......
......@@ -31,7 +31,7 @@
</div>
</div>
</div>
<div class="table-responsive mb-4">
<table id="datatable" class="table data-table table-hover" style="width:100%">
......@@ -54,20 +54,33 @@
$no = 1;
$nomorsurat = $penelaah[0]->no_sk;
$no_surat = explode('/', $nomorsurat);
$noagenda = $no_surat[0];
$tahun = $no_surat[3];
$nama_file = app(App\Http\Controllers\Admin\SakuController::class)->getFileName($tahun, $noagenda);
$jmlSukuNoSurat = count($no_surat);
if(ctype_digit($no_surat[0])){
$noagenda = $no_surat[0];
}
elseif(ctype_digit($no_surat[1])){
$noagenda = $no_surat[1];
}
$tahun = $no_surat[$jmlSukuNoSurat-1];
$namafile = app(App\Http\Controllers\Admin\SakuController::class)->getFileName($tahun, $noagenda);
@endphp
@foreach($penelaah as $key => $item)
@php
// $pengajuan = DB::table('tr_pengajuan')->where('id',$item->id_pengajuan)->first();
if($item->no_sk == $nomorsurat){
$namafile = $nama_file;
}
else{
$nosurat = explode('/', $item->no_sk);
$noagenda = $nosurat[0];
$tahun = $nosurat[3];
if($item->no_sk != $nomorsurat){
$no_surat = explode('/', $item->no_sk);
$jmlSukuNoSurat = count($no_surat);
if(ctype_digit($no_surat[0])){
$noagenda = $no_surat[0];
}
elseif(ctype_digit($no_surat[1])){
$noagenda = $no_surat[1];
}
$tahun = $no_surat[$jmlSukuNoSurat-1];
$namafile = app(App\Http\Controllers\Admin\SakuController::class)->getFileName($tahun, $noagenda);
}
@endphp
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment