added remarks for payments, expanded currency list
This commit is contained in:
@@ -22,154 +22,21 @@ class ClientsController extends Controller
|
||||
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');
|
||||
$staff_members = Models\StaffMember::pluck('name', 'id'); //where('department_id', '1')->
|
||||
$currencies = Models\Currency::get();
|
||||
|
||||
// dd($staff_members);
|
||||
|
||||
$data = [
|
||||
'page_title' => 'Dashboard',
|
||||
'service_types' => $service_type,
|
||||
'countries' => $countries,
|
||||
'staff_members' => $staff_members
|
||||
'staff_members' => $staff_members,
|
||||
'currencies' => $currencies
|
||||
];
|
||||
return view('clients.index', $data);
|
||||
}
|
||||
|
||||
|
||||
public function showOld(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\NetworkOperator::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);
|
||||
|
||||
// dd($showclient);
|
||||
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 --'],
|
||||
]);
|
||||
}
|
||||
|
||||
public function show(int $id)
|
||||
{
|
||||
$showclient = Models\Client::with([
|
||||
@@ -189,6 +56,10 @@ class ClientsController extends Controller
|
||||
$service_type = Models\Service::pluck('name', 'id');
|
||||
$service_type_names = Models\Service::pluck('name', 'name');
|
||||
$show_services = Models\ClientCategory::where('client_id', $id)->get();
|
||||
$currencies = Models\Currency::get();
|
||||
$staff_members = Models\StaffMember::pluck('name', 'id'); //where('department_id', '1')->
|
||||
|
||||
|
||||
|
||||
$country_networks = DB::table('network_operators')
|
||||
->selectRaw('id, CONCAT(name, " (", country, ")") AS network')
|
||||
@@ -279,7 +150,7 @@ class ClientsController extends Controller
|
||||
|
||||
$change_account_mgr_permission = Config::get('permissions.CHANGE_ACCOUNT_MANAGERS');
|
||||
$change_account_mgr_permission = $this->hasAnyAccess([$change_account_mgr_permission]) ? 'YES' : 'NO';
|
||||
|
||||
// dd($showclient);
|
||||
return view('clients.show', [
|
||||
'page_title' => 'Client Profile',
|
||||
'showclient' => $showclient,
|
||||
@@ -295,6 +166,8 @@ class ClientsController extends Controller
|
||||
'ussd_codes' => $ussd_codes,
|
||||
'countries' => $countries,
|
||||
'networks' => $networks,
|
||||
'currencies' => $currencies,
|
||||
'staff_members' => $staff_members,
|
||||
'progress_indicators' => $progress_indicators,
|
||||
'networks_raw' => array_combine($networks_raw, $networks_raw),
|
||||
'renewal_due' => $renewal_due,
|
||||
@@ -551,7 +424,7 @@ class ClientsController extends Controller
|
||||
'status' => $request->status,
|
||||
'pay_mode' => $request->payment_mode,
|
||||
'currency' => $request->currency,
|
||||
'auth_user_id' => $request->auth_user_id,
|
||||
'auth_user_id' => $request->account_manager,
|
||||
'created_by' => Auth::user()->id,
|
||||
'last_modified_by' => Auth::user()->id,
|
||||
'progress_indicator_score' => 10,
|
||||
@@ -617,7 +490,6 @@ class ClientsController extends Controller
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$client = \App\Models\Client::findOrFail($id);
|
||||
|
||||
$client->update([
|
||||
'name' => $request->name,
|
||||
'email' => $request->email,
|
||||
@@ -629,7 +501,7 @@ class ClientsController extends Controller
|
||||
'status' => $request->status,
|
||||
'currency' => $request->currency,
|
||||
'country' => $request->country,
|
||||
// Arrays handled by model casts
|
||||
'auth_user_id' => $request->account_manager,
|
||||
'services' => $request->services,
|
||||
'message_types' => $request->message_types,
|
||||
'connections' => $request->connections,
|
||||
@@ -773,8 +645,6 @@ class ClientsController extends Controller
|
||||
|
||||
dispatch(new SendShortCodeListToFinance($short_code_list, $message_body, $finance_arr));
|
||||
}
|
||||
|
||||
#$payments = Models\ClientPayment::with('client_info', 'created_by_info')->find($result->id);
|
||||
if ($result) {
|
||||
$data = ['code' => 1, 'msg' => 'Payment Details successfully added'];
|
||||
}
|
||||
@@ -809,6 +679,9 @@ class ClientsController extends Controller
|
||||
$payment->short_code = ($request->short_code) ? $request->short_code : "";
|
||||
|
||||
$payment->services = implode(',', $request->services);
|
||||
if ($request->has('remarks')) {
|
||||
$payment->remarks = $request->remarks;
|
||||
}
|
||||
$result = $payment->save();
|
||||
$client = Models\Client::find($request->client_id);
|
||||
if ($request->has('short_code')) {
|
||||
@@ -1017,13 +890,17 @@ class ClientsController extends Controller
|
||||
'invoice_amount' => 'required|numeric',
|
||||
'invoice_date' => 'required|date',
|
||||
'invoice_status' => 'required|string',
|
||||
'remarks' => 'sometimes|string'
|
||||
]);
|
||||
|
||||
// Find the record and update it
|
||||
$payment = Models\ClientPayment::findOrFail($id); // Adjust 'ClientPayment' to your actual model name
|
||||
// if ($request->has('remarks')) {
|
||||
// $payment->remarks = $request->remarks;
|
||||
// }
|
||||
$payment = Models\ClientPayment::findOrFail($id);
|
||||
$payment->update($validated);
|
||||
|
||||
// Return the JSON response for SweetAlert
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Payment record updated successfully!'
|
||||
|
||||
Reference in New Issue
Block a user