diff --git a/app/Http/Controllers/NotisController.php b/app/Http/Controllers/NotisController.php index e54970f0..6ee8b9b1 100644 --- a/app/Http/Controllers/NotisController.php +++ b/app/Http/Controllers/NotisController.php @@ -1430,8 +1430,11 @@ class NotisController extends Controller } -public function jananotisperingatan2($notisid,$cawid) +public function jananotisperingatan2(Request $request) { + $notisid = $request->notisid; + $cawid = $request->cawid; + $user = Auth::user(); $caw = Cawangan::where('id', '=', $cawid)->first(); @@ -1480,8 +1483,11 @@ public function jananotisperingatan2($notisid,$cawid) return $pdf->download('Penjanaan Notis Peringatan Fasa 1 ' . $notisid . '.pdf'); } - public function jananotisperingatan2fasa2($notisid,$cawid) + public function jananotisperingatan2fasa2(Request $request) { + $notisid = $request->notisid; + $cawid = $request->cawid; + $user = Auth::user(); $caw = Cawangan::where('id', '=', $cawid)->first(); diff --git a/resources/views/notisperingatan/shownotisperingatanall.blade.php b/resources/views/notisperingatan/shownotisperingatanall.blade.php index b0c98515..a232ef17 100644 --- a/resources/views/notisperingatan/shownotisperingatanall.blade.php +++ b/resources/views/notisperingatan/shownotisperingatanall.blade.php @@ -152,9 +152,9 @@ @if($caw['fasa'] == 1) - + @elseif($caw['fasa'] == 2) - + @endif @@ -340,7 +340,7 @@ "searching":false, "info": false, "lengthChange": false, - "pageLength": 15, + "pageLength": 100, dom: 'Bfrtip', buttons: [ @@ -367,6 +367,89 @@ $(this).prop('checked', cb.checked); }) } + + $(".downloadFasa1").click(function(){ + var notisid = $(this).data("notisid"); + var cawid = $(this).data("cawid"); + $.confirm({ + content: function() { + var self = this; + var data = ''; + return $.ajax({ + method: 'GET', + url: "{{ route('notisperingatan.jananotisperingatan2') }}", + data: { + notisid: notisid, + cawid: cawid + }, + xhrFields: { + responseType: 'blob' + }, + }).done(function(response) { + var blob = new Blob([response]); + var link = document.createElement('a'); + link.href = window.URL.createObjectURL(blob); + link.download = "Penjanaan Notis Peringatan Fasa 1 " + notisid + ".pdf"; + link.click(); + self.setTitle('Muat Turun Berjaya.'); + }).fail(function(response) { + console.log(response); + alert(response); + self.setTitle('Gagal! Sila hubungi iT.'); + }); + }, + buttons: { + ok: { + keys: ['enter'], + action: function(){ + location.reload(); + } + }, + } + }); + }); + + $(".downloadFasa2").click(function(){ + var notisid = $(this).data("notisid"); + var cawid = $(this).data("cawid"); + $.confirm({ + content: function() { + var self = this; + var data = ''; + return $.ajax({ + method: 'GET', + url: "{{ route('notisperingatan.jananotisperingatan2fasa2') }}", + data: { + notisid: notisid, + cawid: cawid + }, + xhrFields: { + responseType: 'blob' + }, + }).done(function(response) { + var blob = new Blob([response]); + var link = document.createElement('a'); + link.href = window.URL.createObjectURL(blob); + link.download = "Penjanaan Notis Peringatan Fasa 2 " + notisid + ".pdf"; + link.click(); + self.setTitle('Muat Turun Berjaya.'); + }).fail(function(response) { + console.log(response); + alert(response); + self.setTitle('Gagal! Sila hubungi iT.'); + }); + }, + buttons: { + ok: { + keys: ['enter'], + action: function(){ + location.reload(); + } + }, + } + }); + }); + @endsection diff --git a/routes/web.php b/routes/web.php index 255bd767..e58ce639 100644 --- a/routes/web.php +++ b/routes/web.php @@ -659,8 +659,8 @@ Route::group(['middleware' => ['permission:notisperingatan'], 'prefix' => 'notis Route::get('/gadaibycawnotisfasa1excel/{tempoh}/{tempoh2}',['as'=>'notisperingatan.gadaibycawnotisfasa1excel','uses'=>'NotisController@gadaibycawnotisfasa1excel']); Route::get('/kemaskinidatanotis/{tarikhnotis}',['as'=>'notisperingatan.kemaskinidatanotis','uses'=>'NotisController@kemaskinidatanotis']); - Route::get('/jananotisperingatan2/{notisid}/{cawid}',['as'=>'notisperingatan.jananotisperingatan2','uses'=>'NotisController@jananotisperingatan2']); - Route::get('/jananotisperingatan2fasa2/{notisid}/{cawid}',['as'=>'notisperingatan.jananotisperingatan2fasa2','uses'=>'NotisController@jananotisperingatan2fasa2']); + Route::get('/jananotisperingatan2',['as'=>'notisperingatan.jananotisperingatan2','uses'=>'NotisController@jananotisperingatan2']); + Route::get('/jananotisperingatan2fasa2',['as'=>'notisperingatan.jananotisperingatan2fasa2','uses'=>'NotisController@jananotisperingatan2fasa2']); Route::get('/blastnotisperingatan/{notisid}/{cawid}',['as'=>'notisperingatan.blastnotisperingatan','uses'=>'NotisController@blastnotisperingatan']); Route::get('/failedjob',['as'=>'notisperingatan.failedjob','uses'=>'NotisController@failedjob']);