bug fixes, daily reports, holidays
This commit is contained in:
42
app/Http/Controllers/DailyReportController.php
Normal file
42
app/Http/Controllers/DailyReportController.php
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\DailyReport;
|
||||||
|
use App\Models\ReportOverride;
|
||||||
|
use App\Http\Requests\StoreDailyReportRequest;
|
||||||
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
use App\Mail\DailyReportSubmitted;
|
||||||
|
|
||||||
|
class DailyReportController extends Controller
|
||||||
|
{
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$reports = auth()->user()->dailyReports()
|
||||||
|
->orderBy('report_date', 'desc')
|
||||||
|
->paginate(15);
|
||||||
|
|
||||||
|
return view('reports.index', compact('reports'));
|
||||||
|
}
|
||||||
|
public function store(StoreDailyReportRequest $request)
|
||||||
|
{
|
||||||
|
$report = DailyReport::create([
|
||||||
|
'user_id' => auth()->id(),
|
||||||
|
'report_date' => $request->report_date,
|
||||||
|
'content' => $request->content,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// If they used an override, optionally delete or mark it as used so it can't be reused
|
||||||
|
ReportOverride::where('user_id', auth()->id())
|
||||||
|
->where('report_date', $request->report_date)
|
||||||
|
->delete();
|
||||||
|
|
||||||
|
$managementEmails = ['samuel@click-mobile.com'];
|
||||||
|
Mail::to($managementEmails)->send(new DailyReportSubmitted($report, auth()->user()));
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'success' => true,
|
||||||
|
'message' => 'Daily report submitted successfully.'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,8 @@ use App\Models\OfficeLocation;
|
|||||||
use App\Models\StaffMember;
|
use App\Models\StaffMember;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use App\Models\PublicHoliday;
|
||||||
|
|
||||||
|
|
||||||
class OfficeLocationController extends Controller
|
class OfficeLocationController extends Controller
|
||||||
{
|
{
|
||||||
@@ -115,4 +117,13 @@ class OfficeLocationController extends Controller
|
|||||||
$document->delete();
|
$document->delete();
|
||||||
return response()->json(['success' => true, 'message' => 'Document deleted.']);
|
return response()->json(['success' => true, 'message' => 'Document deleted.']);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Swift track malawi
|
||||||
|
// eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI3MTYiLCJvaWQiOjcxNiwidWlkIjoiNDU3OTIzYzgtYmNkMS00ZWJhLWI3NzYtMGYyOTJmNmYzNWM4IiwiYXBpZCI6NTcxLCJpYXQiOjE3ODg1MzYwMzgsImV4cCI6MjEyODUzNjAzOH0.xbcNFzMNcryMACwYjOQMfF4Q06S80ttH4gYrcbduekTRXQcE4LptFEmir7iyeshghXy-C7Jcqno4UCKRIVnNig
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// klick
|
||||||
|
// eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI2OSIsIm9pZCI6NjksInVpZCI6IjEyMTdiMmE4LWNlYTYtNGE3ZC1hODlmLTFiODBhNDQxMzRjYSIsImFwaWQiOjQwMCwiaWF0IjoxNzI2NDc2MTc4LCJleHAiOjIwNjY0NzYxNzh9.7Yv2dyT3wEGz28ddFEMdEN0EsmD18hLSaHfNxIPCAskPjHFQ8819u5cLwfzNeZy5Xa3Xaz1ZNc66j0Fd8xSWDw
|
||||||
@@ -30,6 +30,7 @@ class ProfileController extends Controller
|
|||||||
'photo' => 'nullable|image|mimes:jpg,jpeg,png|max:2048',
|
'photo' => 'nullable|image|mimes:jpg,jpeg,png|max:2048',
|
||||||
]);
|
]);
|
||||||
// Combine month and day if both are provided (e.g., "12-25")
|
// Combine month and day if both are provided (e.g., "12-25")
|
||||||
|
|
||||||
if (!empty($request->birth_month) && !empty($request->birth_day)) {
|
if (!empty($request->birth_month) && !empty($request->birth_day)) {
|
||||||
$validated['dob'] = $request->birth_month . '-' . $request->birth_day;
|
$validated['dob'] = $request->birth_month . '-' . $request->birth_day;
|
||||||
} else {
|
} else {
|
||||||
@@ -52,8 +53,6 @@ class ProfileController extends Controller
|
|||||||
return response()->json(['success' => true, 'message' => 'Profile updated successfully!']);
|
return response()->json(['success' => true, 'message' => 'Profile updated successfully!']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- DEPENDENTS / EMERGENCY CONTACTS CRUD ---
|
|
||||||
|
|
||||||
public function storeDependent(Request $request)
|
public function storeDependent(Request $request)
|
||||||
{
|
{
|
||||||
$staff = StaffMember::where('email', auth()->user()->email)->firstOrFail();
|
$staff = StaffMember::where('email', auth()->user()->email)->firstOrFail();
|
||||||
|
|||||||
81
app/Http/Controllers/PublicHolidaysController.php
Normal file
81
app/Http/Controllers/PublicHolidaysController.php
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\OfficeLocation;
|
||||||
|
use App\Models\PublicHoliday;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
|
||||||
|
class PublicHolidaysController extends Controller
|
||||||
|
{
|
||||||
|
public function index($officeId)
|
||||||
|
{
|
||||||
|
$holidays = PublicHoliday::where('office_location_id', $officeId)
|
||||||
|
->orderBy('holiday_date', 'asc')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
return response()->json($holidays);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$validated = $request->validate([
|
||||||
|
'office_location_id' => 'required|exists:office_locations,id',
|
||||||
|
'name' => 'required|string|max:255',
|
||||||
|
'holiday_date' => 'required|date',
|
||||||
|
'is_recurring' => 'boolean',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$validated['is_recurring'] = $request->has('is_recurring');
|
||||||
|
|
||||||
|
PublicHoliday::create($validated);
|
||||||
|
|
||||||
|
return response()->json(['success' => true]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(PublicHoliday $holiday)
|
||||||
|
{
|
||||||
|
$holiday->delete();
|
||||||
|
return response()->json(['success' => true]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function importFromApi(Request $request, $officeId)
|
||||||
|
{
|
||||||
|
$location = OfficeLocation::findOrFail($officeId);
|
||||||
|
$year = $request->input('year', now()->year);
|
||||||
|
$countryCode = $request->input('country_code');
|
||||||
|
|
||||||
|
if (!$countryCode) {
|
||||||
|
return response()->json(['success' => false, 'message' => 'Country code missing.'], 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = Http::get("https://date.nager.at/api/v3/PublicHolidays/{$year}/{$countryCode}");
|
||||||
|
|
||||||
|
if ($response->successful()) {
|
||||||
|
$apiHolidays = $response->json();
|
||||||
|
$count = 0;
|
||||||
|
|
||||||
|
foreach ($apiHolidays as $holiday) {
|
||||||
|
PublicHoliday::updateOrCreate(
|
||||||
|
[
|
||||||
|
'office_location_id' => $location->id,
|
||||||
|
'holiday_date' => $holiday['date'],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => $holiday['name'],
|
||||||
|
'is_recurring' => $holiday['fixed'] ?? false,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
$count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'success' => true,
|
||||||
|
'message' => "Successfully imported {$count} holidays."
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json(['success' => false, 'message' => 'Failed to fetch from API.'], 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
41
app/Http/Controllers/ReportOverrideController.php
Normal file
41
app/Http/Controllers/ReportOverrideController.php
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\ReportOverride;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
|
||||||
|
class ReportOverrideController extends Controller
|
||||||
|
{
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
// Todo : Add middleware or policy checks for management
|
||||||
|
|
||||||
|
$request->validate([
|
||||||
|
'user_id' => 'required|exists:staff_members,id',
|
||||||
|
'report_date' => 'required|date',
|
||||||
|
'hours_valid' => 'nullable|integer|min:1|max:72',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$hoursValid = (int) ($request->input('hours_valid') ?? 24);
|
||||||
|
|
||||||
|
ReportOverride::updateOrCreate(
|
||||||
|
[
|
||||||
|
'user_id' => $request->user_id,
|
||||||
|
'report_date' => $request->report_date,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'granted_by' => auth()->id(),
|
||||||
|
'expires_at' => now()->addHours($hoursValid),
|
||||||
|
// 'expires_at' => now()->addHours($request->hours_valid ?? 24),
|
||||||
|
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'success' => true,
|
||||||
|
'message' => 'Late submission override granted successfully.'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,7 +17,6 @@ class StaffMembersController extends Controller
|
|||||||
{
|
{
|
||||||
$query = StaffMember::query();
|
$query = StaffMember::query();
|
||||||
|
|
||||||
// 1. Search Filter
|
|
||||||
if ($request->filled('search')) {
|
if ($request->filled('search')) {
|
||||||
$search = $request->search;
|
$search = $request->search;
|
||||||
$query->where(function($q) use ($search) {
|
$query->where(function($q) use ($search) {
|
||||||
@@ -28,12 +27,11 @@ class StaffMembersController extends Controller
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Department Filter
|
|
||||||
if ($request->filled('department_id')) {
|
if ($request->filled('department_id')) {
|
||||||
$query->where('department_id', $request->department_id);
|
$query->where('department_id', $request->department_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Status Filter
|
|
||||||
if ($request->filled('status')) {
|
if ($request->filled('status')) {
|
||||||
$query->where('status', $request->status);
|
$query->where('status', $request->status);
|
||||||
}
|
}
|
||||||
@@ -41,16 +39,20 @@ class StaffMembersController extends Controller
|
|||||||
$staffMembers = $query->orderBy('name', 'asc')->paginate(12);
|
$staffMembers = $query->orderBy('name', 'asc')->paginate(12);
|
||||||
$staffMembers->appends($request->query());
|
$staffMembers->appends($request->query());
|
||||||
|
|
||||||
// Fetch dynamic dropdown lists
|
|
||||||
$departments = Department::orderBy('name', 'asc')->get();
|
$departments = Department::orderBy('name', 'asc')->get();
|
||||||
$countries = Country::orderBy('en_short_name', 'asc')->get();
|
$countries = Country::orderBy('en_short_name', 'asc')->get();
|
||||||
|
$allstaffMembers = StaffMember::orderBy('name')->get(['id', 'name']);
|
||||||
|
|
||||||
|
// dd($staffMembers);
|
||||||
|
// dd(\Auth::user()->designation);
|
||||||
$data = [
|
$data = [
|
||||||
'staffMembers' => $staffMembers,
|
'staffMembers' => $staffMembers,
|
||||||
'departments' => $departments,
|
'departments' => $departments,
|
||||||
|
'allstaffMembers' => $allstaffMembers,
|
||||||
'countries' => $countries,
|
'countries' => $countries,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
return view('staff.index', $data);
|
return view('staff.index', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
48
app/Http/Requests/StoreDailyReportRequest.php
Normal file
48
app/Http/Requests/StoreDailyReportRequest.php
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Requests;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use App\Models\ReportOverride;
|
||||||
|
|
||||||
|
class StoreDailyReportRequest extends FormRequest
|
||||||
|
{
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'report_date' => 'required|date|before_or_equal:today',
|
||||||
|
'content' => 'required|string',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function withValidator($validator)
|
||||||
|
{
|
||||||
|
$validator->after(function ($validator) {
|
||||||
|
$reportDate = Carbon::parse($this->report_date)->startOfDay();
|
||||||
|
|
||||||
|
// Calculate standard deadline: 48 hours from the end of the report date
|
||||||
|
$deadline = $reportDate->copy()->endOfDay()->addHours(48);
|
||||||
|
|
||||||
|
if (now()->greaterThan($deadline)) {
|
||||||
|
// Check if a valid override exists
|
||||||
|
$hasOverride = ReportOverride::where('user_id', auth()->id())
|
||||||
|
->where('report_date', $this->report_date)
|
||||||
|
->where('expires_at', '>', now())
|
||||||
|
->exists();
|
||||||
|
|
||||||
|
if (!$hasOverride) {
|
||||||
|
$validator->errors()->add(
|
||||||
|
'report_date',
|
||||||
|
'The 48-hour submission window for this date has expired. Please contact management for an override.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
27
app/Mail/DailyReportSubmitted.php
Normal file
27
app/Mail/DailyReportSubmitted.php
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Mail;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Mail\Mailable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class DailyReportSubmitted extends Mailable
|
||||||
|
{
|
||||||
|
use Queueable, SerializesModels;
|
||||||
|
|
||||||
|
public $report;
|
||||||
|
public $user;
|
||||||
|
|
||||||
|
public function __construct($report, $user)
|
||||||
|
{
|
||||||
|
$this->report = $report;
|
||||||
|
$this->user = $user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function build()
|
||||||
|
{
|
||||||
|
return $this->subject('New Daily Report: ' . $this->user->name . ' - ' . $this->report->report_date->format('d M Y'))
|
||||||
|
->view('emails.reports.submitted');
|
||||||
|
}
|
||||||
|
}
|
||||||
17
app/Models/DailyReport.php
Normal file
17
app/Models/DailyReport.php
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class DailyReport extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = ['user_id', 'report_date', 'content'];
|
||||||
|
protected $casts = [
|
||||||
|
'report_date' => 'date',
|
||||||
|
];
|
||||||
|
public function user()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(StaffMember::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -29,4 +29,21 @@ class OfficeLocation extends Model
|
|||||||
{
|
{
|
||||||
return $this->hasMany(OfficeLocationDocument::class, 'office_location_id');
|
return $this->hasMany(OfficeLocationDocument::class, 'office_location_id');
|
||||||
}
|
}
|
||||||
|
public function holidays()
|
||||||
|
{
|
||||||
|
return $this->hasMany(PublicHoliday::class)->orderBy('holiday_date');
|
||||||
|
}
|
||||||
|
public function isHoliday($date)
|
||||||
|
{
|
||||||
|
$parsedDate = \Carbon\Carbon::parse($date);
|
||||||
|
|
||||||
|
return $this->holidays()->where(function($query) use ($parsedDate) {
|
||||||
|
$query->whereDate('holiday_date', $parsedDate->format('Y-m-d'))
|
||||||
|
->orWhere(function($q) use ($parsedDate) {
|
||||||
|
$q->where('is_recurring', true)
|
||||||
|
->whereMonth('holiday_date', $parsedDate->month)
|
||||||
|
->whereDay('holiday_date', $parsedDate->day);
|
||||||
|
});
|
||||||
|
})->exists();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
20
app/Models/PublicHoliday.php
Normal file
20
app/Models/PublicHoliday.php
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class PublicHoliday extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = ['office_location_id', 'name', 'holiday_date', 'is_recurring'];
|
||||||
|
// protected $guarded = ['id']
|
||||||
|
protected $casts = [
|
||||||
|
'holiday_date' => 'date',
|
||||||
|
'is_recurring' => 'boolean',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function location()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(OfficeLocation::class, 'office_location_id');
|
||||||
|
}
|
||||||
|
}
|
||||||
10
app/Models/ReportOverride.php
Normal file
10
app/Models/ReportOverride.php
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class ReportOverride extends Model
|
||||||
|
{
|
||||||
|
protected $guarded = ['id'];
|
||||||
|
}
|
||||||
@@ -27,7 +27,13 @@ class StaffMember extends Authenticatable
|
|||||||
public function dependents() {
|
public function dependents() {
|
||||||
return $this->hasMany(StaffDependent::class, 'staff_id');
|
return $this->hasMany(StaffDependent::class, 'staff_id');
|
||||||
}
|
}
|
||||||
|
public function dailyReports() {
|
||||||
|
return $this->hasMany(DailyReport::class, 'user_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function department(){
|
||||||
|
return $this->hasOne('App\Models\Department', 'id', 'department_id');
|
||||||
|
}
|
||||||
// 4. Cast dates correctly
|
// 4. Cast dates correctly
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
// 'dob' => 'date',
|
// 'dob' => 'date',
|
||||||
|
|||||||
@@ -270,6 +270,7 @@ $(document).ready(function() {
|
|||||||
window.location.href = base_url + "/clients/export?" + queryParams;
|
window.location.href = base_url + "/clients/export?" + queryParams;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Render Table Rows
|
||||||
// Render Table Rows
|
// Render Table Rows
|
||||||
function renderTable(clients) {
|
function renderTable(clients) {
|
||||||
let html = '';
|
let html = '';
|
||||||
@@ -310,13 +311,22 @@ $(document).ready(function() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Extract Account Manager name safely
|
// Extract Account Manager name safely
|
||||||
let amName = 'Unassigned';
|
let amName = 'Unassigned';
|
||||||
if (client.account_manager && client.account_manager.name) {
|
if (client.account_manager && client.account_manager.name) {
|
||||||
amName = client.account_manager.name;
|
amName = client.account_manager.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CONDITIONAL EDIT BUTTON LOGIC
|
||||||
|
let editButtonHtml = '';
|
||||||
|
if (typeof currentUserId !== 'undefined' && client.auth_user_id == currentUserId) {
|
||||||
|
editButtonHtml = `
|
||||||
|
<button class="btn btn-sm btn-light text-primary btn-edit-client" data-id="${client.id}" title="Edit Client">
|
||||||
|
<i class="bi bi-pencil"></i>
|
||||||
|
</button>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
html += `
|
html += `
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
@@ -330,12 +340,12 @@ $(document).ready(function() {
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="fw-semibold">${client.contact_person || 'N/A'}</div>
|
<div class="fw-semibold">${client.contact_person || 'N/A'}</div>
|
||||||
|
<div class="text-secondary" style="font-size: 0.8rem;">${client.email || 'N/A'}</div>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<span class="text-dark fw-medium" style="font-size: 0.85rem;">
|
<span class="text-dark fw-medium" style="font-size: 0.85rem;">
|
||||||
<i class="bi bi-person-badge text-secondary me-1"></i>${amName}
|
<i class="bi bi-person-badge text-secondary me-1"></i>${amName}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
|
||||||
<div class="text-secondary" style="font-size: 0.8rem;">${client.email || 'N/A'}</div>
|
|
||||||
</td>
|
</td>
|
||||||
<td style="max-width: 200px; white-space: normal;">
|
<td style="max-width: 200px; white-space: normal;">
|
||||||
${servicesHtml}
|
${servicesHtml}
|
||||||
@@ -348,9 +358,7 @@ $(document).ready(function() {
|
|||||||
<button class="btn btn-sm btn-light text-primary me-1 btn-view-client" data-id="${client.id}" title="View Details">
|
<button class="btn btn-sm btn-light text-primary me-1 btn-view-client" data-id="${client.id}" title="View Details">
|
||||||
<i class="bi bi-eye"></i>
|
<i class="bi bi-eye"></i>
|
||||||
</button>
|
</button>
|
||||||
<button class="btn btn-sm btn-light text-primary btn-edit-client" data-id="${client.id}" title="Edit Client">
|
${editButtonHtml}
|
||||||
<i class="bi bi-pencil"></i>
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
2
public/assets/libs/jquery-3.7.1.min.js
vendored
Normal file
2
public/assets/libs/jquery-3.7.1.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -38,9 +38,11 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
@if(Auth::User()->id == $showclient->auth_user_id)
|
||||||
<button type="button" class="btn btn-sm btn-outline-primary edit-client-btn" data-client-id="{{ $showclient->id }}" data-bs-toggle="modal" data-bs-target="#editClientModal">
|
<button type="button" class="btn btn-sm btn-outline-primary edit-client-btn" data-client-id="{{ $showclient->id }}" data-bs-toggle="modal" data-bs-target="#editClientModal">
|
||||||
<i class="bi bi-pencil me-1"></i> Edit Client
|
<i class="bi bi-pencil me-1"></i> Edit Client
|
||||||
</button>
|
</button>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
104
resources/views/emails/reports/submitted.blade.php
Normal file
104
resources/views/emails/reports/submitted.blade.php
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Daily Report Submitted</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||||
|
line-height: 1.6;
|
||||||
|
color: #333333;
|
||||||
|
background-color: #f4f7f6;
|
||||||
|
margin: 0;
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
.email-wrapper {
|
||||||
|
max-width: 600px;
|
||||||
|
margin: 0 auto;
|
||||||
|
background-color: #ffffff;
|
||||||
|
border-radius: 8px;
|
||||||
|
overflow: hidden;
|
||||||
|
box-shadow: 0 4px 6px rgba(0,0,0,0.05);
|
||||||
|
}
|
||||||
|
.email-header {
|
||||||
|
background-color: #5c4df0;
|
||||||
|
color: #ffffff;
|
||||||
|
padding: 20px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.email-header h2 {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 20px;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
.email-body {
|
||||||
|
padding: 30px;
|
||||||
|
}
|
||||||
|
.info-row {
|
||||||
|
margin-bottom: 15px;
|
||||||
|
border-bottom: 1px solid #eeeeee;
|
||||||
|
padding-bottom: 10px;
|
||||||
|
}
|
||||||
|
.label {
|
||||||
|
font-weight: 600;
|
||||||
|
color: #666666;
|
||||||
|
font-size: 14px;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.5px;
|
||||||
|
}
|
||||||
|
.value {
|
||||||
|
font-size: 16px;
|
||||||
|
color: #111111;
|
||||||
|
margin-top: 4px;
|
||||||
|
}
|
||||||
|
.report-content {
|
||||||
|
background-color: #f8f9fc;
|
||||||
|
border-left: 4px solid #5c4df0;
|
||||||
|
padding: 15px;
|
||||||
|
margin-top: 15px;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
font-size: 15px;
|
||||||
|
color: #444444;
|
||||||
|
}
|
||||||
|
.email-footer {
|
||||||
|
background-color: #fcfcfc;
|
||||||
|
padding: 15px;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 12px;
|
||||||
|
color: #999999;
|
||||||
|
border-top: 1px solid #eeeeee;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="email-wrapper">
|
||||||
|
<div class="email-header">
|
||||||
|
<h2>New Daily Report Submitted</h2>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="email-body">
|
||||||
|
<p>Hello Management,</p>
|
||||||
|
<p>A new daily activity report has been submitted and is ready for review.</p>
|
||||||
|
|
||||||
|
<div class="info-row">
|
||||||
|
<div class="label">Staff Member</div>
|
||||||
|
<div class="value">{{ $user->name }}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="info-row">
|
||||||
|
<div class="label">Report Date</div>
|
||||||
|
<div class="value">{{ \Carbon\Carbon::parse($report->report_date)->format('l, d F Y') }}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="info-row" style="border-bottom: none;">
|
||||||
|
<div class="label">Activities & Progress</div>
|
||||||
|
<div class="report-content">{{ $report->content }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="email-footer">
|
||||||
|
This is an automated notification from the Click ERP System. Please do not reply directly to this email.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -43,6 +43,7 @@
|
|||||||
@stack('styles')
|
@stack('styles')
|
||||||
<script>
|
<script>
|
||||||
var base_url = "{!! url('/') !!}";
|
var base_url = "{!! url('/') !!}";
|
||||||
|
const currentUserId = {{ auth()->id() ?? 'null' }};
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -60,8 +61,10 @@
|
|||||||
|
|
||||||
@stack('modals')
|
@stack('modals')
|
||||||
|
|
||||||
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
|
<!-- <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script> -->
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
<script src="{{ asset('public/assets/libs/jquery-3.7.1.min.js') }}"></script>
|
||||||
|
<script src="{{ asset('public/assets/libs/bootstrap/js/bootstrap5.3.2.js') }}"></script>
|
||||||
|
<!-- <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script> -->
|
||||||
<!-- SweetAlert2 CDN -->
|
<!-- SweetAlert2 CDN -->
|
||||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
||||||
<!-- Select2 JS (Place right after jQuery) -->
|
<!-- Select2 JS (Place right after jQuery) -->
|
||||||
|
|||||||
@@ -39,6 +39,9 @@
|
|||||||
|
|
||||||
|
|
||||||
<div class="sidebar-heading mt-2">Others</div>
|
<div class="sidebar-heading mt-2">Others</div>
|
||||||
|
<a href="{{ url('/reports') }}" class="sidebar-nav-item {{ request()->is('reports*') ? 'active' : '' }}">
|
||||||
|
<i class="bi bi-buildings me-2"></i> Reports
|
||||||
|
</a>
|
||||||
<a href="{{ url('/offices') }}" class="sidebar-nav-item {{ request()->is('offices*') ? 'active' : '' }}">
|
<a href="{{ url('/offices') }}" class="sidebar-nav-item {{ request()->is('offices*') ? 'active' : '' }}">
|
||||||
<i class="bi bi-buildings me-2"></i> Office Locations
|
<i class="bi bi-buildings me-2"></i> Office Locations
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -58,11 +58,16 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Action Button to navigate to Documents -->
|
<!-- Action Button to navigate to Documents -->
|
||||||
<div class="mt-4">
|
<!-- Action Buttons -->
|
||||||
<a href="{{ route('offices.documents', $office->id) }}" class="btn btn-light border w-100 fw-medium d-flex justify-content-between align-items-center">
|
<div class="mt-4 d-flex gap-2">
|
||||||
<span><i class="bi bi-folder-check me-2 text-primary"></i> Documents</span>
|
<a href="{{ route('offices.documents', $office->id) }}" class="btn btn-light border w-50 fw-medium d-flex justify-content-between align-items-center" style="font-size: 0.85rem;">
|
||||||
<span class="badge bg-primary rounded-pill">{{ $office->documents->count() }}</span>
|
<span><i class="bi bi-folder-check me-1 text-primary"></i> Docs</span>
|
||||||
|
<span class="badge bg-primary rounded-pill">{{ $office->documents->count() ?? 0 }}</span>
|
||||||
</a>
|
</a>
|
||||||
|
<button type="button" class="btn btn-light border w-50 fw-medium d-flex justify-content-between align-items-center btn-manage-holidays" data-id="{{ $office->id }}" data-location="{{ $office->city }}, {{ $office->country }}" data-country-code="{{ $office->country_code ?? 'GH' }}" style="font-size: 0.85rem;">
|
||||||
|
<span><i class="bi bi-calendar-event me-1 text-warning"></i> Holidays</span>
|
||||||
|
<span class="badge bg-warning text-dark rounded-pill" id="holiday-count-{{ $office->id }}">{{ $office->holidays->count() ?? 0 }}</span>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -142,6 +147,60 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- MANAGE HOLIDAYS OFFCANVAS -->
|
||||||
|
<div class="offcanvas offcanvas-end shadow" tabindex="-1" id="holidaysOffcanvas" style="width: 500px;">
|
||||||
|
<div class="offcanvas-header bg-light border-bottom">
|
||||||
|
<div>
|
||||||
|
<h5 class="offcanvas-title fw-bold" id="holidaysOffcanvasTitle">Public Holidays</h5>
|
||||||
|
<div class="text-secondary small" id="holidaysLocationName">Loading...</div>
|
||||||
|
</div>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<div class="offcanvas-body p-4">
|
||||||
|
|
||||||
|
<!-- API Auto-Fetch Alert Box -->
|
||||||
|
<!-- <div class="alert alert-info d-flex justify-content-between align-items-center p-3 mb-4">
|
||||||
|
<div>
|
||||||
|
<strong class="d-block" style="font-size: 0.85rem;">Auto-populate Holidays for the year {{ now()->year }} </strong>
|
||||||
|
<small>Fetch standard holidays via Nager.Date API.</small>
|
||||||
|
</div>
|
||||||
|
<button class="btn btn-sm btn-info text-white fw-bold" id="btnFetchApiHolidays">
|
||||||
|
<i class="bi bi-cloud-arrow-down me-1"></i> Fetch
|
||||||
|
</button>
|
||||||
|
</div> -->
|
||||||
|
|
||||||
|
<!-- Add Custom Holiday Form -->
|
||||||
|
<form id="addHolidayForm" class="mb-4 border p-3 rounded bg-light">
|
||||||
|
<h6 class="fw-bold mb-3" style="font-size: 0.85rem;">Add Custom / Local Holiday</h6>
|
||||||
|
<input type="hidden" id="holiday_location_id" name="office_location_id">
|
||||||
|
<div class="row g-2">
|
||||||
|
<div class="col-md-7">
|
||||||
|
<input type="text" class="form-control form-control-sm" name="name" placeholder="Holiday Name" required>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-5">
|
||||||
|
<input type="date" class="form-control form-control-sm" name="holiday_date" required>
|
||||||
|
</div>
|
||||||
|
<div class="col-12 mt-2 d-flex justify-content-between align-items-center">
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="checkbox" name="is_recurring" value="1" id="holidayRecurring">
|
||||||
|
<label class="form-check-label small text-secondary" for="holidayRecurring">Recurs annually</label>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-sm btn-primary fw-bold px-3">Add</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<!-- Holidays List -->
|
||||||
|
<h6 class="fw-bold border-bottom pb-2 mb-3 text-secondary" style="font-size: 0.85rem;">Current Holidays</h6>
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-hover table-sm align-middle">
|
||||||
|
<tbody id="holidaysListBody">
|
||||||
|
<!-- Loaded via AJAX -->
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@endpush
|
@endpush
|
||||||
|
|
||||||
@push('scripts')
|
@push('scripts')
|
||||||
@@ -228,6 +287,112 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
// -- HOLIDAYS OFFCANVAS LOGIC --
|
||||||
|
const holidaysOffcanvas = new bootstrap.Offcanvas(document.getElementById('holidaysOffcanvas'));
|
||||||
|
let currentHolidayLocationId = null;
|
||||||
|
let currentCountryCode = null;
|
||||||
|
|
||||||
|
// 1. Open Offcanvas & Load Data
|
||||||
|
$('.btn-manage-holidays').on('click', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
currentHolidayLocationId = $(this).data('id');
|
||||||
|
currentCountryCode = $(this).data('country-code');
|
||||||
|
console.log(currentHolidayLocationId);
|
||||||
|
|
||||||
|
$('#holidaysLocationName').text($(this).data('location'));
|
||||||
|
$('#holiday_location_id').val(currentHolidayLocationId);
|
||||||
|
|
||||||
|
loadHolidays();
|
||||||
|
holidaysOffcanvas.show();
|
||||||
|
});
|
||||||
|
|
||||||
|
// 2. Fetch Data via AJAX
|
||||||
|
function loadHolidays() {
|
||||||
|
$('#holidaysListBody').html('<tr><td colspan="3" class="text-center py-4"><span class="spinner-border spinner-border-sm text-primary"></span></td></tr>');
|
||||||
|
|
||||||
|
// Ensure you have a route set up in web.php like: Route::get('/offices/{id}/holidays', [OfficeController::class, 'getHolidays']);
|
||||||
|
$.get("{{ url('offices') }}/" + currentHolidayLocationId + "/holidays", function(holidays) {
|
||||||
|
let html = '';
|
||||||
|
if (holidays.length === 0) {
|
||||||
|
html = '<tr><td colspan="3" class="text-center text-secondary py-3 small">No holidays added yet.</td></tr>';
|
||||||
|
} else {
|
||||||
|
holidays.forEach(h => {
|
||||||
|
let dateObj = new Date(h.holiday_date);
|
||||||
|
let formattedDate = dateObj.toLocaleDateString('en-GB', { day: 'numeric', month: 'short', year: 'numeric' });
|
||||||
|
let recurringBadge = h.is_recurring ? '<span class="badge bg-info bg-opacity-10 text-info" style="font-size: 0.65rem;">Recurring</span>' : '';
|
||||||
|
|
||||||
|
html += `
|
||||||
|
<tr>
|
||||||
|
<td class="fw-medium text-dark" style="font-size: 0.85rem;">${formattedDate}</td>
|
||||||
|
<td style="font-size: 0.85rem;">${h.name} ${recurringBadge}</td>
|
||||||
|
<td class="text-end">
|
||||||
|
<button class="btn btn-sm text-danger btn-delete-holiday p-1" data-id="${h.id}"><i class="bi bi-x-circle"></i></button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
`;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
$('#holidaysListBody').html(html);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Add Custom Holiday
|
||||||
|
$('#addHolidayForm').on('submit', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
let $btn = $(this).find('button[type="submit"]');
|
||||||
|
$btn.prop('disabled', true).html('<i class="spinner-border spinner-border-sm"></i>');
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "{{ url('holidays') }}", // Adjust to your store route
|
||||||
|
type: 'POST',
|
||||||
|
data: $(this).serialize() + '&_token={{ csrf_token() }}',
|
||||||
|
success: function() {
|
||||||
|
$('#addHolidayForm')[0].reset();
|
||||||
|
loadHolidays();
|
||||||
|
},
|
||||||
|
complete: function() { $btn.prop('disabled', false).text('Add'); }
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// 4. Delete Holiday
|
||||||
|
$(document).on('click', '.btn-delete-holiday', function() {
|
||||||
|
let id = $(this).data('id');
|
||||||
|
if(confirm('Remove this holiday?')) {
|
||||||
|
$.ajax({
|
||||||
|
url: "{{ url('holidays') }}/" + id,
|
||||||
|
type: 'DELETE',
|
||||||
|
data: { _token: '{{ csrf_token() }}' },
|
||||||
|
success: function() { loadHolidays(); }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 5. Auto-Fetch API Holidays
|
||||||
|
$('#btnFetchApiHolidays').on('click', function() {
|
||||||
|
let $btn = $(this);
|
||||||
|
let originalText = $btn.html();
|
||||||
|
$btn.prop('disabled', true).html('<i class="spinner-border spinner-border-sm"></i>');
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "{{ url('offices') }}/" + currentHolidayLocationId + "/holidays/import",
|
||||||
|
type: 'POST',
|
||||||
|
data: { _token: '{{ csrf_token() }}', year: new Date().getFullYear(), country_code: currentCountryCode },
|
||||||
|
success: function(res) {
|
||||||
|
Swal.fire({ icon: 'success', title: 'Imported!', text: res.message, timer: 2000, showConfirmButton: false });
|
||||||
|
loadHolidays();
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
Swal.fire('Error', 'Ensure the location has a valid ISO Country Code (e.g., GH).', 'error');
|
||||||
|
},
|
||||||
|
complete: function() { $btn.prop('disabled', false).html(originalText); }
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@endpush
|
@endpush
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
216
resources/views/reports/index.blade.php
Normal file
216
resources/views/reports/index.blade.php
Normal file
@@ -0,0 +1,216 @@
|
|||||||
|
@extends('layouts.masterbeta')
|
||||||
|
|
||||||
|
@section('title', 'Click ERP - My Daily Reports')
|
||||||
|
|
||||||
|
@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;">Daily Reports</span>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||||
|
<div>
|
||||||
|
<h4 class="fw-bold mb-1">My Daily Reports</h4>
|
||||||
|
<p class="text-secondary mb-0" style="font-size: 0.9rem;">Submit and track your daily activity and progress.</p>
|
||||||
|
</div>
|
||||||
|
<button class="btn text-white fw-bold d-flex align-items-center" style="background-color: #5c4df0; border-radius: 8px;" data-bs-toggle="modal" data-bs-target="#submitReportModal">
|
||||||
|
<i class="bi bi-plus-lg me-2"></i> Submit Report
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="content-card shadow-sm bg-white rounded-3 overflow-hidden">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-hover align-middle mb-0">
|
||||||
|
<thead class="table-light text-secondary" style="font-size: 0.85rem;">
|
||||||
|
<tr>
|
||||||
|
<th class="ps-4">Report Date</th>
|
||||||
|
<th>Content Preview</th>
|
||||||
|
<th>Submitted At</th>
|
||||||
|
<th class="text-end pe-4">Action</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@forelse($reports as $report)
|
||||||
|
<tr>
|
||||||
|
<td class="ps-4 fw-medium text-dark">
|
||||||
|
<i class="bi bi-calendar-check text-primary me-2"></i>
|
||||||
|
{{ \Carbon\Carbon::parse($report->report_date)->format('D, d M Y') }}
|
||||||
|
</td>
|
||||||
|
<td class="text-secondary" style="max-width: 400px; font-size: 0.9rem;">
|
||||||
|
{{ Str::limit(strip_tags($report->content), 80) }}
|
||||||
|
</td>
|
||||||
|
<td class="text-secondary" style="font-size: 0.85rem;">
|
||||||
|
<i class="bi bi-clock me-1"></i> {{ $report->created_at->format('d M Y, H:i') }}
|
||||||
|
</td>
|
||||||
|
<td class="text-end pe-4">
|
||||||
|
<button class="btn btn-sm btn-light text-primary btn-view-report"
|
||||||
|
data-date="{{ \Carbon\Carbon::parse($report->report_date)->format('D, d M Y') }}"
|
||||||
|
data-content="{{ htmlspecialchars($report->content) }}">
|
||||||
|
<i class="bi bi-eye"></i> View
|
||||||
|
</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@empty
|
||||||
|
<tr>
|
||||||
|
<td colspan="4" class="text-center py-5 text-secondary">
|
||||||
|
<i class="bi bi-journal-x fs-1 text-muted mb-2 d-block"></i>
|
||||||
|
No reports submitted yet.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforelse
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
@if($reports->hasPages())
|
||||||
|
<div class="card-footer bg-white border-top p-3 d-flex justify-content-center">
|
||||||
|
{{ $reports->links('pagination::bootstrap-5') }}
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@push('modals')
|
||||||
|
<!-- SUBMIT REPORT MODAL -->
|
||||||
|
<div class="modal fade" id="submitReportModal" tabindex="-1" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-dialog-centered modal-lg">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header bg-light border-bottom-0">
|
||||||
|
<h5 class="modal-title fw-bold">Submit Daily Report</h5>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form id="submitReportForm">
|
||||||
|
@csrf
|
||||||
|
<div class="modal-body p-4">
|
||||||
|
<!-- <div id="reportModalAlert"></div> -->
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label text-secondary fw-semibold small">Report Date *</label>
|
||||||
|
<input type="date" class="form-control" name="report_date" id="report_date" required max="{{ now()->format('Y-m-d') }}" value="{{ now()->format('Y-m-d') }}">
|
||||||
|
<div class="form-text text-muted" style="font-size: 0.75rem;">Standard submission window is 48 hours from the report date.</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label text-secondary fw-semibold small">Activities & Progress *</label>
|
||||||
|
<textarea class="form-control" name="content" id="report_content" rows="8" required placeholder="Detail your tasks, achievements, and blockers for the day..."></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer bg-light border-top-0">
|
||||||
|
<button type="button" class="btn btn-outline-secondary btn-sm" data-bs-dismiss="modal">Cancel</button>
|
||||||
|
<button type="submit" id="btnSaveReport" class="btn text-white btn-sm fw-bold px-4" style="background-color: #5c4df0;">
|
||||||
|
Submit Report
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- VIEW REPORT MODAL -->
|
||||||
|
<div class="modal fade" id="viewReportModal" tabindex="-1" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-dialog-centered modal-lg">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header bg-light border-bottom-0">
|
||||||
|
<h5 class="modal-title fw-bold">Report Details: <span id="viewReportDate" class="text-primary"></span></h5>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body p-4">
|
||||||
|
<div class="bg-light p-3 rounded border" style="white-space: pre-wrap;" id="viewReportContent"></div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer border-top-0">
|
||||||
|
<button type="button" class="btn btn-secondary btn-sm" data-bs-dismiss="modal">Close</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endpush
|
||||||
|
|
||||||
|
@push('scripts')
|
||||||
|
<script>
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('#submitReportForm').on('submit', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
let $form = $(this);
|
||||||
|
let $submitBtn = $('#btnSaveReport');
|
||||||
|
let originalText = $submitBtn.html();
|
||||||
|
|
||||||
|
$submitBtn.html('<span class="spinner-border spinner-border-sm me-2"></span>Sending...').prop('disabled', true);
|
||||||
|
|
||||||
|
// Clear previous validation errors
|
||||||
|
$form.find('.is-invalid').removeClass('is-invalid');
|
||||||
|
$form.find('.invalid-feedback').remove();
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "{{ url('reports') }}",
|
||||||
|
type: 'POST',
|
||||||
|
data: $form.serialize(),
|
||||||
|
success: function(response) {
|
||||||
|
if(response.success) {
|
||||||
|
$('#submitReportModal').modal('hide');
|
||||||
|
Swal.fire({
|
||||||
|
icon: 'success',
|
||||||
|
title: 'Report Submitted!',
|
||||||
|
text: response.message,
|
||||||
|
showConfirmButton: false,
|
||||||
|
timer: 1500
|
||||||
|
}).then(() => location.reload());
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function(xhr) {
|
||||||
|
if (xhr.status === 422) {
|
||||||
|
let errors = xhr.responseJSON.errors;
|
||||||
|
|
||||||
|
// If the 48-hour validation fails, trigger a SweetAlert warning
|
||||||
|
if (errors.report_date && errors.report_date[0].includes('48-hour')) {
|
||||||
|
$('#submitReportModal').modal('hide');
|
||||||
|
Swal.fire({
|
||||||
|
icon: 'warning',
|
||||||
|
title: 'Submission Locked',
|
||||||
|
text: errors.report_date[0],
|
||||||
|
confirmButtonColor: '#5c4df0'
|
||||||
|
}).then(() => $('#submitReportModal').modal('show')); // reopen if they dismiss
|
||||||
|
} else {
|
||||||
|
// For standard field validation, show inline text errors
|
||||||
|
$.each(errors, function(key, value) {
|
||||||
|
let $input = $form.find('[name="' + key + '"]');
|
||||||
|
if ($input.length) {
|
||||||
|
$input.addClass('is-invalid');
|
||||||
|
$input.parent().append('<div class="invalid-feedback d-block fw-medium">' + value[0] + '</div>');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Generic server errors
|
||||||
|
Swal.fire({
|
||||||
|
icon: 'error',
|
||||||
|
title: 'Server Error',
|
||||||
|
text: 'An unexpected error occurred. Please try again.',
|
||||||
|
confirmButtonColor: '#5c4df0'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
complete: function() {
|
||||||
|
$submitBtn.html(originalText).prop('disabled', false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// View Report Modal Population
|
||||||
|
$('.btn-view-report').on('click', function() {
|
||||||
|
$('#viewReportDate').text($(this).data('date'));
|
||||||
|
$('#viewReportContent').text($(this).data('content'));
|
||||||
|
new bootstrap.Modal(document.getElementById('viewReportModal')).show();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Reset modal on close
|
||||||
|
$('#submitReportModal').on('hidden.bs.modal', function () {
|
||||||
|
$('#submitReportForm')[0].reset();
|
||||||
|
$('#report_date').val("{{ now()->format('Y-m-d') }}");
|
||||||
|
$('#submitReportForm').find('.is-invalid').removeClass('is-invalid');
|
||||||
|
$('#submitReportForm').find('.invalid-feedback').remove();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@endpush
|
||||||
@@ -33,9 +33,16 @@
|
|||||||
<p class="text-secondary mb-0" style="font-size: 0.9rem;">Manage employee profiles, department roles, and system access.</p>
|
<p class="text-secondary mb-0" style="font-size: 0.9rem;">Manage employee profiles, department roles, and system access.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="d-flex gap-2">
|
<div class="d-flex gap-2">
|
||||||
|
@if(strtolower(Auth::user()->department->name) == 'directors')
|
||||||
|
<button class="btn btn-warning btn-sm fw-bold" data-bs-toggle="modal" data-bs-target="#overrideModal">
|
||||||
|
<i class="bi bi-unlock-fill me-1"></i> Grant Report Override
|
||||||
|
</button>
|
||||||
|
@endif
|
||||||
|
@if(in_array(strtolower(Auth::user()->department->name) , ['directors', 'human resource']))
|
||||||
<button class="btn text-white fw-bold d-flex align-items-center" style="background-color: #5c4df0; border-radius: 8px;" id="btnOpenStaffModal">
|
<button class="btn text-white fw-bold d-flex align-items-center" style="background-color: #5c4df0; border-radius: 8px;" id="btnOpenStaffModal">
|
||||||
<i class="bi bi-person-plus me-2"></i> Add Employee
|
<i class="bi bi-person-plus me-2"></i> Add Employee
|
||||||
</button>
|
</button>
|
||||||
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -340,6 +347,65 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@push('modals')
|
||||||
|
|
||||||
|
|
||||||
|
<!-- OVERRIDE MODAL) -->
|
||||||
|
<div class="modal fade" id="overrideModal" tabindex="-1" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-dialog-centered">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header bg-light border-bottom-0">
|
||||||
|
<h5 class="modal-title fw-bold">Grant Report Override</h5>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form id="overrideForm">
|
||||||
|
@csrf
|
||||||
|
<div class="modal-body p-4">
|
||||||
|
<div class="alert alert-warning d-flex align-items-center p-3 mb-4" style="font-size: 0.85rem;">
|
||||||
|
<i class="bi bi-exclamation-triangle-fill me-2 fs-5 text-warning"></i>
|
||||||
|
<div>Temporarily unlock the submission window for a staff member to file a past daily report.</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="overrideModalAlert"></div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label text-secondary fw-semibold small">Staff Member *</label>
|
||||||
|
<select class="form-select select2-staff" id="override_user_id" name="user_id" required style="width: 100%;">
|
||||||
|
<option value=""></option>
|
||||||
|
<!-- Assuming you pass $staffMembers from the controller -->
|
||||||
|
@foreach($allstaffMembers as $staff)
|
||||||
|
<option value="{{ $staff->id }}">{{ $staff->name }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row g-3">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<label class="form-label text-secondary fw-semibold small">Locked Report Date *</label>
|
||||||
|
<input type="date" class="form-control" name="report_date" required max="{{ now()->format('Y-m-d') }}">
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<label class="form-label text-secondary fw-semibold small">Validity Window</label>
|
||||||
|
<div class="input-group">
|
||||||
|
<input type="number" class="form-control" name="hours_valid" value="24" min="1" max="72">
|
||||||
|
<span class="input-group-text bg-light text-secondary">Hours</span>
|
||||||
|
</div>
|
||||||
|
<div class="form-text text-muted" style="font-size: 0.75rem;">Time given to submit before locking again.</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer bg-light border-top-0">
|
||||||
|
<button type="button" class="btn btn-outline-secondary btn-sm" data-bs-dismiss="modal">Cancel</button>
|
||||||
|
<button type="submit" id="btnSubmitOverride" class="btn text-white btn-sm fw-bold px-4" style="background-color: #5c4df0;">
|
||||||
|
Grant Access
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endpush
|
||||||
@endpush
|
@endpush
|
||||||
|
|
||||||
@push('scripts')
|
@push('scripts')
|
||||||
@@ -549,6 +615,85 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// OVERRIDE
|
||||||
|
$(document).ready(function() {
|
||||||
|
|
||||||
|
// Initialize Select2 for the staff dropdown
|
||||||
|
$('.select2-staff').select2({
|
||||||
|
theme: 'bootstrap-5',
|
||||||
|
dropdownParent: $('#overrideModal'),
|
||||||
|
placeholder: 'Search staff member...',
|
||||||
|
allowClear: true
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#overrideForm').on('submit', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
let $form = $(this);
|
||||||
|
let $submitBtn = $('#btnSubmitOverride');
|
||||||
|
let originalText = $submitBtn.html();
|
||||||
|
let $alertBox = $('#overrideModalAlert');
|
||||||
|
|
||||||
|
$submitBtn.html('<span class="spinner-border spinner-border-sm me-2"></span>Processing...').prop('disabled', true);
|
||||||
|
$alertBox.html('');
|
||||||
|
$form.find('.is-invalid').removeClass('is-invalid');
|
||||||
|
$form.find('.invalid-feedback').remove();
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: base_url + '/overrides', // Ensure you mapped this route in web.php to ReportOverrideController@store
|
||||||
|
type: 'POST',
|
||||||
|
data: $form.serialize(),
|
||||||
|
success: function(response) {
|
||||||
|
if(response.success) {
|
||||||
|
$alertBox.html(`
|
||||||
|
<div class="alert alert-success d-flex align-items-center p-3" role="alert">
|
||||||
|
<i class="bi bi-check-circle-fill me-2 fs-5 text-success"></i>
|
||||||
|
<div style="font-size: 0.85rem;">${response.message}</div>
|
||||||
|
</div>
|
||||||
|
`);
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
$('#overrideModal').modal('hide');
|
||||||
|
}, 1500);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function(xhr) {
|
||||||
|
if (xhr.status === 422) {
|
||||||
|
let errors = xhr.responseJSON.errors;
|
||||||
|
$.each(errors, function(key, value) {
|
||||||
|
let $input = $form.find('[name="' + key + '"]');
|
||||||
|
if ($input.length) {
|
||||||
|
$input.addClass('is-invalid');
|
||||||
|
$input.parent().append('<div class="invalid-feedback d-block fw-medium" style="font-size: 0.75rem;">' + value[0] + '</div>');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$alertBox.html(`
|
||||||
|
<div class="alert alert-danger d-flex align-items-center p-3" role="alert">
|
||||||
|
<i class="bi bi-x-circle-fill me-2 fs-5 text-danger"></i>
|
||||||
|
<div style="font-size: 0.85rem;">Server error. Please try again.</div>
|
||||||
|
</div>
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
complete: function() {
|
||||||
|
$submitBtn.html(originalText).prop('disabled', false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Clean up modal on close
|
||||||
|
$('#overrideModal').on('hidden.bs.modal', function () {
|
||||||
|
$('#overrideForm')[0].reset();
|
||||||
|
$('#override_user_id').val(null).trigger('change');
|
||||||
|
$('#overrideModalAlert').html('');
|
||||||
|
$('#overrideForm').find('.is-invalid').removeClass('is-invalid');
|
||||||
|
$('#overrideForm').find('.invalid-feedback').remove();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
@endpush
|
@endpush
|
||||||
@@ -117,5 +117,24 @@ Route::middleware(['auth'])->group(function () {
|
|||||||
Route::get('/api/countries', [App\Http\Controllers\HelperController::class, 'getCountriesJson']);
|
Route::get('/api/countries', [App\Http\Controllers\HelperController::class, 'getCountriesJson']);
|
||||||
|
|
||||||
|
|
||||||
|
// Staff Daily Reports
|
||||||
|
Route::get('/reports', [App\Http\Controllers\DailyReportController::class, 'index'])->name('reports.index');
|
||||||
|
Route::post('/reports', [App\Http\Controllers\DailyReportController::class, 'store'])->name('reports.store');
|
||||||
|
|
||||||
|
// Management Report Overrides
|
||||||
|
Route::post('/overrides', [App\Http\Controllers\ReportOverrideController::class, 'store'])->name('overrides.store');
|
||||||
|
|
||||||
|
|
||||||
|
// Fetch holidays for a specific office
|
||||||
|
Route::get('offices/{office}/holidays', [App\Http\Controllers\PublicHolidaysController::class, 'index']);
|
||||||
|
|
||||||
|
// Import holidays from the Nager.Date API
|
||||||
|
Route::post('offices/{office}/holidays/import', [App\Http\Controllers\PublicHolidaysController::class, 'importFromApi']);
|
||||||
|
|
||||||
|
// Add a manual/custom holiday
|
||||||
|
Route::post('holidays', [App\Http\Controllers\PublicHolidaysController::class, 'store']);
|
||||||
|
|
||||||
|
// Delete a holiday
|
||||||
|
Route::delete('holidays/{holiday}', [App\Http\Controllers\PublicHolidaysController::class, 'destroy']);
|
||||||
Route::post('/logout', [App\Http\Controllers\AuthController::class, 'logout'])->name('logout');
|
Route::post('/logout', [App\Http\Controllers\AuthController::class, 'logout'])->name('logout');
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user