Fix: refactored permit show for new API

This commit is contained in:
Kwesi Banson Jnr 2026-03-09 22:23:34 +00:00
parent 268dfb2ce7
commit d24fa47ec8
20 changed files with 276 additions and 77 deletions

View File

@ -29,7 +29,7 @@ MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_ADDRESS=lupmis@luspa.gov.gh
MAIL_FROM_NAME="${APP_NAME}"
AWS_ACCESS_KEY_ID=

View File

@ -8,7 +8,6 @@ use Illuminate\Http\Request;
class AdminController extends Controller
{
public function index(){
$users_url = "user_mgt/get_all_users.php";
$data = ['api_token' => env('LUPMISAPIKEY')];
$result = ApiCalls::CurlPost(json_encode($data), $users_url);

View File

@ -4,6 +4,8 @@ namespace App\Http\Controllers;
use App\Utilities\ApiCalls;
use Session;
use Illuminate\Http\Request;
use Storage;
use Response;
class PermitsController extends Controller
{
@ -11,13 +13,14 @@ class PermitsController extends Controller
$url = "permit/get_applications_by_district.php";
$data = json_encode([
'district_id' => 176,
'district_id' => 80,
'api_token' => env('LUPMISAPIKEY')
]);
$result = ApiCalls::CurlPost($data, $url);
// dd($result);
dump($result);
$result = json_decode($result, true);
// dd(is_array($result['data']));
$data = [
'page_title' => 'Permits Dashboard',
'permits_arr' => $result
@ -28,13 +31,16 @@ class PermitsController extends Controller
public function statusIndex($status){
$url = "permit/get_applications_by_district.php";
$data = json_encode([
'district_id' => 176,
'district_id' => 80,
'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,
@ -43,7 +49,8 @@ class PermitsController extends Controller
return view('permits.index', $data);
}
public function show($id){
$url = "permit/get_applications_by_application_code.php";
// dump(session('current_user'));
$url = "permit/get_applications_with_applicant_by_application_code.php";
$data = json_encode([
'application_code' => $id,
@ -51,13 +58,30 @@ class PermitsController extends Controller
]);
$result = ApiCalls::CurlPost($data, $url);
$result = json_decode($result, true);
// dump($result['data']);
// 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
]);
}
}

View File

@ -58,6 +58,12 @@ class UserloginController extends Controller
$user_id = session('current_user.id');
$username = session('current_user.name');
$logout_user_url = 'auth/logout_user.php';
$data = ['user_id' => $user_id, 'api_token' => env('LUPMISAPIKEY')];
$result = ApiCalls::CurlPost(json_encode($data), $logout_user_url);
// dd($result);
$request->session()->forget('current_user');
$request->session()->flush();
$request->session()->regenerate(true);

View File

@ -4,10 +4,13 @@ namespace App\Http\Controllers;
use App\Utilities\ApiCalls;
use Session;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Mail;
use App\Mail\UserAccountsMail;
class UsersController extends Controller
{
public function index(){
$data = [
'page_title' => 'Users Page '
];
@ -78,6 +81,11 @@ class UsersController extends Controller
$result = ApiCalls::CurlPost($data, $url);
$result = json_decode($result, true);
\Log::info("Your Password is $password");
$recipientEmail = 'recipient@example.com';
Mail::to($recipientEmail)->send(new UserAccountsMail($password, $request->username));
//dd('Email sent!');
if (request()->expectsJson()) {
return response()->json($result);
}
@ -87,25 +95,34 @@ class UsersController extends Controller
$url = "user_mgt/update_usr_user.php";
// return ['success' => true];
// dd($request->all());
$data = json_encode([
'full_name' => $params['full_name'],
'username' => $params['username'],
'ua_position' => $params['ua_position'],
'email' => $params['email'],
'title' => $params['title'],
'allowed_apps' => implode(", ", $params['allowed_apps']),
'full_name' => $request['full_name'],
'username' => $request['username'],
'ua_position' => $request['ua_position'],
'user_id' => $request['user_id'],
'email' => $request['email'],
'title' => $request['title'],
'allowed_apps' => implode(", ", $request['allowed_apps']),
// 'password_hint' => '',
'phone' => $params['phone'],
'gender' => $params['gender'],
'phone' => $request['phone'],
'gender' => $request['gender'],
'user_type' => 'District User',
'api_token' => env('LUPMISAPIKEY'), //
'api_token' => env('LUPMISAPIKEY'),
]);
/*
if (json_decode($data) === null && json_last_error() !== JSON_ERROR_NONE) {
dump('not json');
} else {
// IS valid JSON
dump('is valid json');
}
*/
// dd($data);
$result = ApiCalls::CurlPost($data, $url);
$result = json_decode($result, true);
// dd($result);
if (request()->expectsJson()) {
return response()->json($result);
}

View File

@ -0,0 +1,58 @@
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
use Illuminate\Mail\Mailables\Address;
class UserAccountsMail extends Mailable
{
use Queueable, SerializesModels;
public $username;
public $password;
/**
* Create a new message instance.
*/
public function __construct($password, $username)
{
$this->password = $password;
$this->username = $username;
}
/**
* Get the message envelope.
*/
public function envelope(): Envelope
{
return new Envelope(
//from: new Address('example@example.com', 'Test Sender'), // Optional, overrides global MAIL_FROM_ADDRESS
subject: 'Lupmis User Credentials',
);
}
/**
* Get the message content definition.
*/
public function content(): Content
{
return new Content(
view: 'emails.new-user',
);
}
/**
* Get the attachments for the message.
*
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
*/
public function attachments(): array
{
return [];
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

View File

@ -2,7 +2,7 @@
var element = document.getElementById('map');
// Height has to be set. You can do this in CSS too.
element.style = 'height:300px;';
element.style = 'height:400px;';
// Create Openlayers map on map element.
var map = new ol.Map({

View File

@ -1,24 +1,15 @@
$(document).ready(function(){
// $('.editUserBtn').click(function(evnt){
// });
//
console.log('foo bar');
$('#editAllowedApps').select2({
// width: "resolve",
dropdownParent: $('#editUserModal'),
placeholder : "Select options, multiple allowed"
});
$('#allowedApps').select2({
// width: "resolve",
dropdownParent: $('#addUserModal'),
placeholder : "Select options, multiple allowed"
});
$('#inputPermissions').select2({
// width: "resolve",
dropdownParent: $('#editUserModal'),
placeholder : "Select options, multiple allowed"
});
@ -46,7 +37,6 @@ $(document).ready(function(){
if (jason['allowed_apps']) {
allowedAppsArray = jason['allowed_apps'].split(",");
}
console.log(jason['full_name']);
$('#editFullName').val(jason['full_name']);
$('#editEmail').val(jason['email']);
$('#editUsername').val(jason['username']);
@ -59,7 +49,7 @@ $(document).ready(function(){
$('#editDistrictId').val(jason['district_id']);
$('#editUaPostion').val(jason['ua_position']);
$('#editGender').val(jason['gender']);
$("input[name='user_id']").val(jason.ua_id);
$("input[name='user_id']").val(jason.user_id);
}
//$('#editUserModal').modal('show');
@ -150,7 +140,7 @@ $(document).ready(function(){
// location.reload();
setTimeout(function() {
location.reload(); // Reloads the current page
}, 15000);
}, 1500);
}
else{
$('#successArea').addClass('d-none');
@ -173,7 +163,7 @@ $(document).ready(function(){
$('#errorsArea').removeClass('d-none');
var formData = new FormData($(this)[0]);
$.ajax({
url: base_url + '/users/update/',
url: base_url + '/userupdate',
type: 'POST',
data: formData,
processData: false,
@ -185,18 +175,23 @@ $(document).ready(function(){
// $('#updateResultsParagraph').text("Processing Please wait ...");
},
success: function(data) {
console.log(data);
// console.log(data['success']);
if (data['success'] == true) {
$('#editSuccessArea').removeClass('d-none');
$('#editErrorArea').addClass('d-none');
$('#editSuccessArea').text("");
$('#editSuccessArea').text("User successfully details updated!");
}
else{
$('#editErrorArea').removeClass('d-none');
$('#editErrorArea').text(data['msg']);
}
},
error: function(xhr, status, error) {
console.error('Error:', error);
$('#editSuccessArea').text(error);
$('#editErrorArea').removeClass('d-none');
$('#editErrorArea').text(error);
location.reload();
// location.reload();
}
});
});
@ -211,7 +206,4 @@ $(document).ready(function(){
});
});
});
});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -53,7 +53,7 @@
<td><?php echo $row['allowed_apps'] ?></td>
<td>
@csrf
<input type="hidden" class="userIdinput" value="<?php echo $row['ua_id'] ?>" name="userId">
<input type="hidden" class="userIdinput" value="<?php echo $row['user_id'] ?>" name="userId">
<!-- <a href="" data-bs-toggle="modal" data-bs-target="#viewUserModal" ><img src="{{ url('public/assets/libs/bootstrap-icons/eye.svg') }}" alt="view icon" width="16" height="16"></a> -->
<a href="" class="editUserBtn" data-bs-toggle="modal" data-bs-target="#editUserModal"><img src="{{ url('public/assets/libs/bootstrap-icons/pencil-square.svg') }}" alt="edit icon" width="16" height="16"></a>

View File

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<title>LUPMIS 2.0 User Account</title>
</head>
<body>
<h2>Account Credentials</h2>
<p>Your LUPMIS Account has been successfully created. Use the credentials below to login.</p>
<ol>
<li>Username: {{ $username }}</li>
<li>Password: {{ $password }} </li>
<li>URL: https://lupmis4luspa.org</li>
</ol>
</body>
</html>

View File

@ -13,6 +13,9 @@
<div class="container mt-4">
<div class="row g-3 settings-grid">
<!-- General Settings Card -->
<div class="col-12">
@include('common.notifications')
</div>
<div class="col-12 col-md-6 col-lg-4" id="viewPendingDiv">
<div class="settings-card">
<div class="card-icon mb-3">

View File

@ -25,6 +25,7 @@
<hr>
<div class="table-responsive">
@include('common.notifications')
<table class="table table-hover">
<thead>
<tr>

View File

@ -0,0 +1,14 @@
<div class="modal fade" id="pdfModal" tabindex="-1" aria-labelledby="pdfModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="pdfModalLabel">Document Preview</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<!-- Iframe to display the PDF -->
<iframe id="pdfIframe" src="" frameborder="0" width="100%" height="500px"></iframe>
</div>
</div>
</div>
</div>

View File

@ -6,10 +6,9 @@
@endsection
@section('page-content')
@include('permits.partials.pdf-modal')
@include('layouts.partials.permits-navbar')
<div class="container">
<div class="row">
<div class="col-md-7">
@ -19,7 +18,8 @@
<!-- Map Area -->
<div class="map-container mb-4">
<div id="applicationmap" class="applicationmap" style="width: 100%; height: 100vH;"></div>
<!-- <div id="applicationmap" class="applicationmap" style="width: 100%; height: 100vH;"></div> -->
<div><img src="{{ url('public/assets/images/grey-map-with-location-pin.jpg') }}" height="500px" width="801px"></div>
<!-- <img src="https://placeholdit.com/900x200/dddddd/999999?text=Project+Location" alt="Project Location" class="img-fluid" /> -->
</div>
@ -27,7 +27,7 @@
<div class="remarks-section">
<h3 class="section-title">Project Location</h3>
<h3 class="section-title">Actual Project Location</h3>
<div class="row mb-3">
<label for="permitLocation" class="form-label fw-bold text-primary">Coordinates *</label>
@ -63,35 +63,43 @@
<div class="row">
<div class="col-md-12">
<h6 class="detail-label">Project Description</h6>
<!-- <h6 class="detail-label">Project Description</h6> -->
<p class="detail-value"></p>
</div>
<div class="col-md-12">
<div class="col-md-6">
<h6 class="detail-label">Name</h6>
<p class="detail-value">Freda Amuzu & Lydia Opare</p>
<p class="detail-value">{{ $permit_arr['applicant_name'] }}</p>
</div>
<div class="col-md-6">
<h6 class="detail-label">Address</h6>
<p class="detail-value">21 Coker Street</p>
<h6 class="detail-label">Nationality</h6>
<p class="detail-value">{{ $permit_arr['nationality'] }}</p>
</div>
<div class="col-md-6">
<h6 class="detail-label">Email</h6>
<p class="detail-value">{{ $permit_arr['email'] }}</p>
</div>
<div class="col-md-6">
<h6 class="detail-label">Telephone Number</h6>
<p class="detail-value">023 398 4569</p>
<p class="detail-value">{{ $permit_arr['phone'] }}</p>
</div>
</div>
<div class="row">
<div class="col-md-12">
<h6 class="detail-label">Address</h6>
<p class="detail-value">{{ $permit_arr['address'] }}, {{ $permit_arr['city'] }}, {{ $permit_arr['region'] }}</p>
</div>
<div class="col-md-6">
<h6 class="detail-label">Location</h6>
<p class="detail-value">Sector 28 Block F - Plot No. 189 & 190</p>
<p class="detail-value">{{ $permit_arr['project_location'] }}</p>
</div>
<!-- <div class="col-md-4">
<h6 class="detail-label">Parcel Size</h6>
<p class="detail-value">0.25 Acre</p>
</div> -->
<div class="col-md-4">
<h6 class="detail-label">Land use</h6>
<p class="detail-value">Residential</p>
<div class="col-md-6">
<h6 class="detail-label">Permit Type</h6>
<p class="detail-value">{{ $permit_arr['permit_type'] }}</p>
</div>
</div>
</div>
@ -103,19 +111,35 @@
<div class="row">
<div class="col-md-6">
<!-- <h6 class="detail-label">Architectural Drawings</h6> -->
<p class="detail-value"><a href="" class="btn btn-link"><i class="fa-solid fa-paperclip"></i> Sketch Design</a></p>
<p class="detail-value"><a href="" class="btn btn-link"><i class="fa-solid fa-paperclip"></i> Working Drawing</a></p>
<p class="detail-value">
<a href="#" class="btn btn-link" data-bs-toggle="modal" data-bs-target="#pdfModal" data-pdf-url="{{ route('view.pdf', ['filename' => 'site_plan.pdf']) }}">
<i class="fa-solid fa-paperclip"></i> Site Plan
</a>
<!-- <a href="" class="btn btn-link"><i class="fa-solid fa-paperclip"></i> Site Plan</a> -->
</p>
<p class="detail-value">
<!-- <a href="" class="btn btn-link"><i class="fa-solid fa-paperclip"></i> Architectural Drawings</a> -->
<a href="#" class="btn btn-link" data-bs-toggle="modal" data-bs-target="#pdfModal" data-pdf-url="{{ route('view.pdf', ['filename' => 'architectural_drawing.pdf']) }}">
<i class="fa-solid fa-paperclip"></i> Architectural Drawings
</a>
</p>
<!-- <p class="detail-value"><a href="" class="btn btn-link"><i class="fa-solid fa-paperclip"></i> Working Drawing</a></p> -->
</div>
<div class="col-md-6">
<!-- <h6 class="detail-label">Others</h6> -->
<p class="detail-value"><a href="" class="btn btn-link"><i class="fa-solid fa-paperclip"></i> Site Plan</a></p>
<p class="detail-value"><a href="" class="btn btn-link"><i class="fa-solid fa-paperclip"></i> Block Plan</a></p>
<p class="detail-value">
<!-- <a href="" class="btn btn-link"><i class="fa-solid fa-paperclip"></i> Block Plan</a> -->
<a href="#" class="btn btn-link" data-bs-toggle="modal" data-bs-target="#pdfModal" data-pdf-url="{{ route('view.pdf', ['filename' => 'block_plan.pdf']) }}">
<i class="fa-solid fa-paperclip"></i> Block Plan
</a>
</p>
</div>
<div class="col-md-6">
<!-- <h6 class="detail-label">Architectural Drawings</h6> -->
<p class="detail-value"><a href="" class="btn btn-link"><i class="fa-solid fa-paperclip"></i> Zoning Report</a></p>
<p class="detail-value"><a href="" class="btn btn-link"><i class="fa-solid fa-paperclip"></i> Working Drawing</a></p>
<!-- <p class="detail-value"><a href="" class="btn btn-link"><i class="fa-solid fa-paperclip"></i> Zoning Report</a></p> -->
<!-- <p class="detail-value"><a href="" class="btn btn-link"><i class="fa-solid fa-paperclip"></i> Working Drawing</a></p> -->
</div>
<!-- <div class="col-md-6">
@ -130,7 +154,15 @@
<div class="row">
<div class="col-md-6">
<h6 class="detail-label">Date of Application</h6>
<p class="detail-value">03-11-2025</p>
<p class="detail-value">
<?php
$originalDate = "2023-05-31 01:16:06";
$unixTime = strtotime($permit_arr['submitted_at']);
$normal_datetime = date("jS F, Y @ g:i A", $unixTime);
echo $normal_datetime;
?>
</p>
</div>
<div class="col-md-6">
<h6 class="detail-label">Processing Days Remaining</h6>
@ -180,10 +212,22 @@
<script type="text/javascript">
$(document).ready(function(){
var pdfModal = document.getElementById('pdfModal');
pdfModal.addEventListener('show.bs.modal', function (event) {
// Button that triggered the modal
var button = event.relatedTarget;
// Extract info from data-bs-* attributes
var pdfUrl = button.getAttribute('data-pdf-url');
// Update the modal's iframe src
var pdfIframe = document.getElementById('pdfIframe');
pdfIframe.src = pdfUrl;
});
// Optional: Clear the iframe src when the modal is closed to stop the stream
pdfModal.addEventListener('hidden.bs.modal', function () {
var pdfIframe = document.getElementById('pdfIframe');
pdfIframe.src = '';
});
});
</script>

View File

@ -33,9 +33,9 @@
<div class="main">
<div class="row g-5">
<div class="col-md-6 col-lg-6 lupmis-primary-bg-50 d-flex flex-column p-4 rounded">
<div id="map" class="map" style="width: 100%; height: 150vH;"></div>
<div id="map" class="map" style="width: 100%; height: 580vH;"></div>
<div class="pt-2 lupmis-primary-text-900">
<h4 class="d-flex justify-content-between align-items-center mbmmm-3"><span class="">Welcome to LUPMIS</span></h4>
<!-- <h4 class="d-flex justify-content-between align-items-center mbmmm-3"><span class="">Welcome to LUPMIS</span></h4> -->
</div>
</div>
<div class="col-md-6 col-lg-6 px-5 d-flex flex-row-reverse">
@ -45,7 +45,7 @@
&nbsp; &nbsp; &nbsp;
<img class="" src="{{ url('public/assets/images/logo-2.png') }}" alt="" width="150" height="150"/>
</div>
<h4 class="mb-3">Login</h4>
<h4 class="mb-3">Welcome to LUPMIS</h4>
@include('common.notifications')
<form class="needs-validation" action="/user-login" method="POST">
@csrf

View File

@ -2,8 +2,14 @@
use Illuminate\Support\Facades\Route;
use App\Http\Middleware\CheckBackendSession;
use Illuminate\Support\Facades\Mail;
use App\Mail\UserAccountsMail;
Route::get('/send-test-email', function () {
$recipientEmail = 'recipient@example.com';
Mail::to($recipientEmail)->send(new UserAccountsMail());
dd('Email sent!');
});
#Auth::routes();
@ -14,7 +20,7 @@ Auth::routes([
]);
Route::get('/view-pdf/{filename}', [App\Http\Controllers\PermitsController::class, 'viewPdf'])->name('view.pdf');
Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
Route::get('/user-login', [App\Http\Controllers\UserloginController::class, 'index']);
@ -38,6 +44,7 @@ Route::middleware([CheckBackendSession::class])->group(function () {
Route::get('/users/{user_id}', [App\Http\Controllers\UsersController::class, 'show']);
Route::post('/users', [App\Http\Controllers\UsersController::class, 'store']);
Route::post('/users/update', [App\Http\Controllers\UsersController::class, 'update']);
Route::post('/userupdate', [App\Http\Controllers\UsersController::class, 'update']);
Route::get('/users/edit/{user_id}', [App\Http\Controllers\UsersController::class, 'edit']);