diff --git a/app/Http/Controllers/ClientsController.php b/app/Http/Controllers/ClientsController.php index 4c89f0e..494dacc 100755 --- a/app/Http/Controllers/ClientsController.php +++ b/app/Http/Controllers/ClientsController.php @@ -8,6 +8,7 @@ use Session; use Illuminate\Support\Arr; use App\Jobs\SendNewUssdClientEmail; use App\Jobs\SendUssdClientActiveEmail; +use App\Jobs\SendNewNotesEmailAlert; class ClientsController extends Controller @@ -236,10 +237,18 @@ class ClientsController extends Controller 'auth_user_id' => $auth_user['id'], 'client_id' => $request->client_id ]; + if ($request->has('highlight')) { + $notes_arr['highlight'] = 'YES'; + } + - //todo : send emails //dd($notes_arr); $result = Models\ClientNote::create($notes_arr); + + $notes = Models\ClientNote::with('client_info', 'created_by_info')->find($result->id); + //todo : send emails + //dispatch(new SendNewNotesEmailAlert($notes)); + if ($result) { $data = ['code' => 1, 'msg' => 'Notes successfully added']; } @@ -262,16 +271,29 @@ 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(); + //->where('highlight', 'NO') $show_notes = Models\ClientNote::with('created_by_info', 'client_info')->where('client_id', $id)->orderBy('id', 'DESC')->get()->take(20); - + + if ($showclient->status == 'Live') { + $status_bg = "info"; + } + elseif ($showclient->status == 'Prospective') { + $status_bg = "warning"; + } + else{ + $status_bg = "danger"; + } + + //dd($showclient->sender_ids); $data = [ - 'page_title' => 'Show Client', + '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' => $show_notes, + 'status_bg' => $status_bg ]; return view('client.show', $data); @@ -307,19 +329,40 @@ class ClientsController extends Controller { $client = Models\Client::find($id); - $service_type = Models\Service::pluck('name', 'id'); - // $payment_type = Models\PaymentType::pluck('name', 'id'); + $countries = Models\Country::pluck('en_short_name','en_short_name'); - $countries = Models\Country::pluck('en_short_name','alpha_2_code'); - - $payment_type = [1 => 'Prepaid', 2 => 'Postpaid']; // Models\PaymentType::pluck('name', 'id')->toArray(); + $payment_type = ['Prepaid' => 'Prepaid', 'Postpaid' => 'Postpaid']; // Models\PaymentType::pluck('name', 'id')->toArray(); $status = ['Live' => 'Live', 'inactive' => 'Inactive', 'Prospective' => 'Prospective']; $currency = Models\Currency::pluck('name', 'name'); // - // dd($currency); - $auth_users = Models\Account::pluck('name', 'id'); - // dump(array_flatten($client->client_services)); + $company_types = ['A2P Supplier' => 'A2P Supplier', 'A2P Consumer' => 'A2P Consumer', 'Hybrid' => 'Hybrid']; + $auth_users = Models\Account::pluck('name', 'id'); + // dd($client->sender_ids); + if ($client->sender_ids) { + $sender_ids = json_decode($client->sender_ids, true); + $sender_ids = array_combine($sender_ids, $sender_ids); + $old_sender_ids = json_decode($client->sender_ids, true); + } + else{ + $sender_ids = ['click' => 'click']; + $old_sender_ids = []; + } + + + if ($client->status == 'Live') { + $status_bg = "info"; + } + elseif ($client->status == 'Prospective') { + $status_bg = "warning"; + } + else{ + $status_bg = "danger"; + } + + $contract_types = ['bilateral' => 'bilateral', 'unilateral' => 'unilateral']; + $connections = ['SMPP' => 'SMPP', 'HTTP' => 'HTTP']; + $data = [ 'client' => $client, 'countries' => $countries, @@ -327,7 +370,14 @@ class ClientsController extends Controller 'payment_type' => $payment_type, 'status' => $status, 'auth_users' => $auth_users, - 'currency' => $currency + 'currency' => $currency, + 'page_title' => 'Update Client Details', + 'connections_arr' => $connections, + 'status_bg' => $status_bg, + 'sender_ids' => $sender_ids, + 'company_types' => $company_types, + 'old_sender_ids' => $old_sender_ids, + 'contract_types' => $contract_types ]; // dd($service_type->toArray()); return view('client.edit', $data); @@ -342,21 +392,24 @@ class ClientsController extends Controller */ public function update(Request $request, $id) { - + //Todo : work on the services and the sender IDs $request->validate([ 'name' => 'required', - // 'email' => 'required|email', - // 'services' => 'required', + 'email' => 'required|email', 'country' => 'required', 'status' => 'required', - // 'payment_mode' => 'required', 'currency' => 'required', + 'auth_user_id' => 'required' ]); $client_update = Models\Client::find($id); + //dump($request->status); + //dump(($request->sender_ids) ? json_encode($request->sender_ids) : ""); //dd($request->all()); + $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; @@ -365,6 +418,15 @@ class ClientsController extends Controller $client_update->notes = $request->notes; $client_update->skype_name = $request->skype_name; $client_update->linkedin_name = $request->linkedin_name; + + $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->smpp_details = $request->smpp_details ?? ""; + $client_update->sender_ids = ($request->sender_ids) ? json_encode($request->sender_ids) : ""; + $client_update->connections = ($request->connections) ? json_encode($request->connections) : ""; + $client_update->created_by = session('current_user.id'); $client_update->last_modified_by = session('current_user.id'); @@ -395,7 +457,7 @@ class ClientsController extends Controller Session::flash('success_message', 'Client successfully Updated'); - return redirect(url('clients')); + return redirect(url('clients', $id)); } /** diff --git a/app/Jobs/SendNewNotesEmailAlert.php b/app/Jobs/SendNewNotesEmailAlert.php new file mode 100644 index 0000000..6b8e99b --- /dev/null +++ b/app/Jobs/SendNewNotesEmailAlert.php @@ -0,0 +1,50 @@ +note = $note; + } + + /** + * Execute the job. + * + * @return void + */ + public function handle(Mailer $mailer) + { + $note = $this->note; + $emails = ['samuel@click-mobile.com']; + + //$note_body = $note->notes_body; + + + $data = [ + 'client' => $note->client_info->name, + 'created_by' => $note->created_by_info->name, + 'services' => $note->services, + 'notes_body' => $note->notes_body + ]; + $mailer->send('emails.new-notes', $data, function ($message) use ($data, $emails) { + $message->from('support@click-mobile.com', 'Click Mobile ERP'); + $message->to($emails)->subject('New Notes'); + }); + } +} diff --git a/resources/views/client/create.blade.php b/resources/views/client/create.blade.php index 4b20d66..d02fa65 100755 --- a/resources/views/client/create.blade.php +++ b/resources/views/client/create.blade.php @@ -44,6 +44,13 @@ {!! $errors->first('contact_person', '
:message
') !!} +:message
') !!} +:message
') !!} + + + +:message
') !!} +:message
') !!} +:message
') !!} +:message
') !!} +:message
') !!} +:message
') !!} +:message
') !!} +:message
') !!} +:message
') !!} +:message
') !!} +:message
') !!} +:message
') !!} +:message
') !!} +:message
') !!} ++ Live: + + Prospective: + + Inactive + +
+:message
') !!}:message
') !!}:message
') !!} +:message
') !!}:message
') !!}:message
') !!}:message
') !!} -:message
') !!}:message
') !!} -:message
') !!} -:message
') !!}:message
') !!} + + +:message
') !!}:message
') !!} +:message
') !!} +:message
') !!} +:message
') !!} +:message
') !!} +:message
') !!} +:message
') !!} +:message
') !!} +:message
') !!} ++ Live: + status == 'Live') ? "checked" : ""; ?> /> +
++ Prospective: + status == 'Prospective') ? "checked" : ""; ?> /> +
++ Inactive + status == 'Inactive') ? "checked" : ""; ?> /> +
+:message
') !!} +:message
') !!} +:message
') !!} +:message
') !!} +:message
') !!} +:message
') !!} +:message
') !!} +:message
') !!} +:message
') !!} +:message
') !!} +:message
') !!} ++ + count(); $i++) { ?> + + highlight == 'NO'): continue; endif; ?> + {{ $i+1 . "." }} {{ $show_notes[$i]->notes_body }} + + +
+Country :
-Company Type :
-Products
-Products Description
-Product Specification
-Networks
-Requested Sender IDs
- ++Country : {{ $showclient->country or "N/A" }}
+Company Type : {{ $showclient->company_type or "N/A" }}
+ + + + +Requested Sender IDs : sender_ids) { echo implode(", ", json_decode($showclient->sender_ids, true)); } else {echo "N/A"; } ?>
+
+Connection Types : connections) { echo implode(", ", json_decode($showclient->connections, true)); } else {echo "N/A"; } ?>
- Partner SMPP Details
- SMPP Categorisation
- SMPP Account Name
+Partner SMPP Details
+
+ smpp_details) { echo $showclient->smpp_details; } else {echo "N/A"; } ?>
+Contract Type : {{ ucfirst($showclient->contract_type) ?? 'N/A'}}
- Contract Validity : [------] - +
Contract Validity (years) : {{ $showclient->contract_validity or 'N/A'}}
+
+Last Invoice Sent : "N/A"
- Payment Status : Paid (2023-01-15) +Payment Status : N/A
+
+ + {{ $created_by }} has added a new note entry to the client details of {{ $client }}. +
+ + Notes Details +{{ $notes_body }}
+ +
+ Sincerely,
+ Click Mobile ERP
+