note highlights, Notes Emails, client edit
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user