after a series of bug fixes plus Non MNO logic for Sender IDs, unfinished leave management and holiday modules

This commit is contained in:
Kwesi Banson Jnr
2025-03-19 10:33:04 +00:00
parent 6cede6d980
commit cf39ff2682
112 changed files with 26812 additions and 496 deletions

View File

@@ -10,6 +10,7 @@ use App\Jobs\SendNewUssdClientEmail;
use App\Jobs\SendUssdClientActiveEmail;
use App\Jobs\SendNewNotesEmailAlert;
use App\Jobs\SendOnboardingCompletedEmailAlert;
use App\Jobs\SendShortCodeListToFinance;
use App\Http\Requests;
use Carbon\Carbon;
use App\Libs\PaperLessNgx;
@@ -23,31 +24,8 @@ class ClientsController extends Controller
* @return \Illuminate\Http\Response
*/
public function index(){
/*
$currentuser = session('current_user.name');
$user_model = Models\SystemUser::find(session('current_user.id'));
#\Auth::user()->actions;
$actions = $user_model->actions;
dd($actions);
$clientModel = new Models\Client;
$currentuser = session('current_user.name');
$user_model = Models\SystemUser::find(session('current_user.id'));
activity()->performedOn($clientModel)
->causedBy($user_model)
->log($currentuser . ' Opened the Client Module at: ' . date('Y-m-d H:i:s'));
*/
// ->log('viewed');
/*
$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,
'current_user' => session('current_user')
];
return view('client.index-tabulator', $data);
@@ -62,22 +40,15 @@ class ClientsController extends Controller
return view('client.index-rawjs', $data);
}
public function getClientJson(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);
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')
->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')
->orderBy('name', 'ASC')
->paginate(15);
->get();
// ->paginate(15);
if($request->has('keyword')){
$keyword = $request->keyword;
@@ -88,7 +59,8 @@ class ClientsController extends Controller
->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')
->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);
->get();
// ->paginate(15);
}
return response()->json($client_arr);
@@ -133,7 +105,6 @@ class ClientsController extends Controller
$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,
@@ -274,10 +245,9 @@ class ClientsController extends Controller
$notes_arr['highlight'] = 'YES';
}
//dd($notes_arr);
$result = Models\ClientNote::create($notes_arr);
$result = Models\ClientNote::updateOrCreate(['services' => $request->services, 'client_id' => $request->client_id, 'auth_user_id' => $auth_user['id'] ], $notes_arr);
// dd($result);
$client = Models\Client::find($request->client_id);
$notes = Models\ClientNote::with('client_info', 'created_by_info')->find($result->id);
//todo : send emails
dispatch(new SendNewNotesEmailAlert($notes));
@@ -290,7 +260,7 @@ class ClientsController extends Controller
}
$user_id = session('current_user.id');
$username = session('current_user.name');
$content = "User ID : " . $user_id . " (" . $username . ") Added a new Note";
$content = "User ID : " . $user_id . " (" . $username . ") Added a new Note for : " . $client->name;
$this->logUsersActivity($type = 'staff', $content);
return response()->json($data, 200);
}
@@ -360,9 +330,7 @@ class ClientsController extends Controller
// 'short_code' => 'sometimes|numeric'
]);
$auth_user = session('current_user');
// dump($request->has('short_code'));
//dd($request->all());
// dump($request->short_code);
if ($request->short_code !== null) {
$check = is_numeric($request->short_code);
if ($check == false) {
@@ -370,7 +338,7 @@ class ClientsController extends Controller
return response()->json($data, 200);
}
}
// dd($request->all());
$finance_arr = [
'invoice_number' => $request->invoice_number,
'invoice_amount' => $request->invoice_amount,
@@ -384,8 +352,15 @@ class ClientsController extends Controller
if ($request->has('remarks')) {
$finance_arr['remarks'] = $request->remarks;
}
// dd($finance_arr);
$result = Models\ClientPayment::create($finance_arr);
$client = Models\Client::find($request->client_id);
$result = Models\ClientPayment::updateOrCreate(['invoice_number' => $request->invoice_number, 'client_id' => $request->client_id, ], $finance_arr);
if ($request->has('short_code')) {
$short_code_list = Models\ClientShortCode::where('client_id', $request->client_id)->get();
$client = Models\Client::find($request->client_id);
$message_body = $auth_user['name'] . " has added a new Short Code ($request->short_code) Payment entry for " . $client->name;
dispatch(new SendShortCodeListToFinance($short_code_list, $message_body, $finance_arr));
}
#$payments = Models\ClientPayment::with('client_info', 'created_by_info')->find($result->id);
if ($result) {
@@ -396,7 +371,7 @@ class ClientsController extends Controller
}
$user_id = session('current_user.id');
$username = session('current_user.name');
$content = "User ID : " . $user_id . " (" . $username . ") Added a payment record";
$content = "User ID : " . $user_id . " (" . $username . ") Added a payment record for : " . $client->name;
$this->logUsersActivity($type = 'staff', $content);
return response()->json($data, 200);
}
@@ -427,7 +402,7 @@ class ClientsController extends Controller
$support_fees_arr['remarks'] = $request->remarks;
}
$result = Models\ClientSupportFees::create($support_fees_arr);
$client = Models\Client::find($request->client_id);
#$payments = Models\ClientPayment::with('client_info', 'created_by_info')->find($result->id);
if ($result) {
$data = ['code' => 1, 'msg' => 'Support Fees Details successfully added'];
@@ -437,7 +412,7 @@ class ClientsController extends Controller
}
$user_id = session('current_user.id');
$username = session('current_user.name');
$content = "User ID : " . $user_id . " (" . $username . ") Added a support fees record";
$content = "User ID : " . $user_id . " (" . $username . ") Added a support fees record for : " . $client->name;
$this->logUsersActivity($type = 'staff', $content);
return response()->json($data, 200);
}
@@ -451,15 +426,17 @@ class ClientsController extends Controller
'status' => 'required',
'remarks' => 'required',
'launch_date' => 'required',
'expiry_date' => 'required'
'expiry_date' => 'required',
'monthly_fee' => 'sometimes'
]);
// dd($request->all());
$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);
}
// $mnoCountry = $this->getMNO($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',
@@ -498,7 +475,7 @@ class ClientsController extends Controller
'name' => $request->name,
'client_id' => $request->client_id,
'network' => $request->network,
'country' => $mnoCountry, //$network->country,
// 'country' => $mnoCountry, //$network->country,
'shortcode' => $request->shortcode,
'code_type' => $request->code_type,
'toll_free' => $request->toll_free,
@@ -506,13 +483,19 @@ class ClientsController extends Controller
'launch_date' => $request->launch_date,
'expiry_date' => $request->expiry_date,
'status' => $request->status
];
// dd($shortcode_arr);
if ($request->has('remarks')) {
$shortcode_arr['remarks'] = $request->remarks;
}
if ($request->has('monthly_fee')) {
$shortcode_arr['monthly_fee'] = $request->monthly_fee;
}
$result = Models\ClientShortCode::create($shortcode_arr);
$client = Models\Client::find($request->client_id);
if ($result) {
$data = ['code' => 1, 'msg' => 'ShortCode Details successfully added'];
}
@@ -521,7 +504,7 @@ class ClientsController extends Controller
}
$user_id = session('current_user.id');
$username = session('current_user.name');
$content = "User ID : " . $user_id . " (" . $username . ") Added new short code";
$content = "User ID : " . $user_id . " (" . $username . ") Added new short code for " . $client->name;
$this->logUsersActivity($type = 'staff', $content);
return response()->json($data, 200);
}
@@ -535,6 +518,7 @@ class ClientsController extends Controller
'invoice_date' => 'required',
'invoice_status' => 'required'
]);
$auth_user = session('current_user');
$payment = Models\ClientPayment::findOrFail($request->payment_id);
@@ -542,9 +526,31 @@ class ClientsController extends Controller
$payment->invoice_amount = $request->invoice_amount;
$payment->invoice_date = $request->invoice_date;
$payment->invoice_status = $request->invoice_status;
$payment->short_code = ($request->short_code) ? $request->short_code : "";
$payment->services = implode(',', $request->services);
$result = $payment->save();
$client = Models\Client::find($request->client_id);
if ($request->has('short_code')) {
$short_code_list = Models\ClientShortCode::where('client_id', $request->client_id)->get();
$finance_arr = [
'invoice_number' => $request->invoice_number,
'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
];
if ($request->has('remarks')) {
$finance_arr['remarks'] = $request->remarks;
}
$message_body = $auth_user['name'] . " has updated a Short Code ($request->short_code) Payment entry for " . $client->name;
#dispatch(new SendShortCodeListToFinance($short_code_list, $message_body, $finance_arr));
}
if ($result) {
$data = ['code' => 1, 'msg' => 'Payment Details successfully updated'];
}
@@ -553,8 +559,11 @@ class ClientsController extends Controller
}
$user_id = session('current_user.id');
$username = session('current_user.name');
$content = "User ID : " . $user_id . " (" . $username . ") updated an existing payment record";
$content = "User ID : " . $user_id . " (" . $username . ") updated an existing payment record for " . $client->name;
$this->logUsersActivity($type = 'staff', $content);
return response()->json($data, 200);
}
public function shortCodeUpdate(Request $request){
@@ -564,6 +573,7 @@ class ClientsController extends Controller
'shortcode' => 'required',
'code_type' => 'required',
'toll_free' => 'required',
'monthly_fee' => 'sometimes',
'status' => 'required',
'remarks' => 'required',
'launch_date' => 'required',
@@ -592,18 +602,21 @@ class ClientsController extends Controller
if ($request->has('remarks')) {
$shortcode_arr['remarks'] = $request->remarks;
}
if ($request->has('monthly_fee')) {
$shortcode_arr['monthly_fee'] = $request->monthly_fee;
}
// $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'];
$data = ['code' => 1, 'msg' => 'Short Code 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";
$content = "User ID : " . $user_id . " (" . $username . ") updated short code enty for " . $request->short_code;
$this->logUsersActivity($type = 'staff', $content);
return response()->json($data, 200);
}
@@ -614,7 +627,6 @@ class ClientsController extends Controller
* @return \Illuminate\Http\Response
*/
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);
//$clientModel = new Models\Client;
/*
@@ -639,6 +651,12 @@ class ClientsController extends Controller
$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_two = Models\NetworkOps::pluck('country', 'id');
// dd($networks_raw_two);
$country_networks = \DB::table('network_operators')->Select(\DB::raw('id, concat(name, " (", country, ")") AS network'))->orderBy('network')->pluck('network', 'network');
// $country_networks = \DB::table('network_operators')->Select(\DB::raw('concat(name, " (", country, ")") AS network)')->orderBy('network')->get()->toArray();
// $country_networks = \DB::table('network_operators')->Select(\DB::raw('concat(name, " (", country, ")") AS network)'))->pluck('network', 'network');
$networks_raw = [
'AirtelTigo GH' => 'AirtelTigo GH',
'MTN GH' => 'MTN GH',
@@ -652,12 +670,16 @@ class ClientsController extends Controller
'Orange Kenya' => 'Orange Kenya'
];
//->where('highlight', 'NO')
$show_notes = Models\ClientNote::with('created_by_info', 'client_info')->where('client_id', $id)->orderBy('id', 'DESC')->get()->take(20);
$show_notes = Models\ClientNote::with('created_by_info', 'client_info')->where('client_id', $id)->orderBy('created_at', 'DESC')->get()->take(20);
$show_notes_highlight = Models\ClientNote::with('created_by_info', 'client_info')->where('client_id', $id)->where('highlight', 'YES')->orderBy('created_at', 'DESC')->get()->take(1);
$voice_codes = Models\ClientShortCode::where('client_id', $id)->where('code_type', 'voice')->get();
$sms_codes = Models\ClientShortCode::where('client_id', $id)->where('code_type', 'sms')->get();
$ussd_codes = Models\ClientShortCode::where('client_id', $id)->where('code_type', 'ussd')->get();
$recent_payments = Models\ClientPayment::where('client_id', $id)->orderBy('id', 'DESC')->get();
$countries = Models\Country::pluck('en_short_name','en_short_name');
// dd($countries);
$networks = Models\NetworkOps::pluck('name', 'id');
$support_fees = Models\ClientSupportFees::where('client_id', $id)->orderBy('id', 'DESC')->get();
@@ -739,6 +761,7 @@ class ClientsController extends Controller
'service_type' => $service_type,
'service_type_names' => $service_type_names,
'show_notes' => $show_notes,
'show_notes_highlight' => $show_notes_highlight,
'status_bg' => $status_bg,
'progress_status_bg' => $progress_status_bg,
'voice_codes' => $voice_codes,
@@ -755,13 +778,17 @@ class ClientsController extends Controller
'support_fees' => $support_fees,
'recurring_arr' => $recurring_arr,
'client_sender_ids' => $client_sender_ids,
'sender_id_statuses' => $sender_id_statuses
'sender_id_statuses' => $sender_id_statuses,
'country_network_arr' => $country_networks,
'mnos_arr' => ['' => '-- Select Country first --']
];
// dump($client_sender_ids);
// foreach ($client_sender_ids as $value) {
// dd($value->network_info->name);
// }
return view('client.show', $data);
// dd($data);
// return view('client.show_original_copy', $data);
return view('client.show_test', $data);
}
public function showReadonly($id){
@@ -1109,7 +1136,7 @@ class ClientsController extends Controller
* @return \Illuminate\Http\Response
*/
public function update(Requests\UpdateClientRequest $request, $id){
// dump($request->all());
// dd($request->all());
// \DB::connection()->enableQueryLog();
$client_update = Models\Client::find($id);
$paperless = new PaperLessNgx();
@@ -1155,25 +1182,25 @@ class ClientsController extends Controller
dispatch(new SendOnboardingCompletedEmailAlert($client));
}
}
$existing_documents = Models\ClientFile::where('client_id', $id)->get();
if ($request->has('document_one') && $request->has('document_one_name')) {
if ($request->file('document_one')->isValid()) {
$filename = "erp_" . time() . str_random(4) . "." . $request->document_one->extension();
$filename = "erp_" . time() . str_random(4) . "." . $request->document_one->extension();
$request->document_one->storeAs('client_files', $filename, 'public');
$document_arr['file_path'] = $filename;
$client_update->name = $request->name;
$store_location = "client_files";
$top = $paperless->processPaperlessFile($request->document_one_name, $request->document_one_name, $filename, $store_location);
#$top = $paperless->processPaperlessFile($request->document_one_name, $request->document_one_name, $filename, $store_location);
$document_arr['file_extension'] = $request->document_one->extension();
$document_arr['file_reff'] = time() . uniqid();
$document_arr['name'] = $request->document_one_name;
$document_arr['created_by'] = session('current_user.id');
//$document_arr['client_id'] = $id;
$result = Models\ClientFile::create($document_arr, ['client_id' => $id]);
//$document_arr,
// $result = Models\ClientNote::updateOrCreate(['services' => $request->services, 'client_id' => $request->client_id, 'auth_user_id' => $auth_user['id'] ], $notes_arr);
$result = Models\ClientFile::updateOrCreate(['client_id' => $id, 'name' => $request->document_one_name], $document_arr);
}
}
if ($request->has('document_two') && $request->has('document_two_name')) {
@@ -1183,7 +1210,7 @@ class ClientsController extends Controller
$document_arr['file_path'] = $filename;
$client_update->name = $request->name;
$store_location = "client_files";
$top = $paperless->processPaperlessFile($request->document_two_name, $request->document_two_name, $filename, $store_location);
#$top = $paperless->processPaperlessFile($request->document_two_name, $request->document_two_name, $filename, $store_location);
$document_arr['file_extension'] = $request->document_two->extension();
@@ -1193,7 +1220,7 @@ class ClientsController extends Controller
$document_arr['client_id'] = $id;
// $result = Models\ClientFile::create($document_arr);
//$document_arr['client_id'] = $id;
$result = Models\ClientFile::create($document_arr, ['client_id' => $id]);
$result = Models\ClientFile::updateOrCreate(['client_id' => $id, 'name' => $request->document_two_name], $document_arr);
}
}
if ($request->has('document_three') && $request->has('document_three_name')) {
@@ -1204,7 +1231,7 @@ class ClientsController extends Controller
$client_update->name = $request->name;
$store_location = "client_files";
$top = $paperless->processPaperlessFile($request->document_three_name, $request->document_three_name, $filename, $store_location);
#$top = $paperless->processPaperlessFile($request->document_three_name, $request->document_three_name, $filename, $store_location);
$document_arr['file_extension'] = $request->document_three->extension();
$document_arr['file_reff'] = time() . uniqid();
@@ -1213,7 +1240,7 @@ class ClientsController extends Controller
$document_arr['client_id'] = $id;
// $result = Models\ClientFile::create($document_arr);
//$document_arr['client_id'] = $id;
$result = Models\ClientFile::create($document_arr, ['client_id' => $id]);
$result = Models\ClientFile::updateOrCreate(['client_id' => $id, 'name' => $request->document_three_name], $document_arr);
}
}
if ($request->has('other_document') && $request->has('other_document_name')) {
@@ -1224,19 +1251,18 @@ class ClientsController extends Controller
$client_update->name = $request->name;
$store_location = "client_files";
$top = $paperless->processPaperlessFile($request->other_document_name, $request->other_document_name, $filename, $store_location);
#$top = $paperless->processPaperlessFile($request->other_document_name, $request->other_document_name, $filename, $store_location);
$document_arr['file_extension'] = $request->other_document->extension();
$document_arr['file_reff'] = time() . uniqid();
$document_arr['name'] = $request->document_three_name;
$document_arr['name'] = ($request->other_document_name == null) ? 'Other Document' : $request->other_document_name;
$document_arr['created_by'] = session('current_user.id');
$document_arr['client_id'] = $id;
$result = Models\ClientFile::create($document_arr);
// dd($document_arr);
$result = Models\ClientFile::updateOrCreate(['client_id' => $id, 'name' => $request->other_document_name], $document_arr);
}
}
$client_update->name = $request->name;
$client_update->email = $request->email;
$client_update->phone = $request->phone ?? "";
@@ -1363,16 +1389,15 @@ class ClientsController extends Controller
return true;
}
public function storeFiles(AddFilesRequest $request){
$document_arr = $request->except('document');
if ($request->hasFile('document')) {
if ($request->file('document')->isValid()) {
$filename = "erp_" . time() . "." . $request->document->extension();
$filename = "erp_" . time() . "." . $request->document->extension();
$request->document->storeAs('client_files', $filename, 'public');
$document_arr['document'] = json_encode([$filename]);
}
}
$client = Models\Client::find($request->client_id);
$document_arr['file_extension'] = $request->document->extension();
$document_arr['file_reff'] = time() . uniqid();
$document_arr['last_modified_by'] = session('current_user.id');
@@ -1385,11 +1410,16 @@ class ClientsController extends Controller
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 . ") Document successfully uploaded for " . $client->name;
$this->logUsersActivity($type = 'staff', $content);
return response()->json($data, 200);
}
public function getClientFile($id){
$client_file = Models\ClientFile::with('client_info')->findOrFail($id);
// dd($client_file);
//PDF file is stored under project/public/download/info.pdf
$file = public_path('documents/client_files/') . $client_file->file_path;
@@ -1425,6 +1455,12 @@ class ClientsController extends Controller
return $string;
}
public function getMNO($id){
$mno = Models\NetworkOps::find($id);
return $mno;
}
public function getMnoCountry($network){
$networks_raw = [
'AirtelTigo GH' => 'AirtelTigo GH',

View File

@@ -71,11 +71,14 @@ class ContractRenewalReminderController extends Controller
break;
}
}
if ($difference->days <= 10) {
$renew_ready['client_name'] = $value->client_info->name;
$renew_ready['account_manager_email'] = $value->created_by_info->email;
$renew_ready['days_to_renew'] = $difference->days;
dispatch(new SendSupportFeesReminderEmailAlert($renew_ready));
if (isset($difference)) {
//will review this later
if ($difference->days <= 10) {
$renew_ready['client_name'] = $value->client_info->name;
$renew_ready['account_manager_email'] = $value->created_by_info->email;
$renew_ready['days_to_renew'] = $difference->days;
dispatch(new SendSupportFeesReminderEmailAlert($renew_ready));
}
}
\Log::info('Support Fees Reminder schedule has successfully ran ');
if (count($renew_ready) > 0) {

View File

@@ -140,7 +140,7 @@ class GeneralDocumentsController extends Controller
#sendToPaperLess
$store_location = "general_files";
$top = $paperless->processPaperlessFile($request->document_one_name, $request->document_one_category, $filename, $store_location);
#$top = $paperless->processPaperlessFile($request->document_one_name, $request->document_one_category, $filename, $store_location);
$document_arr['file_extension'] = $request->document_one->extension();
$document_arr['file_reff'] = time() . uniqid();
@@ -158,7 +158,7 @@ class GeneralDocumentsController extends Controller
#sendToPaperLess
$store_location = "general_files";
$top = $paperless->processPaperlessFile($request->document_two_name, $request->document_two_category, $filename, $store_location);
#$top = $paperless->processPaperlessFile($request->document_two_name, $request->document_two_category, $filename, $store_location);
$document_arr['file_extension'] = $request->document_two->extension();
$document_arr['file_reff'] = time() . uniqid();
@@ -176,7 +176,7 @@ class GeneralDocumentsController extends Controller
#sendToPaperLess
$store_location = "general_files";
$top = $paperless->processPaperlessFile($request->document_three_name, $request->document_three_category, $filename, $store_location);
#$top = $paperless->processPaperlessFile($request->document_three_name, $request->document_three_category, $filename, $store_location);
$document_arr['file_extension'] = $request->document_three->extension();
$document_arr['file_reff'] = time() . uniqid();

View File

@@ -0,0 +1,13 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class HolidaysController extends Controller
{
protected $guarded = array('id');
public $table = "holidays";
}

View File

@@ -0,0 +1,10 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class LeaveManagementController extends Controller
{
//
}

View File

@@ -87,6 +87,17 @@ class NetworkOperatorsController extends Controller
}
return response()->json($mno_arr);
}
public function getCountryNetworks(Request $request){
$mno_arr = Models\NetworkOps::where('country', $request->country)->pluck('name', 'id');
// dd(count($mno_arr));
if (count($mno_arr) == 0) {
$data = ['code' => '2', 'msg' => 'No MNOs found in the selected country'];
}
else{
$data = ['code' => '1', 'mnos' => $mno_arr,];
}
return response()->json($data);
}
/**
* Show the form for creating a new resource.
@@ -388,7 +399,7 @@ class NetworkOperatorsController extends Controller
$operator_update->name = $request->name;
$store_location = "mno_files";
$top = $paperless->processPaperlessFile($request->document_one_name, $request->document_one_category, $filename, $store_location);
#$top = $paperless->processPaperlessFile($request->document_one_name, $request->document_one_category, $filename, $store_location);
$document_arr['file_extension'] = $request->document_one->extension();
$document_arr['file_reff'] = time() . uniqid();
@@ -406,7 +417,7 @@ class NetworkOperatorsController extends Controller
$operator_update->name = $request->name;
$store_location = "mno_files";
$top = $paperless->processPaperlessFile($request->document_two_name, $request->document_two_category, $filename, $store_location);
#$top = $paperless->processPaperlessFile($request->document_two_name, $request->document_two_category, $filename, $store_location);
$document_arr['file_extension'] = $request->document_two->extension();
$document_arr['file_reff'] = time() . uniqid();
@@ -424,7 +435,7 @@ class NetworkOperatorsController extends Controller
// $operator_update->name = $request->name;
$store_location = "mno_files";
$top = $paperless->processPaperlessFile("sliding_rate", 'rates', $filename, $store_location);
#$top = $paperless->processPaperlessFile("sliding_rate", 'rates', $filename, $store_location);
$document_arr['file_extension'] = $request->sliding_rate_file->extension();

View File

@@ -15,8 +15,38 @@ use Carbon\Carbon;
class ReportsController extends Controller
{
class ReportsController extends Controller{
public function overview(){
$document_arr = \DB::table('general_documents')
->select(\DB::raw('count(*) as docs_count, category'))
->groupBy('category')
->get();
$client_docs = \DB::table('client_files')
->join('clients', 'clients.id', '=', 'client_files.client_id')
->select(\DB::raw('count(*) as docs_count, clients.name, client_files.client_id'))
->groupBy('clients.name', 'client_files.client_id')
->get();
$mno_docs = \DB::table('mno_files')
->join('network_operators', 'network_operators.id', '=', 'mno_files.mno_id')
->select(\DB::raw('count(*) as docs_count, network_operators.name, mno_files.mno_id'))
->groupBy('network_operators.name', 'mno_files.mno_id')
->get();
$data = [
'page_title' => 'Report Overview',
// 'vas_clients' => $vas_clients,
// 'domain_clients' => $domain_clients,
// 'recent_clients' => $recent_clients,
// 'user_activities' => $user_activities,
'current_user' => session('current_user'),
// 'client_docs' => $client_docs,
'mno_docs' => $mno_docs
];
return view('reports.overview', $data);
}
public function getRecentClients(){
$data = [
'page_title' => 'Recent Clients',
@@ -43,4 +73,70 @@ class ReportsController extends Controller
return response()->json($clients);
}
public function getUserActivities(){
#$user_activities = Models\UserActivity::where('user_id', '>', '1')->with('userInfo')->orderBy('created_at', 'DESC')->take(5)->get();
$data = [
'page_title' => 'User Activities',
'current_user' => session('current_user')
];
return view('reports.user-activities', $data);
}
public function getUserActivitiesJson(Request $request){
#$user_activities = Models\UserActivity::where('user_id', '>', '1')->with('userInfo')->orderBy('created_at', 'DESC')->take(5)->get();
$user_activities = \DB::table('user_activities')
->join('auth_users', 'auth_users.id', '=', 'user_activities.user_id')
->select('user_activities.id','auth_users.name', 'user_activities.content', 'user_activities.ip_address', 'user_activities.created_at',
'user_activities.updated_at')
->whereRaw("user_activities.type = 'staff'")
->orderBy('user_activities.created_at', 'DESC')
->get();
if($request->has('keyword')){
$keyword = $request->keyword;
$user_activities = \DB::table('user_activities')
->join('auth_users', 'auth_users.id', '=', 'user_activities.user_id')
->select('user_activities.id','auth_users.name', 'user_activities.content', 'user_activities.ip_address', 'user_activities.created_at', 'user_activities.updated_at')
->whereRaw("user_activities.name like '%$keyword%' or user_activities.ip_address like '%$keyword%' OR user_activities.created_at like '%$keyword%' OR user_activities.updated_at like '%$keyword%'")
->orderBy('user_activities.created_at', 'DESC')
->get();
// ->paginate(15);
}
return response()->json($user_activities);
}
public function getAmNewClients(){
// $new_clients = Models\Client::where()
}
public function getAmNewNotes(){
}
public function getClientsByService(){
$data = [
'page_title' => 'Clients By Service',
'current_user' => session('current_user')
];
return view('reports.clients-by-service', $data);
}
public function getClientsByServiceJson(){
$keyword = "USSD";
$clients = \DB::table('clients')
->join('auth_users AS aumngr', 'aumngr.id', '=', 'clients.auth_user_id')
->select('clients.name', 'clients.services', 'clients.status', 'clients.country', 'aumngr.name As accountMgr', 'clients.created_at')
->whereRaw("services like '%$keyword%'")
->orderBy('name', 'ASC')->get();
return response()->json($clients);
}
public function name(){
$list = ['first', 'second', 'third'];
// return $list[2];
print($list[2]);
}
}

View File

@@ -27,7 +27,7 @@ class SenderIdController extends Controller
->join('staff_members AS staffmodify', 'staffmodify.id', '=', 'sender_ids.last_modified_by')
->join('network_operators', 'network_operators.id', '=', 'sender_ids.network_id')
->join('clients', 'clients.id', '=', 'sender_ids.client_id')
->select('sender_ids.id', 'clients.name AS clientName', 'network_operators.name AS networkName', 'network_operators.country', 'sender_ids.senderid', 'sender_ids.status', 'sender_ids.network_id', 'network_operators.country','sender_ids.remarks', 'staffcreate.name As createdBy', 'staffmodify.name AS modifiedBy')
->select('sender_ids.id', 'clients.name AS clientName', 'network_operators.name AS networkName', 'network_operators.country', 'sender_ids.senderid', 'sender_ids.status', 'sender_ids.network_id', 'network_operators.country','sender_ids.remarks', 'staffcreate.name As createdBy','sender_ids.direct_mno', 'staffmodify.name AS modifiedBy')
->orderBy('sender_ids.senderid', 'ASC')
->paginate(15);
@@ -38,8 +38,8 @@ class SenderIdController extends Controller
->join('staff_members AS staffmodify', 'staffmodify.id', '=', 'sender_ids.last_modified_by')
->join('network_operators', 'network_operators.id', '=', 'sender_ids.network_id')
->join('clients', 'clients.id', '=', 'sender_ids.client_id')
->select('sender_ids.id', 'clients.name AS clientName', 'network_operators.name AS networkName', 'network_operators.country', 'sender_ids.senderid', 'sender_ids.status', 'sender_ids.network_id', 'network_operators.country','sender_ids.remarks', 'staffcreate.name As createdBy', 'staffmodify.name AS modifiedBy')
->whereRaw("sender_ids.senderid LIKE '%$keyword%' OR sender_ids.status LIKE '%$keyword%' OR network_operators.name LIKE '%$keyword%' OR network_operators.country LIKE '%$keyword%' OR staffcreate.name LIKE '%$keyword%' OR staffmodify.name LIKE '%$keyword%' OR clients.name LIKE '%$keyword%'")
->select('sender_ids.id', 'clients.name AS clientName', 'network_operators.name AS networkName', 'network_operators.country', 'sender_ids.senderid', 'sender_ids.status', 'sender_ids.network_id', 'network_operators.country','sender_ids.remarks', 'staffcreate.name As createdBy', 'sender_ids.direct_mno', 'staffmodify.name AS modifiedBy')
->whereRaw("sender_ids.senderid LIKE '%$keyword%' OR sender_ids.status LIKE '%$keyword%' OR network_operators.name LIKE '%$keyword%' OR network_operators.country LIKE '%$keyword%' OR staffcreate.name LIKE '%$keyword%' OR staffmodify.name LIKE '%$keyword%' OR clients.name LIKE '%$keyword%' OR sender_ids.direct_mno LIKE '%$keyword%'")
->orderBy('sender_ids.senderid', 'ASC')
->paginate(15);
}
@@ -51,6 +51,8 @@ class SenderIdController extends Controller
$networks = \DB::table('network_operators')->Select(\DB::raw('id, concat(name, " (", country, ")") AS network'))->orderBy('network')->get()->toArray();
$network_arr = array_pluck($networks, 'network', 'id');
$direct_mno_arr = ['YES' => 'YES', 'NO' => 'NO'];
// dd($network_arr);
#$network_arr = array_combine($network_arr, $network_arr);
@@ -61,9 +63,10 @@ class SenderIdController extends Controller
$data = [
'page_title' => 'Create Sender ID',
'network_arr' => $network_arr,
'network_arr' => [], // $network_arr,
'status' => $status,
'clients' => $clients,
'direct_mno_arr' => $direct_mno_arr,
'staffmembers' => $staffmembers
];
@@ -87,7 +90,16 @@ class SenderIdController extends Controller
$senderid_arr['created_by'] = session('current_user.id');
$senderid_arr['last_modified_by'] = session('current_user.id');
$senderid_arr['remarks'] = $request->remarks ?? '';
if ($request->direct_mno == 'NO') {
$mno_world_wide = Models\Worldwidemno::find($request->network_id);
// code... save in the network ops with status as non-direct ... user createOrUpdate method
$network_ops_arr['name'] = $mno_world_wide->network;
$network_ops_arr['country'] = $mno_world_wide->country;
$network_ops_arr['name'] = $mno_world_wide->network;
$network_ops_arr['direct_business'] = 'NO'; // $mno_world_wide->network;
$result = Models\NetworkOps::updateOrCreate(['name' => $mno_world_wide->network, 'country' => $mno_world_wide->country, 'direct_business' => 'NO'], $network_ops_arr);
}
// dd($senderid_arr);
$result = Models\SenderId::create($senderid_arr);
@@ -169,4 +181,18 @@ class SenderIdController extends Controller
return response()->json([ 'code' => 3, 'msg' => 'Request could not be handled at this time']);
}
}
public function getMNOList($type){
if ($type == 'YES') {
$data_arr = \DB::table('network_operators')->Select(\DB::raw('id, concat(name, " (", country, ")") AS name'))->orderBy('country')->get()->toArray();
}
elseif ($type == 'NO') {
$data_arr = \DB::table('mno_world_wide')->Select(\DB::raw('id, concat(network, " (", country, ")") AS name'))->orderBy('country')->get()->toArray();
}
else{
return response()->json(['code' => 3, 'msg' => 'invalid request']);
}
return response()->json(['code' => 1, 'msg' => 'success', 'result' => $data_arr]);
}
}

View File

@@ -26,22 +26,36 @@ class ShortCodesController extends Controller{
->select('code_type', \DB::raw('count(*) as total'))
->groupBy('code_type')
->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',
'Safaricom Kenya' => 'Safaricom Kenya',
'Airtel Kenya' => 'Airtel Kenya',
'Telkom Kenya' => 'Telkom Kenya',
'Orange Kenya' => 'Orange Kenya'
];
sort($networks_raw);
$data = [
'page_title' => 'Short Codes',
'type' => 'SMS',
'codes_data' => $codes_data,
'networks_raw' => array_combine($networks_raw, $networks_raw),
'current_user' => session('current_user')
];
return view('shortcodes.smsindex', $data);
}
public function getShortCodesJson(Request $request){
#$this->log_query();
$this->log_query();
//$codes_data = Models\ClientShortCode::with('client_info', 'update_info')->where('code_type', 'sms')->orderBy('id', 'DESC')->get();
$shortcode_arr = \DB::table('client_short_codes')
->join('auth_users', 'auth_users.id', '=', 'client_short_codes.last_updated_by')
->join('clients', 'clients.id', '=', 'client_short_codes.client_id')
->select('client_short_codes.id', 'client_short_codes.name', 'client_short_codes.shortcode', 'clients.name AS clientName', 'client_short_codes.network', 'client_short_codes.toll_free', 'client_short_codes.status', 'client_short_codes.remarks', 'client_short_codes.launch_date', 'client_short_codes.expiry_date', 'client_short_codes.last_updated_by', 'auth_users.name AS modifiedBy')
->select('client_short_codes.id', 'client_short_codes.name', 'client_short_codes.shortcode', 'clients.name AS clientName', 'client_short_codes.network', 'client_short_codes.toll_free', 'client_short_codes.monthly_fee', 'client_short_codes.status', 'client_short_codes.remarks', 'client_short_codes.launch_date', 'client_short_codes.expiry_date', 'client_short_codes.last_updated_by', 'auth_users.name AS modifiedBy')
->where('client_short_codes.code_type', 'sms')
->orderBy('client_short_codes.shortcode', 'ASC')
->paginate(15);
@@ -52,8 +66,8 @@ class ShortCodesController extends Controller{
$shortcode_arr = \DB::table('client_short_codes')
->join('auth_users', 'auth_users.id', '=', 'client_short_codes.last_updated_by')
->join('clients', 'clients.id', '=', 'client_short_codes.client_id')
->select('client_short_codes.id', 'client_short_codes.name', 'client_short_codes.shortcode', 'clients.name AS clientName', 'client_short_codes.network', 'client_short_codes.toll_free', 'client_short_codes.status', 'client_short_codes.remarks', 'client_short_codes.launch_date', 'client_short_codes.expiry_date', 'client_short_codes.last_updated_by', 'auth_users.name AS modifiedBy')
->whereRaw("code_type = '$code_type' AND (client_short_codes.name LIKE '%$keyword%' OR client_short_codes.shortcode LIKE '%$keyword%' OR client_short_codes.status LIKE '%$keyword%' OR client_short_codes.network LIKE '%$keyword%' OR client_short_codes.toll_free LIKE '%$keyword%' OR client_short_codes.launch_date LIKE '%$keyword%' OR client_short_codes.expiry_date LIKE '%$keyword%' OR clients.name LIKE '%$keyword%' OR auth_users.name LIKE '%$keyword%')")
->select('client_short_codes.id', 'client_short_codes.name', 'client_short_codes.shortcode', 'clients.name AS clientName', 'client_short_codes.network', 'client_short_codes.toll_free', 'client_short_codes.monthly_fee', 'client_short_codes.status', 'client_short_codes.remarks', 'client_short_codes.launch_date', 'client_short_codes.expiry_date', 'client_short_codes.last_updated_by', 'auth_users.name AS modifiedBy')
->whereRaw("code_type = '$code_type' AND (client_short_codes.name LIKE '%$keyword%' OR client_short_codes.shortcode LIKE '%$keyword%' OR client_short_codes.status LIKE '%$keyword%' OR client_short_codes.network LIKE '%$keyword%' OR client_short_codes.toll_free LIKE '%$keyword%' OR client_short_codes.monthly_fee LIKE '%$keyword%' OR client_short_codes.launch_date LIKE '%$keyword%' OR client_short_codes.expiry_date LIKE '%$keyword%' OR clients.name LIKE '%$keyword%' OR auth_users.name LIKE '%$keyword%')")
// ->where('code_type', $code_type)
->orderBy('client_short_codes.shortcode', 'ASC')
->paginate(15);
@@ -82,7 +96,7 @@ class ShortCodesController extends Controller{
$shortcode_arr = \DB::table('client_short_codes')
->join('auth_users', 'auth_users.id', '=', 'client_short_codes.last_updated_by')
->join('clients', 'clients.id', '=', 'client_short_codes.client_id')
->select('client_short_codes.id', 'client_short_codes.name', 'client_short_codes.shortcode', 'clients.name AS clientName', 'client_short_codes.network', 'client_short_codes.toll_free', 'client_short_codes.status', 'client_short_codes.remarks', 'client_short_codes.launch_date', 'client_short_codes.expiry_date', 'client_short_codes.last_updated_by', 'auth_users.name AS modifiedBy')
->select('client_short_codes.id', 'client_short_codes.name', 'client_short_codes.shortcode', 'clients.name AS clientName', 'client_short_codes.network', 'client_short_codes.toll_free', 'client_short_codes.monthly_fee', 'client_short_codes.status', 'client_short_codes.remarks', 'client_short_codes.launch_date', 'client_short_codes.expiry_date', 'client_short_codes.last_updated_by', 'auth_users.name AS modifiedBy')
->where('client_short_codes.code_type', 'ussd')
->orderBy('client_short_codes.shortcode', 'ASC')
->paginate(15);
@@ -93,8 +107,8 @@ class ShortCodesController extends Controller{
$shortcode_arr = \DB::table('client_short_codes')
->join('auth_users', 'auth_users.id', '=', 'client_short_codes.last_updated_by')
->join('clients', 'clients.id', '=', 'client_short_codes.client_id')
->select('client_short_codes.id', 'client_short_codes.name', 'client_short_codes.shortcode', 'clients.name AS clientName', 'client_short_codes.network', 'client_short_codes.toll_free', 'client_short_codes.status', 'client_short_codes.remarks', 'client_short_codes.launch_date', 'client_short_codes.expiry_date', 'client_short_codes.last_updated_by', 'auth_users.name AS modifiedBy')
->whereRaw("code_type = '$code_type' AND (client_short_codes.name LIKE '%$keyword%' OR client_short_codes.shortcode LIKE '%$keyword%' OR client_short_codes.status LIKE '%$keyword%' OR client_short_codes.network LIKE '%$keyword%' OR client_short_codes.toll_free LIKE '%$keyword%' OR client_short_codes.launch_date LIKE '%$keyword%' OR client_short_codes.expiry_date LIKE '%$keyword%' OR clients.name LIKE '%$keyword%' OR auth_users.name LIKE '%$keyword%')")
->select('client_short_codes.id', 'client_short_codes.name', 'client_short_codes.shortcode', 'clients.name AS clientName', 'client_short_codes.network', 'client_short_codes.toll_free', 'client_short_codes.monthly_fee', 'client_short_codes.status', 'client_short_codes.remarks', 'client_short_codes.launch_date', 'client_short_codes.expiry_date', 'client_short_codes.last_updated_by', 'auth_users.name AS modifiedBy')
->whereRaw("code_type = '$code_type' AND (client_short_codes.name LIKE '%$keyword%' OR client_short_codes.shortcode LIKE '%$keyword%' OR client_short_codes.status LIKE '%$keyword%' OR client_short_codes.network LIKE '%$keyword%' OR client_short_codes.toll_free LIKE '%$keyword%' OR client_short_codes.monthly_fee LIKE '%$keyword%' OR client_short_codes.launch_date LIKE '%$keyword%' OR client_short_codes.expiry_date LIKE '%$keyword%' OR clients.name LIKE '%$keyword%' OR auth_users.name LIKE '%$keyword%')")
// ->where('code_type', $code_type)
->orderBy('client_short_codes.shortcode', 'ASC')
->paginate(15);
@@ -124,7 +138,7 @@ class ShortCodesController extends Controller{
$shortcode_arr = \DB::table('client_short_codes')
->join('auth_users', 'auth_users.id', '=', 'client_short_codes.last_updated_by')
->join('clients', 'clients.id', '=', 'client_short_codes.client_id')
->select('client_short_codes.id', 'client_short_codes.name', 'client_short_codes.shortcode', 'clients.name AS clientName', 'client_short_codes.network', 'client_short_codes.toll_free', 'client_short_codes.status', 'client_short_codes.remarks', 'client_short_codes.launch_date', 'client_short_codes.expiry_date', 'client_short_codes.last_updated_by', 'auth_users.name AS modifiedBy')
->select('client_short_codes.id', 'client_short_codes.name', 'client_short_codes.shortcode', 'clients.name AS clientName', 'client_short_codes.network', 'client_short_codes.toll_free', 'client_short_codes.monthly_fee','client_short_codes.status', 'client_short_codes.remarks', 'client_short_codes.launch_date', 'client_short_codes.expiry_date', 'client_short_codes.last_updated_by', 'auth_users.name AS modifiedBy')
->where('client_short_codes.code_type', 'voice')
->orderBy('client_short_codes.shortcode', 'ASC')
->paginate(15);
@@ -135,8 +149,8 @@ class ShortCodesController extends Controller{
$shortcode_arr = \DB::table('client_short_codes')
->join('auth_users', 'auth_users.id', '=', 'client_short_codes.last_updated_by')
->join('clients', 'clients.id', '=', 'client_short_codes.client_id')
->select('client_short_codes.id', 'client_short_codes.name', 'client_short_codes.shortcode', 'clients.name AS clientName', 'client_short_codes.network', 'client_short_codes.toll_free', 'client_short_codes.status', 'client_short_codes.remarks', 'client_short_codes.launch_date', 'client_short_codes.expiry_date', 'client_short_codes.last_updated_by', 'auth_users.name AS modifiedBy')
->whereRaw("code_type = '$code_type' AND (client_short_codes.name LIKE '%$keyword%' OR client_short_codes.shortcode LIKE '%$keyword%' OR client_short_codes.status LIKE '%$keyword%' OR client_short_codes.network LIKE '%$keyword%' OR client_short_codes.toll_free LIKE '%$keyword%' OR client_short_codes.launch_date LIKE '%$keyword%' OR client_short_codes.expiry_date LIKE '%$keyword%' OR clients.name LIKE '%$keyword%' OR auth_users.name LIKE '%$keyword%')")
->select('client_short_codes.id', 'client_short_codes.name', 'client_short_codes.shortcode', 'clients.name AS clientName', 'client_short_codes.network', 'client_short_codes.toll_free', 'client_short_codes.monthly_fee', 'client_short_codes.status', 'client_short_codes.remarks', 'client_short_codes.launch_date', 'client_short_codes.expiry_date', 'client_short_codes.last_updated_by', 'auth_users.name AS modifiedBy')
->whereRaw("code_type = '$code_type' AND (client_short_codes.name LIKE '%$keyword%' OR client_short_codes.shortcode LIKE '%$keyword%' OR client_short_codes.status LIKE '%$keyword%' OR client_short_codes.network LIKE '%$keyword%' OR client_short_codes.toll_free LIKE '%$keyword%' OR client_short_codes.monthly_fee LIKE '%$keyword%' OR client_short_codes.launch_date LIKE '%$keyword%' OR client_short_codes.expiry_date LIKE '%$keyword%' OR clients.name LIKE '%$keyword%' OR auth_users.name LIKE '%$keyword%')")
// ->where('code_type', $code_type)
->orderBy('client_short_codes.shortcode', 'ASC')
->paginate(15);

View File

@@ -9,6 +9,28 @@ use Session;
class StaffMembersController extends Controller
{
public function index(){
$staff_members_arr = Models\StaffMember::paginate(10);
// dd($staff_members_arr);
$data = [
'page_title' => 'Staff Members',
'staff_members' => $staff_members_arr,
'current_user' => session('current_user')
];
return view('staff_members.index-two', $data);
}
public function profile($staff_member_id){
$staff_member = Models\StaffMember::find($staff_member_id);
// dd($staff_member);
$data = [
'page_title' => 'Staff Profile',
'staff_member' => $staff_member,
'current_user' => session('current_user')
];
return view('staff_members.profile', $data);
}
public function indexOld(){
$staff_members_arr = new Models\StaffMember;
$data = [
'page_title' => 'Staff Members',

View File

@@ -6,9 +6,8 @@ use Illuminate\Http\Request;
use App\Models;
use Spatie\Activitylog\Models\Activity;
// use Illuminate\Contracts\Mail\Mailer;
use Illuminate\Contracts\Mail\Mailer;
use App\Jobs\SendTestEmail;
class UtilityController extends Controller
{
@@ -17,7 +16,8 @@ class UtilityController extends Controller
}
public function EmailTest(Mailer $mailer)
{
dispatch(new SendTestEmail());
/*
$emails = ['kwesi@click-mobile.com', 'kwesi_banson@hotmail.com'];
$data = [
@@ -30,6 +30,20 @@ class UtilityController extends Controller
$message->from('erp@click-mobile.com', 'Click Mobile ERP');
$message->to($emails)->subject('New Notes');
});
*/
/*
$emails = [
'kwesi@click-mobile.com',
'kwesi_banson@hotmail.com'
];
$data = [];
$top = $mailer->send('emails.test', $data, function ($message) use ($data, $emails) {
$message->from('support@click-mobile.com', 'Click Mobile ERP');
$message->to($emails)->subject('Short Code Invoices');
});
dd($top);
*/
}
/**
* maptest function to display the map view.
@@ -37,7 +51,6 @@ class UtilityController extends Controller
* @return Illuminate\View\View
*/
public function maptest(){
return view('utility.map');
}
@@ -145,5 +158,71 @@ class UtilityController extends Controller
dump($activity_up->subject); //returns the instance of NewsItem that was created
dump($activity_up->changes);
}
public function loadShortCodes(){
$short_codes_file = public_path('misc/client_short_codes.csv');
$codes_arr = file($short_codes_file);
dump($codes_arr);
// "Friendly Name"
// 1 => "Shortcode"
// 2 => "Network"
// 3 => "Client"
// 4 => "Status"
// 0 => "Nexmo"
// 1 => "40520"
// 2 => "Safaricom"
// 3 => "Nexmo"
// 4 => "LIVE\r\n"
$client_arr = [];
foreach ($codes_arr as $row) {
$row_arr = explode(',', $row);
$client_arr['name'] = trim($row_arr[0]);
$client_arr['shortcode'] = trim($row_arr[1]);
$client_arr['network'] = trim($row_arr[2]);
$client_arr['client'] = trim($row_arr[3]);
$client_arr['status'] = trim($row_arr[4]);
dd($client_arr);
}
}
public function getClient($name){
}
public function getNetwork($name){
}
public function processMnoWorldwideFile(){
$file = public_path('helper_documents/mcc_mnc_table.json');
$jsonData = file_get_contents($file);
// Decode the JSON string into an associative array
$dataArray = json_decode($jsonData, true);
if (json_last_error() === JSON_ERROR_NONE) {
$counter = 0;
foreach ($dataArray as $key => $value) {
$result = Models\Worldwidemno::create($value);
$counter++;
}
dump($counter . " Records found and inserted");
} else {
dump('Error decoding JSON: ' . json_last_error_msg());
}
// dd($file);
// $decoded = json_decode($file, true);
// dd($decoded);
}
}
// https://www.tokyvideo.com/video/sheena-the-queen-of-the-jungle-1984-movie-with-tanya-roberts-ted-wass-donovan-scott

View File

@@ -0,0 +1,156 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models;
use Session;
class VpnController extends Controller{
public function indexBK(){
$result = Models\VpnConfig::where('partner_type', 'mno')->with('mno_info')->paginate(15);
// dd($result);
$data = [
'page_title' => 'infrastructure: VPN',
'vpn_list' => $result
];
// dd($result);
return view('vpn.index', $data);
}
public function indexBKK(){
$result = Models\VpnConfig::get();
// dd($result);
$data = [
'page_title' => 'infrastructure: VPN',
'vpn_list' => $result
];
return view('vpn.index_test', $data);
}
public function index(){
$data = [
'page_title' => 'Infrastructure: VPN',
'current_user' => session('current_user')
];
return view('vpn.index_rawjs', $data);
}
public function getVpnListJsonRawJs(Request $request){
// dd($request->has('keyword') && $request->keyword == true);
if($request->has('keyword') && $request->keyword == true){
//'vpn_configs.client_id',
$keyword = $request->keyword;
$vpn_list_arr = \DB::table('vpn_configs')
->join('auth_users', 'auth_users.id', '=', 'vpn_configs.user_id')
->join('network_operators', 'network_operators.id', '=', 'vpn_configs.mno_id')
->select('network_operators.id', 'vpn_configs.date_received', 'network_operators.name AS mnoName', 'network_operators.country', 'auth_users.name As username', 'vpn_configs.vpn_device', 'vpn_configs.mno_id', 'vpn_configs.partner_type', 'vpn_configs.remote_peer_ip', 'vpn_configs.local_access_control_list', 'vpn_configs.partner_access_control_list')
->whereRaw("network_operators.name LIKE '%$keyword%' OR vpn_configs.vpn_device LIKE '%$keyword%' OR network_operators.country LIKE '%$keyword%' OR vpn_configs.remote_peer_ip LIKE '%$keyword%' OR vpn_configs.local_access_control_list like '%$keyword%' OR vpn_configs.partner_access_control_list LIKE '%$keyword%'")
->paginate(10);
}
else{
$vpn_list_arr = \DB::table('vpn_configs')
->join('auth_users', 'auth_users.id', '=', 'vpn_configs.user_id')
->join('network_operators', 'network_operators.id', '=', 'vpn_configs.mno_id')
->select('vpn_configs.id', 'vpn_configs.date_received', 'network_operators.name AS mnoName', 'network_operators.country', 'auth_users.name As username', 'vpn_configs.vpn_device', 'vpn_configs.mno_id', 'vpn_configs.partner_type', 'vpn_configs.remote_peer_ip', 'vpn_configs.local_access_control_list', 'vpn_configs.partner_access_control_list')
->paginate(10);
}
return response()->json($vpn_list_arr);
}
public function create(){
$partner_type_arr = ['client' => 'client', 'mno' => 'mno'];
$partners_arr = [];
$services = Models\Service::pluck('name', 'name');
$data = [
'page_title' => 'infrastructure: VPN',
'partner_type_arr' => $partner_type_arr,
'partners_arr' => $partners_arr,
'services_arr' => $services
];
return view('vpn.create', $data);
}
public function edit($id){
$vpn = Models\VpnConfig::find($id);
$partner_type_arr = ['client' => 'client', 'mno' => 'mno'];
$partners_arr = [];
$services = Models\Service::pluck('name', 'name');
$data = [
'vpn' => $vpn,
'page_title' => 'infrastructure: VPN',
'partner_type_arr' => $partner_type_arr,
'partners_arr' => $partners_arr,
'services_arr' => $services
];
return view('vpn.create', $data);
}
public function store(Request $request){
$request->validate([
'partner_type_id' => 'required',
'vpn_device' => 'sometimes',
'remote_peer_ip' => 'required',
'partner_access_control_list' => 'required',
'local_access_control_list' => 'required',
'partner_type' => 'required',
'phase_1_raw_settings' => 'sometimes',
'phase_2_raw_settings' => 'sometimes',
]);
// dd($request->all());
$vpn_configs_arr = $request->except('_token', 'vpn_form');
if ($request->partner_type == 'mno') {
$vpn_configs_arr['mno_id'] = $request->partner_type_id;
}
elseif($request->partner_type == 'client'){
$vpn_configs_arr['client_id'] = $request->partner_type_id;
}
else{
Session::flash('error_message', 'Your request could not be handled at this time. Try again');
return redirect(url('infrastructure/vpn'));
}
$vpn_configs_arr['user_id'] = session('current_user.id');
// dd($vpn_configs_arr);
if ($request->hasFile('vpn_form')) {
if ($request->file('vpn_form')->isValid()) {
$filename = "erp_" . time() . "." . $request->vpn_form->extension();
$request->vpn_form->storeAs('vpn_form_files', $filename, 'public');
$document_arr['vpn_form'] = json_encode([$filename]);
$vpn_configs_arr['partner_vpn_form'] = $filename;
}
}
$result = Models\VpnConfig::create($vpn_configs_arr);
Session::flash('success_message', 'VPN Configs successfully added');
return redirect(url('infrastructure/vpn'));
}
public function getMNOandClient($type){
if ($type == 'mno') {
$data_arr = \DB::table('network_operators')->Select(\DB::raw('id, concat(name, " (", country, ")") AS partner'))->orderBy('name')->get()->toArray();
}
elseif ($type == 'client') {
$data_arr = \DB::table('clients')->Select(\DB::raw('id, concat(name, " (", country, ")") AS partner'))->orderBy('name')->get()->toArray();
}
else{
return response()->json(['code' => 3, 'msg' => 'invalid request']);
}
return response()->json(['code' => 1, 'msg' => 'success', 'result' => $data_arr]);
}
public function getPhaseOneTwo($vpn_list_id){
$vpn = Models\VpnConfig::find($vpn_list_id);
if ($vpn) {
// code...
$data = ['code' => 1, 'msg' => 'success', 'result' => $vpn];
}
else{
$data = ['code' => 3, 'msg' => 'request could not be handled'];
}
return response()->json($data);
}
}