From 318fddbff073f88f52123e9ba28cc89d0b6e40cd Mon Sep 17 00:00:00 2001 From: Kwesi Banson Date: Tue, 11 Jun 2024 23:41:52 +0000 Subject: [PATCH] short code in client payment, edit logic for short codes --- .../ProcessClientContractRenewalAlert.php | 2 +- .../Commands/SendContractRenewalReminders.php | 2 +- app/Console/Kernel.php | 2 +- app/Http/Controllers/ClientsController.php | 303 ++++++++++++------ app/Http/Controllers/UtilityController.php | 7 +- app/Jobs/SendMnoContractRenewalEmailAlert.php | 2 - public/assets/js/clientshow.js | 146 +++++++-- .../client/partials/edit-shortcodes.blade.php | 107 +++++++ .../views/client/partials/finance.blade.php | 25 +- .../views/client/partials/sms-codes.blade.php | 9 +- .../client/partials/ussd-codes.blade.php | 15 +- .../client/partials/voice-codes.blade.php | 103 +++--- resources/views/client/show.blade.php | 69 ++-- resources/views/utility/arraylogic.blade.php | 166 ++++++++++ routes/web.php | 15 +- storage/laravel-2024-06-11.log | 1 + 16 files changed, 730 insertions(+), 244 deletions(-) create mode 100644 resources/views/client/partials/edit-shortcodes.blade.php create mode 100644 resources/views/utility/arraylogic.blade.php create mode 100644 storage/laravel-2024-06-11.log diff --git a/app/Console/Commands/ProcessClientContractRenewalAlert.php b/app/Console/Commands/ProcessClientContractRenewalAlert.php index f5c063f..75874a4 100644 --- a/app/Console/Commands/ProcessClientContractRenewalAlert.php +++ b/app/Console/Commands/ProcessClientContractRenewalAlert.php @@ -41,6 +41,6 @@ class ProcessClientContractRenewalAlert extends Command { $this->client_contractRenewalReminder->getClientDetails(); - \Log::info('SendClientContractRenewalReminders command completed...'); + // \Log::info('SendClientContractRenewalReminders command completed...'); } } diff --git a/app/Console/Commands/SendContractRenewalReminders.php b/app/Console/Commands/SendContractRenewalReminders.php index 9b49b9f..ab7e488 100644 --- a/app/Console/Commands/SendContractRenewalReminders.php +++ b/app/Console/Commands/SendContractRenewalReminders.php @@ -41,6 +41,6 @@ class SendContractRenewalReminders extends Command { $this->contractRenewalReminder->getMnos(); - \Log::info('SendContractRenewalReminders command completed...'); + // \Log::info('SendContractRenewalReminders command completed...'); } } diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 3a3d670..9815331 100755 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -13,7 +13,7 @@ class Kernel extends ConsoleKernel * @var array */ protected $commands = [ - Commands\SendContractRenewalReminders::class + Commands\SendContractRenewalReminders::class, Commands\ProcessClientContractRenewalAlert::class ]; diff --git a/app/Http/Controllers/ClientsController.php b/app/Http/Controllers/ClientsController.php index 02ff6da..20ebee3 100755 --- a/app/Http/Controllers/ClientsController.php +++ b/app/Http/Controllers/ClientsController.php @@ -15,7 +15,7 @@ use Carbon\Carbon; class ClientsController extends Controller -{ +{ /** * Display a listing of the resource. * @@ -51,11 +51,11 @@ class ClientsController extends Controller /* $client_arr = new Models\Client; $client_arr = $client_arr->with('auth_user_info','country_info', 'created_by_info', 'modified_by_info')->orderBy('name', 'ASC')->paginate(20); - + dump($request->all()); $client_arr = $client_arr->with('auth_user_info','country_info', 'created_by_info', 'modified_by_info') ->orderBy('name', 'ASC')->paginate(20); - } + } */ $client_arr = \DB::table('clients') ->join('auth_users AS aumngr', 'aumngr.id', '=', 'clients.auth_user_id') @@ -75,8 +75,8 @@ class ClientsController extends Controller ->whereRaw("clients.name like '%$keyword%' or clients.status like '%$keyword%' OR clients.country like '%$keyword%' OR aumngr.name like '%$keyword%' OR aumodify.name like '%$keyword%' OR clients.progress_indicator_score like '%$keyword%'") ->orderBy('name', 'ASC') ->paginate(15); - } - + } + return response()->json($client_arr); } public function getClientJsonRawJs(Request $request){ @@ -100,7 +100,7 @@ class ClientsController extends Controller } return response()->json($client_arr); } - + /** * Show the form for creating a new resource. @@ -118,7 +118,7 @@ class ClientsController extends Controller $company_types = ['Aggregator/Supplier' => 'Aggregator/Supplier', 'Enterprise' => 'Enterprise', 'Hybrid' => 'Hybrid']; $industries = Models\Industry::orderBy('name', 'ASC')->pluck('name', 'name'); // $industries = Models\Industry::pluck('name', 'name')->orderBy('name', 'ASC'); - + $data = [ 'page_title' => 'Create Client', @@ -134,7 +134,7 @@ class ClientsController extends Controller return view('client.create', $data); } - + /** * Store a newly created resource in storage. @@ -160,11 +160,11 @@ class ClientsController extends Controller $onboarding_stages = Models\ClientOnboardingMainStage::orderBy('stage_id')->get(); // dd($onboarding_stages); $client_current_stages = []; - + foreach ($onboarding_stages as $value) { $client_current_stages[$value->stage] = "PENDING"; } - + $client_arr = [ 'name' => $request->name, 'email' => $request->email, @@ -176,7 +176,7 @@ class ClientsController extends Controller 'created_by' => session('current_user.id'), 'last_modified_by' => session('current_user.id'), 'progress_indicator_score' => 10, - 'progress_indicator' => $onboarding_stages[0]->stage, // 'Agreement Stage', // + 'progress_indicator' => $onboarding_stages[0]->stage, // 'Agreement Stage', // 'onboarding_progress_stage' => json_encode($client_current_stages) ]; if ($request->has('notes')) { @@ -206,16 +206,16 @@ class ClientsController extends Controller if ($request->has('payment_mode')) { $client_arr['pay_mode'] = $request->payment_mode; } - + $result = Models\Client::create($client_arr); - + //add entries for client_onboarding_progress - $get_stage_subs_items = Models\ClientOnboardingSubItem::get(); + $get_stage_subs_items = Models\ClientOnboardingSubItem::get(); foreach ($get_stage_subs_items as $value) { $progress_arr = [ - 'stage_id' => $value->stage_id, - 'client_id' => $result->id, - 'name' => $value->name, + 'stage_id' => $value->stage_id, + 'client_id' => $result->id, + 'name' => $value->name, 'status' => 'PENDING' ]; $clients_onboarding_progress = Models\ClientOnboardingProgress::create($progress_arr); @@ -228,7 +228,7 @@ class ClientsController extends Controller 'last_modified_by_id' => session('current_user.id') ]; $retval = Models\UssdClientPayment::create($ussd_client_payment_arr); - //TODO send an email to jim/priscilla about new USSD client, + //TODO send an email to jim/priscilla about new USSD client, #dispatch(new SendNewUssdClientEmail($result)); } #save services this has been moved to the main client table @@ -261,8 +261,8 @@ class ClientsController extends Controller if ($request->has('highlight')) { $notes_arr['highlight'] = 'YES'; } - - + + //dd($notes_arr); $result = Models\ClientNote::create($notes_arr); // dd($result); @@ -285,7 +285,7 @@ class ClientsController extends Controller public function getSingleNote($id){ $note = Models\ClientNote::find($id); if ($note) { - + $current_date = date_create(date('Y-m-d')); // dump($current_date); $expiry_date = date_create($note->created_at); @@ -304,7 +304,7 @@ class ClientsController extends Controller else{ return response()->json([ 'code' => 3, 'msg' => 'Request could not be handled at this time']); } - + } public function notesUpdate(Request $request) { @@ -316,14 +316,14 @@ class ClientsController extends Controller $note = Models\ClientNote::find($request->note_id); $note->notes_body = $request->notes_body; $note->services = implode(',', $request->services); - + if ($request->has('highlight')) { $note->highlight = 'YES'; } $result = $note->save(); - + $notes = Models\ClientNote::with('client_info', 'created_by_info')->find($request->note_id); - + //dispatch(new SendNewNotesEmailAlert($notes)); if ($result) { @@ -338,15 +338,15 @@ class ClientsController extends Controller $this->logUsersActivity($type = 'staff', $content); return response()->json($data, 200); } - public function financeStore(Request $request) - { + public function financeStore(Request $request){ $request->validate([ 'client_id' => 'required', 'services' => 'required', 'invoice_number' => 'required', 'invoice_amount' => 'required|numeric', 'invoice_date' => 'required', - 'invoice_status' => 'required' + 'invoice_status' => 'required', + 'short_code' => 'sometimes|numeric' ]); $auth_user = session('current_user'); @@ -356,6 +356,7 @@ class ClientsController extends Controller 'invoice_amount' => $request->invoice_amount, 'invoice_date' => $request->invoice_date, 'invoice_status' => $request->invoice_status, + 'short_code' => ($request->short_code) ? $request->short_code : "", 'services' => implode(',', $request->services), 'user_id' => $auth_user['id'], 'client_id' => $request->client_id @@ -363,7 +364,7 @@ class ClientsController extends Controller if ($request->has('remarks')) { $finance_arr['remarks'] = $request->remarks; } - + $result = Models\ClientPayment::create($finance_arr); #$payments = Models\ClientPayment::with('client_info', 'created_by_info')->find($result->id); @@ -394,19 +395,24 @@ class ClientsController extends Controller ]); $auth_user = session('current_user'); #$network = Models\NetworkOps::find($request->network); - + $mnoCountry = $this->getMnoCountry($request->network); + if ($mnoCountry == false) { + $data = ['code' => 3, 'msg' => 'Your request could not be handled at this time']; + return response()->json($data, 200); + } + /* $networks_raw = [ 'AirtelTigo GH' => 'AirtelTigo GH', 'MTN GH' => 'MTN GH', 'Airtel MW' => 'Airtel MW', - 'Airtel Zambia' => 'Airtel Zambia', - 'TNM MW' => 'TNM MW', + 'Airtel Zambia' => 'Airtel Zambia', + 'TNM MW' => 'TNM MW', 'Airtel MW' => 'Airtel MW', - 'Safaricom Kenya' => 'Safaricom Kenya', + 'Safaricom Kenya' => 'Safaricom Kenya', 'Airtel Kenya' => 'Airtel Kenya', - 'Telkom Kenya' => 'Telkom Kenya', + 'Telkom Kenya' => 'Telkom Kenya', 'Orange Kenya' => 'Orange Kenya' - ]; + ]; if (stripos($request->network, 'MW') !== false ) { $country = 'Malawi'; } @@ -426,16 +432,17 @@ class ClientsController extends Controller $data = ['code' => 3, 'msg' => 'Your request could not be handled at this time']; return response()->json($data, 200); } + */ $shortcode_arr = [ 'name' => $request->name, 'client_id' => $request->client_id, 'network' => $request->network, - 'country' => $country, //$network->country, + 'country' => $mnoCountry, //$network->country, 'shortcode' => $request->shortcode, 'code_type' => $request->code_type, 'toll_free' => $request->toll_free, - 'last_updaed_by' => $auth_user['id'], + 'last_updated_by' => $auth_user['id'], 'launch_date' => $request->launch_date, 'expiry_date' => $request->expiry_date, 'status' => $request->status @@ -443,7 +450,7 @@ class ClientsController extends Controller if ($request->has('remarks')) { $shortcode_arr['remarks'] = $request->remarks; } - + $result = Models\ClientShortCode::create($shortcode_arr); if ($result) { @@ -458,8 +465,7 @@ class ClientsController extends Controller $this->logUsersActivity($type = 'staff', $content); return response()->json($data, 200); } - public function financeUpdate(Request $request) - { + public function financeUpdate(Request $request){ $request->validate([ 'payment_id' => 'required', 'client_id' => 'required', @@ -491,14 +497,63 @@ class ClientsController extends Controller $this->logUsersActivity($type = 'staff', $content); return response()->json($data, 200); } + public function shortCodeUpdate(Request $request){ + $request->validate([ + 'client_id' => 'required', + 'network' => 'required', + 'shortcode' => 'required', + 'code_type' => 'required', + 'toll_free' => 'required', + 'status' => 'required', + 'remarks' => 'required', + 'launch_date' => 'required', + 'expiry_date' => 'required' + ]); + $auth_user = session('current_user'); + $mnoCountry = $this->getMnoCountry($request->network); + if ($mnoCountry == false) { + $data = ['code' => 3, 'msg' => 'Your request could not be handled at this time']; + return response()->json($data, 200); + // code... + } + $shortcode_arr = [ + 'name' => $request->name, + 'client_id' => $request->client_id, + 'network' => $request->network, + 'country' => $mnoCountry, //$network->country, + 'shortcode' => $request->shortcode, + 'code_type' => $request->code_type, + 'toll_free' => $request->toll_free, + 'last_updated_by' => $auth_user['id'], + 'launch_date' => $request->launch_date, + 'expiry_date' => $request->expiry_date, + 'status' => $request->status + ]; + if ($request->has('remarks')) { + $shortcode_arr['remarks'] = $request->remarks; + } + // $payment = Models\ClientShortCode::findOrFail($request->shortcode_id); + $result = Models\ClientShortCode::where('id', $request->shortcode_id)->update($shortcode_arr); + + if ($result) { + $data = ['code' => 1, 'msg' => 'Payment Details successfully updated']; + } + else{ + $data = ['code' => 3, 'msg' => 'Your request could not be handled at this time']; + } + $user_id = session('current_user.id'); + $username = session('current_user.name'); + $content = "User ID : " . $user_id . " (" . $username . ") updated short code enty"; + $this->logUsersActivity($type = 'staff', $content); + return response()->json($data, 200); + } /** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ - public function show($id) - { + public function show($id){ //with('short_code_info')-> $showclient = Models\Client::with('service_info', 'country_flag_info', 'auth_user_info', 'short_code_info')->find($id); // dd(json_decode($showclient->progress_indicators, true)); @@ -515,17 +570,17 @@ 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(); - //$networks_raw = ['AirtelTigo GH' => 'AirtelTigo GH','MTN GH' => 'MTN GH', 'Airtel MW' => 'Airtel MW', 'Airtel Zambia' => 'Airtel Zambia', 'TNM MW' => 'TNM MW', 'Airtel MW' => 'Airtel MW']; + //$networks_raw = ['AirtelTigo GH' => 'AirtelTigo GH','MTN GH' => 'MTN GH', 'Airtel MW' => 'Airtel MW', 'Airtel Zambia' => 'Airtel Zambia', 'TNM MW' => 'TNM MW', 'Airtel MW' => 'Airtel MW']; $networks_raw = [ 'AirtelTigo GH' => 'AirtelTigo GH', 'MTN GH' => 'MTN GH', 'Airtel MW' => 'Airtel MW', - 'Airtel Zambia' => 'Airtel Zambia', - 'TNM MW' => 'TNM MW', + 'Airtel Zambia' => 'Airtel Zambia', + 'TNM MW' => 'TNM MW', 'Airtel MW' => 'Airtel MW', - 'Safaricom Kenya' => 'Safaricom Kenya', + 'Safaricom Kenya' => 'Safaricom Kenya', 'Airtel Kenya' => 'Airtel Kenya', - 'Telkom Kenya' => 'Telkom Kenya', + 'Telkom Kenya' => 'Telkom Kenya', 'Orange Kenya' => 'Orange Kenya' ]; //->where('highlight', 'NO') @@ -568,27 +623,27 @@ class ClientsController extends Controller else{ $expiry_date = Carbon::parse($showclient->contract_validity); $current_date = Carbon::parse(date('Y-m-d')); - - $polar = ($expiry_date < $current_date) ? "-" : "+"; + + $polar = ($expiry_date < $current_date) ? "-" : "+"; $days = $expiry_date->diffInDays($current_date); if($days > 365){ if ($polar == '-') { $highlight_colour = 'warning'; $renewal_due = "Contract expired " . floor($days/365) . " year(s) ago"; - + } else{ - $renewal_due = "In " . floor($days/365) . " year(s)"; + $renewal_due = "In " . floor($days/365) . " year(s)"; } } elseif($days > 31){ if ($polar == '-') { $highlight_colour = 'warning'; $renewal_due = "Contract expired " . floor($days/31) . " month(s) ago"; - + } else{ - $renewal_due = "In " . floor($days/31) . " months"; + $renewal_due = "In " . floor($days/31) . " months"; } } else{ @@ -598,9 +653,9 @@ class ClientsController extends Controller $renewal_due = "Contract expired $days days(s) ago"; } else{ - $renewal_due = "In $days day(s)" ; + $renewal_due = "In $days day(s)" ; } - } + } } sort($networks_raw); @@ -629,14 +684,13 @@ class ClientsController extends Controller ]; return view('client.show', $data); } - public function showReadonly($id) - { + public function showReadonly($id){ //with('short_code_info')-> $showclient = Models\Client::with('service_info', 'country_info', 'auth_user_info', 'short_code_info')->find($id); $service_type = Models\Service::pluck('name', 'id'); $service_type_names = Models\Service::pluck('name', 'name'); $show_services = json_decode($showclient->services, true); //Models\ClientCategory::where('client_id', $id)->get(); - + //->where('highlight', 'NO') $show_notes = Models\ClientNote::with('created_by_info', 'client_info')->where('client_id', $id)->orderBy('id', 'DESC')->get()->take(20); $voice_codes = Models\ClientShortCode::where('client_id', $id)->where('code_type', 'voice')->get(); @@ -647,7 +701,7 @@ class ClientsController extends Controller $networks = Models\NetworkOps::pluck('name', 'name'); $all_shortcodes = Models\ClientShortCode::with('client_info', 'client_info', 'update_info')->where('client_id', $id)->orderBy('code_type', 'ASC')->get(); $showdocuments = Models\ClientFile::where('client_id', $id)->get(); - + if ($showclient->status == 'Live') { $status_bg = "info"; } @@ -665,18 +719,18 @@ class ClientsController extends Controller $renewal_due = "N/A"; } else{ - + $current_date = date_create(date('Y-m-d')); $expiry_date = date_create($showclient->contract_validity); $diff = date_diff($current_date, $expiry_date); - + $polar = $diff->format("%R"); - + $months = $diff->format("%m"); - + $days = $diff->format("%a"); if ($days < 31) { if ($polar == '-') { @@ -684,7 +738,7 @@ class ClientsController extends Controller $renewal_due = "Contract expired $days days(s) ago"; } else{ - $renewal_due = "In $days day(s)" ; + $renewal_due = "In $days day(s)" ; } } else{ @@ -692,12 +746,12 @@ class ClientsController extends Controller if ($polar == '-') { $highlight_colour = 'warning'; $renewal_due = "Contract expired $months month(s) ago"; - + } else{ - $renewal_due = "In $months months"; + $renewal_due = "In $months months"; } - } + } } $data = [ 'page_title' => 'Client Profile', @@ -738,8 +792,7 @@ class ClientsController extends Controller ]; return view('client.service-edit', $data); } - public function getPayment($id) - { + public function getPayment($id){ $payment = Models\ClientPayment::find($id); if ($payment) { $services_arr = explode(',', $payment->services); @@ -749,9 +802,17 @@ class ClientsController extends Controller else{ return response()->json([ 'code' => 3, 'msg' => 'Request could not be handled at this time']); } - } - + public function getShortCodeDetails($id){ + $shortcode = Models\ClientShortCode::with('client_info', 'update_info')->find($id); + if ($shortcode) { + $services_arr = Models\Service::pluck('name', 'id'); + return response()->json([ 'code' => 1, 'result' => $shortcode, 'services_arr' => $services_arr]); + } + else{ + return response()->json([ 'code' => 3, 'msg' => 'Request could not be handled at this time']); + } + } public function getShortCodes($type){ //$auth_users = Models\SystemUser::pluck('name', 'id'); //todo : separate the short codes into individual pages @@ -770,7 +831,7 @@ class ClientsController extends Controller break; } $codes = Models\ClientShortCode::with('update_info')->get(); - + $data = [ 'page_title' => 'Client Short Codes', 'codes_data' => $codes_data, @@ -789,7 +850,7 @@ class ClientsController extends Controller { $client = Models\Client::find($id); $service_type = Models\Service::orderBy('name', 'ASC')->pluck('name', 'name'); - + $countries = Models\Country::orderBy('en_short_name', 'ASC')->pluck('en_short_name','en_short_name'); $payment_type = ['Prepaid' => 'Prepaid', 'Postpaid' => 'Postpaid']; // Models\PaymentType::pluck('name', 'id')->toArray(); @@ -814,10 +875,10 @@ class ClientsController extends Controller // dump($stage_details); $onboarding_sub_items_progress = Models\ClientOnboardingProgress::where('stage_id', $stage_details->stage_id)->where('client_id', $id)->pluck('name', 'name'); // dd($onboarding_sub_items_progress); - $onboarding_sub_items = Models\ClientOnboardingSubItem::where('stage_id', $stage_details->stage_id)->pluck('name', 'name'); + $onboarding_sub_items = Models\ClientOnboardingSubItem::where('stage_id', $stage_details->stage_id)->pluck('name', 'name'); } - - + + /* else{ @@ -829,7 +890,7 @@ class ClientsController extends Controller } */ $how_we_got_clients_arr = ['Event : (GCCM) etc' => 'Event : (GCCM) etc', 'Referral' => 'Referral', 'Word of Mouth' => 'Word of Mouth', 'Marketing' => 'Marketing', 'Other' => 'Other']; - + // 'current_services' => json_decode($client->services, true); @@ -891,7 +952,7 @@ class ClientsController extends Controller $sender_ids = ['click' => 'click']; $old_sender_ids = []; } - + if ($client->status == 'Live') { $status_bg = "info"; @@ -902,10 +963,10 @@ class ClientsController extends Controller else{ $status_bg = "danger"; } - + $contract_types = ['Bilateral' => 'Bilateral', 'Unilateral' => 'Unilateral']; $connections = ['SMPP' => 'SMPP', 'HTTP' => 'HTTP']; - + $data = [ 'client' => $client, 'countries' => $countries, @@ -924,7 +985,7 @@ class ClientsController extends Controller 'rate_emails' => $rate_emails, 'support_skype_arr' => $support_skype_arr, 'support_phones' => $support_phones, - + 'old_finance_emails' => $old_finance_emails, 'old_rate_emails' => $old_rate_emails, 'old_support_emails' => $old_support_emails, @@ -938,7 +999,7 @@ class ClientsController extends Controller 'industries' => $industries, 'how_we_got_clients_arr' => $how_we_got_clients_arr, 'current_services' => json_decode($client->services, true), - + 'onboarding_sub_items_progress' => $onboarding_sub_items_progress, 'onboarding_sub_items' => $onboarding_sub_items, 'current_pending_stage' => $client->progress_indicator, @@ -956,21 +1017,21 @@ class ClientsController extends Controller */ public function update(Requests\UpdateClientRequest $request, $id) { - + $client_update = Models\Client::find($id); 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(); + $get_stage_subs_items = Models\ClientOnboardingSubItem::where('stage_id', $current_pending_stage_details->stage_id)->get(); #update the table for onboarding progress foreach ($request->onboarding_sub_items_progress as $value) { $stage_id = ['stage_id' => $current_pending_stage_details->stage_id, 'client_id' => $id, 'name' => $value ]; $progress_arr = [ - 'status' => 'COMPLETED' + 'status' => 'COMPLETED' ]; $clients_onboarding_progress = Models\ClientOnboardingProgress::updateOrCreate($stage_id, $progress_arr); } - //update the status of onboarding progress stage in clients + //update the status of onboarding progress stage in clients $get_stage_onboarding_status = Models\ClientOnboardingProgress::where('client_id', $id)->where('stage_id', $current_pending_stage_details->stage_id)->where('status', 'COMPLETED')->get(); // dd($get_stage_onboarding_status); $onboarding_progress_stage = json_decode($client_update->onboarding_progress_stage, true); @@ -979,11 +1040,11 @@ class ClientsController extends Controller if (count($get_stage_subs_items) == count($get_stage_onboarding_status)) { //check if all items have been completed and update $onboarding_progress_stage[$current_pending_stage_details->stage] = 'COMPLETED'; - } + } $pending_stage = Arr::where($onboarding_progress_stage, function ($value, $key) { return $value == "PENDING"; }); - + #$pending_stage = array_key_first($pending_stage); reset($pending_stage); $pending_stage = key($pending_stage); @@ -1006,7 +1067,7 @@ class ClientsController extends Controller $request->document_one->storeAs('client_files', $filename, 'public'); $document_arr['file_path'] = $filename; $client_update->name = $request->name; - + $document_arr['file_extension'] = $request->document_one->extension(); $document_arr['file_reff'] = time() . uniqid(); $document_arr['name'] = $request->document_one_name; @@ -1021,7 +1082,7 @@ class ClientsController extends Controller $request->document_two->storeAs('client_files', $filename, 'public'); $document_arr['file_path'] = $filename; $client_update->name = $request->name; - + $document_arr['file_extension'] = $request->document_two->extension(); $document_arr['file_reff'] = time() . uniqid(); $document_arr['name'] = $request->document_two_name; @@ -1036,7 +1097,7 @@ class ClientsController extends Controller $request->document_three->storeAs('client_files', $filename, 'public'); $document_arr['file_path'] = $filename; $client_update->name = $request->name; - + $document_arr['file_extension'] = $request->document_three->extension(); $document_arr['file_reff'] = time() . uniqid(); $document_arr['name'] = $request->document_three_name; @@ -1051,7 +1112,7 @@ class ClientsController extends Controller $request->other_document->storeAs('client_files', $filename, 'public'); $document_arr['file_path'] = $filename; $client_update->name = $request->name; - + $document_arr['file_extension'] = $request->other_document->extension(); $document_arr['file_reff'] = time() . uniqid(); $document_arr['name'] = $request->document_three_name; @@ -1074,14 +1135,14 @@ class ClientsController extends Controller #$client_update->progress_indicators = json_encode($request->onboarding_sub_items_progress); if ($client_update->progress_indicator != 'COMPLETED') { $client_update->onboarding_progress_stage = json_encode($onboarding_progress_stage); - + $progress_breakdown = array_count_values($onboarding_progress_stage); if (array_has($progress_breakdown, ['COMPLETED']) == false) { $indicator_score = "0"; } else{ - $indicator_score = ($progress_breakdown['COMPLETED']/count($onboarding_progress_stage)) * 100; - } + $indicator_score = ($progress_breakdown['COMPLETED']/count($onboarding_progress_stage)) * 100; + } $indicator_score = number_format($indicator_score); $client_update->progress_indicator_score = $indicator_score; @@ -1093,7 +1154,7 @@ class ClientsController extends Controller $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 ?? ""; @@ -1116,13 +1177,13 @@ class ClientsController extends Controller $client_update->how_we_got_client = $request->how_we_got_client_other ?? ""; } else{ - $client_update->how_we_got_client = $request->how_we_got_client ?? ""; + $client_update->how_we_got_client = $request->how_we_got_client ?? ""; } } - + $client_update->created_by = session('current_user.id'); - $client_update->last_modified_by = session('current_user.id'); + $client_update->last_modified_by = session('current_user.id'); $result = $client_update->save(); @@ -1162,7 +1223,7 @@ class ClientsController extends Controller public function store_services($services_arr, $client_id){ foreach ($services_arr as $id) { $client_arr = [ - 'client_id' => $client_id, + 'client_id' => $client_id, 'category_id' => $id ]; $result = Models\ClientCategory::create($client_arr); @@ -1175,7 +1236,7 @@ class ClientsController extends Controller foreach ($services_arr as $id) { $client_arr = [ - 'client_id' => $client_id, + 'client_id' => $client_id, 'category_id' => $id ]; $result = Models\ClientCategory::create($client_arr); @@ -1212,7 +1273,7 @@ class ClientsController extends Controller $client_file = Models\ClientFile::with('client_info')->findOrFail($id); //PDF file is stored under project/public/download/info.pdf $file = public_path('documents/client_files/') . $client_file->file_path; - + $headers = []; //['Content-Type: application/pdf']; $filename = $client_file->client_info->name . "_" . $client_file->name; $filename = $this->cleanStr($filename); @@ -1223,7 +1284,7 @@ class ClientsController extends Controller } public function showOnboardingForm($client_id){ $client = Models\Client::findOrFail($client_id); - + $onboarding_stages = Models\ClientOnboardingProgress::where('client_id', $client_id)->orderBy('stage_id')->get(); //dd($onboarding_stages); $data = [ @@ -1241,7 +1302,41 @@ class ClientsController extends Controller $string = preg_replace('/[^A-Za-z0-9\-]/', '', $string); // Replaces multiple hyphens with single one. $string = preg_replace('/-+/', '_', $string); - + return $string; } + + public function getMnoCountry($network){ + $networks_raw = [ + 'AirtelTigo GH' => 'AirtelTigo GH', + 'MTN GH' => 'MTN GH', + 'Airtel MW' => 'Airtel MW', + 'Airtel Zambia' => 'Airtel Zambia', + 'TNM MW' => 'TNM MW', + 'Airtel MW' => 'Airtel MW', + 'Safaricom Kenya' => 'Safaricom Kenya', + 'Airtel Kenya' => 'Airtel Kenya', + 'Telkom Kenya' => 'Telkom Kenya', + 'Orange Kenya' => 'Orange Kenya' + ]; + if (stripos($network, 'MW') !== false ) { + $country = 'Malawi'; + } + elseif (stripos($network, 'GH') !== false) { + $country = 'Ghana'; + } + elseif (stripos($network, 'Zambia') !== false) { + $country = 'Zambia'; + } + elseif (stripos($network, 'Bots') !== false) { + $country = 'Botswana'; + } + elseif (stripos($network, 'KE') !== false) { + $country = 'Kenya'; + } + else{ + $country = false; + } + return $country; + } } diff --git a/app/Http/Controllers/UtilityController.php b/app/Http/Controllers/UtilityController.php index ec0a74e..ec71c00 100644 --- a/app/Http/Controllers/UtilityController.php +++ b/app/Http/Controllers/UtilityController.php @@ -5,7 +5,7 @@ namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Models; -use Illuminate\Contracts\Mail\Mailer; +// use Illuminate\Contracts\Mail\Mailer; @@ -32,6 +32,11 @@ class UtilityController extends Controller return view('utility.map'); } + + public function showPage(){ + + return view('utility.arraylogic'); + } public function ntfyTest(){ $this->sendNtfy('In the ERP'); } diff --git a/app/Jobs/SendMnoContractRenewalEmailAlert.php b/app/Jobs/SendMnoContractRenewalEmailAlert.php index 7fe64f3..6116154 100644 --- a/app/Jobs/SendMnoContractRenewalEmailAlert.php +++ b/app/Jobs/SendMnoContractRenewalEmailAlert.php @@ -38,8 +38,6 @@ class SendMnoContractRenewalEmailAlert implements ShouldQueue 'mno_name' => $renewalSet['mno_name'], 'alert_body' => 'Contract for ' . $renewalSet['mno_name'] . ' will expire in ' . $renewalSet['days_to_expire'] . ' days. Take note' ]; - - \Log::info("Contract Renewal Alert triggered by : "); $mailer->send('emails.renewal-alert', $data, function ($message) use ($data, $emails) { $message->from('support@click-mobile.com', 'Click Mobile ERP'); $message->to($emails)->subject('Contract Renewal Alert'); diff --git a/public/assets/js/clientshow.js b/public/assets/js/clientshow.js index cf20611..baf6d15 100644 --- a/public/assets/js/clientshow.js +++ b/public/assets/js/clientshow.js @@ -11,10 +11,10 @@ var returnVal = confirm("Are you sure?"); $(this).prop("checked", returnVal); } - $('#textbox1').val(this.checked); + $('#textbox1').val(this.checked); }); */ - $('.progressIndicatorCheckbox').on('change', function() { + $('.progressIndicatorCheckbox').on('change', function() { // From the other examples // console.log('finker'); if (!this.checked) { @@ -45,7 +45,7 @@ evt.preventDefault(); $('#progressIndicatorDetailsModal').modal('show'); }); - + $('#createSmsShortCodeBtn').click(function(evt){ evt.preventDefault(); $('#shortCodeType').val('sms'); @@ -101,11 +101,56 @@ title: 'Alert!', content: 'Your request could not be handled. Try again !', }); - + } } }); - + + }); + + + $('.shortCodeEditBtn').click(function(tve){ + tve.preventDefault(); + var theIDD = $(this).siblings('.shortCodeEntryRowId').val(); + $.ajax({ + type: "GET", + url: base_url + '/clients/get_shortcode/' + theIDD, + processData: false, + contentType: false, + async: false, + success: function (data){ + if (data.code === 1) { + console.log(theIDD); + console.log(data); + $('#shortCodeIDEdit').val(theIDD); + $('#nameEdit').val(data.result.name); + $('#shortCodeClientIdEdit').val(data.result.client_id); + $('#shortCodeTypeEdit').val(data.result.code_type); + $('#shortCodeEdit').val(data.result.shortcode); + $('#tollFreeEdit').val(data.result.toll_free).change(); + $('#launchDateEdit').val(data.result.launch_date); + $('#expiryDateEdit').val(data.result.expiry_date); + $('#codeStatusEdit').val(data.result.status).change(); + $('#network').val(data.result.network).change(); + $('#remarksEdit').val(data.result.remarks); + $('#shortCodeEditModal').modal('show'); + } + else if (data.code > 1) { + $.alert({ + title: 'Alert!', + content: data.msg, + }); + } + else { + $.alert({ + title: 'Alert!', + content: 'Your request could not be handled. Try again !', + }); + + } + } + }); + }); @@ -143,17 +188,17 @@ title: 'Alert!', content: 'Your request could not be handled. Try again !', }); - + } } }); - + }); $('#newNotesFormForm').submit(function(evt){ - evt.preventDefault(); + evt.preventDefault(); var formData = new FormData($(this)[0]); $.ajax({ type: "POST", @@ -184,14 +229,14 @@ title: 'Alert!', content: 'Your request could not be handled. Try again !', }); - + } } - }); }); - + }); + $('#financeForm').submit(function(evt){ - evt.preventDefault(); + evt.preventDefault(); var formData = new FormData($(this)[0]); $.ajax({ type: "POST", @@ -222,7 +267,7 @@ title: 'Alert!', content: 'Your request could not be handled. Try again !', }); - + } }, error: function(error){ @@ -237,11 +282,26 @@ $('#financeNotifyArea').text(value[0]); }); } - }); + }); }); + $('#financeServicesStore').change(function(evtt){ + let currentServices = $('#financeServicesStore').val(); + $.each(currentServices, function (key, value) { + // console.log(value); + let short_code_services = ["USSD", "SMS Application", "IVR"]; + let checkArray = $.inArray(value, short_code_services) > -1; + // console.log(checkArray); + if (checkArray == true) { + $('#ShortCodeFormGrp').removeClass('hidden'); + } + else{ + $('#ShortCodeFormGrp').addClass('hidden'); + } + }); + }); $('#financeEditForm').submit(function(evt){ - evt.preventDefault(); + evt.preventDefault(); var formData = new FormData($(this)[0]); $.ajax({ type: "POST", @@ -271,14 +331,50 @@ title: 'Alert!', content: 'Your request could not be handled. Try again !', }); - + } } - }); + }); }); - + $('#shortCodeEditForm').submit(function(evt){ + evt.preventDefault(); + var formData = new FormData($(this)[0]); + $.ajax({ + type: "POST", + url: base_url + '/clients/shortcode_update', + data : formData, + processData: false, + contentType: false, + async: false, + success: function (data){ + if (data.code === 1) { + $.alert({ + title: 'Alert!', + content: 'Short Code Details successfully updated', + }); + setTimeout(function(){ + location.reload(); + }, 8000); + } + else if (data.code > 1) { + $.alert({ + title: 'Alert!', + content: data.msg, + }); + } + else { + $.alert({ + title: 'Alert!', + content: 'Your request could not be handled. Try again !', + }); + + } + } + }); + }); + $('#editNotesForm').submit(function(evt){ - evt.preventDefault(); + evt.preventDefault(); // console.log($(this).length); var formData = new FormData($(this)[0]); $.ajax({ @@ -309,14 +405,14 @@ title: 'Alert!', content: 'Your request could not be handled. Try again !', }); - + } } - }); + }); }); $('#shortCodeForm').submit(function(evt){ - evt.preventDefault(); + evt.preventDefault(); var formData = new FormData($(this)[0]); $.ajax({ type: "POST", @@ -346,7 +442,7 @@ title: 'Alert!', content: 'Your request could not be handled. Try again !', }); - + } }, error: function (data) { @@ -361,7 +457,7 @@ fail : function(errordata){ // console.log(errordata); } - }); + }); }); - }); \ No newline at end of file + }); diff --git a/resources/views/client/partials/edit-shortcodes.blade.php b/resources/views/client/partials/edit-shortcodes.blade.php new file mode 100644 index 0000000..5d97616 --- /dev/null +++ b/resources/views/client/partials/edit-shortcodes.blade.php @@ -0,0 +1,107 @@ + + diff --git a/resources/views/client/partials/finance.blade.php b/resources/views/client/partials/finance.blade.php index b9a8ad7..9f5d601 100644 --- a/resources/views/client/partials/finance.blade.php +++ b/resources/views/client/partials/finance.blade.php @@ -14,16 +14,23 @@ {{ csrf_field() }}
-
+
- - {!! Form::select('services[]', $service_type_names , old('services'), ['class' => 'form-control' , 'id' => 'financeServices', 'required' => 'required', 'multiple'=> 'true', 'style' => 'width: 100%']) !!} + + {!! Form::select('services[]', $service_type_names , old('services'), ['class' => 'form-control' , 'id' => 'financeServicesStore', 'required' => 'required', 'multiple'=> 'true', 'style' => 'width: 100%']) !!} +
+
+
- +
@@ -32,7 +39,7 @@
Enter Amount without commas
-
+
@@ -44,13 +51,13 @@
- -
+
+
{!! Form::select('invoice_status', [ 'PAID' => 'PAID', 'UNPAID' => 'UNPAID'] , old('services'), ['class' => 'form-control' , 'id' => 'invoiceStatus', 'required' => 'required', 'placeholder' => '', 'style' => 'width: 100%']) !!}
-
+
@@ -58,7 +65,7 @@
- +
diff --git a/resources/views/client/partials/sms-codes.blade.php b/resources/views/client/partials/sms-codes.blade.php index a2c67d9..96f7c5c 100644 --- a/resources/views/client/partials/sms-codes.blade.php +++ b/resources/views/client/partials/sms-codes.blade.php @@ -13,7 +13,7 @@ Renewal Date Action - + @@ -27,7 +27,7 @@ {{ $row->name }} {{ $row->shortcode }} {{ $row->network }} - {{ $row->toll_free }} + {{ $row->toll_free }} {{ $row->status }} {{ date('d-m-Y', strtotime($row->launch_date)) }} @@ -39,7 +39,8 @@ - + + @@ -48,4 +49,4 @@
-
\ No newline at end of file + diff --git a/resources/views/client/partials/ussd-codes.blade.php b/resources/views/client/partials/ussd-codes.blade.php index 51e0403..aae3f6f 100644 --- a/resources/views/client/partials/ussd-codes.blade.php +++ b/resources/views/client/partials/ussd-codes.blade.php @@ -14,7 +14,7 @@ Expiry Date Action - + @@ -28,21 +28,22 @@ {{ $row->name }} {{ $row->shortcode }} {{ $row->network }} - {{ $row->toll_free }} + {{ $row->toll_free }} {{ $row->status }} {{ date('d-m-Y', strtotime($row->launch_date)) }} - + @if($row->expiry_date == false) {{ "No found"}} @else {{ date('d-m-Y', strtotime($row->expiry_date)) }} - @endif + @endif - + - + + @@ -52,4 +53,4 @@ - \ No newline at end of file + diff --git a/resources/views/client/partials/voice-codes.blade.php b/resources/views/client/partials/voice-codes.blade.php index e299de8..39380b0 100644 --- a/resources/views/client/partials/voice-codes.blade.php +++ b/resources/views/client/partials/voice-codes.blade.php @@ -1,52 +1,53 @@
-
- - - - {{-- --}} - - - - - - - - - - - - - @if ($voice_codes->isEmpty()) - - - - @else - @foreach ($voice_codes as $row) - - - - - - - - - - - @endforeach - @endif - -
#NameCodeNetwork/CountryToll FreeStatusLaunch DateExpiry DateAction -
No Records found
{{ $row->name }}{{ $row->shortcode }}{{ $row->network }}{{ $row->toll_free }}{{ $row->status }}{{ date('d-m-Y', strtotime($row->launch_date)) }} - @if($row->expiry_date == false) - {{ "No found"}} - @else - {{ date('d-m-Y', strtotime($row->expiry_date)) }} - @endif - - - - - -
-
-
\ No newline at end of file +
+ + + + {{-- --}} + + + + + + + + + + + + + @if ($voice_codes->isEmpty()) + + + + @else + @foreach ($voice_codes as $row) + + + + + + + + + + + @endforeach + @endif + +
#NameCodeNetwork/CountryToll FreeStatusLaunch DateExpiry DateAction +
No Records found
{{ $row->name }}{{ $row->shortcode }}{{ $row->network }}{{ $row->toll_free }}{{ $row->status }}{{ date('d-m-Y', strtotime($row->launch_date)) }} + @if($row->expiry_date == false) + {{ "No found"}} + @else + {{ date('d-m-Y', strtotime($row->expiry_date)) }} + @endif + + + + + + +
+
+ diff --git a/resources/views/client/show.blade.php b/resources/views/client/show.blade.php index d57ba58..04baa6c 100755 --- a/resources/views/client/show.blade.php +++ b/resources/views/client/show.blade.php @@ -13,6 +13,7 @@ @include('client.partials.edit-notes') @include('client.partials.finance') @include('client.partials.create-shortcodes') +@include('client.partials.edit-shortcodes') @include('client.partials.edit-finance') @include('client.partials.progress_indicator_details') @@ -44,7 +45,7 @@
@if($showclient->country_flag_info !== null) - Generic Client Icon + Generic Client Icon @else Generic Client Icon @@ -76,7 +77,7 @@ count(); $i++) { ?> highlight == 'NO'): continue; endif; ?> - {{ $i+1 . "." }} {{ $show_notes[$i]->notes_body }} + {{ $i+1 . "." }} {{ $show_notes[$i]->notes_body }}

@@ -88,8 +89,8 @@ Onboarding Checklist @endif Full Details (Readonly) - -
+ +
+ -->
@@ -115,10 +116,10 @@
- - + +

Company Details

- +

Country : {{ $showclient->country or "N/A" }}

Company Type : {{ $showclient->company_type or "N/A" }}

@@ -135,12 +136,12 @@

SMPP Username : smpp_username) { echo $showclient->smpp_username; } else {echo "N/A"; } ?>

Message Types : - message_types) { + message_types) { $types_array = json_decode($showclient->message_types); - echo implode(', ', $types_array); - } + echo implode(', ', $types_array); + } else { - echo "N/A"; + echo "N/A"; } ?>

@@ -151,13 +152,13 @@

Support Phone(s)

@if(!empty($showclient->support_phones))
- support_phones, true) ?>
    - +
  • {{ $row }}
  • - +
@@ -167,13 +168,13 @@

Support Email(s)

@if(!empty($showclient->support_emails))
- support_emails, true) ?>
    - +
  • {{ $row }}
  • - +
@@ -183,13 +184,13 @@ @if(!empty($showclient->rate_emails))

Rates Email(s)

- rate_emails, true) ?>
    - +
  • {{ $row }}
  • - +
@@ -199,39 +200,39 @@

Finance Email(s)

@if(!empty($showclient->finance_email))
- finance_email, true) ?>
    - +
  • {{ $row }}
  • - +
@else - N/A + N/A @endif - +

Support Skype ID(s)

@if(!empty($showclient->support_skype))
- support_skype, true) ?>
    - +
  • {{ $row }}
  • - +
@else - N/A + N/A @endif -
+

How We Got This Client

how_we_got_client ?? "N/A" ?>
@@ -289,7 +290,7 @@
- +
    @if($show_notes->isEmpty())
  • No notes found
  • @@ -350,7 +351,7 @@ -@endsection \ No newline at end of file +@endsection diff --git a/resources/views/utility/arraylogic.blade.php b/resources/views/utility/arraylogic.blade.php new file mode 100644 index 0000000..ded23ea --- /dev/null +++ b/resources/views/utility/arraylogic.blade.php @@ -0,0 +1,166 @@ +@extends('layouts.master') + @section('page_title') + @if(isset($page_title)) + {{ $page_title }} + @endif + @endsection +@section('css') + + +@endsection +@section('content') +
    +
    +
    +
    + +
    +
    + +
    +
    +
    +
    + +
    + +
    +
    +
    +
    + +
    +
    + @include('commons.notifications') +
    +
    +
    +

    Testing

    +
    +
    + +
    +
    +
    +
    +
    +

    Transaction Summary Weekly progress

    +
    +
    + + December 30, 2014 - January 28, 2015 +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + Total Sessions +

    231,809

    + + + +
    +
    + Total Revenue +

    $231,809

    + + + +
    +
    + Total Sessions +

    231,809

    + + + +
    +
    + +
    + +
    +
    +
    +

    Top Profiles

    + +
    +
    + +
    +
    + +
    +
    +
    +
    + + +
    +
    +
    +
    +
    + +@endsection + +@section('javascript') + + + + +@endsection diff --git a/routes/web.php b/routes/web.php index 7a39855..2a63af0 100755 --- a/routes/web.php +++ b/routes/web.php @@ -22,12 +22,17 @@ Auth::routes(); Route::get('/home', 'HomeController@index')->name('home'); */ +// Route::post('testjs', 'UtilityController@showPage'); +// Route::get('/testjs', function () { + // return view('contacts'); + // return view('utility.arraylogic'); +// }); //Route::post('ipstore', 'NetworkOperatorsController@ipStore'); -Route::get('testemail', 'UtilityController@EmailTest'); -Route::get('testmno', 'ContractRenewalReminderController@getMnos'); -Route::get('ntfy', 'UtilityController@ntfyTest'); -Route::get('client-renewal', 'ClientContractRenewalAlertsController@getClientDetails'); +//Route::get('testemail', 'UtilityController@EmailTest'); +//Route::get('testmno', 'ContractRenewalReminderController@getMnos'); +//Route::get('ntfy', 'UtilityController@ntfyTest'); +//Route::get('client-renewal', 'ClientContractRenewalAlertsController@getClientDetails'); //insertOnboardingProgress @@ -94,8 +99,10 @@ Route::group(['middleware' => ['checklogin', 'checkcurrentlylogged']], function( Route::post('clients/notes_store', 'ClientsController@notesStore'); Route::post('clients/finance_store', 'ClientsController@financeStore'); Route::post('clients/finance_update', 'ClientsController@financeUpdate'); + Route::post('clients/shortcode_update', 'ClientsController@shortCodeUpdate'); Route::get('clients/get_payment/{id}', 'ClientsController@getPayment'); + Route::get('clients/get_shortcode/{id}', 'ClientsController@getShortCodeDetails'); Route::get('clients/get_note/{id}', 'ClientsController@getSingleNote'); Route::get('clients/create-notes', 'ClientsController@createNotes'); Route::get('clients/shortcodes/{type}', 'ClientsController@getShortCodes'); diff --git a/storage/laravel-2024-06-11.log b/storage/laravel-2024-06-11.log new file mode 100644 index 0000000..65e7f24 --- /dev/null +++ b/storage/laravel-2024-06-11.log @@ -0,0 +1 @@ +[2024-06-11 21:10:55] production.INFO: Kwesi Banson Successfully logged in at : 2024-06-11 21:10:55