added sender ID to the clients Tab in Show view plus bug fixes
This commit is contained in:
44
app/Console/Commands/ProcessSupportFeesRenewalReminders.php
Normal file
44
app/Console/Commands/ProcessSupportFeesRenewalReminders.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Http\Controllers\ContractRenewalReminderController;
|
||||
|
||||
class ProcessSupportFeesRenewalReminders extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'support_fees_renewal:send';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Send Reminders on Support Fees';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(ContractRenewalReminderController $contractRenewalReminder)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->contractRenewalReminder = $contractRenewalReminder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->contractRenewalReminder->getSupportFeesList();
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,7 @@ class Kernel extends ConsoleKernel
|
||||
// ->hourly();
|
||||
$schedule->command('renewal:send')->weekdays()->at('13:00');
|
||||
$schedule->command('client_renewal:send')->weekdays()->at('14:00');
|
||||
$schedule->command('support_fees_renewal:send')->weekdays()->at('15:00');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,6 +13,7 @@ use App\Jobs\SendOnboardingCompletedEmailAlert;
|
||||
use App\Http\Requests;
|
||||
use Carbon\Carbon;
|
||||
use App\Libs\PaperLessNgx;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
|
||||
class ClientsController extends Controller
|
||||
{
|
||||
@@ -22,6 +23,21 @@ 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);
|
||||
@@ -341,11 +357,20 @@ class ClientsController extends Controller
|
||||
'invoice_amount' => 'required|numeric',
|
||||
'invoice_date' => 'required',
|
||||
'invoice_status' => 'required',
|
||||
'short_code' => 'sometimes|numeric'
|
||||
// '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) {
|
||||
$data = ['code' => 3, 'msg' => 'Short Code must be a number'];
|
||||
return response()->json($data, 200);
|
||||
}
|
||||
}
|
||||
// dd($request->all());
|
||||
$finance_arr = [
|
||||
'invoice_number' => $request->invoice_number,
|
||||
'invoice_amount' => $request->invoice_amount,
|
||||
@@ -359,7 +384,7 @@ class ClientsController extends Controller
|
||||
if ($request->has('remarks')) {
|
||||
$finance_arr['remarks'] = $request->remarks;
|
||||
}
|
||||
|
||||
// dd($finance_arr);
|
||||
$result = Models\ClientPayment::create($finance_arr);
|
||||
|
||||
#$payments = Models\ClientPayment::with('client_info', 'created_by_info')->find($result->id);
|
||||
@@ -591,6 +616,14 @@ class ClientsController extends Controller
|
||||
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;
|
||||
/*
|
||||
$currentuser = session('current_user.name');
|
||||
$user_model = Models\SystemUser::find(session('current_user.id'));
|
||||
activity()->performedOn($showclient)
|
||||
->causedBy($user_model)
|
||||
->log($currentuser . ' Opened the page for : ' . $showclient->name . date('Y-m-d H:i:s'));
|
||||
*/
|
||||
// dd(json_decode($showclient->progress_indicators, true));
|
||||
/*
|
||||
"Initial talks\/ discussions",
|
||||
@@ -629,6 +662,7 @@ class ClientsController extends Controller
|
||||
$support_fees = Models\ClientSupportFees::where('client_id', $id)->orderBy('id', 'DESC')->get();
|
||||
|
||||
$showdocuments = Models\ClientFile::where('client_id', $id)->get();
|
||||
$client_sender_ids = Models\SenderId::with('network_info', 'created_by_info')->where('client_id', $id)->orderBy('senderid', 'ASC')->get();
|
||||
// dd($showdocuments[0]->name);
|
||||
if ($showclient->status == 'Live') {
|
||||
$status_bg = "info";
|
||||
@@ -697,7 +731,7 @@ class ClientsController extends Controller
|
||||
|
||||
sort($networks_raw);
|
||||
$recurring_arr = ['NO' => 'NO', 'Monthly' => 'Monthly', 'Quarterly' => 'Quarterly', 'Semiannual' => 'Semiannual', 'Yearly' => 'Yearly'];
|
||||
|
||||
$sender_id_statuses = ['Pending' => 'Pending', 'Inactive' => 'Inactive', 'Approved' => 'Approved'];
|
||||
$data = [
|
||||
'page_title' => 'Client Profile',
|
||||
'showclient' => $showclient,
|
||||
@@ -719,8 +753,14 @@ class ClientsController extends Controller
|
||||
'highlight_colour' => $highlight_colour,
|
||||
'showdocuments' => $showdocuments,
|
||||
'support_fees' => $support_fees,
|
||||
'recurring_arr' => $recurring_arr
|
||||
'recurring_arr' => $recurring_arr,
|
||||
'client_sender_ids' => $client_sender_ids,
|
||||
'sender_id_statuses' => $sender_id_statuses
|
||||
];
|
||||
// dump($client_sender_ids);
|
||||
// foreach ($client_sender_ids as $value) {
|
||||
// dd($value->network_info->name);
|
||||
// }
|
||||
return view('client.show', $data);
|
||||
}
|
||||
|
||||
@@ -1070,6 +1110,7 @@ class ClientsController extends Controller
|
||||
*/
|
||||
public function update(Requests\UpdateClientRequest $request, $id){
|
||||
// dump($request->all());
|
||||
// \DB::connection()->enableQueryLog();
|
||||
$client_update = Models\Client::find($id);
|
||||
$paperless = new PaperLessNgx();
|
||||
if ($client_update->progress_indicator != 'COMPLETED') {
|
||||
@@ -1117,7 +1158,6 @@ class ClientsController extends Controller
|
||||
|
||||
|
||||
$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();
|
||||
@@ -1270,6 +1310,10 @@ class ClientsController extends Controller
|
||||
'device' => $request->header('User-Agent')
|
||||
];
|
||||
$retval = Models\UserActivity::create($activity_arr);
|
||||
// $queries = \DB::getQueryLog();
|
||||
// dd($queries);
|
||||
// \Log::info($queries);
|
||||
|
||||
Session::flash('success_message', 'Client successfully Updated');
|
||||
return redirect(url('clients', $id));
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ use App\Models;
|
||||
use Session;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Jobs\SendMnoContractRenewalEmailAlert;
|
||||
use App\Jobs\SendSupportFeesReminderEmailAlert;
|
||||
use App\Http\Requests;
|
||||
use Carbon\Carbon;
|
||||
|
||||
@@ -36,4 +37,51 @@ class ContractRenewalReminderController extends Controller
|
||||
\Log::info('MNOs due for renewal ' . $log_data);
|
||||
$this->sendNtfy('MNOs due for renewal ' . $log_data);
|
||||
}
|
||||
public function getSupportFeesList(){
|
||||
$support_fees_arr = Models\ClientSupportFees::with('created_by_info', 'client_info')->where('recurring', '<>', 'NO')->get();
|
||||
// dd($support_fees_arr);
|
||||
$renew_ready = [];
|
||||
$current_date = date('Y-m-d');
|
||||
foreach ($support_fees_arr as $value) {
|
||||
// dd($value->created_by_info);
|
||||
$date1 = date_create($current_date);
|
||||
switch ($value->recurring) {
|
||||
case 'Annual':
|
||||
$date2 = date('Y-m-d', strtotime('+1 year', strtotime($value->invoice_date)));
|
||||
$date2 = date_create($value->invoice_date);
|
||||
$difference = date_diff($date1, $date2);
|
||||
break;
|
||||
case 'Semiannual':
|
||||
$date2 = date('Y-m-d', strtotime('+6 months', strtotime($value->invoice_date)));
|
||||
$date2 = date_create($value->invoice_date);
|
||||
$difference = date_diff($date1, $date2);
|
||||
break;
|
||||
case 'Quarterly':
|
||||
$date2 = date('Y-m-d', strtotime('+3 months', strtotime($value->invoice_date)));
|
||||
$date2 = date_create($value->invoice_date);
|
||||
$difference = date_diff($date1, $date2);
|
||||
break;
|
||||
case 'Monthly':
|
||||
$date2 = date('Y-m-d', strtotime('+1 month', strtotime($value->invoice_date)));
|
||||
$date2 = date_create($date2);
|
||||
$difference = date_diff($date1, $date2);
|
||||
break;
|
||||
default:
|
||||
continue 2;
|
||||
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));
|
||||
}
|
||||
\Log::info('Support Fees Reminder schedule has successfully ran ');
|
||||
if (count($renew_ready) > 0) {
|
||||
$log_data = implode(', ', $renew_ready);
|
||||
\Log::info('Support Fees Reminder for ' . $log_data);
|
||||
$this->sendNtfy('Support Fees due for renewal ' . $log_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,6 +64,15 @@ class Controller extends BaseController{
|
||||
$retval = Models\UserActivity::create($activity_arr);
|
||||
return true;
|
||||
}
|
||||
public function logUsersActivityTwo($content){
|
||||
$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'));
|
||||
return true;
|
||||
}
|
||||
public function storeLoggedUser(){
|
||||
$user_id = session('current_user.id');
|
||||
$logged_arr = [
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
@@ -19,7 +20,7 @@ class LoginController extends Controller
|
||||
$this->validate($request, ['email' => 'required', 'password' => 'required']);
|
||||
//system user : $table = "auth_users";
|
||||
$logged_in = Models\SystemUser::with('designation_info')->where('email', $request->email)->where('password', md5($request->password))->first();
|
||||
|
||||
|
||||
if(empty($logged_in)){
|
||||
return redirect("/")->withErrors(array("Incorrect Email/Password. Check and try again!"))->withInput();
|
||||
}
|
||||
@@ -32,12 +33,14 @@ class LoginController extends Controller
|
||||
$request->session()->put('current_user.designation', $logged_in->designation_info->name);
|
||||
|
||||
\Log::info($logged_in->name . ' Successfully logged in at : ' . date('Y-m-d H:i:s'));
|
||||
|
||||
$content = $logged_in->name . " Successfully Logged In";
|
||||
|
||||
activity()->log($logged_in->name . ' Successfully logged in at : ' . date('Y-m-d H:i:s'));
|
||||
|
||||
$this->logUsersActivity($type = 'staff', $content, $logged_in->id);
|
||||
$this->deleteLoggedUser();
|
||||
$this->storeLoggedUser();
|
||||
|
||||
|
||||
switch ($logged_in->designation_info->name) {
|
||||
case 'Administrator':
|
||||
return redirect(url('finance')); // change it to a combined dashboard
|
||||
@@ -45,11 +48,11 @@ class LoginController extends Controller
|
||||
case 'Accounts & Finance':
|
||||
return redirect(url('finance'));
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
return redirect(url('/'));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function handle_logout(Request $request) {
|
||||
@@ -62,7 +65,8 @@ class LoginController extends Controller
|
||||
$request->session()->flush();
|
||||
$request->session()->regenerate(true);
|
||||
|
||||
$this->logUsersActivity($type = 'staff', $content, $user_id);
|
||||
activity()->log($username . " Logged Out : " . date('Y-m-d H:i:s'));
|
||||
// $this->logUsersActivity($type = 'staff', $content, $user_id);
|
||||
|
||||
return redirect("/");
|
||||
}
|
||||
@@ -75,7 +79,7 @@ class LoginController extends Controller
|
||||
'email' => 'required',
|
||||
'phone' => 'required',
|
||||
'password' => 'required',
|
||||
'confirm_password' => 'same:password',
|
||||
'confirm_password' => 'same:password',
|
||||
]);
|
||||
|
||||
$make_account = [
|
||||
|
||||
@@ -21,8 +21,7 @@ class NetworkOperatorsController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function indexBAK()
|
||||
{
|
||||
public function indexBAK(){
|
||||
$network_operators = new Models\NetworkOps;
|
||||
$table_columns = \DB::select(\DB::raw("show full columns from network_operators"));
|
||||
$exclude_arr = [
|
||||
@@ -99,14 +98,16 @@ class NetworkOperatorsController extends Controller
|
||||
$account_manager = Models\SystemUser::pluck('name', 'id');
|
||||
$services = Models\Service::pluck('name', 'name');
|
||||
$status = ['Active' => 'Active', 'Inactive' => 'Inactive', 'Pending' => 'Pending'];
|
||||
$direct_arr = ['Direct' => 'Direct', 'Non Direct' => 'Non Direct'];
|
||||
// dd('foo bar');
|
||||
$data = [
|
||||
'page_title' => 'Create Network Operator',
|
||||
'countries'=> $countries,
|
||||
'account_manager' => $account_manager,
|
||||
'services' => $services,
|
||||
'status' => $status
|
||||
'status' => $status,
|
||||
'direct_arr' => $direct_arr
|
||||
];
|
||||
|
||||
return view('network_ops.create', $data);
|
||||
}
|
||||
|
||||
@@ -119,12 +120,14 @@ class NetworkOperatorsController extends Controller
|
||||
public function store(Request $request){
|
||||
$request->validate([
|
||||
'name' => 'required',
|
||||
'direct_status' => 'required',
|
||||
'country' => 'required',
|
||||
'account_manager_id' => 'required',
|
||||
'services' => 'required',
|
||||
'contact_person' => 'required',
|
||||
'email' => 'required',
|
||||
'phone' => 'required'
|
||||
'account_manager_id' => 'required_if:direct_status,Direct',
|
||||
'services' => 'required_if:direct_status,Direct',
|
||||
'contact_person' => 'required_if:direct_status,Direct',
|
||||
'email' => 'required_if:direct_status,Direct',
|
||||
'phone' => 'required_if:direct_status,Direct',
|
||||
'status' => 'required'
|
||||
]);
|
||||
|
||||
$operator_arr = [
|
||||
@@ -140,6 +143,9 @@ class NetworkOperatorsController extends Controller
|
||||
if ($request->has('services')) {
|
||||
$operator_arr['services'] = json_encode($request->services);
|
||||
}
|
||||
if ($request->account_manager_id == false) {
|
||||
$operator_arr['account_manager_id'] = session('current_user.id');
|
||||
}
|
||||
if ($request->has('phone')) {
|
||||
$operator_arr['phone'] = $request->phone;
|
||||
}
|
||||
@@ -152,7 +158,7 @@ class NetworkOperatorsController extends Controller
|
||||
if ($request->has('contact_person')) {
|
||||
$operator_arr['contact_person'] = $request->contact_person;
|
||||
}
|
||||
|
||||
// dd($operator_arr);
|
||||
$saved = Models\NetworkOps::create($operator_arr);
|
||||
Session::flash('success_message', 'Network Operator successfully added');
|
||||
return redirect(url('mnos'));
|
||||
|
||||
10
app/Http/Controllers/RemindersController.php
Normal file
10
app/Http/Controllers/RemindersController.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class RemindersController extends Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
@@ -16,7 +16,7 @@ use Carbon\Carbon;
|
||||
|
||||
|
||||
class ReportsController extends Controller
|
||||
{
|
||||
{
|
||||
public function getRecentClients(){
|
||||
$data = [
|
||||
'page_title' => 'Recent Clients',
|
||||
@@ -26,6 +26,7 @@ class ReportsController extends Controller
|
||||
|
||||
}
|
||||
public function getRecentClientsJson(){
|
||||
// $period = $request->period;
|
||||
// $clients = Models\Client::where()->get();
|
||||
/*
|
||||
$clients = \DB::table('clients')
|
||||
|
||||
@@ -42,23 +42,23 @@ class SenderIdController extends Controller
|
||||
->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%'")
|
||||
->orderBy('sender_ids.senderid', 'ASC')
|
||||
->paginate(15);
|
||||
}
|
||||
}
|
||||
return response()->json($senderid_arr);
|
||||
}
|
||||
public function create()
|
||||
{
|
||||
#$network_arr = Models\NetworkOps::pluck('name','country');
|
||||
|
||||
|
||||
$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');
|
||||
// dd($network_arr);
|
||||
#$network_arr = array_combine($network_arr, $network_arr);
|
||||
|
||||
|
||||
|
||||
$clients = Models\Client::pluck('name', 'id');
|
||||
$staffmembers = Models\StaffMember::pluck('name', 'id');
|
||||
$status = ['Pending' => 'Pending', 'Inactive' => 'Inactive', 'Approved' => 'Approved'];
|
||||
|
||||
|
||||
$data = [
|
||||
'page_title' => 'Create Sender ID',
|
||||
'network_arr' => $network_arr,
|
||||
@@ -87,14 +87,14 @@ 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 ?? '';
|
||||
|
||||
|
||||
|
||||
$result = Models\SenderId::create($senderid_arr);
|
||||
|
||||
|
||||
|
||||
|
||||
#save services this has been moved to the main client table
|
||||
//$retval = $this->store_services($request->services, $result->id);
|
||||
|
||||
|
||||
Session::flash('success_message', 'Sender ID successfully added');
|
||||
return redirect(url('senderids'));
|
||||
}
|
||||
@@ -104,12 +104,12 @@ 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');
|
||||
|
||||
|
||||
|
||||
$clients = Models\Client::pluck('name', 'id');
|
||||
$staffmembers = Models\StaffMember::pluck('name', 'id');
|
||||
$status = ['Pending' => 'Pending', 'Inactive' => 'Inactive', 'Approved' => 'Approved'];
|
||||
|
||||
|
||||
|
||||
$data = [
|
||||
'page_title' => 'Create Sender ID',
|
||||
@@ -131,9 +131,9 @@ class SenderIdController extends Controller
|
||||
'status' => 'required',
|
||||
'remarks' => 'sometimes',
|
||||
]);
|
||||
|
||||
|
||||
$senderid = Models\SenderId::findOrFail($id);
|
||||
|
||||
|
||||
$senderid->senderid = $request->senderid;
|
||||
$senderid->client_id = $request->client_id;
|
||||
$senderid->status = $request->status;
|
||||
@@ -145,4 +145,28 @@ class SenderIdController extends Controller
|
||||
Session::flash('success_message', 'Sender ID successfully Updated');
|
||||
return redirect(url('senderids'));
|
||||
}
|
||||
public function direct_store(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'senderid' => 'required|max:11',
|
||||
'network_id' => 'required',
|
||||
'status' => 'required',
|
||||
'remarks' => 'sometimes',
|
||||
]);
|
||||
$senderid_arr = $request->except('_token');
|
||||
$senderid_arr['created_by'] = session('current_user.id');
|
||||
$senderid_arr['last_modified_by'] = session('current_user.id');
|
||||
$senderid_arr['remarks'] = $request->remarks ?? '';
|
||||
|
||||
|
||||
$result = Models\SenderId::create($senderid_arr);
|
||||
|
||||
|
||||
if($result){
|
||||
return response()->json([ 'code' => 1, 'result' => 'success']);
|
||||
}
|
||||
else {
|
||||
return response()->json([ 'code' => 3, 'msg' => 'Request could not be handled at this time']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
145
app/Http/Controllers/SystemCredentialsController.php
Normal file
145
app/Http/Controllers/SystemCredentialsController.php
Normal file
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use App\Models;
|
||||
use Session;
|
||||
|
||||
|
||||
class SystemCredentialsController extends Controller{
|
||||
|
||||
|
||||
|
||||
public function index(){
|
||||
$data = [
|
||||
'page_title' => 'Credentials',
|
||||
];
|
||||
return view('sys_credentials.index', $data);
|
||||
|
||||
}
|
||||
public function getCredListJson(Request $request){
|
||||
//$this->log_query();
|
||||
$credentials_arr = \DB::table('sys_credentials')
|
||||
->join('auth_users AS userModify', 'userModify.id', '=', 'sys_credentials.last_modified_by_id')
|
||||
->join('auth_users AS userCreate', 'userCreate.id', '=', 'sys_credentials.created_by_id')
|
||||
->join('clients', 'clients.id', '=', 'sys_credentials.client_id')
|
||||
->join('network_operators', 'network_operators.id', '=', 'sys_credentials.network_operator_id')
|
||||
->select('sys_credentials.id', 'clients.name AS clientName', 'network_operators.name AS networkOpsName', 'sys_credentials.service', 'userCreate.name AS created_by_user', 'userModify.name AS modified_by_user', 'sys_credentials.client_id','sys_credentials.network_operator_id', 'sys_credentials.url_endpoint', 'sys_credentials.credentials', 'sys_credentials.expiry_date', 'sys_credentials.remarks', 'sys_credentials.created_at', 'sys_credentials.updated_at')
|
||||
->orderBy('sys_credentials.service', 'ASC')
|
||||
->paginate(20);
|
||||
|
||||
if($request->has('keyword')){
|
||||
$keyword = $request->keyword;
|
||||
$credentials_arr = \DB::table('sys_credentials')
|
||||
->join('auth_users AS userModify', 'userModify.id', '=', 'sys_credentials.last_modified_by_id')
|
||||
->join('auth_users AS userCreate', 'userCreate.id', '=', 'sys_credentials.created_by_id')
|
||||
->join('clients', 'clients.id', '=', 'sys_credentials.client_id')
|
||||
->join('network_operators', 'network_operators.id', '=', 'sys_credentials.network_operator_id')
|
||||
->select('sys_credentials.id', 'clients.name AS clientName', 'network_operators.name AS networkOpsName', 'sys_credentials.service', 'userCreate.name AS created_by_user', 'userModify.name AS modified_by_user', 'sys_credentials.client_id','sys_credentials.network_operator_id', 'sys_credentials.url_endpoint', 'sys_credentials.credentials', 'sys_credentials.expiry_date', 'sys_credentials.remarks', 'sys_credentials.created_at', 'sys_credentials.updated_at')
|
||||
->whereRaw("sys_credentials.service LIKE '%$keyword%' OR userCreate.name LIKE '%$keyword%' OR sys_credentials.url_endpoint LIKE '%$keyword%' OR sys_credentials.expiry_date LIKE '%$keyword%' OR userModify.name LIKE '%$keyword%' OR sys_credentials.created_at LIKE '%$keyword%' OR sys_credentials.remarks LIKE '%$keyword%' OR sys_credentials.updated_at LIKE '%$keyword%' OR network_operators.name LIKE '%$keyword%'")
|
||||
->orderBy('sys_credentials.service', 'ASC')
|
||||
->paginate(15);
|
||||
}
|
||||
return response()->json($credentials_arr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function create(){
|
||||
$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');
|
||||
$services = Models\Service::pluck('name', 'name');
|
||||
$clients = Models\Client::pluck('name', 'id');
|
||||
$auth_users = Models\SystemUser::pluck('name', 'id');
|
||||
|
||||
$data = [
|
||||
'page_title' => 'System Credentialss',
|
||||
'clients' => $clients,
|
||||
'network_arr' => $network_arr,
|
||||
'services' => $services,
|
||||
'auth_users' => $auth_users
|
||||
];
|
||||
return view('sys_credentials.create', $data);
|
||||
}
|
||||
public function store(Request $request){
|
||||
$request->validate([
|
||||
'service' => 'required',
|
||||
'client_id' => 'required',
|
||||
'network_operator_id' => 'required',
|
||||
'url_endpoint' => 'required',
|
||||
'credentials' => 'required',
|
||||
'expiry_date' => 'required',
|
||||
'remarks' => 'sometimes',
|
||||
]);
|
||||
// dump($request->all());
|
||||
|
||||
$credentials_arr = $request->except('_token');
|
||||
$credentials_arr['last_modified_by_id'] = session('current_user.id');
|
||||
$credentials_arr['created_by_id'] = session('current_user.id');
|
||||
|
||||
// dd($credentials_arr);
|
||||
// TODO: add user activity here
|
||||
$result = Models\SystemCredential::create($credentials_arr);
|
||||
Session::flash('success_message', 'Credentials successfully added');
|
||||
return redirect(url('systemcreds'));
|
||||
}
|
||||
|
||||
public function edit($id){
|
||||
$credential = Models\SystemCredential::find($id);
|
||||
|
||||
$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');
|
||||
$clients = Models\Client::pluck('name', 'id');
|
||||
$auth_users = Models\SystemUser::pluck('name', 'id');
|
||||
|
||||
|
||||
$data = [
|
||||
'page_title' => 'System Credentials',
|
||||
'credential' => $credential,
|
||||
'clients' => $clients,
|
||||
'network_arr' => $network_arr,
|
||||
'auth_users' => $auth_users
|
||||
];
|
||||
return view('sys_credentials.edit', $data);
|
||||
}
|
||||
|
||||
public function update(Request $request, $id){
|
||||
$request->validate([
|
||||
'friendly_name' => 'required',
|
||||
'server_id' => 'required',
|
||||
'public_ip_address' => 'sometimes|ip',
|
||||
'private_ip_address' => 'sometimes|nullable|ip',
|
||||
'main_use' => 'required',
|
||||
'remarks' => 'nullable',
|
||||
'status' => 'required',
|
||||
'server_number' => 'required',
|
||||
]);
|
||||
$server = Models\ClickServer::findOrFail($id);
|
||||
$server_arr = $request->except('_token', 'server_id', 'server_number');
|
||||
$server_arr['last_modified_by_id'] = session('current_user.id');
|
||||
$server_arr['server_id'] = $request->server_number;
|
||||
$result = $server->update($server_arr);
|
||||
Session::flash('success_message', 'Server Details successfully updated');
|
||||
return redirect(url('infrastructure/server-list'));
|
||||
}
|
||||
|
||||
public function reveal_password($id){
|
||||
$server = Models\ClickServer::find($id);
|
||||
if ($server) {
|
||||
$response_arr = [
|
||||
'code' => 1,
|
||||
'password' => decrypt($server->root_password)
|
||||
];
|
||||
}
|
||||
else{
|
||||
$response_arr = [
|
||||
'code' => 3,
|
||||
'msg' => 'not found'
|
||||
];
|
||||
}
|
||||
return response()->json($response_arr);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,13 +5,16 @@ namespace App\Http\Controllers;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use App\Models;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
// use Illuminate\Contracts\Mail\Mailer;
|
||||
|
||||
|
||||
|
||||
class UtilityController extends Controller
|
||||
{
|
||||
|
||||
public function underconstruction(){
|
||||
return view('utility.underconstruction');
|
||||
}
|
||||
public function EmailTest(Mailer $mailer)
|
||||
{
|
||||
|
||||
@@ -28,6 +31,11 @@ class UtilityController extends Controller
|
||||
$message->to($emails)->subject('New Notes');
|
||||
});
|
||||
}
|
||||
/**
|
||||
* maptest function to display the map view.
|
||||
*
|
||||
* @return Illuminate\View\View
|
||||
*/
|
||||
public function maptest(){
|
||||
|
||||
return view('utility.map');
|
||||
@@ -111,5 +119,31 @@ class UtilityController extends Controller
|
||||
}
|
||||
dump($count_cl);
|
||||
}
|
||||
function loggingTest(){
|
||||
$rando = uniqid();
|
||||
|
||||
$newsItem = Models\Utility::create([
|
||||
'name' => 'original name : ' . $rando,
|
||||
'type' => 'Lorum'
|
||||
]);
|
||||
$activity = Activity::all()->last();
|
||||
|
||||
dump($activity->description); //returns 'created'
|
||||
dump($activity->subject); //returns the instance of NewsItem that was created
|
||||
dump($activity->changes); //returns ['attributes' => ['name' => 'original name', 'text' => 'Lorum']];
|
||||
//
|
||||
$rando = uniqid();
|
||||
|
||||
$newsItem->name = 'updated name to something like this ' . $rando;
|
||||
$newsItem->type = 'franko';
|
||||
$newsItem->save();
|
||||
|
||||
//updating the newsItem will cause an activity being logged
|
||||
$activity_up = Activity::all()->last();
|
||||
dump($activity_up);
|
||||
dump($activity_up->description); //returns 'updated'
|
||||
dump($activity_up->subject); //returns the instance of NewsItem that was created
|
||||
dump($activity_up->changes);
|
||||
}
|
||||
}
|
||||
// https://www.tokyvideo.com/video/sheena-the-queen-of-the-jungle-1984-movie-with-tanya-roberts-ted-wass-donovan-scott
|
||||
|
||||
@@ -17,6 +17,7 @@ class CheckCurrentlyLoggedInUsers
|
||||
{
|
||||
if($request->session()->has('current_user')){
|
||||
$id = session('current_user.id');
|
||||
|
||||
$device = $request->server('HTTP_USER_AGENT');
|
||||
$realm = $id . $device;
|
||||
$current_user = Models\LoggedUser::where('user_id', $id)->where('device', $device)->first();
|
||||
|
||||
52
app/Jobs/SendSupportFeesReminderEmailAlert.php
Normal file
52
app/Jobs/SendSupportFeesReminderEmailAlert.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
use App\Models;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Contracts\Mail\Mailer;
|
||||
|
||||
class SendSupportFeesReminderEmailAlert implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
protected $renewalSet;
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
public function __construct($renewalSet)
|
||||
{
|
||||
$this->renewalSet = $renewalSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
public function handle(Mailer $mailer){
|
||||
$renewalSet = $this->renewalSet;
|
||||
$emails = ['samuel@click-mobile.com'];
|
||||
$emails = ['kwesi@click-mobile.com'];
|
||||
$emails = ['effie@click-mobile.com'];
|
||||
$emails = ['priscilla@click-mobile.com'];
|
||||
$emails = ['jim@click-mobile.com'];
|
||||
$emails = ['daniel@click-mobile.com'];
|
||||
$emails = ['mansa@click-mobile.com'];
|
||||
$emails[] = $renewalSet['account_manager_email'];
|
||||
$data = [
|
||||
'client_name' => $renewalSet['client_name'],
|
||||
'alert_body' => 'Support fees for ' . $renewalSet['client_name'] . ' will be due in ' . $renewalSet['days_to_renew'] . ' days. Take note'
|
||||
];
|
||||
$mailer->send('emails.supportfees-alert', $data, function ($message) use ($data, $emails) {
|
||||
$message->from('support@click-mobile.com', 'Click Mobile ERP');
|
||||
$message->to($emails)->subject('Support Fees Reminder');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,29 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Models;
|
||||
#use Spatie\Activitylog\Traits\LogsActivity;
|
||||
//use Spatie\Activitylog\Traits\CausesActivity;
|
||||
#use Spatie\Activitylog\LogOptions;
|
||||
|
||||
class Client extends Model
|
||||
{
|
||||
#use LogsActivity;
|
||||
|
||||
protected $guarded = array('id');
|
||||
public $table = "clients";
|
||||
protected $appends = ['client_services'];
|
||||
/*
|
||||
protected static $logName = 'clients_log';
|
||||
protected static $logOnlyDirty = true;
|
||||
protected static $dontSubmitEmptyLogs = true;
|
||||
|
||||
|
||||
protected static $logUnguarded = true;
|
||||
public function getActivitylogOptions(): LogOptions{
|
||||
return LogOptions::defaults()
|
||||
->logUnguarded()->useLogName('client')->logOnlyDirty()->dontSubmitEmptyLogs();
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
public function getprogressIndicatorsAttribute($value){
|
||||
@@ -17,8 +35,8 @@ class Client extends Model
|
||||
$indicator_score = (count($current_indicator_count)/$general_indicators) * 100;
|
||||
return number_format($indicator_score);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function getOnboardingProgressStageAttribute($value){
|
||||
$onboarding_stage = json_decode($value, true);
|
||||
|
||||
@@ -55,8 +73,8 @@ class Client extends Model
|
||||
public function short_code_info(){
|
||||
return $this->hasMany('App\Models\ShortCode', 'client_id', 'id');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function getClientServicesAttribute(){
|
||||
$services = $this->service_info;
|
||||
$service_name_arr = [];
|
||||
@@ -66,5 +84,5 @@ class Client extends Model
|
||||
}
|
||||
return $service_name_arr;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -3,10 +3,17 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
|
||||
class ClientNote extends Model
|
||||
{
|
||||
protected $guarded = array('id');
|
||||
protected static $logUnguarded = true;
|
||||
|
||||
public function getActivitylogOptions(): LogOptions{
|
||||
return LogOptions::defaults()->logUnguarded();
|
||||
}
|
||||
|
||||
public function client_info(){
|
||||
return $this->hasOne('App\Models\Client', 'id', 'client_id');
|
||||
@@ -14,5 +21,5 @@ class ClientNote extends Model
|
||||
public function created_by_info(){
|
||||
return $this->hasOne('App\Models\SystemUser', 'id', 'auth_user_id');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -14,6 +14,6 @@ class ClientSupportFees extends Model
|
||||
}
|
||||
public function created_by_info(){
|
||||
// return $this->hasOne('App\Models\Account', 'id', 'auth_user_id');
|
||||
return $this->hasOne('App\Models\SystemUser', 'id', 'auth_user_id');
|
||||
return $this->hasOne('App\Models\SystemUser', 'id', 'user_id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,6 @@ class LoggedUser extends Model
|
||||
|
||||
|
||||
public function auth_user_info(){
|
||||
return $this->hasOne('App\Models\Account', 'id', 'user_id');
|
||||
return $this->hasOne('App\Models\SystemUser', 'id', 'user_id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,19 +3,35 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
|
||||
class SenderId extends Model{
|
||||
use LogsActivity;
|
||||
|
||||
|
||||
protected $guarded = array('id');
|
||||
public $table = "sender_ids";
|
||||
protected static $logName = 'senderid_log';
|
||||
// protected static $causedBy = $user_model;
|
||||
protected static $logOnlyDirty = true;
|
||||
protected static $dontSubmitEmptyLogs = true;
|
||||
|
||||
|
||||
protected static $logUnguarded = true;
|
||||
public function getActivitylogOptions(): LogOptions{
|
||||
return LogOptions::defaults()
|
||||
->logUnguarded()->useLogName('senderid_log')->logOnlyDirty()->dontSubmitEmptyLogs();
|
||||
}
|
||||
|
||||
|
||||
public function modified_by_info(){
|
||||
return $this->hasOne('App\Models\StaffMember', 'id', 'last_modified_by');
|
||||
}
|
||||
public function network_info(){
|
||||
return $this->hasOne('App\Models\NetworkOps', 'id', 'netowkr_id');
|
||||
return $this->hasOne('App\Models\NetworkOps', 'id', 'network_id');
|
||||
}
|
||||
public function created_by_info(){
|
||||
return $this->hasOne('App\Models\StaffMember', 'id', 'created_by');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
24
app/Models/SystemCredential.php
Normal file
24
app/Models/SystemCredential.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SystemCredential extends Model{
|
||||
|
||||
protected $guarded = array('id');
|
||||
public $table = "sys_credentials";
|
||||
|
||||
public function modified_by_info(){
|
||||
return $this->hasOne('App\Models\SystemUser', 'id', 'last_modified_by_id');
|
||||
}
|
||||
public function network_info(){
|
||||
return $this->hasOne('App\Models\NetworkOps', 'id', 'network_id');
|
||||
}
|
||||
public function client_info(){
|
||||
return $this->hasOne('App\Models\Client', 'id', 'client_id');
|
||||
}
|
||||
public function created_by_info(){
|
||||
return $this->hasOne('App\Models\SystemUser', 'id', 'created_by_id');
|
||||
}
|
||||
}
|
||||
@@ -3,12 +3,21 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
// use Spatie\Activitylog\Traits\LogsActivity;
|
||||
use Spatie\Activitylog\Traits\CausesActivity;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
|
||||
class SystemUser extends Model
|
||||
{
|
||||
// use LogsActivity;
|
||||
use CausesActivity;
|
||||
protected $guarded = array('id');
|
||||
public $table = "auth_users";
|
||||
|
||||
protected static $logUnguarded = true;
|
||||
// public function getActivitylogOptions(): LogOptions{
|
||||
// return LogOptions::defaults()->logUnguarded();
|
||||
// }
|
||||
|
||||
public function designation_info(){
|
||||
return $this->hasOne('App\Models\Designation', 'id', 'designation');
|
||||
}
|
||||
|
||||
@@ -14,10 +14,13 @@ class UserActivity extends Model
|
||||
public function userInfo(){
|
||||
return $this->hasOne('App\Models\StaffMember', 'id', 'user_id');
|
||||
}
|
||||
public function userInfoSystem(){
|
||||
return $this->hasOne('App\Models\SystemUser', 'id', 'user_id');
|
||||
}
|
||||
public function getActivityTimeAttribute(){
|
||||
$created = $this->created_at;
|
||||
$parsed_created_date = Carbon::parse($created);
|
||||
$current_date = Carbon::parse(date('Y-m-d'));
|
||||
$current_date = Carbon::parse(date('Y-m-d'));
|
||||
$days = $parsed_created_date->diffForHumans();
|
||||
return $days;
|
||||
}
|
||||
|
||||
23
app/Models/Utility.php
Normal file
23
app/Models/Utility.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Spatie\Activitylog\Traits\LogsActivity;
|
||||
use Spatie\Activitylog\LogOptions;
|
||||
|
||||
|
||||
class Utility extends Model{
|
||||
|
||||
use LogsActivity;
|
||||
protected $guarded = ['id'];
|
||||
protected $table = "utility";
|
||||
protected static $logUnguarded = true;
|
||||
public function getActivitylogOptions(): LogOptions
|
||||
{
|
||||
return LogOptions::defaults()
|
||||
->logUnguarded();
|
||||
// ->logOnly(['name', 'type']);
|
||||
// Chain fluent methods for configuration options
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user