worked on the new onboarding steps
This commit is contained in:
@@ -10,6 +10,7 @@ use App\Jobs\SendNewUssdClientEmail;
|
||||
use App\Jobs\SendUssdClientActiveEmail;
|
||||
use App\Jobs\SendNewNotesEmailAlert;
|
||||
use App\Http\Requests;
|
||||
use Carbon\Carbon;
|
||||
|
||||
|
||||
class ClientsController extends Controller
|
||||
@@ -21,12 +22,16 @@ class ClientsController extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
/*
|
||||
$client = Models\Client::find(3);
|
||||
dd($client->client_services);
|
||||
|
||||
$client_arr = new Models\Client;
|
||||
$client_arr = $client_arr->with('auth_user_info','country_info', 'created_by_info')->orderBy('name', 'ASC')->paginate(15);
|
||||
*/
|
||||
$data = [
|
||||
'page_title' => 'Clients',
|
||||
'client_arr' => $client_arr,
|
||||
//'client_arr' => $client_arr,
|
||||
'current_user' => session('current_user')
|
||||
];
|
||||
return view('client.index-tabulator', $data);
|
||||
@@ -55,7 +60,7 @@ class ClientsController extends Controller
|
||||
->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')
|
||||
->select('clients.id', 'clients.name', 'clients.status','clients.progress_indicator', 'clients.country', 'aumngr.name As accountMgr', 'aumodify.name AS modifiedBy', 'flags.url AS theflag')
|
||||
->orderBy('name', 'ASC')
|
||||
->paginate(15);
|
||||
|
||||
@@ -65,8 +70,8 @@ class ClientsController extends Controller
|
||||
->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_indicators','clients.country', 'aumngr.name As accountMgr', 'aumodify.name AS modifiedBy', 'flags.url AS theflag')
|
||||
->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_indicators_score like '%$keyword%'")
|
||||
->select('clients.id','clients.name', 'clients.status', 'clients.progress_indicator','clients.country', 'aumngr.name As accountMgr', 'aumodify.name AS modifiedBy', 'flags.url AS theflag')
|
||||
->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 like '%$keyword%'")
|
||||
->orderBy('name', 'ASC')
|
||||
->paginate(15);
|
||||
}
|
||||
@@ -112,6 +117,8 @@ 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',
|
||||
'countries' => $countries,
|
||||
@@ -148,7 +155,13 @@ class ClientsController extends Controller
|
||||
'industry' => 'required',
|
||||
'auth_user_id' => 'required', // account manager
|
||||
]);
|
||||
|
||||
$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,
|
||||
@@ -158,7 +171,9 @@ class ClientsController extends Controller
|
||||
'currency' => $request->currency,
|
||||
'auth_user_id' => $request->auth_user_id, // account manager
|
||||
'created_by' => session('current_user.id'),
|
||||
'last_modified_by' => session('current_user.id')
|
||||
'last_modified_by' => session('current_user.id'),
|
||||
'progress_indicator_score' => 10,
|
||||
'onboarding_progress_stage' => json_encode($client_current_stages)
|
||||
];
|
||||
if ($request->has('notes')) {
|
||||
$client_arr['notes'] = $request->notes;
|
||||
@@ -474,7 +489,17 @@ class ClientsController extends Controller
|
||||
{
|
||||
//with('short_code_info')->
|
||||
$showclient = Models\Client::with('service_info', 'country_flag_info', 'auth_user_info', 'short_code_info')->find($id);
|
||||
// dd($showclient);
|
||||
// dd(json_decode($showclient->progress_indicators, true));
|
||||
/*
|
||||
"Initial talks\/ discussions",
|
||||
"Agreement Shared",
|
||||
"Agreement signed by one party (Click Mobile\/ Client)",
|
||||
"The agreement signed by both parties but interconnectivity has yet to begin",
|
||||
"Connectivity details pending on Click Mobile side.","Integration initiated"
|
||||
]
|
||||
*/
|
||||
|
||||
$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();
|
||||
@@ -511,6 +536,17 @@ class ClientsController extends Controller
|
||||
$status_bg = "danger";
|
||||
}
|
||||
|
||||
if ($showclient->progress_indicator_score >= 70) {
|
||||
$progress_status_bg = "success";
|
||||
}
|
||||
elseif ($showclient->progress_indicator_score >= 50 && $showclient->progress_indicator_score < 70) {
|
||||
$progress_status_bg = "warning";
|
||||
}
|
||||
else{
|
||||
$progress_status_bg = "danger";
|
||||
}
|
||||
|
||||
|
||||
$renewal_due = 'N/A';
|
||||
$highlight_colour = 'none';
|
||||
//review this later
|
||||
@@ -518,35 +554,40 @@ 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);
|
||||
$expiry_date = Carbon::parse($showclient->contract_validity);
|
||||
$current_date = Carbon::parse(date('Y-m-d'));
|
||||
|
||||
$polar = $diff->format("%R");
|
||||
|
||||
$months = $diff->format("%m");
|
||||
|
||||
$days = $diff->format("%a");
|
||||
if ($days < 31) {
|
||||
$polar = ($expiry_date < $current_date) ? "-" : "+";
|
||||
$days = $expiry_date->diffInDays($current_date);
|
||||
if($days > 365){
|
||||
if ($polar == '-') {
|
||||
$highlight_colour = 'warning';
|
||||
$renewal_due = "Contract expired $days days(s) ago";
|
||||
$renewal_due = "Contract expired " . floor($days/365) . " year(s) ago";
|
||||
|
||||
}
|
||||
else{
|
||||
$renewal_due = "In $days day(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{
|
||||
dump($days);
|
||||
$renewal_due = "In " . floor($days/31) . " months";
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
||||
if ($polar == '-') {
|
||||
$highlight_colour = 'warning';
|
||||
$renewal_due = "Contract expired $months month(s) ago";
|
||||
|
||||
$renewal_due = "Contract expired $days days(s) ago";
|
||||
}
|
||||
else{
|
||||
$renewal_due = "In $months months";
|
||||
$renewal_due = "In $days day(s)" ;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -560,11 +601,13 @@ class ClientsController extends Controller
|
||||
'service_type_names' => $service_type_names,
|
||||
'show_notes' => $show_notes,
|
||||
'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,
|
||||
@@ -667,12 +710,10 @@ class ClientsController extends Controller
|
||||
public function showservices($id)
|
||||
{
|
||||
$show_services = Models\ClientCategory::where('client_id', $id)->get();
|
||||
dd($show_services);
|
||||
$data = [
|
||||
'page_title' => 'Show Services',
|
||||
'show_services' => $show_services
|
||||
];
|
||||
|
||||
return view('client.services', $data);
|
||||
}
|
||||
public function editservice($id)
|
||||
@@ -742,9 +783,51 @@ class ClientsController extends Controller
|
||||
$auth_users = Models\SystemUser::orderBy('name', 'ASC')->pluck('name', 'id');
|
||||
$industries = Models\Industry::orderBy('name', 'ASC')->pluck('name', 'name');
|
||||
$message_types_arr = ['International' => 'International', 'Local' => 'Local'];
|
||||
$progress_indicators = Models\ClientIndicator::pluck('name', 'name');
|
||||
$current_progress_indicators = json_decode($client->progress_indicators, true);
|
||||
$onboarding_sub_items = [];
|
||||
$onboarding_sub_items_progress = [];
|
||||
$has_pending = false;
|
||||
|
||||
//This should not be false because onboarding_progress_stage is populated during client creation
|
||||
$onboarding_progress = json_decode($client->onboarding_progress_stage, 1);
|
||||
//
|
||||
$has_pending = in_array("PENDING", $onboarding_progress);
|
||||
if ($has_pending == true) {
|
||||
$pending_stage = Arr::where($onboarding_progress, function ($value, $key) {
|
||||
return $value == "PENDING";
|
||||
});
|
||||
$pending_stage = array_key_first($pending_stage);
|
||||
|
||||
$stage_details = Models\ClientOnboardingMainStage::where('stage', $pending_stage)->first();
|
||||
//get sub items
|
||||
//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');
|
||||
// dump($stage_details->stage_id);
|
||||
// dd($onboarding_sub_items);
|
||||
/*
|
||||
$onboarding_stages = Models\ClientOnboardingStage::where('client_id', $id)->where('status', 'PENDING')->groupBy('stage')->get();
|
||||
|
||||
$onboarding_stages = Models\ClientOnboardingProgress::where('client_id', $id)->where('status', 'PENDING')->orderBy('stage', 'ASC')->first();
|
||||
|
||||
*/
|
||||
#$progress_indicators = Models\ClientIndicator::pluck('name', 'name');
|
||||
#$current_progress_indicators = json_decode($client->progress_indicators, true);
|
||||
}
|
||||
else{
|
||||
$pending_stage = "COMPLETED";
|
||||
}
|
||||
|
||||
/*
|
||||
else{
|
||||
|
||||
$stage_details = Models\ClientOnboardingMainStage::where('stage_id', 1)->first();
|
||||
//get sub items
|
||||
// dd($stage_details);
|
||||
$onboarding_sub_items_progress = Models\ClientOnboardingProgress::where('stage_id', $stage_details->stage_id)->where('client_id', $id)->get();
|
||||
$onboarding_sub_items = Models\ClientOnboardingSubItem::where('stage_id', $stage_details->stage_id)->pluck('name', 'id');
|
||||
}
|
||||
*/
|
||||
$how_we_got_clients_arr = ['Event : (GCCM) etc' => 'Event : (GCCM) etc', 'Referral' => 'Referral', 'Word of Mouth' => 'Word of Mouth', 'Marketing' => 'Marketing', 'Other' => 'Other'];
|
||||
|
||||
|
||||
@@ -823,7 +906,6 @@ class ClientsController extends Controller
|
||||
$contract_types = ['Bilateral' => 'Bilateral', 'Unilateral' => 'Unilateral'];
|
||||
$connections = ['SMPP' => 'SMPP', 'HTTP' => 'HTTP'];
|
||||
|
||||
|
||||
$data = [
|
||||
'client' => $client,
|
||||
'countries' => $countries,
|
||||
@@ -856,9 +938,14 @@ class ClientsController extends Controller
|
||||
'industries' => $industries,
|
||||
'how_we_got_clients_arr' => $how_we_got_clients_arr,
|
||||
'current_services' => json_decode($client->services, true),
|
||||
'progress_indicators' => $progress_indicators,
|
||||
'current_progress_indicators' => $current_progress_indicators
|
||||
|
||||
'onboarding_sub_items_progress' => $onboarding_sub_items_progress,
|
||||
'onboarding_sub_items' => $onboarding_sub_items,
|
||||
'current_pending_stage' => $pending_stage,
|
||||
'has_pending' => $has_pending
|
||||
];
|
||||
// dd($data);
|
||||
|
||||
return view('client.edit', $data);
|
||||
}
|
||||
|
||||
@@ -883,10 +970,48 @@ class ClientsController extends Controller
|
||||
]);
|
||||
*/
|
||||
// dump($request->has('other_document_name'));
|
||||
// dd($request->all());
|
||||
// dump($request->all());
|
||||
$client_update = Models\Client::find($id);
|
||||
$progress_indicators_arr = json_encode($request->progress_indicators);
|
||||
// dd($progress_indicators_arr);
|
||||
$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();
|
||||
// dd($get_stage_subs_items);
|
||||
//$onboarding_sub_items_progress = Models\ClientOnboardingProgress::where('stage_id', $current_pending_stage_details->stage_id)->where('client_id', $id)->pluck('name', 'name');
|
||||
//$progress_indicators_arr = json_encode($request->progress_indicators);
|
||||
|
||||
#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'
|
||||
];
|
||||
$clients_onboarding_progress = Models\ClientOnboardingProgress::updateOrCreate($stage_id, $progress_arr);
|
||||
}
|
||||
|
||||
//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);
|
||||
|
||||
// dd(count($get_stage_subs_items) == count($get_stage_onboarding_status));
|
||||
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);
|
||||
if ($pending_stage == true) {
|
||||
$client_update->progress_indicator = $pending_stage;
|
||||
}
|
||||
else{
|
||||
$client_update->progress_indicator = 'COMPLETED';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($request->has('document_one') && $request->has('document_one_name')) {
|
||||
if ($request->file('document_one')->isValid()) {
|
||||
$filename = "erp_" . time() . str_random(6) . "." . $request->document_one->extension();
|
||||
@@ -958,14 +1083,15 @@ class ClientsController extends Controller
|
||||
$client_update->currency = $request->currency;
|
||||
$client_update->notes = $request->notes;
|
||||
$client_update->industry = $request->industry;
|
||||
$client_update->progress_indicators = $progress_indicators_arr;
|
||||
|
||||
#$client_update->progress_indicators = json_encode($request->onboarding_sub_items_progress);
|
||||
$client_update->onboarding_progress_stage = json_encode($onboarding_progress_stage);
|
||||
/*
|
||||
$general_indicators = Models\ClientIndicator::count();
|
||||
|
||||
$indicator_score = (count($request->progress_indicators)/$general_indicators) * 100;
|
||||
$indicator_score = number_format($indicator_score);
|
||||
// dd($indicator_score);
|
||||
$client_update->progress_indicator_score = $indicator_score;
|
||||
|
||||
*/
|
||||
$client_update->skype_name = $request->skype_name ?? "";
|
||||
$client_update->linkedin_name = $request->linkedin_name ?? "";
|
||||
$client_update->smpp_username = $request->smpp_username ?? "";
|
||||
@@ -1002,7 +1128,9 @@ class ClientsController extends Controller
|
||||
|
||||
$result = $client_update->save();
|
||||
|
||||
$client = Models\Client::find($id);
|
||||
|
||||
|
||||
#$client = Models\Client::find($id);
|
||||
/*
|
||||
if (in_array('3', $request->services)) {
|
||||
if ($request->status == 'active' && $client_update->status !== 'active') {
|
||||
@@ -1118,6 +1246,16 @@ class ClientsController extends Controller
|
||||
// $filename = str_replace(' ', '_', $filename);
|
||||
return \Response::download($file, $filename, $headers);
|
||||
}
|
||||
public function showOnboardingForm($client_id){
|
||||
$client = Models\Client::findOrFail($client_id);
|
||||
|
||||
|
||||
$data = [
|
||||
'page_title' => 'Clients | Onboarding Checklist',
|
||||
'client' => $client
|
||||
];
|
||||
return view('client.onboarding_show', $data);
|
||||
}
|
||||
public function cleanStr($string){
|
||||
// Replaces all spaces with hyphens.
|
||||
$string = str_replace(' ', '-', $string);
|
||||
|
||||
Reference in New Issue
Block a user