bug fixes on activity log and array_key_first alt using reset

This commit is contained in:
Kwesi Banson
2024-02-16 19:46:38 +00:00
parent d4ab479e0c
commit 7b3a29ca53
25 changed files with 579 additions and 160 deletions

View File

@@ -82,14 +82,14 @@ class ClientsController extends Controller
public function getClientJsonRawJs(Request $request){
#$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);
//$this->log_query();
$client_arr = \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')
->select('clients.id', 'clients.name', 'clients.status', 'clients.country', 'aumngr.name As accountMgr', 'aumodify.name AS modifiedBy')
->paginate(10);
if($request->has('keyword')){ // != ''
if($request->has('keyword')){
$keyword = $request->keyword;
$client_arr = \DB::table('clients')
->join('auth_users AS aumngr', 'aumngr.id', '=', 'clients.auth_user_id')
@@ -156,6 +156,7 @@ class ClientsController extends Controller
'industry' => 'required',
'auth_user_id' => 'required', // account manager
]);
$onboarding_stages = Models\ClientOnboardingMainStage::orderBy('stage_id')->get();
// dd($onboarding_stages);
$client_current_stages = [];
@@ -219,7 +220,8 @@ class ClientsController extends Controller
];
$clients_onboarding_progress = Models\ClientOnboardingProgress::create($progress_arr);
}
if (in_array('3', $request->services)) {
if (in_array('USSD', $request->services)) {
\Log::info('ussd client detected');
$ussd_client_payment_arr = [
'client_id' => $result->id,
@@ -263,7 +265,7 @@ class ClientsController extends Controller
//dd($notes_arr);
$result = Models\ClientNote::create($notes_arr);
// dd($result);
$notes = Models\ClientNote::with('client_info', 'created_by_info')->find($result->id);
//todo : send emails
dispatch(new SendNewNotesEmailAlert($notes));
@@ -606,6 +608,8 @@ class ClientsController extends Controller
}
sort($networks_raw);
$data = [
'page_title' => 'Client Profile',
'showclient' => $showclient,
@@ -752,26 +756,30 @@ class ClientsController extends Controller
}
public function getShortCodes(){
public function getShortCodes($type){
//$auth_users = Models\SystemUser::pluck('name', 'id');
$voice_codes = Models\ClientShortCode::with('client_info', 'client_info', 'update_info')->where('code_type', 'voice')->get();
$sms_codes = Models\ClientShortCode::with('client_info','client_info', 'update_info')->where('code_type', 'sms')->get();
$ussd_codes = Models\ClientShortCode::with('client_info', 'client_info', 'update_info')->where('code_type', 'ussd')->get();
//dd($voice_codes);
// dump($sms_codes[0]->last_updaed_by);
// dd($auth_users[$sms_codes[0]->last_updaed_by]);
//todo : separate the short codes into individual pages
switch ($type) {
case 'sms':
$codes_data = Models\ClientShortCode::with('client_info','client_info', 'update_info')->where('code_type', 'sms')->get();
break;
case 'ussd':
$codes_data = Models\ClientShortCode::with('client_info', 'client_info', 'update_info')->where('code_type', 'ussd')->get();
break;
case 'voice':
$codes_data = Models\ClientShortCode::with('client_info', 'client_info', 'update_info')->where('code_type', 'voice')->get();
break;
default:
// code... show 404
break;
}
$codes = Models\ClientShortCode::with('update_info')->get();
$data = [
'page_title' => 'Client Short Codes',
'voice_codes' => $voice_codes,
'sms_codes' => $sms_codes,
'ussd_codes' => $ussd_codes,
'codes_data' => $codes_data,
'type' => $type
];
// dd($data);
return view('client.shortcodes', $data);
}
/**
@@ -783,7 +791,6 @@ class ClientsController extends Controller
public function edit($id)
{
$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');
@@ -977,8 +984,11 @@ class ClientsController extends Controller
$pending_stage = Arr::where($onboarding_progress_stage, function ($value, $key) {
return $value == "PENDING";
});
$pending_stage = array_key_first($pending_stage);
#$pending_stage = array_key_first($pending_stage);
reset($pending_stage);
$pending_stage = key($pending_stage);
if ($pending_stage == true) {
//Pending Exist
$client_update->progress_indicator = $pending_stage;
@@ -1215,10 +1225,12 @@ 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 = [
'page_title' => 'Clients | Onboarding Checklist',
'client' => $client
'client' => $client,
'onboarding_stages' => $onboarding_stages
];
return view('client.onboarding_show', $data);
}