updated client views and routes

This commit is contained in:
Kwesi Banson Jnr
2026-07-23 21:16:22 +00:00
parent 7b29bb278c
commit 08ded57875
10 changed files with 1685 additions and 188 deletions

View File

@@ -4,19 +4,193 @@ namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\Log;
use Carbon\Carbon;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\DB;
class ClientsController extends Controller
{
public function index()
{
// $clients = Models\Client::get();
public function index(){
$countries = Models\Country::pluck('en_short_name', 'en_short_name');
$service_type = Models\Service::pluck('name', 'name');
$staff_members = Models\StaffMember::pluck('name', 'id');
// dd($staff_members);
$data = [
'page_title' => 'Dashboard',
// 'clients' => $clients
'service_types' => $service_type,
'countries' => $countries,
'staff_members' => $staff_members
];
return view('clients.index', $data);
}
public function show(int $id)
{
$showclient = Models\Client::with([
'service_info',
'country_flag_info',
'auth_user_info',
'short_code_info',
])->findOrFail($id);
$progress_indicators = Models\ClientIndicator::pluck('name', 'name');
$service_type = Models\Service::pluck('name', 'id');
$service_type_names = Models\Service::pluck('name', 'name');
$show_services = Models\ClientCategory::where('client_id', $id)->get();
$country_networks = DB::table('network_operators')
->selectRaw('id, CONCAT(name, " (", country, ")") AS network')
->orderBy('network')
->pluck('network', 'network');
$auth_users = Models\SystemUser::orderBy('name')->pluck('name', 'id');
$networks_raw = [
'AirtelTigo GH',
'MTN GH',
'Airtel MW',
'Airtel Zambia',
'TNM MW',
'Safaricom Kenya',
'Airtel Kenya',
'Telkom Kenya',
'Orange Kenya',
];
$show_notes_query = Models\ClientNote::with(['created_by_info', 'client_info'])
->where('client_id', $id)
->latest();
$show_notes = $show_notes_query->take(20)->get();
$show_notes_highlight = (clone $show_notes_query)
->where('highlight', 'YES')
->take(1)
->get();
$voice_codes = Models\ClientShortCode::where('client_id', $id)
->where('code_type', 'voice')
->get();
$sms_codes = Models\ClientShortCode::where('client_id', $id)
->where('code_type', 'sms')
->get();
$ussd_codes = Models\ClientShortCode::where('client_id', $id)
->where('code_type', 'ussd')
->get();
$recent_payments = Models\ClientPayment::where('client_id', $id)
->latest('id')
->get();
$countries = Models\Country::pluck('en_short_name', 'en_short_name');
$networks = Models\NetworkOps::pluck('name', 'id');
$support_fees = Models\ClientSupportFees::where('client_id', $id)
->latest('id')
->get();
$showdocuments = Models\ClientFile::where('client_id', $id)->get();
$status_bg = match ($showclient->status) {
'Live' => 'info',
'Prospective' => 'warning',
default => 'danger',
};
$progress_status_bg = match (true) {
$showclient->progress_indicator_score >= 70 => 'success',
$showclient->progress_indicator_score >= 50 => 'warning',
default => 'danger',
};
[$renewal_due, $highlight_colour] = $this->getRenewalDue(
$showclient->contract_validity
);
$recurring_arr = [
'NO' => 'NO',
'Monthly' => 'Monthly',
'Quarterly' => 'Quarterly',
'Semiannual' => 'Semiannual',
'Yearly' => 'Yearly',
];
$sender_id_statuses = [
'Pending' => 'Pending',
'Inactive' => 'Inactive',
'Approved' => 'Approved',
];
$change_account_mgr_permission = Config::get('permissions.CHANGE_ACCOUNT_MANAGERS');
// dump($change_account_mgr_permission);
$change_account_mgr_permission = $this->hasAnyAccess([$change_account_mgr_permission]) ? 'YES' : 'NO';
// dd($change_account_mgr_permission);
return view('clients.show', [
'page_title' => 'Client Profile',
'showclient' => $showclient,
'show_services' => $show_services,
'service_type' => $service_type,
'service_type_names' => $service_type_names,
'show_notes' => $show_notes,
'show_notes_highlight' => $show_notes_highlight,
'status_bg' => $status_bg,
'progress_status_bg' => $progress_status_bg,
'voice_codes' => $voice_codes,
'sms_codes' => $sms_codes,
'ussd_codes' => $ussd_codes,
'countries' => $countries,
'networks' => $networks,
'progress_indicators' => $progress_indicators,
'networks_raw' => array_combine($networks_raw, $networks_raw),
'renewal_due' => $renewal_due,
'recent_payments' => $recent_payments,
'highlight_colour' => $highlight_colour,
'showdocuments' => $showdocuments,
'support_fees' => $support_fees,
'recurring_arr' => $recurring_arr,
'sender_id_statuses' => $sender_id_statuses,
'change_account_mgr_permisson' => $change_account_mgr_permission,
'am_list_arr' => $auth_users,
'country_network_arr' => $country_networks,
'mnos_arr' => ['' => '-- Select Country first --'],
]);
}
private function getRenewalDue(?string $contractValidity): array
{
if (blank($contractValidity)) {
return ['N/A', 'none'];
}
$expiryDate = Carbon::parse($contractValidity)->startOfDay();
$today = now()->startOfDay();
if ($expiryDate->greaterThanOrEqualTo($today)) {
$days = $today->diffInDays($expiryDate);
return match (true) {
$days > 365 => ['In ' . floor($days / 365) . ' year(s)', 'none'],
$days > 31 => ['In ' . floor($days / 31) . ' month(s)', 'none'],
default => ['In ' . $days . ' day(s)', 'none'],
};
}
$days = $expiryDate->diffInDays($today);
return match (true) {
$days > 365 => ['Contract expired ' . floor($days / 365) . ' year(s) ago', 'warning'],
$days > 31 => ['Contract expired ' . floor($days / 31) . ' month(s) ago', 'warning'],
default => ['Contract expired ' . $days . ' day(s) ago', 'warning'],
};
}
public function fetchDataOld(Request $request)
{
$query = Models\Client::query();
@@ -147,4 +321,90 @@ class ClientsController extends Controller
return $pdf->download('clients_export_' . date('Y-m-d_H-i') . '.pdf');
}
public function store(Request $request): JsonResponse|RedirectResponse
{
$request->validate([
'name' => 'required|unique:clients,name',
'email' => 'required|email',
'services' => 'required|array',
'country' => 'required',
'status' => 'required',
'payment_mode' => 'required',
'currency' => 'required',
'company_type' => 'required',
'industry' => 'required',
'account_manager' => 'required',
]);
$onboarding_stages = Models\ClientOnboardingMainStage::orderBy('stage_id')->get();
$client_current_stages = [];
foreach ($onboarding_stages as $value) {
$client_current_stages[$value->stage] = "PENDING";
}
$client_arr = [
'name' => $request->name,
'email' => $request->email,
'country' => $request->country,
'status' => $request->status,
'pay_mode' => $request->payment_mode,
'currency' => $request->currency,
'auth_user_id' => $request->auth_user_id,
'created_by' => Auth::user()->id,
'last_modified_by' => Auth::user()->id,
'progress_indicator_score' => 10,
'progress_indicator' => $onboarding_stages[0]->stage,
'onboarding_progress_stage' => json_encode($client_current_stages),
'notes' => $request->notes,
'services' => json_encode($request->services),
'phone' => $request->phone,
'skype_name' => $request->skype_name,
'linkedin_name' => $request->linkedin_name,
'contact_person' => $request->contact_person,
'company_type' => $request->company_type,
'industry' => $request->industry,
];
$result = Models\Client::create(array_filter($client_arr));
$get_stage_subs_items = Models\ClientOnboardingSubItem::get();
foreach ($get_stage_subs_items as $value) {
Models\ClientOnboardingProgress::create([
'stage_id' => $value->stage_id,
'client_id' => $result->id,
'name' => $value->name,
'status' => 'PENDING'
]);
}
if (in_array('USSD', $request->services)) {
Log::info('ussd client detected');
Models\UssdClientPayment::create([
'client_id' => $result->id,
'last_modified_by_id' => session('current_user.id')
]);
}
Models\UserActivity::create([
'type' => 'staff',
'content' => session('current_user.name') . " added a new client ({$result->name}) successfully!",
'user_id' => session('current_user.id'),
'ip_address' => request()->ip(),
'device' => $request->header('User-Agent')
]);
if ($request->ajax() || $request->wantsJson()) {
return response()->json([
'success' => true,
'message' => 'Client successfully added',
'data' => $result
]);
}
Session::flash('success_message', 'Client successfully added');
return redirect('clients');
}
}

View File

@@ -9,4 +9,19 @@ use Illuminate\Routing\Controller as BaseController;
class Controller extends BaseController
{
use AuthorizesRequests, ValidatesRequests;
public function hasAnyAccess($permissions){
// dump(Config::get('permissions.' ));
$required_permission = array_sum($permissions);
#$system_permissions = Models\Permission::where('status', 'active')->get();
if (session('current_user.permissions') <> '') {
if ((int)session('current_user.permissions') & $required_permission) {
return true;
}
else{
return false;
}
}
return false;
}
}

View File

@@ -0,0 +1,424 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
use Illuminate\View\View;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\Response;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Carbon\Carbon;
use App\Models;
use App\Http\Requests;
use App\Libs\PaperLessNgx;
use App\Jobs\SendNewUssdClientEmail;
use App\Jobs\SendOnboardingCompletedEmailAlert;
use App\Jobs\SendShortCodeListToFinance;
use App\Jobs\SendNewNotesEmailAlert;
use Spatie\Activitylog\Models\Activity;
use Illuminate\Support\Facades\Config;
class ClientsController extends Controller
{
public function index(): View
{
return view('client.index-tabulator', [
'page_title' => 'Clients',
'current_user' => session('current_user')
]);
}
public function indexInactive(): View
{
return view('client.index-inactive', [
'page_title' => 'Inactive Clients',
'current_user' => session('current_user')
]);
}
public function indexStatus($status): View
{
return view('client.index-status', [
'status' => $status,
'page_title' => strtoupper($status) . ' Clients',
'current_user' => session('current_user')
]);
}
public function indexCancelled(): View
{
return view('client.index-prospective', [
'page_title' => 'Prospective Clients',
'current_user' => session('current_user')
]);
}
public function indexDiscussion(): View
{
return view('client.index-prospective', [
'page_title' => 'In Discussion Clients',
'current_user' => session('current_user')
]);
}
public function getClientJson(Request $request): JsonResponse
{
$query = DB::table('clients')
->join('auth_users AS aumngr', 'aumngr.id', '=', 'clients.auth_user_id')
->join('auth_users AS aumodify', 'aumodify.id', '=', 'clients.last_modified_by')
->join('flags AS flags', 'flags.country', '=', 'clients.country')
->select('clients.id', 'clients.name', 'clients.status', 'clients.progress_indicator_score', 'clients.country', 'aumngr.name As accountMgr', 'aumodify.name AS modifiedBy', 'flags.url AS theflag')
->whereNotIn('status', ['inactive', 'Cancelled']);
if ($request->filled('keyword')) {
$keyword = $request->keyword;
$query->where(function ($q) use ($keyword) {
$q->where('clients.name', 'LIKE', "%{$keyword}%")
->orWhere('clients.country', 'LIKE', "%{$keyword}%")
->orWhere('aumngr.name', 'LIKE', "%{$keyword}%")
->orWhere('aumodify.name', 'LIKE', "%{$keyword}%");
});
}
return response()->json($query->orderBy('name', 'ASC')->get());
}
public function getInactiveClientJson(Request $request): JsonResponse
{
$query = DB::table('clients')
->join('auth_users AS aumngr', 'aumngr.id', '=', 'clients.auth_user_id')
->join('auth_users AS aumodify', 'aumodify.id', '=', 'clients.last_modified_by')
->join('flags AS flags', 'flags.country', '=', 'clients.country')
->select('clients.id', 'clients.name', 'clients.status', 'clients.progress_indicator_score', 'clients.country', 'aumngr.name As accountMgr', 'aumodify.name AS modifiedBy', 'flags.url AS theflag')
->whereIn('status', ['inactive', 'Cancelled']);
if ($request->filled('keyword')) {
$keyword = $request->keyword;
$query->where(function ($q) use ($keyword) {
$q->where('clients.name', 'LIKE', "%{$keyword}%")
->orWhere('clients.status', 'LIKE', "%{$keyword}%")
->orWhere('clients.country', 'LIKE', "%{$keyword}%")
->orWhere('aumngr.name', 'LIKE', "%{$keyword}%")
->orWhere('aumodify.name', 'LIKE', "%{$keyword}%")
->orWhere('clients.progress_indicator_score', 'LIKE', "%{$keyword}%");
});
}
return response()->json($query->orderBy('name', 'ASC')->get());
}
public function create(): View
{
return view('client.create', [
'page_title' => 'Create Client',
'countries' => Models\Country::pluck('en_short_name', 'en_short_name'),
'service_type' => Models\Service::pluck('name', 'name'),
'status' => ['Live' => 'Live', 'Inactive' => 'Inactive', 'Prospective' => 'Prospective', 'Cancelled' => 'Cancelled'],
'currency' => Models\Currency::pluck('name', 'name'),
'auth_users' => Models\SystemUser::pluck('name', 'id'),
'payment_type' => ['Prepaid' => 'Prepaid', 'Postpaid' => 'Postpaid'],
'company_types' => ['Aggregator/Supplier' => 'Aggregator/Supplier', 'Enterprise' => 'Enterprise', 'Hybrid' => 'Hybrid'],
'industries' => Models\Industry::orderBy('name', 'ASC')->pluck('name', 'name')
]);
}
public function store(Request $request): RedirectResponse
{
$request->validate([
'name' => 'required|unique:clients,name',
'email' => 'required|email',
'services' => 'required|array',
'country' => 'required',
'status' => 'required',
'payment_mode' => 'required',
'currency' => 'required',
'company_type' => 'required',
'industry' => 'required',
'auth_user_id' => 'required',
]);
$onboarding_stages = Models\ClientOnboardingMainStage::orderBy('stage_id')->get();
$client_current_stages = [];
foreach ($onboarding_stages as $value) {
$client_current_stages[$value->stage] = "PENDING";
}
$client_arr = [
'name' => $request->name,
'email' => $request->email,
'country' => $request->country,
'status' => $request->status,
'pay_mode' => $request->payment_mode,
'currency' => $request->currency,
'auth_user_id' => $request->auth_user_id,
'created_by' => session('current_user.id'),
'last_modified_by' => session('current_user.id'),
'progress_indicator_score' => 10,
'progress_indicator' => $onboarding_stages[0]->stage,
'onboarding_progress_stage' => json_encode($client_current_stages),
'notes' => $request->notes,
'services' => json_encode($request->services),
'phone' => $request->phone,
'skype_name' => $request->skype_name,
'linkedin_name' => $request->linkedin_name,
'contact_person' => $request->contact_person,
'company_type' => $request->company_type,
'industry' => $request->industry,
];
$result = Models\Client::create(array_filter($client_arr)); // Remove nulls automatically
$get_stage_subs_items = Models\ClientOnboardingSubItem::get();
foreach ($get_stage_subs_items as $value) {
Models\ClientOnboardingProgress::create([
'stage_id' => $value->stage_id,
'client_id' => $result->id,
'name' => $value->name,
'status' => 'PENDING'
]);
}
if (in_array('USSD', $request->services)) {
Log::info('ussd client detected');
Models\UssdClientPayment::create([
'client_id' => $result->id,
'last_modified_by_id' => session('current_user.id')
]);
}
Models\UserActivity::create([
'type' => 'staff',
'content' => session('current_user.name') . " added a new client ({$result->name}) successfully!",
'user_id' => session('current_user.id'),
'ip_address' => request()->ip(),
'device' => $request->header('User-Agent')
]);
Session::flash('success_message', 'Client successfully added');
return redirect('clients');
}
public function show($id): View
{
$showclient = Models\Client::with('service_info', 'country_flag_info', 'auth_user_info', 'short_code_info')->findOrFail($id);
$networks_raw = [
'AirtelTigo GH', 'MTN GH', 'Airtel MW', 'Airtel Zambia', 'TNM MW',
'Safaricom Kenya', 'Airtel Kenya', 'Telkom Kenya', 'Orange Kenya'
];
sort($networks_raw);
$renewal_due = 'N/A';
$highlight_colour = 'none';
if (!empty($showclient->contract_validity)) {
$expiry_date = Carbon::parse($showclient->contract_validity);
$current_date = Carbon::today();
$days = $current_date->diffInDays($expiry_date, false); // False allows negative values for past dates
if ($days < 0) {
$highlight_colour = 'warning';
$days_abs = abs($days);
if ($days_abs > 365) $renewal_due = "Contract expired " . floor($days_abs / 365) . " year(s) ago";
elseif ($days_abs > 31) $renewal_due = "Contract expired " . floor($days_abs / 31) . " month(s) ago";
else $renewal_due = "Contract expired {$days_abs} days(s) ago";
} else {
if ($days > 365) $renewal_due = "In " . floor($days / 365) . " year(s)";
elseif ($days > 31) $renewal_due = "In " . floor($days / 31) . " months";
else $renewal_due = "In {$days} day(s)";
}
}
$change_account_mgr_permission = Config::get('permissions.CHANGE_ACCOUNT_MANAGERS');
$has_permission = $this->hasAnyAccess([$change_account_mgr_permission]) ? 'YES' : 'NO';
return view('client.show_accordion', [
'page_title' => 'Client Profile',
'showclient' => $showclient,
'show_services' => Models\ClientCategory::where('client_id', $id)->get(),
'service_type' => Models\Service::pluck('name', 'id'),
'service_type_names' => Models\Service::pluck('name', 'name'),
'show_notes' => Models\ClientNote::with('created_by_info', 'client_info')->where('client_id', $id)->latest()->take(20)->get(),
'show_notes_highlight' => Models\ClientNote::with('created_by_info', 'client_info')->where('client_id', $id)->where('highlight', 'YES')->latest()->take(1)->get(),
'status_bg' => $showclient->status == 'Live' ? 'info' : ($showclient->status == 'Prospective' ? 'warning' : 'danger'),
'progress_status_bg' => $showclient->progress_indicator_score >= 70 ? 'success' : ($showclient->progress_indicator_score >= 50 ? 'warning' : 'danger'),
'voice_codes' => Models\ClientShortCode::where('client_id', $id)->where('code_type', 'voice')->get(),
'sms_codes' => Models\ClientShortCode::where('client_id', $id)->where('code_type', 'sms')->get(),
'ussd_codes' => Models\ClientShortCode::where('client_id', $id)->where('code_type', 'ussd')->get(),
'countries' => Models\Country::pluck('en_short_name', 'en_short_name'),
'networks' => Models\NetworkOps::pluck('name', 'id'),
'progress_indicators' => Models\ClientIndicator::pluck('name', 'name'),
'networks_raw' => array_combine($networks_raw, $networks_raw),
'renewal_due' => $renewal_due,
'recent_payments' => Models\ClientPayment::where('client_id', $id)->latest()->get(),
'highlight_colour' => $highlight_colour,
'showdocuments' => Models\ClientFile::where('client_id', $id)->get(),
'support_fees' => Models\ClientSupportFees::where('client_id', $id)->latest()->get(),
'recurring_arr' => ['NO' => 'NO', 'Monthly' => 'Monthly', 'Quarterly' => 'Quarterly', 'Semiannual' => 'Semiannual', 'Yearly' => 'Yearly'],
'change_account_mgr_permisson' => $has_permission,
'am_list_arr' => Models\SystemUser::orderBy('name', 'ASC')->pluck('name', 'id'),
'country_network_arr' => DB::table('network_operators')->selectRaw('id, concat(name, " (", country, ")") AS network')->orderBy('network')->pluck('network', 'network'),
'mnos_arr' => ['' => '-- Select Country first --']
]);
}
public function update(Requests\UpdateClientRequest $request, $id): RedirectResponse
{
$client_update = Models\Client::findOrFail($id);
$paperless = new PaperLessNgx();
if ($client_update->progress_indicator != 'COMPLETED') {
$current_pending_stage_details = Models\ClientOnboardingMainStage::where('stage', $request->current_pending_stage)->first();
$get_stage_subs_items = Models\ClientOnboardingSubItem::where('stage_id', $current_pending_stage_details->stage_id)->get();
if ($request->onboarding_sub_items_progress) {
foreach ($request->onboarding_sub_items_progress as $value) {
Models\ClientOnboardingProgress::updateOrCreate(
['stage_id' => $current_pending_stage_details->stage_id, 'client_id' => $id, 'name' => $value],
['status' => 'COMPLETED']
);
}
}
$get_stage_onboarding_status = Models\ClientOnboardingProgress::where('client_id', $id)
->where('stage_id', $current_pending_stage_details->stage_id)
->where('status', 'COMPLETED')
->get();
$onboarding_progress_stage = json_decode($client_update->onboarding_progress_stage, true);
if (count($get_stage_subs_items) == count($get_stage_onboarding_status)) {
$onboarding_progress_stage[$current_pending_stage_details->stage] = 'COMPLETED';
}
$pending_stage = Arr::where($onboarding_progress_stage, fn($value) => $value == "PENDING");
if (!empty($pending_stage)) {
$client_update->progress_indicator = array_key_first($pending_stage);
} else {
$client_update->progress_indicator = 'COMPLETED';
dispatch(new SendOnboardingCompletedEmailAlert(Models\Client::with('auth_user_info')->find($id)));
}
}
// File handling logic encapsulated safely
$fileFields = [
'document_one' => 'document_one_name',
'document_two' => 'document_two_name',
'document_three' => 'document_three_name',
'other_document' => 'other_document_name'
];
foreach ($fileFields as $fileInput => $nameInput) {
if ($request->hasFile($fileInput) && $request->file($fileInput)->isValid() && $request->filled($nameInput)) {
$filename = "erp_" . time() . Str::random(4) . "." . $request->file($fileInput)->extension();
$request->file($fileInput)->storeAs('client_files', $filename, 'public');
$document_name = $fileInput === 'other_document' && !$request->filled($nameInput)
? 'Other Document'
: $request->input($nameInput);
Models\ClientFile::updateOrCreate(
['client_id' => $id, 'name' => $document_name],
[
'file_path' => $filename,
'file_extension' => $request->file($fileInput)->extension(),
'file_reff' => time() . uniqid(),
'created_by' => session('current_user.id'),
]
);
}
}
$client_update->name = $request->name;
$client_update->email = $request->email;
$client_update->phone = $request->phone ?? "";
$client_update->contact_person = $request->contact_person;
$client_update->status = $request->status;
$client_update->pay_mode = $request->payment_mode;
$client_update->country = $request->country;
$client_update->currency = $request->currency;
$client_update->notes = $request->notes;
$client_update->industry = $request->industry;
if ($client_update->progress_indicator != 'COMPLETED') {
$client_update->onboarding_progress_stage = json_encode($onboarding_progress_stage);
$progress_breakdown = array_count_values($onboarding_progress_stage);
$indicator_score = Arr::has($progress_breakdown, 'COMPLETED')
? ($progress_breakdown['COMPLETED'] / count($onboarding_progress_stage)) * 100
: 0;
$client_update->progress_indicator_score = number_format($indicator_score);
} else {
$client_update->progress_indicator_score = 100;
}
$client_update->skype_name = $request->skype_name ?? "";
$client_update->linkedin_name = $request->linkedin_name ?? "";
$client_update->smpp_username = $request->smpp_username ?? "";
$client_update->company_type = $request->company_type ?? "";
$client_update->auth_user_id = $request->auth_user_id ?? "";
$client_update->contract_type = $request->contract_type ?? "";
$client_update->contract_validity = $request->contract_validity ?? "";
$client_update->contract_auto_renew = $request->contract_auto_renew ?? "";
$client_update->sender_ids = $request->sender_ids ? json_encode($request->sender_ids) : "";
$client_update->connections = $request->connections ? json_encode($request->connections) : "";
$client_update->services = $request->services ? json_encode($request->services) : "";
$client_update->message_types = $request->message_types ? json_encode($request->message_types) : "";
$client_update->finance_email = $request->finance_email ? json_encode($request->finance_email) : "";
$client_update->support_emails = $request->support_emails ? json_encode($request->support_emails) : "";
$client_update->rate_emails = $request->rate_emails ? json_encode($request->rate_emails) : "";
$client_update->support_phones = $request->support_phones ? json_encode($request->support_phones) : "";
$client_update->support_skype = $request->support_skype ? json_encode($request->support_skype) : "";
if ($request->has('how_we_got_client')) {
$client_update->how_we_got_client = $request->how_we_got_client == 'Other' ? ($request->how_we_got_client_other ?? "") : $request->how_we_got_client;
}
$client_update->last_modified_by = session('current_user.id');
$client_update->save();
Models\UserActivity::create([
'type' => 'staff',
'content' => session('current_user.name') . " updated ({$client_update->name}) details successfully!",
'user_id' => session('current_user.id'),
'ip_address' => request()->ip(),
'device' => $request->header('User-Agent')
]);
Session::flash('success_message', 'Client successfully Updated');
return redirect(url('clients', $id));
}
public function getClientFile($id)
{
$client_file = Models\ClientFile::with('client_info')->findOrFail($id);
// Use proper storage path logic
$file = storage_path('app/public/client_files/' . $client_file->file_path);
if (!file_exists($file)) {
abort(404, 'File not found on the server.');
}
$filename = Str::slug($client_file->client_info->name . "_" . $client_file->name, '_');
$filename = $filename . "." . $client_file->file_extension;
return Response::download($file, $filename);
}
public function cleanStr($string): string
{
// Replaced custom regex block with Laravel's native slug helper
return Str::slug($string, '_');
}
// ... Additional unchanged methods (getMnoCountry, etc.) follow below.
}

18
config/permissions.php Normal file
View File

@@ -0,0 +1,18 @@
<?php
return [
'SUPER_ADMIN' => 1,
'VIEW_USERS' => 2,
'ADD_EDIT_REMOVE_USERS' => 4,
'MANAGE_CLIENTS' => 8,
'MANAGE_MNOS' => 16,
'MANAGE_SHORT_CODES' => 32,
'MANAGE_SENDER_IDS' => 64,
'MANAGE_VPN_CONFIGS' => 128,
'MANAGE_BRANCH_OFFICES' => 256,
'MANAGE_UTILITIES' => 512,
'MANAGE_TEAM_MEMBERS' => 1024,
'CHANGE_ACCOUNT_MANAGERS' => 2048,
];
?>

View File

@@ -3,8 +3,35 @@
@section('title', 'Click ERP - Client Management')
@push('styles')
<style>
.avatar-circle { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: 50%; font-weight: bold; font-size: 0.85rem; }
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
<style>
/* Custom styling to make Select2 match Bootstrap 5 form controls */
.select2-container .select2-selection--multiple {
min-height: 38px;
border: 1px solid #dee2e6;
border-radius: 0.375rem;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice {
background-color: #5c4df0;
border: none;
color: white;
border-radius: 4px;
padding: 2px 8px;
margin-top: 5px;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
color: white;
margin-right: 5px;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
color: #ffcccc;
background: transparent;
}
/* Fix for validation red border */
.is-invalid + .select2-container .select2-selection {
border-color: #dc3545;
}
.avatar-circle { width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: 50%; font-weight: bold; font-size: 0.85rem; }
</style>
@endpush
@@ -83,6 +110,7 @@
<th>Primary Contact</th>
<th>Services</th>
<th>Billing</th>
<th>Date Added</th>
<th>Status</th>
<th class="text-end">Actions</th>
</tr>
@@ -110,8 +138,14 @@
@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() {
$('#clientService').select2({
placeholder: "-- Select Services --",
allowClear: true,
dropdownParent: $('#createClientModal')
});
let searchTimer;
// Initialize the table on page load
@@ -134,18 +168,13 @@
let page = $(this).data('page');
if (page) fetchClients(page);
});
// ---------------------------------------------------------
// 1. CREATE BUTTON (Open Modal)
// ---------------------------------------------------------
$('#btnOpenClientModal').on('click', function(e) {
e.preventDefault();
// Replace '#createClientModal' with the actual ID of the modal in your clients.partials.create file
$('#createClientModal').modal('show');
});
// ---------------------------------------------------------
// 2. VIEW BUTTON (Event Delegation for AJAX buttons)
// ---------------------------------------------------------
$(document).on('click', '.btn-view-client', function(e) {
e.preventDefault();
let clientId = $(this).data('id');
@@ -158,9 +187,7 @@
// $('#viewClientModal').modal('show');
});
// ---------------------------------------------------------
// 3. EDIT BUTTON (Event Delegation for AJAX buttons)
// ---------------------------------------------------------
$(document).on('click', '.btn-edit-client', function(e) {
e.preventDefault();
let clientId = $(this).data('id');
@@ -173,6 +200,100 @@
// $('#editClientModal').modal('show');
});
// ---------------------------------------------------------
// AJAX FORM SUBMISSION (Create Client)
// ---------------------------------------------------------
$('#createClientForm').on('submit', function(e) {
e.preventDefault();
let $form = $(this);
let $submitBtn = $('#btnSubmitClient');
let originalText = $submitBtn.html();
let $alertBox = $('#clientModalAlert');
// 1. Show loading state & reset previous alerts/errors
$submitBtn.html('<span class="spinner-border spinner-border-sm me-2"></span>Saving...').prop('disabled', true);
$alertBox.html('');
$form.find('.is-invalid').removeClass('is-invalid');
$form.find('.invalid-feedback').remove();
$.ajax({
url: $form.attr('action'),
method: 'POST',
data: $form.serialize(),
success: function(response) {
if(response.success) {
// Show success message inside the modal
$alertBox.html(`
<div class="alert alert-success d-flex align-items-center" role="alert">
<i class="bi bi-check-circle-fill me-2"></i>
<div>${response.message || 'Client added successfully!'}</div>
</div>
`);
// Refresh the background datatable
fetchClients(1);
// Optional: Automatically close the modal after 2 seconds
setTimeout(() => {
$('#createClientModal').modal('hide');
$form[0].reset();
$alertBox.html('');
}, 2000);
}
},
error: function(xhr) {
// Handle Laravel Validation Errors (Status 422)
if (xhr.status === 422) {
let errors = xhr.responseJSON.errors;
// Show general warning alert at the top
$alertBox.html(`
<div class="alert alert-danger d-flex align-items-center" role="alert">
<i class="bi bi-exclamation-triangle-fill me-2"></i>
<div>Please fix the errors highlighted below.</div>
</div>
`);
// Highlight specific fields
$.each(errors, function(key, value) {
// Account for array names like services[]
let fieldName = key;
if(key === 'services') fieldName = 'services[]';
let $input = $form.find('[name="' + fieldName + '"]');
if ($input.length) {
$input.addClass('is-invalid');
// Append the specific error message right below the field
$input.parent().append('<div class="invalid-feedback d-block fw-medium">' + value[0] + '</div>');
}
});
} else {
// Handle standard 500 server errors
$alertBox.html(`
<div class="alert alert-danger d-flex align-items-center" role="alert">
<i class="bi bi-x-circle-fill me-2"></i>
<div>An unexpected server error occurred. Please try again.</div>
</div>
`);
}
},
complete: function() {
// Restore the button to its original state
$submitBtn.html(originalText).prop('disabled', false);
}
});
});
// Clear alerts and errors when the modal is closed manually
$('#createClientModal').on('hidden.bs.modal', function () {
$('#createClientForm')[0].reset();
$('#clientService').val(null).trigger('change');
$('#clientModalAlert').html('');
$('#createClientForm').find('.is-invalid').removeClass('is-invalid');
$('#createClientForm').find('.invalid-feedback').remove();
});
// AJAX Fetch Function
function fetchClients(page = 1) {
const search = $('#searchClient').val();
@@ -224,7 +345,7 @@
window.location.href = "{{ route('clients.export') }}?" + queryParams;
});
// Render Table Rows
function renderTable(clients) {
function renderTableOld(clients) {
let html = '';
if (clients.length === 0) {
@@ -275,6 +396,91 @@
${servicesHtml}
</td>
<td><span class="badge bg-info bg-opacity-10 text-info text-uppercase">${client.pay_mode || 'N/A'}</span></td>
<td><span class="fw-medium text-primary">${client.created_at}</span></td>
<td>${statusBadge}</td>
<td class="text-end">
<button class="btn btn-sm btn-light text-primary me-1 btn-view-client"
data-id="${client.id}">
<i class="bi bi-eye"></i>
</button>
<button class="btn btn-sm btn-light text-primary me-1 btn-edit-client"
data-id="${client.id}">
<i class="bi bi-pencil"></i>
</button>
</td>
</tr>
`;
});
$('#clientTableBody').html(html);
}
function renderTable(clients) {
let html = '';
if (clients.length === 0) {
$('#clientTableBody').html('<tr><td colspan="7" class="text-center text-secondary py-4">No clients found matching your criteria.</td></tr>');
return;
}
clients.forEach(client => {
// 1. Extract initials for the avatar
let initials = client.name.substring(0, 2).toUpperCase();
// 2. Handle Services
let servicesHtml = '<span class="text-secondary" style="font-size: 0.8rem;">N/A</span>';
if (client.services) {
try {
let servicesArray = JSON.parse(client.services);
if (Array.isArray(servicesArray) && servicesArray.length > 0) {
servicesHtml = servicesArray.map(service =>
`<span class="badge bg-secondary bg-opacity-10 text-secondary border me-1 mb-1" style="font-size: 0.7rem;">${service}</span>`
).join('');
}
} catch (e) {
console.error("Could not parse services for client: " + client.name);
}
}
// 3. Status Badge Logic
let statusBadge = client.status === 'Live' || client.status === 'active'
? '<span class="badge bg-success bg-opacity-10 text-success px-2 py-1"><i class="bi bi-check-circle me-1"></i>Active</span>'
: '<span class="badge bg-warning bg-opacity-10 text-warning px-2 py-1"><i class="bi bi-clock me-1"></i>' + client.status + '</span>';
// 4. Format the Date (Human Friendly)
let formattedDate = 'N/A';
if (client.created_at) {
const dateObj = new Date(client.created_at);
// Formats to: "23 Jul 2026"
formattedDate = dateObj.toLocaleDateString('en-GB', {
day: 'numeric',
month: 'short',
year: 'numeric'
});
}
html += `
<tr>
<td>
<div class="d-flex align-items-center">
<div class="avatar-circle bg-primary bg-opacity-10 text-primary me-3">${initials}</div>
<div>
<div class="fw-bold text-dark">${client.name}</div>
<div class="text-secondary" style="font-size: 0.8rem;"><i class="bi bi-geo-alt me-1"></i>${client.country || 'N/A'}</div>
</div>
</div>
</td>
<td>
<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 style="max-width: 200px; white-space: normal;">
${servicesHtml}
</td>
<td><span class="badge bg-info bg-opacity-10 text-info text-uppercase">${client.pay_mode || 'N/A'}</span></td>
<!-- Updated Date Column -->
<td><span class="fw-medium text-primary">${formattedDate}</span></td>
<td>${statusBadge}</td>
<td class="text-end">
<button class="btn btn-sm btn-light text-primary me-1 btn-view-client"

View File

@@ -1,108 +1,132 @@
<div class="modal fade" id="clientModal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title fw-bold" id="clientModalTitle">Add New Client</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<form id="clientForm">
<div class="modal-body p-4">
<input type="hidden" id="clientId" name="id">
<h6 class="fw-bold mb-3 text-secondary text-uppercase" style="font-size: 0.75rem;">Company Details</h6>
<div class="row g-3 mb-4">
<div class="col-md-6">
<label class="form-label text-secondary fw-semibold" style="font-size: 0.85rem;">Company Name *</label>
<input type="text" class="form-control" id="clientName" name="name" required placeholder="e.g. Kasapreko Distilleries">
</div>
<div class="col-md-6">
<label class="form-label text-secondary fw-semibold" style="font-size: 0.85rem;">Location / Country</label>
<input type="text" class="form-control" id="country" name="location" placeholder="">
</div>
<div class="col-md-6">
<label class="form-label text-secondary fw-semibold" style="font-size: 0.85rem;">Company Type</label>
<select class="form-select" id="companyType" name="company_type">
<option value="" selected disabled>--Select--</option>
<option value="aggregator">Aggregator/Supplier</option>
<option value="enterprise">Enterprice</option>
<option value="hybrid">Hybrid</option>
</select>
</div>
<div class="col-md-6">
<label class="form-label text-secondary fw-semibold" style="font-size: 0.85rem;">Industry Type</label>
<select class="form-select" id="industryType" name="industry_type">
<option value="" selected disabled>--Select--</option>
<option value="aggregator">Aggregator SMS/USSD/Voice</option>
<option value="delivery">Delivery Service</option>
<option value="education">Education </option>
<option value="financial">Financial Institution</option>
<option value="games">Games & Gambling</option>
<option value="general">General</option>
<option value="government">Government</option>
<option value="health">Health</option>
<option value="hospitality">Hospitality</option>
<option value="mobile_network_operator">Mobile Network Operator</option>
<option value="ngo">NGO</option>
</select>
</div>
</div>
<h6 class="fw-bold mb-3 text-secondary text-uppercase" style="font-size: 0.75rem;">Primary Contact</h6>
<div class="row g-3 mb-4">
<div class="col-md-4">
<label class="form-label text-secondary fw-semibold" style="font-size: 0.85rem;">Full Name</label>
<input type="text" class="form-control" id="clientContact" name="contact_name" placeholder="Contact person">
</div>
<div class="col-md-4">
<label class="form-label text-secondary fw-semibold" style="font-size: 0.85rem;">Email Address *</label>
<input type="email" class="form-control" id="clientEmail" name="email" required placeholder="name@company.com">
</div>
<div class="col-md-4">
<label class="form-label text-secondary fw-semibold" style="font-size: 0.85rem;">Phone Number</label>
<input type="text" class="form-control" id="clientPhone" name="phone" placeholder="+233 ...">
</div>
</div>
<h6 class="fw-bold mb-3 text-secondary text-uppercase" style="font-size: 0.75rem;">Service & Billing Configuration</h6>
<div class="row g-3">
<div class="col-md-4">
<label class="form-label text-secondary fw-semibold" style="font-size: 0.85rem;">Primary Service</label>
<select class="form-select" id="clientService" name="service_type">
<option value="" selected disabled>--Select--</option>
<option value="sms">SMS</option>
<option value="ussd">USSD</option>
<option value="airtime">Airtime</option>
<option value="voice">Voice</option>
</select>
</div>
<div class="col-md-4">
<label class="form-label text-secondary fw-semibold" style="font-size: 0.85rem;">Billing Type</label>
<select class="form-select" id="clientBilling" name="billing_type">
<option value="" selected disabled>--Select--</option>
<option value="postpaid">Postpaid (Invoice)</option>
<option value="prepaid">Prepaid (Balance)</option>
</select>
</div>
<div class="col-md-4">
<label class="form-label text-secondary fw-semibold" style="font-size: 0.85rem;">Account Status</label>
<select class="form-select" id="clientStatus" name="status">
<option value="" selected disabled>--Select--</option>
<option value="active">Active</option>
<option value="onboarding">Prospective</option>
<option value="suspended">In Discussion</option>
</select>
</div>
</div>
</div>
<div class="modal-footer bg-light">
<button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">Cancel</button>
<button type="submit" class="btn text-white fw-bold px-4" style="background-color: #5c4df0;" id="btnSubmitClient">
Save Client
</button>
</div>
</form>
<div class="modal fade" id="createClientModal" tabindex="-1" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title fw-bold" id="clientModalTitle">Add New Client</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<form id="createClientForm" action="{{ route('clients.store') }}" method="POST">
@csrf
<div class="modal-body p-4">
<input type="hidden" id="clientId" name="id">
<div id="clientModalAlert"></div>
<h6 class="fw-bold mb-3 text-secondary text-uppercase" style="font-size: 0.75rem;">Company Details</h6>
<div class="row g-3 mb-4">
<div class="col-md-6">
<label class="form-label text-secondary fw-semibold" style="font-size: 0.85rem;">Company Name *</label>
<input type="text" class="form-control" id="clientName" name="name" required placeholder="e.g. Kasapreko Distilleries">
</div>
<div class="col-md-6">
<label class="form-label text-secondary fw-semibold" style="font-size: 0.85rem;">Location / Country *</label>
<!-- Changed name from 'location' to 'country' -->
<input type="text" class="form-control" id="country" name="country" required placeholder="e.g. Ghana">
</div>
<div class="col-md-6">
<label class="form-label text-secondary fw-semibold" style="font-size: 0.85rem;">Company Type *</label>
<select class="form-select" id="companyType" name="company_type" required>
<option value="" selected disabled>--Select--</option>
<option value="Aggregator/Supplier">Aggregator/Supplier</option>
<option value="Enterprise">Enterprise</option>
<option value="Hybrid">Hybrid</option>
</select>
</div>
<div class="col-md-6">
<label class="form-label text-secondary fw-semibold" style="font-size: 0.85rem;">Industry Type *</label>
<!-- Changed name from 'industry_type' to 'industry' -->
<select class="form-select" id="industryType" name="industry" required>
<option value="" selected disabled>--Select--</option>
<option value="Aggregator SMS/USSD/Voice">Aggregator SMS/USSD/Voice</option>
<option value="Delivery Service">Delivery Service</option>
<option value="Education">Education</option>
<option value="Financial Institution">Financial Institution</option>
<option value="Games & Gambling">Games & Gambling</option>
<option value="General">General</option>
<option value="Government">Government</option>
<option value="Health">Health</option>
<option value="Hospitality">Hospitality</option>
<option value="Mobile Network Operator">Mobile Network Operator</option>
<option value="NGO">NGO</option>
</select>
</div>
</div>
<h6 class="fw-bold mb-3 text-secondary text-uppercase" style="font-size: 0.75rem;">Primary Contact</h6>
<div class="row g-3 mb-4">
<div class="col-md-4">
<label class="form-label text-secondary fw-semibold" style="font-size: 0.85rem;">Full Name</label>
<!-- Changed name from 'contact_name' to 'contact_person' -->
<input type="text" class="form-control" id="clientContact" name="contact_person" placeholder="Contact person">
</div>
<div class="col-md-4">
<label class="form-label text-secondary fw-semibold" style="font-size: 0.85rem;">Email Address *</label>
<input type="email" class="form-control" id="clientEmail" name="email" required placeholder="name@company.com">
</div>
<div class="col-md-4">
<label class="form-label text-secondary fw-semibold" style="font-size: 0.85rem;">Phone Number</label>
<input type="text" class="form-control" id="clientPhone" name="phone" placeholder="+233 ...">
</div>
</div>
<h6 class="fw-bold mb-3 text-secondary text-uppercase" style="font-size: 0.75rem;">Service & Billing Information</h6>
<div class="row g-3">
<div class="col-md-12">
<label class="form-label text-secondary fw-semibold" style="font-size: 0.85rem;">Primary Services *</label>
<select class="form-select" id="clientService" name="services[]" multiple required style="width: 100%;">
@foreach($service_types as $row)
<option value="{{ $row }}">{{ $row }}</option>
@endforeach
</select>
</div>
<div class="col-md-6">
<label class="form-label text-secondary fw-semibold" style="font-size: 0.85rem;">Billing Type *</label>
<!-- Changed name from 'billing_type' to 'payment_mode' -->
<select class="form-select" id="clientBilling" name="payment_mode" required>
<option value="" selected disabled>--Select--</option>
<option value="Postpaid">Postpaid (Invoice)</option>
<option value="Prepaid">Prepaid (Balance)</option>
</select>
</div>
<div class="col-md-6">
<label class="form-label text-secondary fw-semibold" style="font-size: 0.85rem;">Account Status *</label>
<select class="form-select" id="clientStatus" name="status" required>
<option value="" selected disabled>--Select--</option>
<option value="Live">Active / Live</option>
<option value="Prospective">Prospective</option>
<option value="Cancelled">Cancelled</option>
</select>
</div>
<!-- Added Missing Required Fields for the Controller -->
<div class="col-md-6 mt-3">
<label class="form-label text-secondary fw-semibold" style="font-size: 0.85rem;">Currency *</label>
<select class="form-select" id="clientCurrency" name="currency" required>
<option value="" selected disabled>--Select--</option>
<option value="USD">USD</option>
<option value="EUR">EUR</option>
</select>
</div>
<div class="col-md-6 mt-3">
<label class="form-label text-secondary fw-semibold" style="font-size: 0.85rem;">Account Manager *</label>
<select class="form-select" id="authUserId" name="account_manager" required>
<option value="" selected disabled>--Select--</option>
<option value="{{ Auth()->user()->id }}">Assign to Me</option>
@foreach($staff_members as $id => $name)
<option value="{{ $id }}">{{ $name }}</option>
@endforeach
</select>
</div>
</div>
</div>
<div class="modal-footer bg-light">
<button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">Cancel</button>
<button type="submit" class="btn text-white fw-bold px-4" style="background-color: #5c4df0;" id="btnSubmitClient">
Save Client
</button>
</div>
</form>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,474 @@
@extends('layouts.masterbeta')
@section('page-title')
Clients | {{ $showclient->name }}
@endsection
@section('breadcrumbs')
<nav aria-label="breadcrumb">
<ol class="breadcrumb mb-0">
<li class="breadcrumb-item"><a href="{{ url('/clients') }}" class="text-decoration-none">Clients</a></li>
<li class="breadcrumb-item active" aria-current="page">{{ $showclient->name }}</li>
</ol>
</nav>
@endsection
@section('content')
<div class="container-fluid px-0">
<!-- Header Section -->
<div class="d-flex justify-content-between align-items-center mb-4">
<div class="d-flex align-items-center">
<div class="avatar-circle bg-primary text-white me-3 d-flex justify-content-center align-items-center fw-bold shadow-sm" style="width: 54px; height: 54px; border-radius: 50%; font-size: 1.5rem;">
{{ substr($showclient->name, 0, 2) }}
</div>
<div>
<h3 class="fw-bold mb-1 text-dark">{{ $showclient->name }}</h3>
<div class="text-secondary d-flex align-items-center" style="font-size: 0.9rem;">
<i class="bi bi-geo-alt-fill text-danger me-1"></i> {{ $showclient->country ?? 'Unknown Location' }}
<span class="mx-2"></span>
<i class="bi bi-building me-1"></i> {{ $showclient->company_type ?? 'N/A' }}
<span class="mx-2"></span>
@if($showclient->status == 'Live' || $showclient->status == 'active')
<span class="badge bg-success bg-opacity-10 text-success"><i class="bi bi-check-circle me-1"></i>Active</span>
@else
<span class="badge bg-warning bg-opacity-10 text-warning"><i class="bi bi-clock me-1"></i>{{ ucfirst($showclient->status) }}</span>
@endif
</div>
</div>
</div>
<div>
<!-- Button to trigger the Edit modal or go to edit page -->
<button class="btn btn-primary fw-bold shadow-sm px-4" data-bs-toggle="modal" data-bs-target="#editClientModal">
<i class="bi bi-pencil-square me-2"></i> Edit Client
</button>
</div>
</div>
<!-- Main Grid Layout -->
<div class="row g-4 mb-5">
<!-- COLUMN 1 -->
<div class="col-lg-4 d-flex flex-column">
<!-- Company Profile -->
<div class="card border-light-subtle shadow-sm mb-4">
<div class="card-header bg-white py-3 border-bottom border-light">
<h6 class="fw-bold mb-0 text-secondary text-uppercase" style="font-size: 0.8rem; letter-spacing: 0.5px;">
<i class="bi bi-info-circle text-primary me-2"></i> Company Profile
</h6>
</div>
<div class="card-body">
<ul class="list-group list-group-flush">
<li class="list-group-item px-0 py-2 d-flex justify-content-between align-items-center border-0">
<span class="text-muted small">Industry</span>
<span class="fw-medium text-dark">{{ $showclient->industry ?? 'N/A' }}</span>
</li>
<li class="list-group-item px-0 py-2 d-flex justify-content-between align-items-center border-0">
<span class="text-muted small">Type</span>
<span class="fw-medium text-dark">{{ $showclient->type ?? 'N/A' }}</span>
</li>
<li class="list-group-item px-0 py-2 d-flex justify-content-between align-items-center border-0">
<span class="text-muted small">Acquisition</span>
<span class="fw-medium text-dark">{{ $showclient->how_we_got_client ?? 'N/A' }}</span>
</li>
<li class="list-group-item px-0 py-2 d-flex justify-content-between align-items-center border-0">
<span class="text-muted small">Date Added</span>
<span class="fw-medium text-dark">{{ $showclient->created_at ? \Carbon\Carbon::parse($showclient->created_at)->format('d M Y') : 'N/A' }}</span>
</li>
</ul>
</div>
</div>
<!-- Primary Contact (Will now stretch automatically) -->
<div class="card border-light-subtle shadow-sm flex-grow-1">
<div class="card-header bg-white py-3 border-bottom border-light">
<h6 class="fw-bold mb-0 text-secondary text-uppercase" style="font-size: 0.8rem; letter-spacing: 0.5px;">
<i class="bi bi-person-badge text-primary me-2"></i> Primary Contact
</h6>
</div>
<div class="card-body">
<div class="mb-3">
<div class="text-muted small mb-1">Contact Person</div>
<div class="fw-bold text-dark">{{ $showclient->contact_person ?? 'N/A' }}</div>
</div>
<div class="mb-3">
<div class="text-muted small mb-1">Email Address</div>
<div class="fw-medium text-primary"><a href="mailto:{{ $showclient->email }}" class="text-decoration-none">{{ $showclient->email ?? 'N/A' }}</a></div>
</div>
<div class="mb-3">
<div class="text-muted small mb-1">Phone Number</div>
<div class="fw-medium text-dark">{{ $showclient->phone ?? 'N/A' }}</div>
</div>
<div class="row">
<div class="col-6">
<div class="text-muted small mb-1">Skype</div>
<div class="fw-medium text-dark">{{ $showclient->skype_name ?? 'N/A' }}</div>
</div>
<div class="col-6">
<div class="text-muted small mb-1">LinkedIn</div>
<div class="fw-medium text-dark">{{ $showclient->linkedin_name ?? 'N/A' }}</div>
</div>
</div>
</div>
</div>
</div>
<!-- COLUMN 2 -->
<div class="col-lg-4">
<!-- Service & Billing -->
<div class="card border-light-subtle shadow-sm mb-4">
<div class="card-header bg-white py-3 border-bottom border-light">
<h6 class="fw-bold mb-0 text-secondary text-uppercase" style="font-size: 0.8rem; letter-spacing: 0.5px;">
<i class="bi bi-wallet2 text-primary me-2"></i> Service & Billing
</h6>
</div>
<div class="card-body">
<div class="mb-3">
<div class="text-muted small mb-2">Subscribed Services</div>
<div>
@php
$services = json_decode($showclient->services, true) ?? [];
@endphp
@if(count($services) > 0)
@foreach($services as $service)
<span class="badge bg-secondary bg-opacity-10 text-secondary border me-1">{{ $service }}</span>
@endforeach
@else
<span class="text-muted small">N/A</span>
@endif
</div>
</div>
<div class="row mb-3">
<div class="col-6">
<div class="text-muted small mb-1">Billing Mode</div>
<div class="fw-bold text-dark text-uppercase">{{ $showclient->pay_mode ?? 'N/A' }}</div>
</div>
<div class="col-6">
<div class="text-muted small mb-1">Currency</div>
<div class="fw-bold text-dark">{{ $showclient->currency ?? 'N/A' }}</div>
</div>
</div>
<div class="mb-2">
<div class="text-muted small mb-1">Message Types</div>
<div>
@php
$msgTypes = json_decode($showclient->message_types, true) ?? [];
@endphp
@if(count($msgTypes) > 0)
@foreach($msgTypes as $type)
<span class="badge bg-info bg-opacity-10 text-info border border-info me-1">{{ $type }}</span>
@endforeach
@else
<span class="text-muted small">N/A</span>
@endif
</div>
</div>
</div>
</div>
<!-- Contract Details -->
<div class="card border-light-subtle shadow-sm">
<div class="card-header bg-white py-3 border-bottom border-light">
<h6 class="fw-bold mb-0 text-secondary text-uppercase" style="font-size: 0.8rem; letter-spacing: 0.5px;">
<i class="bi bi-file-earmark-text text-primary me-2"></i> Contract Details
</h6>
</div>
<div class="card-body">
<ul class="list-group list-group-flush">
<li class="list-group-item px-0 py-2 d-flex justify-content-between align-items-center border-0">
<span class="text-muted small">Contract Type</span>
<span class="fw-medium text-dark">{{ $showclient->contract_type ?? 'N/A' }}</span>
</li>
<li class="list-group-item px-0 py-2 d-flex justify-content-between align-items-center border-0">
<span class="text-muted small">Auto Renew</span>
@if($showclient->contract_auto_renew == 'YES')
<span class="badge bg-success">Yes</span>
@else
<span class="badge bg-secondary">No</span>
@endif
</li>
<li class="list-group-item px-0 py-2 d-flex justify-content-between align-items-center border-0">
<span class="text-muted small">Validity (Expiry)</span>
@if($showclient->contract_validity && $showclient->contract_validity != '1970-01-01 22:00:00')
<span class="fw-medium text-dark">{{ \Carbon\Carbon::parse($showclient->contract_validity)->format('d M Y') }}</span>
@else
<span class="text-muted small">N/A</span>
@endif
</li>
<li class="list-group-item px-0 py-2 border-0 mt-2 bg-light rounded">
<div class="text-muted small mb-1">SMPP Username</div>
<div class="fw-bold text-dark font-monospace">{{ $showclient->smpp_username ?? 'N/A' }}</div>
</li>
</ul>
</div>
</div>
</div>
<!-- COLUMN 3 -->
<div class="col-lg-4">
<!-- Onboarding Progress -->
<div class="card border-light-subtle shadow-sm mb-4">
<div class="card-header bg-white py-3 border-bottom border-light">
<h6 class="fw-bold mb-0 text-secondary text-uppercase" style="font-size: 0.8rem; letter-spacing: 0.5px;">
<i class="bi bi-graph-up text-primary me-2"></i> Onboarding Progress
</h6>
</div>
<div class="card-body">
<div class="d-flex justify-content-between align-items-center mb-2">
<div class="text-muted small fw-bold">Current Stage</div>
<div class="badge bg-primary">{{ $showclient->progress_indicator ?? 'N/A' }}</div>
</div>
@php
$score = $showclient->progress_indicator_score ?? 0;
$scoreColor = $score >= 100 ? 'bg-success' : ($score >= 50 ? 'bg-primary' : 'bg-warning');
@endphp
<div class="d-flex justify-content-between align-items-center mt-3 mb-1">
<span class="text-muted small">Completion Score</span>
<span class="fw-bold text-dark">{{ $score }}%</span>
</div>
<div class="progress" style="height: 8px;">
<div class="progress-bar {{ $scoreColor }}" role="progressbar" style="width: {{ $score }}%" aria-valuenow="{{ $score }}" aria-valuemin="0" aria-valuemax="100"></div>
</div>
</div>
</div>
<!-- Communication Channels -->
<div class="card border-light-subtle shadow-sm">
<div class="card-header bg-white py-3 border-bottom border-light">
<h6 class="fw-bold mb-0 text-secondary text-uppercase" style="font-size: 0.8rem; letter-spacing: 0.5px;">
<i class="bi bi-chat-dots text-primary me-2"></i> Communications
</h6>
</div>
<div class="card-body">
<!-- Helper Macro for JSON Emails/Phones -->
@php
function renderBadges($jsonString, $type = 'email') {
$items = json_decode($jsonString, true) ?? [];
if(count($items) === 0) return '<span class="text-muted small">N/A</span>';
$html = '';
foreach($items as $item) {
$icon = $type == 'email' ? 'bi-envelope' : 'bi-telephone';
$html .= '<span class="badge bg-light text-dark border me-1 mb-1"><i class="bi '.$icon.' text-secondary me-1"></i>'.$item.'</span>';
}
return $html;
}
@endphp
<div class="mb-3">
<div class="text-muted small mb-1">Finance Emails</div>
<div>{!! renderBadges($showclient->finance_email, 'email') !!}</div>
</div>
<div class="mb-3">
<div class="text-muted small mb-1">Support Emails</div>
<div>{!! renderBadges($showclient->support_emails, 'email') !!}</div>
</div>
<div class="mb-3">
<div class="text-muted small mb-1">Rate Emails</div>
<div>{!! renderBadges($showclient->rate_emails, 'email') !!}</div>
</div>
<div class="mb-0">
<div class="text-muted small mb-1">Support Phones</div>
<div>{!! renderBadges($showclient->support_phones, 'phone') !!}</div>
</div>
</div>
</div>
</div>
</div>
<!-- Tabs Navigation for Additional Records -->
<div class="card border-light-subtle shadow-sm mt-5 mb-4">
<div class="card-header bg-white pt-3 pb-0 border-bottom">
<ul class="nav nav-tabs card-header-tabs" id="clientRecordTabs" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active fw-bold text-dark" id="shortcodes-tab" data-bs-toggle="tab" data-bs-target="#shortcodes-pane" type="button" role="tab">
<i class="bi bi-code-square text-primary me-1"></i> Short Codes
<span class="badge bg-primary bg-opacity-10 text-primary ms-1">{{ count($voice_codes) + count($sms_codes) + count($ussd_codes) }}</span>
</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link fw-bold text-dark" id="payments-tab" data-bs-toggle="tab" data-bs-target="#payments-pane" type="button" role="tab">
<i class="bi bi-wallet2 text-primary me-1"></i> Payments
<span class="badge bg-primary bg-opacity-10 text-primary ms-1">{{ count($recent_payments) }}</span>
</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link fw-bold text-dark" id="files-tab" data-bs-toggle="tab" data-bs-target="#files-pane" type="button" role="tab">
<i class="bi bi-file-earmark-arrow-down text-primary me-1"></i> Documents
<span class="badge bg-primary bg-opacity-10 text-primary ms-1">{{ count($showdocuments) }}</span>
</button>
</li>
</ul>
</div>
<div class="card-body bg-light tab-content" id="clientRecordTabsContent">
<!-- TAB 1: SHORT CODES -->
<div class="tab-pane fade show active" id="shortcodes-pane" role="tabpanel" tabindex="0">
@php
$allCodes = collect($voice_codes)->concat($sms_codes)->concat($ussd_codes);
@endphp
@if($allCodes->count() > 0)
<div class="table-responsive">
<table class="table table-hover align-middle mb-0 bg-white border rounded">
<thead class="table-light">
<tr style="font-size: 0.8rem;" class="text-secondary text-uppercase">
<th>Type</th>
<th>Shortcode</th>
<th>Network</th>
<th>Status</th>
<th>Expiry Date</th>
</tr>
</thead>
<tbody>
@foreach($allCodes as $code)
<tr>
<td><span class="badge bg-secondary text-uppercase" style="font-size: 0.7rem;">{{ $code->code_type ?? 'N/A' }}</span></td>
<td class="fw-bold text-dark font-monospace">{{ $code->shortcode ?? 'N/A' }}</td>
<td>{{ $code->network ?? 'N/A' }}</td>
<td>
<span class="badge bg-success bg-opacity-10 text-success">{{ $code->status ?? 'Active' }}</span>
</td>
<td class="text-muted small">{{ $code->expiry_date ? \Carbon\Carbon::parse($code->expiry_date)->format('d M Y') : 'N/A' }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@else
<div class="text-center py-4 text-muted small">
<i class="bi bi-folder2-open fs-4 d-block mb-1"></i> No short codes assigned to this client.
</div>
@endif
</div>
<!-- TAB 2: PAYMENTS -->
<div class="tab-pane fade" id="payments-pane" role="tabpanel" tabindex="0">
@if(isset($recent_payments) && count($recent_payments) > 0)
<div class="table-responsive" style="max-height: 450px; overflow-y: auto;">
<table class="table table-hover align-middle mb-0 bg-white border rounded">
<thead class="table-light">
<tr style="font-size: 0.8rem;" class="text-secondary text-uppercase">
<th>Invoice #</th>
<th>Amount</th>
<th>Date</th>
<th>Status</th>
</tr>
</thead>
<tbody>
@foreach($recent_payments as $payment)
<tr>
<td class="fw-bold text-dark">{{ $payment->invoice_number ?? 'N/A' }}</td>
<td class="fw-semibold text-success">{{ number_format($payment->invoice_amount ?? 0, 2) }}</td>
<td class="text-muted small">{{ $payment->invoice_date ? \Carbon\Carbon::parse($payment->invoice_date)->format('d M Y') : 'N/A' }}</td>
<td>
<span class="badge bg-info bg-opacity-10 text-info text-uppercase">{{ $payment->invoice_status ?? 'Pending' }}</span>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@else
<div class="text-center py-4 text-muted small">
<i class="bi bi-wallet fs-4 d-block mb-1"></i> No payment records found.
</div>
@endif
</div>
<!-- TAB 3: DOCUMENTS -->
<div class="tab-pane fade" id="files-pane" role="tabpanel" tabindex="0">
@if(isset($showdocuments) && count($showdocuments) > 0)
<div class="row g-3">
@foreach($showdocuments as $file)
<div class="col-md-4">
<div class="card border bg-white shadow-sm p-3 d-flex flex-row align-items-center justify-content-between">
<div class="d-flex align-items-center overflow-hidden">
<i class="bi bi-file-earmark-text fs-3 text-primary me-3"></i>
<div class="text-truncate">
<div class="fw-bold text-dark text-truncate" style="font-size: 0.9rem;" title="{{ $file->name }}">{{ $file->name }}</div>
<small class="text-muted text-uppercase" style="font-size: 0.7rem;">{{ $file->file_extension ?? 'file' }}</small>
</div>
</div>
@if(!empty($file->file_path))
<a href="{{ asset('storage/client_files/' . $file->file_path) }}" target="_blank" class="btn btn-sm btn-light text-primary" title="Download File">
<i class="bi bi-download"></i>
</a>
@endif
</div>
</div>
@endforeach
</div>
@else
<div class="text-center py-4 text-muted small">
<i class="bi bi-file-earmark-x fs-4 d-block mb-1"></i> No documents uploaded for this client.
</div>
@endif
</div>
</div>
</div>
<!-- Notes / Activity Log Section -->
<div class="card border-light-subtle shadow-sm mt-5 mb-5">
<div class="card-header bg-white py-3 border-bottom border-light d-flex justify-content-between align-items-center">
<h6 class="fw-bold mb-0 text-secondary text-uppercase" style="font-size: 0.8rem; letter-spacing: 0.5px;">
<i class="bi bi-journal-text text-primary me-2"></i> Client Notes & Activity Logs
</h6>
<span class="badge bg-primary bg-opacity-10 text-primary">{{ count($show_notes) }} Entries</span>
</div>
<!-- Scrollable Container -->
<div class="card-body bg-light p-3" style="max-height: 450px; overflow-y: auto;">
@if(isset($show_notes) && count($show_notes) > 0)
<div class="timeline">
@foreach($show_notes as $note)
<div class="card border-0 shadow-sm mb-3">
<div class="card-body p-3">
<div class="d-flex justify-content-between align-items-center mb-2">
<div class="d-flex align-items-center">
<!-- Author Avatar or Name -->
<div class="fw-bold text-dark me-2">
<i class="bi bi-person-circle text-secondary me-1"></i>
{{ $note->created_by_info->name ?? 'System User' }}
</div>
@if(isset($note->highlight) && $note->highlight == 'YES')
<span class="badge bg-warning bg-opacity-10 text-warning border border-warning-subtle" style="font-size: 0.7rem;">Highlighted</span>
@endif
</div>
<small class="text-muted" style="font-size: 0.8rem;">
<i class="bi bi-clock me-1"></i>{{ \Carbon\Carbon::parse($note->created_at)->format('d M Y, h:i A') }}
</small>
</div>
<!-- Note Content -->
<p class="mb-0 text-dark" style="white-space: pre-wrap; font-size: 0.95rem;">
{{ $note->notes_body ?? $note->note ?? $note->content ?? 'No content found' }}
</p>
</div>
</div>
@endforeach
</div>
@else
<div class="text-center py-4 text-muted small">
<i class="bi bi-journal-x fs-4 d-block mb-1"></i> No notes recorded for this client yet.
</div>
@endif
</div>
</div>
</div>
@endsection

View File

@@ -0,0 +1,104 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
<title>@yield('title', config('app.name'))</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css">
<style>
body { background-color: #f8f9fc; }
/* Sidebar Styling */
#sidebar {
width: 260px;
background-color: #111425;
position: fixed;
top: 0;
left: 0;
height: 100vh;
overflow-y: auto;
z-index: 1000;
}
.sidebar-brand { color: #fff; padding: 1.5rem 1.25rem; font-weight: 700; }
.sidebar-brand-icon { background: #5c4df0; padding: 0.5rem; border-radius: 8px; margin-right: 10px; }
.sidebar-nav-item { color: #8a90a5; text-decoration: none; padding: 0.75rem 1.25rem; display: block; border-radius: 8px; margin: 0.2rem 1rem; font-size: 0.9rem; }
.sidebar-nav-item:hover, .sidebar-nav-item.active { background-color: #5c4df0; color: #fff; }
.sidebar-heading { color: #5a617a; font-size: 0.75rem; text-transform: uppercase; padding: 1rem 1.25rem 0.5rem; font-weight: 600; letter-spacing: 0.5px; }
/* Main Content Layout */
#main-content { margin-left: 260px; min-height: 100vh; }
/* Topbar Styling */
.topbar { background: #fff; height: 70px; border-bottom: 1px solid #eaedf1; padding: 0 1.5rem; }
.badge-notification { position: absolute; top: -5px; right: -5px; background: #e74a3b; border-radius: 50%; padding: 3px 6px; font-size: 10px; color: white;}
/* Dashboard Cards */
.hero-banner { background-color: #181b31; color: white; border-radius: 12px; }
.stat-card { border: 1px solid #eaedf1; border-radius: 12px; box-shadow: 0 2px 4px rgba(0,0,0,0.02); }
.stat-icon { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; border-radius: 8px; font-size: 1.2rem; }
.progress-slim { height: 6px; border-radius: 4px; }
</style>
@stack('styles')
</head>
<body>
@include('layouts.partials.sidebar')
<main id="main-content">
@include('layouts.partials.topbar')
<div class="container-fluid p-4">
@yield('content')
</div>
</main>
<!-- jQuery -->
<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>
$(document).ready(function() {
// Function to update the clock dynamically
function updateClock() {
const now = new Date();
// Format Date: Thu, Jun 18, 2026
const dateOptions = { weekday: 'short', month: 'short', day: 'numeric', year: 'numeric' };
const formattedDate = now.toLocaleDateString('en-US', dateOptions);
// Format Time: 01:37:34 PM
const timeOptions = { hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: true };
const formattedTime = now.toLocaleTimeString('en-US', timeOptions);
$('#current-date').text(formattedDate);
$('#current-time').text(formattedTime);
}
// Run clock update immediately and then every second
updateClock();
setInterval(updateClock, 1000);
// Basic button interaction demo using jQuery
$('#seedBtn').on('click', function() {
const $btn = $(this);
const originalText = $btn.html();
$btn.html('<span class="spinner-border spinner-border-sm me-2" role="status" aria-hidden="true"></span> Seeding...');
$btn.prop('disabled', true);
// Simulate an API call
setTimeout(() => {
$btn.html(originalText);
$btn.prop('disabled', false);
alert('Demo records seeded successfully!');
}, 1500);
});
});
</script>
@stack('scripts')
</body>
</html>

View File

@@ -1,104 +1,76 @@
<!DOCTYPE html>
<html lang="en">
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
<title>@yield('title', config('app.name'))</title>
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>@yield('title', 'CML ERP')</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css">
<style>
body { background-color: #f8f9fc; }
/* Sidebar Styling */
#sidebar {
width: 260px;
background-color: #111425;
position: fixed;
top: 0;
left: 0;
height: 100vh;
overflow-y: auto;
z-index: 1000;
}
#sidebar { width: 260px; background-color: #111425; position: fixed; height: 100vh; overflow-y: auto; z-index: 1000; }
.sidebar-brand { color: #fff; padding: 1.5rem 1.25rem; font-weight: 700; }
.sidebar-brand-icon { background: #5c4df0; padding: 0.5rem; border-radius: 8px; margin-right: 10px; }
.sidebar-nav-item { color: #8a90a5; text-decoration: none; padding: 0.75rem 1.25rem; display: block; border-radius: 8px; margin: 0.2rem 1rem; font-size: 0.9rem; }
.sidebar-nav-item { color: #8a90a5; text-decoration: none; padding: 0.75rem 1.25rem; display: block; border-radius: 8px; margin: 0.2rem 1rem; font-size: 0.9rem; transition: all 0.2s; }
.sidebar-nav-item:hover, .sidebar-nav-item.active { background-color: #5c4df0; color: #fff; }
.sidebar-heading { color: #5a617a; font-size: 0.75rem; text-transform: uppercase; padding: 1rem 1.25rem 0.5rem; font-weight: 600; letter-spacing: 0.5px; }
.sidebar-heading { color: #5a617a; font-size: 0.75rem; text-transform: uppercase; padding: 1rem 1.25rem 0.5rem; font-weight: 600; }
/* Main Content Layout */
#main-content { margin-left: 260px; min-height: 100vh; }
/* Main Content & Topbar */
#main-content { margin-left: 260px; min-height: 100vh; display: flex; flex-direction: column; }
.topbar { background: #fff; height: 70px; border-bottom: 1px solid #eaedf1; padding: 0 1.5rem; flex-shrink: 0; }
/* Topbar Styling */
.topbar { background: #fff; height: 70px; border-bottom: 1px solid #eaedf1; padding: 0 1.5rem; }
.badge-notification { position: absolute; top: -5px; right: -5px; background: #e74a3b; border-radius: 50%; padding: 3px 6px; font-size: 10px; color: white;}
/* Dashboard Cards */
.hero-banner { background-color: #181b31; color: white; border-radius: 12px; }
.stat-card { border: 1px solid #eaedf1; border-radius: 12px; box-shadow: 0 2px 4px rgba(0,0,0,0.02); }
.stat-icon { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; border-radius: 8px; font-size: 1.2rem; }
.progress-slim { height: 6px; border-radius: 4px; }
/* Reusable Components */
.content-card { background: #fff; border: 1px solid #eaedf1; border-radius: 12px; box-shadow: 0 2px 4px rgba(0,0,0,0.02); }
.table-custom th { background-color: #f8f9fc; color: #5a617a; font-weight: 600; font-size: 0.8rem; text-transform: uppercase; border-bottom: 2px solid #eaedf1; padding: 1rem; }
.table-custom td { padding: 1rem; vertical-align: middle; font-size: 0.9rem; border-bottom: 1px solid #eaedf1; }
.form-control:focus, .form-select:focus { border-color: #5c4df0; box-shadow: 0 0 0 0.25rem rgba(92, 77, 240, 0.25); }
</style>
@stack('styles')
<script>
var base_url = "{!! url('/') !!}";
</script>
</head>
<body>
@include('layouts.partials.sidebar')
<main id="main-content">
@include('layouts.partials.topbar')
<div class="container-fluid p-4">
<div class="container-fluid p-4 flex-grow-1">
@yield('content')
</div>
</main>
<!-- jQuery -->
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
@stack('modals')
<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>
$(document).ready(function() {
// Function to update the clock dynamically
$.ajaxSetup({
headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }
});
function updateClock() {
const now = new Date();
// Format Date: Thu, Jun 18, 2026
const dateOptions = { weekday: 'short', month: 'short', day: 'numeric', year: 'numeric' };
const formattedDate = now.toLocaleDateString('en-US', dateOptions);
// Format Time: 01:37:34 PM
const timeOptions = { hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: true };
const formattedTime = now.toLocaleTimeString('en-US', timeOptions);
$('#current-date').text(formattedDate);
$('#current-time').text(formattedTime);
$('#current-time').text(now.toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: true }));
}
// Run clock update immediately and then every second
updateClock();
setInterval(updateClock, 1000);
// Basic button interaction demo using jQuery
$('#seedBtn').on('click', function() {
const $btn = $(this);
const originalText = $btn.html();
$btn.html('<span class="spinner-border spinner-border-sm me-2" role="status" aria-hidden="true"></span> Seeding...');
$btn.prop('disabled', true);
// Simulate an API call
setTimeout(() => {
$btn.html(originalText);
$btn.prop('disabled', false);
alert('Demo records seeded successfully!');
}, 1500);
});
});
</script>
@stack('scripts')
@stack('scripts')
</body>
</html>

View File

@@ -13,12 +13,12 @@ Route::middleware(['auth'])->group(function () {
Route::get('/', [App\Http\Controllers\DashboardController::class, 'index'])->name('home');
Route::get('home', [App\Http\Controllers\DashboardController::class, 'index'])->name('home');
Route::get('/clients', [App\Http\Controllers\ClientsController::class, 'index'])->name('clients.index');
// Route::get('/clients', [App\Http\Controllers\ClientsController::class, 'index'])->name('clients.index');
Route::get('/clients/data', [App\Http\Controllers\ClientsController::class, 'fetchData'])->name('clients.data');
Route::get('/clients/export', [App\Http\Controllers\ClientController::class, 'export'])->name('clients.export');
Route::resource('clients', App\Http\Controllers\ClientsController::class);