started work on OTP and disabled registration
This commit is contained in:
209
resources/views/offices/documents.blade.php
Normal file
209
resources/views/offices/documents.blade.php
Normal file
@@ -0,0 +1,209 @@
|
||||
@extends('layouts.masterbeta')
|
||||
|
||||
@section('title', 'Click ERP - Office Documents')
|
||||
|
||||
@section('breadcrumbs')
|
||||
<a href="{{ url('/') }}" class="text-secondary text-decoration-none"><i class="bi bi-house me-2"></i></a>
|
||||
<i class="bi bi-chevron-right text-secondary me-2" style="font-size: 0.8rem;"></i>
|
||||
<a href="{{ route('offices.index') }}" class="text-secondary text-decoration-none">Offices</a>
|
||||
<i class="bi bi-chevron-right text-secondary me-2" style="font-size: 0.8rem;"></i>
|
||||
<span class="fw-bold" style="font-size: 0.95rem;">{{ $location->city }} Documents</span>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<div>
|
||||
<h4 class="fw-bold mb-1"><i class="bi bi-folder-check text-primary me-2"></i>{{ $location->city }}, {{ $location->country }}</h4>
|
||||
<p class="text-secondary mb-0" style="font-size: 0.9rem;">Manage compliance files, leases, and local registrations.</p>
|
||||
</div>
|
||||
<button class="btn text-white fw-bold d-flex align-items-center" style="background-color: #5c4df0; border-radius: 8px;" id="btnOpenDocModal">
|
||||
<i class="bi bi-upload me-2"></i> Upload Document
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="content-card shadow-sm">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-custom table-hover mb-0 align-middle">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Document Name</th>
|
||||
<th>Format</th>
|
||||
<th>Validity Period</th>
|
||||
<th>Next Renewal</th>
|
||||
<th class="text-end">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@forelse($location->documents as $doc)
|
||||
<tr>
|
||||
<td class="fw-bold text-dark">{{ $doc->name }}</td>
|
||||
<td class="text-uppercase small fw-bold text-secondary">{{ $doc->file_extension }}</td>
|
||||
<td>
|
||||
<span class="badge bg-secondary bg-opacity-10 text-dark border">{{ $doc->validity_period }}</span>
|
||||
</td>
|
||||
<td>
|
||||
@if($doc->validity_period === 'On Demand')
|
||||
<span class="text-secondary small">N/A</span>
|
||||
@else
|
||||
@php
|
||||
// Highlight if renewal is approaching within 30 days or past due
|
||||
$isUrgent = $doc->next_renewal_date && \Carbon\Carbon::parse($doc->next_renewal_date)->isPast() || \Carbon\Carbon::parse($doc->next_renewal_date)->diffInDays(now()) <= 30;
|
||||
@endphp
|
||||
<span class="small fw-medium {{ $isUrgent ? 'text-danger' : 'text-dark' }}">
|
||||
@if($isUrgent) <i class="bi bi-exclamation-circle-fill me-1"></i> @endif
|
||||
{{ $doc->next_renewal_date ? \Carbon\Carbon::parse($doc->next_renewal_date)->format('M d, Y') : 'Not Set' }}
|
||||
</span>
|
||||
@endif
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<a href="{{ asset('public/storage/' . $doc->file_path) }}" target="_blank" class="btn btn-sm btn-light text-primary me-1" title="View File">
|
||||
<i class="bi bi-download"></i>
|
||||
</a>
|
||||
<button class="btn btn-sm btn-light text-danger btn-delete-doc" data-id="{{ $doc->id }}" title="Delete">
|
||||
<i class="bi bi-trash"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="5" class="text-center py-4 text-secondary">No regional documents uploaded yet.</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('modals')
|
||||
<!-- UPLOAD DOCUMENT MODAL -->
|
||||
<div class="modal fade" id="uploadOfficeDocModal" tabindex="-1" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header bg-light">
|
||||
<h5 class="modal-title fw-bold">Archive Regional Document</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
|
||||
<form id="officeDocForm" enctype="multipart/form-data">
|
||||
@csrf
|
||||
<div class="modal-body p-4">
|
||||
<div id="officeDocAlert"></div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label text-secondary fw-semibold small">Document Name *</label>
|
||||
<input type="text" class="form-control" name="name" required placeholder="e.g. Business Operating License">
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label text-secondary fw-semibold small">Validity Period *</label>
|
||||
<select class="form-select" id="validityPeriodSelect" name="validity_period" required>
|
||||
<option value="On Demand">On Demand (No Expiration)</option>
|
||||
<option value="Monthly">Monthly</option>
|
||||
<option value="Quarterly">Quarterly</option>
|
||||
<option value="Biannually">Biannually</option>
|
||||
<option value="Yearly">Yearly</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- This wrapper is hidden by default in JS if 'On Demand' is selected -->
|
||||
<div class="mb-3" id="renewalDateWrapper" style="display: none;">
|
||||
<label class="form-label text-secondary fw-semibold small">Next Renewal Date *</label>
|
||||
<input type="date" class="form-control" id="nextRenewalDateInput" name="next_renewal_date">
|
||||
</div>
|
||||
|
||||
<div class="mb-3 border-top pt-3 mt-3">
|
||||
<label class="form-label text-secondary fw-semibold small">Select File * (Max: 10MB)</label>
|
||||
<input type="file" class="form-control" name="file" required accept=".pdf,.jpg,.jpeg,.png,.doc,.docx">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer bg-light">
|
||||
<button type="button" class="btn btn-outline-secondary btn-sm" data-bs-dismiss="modal">Cancel</button>
|
||||
<button type="submit" id="btnSubmitOfficeDoc" class="btn text-white btn-sm fw-bold px-4" style="background-color: #5c4df0;">Upload Document</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endpush
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
const uploadModal = new bootstrap.Modal(document.getElementById('uploadOfficeDocModal'));
|
||||
const $form = $('#officeDocForm');
|
||||
|
||||
$('#btnOpenDocModal').on('click', function() {
|
||||
$form[0].reset();
|
||||
$('#officeDocAlert').html('');
|
||||
$('#renewalDateWrapper').hide(); // Reset to hidden
|
||||
$('#nextRenewalDateInput').prop('required', false);
|
||||
uploadModal.show();
|
||||
});
|
||||
|
||||
// Dynamic logic for Validity Period selection
|
||||
$('#validityPeriodSelect').on('change', function() {
|
||||
if ($(this).val() === 'On Demand') {
|
||||
$('#renewalDateWrapper').slideUp();
|
||||
$('#nextRenewalDateInput').prop('required', false).val('');
|
||||
} else {
|
||||
$('#renewalDateWrapper').slideDown();
|
||||
$('#nextRenewalDateInput').prop('required', true);
|
||||
}
|
||||
});
|
||||
|
||||
// Submit logic
|
||||
$form.on('submit', function(e) {
|
||||
e.preventDefault();
|
||||
const $btn = $('#btnSubmitOfficeDoc');
|
||||
const originalText = $btn.html();
|
||||
|
||||
$btn.html('<span class="spinner-border spinner-border-sm me-2"></span> Uploading...');
|
||||
$btn.prop('disabled', true);
|
||||
|
||||
$.ajax({
|
||||
url: "{{ route('offices.documents.store', $location->id) }}",
|
||||
type: 'POST',
|
||||
data: new FormData(this),
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
uploadModal.hide();
|
||||
Swal.fire({
|
||||
icon: 'success', title: 'Uploaded!', text: response.message, confirmButtonColor: '#5c4df0'
|
||||
}).then(() => location.reload());
|
||||
}
|
||||
},
|
||||
error: function(xhr) {
|
||||
let msg = xhr.responseJSON?.message || 'Failed to upload document.';
|
||||
$('#officeDocAlert').html(`<div class="alert alert-danger py-2 px-3 small"><i class="bi bi-exclamation-triangle-fill me-2"></i> ${msg}</div>`);
|
||||
},
|
||||
complete: function() {
|
||||
$btn.html(originalText).prop('disabled', false);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Delete logic
|
||||
$('.btn-delete-doc').on('click', function() {
|
||||
const docId = $(this).data('id');
|
||||
Swal.fire({
|
||||
title: 'Delete Document?', icon: 'warning', showCancelButton: true, confirmButtonColor: '#ef4444', confirmButtonText: 'Yes, delete it!'
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
$.ajax({
|
||||
url: "{{ url('offices/documents/delete') }}/" + docId,
|
||||
type: 'POST',
|
||||
data: { _token: '{{ csrf_token() }}', _method: 'DELETE' },
|
||||
success: function(response) {
|
||||
if (response.success) location.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
233
resources/views/offices/index.blade.php
Normal file
233
resources/views/offices/index.blade.php
Normal file
@@ -0,0 +1,233 @@
|
||||
@extends('layouts.masterbeta')
|
||||
|
||||
@section('title', 'Click ERP - Office Locations')
|
||||
@push('styles')
|
||||
<!-- Select2 CSS -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
|
||||
<link href="https://cdn.jsdelivr.net/npm/select2-bootstrap-5-theme@1.3.0/dist/select2-bootstrap-5-theme.min.css" rel="stylesheet" />
|
||||
@endpush
|
||||
|
||||
@section('breadcrumbs')
|
||||
<a href="{{ url('/') }}" class="text-secondary text-decoration-none"><i class="bi bi-house me-2"></i></a>
|
||||
<i class="bi bi-chevron-right text-secondary me-2" style="font-size: 0.8rem;"></i>
|
||||
<span class="fw-bold" style="font-size: 0.95rem;">Office Locations</span>
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<div>
|
||||
<h4 class="fw-bold mb-1">Global Offices</h4>
|
||||
<p class="text-secondary mb-0" style="font-size: 0.9rem;">Manage regional branches and compliance documents.</p>
|
||||
</div>
|
||||
<button class="btn text-white fw-bold d-flex align-items-center" style="background-color: #5c4df0; border-radius: 8px;" id="btnOpenLocationModal">
|
||||
<i class="bi bi-plus-lg me-2"></i> Add Office
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="row g-4">
|
||||
@forelse($locations as $office)
|
||||
<div class="col-md-4">
|
||||
<div class="content-card shadow-sm h-100 position-relative">
|
||||
<div class="p-4">
|
||||
<div class="d-flex justify-content-between align-items-start mb-3">
|
||||
<h5 class="fw-bold mb-0 text-dark">
|
||||
<i class="bi bi-geo-alt-fill text-danger me-2"></i>{{ $office->city ?? 'N/A' }}, {{ $office->country }}
|
||||
</h5>
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-sm btn-light border-0" type="button" data-bs-toggle="dropdown">
|
||||
<i class="bi bi-three-dots-vertical"></i>
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu-end shadow-sm">
|
||||
<li><a class="dropdown-item btn-edit-location" href="#" data-location="{{ json_encode($office) }}"><i class="bi bi-pencil me-2"></i>Edit Details</a></li>
|
||||
<li><a class="dropdown-item text-danger btn-delete-location" href="#" data-id="{{ $office->id }}"><i class="bi bi-trash me-2"></i>Remove</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3 text-secondary small">
|
||||
<div><i class="bi bi-building me-2"></i>{{ $office->physical_address ?? 'Address not set' }}</div>
|
||||
<div class="mt-1"><i class="bi bi-telephone me-2"></i>{{ $office->office_phone ?? 'Phone not set' }}</div>
|
||||
</div>
|
||||
|
||||
<div class="border-top pt-3 mt-auto">
|
||||
<div class="text-secondary fw-bold" style="font-size: 0.7rem; letter-spacing: 0.5px;">COUNTRY MANAGER</div>
|
||||
<div class="d-flex align-items-center mt-1">
|
||||
<i class="bi bi-person-circle fs-4 text-primary me-2"></i>
|
||||
<span class="fw-medium text-dark">{{ $office->manager->name ?? 'Not Assigned' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Action Button to navigate to Documents -->
|
||||
<div class="mt-4">
|
||||
<a href="{{ route('offices.documents', $office->id) }}" class="btn btn-light border w-100 fw-medium d-flex justify-content-between align-items-center">
|
||||
<span><i class="bi bi-folder-check me-2 text-primary"></i> Documents</span>
|
||||
<span class="badge bg-primary rounded-pill">{{ $office->documents->count() }}</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@empty
|
||||
<div class="col-12 text-center py-5">
|
||||
<div class="text-secondary">No office locations configured yet.</div>
|
||||
</div>
|
||||
@endforelse
|
||||
</div>
|
||||
<div class="d-flex justify-content-center mt-4">
|
||||
{{ $locations->links('pagination::bootstrap-5') }}
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('modals')
|
||||
<!-- ADD/EDIT LOCATION MODAL -->
|
||||
<div class="modal fade" id="locationModal" tabindex="-1" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header bg-light">
|
||||
<h5 class="modal-title fw-bold" id="locationModalTitle">Add Office Location</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
|
||||
<form id="locationForm">
|
||||
@csrf
|
||||
<input type="hidden" id="locationId" name="id">
|
||||
<div class="modal-body p-4">
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6">
|
||||
<label class="form-label text-secondary fw-semibold small">Country *</label>
|
||||
<!-- Added width: 100% and select2 class -->
|
||||
<select class="form-select select2-country" id="loc_country" name="country" required style="width: 100%;">
|
||||
<option value=""></option> <!-- Empty option required for Select2 placeholder -->
|
||||
@foreach($countries as $country)
|
||||
<option value="{{ $country->en_short_name }}">{{ $country->en_short_name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label text-secondary fw-semibold small">City *</label>
|
||||
<input type="text" class="form-control" id="loc_city" name="city" required placeholder="e.g. Accra">
|
||||
</div>
|
||||
|
||||
<div class="col-md-12">
|
||||
<label class="form-label text-secondary fw-semibold small">Physical Address</label>
|
||||
<input type="text" class="form-control" id="loc_physical_address" name="physical_address">
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<label class="form-label text-secondary fw-semibold small">Office Phone</label>
|
||||
<input type="text" class="form-control" id="loc_office_phone" name="office_phone">
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<label class="form-label text-secondary fw-semibold small">ZIP / Postal Code</label>
|
||||
<input type="text" class="form-control" id="loc_zip_code" name="zip_code">
|
||||
</div>
|
||||
|
||||
<div class="col-md-12 border-top pt-3 mt-3">
|
||||
<label class="form-label text-secondary fw-semibold small">Country Manager</label>
|
||||
<select class="form-select" id="loc_country_manager_id" name="country_manager_id">
|
||||
<option value="">Select a Manager</option>
|
||||
@foreach($staffMembers as $staff)
|
||||
<option value="{{ $staff->id }}">{{ $staff->name }} ({{ $staff->designation ?? 'Staff' }})</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer bg-light">
|
||||
<button type="button" class="btn btn-outline-secondary btn-sm" data-bs-dismiss="modal">Cancel</button>
|
||||
<button type="submit" id="btnSubmitLocation" class="btn text-white btn-sm fw-bold px-4" style="background-color: #5c4df0;">Save Location</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endpush
|
||||
|
||||
@push('scripts')
|
||||
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
const locationModal = new bootstrap.Modal(document.getElementById('locationModal'));
|
||||
const $form = $('#locationForm');
|
||||
|
||||
$('.select2-country').select2({
|
||||
theme: 'bootstrap-5',
|
||||
dropdownParent: $('#locationModal'), // Fixes unclickable search box in Bootstrap modals
|
||||
placeholder: 'Search for a country...',
|
||||
allowClear: true
|
||||
});
|
||||
|
||||
$('#btnOpenLocationModal').on('click', function() {
|
||||
$form[0].reset();
|
||||
$('#locationId').val('');
|
||||
|
||||
$('#loc_country').val(null).trigger('change');
|
||||
|
||||
$('#locationModalTitle').text('Add Office Location');
|
||||
$('#btnSubmitLocation').text('Save Location');
|
||||
locationModal.show();
|
||||
});
|
||||
|
||||
$('.btn-edit-location').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
const data = $(this).data('location');
|
||||
|
||||
$form[0].reset();
|
||||
$('#locationId').val(data.id);
|
||||
|
||||
|
||||
$('#loc_country').val(data.country).trigger('change');
|
||||
|
||||
$('#loc_city').val(data.city);
|
||||
$('#loc_physical_address').val(data.physical_address);
|
||||
$('#loc_office_phone').val(data.office_phone);
|
||||
$('#loc_zip_code').val(data.zip_code);
|
||||
$('#loc_country_manager_id').val(data.country_manager_id);
|
||||
|
||||
$('#locationModalTitle').text('Edit Office Location');
|
||||
$('#btnSubmitLocation').text('Update Location');
|
||||
locationModal.show();
|
||||
});
|
||||
|
||||
$form.on('submit', function(e) {
|
||||
e.preventDefault();
|
||||
const recordId = $('#locationId').val();
|
||||
const url = recordId ? "{{ url('offices') }}/" + recordId : "{{ route('offices.store') }}";
|
||||
let formData = $form.serialize();
|
||||
if (recordId) formData += '&_method=PUT';
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
locationModal.hide();
|
||||
Swal.fire({
|
||||
icon: 'success', title: 'Success!', text: response.message, confirmButtonColor: '#5c4df0'
|
||||
}).then(() => location.reload());
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('.btn-delete-location').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
const id = $(this).data('id');
|
||||
Swal.fire({
|
||||
title: 'Remove Office?', icon: 'warning', showCancelButton: true, confirmButtonColor: '#ef4444', confirmButtonText: 'Yes, remove!'
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
$.ajax({
|
||||
url: "{{ url('offices') }}/" + id, type: 'POST', data: { _token: '{{ csrf_token() }}', _method: 'DELETE' },
|
||||
success: function(response) {
|
||||
if(response.success) location.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
Reference in New Issue
Block a user