Commit 06298898 by Triyah Fatmawati

Fix ambil file surat eoffice

parent fe0db369
...@@ -65,9 +65,8 @@ public function index(Request $request) { ...@@ -65,9 +65,8 @@ public function index(Request $request) {
public function getFileName($tahun, $nosurat){ public function getFileName($tahun, $nosurat){
$client = new Client(); $client = new Client();
// $response = $client->request('GET', 'https://e-office.unesa.ac.id/api/show-surat-keluar/'.$tahun.'/'.$nosurat); $response = $client->request('GET', 'https://e-office.unesa.ac.id/api/show-surat-keluar/'.$tahun.'/'.$nosurat);
// $data = json_decode($response->getBody(), true); $data = json_decode($response->getBody(), true);
$data = null;
if (is_null($data)) { if (is_null($data)) {
$namafile = ''; $namafile = '';
......
...@@ -17,8 +17,8 @@ public function index($tahun){ ...@@ -17,8 +17,8 @@ public function index($tahun){
->whereHas('penelaah', function($query) use ($tahun) { ->whereHas('penelaah', function($query) use ($tahun) {
$query->where('tahun', $tahun); $query->where('tahun', $tahun);
}) })
->orderBy('nip', 'asc')
->orderBy('created_at','desc') ->orderBy('created_at','desc')
->orderBy('nip', 'asc')
->get(); ->get();
if($penelaah){ if($penelaah){
...@@ -51,8 +51,8 @@ public function index1($tahun){ ...@@ -51,8 +51,8 @@ public function index1($tahun){
->whereHas('penelaah', function($query) use ($tahun) { ->whereHas('penelaah', function($query) use ($tahun) {
$query->whereYear('created_at', $tahun); $query->whereYear('created_at', $tahun);
}) })
->orderBy('nip', 'asc')
->orderBy('created_at','desc') ->orderBy('created_at','desc')
->orderBy('nip', 'asc')
->get(); ->get();
if($penelaah){ if($penelaah){
......
...@@ -54,20 +54,33 @@ ...@@ -54,20 +54,33 @@
$no = 1; $no = 1;
$nomorsurat = $penelaah[0]->no_sk; $nomorsurat = $penelaah[0]->no_sk;
$no_surat = explode('/', $nomorsurat); $no_surat = explode('/', $nomorsurat);
$jmlSukuNoSurat = count($no_surat);
if(ctype_digit($no_surat[0])){
$noagenda = $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 @endphp
@foreach($penelaah as $key => $item) @foreach($penelaah as $key => $item)
@php @php
// $pengajuan = DB::table('tr_pengajuan')->where('id',$item->id_pengajuan)->first(); // $pengajuan = DB::table('tr_pengajuan')->where('id',$item->id_pengajuan)->first();
if($item->no_sk == $nomorsurat){ if($item->no_sk != $nomorsurat){
$namafile = $nama_file; $no_surat = explode('/', $item->no_sk);
$jmlSukuNoSurat = count($no_surat);
if(ctype_digit($no_surat[0])){
$noagenda = $no_surat[0];
} }
else{ elseif(ctype_digit($no_surat[1])){
$nosurat = explode('/', $item->no_sk); $noagenda = $no_surat[1];
$noagenda = $nosurat[0]; }
$tahun = $nosurat[3];
$tahun = $no_surat[$jmlSukuNoSurat-1];
$namafile = app(App\Http\Controllers\Admin\SakuController::class)->getFileName($tahun, $noagenda); $namafile = app(App\Http\Controllers\Admin\SakuController::class)->getFileName($tahun, $noagenda);
} }
@endphp @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