Commit 06298898 by Triyah Fatmawati

Fix ambil file surat eoffice

parent fe0db369
......@@ -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,8 +51,8 @@ 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){
......
......@@ -54,20 +54,33 @@
$no = 1;
$nomorsurat = $penelaah[0]->no_sk;
$no_surat = explode('/', $nomorsurat);
$jmlSukuNoSurat = count($no_surat);
if(ctype_digit($no_surat[0])){
$noagenda = $no_surat[0];
$tahun = $no_surat[3];
$nama_file = app(App\Http\Controllers\Admin\SakuController::class)->getFileName($tahun, $noagenda);
}
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;
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];
}
else{
$nosurat = explode('/', $item->no_sk);
$noagenda = $nosurat[0];
$tahun = $nosurat[3];
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