diff --git a/app/Http/Controllers/CommentsController.php b/app/Http/Controllers/CommentsController.php deleted file mode 100644 index 3d854dc..0000000 --- a/app/Http/Controllers/CommentsController.php +++ /dev/null @@ -1,63 +0,0 @@ -id; - $result = Models\Comment::with('projectStatus') - ->where('assignee_id', $user_id) - ->orderBy('project_id', 'DESC') - ->get(); - $data = [ - 'page_title' => 'Projects Status List', - 'project_statuses' => $result - ]; - return view('comments.index', $data); - } - public function add_comment($id){ - $result = Models\ProjectStatus::with('comments', 'project')->where('id', $id)->firstOrFail(); - // dd($result); - $data = [ - 'page_title' => 'Projects Status Comment', - 'project_arr' => $result - ]; - // dump($data); - return view('comments.create', $data); - } - public function store(Request $request) { - // Save a new post - $this->validate($request, [ - 'description' => 'required', - 'status' => 'required', - 'project_id' => 'required', - 'assignee_id' => 'required' - ]); - $project_status_arr = $request->except('_token'); - $result = Models\ProjectStatus::create($project_status_arr); - Session::flash('success_message', 'Project status added successfully!'); - - return redirect(url('project-status')); - } - - public function show($id) { - // Show a specific post - } - - public function edit($id) { - // Show form to edit a post - } - - public function update(Request $request, $id) { - // Update a specific post - return redirect(url('project-status')); - } - - public function destroy($id) { - // Delete a specific post - } -} diff --git a/app/Http/Controllers/DailyReportController.php b/app/Http/Controllers/DailyReportController.php index b251ecc..15d3e3b 100644 --- a/app/Http/Controllers/DailyReportController.php +++ b/app/Http/Controllers/DailyReportController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers; use App\Models\DailyReport; use App\Models\ReportOverride; +use App\Models\StaffMember; use App\Http\Requests\StoreDailyReportRequest; use Illuminate\Support\Facades\Mail; use App\Mail\DailyReportSubmitted; @@ -18,6 +19,7 @@ class DailyReportController extends Controller return view('reports.index', compact('reports')); } + public function store(StoreDailyReportRequest $request) { $report = DailyReport::create([ @@ -26,20 +28,25 @@ class DailyReportController extends Controller 'content' => $request->content, ]); - // If they used an override, optionally delete or mark it as used so it can't be reused + // Reward the staff member with points (e.g., 10 points per report) + $staff = auth()->user(); + $staff->increment('report_points', 10); + ReportOverride::where('user_id', auth()->id()) ->where('report_date', $request->report_date) ->delete(); - $managementEmails = ['kwesi@click-mobile.com']; - // $managementEmails = User::whereIn('group', ['directors']) - // ->pluck('email') - // ->toArray(); - Mail::to($managementEmails)->send(new DailyReportSubmitted($report, auth()->user())); + /// modify this to make it dynamic + $managementEmails = StaffMember::with('department')->whereIn('department_id', [5])->pluck('email')->toArray(); + + if (env('APP_ENV') == 'production') { + Mail::to($managementEmails)->send(new DailyReportSubmitted($report, auth()->user())); + } return response()->json([ 'success' => true, - 'message' => 'Daily report submitted successfully.' + 'message' => 'Daily report submitted successfully! You earned 10 points.', + 'new_points_total' => $staff->report_points // Optional: send back to update UI dynamically ]); } } \ No newline at end of file diff --git a/app/Http/Controllers/LeaveRequestController.php b/app/Http/Controllers/LeaveRequestController.php index db1f7cb..cd177e5 100644 --- a/app/Http/Controllers/LeaveRequestController.php +++ b/app/Http/Controllers/LeaveRequestController.php @@ -16,7 +16,7 @@ class LeaveRequestController extends Controller { $query = LeaveRequest::with('staff'); - // Search by Staff Name + if ($request->filled('search')) { $search = $request->search; $query->whereHas('staff', function($q) use ($search) { @@ -24,18 +24,17 @@ class LeaveRequestController extends Controller }); } - // Filter by Status if ($request->filled('status')) { $query->where('status', $request->status); - } else { - // Default to showing pending requests first if no filter is applied + } + else { + $query->orderByRaw("FIELD(status, 'PENDING', 'APPROVED', 'REJECTED')"); } $leaveRequests = $query->orderBy('created_at', 'desc')->paginate(15); $leaveRequests->appends($request->query()); - // KPIs for HR $pendingCount = LeaveRequest::where('status', 'PENDING')->count(); $approvedThisMonth = LeaveRequest::where('status', 'APPROVED') ->whereMonth('start_date', Carbon::now()->month) @@ -52,11 +51,8 @@ class LeaveRequestController extends Controller } public function myLeave() { - // Find the staff profile of the currently logged-in user - // Adjust this logic if you link Users to StaffMembers differently (e.g., via a staff_id foreign key) - $staff = StaffMember::where('email', auth()->user()->email)->firstOrFail(); - // Fetch their leave history, latest first + $staff = StaffMember::where('email', auth()->user()->email)->firstOrFail(); $leaveRequests = LeaveRequest::where('staff_member_id', $staff->id) ->orderBy('created_at', 'desc') ->paginate(10); @@ -82,7 +78,6 @@ class LeaveRequestController extends Controller $start = Carbon::parse($validated['start_date']); $end = Carbon::parse($validated['end_date']); - // Calculate total days excluding weekends $totalDays = $start->diffInDaysFiltered(function (Carbon $date) { return !$date->isWeekend(); }, $end) + 1; // +1 to include both the start and end day @@ -107,7 +102,7 @@ class LeaveRequestController extends Controller } - public function updateStatus(Request $request, $id) + public function updateStatusOld(Request $request, $id) { $leaveRequest = LeaveRequest::findOrFail($id); @@ -140,4 +135,42 @@ class LeaveRequestController extends Controller return response()->json(['success' => true, 'message' => 'Leave status updated successfully!']); } -} \ No newline at end of file + public function updateStatus(Request $request, $id) + { + $leaveRequest = LeaveRequest::findOrFail($id); + + $incomingStatus = strtoupper($request->status); + $request->merge(['status' => $incomingStatus]); + + $validated = $request->validate([ + 'status' => 'required|in:APPROVED,REJECTED', + 'admin_remarks' => 'nullable|string', + ]); + + $currentStatus = strtoupper($leaveRequest->status); + $newStatus = $validated['status']; + + $staff = $leaveRequest->staff; + + if ($staff && strtolower($leaveRequest->leave_type) === 'annual') { // only annual leave affects leave balance + + if ($newStatus === 'APPROVED' && $currentStatus !== 'APPROVED') { + $staff->annual_leave_balance -= $leaveRequest->total_days; + $staff->save(); + } + + if ($newStatus === 'REJECTED' && $currentStatus === 'APPROVED') { + $staff->annual_leave_balance += $leaveRequest->total_days; + $staff->save(); + } + } + + $leaveRequest->update([ + 'status' => $newStatus, + 'admin_remarks' => $validated['admin_remarks'] ?? null, + 'approved_by' => auth()->id(), + ]); + + return response()->json(['success' => true, 'message' => 'Leave status updated successfully!']); + } +} diff --git a/app/Http/Controllers/ManagementDashboardController.php b/app/Http/Controllers/ManagementDashboardController.php index 02688d5..c60d17f 100644 --- a/app/Http/Controllers/ManagementDashboardController.php +++ b/app/Http/Controllers/ManagementDashboardController.php @@ -11,25 +11,24 @@ class ManagementDashboardController extends Controller { public function index(Request $request) { - // 1. Fetch Pending Leaves (Adjust status/model names to match your schema) $pendingLeaves = LeaveRequest::with('staff') ->where('status', 'Pending') ->orderBy('created_at', 'asc') ->get(); - $startDate = $request->input('start_date', Carbon::now()->startOfMonth()->format('Y-m-d')); $endDate = $request->input('end_date', Carbon::now()->endOfMonth()->format('Y-m-d')); - $staffReports = StaffMember::withCount(['dailyReports' => function ($query) use ($startDate, $endDate) { - $query->whereBetween('report_date', [$startDate, $endDate]); - }]) - ->orderBy('name') - ->get(); + + $staffReports = StaffMember::where('department_id', '!=', 5) + ->withCount(['dailyReports' => function ($query) use ($startDate, $endDate) { + $query->whereBetween('report_date', [$startDate, $endDate]); + }]) + ->orderBy('name') + ->get(); return view('management.index', compact('pendingLeaves', 'staffReports', 'startDate', 'endDate')); } - public function updateLeaveStatus(Request $request, $id) { $request->validate(['status' => 'required|in:Approved,Rejected']); diff --git a/app/Http/Controllers/NetworkOperatorsController.php b/app/Http/Controllers/NetworkOperatorsController.php index 1dbe6cb..57be150 100644 --- a/app/Http/Controllers/NetworkOperatorsController.php +++ b/app/Http/Controllers/NetworkOperatorsController.php @@ -79,8 +79,9 @@ class NetworkOperatorsController extends Controller $request->validate([ 'name' => 'required|string|max:200', 'country' => 'required|string', - 'contract_auto_renew' => 'required|boolean', - 'next_renewal_date' => 'nullable|required_if:contract_auto_renew,0|date', + 'connection_status' => 'required|string', + // 'contract_auto_renew' => 'required|boolean', + // 'next_renewal_date' => 'nullable|required_if:contract_auto_renew,0|date', ]); $operator->update([ @@ -109,7 +110,7 @@ class NetworkOperatorsController extends Controller return response()->json(['message' => 'MNO Partner updated successfully!']); } - // Fetch single record JSON for editing modal + public function getJson($id) { $operator = NetworkOperator::findOrFail($id); @@ -118,8 +119,6 @@ class NetworkOperatorsController extends Controller public function show($id) { $operator = NetworkOperator::findOrFail($id); - - // Fetch all services for the dropdown $allServices = \App\Models\Service::orderBy('name')->get(); $staffMembers = \App\Models\StaffMember::orderBy('name')->get(); @@ -134,13 +133,9 @@ class NetworkOperatorsController extends Controller 'required', 'string', function ($attribute, $value, $fail) { - // 1. Check if valid IP Address (IPv4 or IPv6) + $isIp = filter_var($value, FILTER_VALIDATE_IP); - - // 2. Check if valid Domain Name (e.g., smpp.operator.com) - $isDomain = preg_match('/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i', $value); - - // 3. Check if valid CIDR Subnet (e.g., 196.200.15.0/24) + $isDomain = preg_match('/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i', $value); $isSubnet = preg_match('/^([0-9]{1,3}\.){3}[0-9]{1,3}\/([0-9]|[1-2][0-9]|3[0-2])$/', $value); if (!$isIp && !$isDomain && !$isSubnet) { @@ -192,7 +187,7 @@ class NetworkOperatorsController extends Controller \App\Models\MnoNote::create([ 'mno_id' => $operatorId, 'services' => $request->services ?? '', - 'user_id' => auth()->id(), // Automatically assign the logged-in user + 'user_id' => auth()->id(), 'notes_body' => $request->notes_body, ]); diff --git a/database/migrations/2026_11_02_132050_add_report_points_to_staff_members_table.php b/database/migrations/2026_11_02_132050_add_report_points_to_staff_members_table.php new file mode 100644 index 0000000..c2d2b0f --- /dev/null +++ b/database/migrations/2026_11_02_132050_add_report_points_to_staff_members_table.php @@ -0,0 +1,22 @@ +integer('report_points')->default(0)->after('status'); + }); + } + + public function down() + { + Schema::table('staff_members', function (Blueprint $table) { + $table->dropColumn('report_points'); + }); + } +}; \ No newline at end of file diff --git a/info.md b/info.md new file mode 100644 index 0000000..e828284 --- /dev/null +++ b/info.md @@ -0,0 +1,6 @@ +Each team Member should have a profile +Names +Job Description +Each day they should have a template with fixed date to submit report, after 48 hours the write pad locks and can only be opened with my approval. +Each submission carries points which will be reflected on a employee graph - just like the tracker I share. +When the report is submitted, an e-mail sent to me where I can reply from. \ No newline at end of file diff --git a/resources/views/layouts/partials/sidebar.blade.php b/resources/views/layouts/partials/sidebar.blade.php index 33284d9..017b4ec 100644 --- a/resources/views/layouts/partials/sidebar.blade.php +++ b/resources/views/layouts/partials/sidebar.blade.php @@ -20,9 +20,7 @@ Management Hub @endif - - Management Hub - + Clients diff --git a/resources/views/leave/index.blade.php b/resources/views/leave/index.blade.php index 5845b0a..6c3273a 100644 --- a/resources/views/leave/index.blade.php +++ b/resources/views/leave/index.blade.php @@ -137,13 +137,11 @@ @push('scripts')