467 lines
20 KiB
PHP
467 lines
20 KiB
PHP
@extends('layouts.master')
|
|
@section('page-title')
|
|
Permits | {{ $page_title }}
|
|
@endsection
|
|
@section('page-css')
|
|
<link rel="stylesheet" type="text/css" href="{{ url('public/assets/css/permit_show.css') }}">
|
|
|
|
@endsection
|
|
@section('page-content')
|
|
@include('permits.partials.pdf-modal')
|
|
@include('layouts.partials.permits-navbar')
|
|
@include('permits.partials.site-inspection')
|
|
<div class="container">
|
|
<div class="row">
|
|
<div class="col-md-7">
|
|
<div class="d-flex justify-content-between align-items-center mb-4 mt-2">
|
|
<h1 class="display-6 fw-bold text-dark">{{ $permit_arr['application_code'] }} <span class="badge bg-warning text-dark">{{ $permit_arr['status'] }}</span></h1>
|
|
</div>
|
|
|
|
<!-- Map Area -->
|
|
<!-- <div class="map-container mb-4"> -->
|
|
<!-- <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> -->
|
|
<div class="map-container mb-4">
|
|
<iframe id="permit-map"
|
|
src="https://pwa.lupmis4luspa.org/embed.php?mode=permit&application_code={{ urlencode($permit_arr['application_code']) }}{{ !empty($permit_arr['lon']) ? '&lon='.urlencode($permit_arr['lon']).'&lat='.urlencode($permit_arr['lat']) : '' }}{{ !empty($permit_arr['upn']) ? '&upn='.urlencode($permit_arr['upn']) : '' }}"
|
|
style="width:100%;height:500px;border:0;border-radius:8px;"
|
|
allow="geolocation; clipboard-write"
|
|
referrerpolicy="strict-origin-when-cross-origin"
|
|
loading="lazy"
|
|
title="Permit location map">
|
|
</iframe>
|
|
</div>
|
|
|
|
|
|
<!-- Applicant & Property Details -->
|
|
<div class="remarks-section">
|
|
|
|
|
|
<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>
|
|
<input type="text" name="permit_location" id="permitLocation" class="form-control">
|
|
</div>
|
|
<div class="row mb-3">
|
|
<label for="permitUPN" class="form-label fw-bold text-primary">UPN</label>
|
|
<input type="text" name="permit_upn" id="permitUPN" class="form-control">
|
|
</div>
|
|
<div class="row mb-3">
|
|
<div class="d-flex gap-1">
|
|
<button class="btn btn-warning btn-sm flex-fill" id="checkComplianceBtn"><i class="fa-solid fa-map"></i> Check Compliance</button>
|
|
</div>
|
|
</div>
|
|
<div class="row mb-3">
|
|
<label for="processingFee" class="form-label fw-bold text-primary">Permit Fee *</label>
|
|
<input type="text" name="processing_fees" id="processingFee" class="form-control">
|
|
</div>
|
|
<div class="row mb-3">
|
|
<div class="d-flex gap-1">
|
|
<button class="btn btn-primary flex-fill"><i class="fa-solid fa-paper-plane"></i> Submit</button>
|
|
<button type="button" class="btn btn-outline-primary" data-bs-toggle="modal" data-bs-target="#inspectionReportModal">
|
|
<i class="bi bi-file-earmark-text"></i> Site Inspection Report
|
|
</button>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-md-5">
|
|
<!-- Remarks -->
|
|
<div class="details-section mt-2">
|
|
<h2 class="section-title text-primary">
|
|
Applicant & Property Details
|
|
</h2>
|
|
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<!-- <h6 class="detail-label">Project Description</h6> -->
|
|
<p class="detail-value"></p>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<h6 class="detail-label">Name</h6>
|
|
<p class="detail-value">{{ $permit_arr['applicant_name'] }}</p>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<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">{{ $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">Project Location</h6>
|
|
<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-6">
|
|
<h6 class="detail-label">Permit Type</h6>
|
|
<p class="detail-value">{{ $permit_arr['permit_type'] }}</p>
|
|
</div>
|
|
|
|
<div class="col-md-12">
|
|
<h6 class="detail-label">Description</h6>
|
|
<p class="detail-value">{{ $permit_arr['project_description'] }}</p>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<h6 class="detail-label">Purpose</h6>
|
|
<p class="detail-value">{{ $permit_arr['land_request_use'] }}</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Planning Permit Application -->
|
|
<div class="details-section mt-4">
|
|
<h2 class="section-title text-primary">Documents</h2>
|
|
|
|
<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" 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> 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> -->
|
|
|
|
</div>
|
|
<!-- <div class="col-md-6">
|
|
<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> Title Certificate</a></p>
|
|
</div> -->
|
|
</div>
|
|
</div>
|
|
<div class="details-section mt-4">
|
|
<h2 class="section-title text-primary">Duration</h2>
|
|
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<h6 class="detail-label">Date of Application</h6>
|
|
<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>
|
|
<p class="detail-value">
|
|
<span class="badge bg-warning text-dark">
|
|
<?php
|
|
if ($permit_arr['status'] == 'submitted') {
|
|
echo "N/A";
|
|
}
|
|
?>
|
|
</span>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="remarks-section">
|
|
<h3 class="section-title">Status & Comments</h3>
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
@include('permits.partials.comments-timeline')
|
|
</div>
|
|
</div>
|
|
<div class="row mb-3">
|
|
<div class="col-md-12">
|
|
<label for="permitCurrentStatus" class="form-label fw-bold text-primary"><i class="fa-solid fa-temperature-three-quarters"></i> Status Update</label>
|
|
{{-- @if(in_array(session('current_user.ua_position'), $allowed_users_to_comment)) --}}
|
|
<select class="form-select form-select-lgdd" id="permitCurrentStatus">
|
|
<option value="" selected disabled>Select status ...</option>
|
|
<option value="status_five">Applicant to Review</option>
|
|
<option value="status_one">Application Received</option>
|
|
<option value="status_two" disabled>Application Accepted</option>
|
|
<option value="status_three" disabled>Permit Pending TSC Review</option>
|
|
<option value="status_four" disabled>Permit Pending SPC Decision</option>
|
|
<option value="status_five" disabled>Permit Approved (In Principle)</option>
|
|
<option value="status_size" disabled>Permit Approved</option>
|
|
<option value="status_seven" disabled>Permit Refused</option>
|
|
<option value="status_eight" disabled>Permit Deferred</option>
|
|
</select>
|
|
{{-- @else --}}
|
|
<!-- <p class="badge bg-warning text-dark">You don't have the right permission to update the status.</p> -->
|
|
{{-- @endif-- }}
|
|
</div>
|
|
</div>
|
|
<div class="row mb-3">
|
|
<div class="col-md-12">
|
|
|
|
{{-- @if(in_array(session('current_user.ua_position'), $allowed_users_to_comment)) --}}
|
|
<textarea class="form-control mb-3 commentBody" rows="4" name="comment_body" placeholder="Enter new comment here" ></textarea>
|
|
<input type="hidden" class="applicationCode" name="application_code" value="{{ $permit_arr['application_code'] }}">
|
|
{{-- @else --}}
|
|
<!-- <p class="badge bg-warning text-dark">You don't have the right permission to add comments.</p> -->
|
|
{{-- @endif --}}
|
|
</div>
|
|
</div>
|
|
<div class="row mb-3">
|
|
<div class="d-flex gap-1">
|
|
<button class="btn btn-primary flex-fill submitPermitCommentBtn"><i class="fa-solid fa-paper-plane"></i> Submit</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
@endsection
|
|
@section('page-js')
|
|
<!-- <script src="{{ url('public/assets/libs/select2/dist/js/select2.full.min.js') }}" type="text/javascript" ></script> -->
|
|
|
|
|
|
<!-- <script src="{{ url('public/assets/js/permit_tools.js') }}" type="text/javascript" ></script> -->
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js"></script>
|
|
<script src="{{ url('public/assets/js/permit_comments.js') }}" type="text/javascript" ></script>
|
|
<script type="text/javascript">
|
|
$(document).ready(function(){
|
|
|
|
// Initial load
|
|
|
|
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 = '';
|
|
});
|
|
|
|
const MAP_ORIGIN = 'https://pwa.lupmis4luspa.org';
|
|
const iframe = document.getElementById('permit-map');
|
|
const upnInput = document.getElementById('permitUPN');
|
|
const locInput = document.getElementById('permitLocation');
|
|
|
|
window.addEventListener('message', function (event) {
|
|
if (event.origin !== MAP_ORIGIN) return;
|
|
const msg = event.data;
|
|
if (!msg || typeof msg !== 'object') return;
|
|
|
|
switch (msg.type) {
|
|
case 'ready':
|
|
@if(!empty($permit_arr['upn']))
|
|
iframe.contentWindow.postMessage(
|
|
{ type: 'set:selected', upn: @json($permit_arr['upn']) },
|
|
MAP_ORIGIN);
|
|
@endif
|
|
break;
|
|
|
|
case 'parcel:select':
|
|
upnInput.value = msg.upn || '';
|
|
locInput.value = (msg.lon != null && msg.lat != null)
|
|
? msg.lat.toFixed(6) + ', ' + msg.lon.toFixed(6)
|
|
: '';
|
|
upnInput.dataset.parcelId = msg.parcel_id || '';
|
|
upnInput.dataset.zoneCode = msg.zone_code || '';
|
|
break;
|
|
|
|
case 'parcel:cleared':
|
|
upnInput.value = '';
|
|
locInput.value = '';
|
|
delete upnInput.dataset.parcelId;
|
|
delete upnInput.dataset.zoneCode;
|
|
break;
|
|
|
|
case 'error':
|
|
console.warn('[permit-map]', msg.code, msg.message);
|
|
break;
|
|
}
|
|
|
|
$('#checkComplianceBtn').on('click', function (e) {
|
|
e.preventDefault();
|
|
const payload = {
|
|
application_code: @json($permit_arr['application_code']),
|
|
upn: upnInput.value,
|
|
parcel_id: upnInput.dataset.parcelId || null,
|
|
coordinates: locInput.value,
|
|
zone_code: upnInput.dataset.zoneCode || null,
|
|
};
|
|
$.ajax({ url: '{{ route("permits.checkCompliance") }}',
|
|
method: 'POST', data: payload })
|
|
.done(function (res) { /* render compliance result */ });
|
|
});
|
|
|
|
});
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
const downloadBtn = document.getElementById('downloadPdfBtn');
|
|
|
|
if(downloadBtn) {
|
|
downloadBtn.addEventListener('click', function() {
|
|
const element = document.getElementById('report-pdf-content');
|
|
const inputs = element.querySelectorAll('input, textarea, select');
|
|
inputs.forEach(input => {
|
|
if (input.tagName === 'TEXTAREA') {
|
|
input.innerHTML = input.value;
|
|
} else if (input.tagName === 'SELECT') {
|
|
const selectedOption = input.options[input.selectedIndex];
|
|
if (selectedOption) selectedOption.setAttribute('selected', 'selected');
|
|
} else {
|
|
input.setAttribute('value', input.value);
|
|
}
|
|
});
|
|
const originalText = downloadBtn.innerHTML;
|
|
downloadBtn.innerHTML = '<i class="bi bi-hourglass-split"></i> Generating...';
|
|
downloadBtn.disabled = true;
|
|
|
|
// Configure and generate PDF
|
|
const opt = {
|
|
margin: 0.5,
|
|
filename: 'Site_Inspection_Report.pdf',
|
|
image: { type: 'jpeg', quality: 0.98 },
|
|
html2canvas: { scale: 2, useCORS: true, logging: false },
|
|
jsPDF: { unit: 'in', format: 'a4', orientation: 'portrait' }
|
|
};
|
|
|
|
html2pdf().set(opt).from(element).save().then(() => {
|
|
downloadBtn.innerHTML = originalText;
|
|
downloadBtn.disabled = false;
|
|
});
|
|
});
|
|
}
|
|
});
|
|
window.generateReportPDF = function() {
|
|
console.log("1. Button clicked. Starting PDF process...");
|
|
|
|
if (typeof html2pdf === 'undefined') {
|
|
alert("ERROR: The html2pdf library is not loaded.");
|
|
return;
|
|
}
|
|
|
|
const element = document.getElementById('report-pdf-content');
|
|
if (!element) {
|
|
alert("ERROR: Could not find the div with id='report-pdf-content'.");
|
|
return;
|
|
}
|
|
|
|
try {
|
|
const inputs = element.querySelectorAll('input, textarea, select');
|
|
inputs.forEach(input => {
|
|
if (input.tagName === 'TEXTAREA') {
|
|
input.innerHTML = input.value;
|
|
} else if (input.tagName === 'SELECT') {
|
|
const selectedOption = input.options[input.selectedIndex];
|
|
if (selectedOption) selectedOption.setAttribute('selected', 'selected');
|
|
input.style.backgroundImage = 'none';
|
|
input.style.appearance = 'none'; // Removes native browser arrows
|
|
} else {
|
|
input.setAttribute('value', input.value);
|
|
}
|
|
});
|
|
|
|
console.log("3. Form data locked and SVGs removed. Generating file...");
|
|
const opt = {
|
|
margin: 0.5,
|
|
filename: 'Site_Inspection_Report.pdf',
|
|
image: { type: 'jpeg', quality: 0.98 },
|
|
html2canvas: {
|
|
scale: 2,
|
|
useCORS: true,
|
|
logging: false,
|
|
scrollY: 0,
|
|
windowY: 0
|
|
},
|
|
jsPDF: { unit: 'in', format: 'a4', orientation: 'portrait' },
|
|
|
|
pagebreak: {
|
|
mode: 'css',
|
|
avoid: ['.row', 'h6']
|
|
}
|
|
};
|
|
|
|
// Generate PDF
|
|
html2pdf().set(opt).from(element).save().then(() => {
|
|
console.log("Success: PDF downloaded.");
|
|
|
|
// THE RESTORE: Put the arrows back on the screen after download finishes
|
|
inputs.forEach(input => {
|
|
if (input.tagName === 'SELECT') {
|
|
input.style.backgroundImage = '';
|
|
input.style.appearance = '';
|
|
}
|
|
});
|
|
}).catch(err => {
|
|
console.error("PDF Generation Error:", err);
|
|
alert("Failed to build the PDF. Check the browser console.");
|
|
});
|
|
|
|
} catch (error) {
|
|
console.error("Critical Execution Error:", error);
|
|
alert("A javascript error occurred: " + error.message);
|
|
}
|
|
}
|
|
|
|
});
|
|
</script>
|
|
@endsection
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|