88 lines
2.7 KiB
PHP
88 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
use App\Utilities\ApiCalls;
|
|
use Session;
|
|
use Illuminate\Http\Request;
|
|
use Storage;
|
|
use Response;
|
|
|
|
class PermitsController extends Controller
|
|
{
|
|
public function index(){
|
|
|
|
$url = "permit/get_applications_by_district.php";
|
|
$data = json_encode([
|
|
'district_id' => session('district_id'),
|
|
'api_token' => env('LUPMISAPIKEY')
|
|
]);
|
|
$result = ApiCalls::CurlPost($data, $url);
|
|
// dump($result);
|
|
$result = json_decode($result, true);
|
|
// dd(is_array($result['data']));
|
|
|
|
$data = [
|
|
'page_title' => 'Permits Dashboard',
|
|
'permits_arr' => $result
|
|
];
|
|
return view('permits.dashboard', $data);
|
|
}
|
|
|
|
public function statusIndex($status){
|
|
$url = "permit/get_applications_by_district.php";
|
|
$data = json_encode([
|
|
'district_id' => session('district_id'),
|
|
'api_token' => env('LUPMISAPIKEY')
|
|
]);
|
|
$result = ApiCalls::CurlPost($data, $url);
|
|
$result = json_decode($result, true);
|
|
// dump($result);
|
|
if ($result['success'] && $result['data'] == null) {
|
|
Session::flash('error_message', 'Your request could not be handled at this time. Try again later');
|
|
return redirect()->back();
|
|
}
|
|
$data = [
|
|
'page_title' => 'Permits Page',
|
|
'permits_arr' => $result,
|
|
'status' => $status
|
|
];
|
|
return view('permits.index', $data);
|
|
}
|
|
public function show($id){
|
|
// dump(session('current_user'));
|
|
$url = "permit/get_applications_with_applicant_by_application_code.php";
|
|
|
|
$data = json_encode([
|
|
'application_code' => $id,
|
|
'api_token' => env('LUPMISAPIKEY')
|
|
]);
|
|
$result = ApiCalls::CurlPost($data, $url);
|
|
$result = json_decode($result, true);
|
|
// dump($result);
|
|
$data = [
|
|
'page_title' => 'Permits Details',
|
|
'permit_arr' => $result['data'][0],
|
|
];
|
|
return view('permits.show', $data);
|
|
}
|
|
public function statusUpdate($id){
|
|
|
|
}
|
|
public function viewPdf($filename){
|
|
// Ensure the file exists and is in the correct storage sub-directory
|
|
$path = storage_path('app/public/site_plans/' . $filename);
|
|
|
|
if (!Storage::disk('public')->exists('site_plans/' . $filename)) {
|
|
abort(404);
|
|
}
|
|
|
|
// Return the file with an inline content disposition to display in the browser
|
|
return Response::make(file_get_contents($path), 200, [
|
|
'Content-Type' => 'application/pdf',
|
|
'Content-Disposition' => 'inline; filename="' . $filename . '"' // 'inline' displays it in the browser/iframe
|
|
]);
|
|
}
|
|
}
|
|
|
|
|