first commit, after modifying client section
This commit is contained in:
42
app/Console/Kernel.php
Executable file
42
app/Console/Kernel.php
Executable file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console;
|
||||
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
/**
|
||||
* The Artisan commands provided by your application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $commands = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
* @return void
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
// $schedule->command('inspire')
|
||||
// ->hourly();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the commands for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function commands()
|
||||
{
|
||||
$this->load(__DIR__.'/Commands');
|
||||
|
||||
require base_path('routes/console.php');
|
||||
}
|
||||
}
|
||||
53
app/Exceptions/Handler.php
Executable file
53
app/Exceptions/Handler.php
Executable file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
/**
|
||||
* A list of the exception types that are not reported.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dontReport = [
|
||||
//
|
||||
];
|
||||
|
||||
/**
|
||||
* A list of the inputs that are never flashed for validation exceptions.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dontFlash = [
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
|
||||
/**
|
||||
* Report or log an exception.
|
||||
*
|
||||
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
|
||||
*
|
||||
* @param \Exception $exception
|
||||
* @return void
|
||||
*/
|
||||
public function report(Exception $exception)
|
||||
{
|
||||
parent::report($exception);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an exception into an HTTP response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Exception $exception
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function render($request, Exception $exception)
|
||||
{
|
||||
return parent::render($request, $exception);
|
||||
}
|
||||
}
|
||||
32
app/Http/Controllers/Auth/ForgotPasswordController.php
Executable file
32
app/Http/Controllers/Auth/ForgotPasswordController.php
Executable file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||
|
||||
class ForgotPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset emails and
|
||||
| includes a trait which assists in sending these notifications from
|
||||
| your application to your users. Feel free to explore this trait.
|
||||
|
|
||||
*/
|
||||
|
||||
use SendsPasswordResetEmails;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
}
|
||||
39
app/Http/Controllers/Auth/LoginController.php
Executable file
39
app/Http/Controllers/Auth/LoginController.php
Executable file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Login Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles authenticating users for the application and
|
||||
| redirecting them to your home screen. The controller uses a trait
|
||||
| to conveniently provide its functionality to your applications.
|
||||
|
|
||||
*/
|
||||
|
||||
use AuthenticatesUsers;
|
||||
|
||||
/**
|
||||
* Where to redirect users after login.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest')->except('logout');
|
||||
}
|
||||
}
|
||||
71
app/Http/Controllers/Auth/RegisterController.php
Executable file
71
app/Http/Controllers/Auth/RegisterController.php
Executable file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\User;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||
|
||||
class RegisterController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles the registration of new users as well as their
|
||||
| validation and creation. By default this controller uses a trait to
|
||||
| provide this functionality without requiring any additional code.
|
||||
|
|
||||
*/
|
||||
|
||||
use RegistersUsers;
|
||||
|
||||
/**
|
||||
* Where to redirect users after registration.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a validator for an incoming registration request.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \Illuminate\Contracts\Validation\Validator
|
||||
*/
|
||||
protected function validator(array $data)
|
||||
{
|
||||
return Validator::make($data, [
|
||||
'name' => 'required|string|max:255',
|
||||
'email' => 'required|string|email|max:255|unique:users',
|
||||
'password' => 'required|string|min:6|confirmed',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new user instance after a valid registration.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \App\User
|
||||
*/
|
||||
protected function create(array $data)
|
||||
{
|
||||
return User::create([
|
||||
'name' => $data['name'],
|
||||
'email' => $data['email'],
|
||||
'password' => bcrypt($data['password']),
|
||||
]);
|
||||
}
|
||||
}
|
||||
39
app/Http/Controllers/Auth/ResetPasswordController.php
Executable file
39
app/Http/Controllers/Auth/ResetPasswordController.php
Executable file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
|
||||
class ResetPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset requests
|
||||
| and uses a simple trait to include this behavior. You're free to
|
||||
| explore this trait and override any methods you wish to tweak.
|
||||
|
|
||||
*/
|
||||
|
||||
use ResetsPasswords;
|
||||
|
||||
/**
|
||||
* Where to redirect users after resetting their password.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/home';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
}
|
||||
166
app/Http/Controllers/ClickAppsController.php
Executable file
166
app/Http/Controllers/ClickAppsController.php
Executable file
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models;
|
||||
use Illuminate\Http\Request;
|
||||
use Session;
|
||||
use DB;
|
||||
|
||||
|
||||
class ClickAppsController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$click_apps = DB::table('apps');
|
||||
$columns = [
|
||||
'app_name' => 'App Name',
|
||||
'operator' => 'Operator',
|
||||
'country' => 'Counry',
|
||||
'status' => 'Status'
|
||||
];
|
||||
if (!empty($request->filter) && !empty($request->keyword)) {
|
||||
$click_apps = $this->resolveAppQuery($click_apps, $request);
|
||||
}
|
||||
|
||||
$click_apps = $click_apps->orderBy('apps.created_at', 'DESC')->paginate(20);
|
||||
|
||||
$data = [
|
||||
'page_title' => 'Click Apps',
|
||||
'click_apps' => $click_apps,
|
||||
'columns' => $columns
|
||||
];
|
||||
|
||||
return view('click_apps.index', $data);
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$data = $this->crudData();
|
||||
return view('click_apps.create', $data);
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate($this->valdtePrams());
|
||||
DB::transaction(function () use ($request) {
|
||||
Models\ClickApps::create($request->only($this->whiteListCrudParams()));
|
||||
});
|
||||
Session::flash('success_message', 'App record created successfully');
|
||||
return redirect(url('clickapps/create'));
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$clickapp = Models\ClickApps::find($id);
|
||||
if (!$clickapp) {
|
||||
Session::flash('error_message', "Record with ID: {$id} not found");
|
||||
return redirect(url('clickapps'));
|
||||
}
|
||||
$data = $this->crudData();
|
||||
return view('click_apps.edit', array_merge($data, [
|
||||
'clickapp' => $clickapp
|
||||
]));
|
||||
}
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$clickapp = Models\ClickApps::find($id);
|
||||
if (!$clickapp) {
|
||||
Session::flash('error_message', "Record with ID: {$id} not found");
|
||||
return redirect(url('clickapps'));
|
||||
}
|
||||
$request->validate($this->valdtePrams());
|
||||
DB::transaction(function () use ($request, $clickapp) {
|
||||
$clickapp->update($request->only($this->whiteListCrudParams()));
|
||||
});
|
||||
Session::flash('success_message', 'App record updated successfully');
|
||||
return redirect(url('clickapps'));
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
Models\ClickApps::destroy($id);
|
||||
if (request()->ajax()) {
|
||||
$res = ['code' => 1];
|
||||
return response()->json($res);
|
||||
}
|
||||
Session::flash('success_message', 'App successfully deleted!');
|
||||
return redirect(url('clickapps'));
|
||||
}
|
||||
|
||||
private function crudData()
|
||||
{
|
||||
$click_apps = Models\ClickApps::get();
|
||||
$countries = Models\Country::pluck('en_short_name', 'alpha_2_code');
|
||||
$net_ops = Models\NetworkOps::pluck('name', 'name');
|
||||
$toll_types = ['YES' => 'YES', 'NO' => 'NO'];
|
||||
$status_types = ['ACTIVE' => 'ACTIVE', 'PENDING' => 'PENDING', 'CANCELLED' => 'CANCELLED', 'FINISHED' => 'FINISHED'];
|
||||
return [
|
||||
'page_title' => 'Click Apps',
|
||||
'click_apps' => $click_apps,
|
||||
'countries' => $countries,
|
||||
'net_ops' => $net_ops,
|
||||
'toll_types' => $toll_types,
|
||||
'status_types' => $status_types
|
||||
];
|
||||
}
|
||||
|
||||
private function valdtePrams()
|
||||
{
|
||||
return [
|
||||
'app_name' => 'required',
|
||||
'app_type' => 'required',
|
||||
'client' => 'required',
|
||||
'code' => 'required',
|
||||
'country' => 'required',
|
||||
'operator' => 'required',
|
||||
'tollfree' => 'required',
|
||||
'app_path' => 'required',
|
||||
'launch_date' => 'required',
|
||||
'status' => 'required',
|
||||
'other_info' => 'required',
|
||||
];
|
||||
}
|
||||
private function whiteListCrudParams()
|
||||
{
|
||||
return [
|
||||
'app_name',
|
||||
'app_type',
|
||||
'client',
|
||||
'code',
|
||||
'country',
|
||||
'operator',
|
||||
'tollfree',
|
||||
'app_path',
|
||||
'launch_date',
|
||||
'status',
|
||||
'other_info',
|
||||
];
|
||||
}
|
||||
|
||||
function resolveAppQuery($clients, $request)
|
||||
{
|
||||
switch ($request->filter) {
|
||||
case 'app_name':
|
||||
return $clients
|
||||
->where('app_name', 'like', "%$request->keyword%");
|
||||
break;
|
||||
case 'operator':
|
||||
return $clients
|
||||
->where('operator', 'like', "%$request->keyword%");
|
||||
break;
|
||||
case 'country':
|
||||
return $clients
|
||||
->where('country', 'like', "%$request->keyword%");
|
||||
break;
|
||||
case 'status':
|
||||
return $clients
|
||||
->where('status', 'like', "%$request->keyword%");
|
||||
break;
|
||||
default:
|
||||
# code...
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
200
app/Http/Controllers/ClickInfrastructureController.php
Executable file
200
app/Http/Controllers/ClickInfrastructureController.php
Executable file
@@ -0,0 +1,200 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models;
|
||||
use Session;
|
||||
|
||||
class ClickInfrastructureController extends Controller
|
||||
{
|
||||
|
||||
public function servers(){
|
||||
// dd(session('current_user'));
|
||||
// die;
|
||||
$servers = Models\ClickServer::with('direct_connections_info', 'credentials_info')->get();
|
||||
$data = [
|
||||
'page_title' => 'Servers',
|
||||
'servers' => $servers
|
||||
];
|
||||
return view('infrastructure.index', $data);
|
||||
|
||||
}
|
||||
public function domains(){
|
||||
|
||||
}
|
||||
public function create_direct($id)
|
||||
{
|
||||
|
||||
$server = Models\ClickServer::find($id);
|
||||
$data = [
|
||||
'page_title' => 'Servers',
|
||||
'server' => $server,
|
||||
'connection_types' => ['vpn' => 'VPN', 'fqdn' => 'FQDN' ]
|
||||
];
|
||||
return view('infrastructure.create_direct_connection', $data);
|
||||
}
|
||||
public function store_direct(Request $request){
|
||||
// dd($request->all());
|
||||
|
||||
$request->validate([
|
||||
'direct_partner' => 'required',
|
||||
'server_id' => 'required',
|
||||
'connection_type' => 'required',
|
||||
'port' => 'required_with:main_ip_address,domain_name',
|
||||
'main_ip_address' => 'sometimes|nullable|ip',
|
||||
'private_ip_address' => 'sometimes|nullable|ip',
|
||||
'domain_name' => 'required_if:connection_type,fqdn|nullable|regex:/^([a-zA-Z0-9][a-zA-Z0-9-_]*\.)*[a-zA-Z0-9]*[a-zA-Z0-9-_]*[[a-zA-Z0-9]+$/',
|
||||
'vpn_peer_ip' => 'required_if:connection_type,vpn|nullable|ip',
|
||||
'connection_form' => 'sometimes|nullable|max:2000|mimes:doc,docx,xlx,xlsx,png,jpg,jpeg,bmp,pdf',
|
||||
]);
|
||||
// dd($request->all());
|
||||
if ($request->main_ip_address == null && $request->domain_name == null ) {
|
||||
return redirect()->back()->withInput()->withErrors(['You need either an IP address or a Domain name']);
|
||||
}
|
||||
$direct_arr = $request->except('_token');
|
||||
$direct_arr['last_modified_by'] = session('current_user.id');
|
||||
|
||||
if ($request->hasFile('connection_form')) {
|
||||
if ($request->file('connection_form')->isValid()) {
|
||||
$filename = "connection_document_" . time() . "." . $request->connection_form->extension();
|
||||
$request->connection_form->storeAs('connection_files', $filename, 'public');
|
||||
$direct_arr['connection_document'] = $filename;
|
||||
}
|
||||
}
|
||||
// dd($direct_arr);
|
||||
|
||||
$result = Models\DirectConnection::create($direct_arr);
|
||||
Session::flash('success_message', 'Direct connection successfully added');
|
||||
return redirect(url('infrastructure/servers'));
|
||||
}
|
||||
|
||||
public function edit_direct($id)
|
||||
{
|
||||
|
||||
$direct_connection = Models\DirectConnection::find($id);
|
||||
// dump($direct_connection);
|
||||
// TNM_CLICKB_NOSIR_NEW_SMSC
|
||||
$server = Models\ClickServer::find($direct_connection->server_id);
|
||||
// dd($server);
|
||||
$data = [
|
||||
'page_title' => 'Servers',
|
||||
'server' => $server,
|
||||
'direct_connection' => $direct_connection,
|
||||
'connection_types' => ['vpn' => 'VPN', 'fqdn' => 'FQDN' ]
|
||||
];
|
||||
return view('infrastructure.edit_direct_connection', $data);
|
||||
}
|
||||
public function update_direct(Request $request){
|
||||
|
||||
$request->validate([
|
||||
'direct_partner' => 'required',
|
||||
'server_id' => 'required',
|
||||
'connection_type' => 'required',
|
||||
'port' => 'required_with:main_ip_address,domain_name',
|
||||
'main_ip_address' => 'sometimes|nullable|ip',
|
||||
'private_ip_address' => 'sometimes|nullable|ip',
|
||||
'domain_name' => 'sometimes|nullable|regex:/^([a-zA-Z0-9][a-zA-Z0-9-_]*\.)*[a-zA-Z0-9]*[a-zA-Z0-9-_]*[[a-zA-Z0-9]+$/',
|
||||
'vpn_peer_ip' => 'required_if:connection_type,vpn|nullable|ip',
|
||||
'connection_form' => 'sometimes|nullable|max:2000|mimes:doc,docx,xlx,xlsx,png,jpg,jpeg,bmp',
|
||||
]);
|
||||
if ($request->direct_id == null) {
|
||||
return redirect()->back()->withInput()->withErrors(['Your request could not be handled at this time. Try again!']);
|
||||
}
|
||||
$direct_connection = Models\DirectConnection::find($request->direct_id);
|
||||
|
||||
if ($request->main_ip_address == null && $request->domain_name == null ) {
|
||||
return redirect()->back()->withInput()->withErrors(['You need either an IP address or a Domain name']);
|
||||
}
|
||||
$direct_arr = $request->except('_token');
|
||||
$direct_arr['last_modified_by'] = session('current_user.id');
|
||||
// dd($direct_arr);
|
||||
|
||||
if ($request->hasFile('connection_form')) {
|
||||
if ($request->file('connection_form')->isValid()) {
|
||||
$filename = "connection_document_" . time() . "." . $request->connection_form->extension();
|
||||
$request->connection_form->storeAs('connection_files', $filename, 'public');
|
||||
$direct_arr['connection_document'] = $filename;
|
||||
}
|
||||
}
|
||||
|
||||
$result = $direct_connection->update($direct_arr);
|
||||
Session::flash('success_message', 'Direct connection successfully updated');
|
||||
return redirect(url('infrastructure/servers'));
|
||||
}
|
||||
public function server_list(){
|
||||
|
||||
$servers = Models\ClickServer::with('credentials_info')->get();
|
||||
// dd($servers[0]->credentials_info->where('username', 'root')->first());
|
||||
$data = [
|
||||
'page_title' => 'Servers',
|
||||
'servers' => $servers
|
||||
];
|
||||
return view('infrastructure.server_list', $data);
|
||||
|
||||
}
|
||||
public function edit_server($id)
|
||||
{
|
||||
$server = Models\ClickServer::find($id);
|
||||
$credentials = Models\ServerCredential::where('username', 'root')->where('server_id', $server->id) ->first();
|
||||
|
||||
$data = [
|
||||
'page_title' => 'Servers',
|
||||
'server' => $server,
|
||||
'credentials' => $credentials
|
||||
];
|
||||
return view('infrastructure.edit_server', $data);
|
||||
}
|
||||
public function updateserver(Request $request){
|
||||
$request->validate([
|
||||
'friendly_name' => 'required',
|
||||
'server_id' => 'required',
|
||||
'public_ip_address' => 'sometimes|ip',
|
||||
'private_ip_address' => 'sometimes|nullable|ip',
|
||||
'main_use' => 'required',
|
||||
'remarks' => 'nullable',
|
||||
'password' => 'nullable',
|
||||
]);
|
||||
$server = Models\ClickServer::findOrFail($request->server_id);
|
||||
$server_arr = $request->except('_token', 'password', 'server_id');
|
||||
$server_arr['last_modified_by'] = session('current_user.id');
|
||||
if ($request->password !== null) {
|
||||
// dd('foo bar');
|
||||
$credentials_arr = [
|
||||
'server_id' => $request->server_id,
|
||||
'username' => 'root',
|
||||
'password' => encrypt($request->password),
|
||||
'last_modified_by' => session('current_user.id')
|
||||
];
|
||||
$retval = Models\ServerCredential::find($request->server_id);
|
||||
if ($retval) {
|
||||
$retval->update($credentials_arr);
|
||||
}
|
||||
else{
|
||||
$result = Models\ServerCredential::create($credentials_arr);
|
||||
}
|
||||
}
|
||||
$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);
|
||||
}
|
||||
}
|
||||
//LJ School Location
|
||||
//5.637192,-0.158916
|
||||
//5.637093,-0.159269
|
||||
515
app/Http/Controllers/ClientsController.php
Executable file
515
app/Http/Controllers/ClientsController.php
Executable file
@@ -0,0 +1,515 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models;
|
||||
use Session;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Jobs\SendNewUssdClientEmail;
|
||||
use App\Jobs\SendUssdClientActiveEmail;
|
||||
|
||||
|
||||
class ClientsController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
|
||||
$client_arr = new Models\Client;
|
||||
$client_arr = $client_arr->with('auth_user_info','country_info', 'created_by_info')->orderBy('name', 'ASC')->paginate(10);
|
||||
|
||||
$data = [
|
||||
'page_title' => 'Clients',
|
||||
'client_arr' => $client_arr,
|
||||
'current_user' => session('current_user')
|
||||
];
|
||||
return view('client.index-tabulator', $data);
|
||||
}
|
||||
public function indexBak(){
|
||||
$client_arr = new Models\Client;
|
||||
$client_arr = $client_arr->with('auth_user_info','country_info', 'created_by_info')->orderBy('name', 'ASC')->paginate(10);
|
||||
$data = [
|
||||
'page_title' => 'Clients',
|
||||
'current_user' => session('current_user')
|
||||
];
|
||||
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')
|
||||
->select('clients.id', 'clients.name', 'clients.status', 'clients.country', 'aumngr.name As accountMgr', 'aumodify.name AS modifiedBy')
|
||||
->paginate(15);
|
||||
|
||||
if($request->has('keyword')){ // != ''
|
||||
$keyword = $request->keyword;
|
||||
$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')
|
||||
->select('clients.id','clients.name', 'clients.status', 'clients.country', 'aumngr.name As accountMgr', 'aumodify.name AS modifiedBy')
|
||||
->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%'")
|
||||
->paginate(15);
|
||||
}
|
||||
|
||||
return response()->json($client_arr);
|
||||
}
|
||||
public function getClientJsonRawJs(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);
|
||||
|
||||
$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')
|
||||
->select('clients.id', 'clients.name', 'clients.status', 'clients.country', 'aumngr.name As accountMgr', 'aumodify.name AS modifiedBy')
|
||||
->paginate(10);
|
||||
|
||||
if($request->has('keyword')){ // != ''
|
||||
$keyword = $request->keyword;
|
||||
$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')
|
||||
->select('clients.id','clients.name', 'clients.status', 'clients.country', 'aumngr.name As accountMgr', 'aumodify.name AS modifiedBy')
|
||||
->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%'")
|
||||
->paginate(10);
|
||||
}
|
||||
return response()->json($client_arr);
|
||||
}
|
||||
public function indexOriginal()
|
||||
{
|
||||
|
||||
$client_arr = new Models\Client;
|
||||
$table_columns = \DB::select(\DB::raw("show full columns from clients"));
|
||||
$exclude_arr = [
|
||||
'updated_at', 'id', 'auth_user_id', 'pay_mode', 'type', 'created_at', 'currency'
|
||||
];
|
||||
$columns = [];
|
||||
$queries = [];
|
||||
foreach ($table_columns as $key) {
|
||||
$columns[$key->Field] = $key->Field;
|
||||
}
|
||||
foreach ($columns as $col) {
|
||||
if (request('filter') == $col) {
|
||||
$filter = request('filter');
|
||||
$keyword = request('keyword');
|
||||
$table_arr = ['staff_id', 'pay_mode'];
|
||||
// dump($col);
|
||||
// dump(in_array($col, $table_arr));
|
||||
if (in_array($col, $table_arr)) {
|
||||
$key = $this->get_filter_ids($filter, $keyword);
|
||||
if (!empty($key)) {
|
||||
$keyword = $key;
|
||||
}
|
||||
}
|
||||
$client_arr = $client_arr->where($col, 'like', '%'.$keyword.'%');
|
||||
$queries[$col] = request('keyword');
|
||||
}
|
||||
}
|
||||
|
||||
$client_arr = $client_arr->with('payment_type_info', 'service_info', 'auth_user_info', 'created_by_info')->orderBy('name', 'ASC')->paginate(10)->appends($queries);
|
||||
$columns = Arr::except($columns, $exclude_arr);
|
||||
$columns['pay_mode'] = 'Payment Mode';
|
||||
$data = [
|
||||
'page_title' => 'Clients',
|
||||
'columns' => $columns,
|
||||
'client_arr' => $client_arr,
|
||||
'current_user' => session('current_user')
|
||||
];
|
||||
return view('client.index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$countries = Models\Country::pluck('en_short_name','alpha_2_code');
|
||||
$service_type = Models\Service::pluck('name', 'id');
|
||||
$payment_type = Models\PaymentType::pluck('name', 'id');
|
||||
$auth_users = Models\Account::pluck('name', 'id');
|
||||
$status = ['Live' => 'Live', 'inactive' => 'Inactive', 'Prospective' => 'Prospective'];
|
||||
$currency = Models\Currency::pluck('name','name');
|
||||
|
||||
$data = [
|
||||
'page_title' => 'Create Client',
|
||||
'countries' => $countries,
|
||||
'service_type' => $service_type,
|
||||
'status' => $status,
|
||||
'currency' => $currency,
|
||||
'auth_users' => $auth_users,
|
||||
'payment_type' => $payment_type
|
||||
];
|
||||
|
||||
return view('client.create', $data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'name' => 'required|unique:clients,name',
|
||||
'email' => 'required|email',
|
||||
'services' => 'required',
|
||||
'country' => 'required',
|
||||
'status' => 'required',
|
||||
'payment_mode' => 'required',
|
||||
'currency' => 'required',
|
||||
'auth_user_id' => 'required', // account manager
|
||||
]);
|
||||
|
||||
|
||||
// dd($request->all());
|
||||
//'email' => 'unique:users,email_address'
|
||||
$client_arr = [
|
||||
'name' => $request->name,
|
||||
'email' => $request->email,
|
||||
'country' => $request->country,
|
||||
'status' => $request->status,
|
||||
'pay_mode' => $request->payment_mode,
|
||||
'currency' => $request->currency,
|
||||
'auth_user_id' => $request->auth_user_id, // account manager
|
||||
'created_by' => session('current_user.id'),
|
||||
'last_modified_by' => session('current_user.id')
|
||||
];
|
||||
if ($request->notes) {
|
||||
$client_arr['notes'] = $request->notes;
|
||||
}
|
||||
if ($request->skype_name) {
|
||||
$client_arr['skype_name'] = $request->skype_name;
|
||||
}
|
||||
if ($request->linkedin_name) {
|
||||
$client_arr['linkedin_name'] = $request->linkedin_name;
|
||||
}
|
||||
|
||||
$result = Models\Client::create($client_arr);
|
||||
|
||||
if (in_array('3', $request->services)) {
|
||||
\Log::info('ussd client detected');
|
||||
$ussd_client_payment_arr = [
|
||||
'client_id' => $result->id,
|
||||
'last_modified_by_id' => session('current_user.id')
|
||||
];
|
||||
$retval = Models\UssdClientPayment::create($ussd_client_payment_arr);
|
||||
//TODO send an email to jim/priscilla about new USSD client,
|
||||
#dispatch(new SendNewUssdClientEmail($result));
|
||||
}
|
||||
$retval = $this->store_services($request->services, $result->id);
|
||||
|
||||
Session::flash('success_message', 'Client successfully added');
|
||||
return redirect(url('clients'));
|
||||
}
|
||||
public function notesStore(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'client_id' => 'required',
|
||||
'notes_body' => 'required'
|
||||
]);
|
||||
$auth_user = session('current_user');
|
||||
|
||||
// dd($request->all());
|
||||
//'email' => 'unique:users,email_address'
|
||||
$notes_arr = [
|
||||
'notes_body' => $request->notes_body,
|
||||
'services' => implode(',', $request->services),
|
||||
'auth_user_id' => $auth_user['id'],
|
||||
'client_id' => $request->client_id
|
||||
];
|
||||
|
||||
//todo : send emails
|
||||
//dd($notes_arr);
|
||||
$result = Models\ClientNote::create($notes_arr);
|
||||
if ($result) {
|
||||
$data = ['code' => 1, 'msg' => 'Notes successfully added'];
|
||||
}
|
||||
else{
|
||||
$data = ['code' => 3, 'msg' => 'Your request could not be handled at this time'];
|
||||
}
|
||||
return response()->json($data, 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
|
||||
$showclient = Models\Client::with('service_info', 'country_info', 'auth_user_info')->find($id);
|
||||
$service_type = Models\Service::pluck('name', 'id');
|
||||
$service_type_names = Models\Service::pluck('name', 'name');
|
||||
$show_services = Models\ClientCategory::where('client_id', $id)->get();
|
||||
$show_notes = Models\ClientNote::with('created_by_info', 'client_info')->where('client_id', $id)->orderBy('id', 'DESC')->get()->take(20);
|
||||
|
||||
|
||||
$data = [
|
||||
'page_title' => 'Show Client',
|
||||
'showclient' => $showclient,
|
||||
'show_services' => $show_services,
|
||||
'service_type' => $service_type,
|
||||
'service_type_names' => $service_type_names,
|
||||
'show_notes' => $show_notes
|
||||
];
|
||||
|
||||
return view('client.show', $data);
|
||||
}
|
||||
public function showservices($id)
|
||||
{
|
||||
$show_services = Models\ClientCategory::where('client_id', $id)->get();
|
||||
dd($show_services);
|
||||
$data = [
|
||||
'page_title' => 'Show Services',
|
||||
'show_services' => $show_services
|
||||
];
|
||||
|
||||
return view('client.services', $data);
|
||||
}
|
||||
public function editservice($id)
|
||||
{
|
||||
$service = Models\ClientCategory::find($id);
|
||||
dd($service);
|
||||
$data = [
|
||||
'page_title' => 'Show Services',
|
||||
'service' => $service
|
||||
];
|
||||
return view('client.service-edit', $data);
|
||||
}
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$client = Models\Client::find($id);
|
||||
|
||||
|
||||
$service_type = Models\Service::pluck('name', 'id');
|
||||
// $payment_type = Models\PaymentType::pluck('name', 'id');
|
||||
|
||||
$countries = Models\Country::pluck('en_short_name','alpha_2_code');
|
||||
|
||||
$payment_type = [1 => 'Prepaid', 2 => 'Postpaid']; // Models\PaymentType::pluck('name', 'id')->toArray();
|
||||
$status = ['Live' => 'Live', 'inactive' => 'Inactive', 'Prospective' => 'Prospective'];
|
||||
$currency = Models\Currency::pluck('name', 'name'); //
|
||||
// dd($currency);
|
||||
$auth_users = Models\Account::pluck('name', 'id');
|
||||
|
||||
// dump(array_flatten($client->client_services));
|
||||
$data = [
|
||||
'client' => $client,
|
||||
'countries' => $countries,
|
||||
'service_type' => $service_type->toArray(),
|
||||
'payment_type' => $payment_type,
|
||||
'status' => $status,
|
||||
'auth_users' => $auth_users,
|
||||
'currency' => $currency
|
||||
];
|
||||
// dd($service_type->toArray());
|
||||
return view('client.edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
|
||||
$request->validate([
|
||||
'name' => 'required',
|
||||
// 'email' => 'required|email',
|
||||
// 'services' => 'required',
|
||||
'country' => 'required',
|
||||
'status' => 'required',
|
||||
// 'payment_mode' => 'required',
|
||||
'currency' => 'required',
|
||||
]);
|
||||
$client_update = Models\Client::find($id);
|
||||
|
||||
//dd($request->all());
|
||||
$client_update->name = $request->name;
|
||||
$client_update->email = $request->email;
|
||||
$client_update->contact_person = $request->contact_person;
|
||||
$client_update->status = $request->status;
|
||||
$client_update->pay_mode = $request->payment_mode;
|
||||
$client_update->country = $request->country;
|
||||
$client_update->currency = $request->currency;
|
||||
$client_update->notes = $request->notes;
|
||||
$client_update->skype_name = $request->skype_name;
|
||||
$client_update->linkedin_name = $request->linkedin_name;
|
||||
$client_update->created_by = session('current_user.id');
|
||||
$client_update->last_modified_by = session('current_user.id');
|
||||
|
||||
$result = $client_update->save();
|
||||
|
||||
$client = Models\Client::find($id);
|
||||
/*
|
||||
if (in_array('3', $request->services)) {
|
||||
if ($request->status == 'active' && $client_update->status !== 'active') {
|
||||
\log::info('ussd client active detected');
|
||||
#dispatch(new SendUssdClientActiveEmail($client));
|
||||
}
|
||||
}
|
||||
|
||||
if (in_array('3', $request->services)) {
|
||||
\Log::info('ussd client detected');
|
||||
$ussd_client_payment_arr = [
|
||||
'client_id' => $client_update->id,
|
||||
'last_modified_by_id' => session('current_user.id')
|
||||
];
|
||||
$retval = Models\UssdClientPayment::create($ussd_client_payment_arr);
|
||||
//TODO send an email to jim/priscilla about new USSD client,
|
||||
#dispatch(new SendNewUssdClientEmail($client_update));
|
||||
}
|
||||
$retval = $this->update_services($request->services, $client_update->id);
|
||||
*/
|
||||
|
||||
|
||||
|
||||
Session::flash('success_message', 'Client successfully Updated');
|
||||
return redirect(url('clients'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$result = Models\Client::destroy($id);
|
||||
if (request()->ajax()) {
|
||||
$result_arr = ['code' => 1];
|
||||
return response()->json($result_arr);
|
||||
}
|
||||
Session::flash('success_message', 'Client successfully deleted!');
|
||||
return redirect(route('client.index'));
|
||||
}
|
||||
|
||||
public function store_services($services_arr, $client_id){
|
||||
foreach ($services_arr as $id) {
|
||||
$client_arr = [
|
||||
'client_id' => $client_id,
|
||||
'category_id' => $id
|
||||
];
|
||||
$result = Models\ClientCategory::create($client_arr);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public function update_services($services_arr, $client_id){
|
||||
// remove and add will think of a better approach later
|
||||
$result = Models\ClientCategory::where('client_id', $client_id)->delete();
|
||||
|
||||
foreach ($services_arr as $id) {
|
||||
$client_arr = [
|
||||
'client_id' => $client_id,
|
||||
'category_id' => $id
|
||||
];
|
||||
$result = Models\ClientCategory::create($client_arr);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function get_filter_ids($filter, $keyword)
|
||||
{
|
||||
switch ($filter) {
|
||||
case 'status':
|
||||
$id = Models\Client::where('status', 'like', "%$keyword%")->get(['id']);
|
||||
if ($id->isEmpty()) {
|
||||
return '';
|
||||
}
|
||||
$step = json_decode($id);
|
||||
$the_id = $step[0]->id;
|
||||
return (count($step) > 0 ) ? $step[0]->id : "";
|
||||
break;
|
||||
case 'type':
|
||||
$id = Models\Client::where('type', 'like', "%$keyword%")->get(['id']);
|
||||
if ($id->isEmpty()) {
|
||||
return '';
|
||||
}
|
||||
$step = json_decode($id);
|
||||
$the_id = $step[0]->id;
|
||||
return (count($step) > 0 ) ? $step[0]->id : "";
|
||||
break;
|
||||
case 'country':
|
||||
$id = Models\Country::where('alpha_2_code', 'like', "%$keyword%")->orWhere('alpha_3_code', 'like', "%$keyword%")->orWhere('en_short_name', 'like', "%$keyword%")->get(['id']);
|
||||
if ($id->isEmpty()) {
|
||||
return '';
|
||||
}
|
||||
$step = json_decode($id);
|
||||
$the_id = $step[0]->id;
|
||||
return (count($step) > 0 ) ? $step[0]->id : "";
|
||||
break;
|
||||
case 'currency':
|
||||
$id = Models\Client::where('currency', 'like', "%$keyword%")->get(['id']);
|
||||
if ($id->isEmpty()) {
|
||||
return '';
|
||||
}
|
||||
$step = json_decode($id);
|
||||
$the_id = $step[0]->id;
|
||||
return (count($step) > 0 ) ? $step[0]->id : "";
|
||||
break;
|
||||
case 'auth_user_id':
|
||||
$id = Models\SystemUser::where('name', 'like', "%$keyword%")->get(['id']);
|
||||
if ($id->isEmpty()) {
|
||||
return '';
|
||||
}
|
||||
$step = json_decode($id);
|
||||
$the_id = $step[0]->id;
|
||||
return (count($step) > 0 ) ? $step[0]->id : "";
|
||||
break;
|
||||
case 'name':
|
||||
// $this->log_query();
|
||||
$id = Models\Client::where('name', 'like', "%$keyword%")->get(['id']);
|
||||
if ($id->isEmpty()) {
|
||||
return '';
|
||||
}
|
||||
$step = json_decode($id);
|
||||
return (count($step) > 0 ) ? $step[0]->id : "";
|
||||
break;
|
||||
case 'pay_mode':
|
||||
// $this->log_query();
|
||||
$id = Models\PaymentType::where('name', 'like', "%$keyword%")->get(['id']);
|
||||
if ($id->isEmpty()) {
|
||||
return '';
|
||||
}
|
||||
$step = json_decode($id);
|
||||
return (count($step) > 0 ) ? $step[0]->id : "";
|
||||
break;
|
||||
default:
|
||||
return '';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
19
app/Http/Controllers/Controller.php
Executable file
19
app/Http/Controllers/Controller.php
Executable file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
public function log_query() {
|
||||
\DB::listen(function ($sql) {
|
||||
\Log::info('showing query', array('sql' => $sql));
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
15
app/Http/Controllers/DashboardController.php
Executable file
15
app/Http/Controllers/DashboardController.php
Executable file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
public function index(){
|
||||
$data = [
|
||||
'page_title' => 'Dashboard'
|
||||
];
|
||||
return view('dashboard.index', $data);
|
||||
}
|
||||
}
|
||||
20
app/Http/Controllers/FilesController.php
Executable file
20
app/Http/Controllers/FilesController.php
Executable file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class FilesController extends Controller
|
||||
{
|
||||
public function index(){
|
||||
// dd(session('current_user'));
|
||||
// die;
|
||||
$files = Models\ClickFile::get();
|
||||
$data = [
|
||||
'page_title' => 'Files',
|
||||
'servers' => $files
|
||||
];
|
||||
return view('infrastructure.index', $data);
|
||||
//sudo chown vagrant.vagrant ~/.npm/ -R
|
||||
}
|
||||
}
|
||||
28
app/Http/Controllers/HomeController.php
Executable file
28
app/Http/Controllers/HomeController.php
Executable file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Support\Renderable
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('home');
|
||||
}
|
||||
}
|
||||
70
app/Http/Controllers/LoginController.php
Executable file
70
app/Http/Controllers/LoginController.php
Executable file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
public function getLoginPage(){
|
||||
$designation = Models\Designation::pluck('name', 'id');
|
||||
$data = [
|
||||
'designation' => $designation
|
||||
];
|
||||
|
||||
return view('login.index', $data);
|
||||
}
|
||||
|
||||
public function handleLogin(Request $request){
|
||||
$this->validate($request, ['email' => 'required', 'password' => 'required']);
|
||||
|
||||
$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();
|
||||
}
|
||||
|
||||
$request->session()->regenerate(true);
|
||||
$request->session()->put('current_user.id', $logged_in->id);
|
||||
$request->session()->put('current_user.name', $logged_in->name);
|
||||
$request->session()->put('current_user.email', $logged_in->email);
|
||||
$request->session()->put('current_user.phone', $logged_in->phone);
|
||||
$request->session()->put('current_user.designation', $logged_in->designation_info->name);
|
||||
|
||||
// return redirect(url('dashboard'));
|
||||
return redirect(url('clients'));
|
||||
}
|
||||
|
||||
public function handle_logout(Request $request) {
|
||||
|
||||
$request->session()->forget('current_user');
|
||||
$request->session()->flush();
|
||||
$request->session()->regenerate(true);
|
||||
return redirect("/");
|
||||
}
|
||||
|
||||
public function registerAccount(Request $request){
|
||||
dd($request->all());
|
||||
$request->validate([
|
||||
'name' => 'required',
|
||||
'designation' => 'required',
|
||||
'email' => 'required',
|
||||
'phone' => 'required',
|
||||
'password' => 'required',
|
||||
'confirm_password' => 'same:password',
|
||||
]);
|
||||
|
||||
$make_account = [
|
||||
'name' => $request->name,
|
||||
'designation' => $request->designation,
|
||||
'email' => $request->email,
|
||||
'phone' => $request->phone,
|
||||
'password' => md5($request->password)
|
||||
];
|
||||
|
||||
$inserted = Models\Account::create($make_account);
|
||||
Session::flash('success_message', 'Account successfully added');
|
||||
return redirect(url('/'));
|
||||
}
|
||||
}
|
||||
270
app/Http/Controllers/MarketerReportController.php
Executable file
270
app/Http/Controllers/MarketerReportController.php
Executable file
@@ -0,0 +1,270 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models;
|
||||
use Illuminate\Http\Request;
|
||||
use Session;
|
||||
use DB;
|
||||
|
||||
|
||||
class MarketerReportController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$market_reports = Models\MarketReport::where('market_reports.id', '>', 0);
|
||||
$payment_type = [1 => 'Prepaid', 2 => 'Postpaid'];
|
||||
|
||||
$columns = [
|
||||
'service' => 'Service',
|
||||
'email' => 'Email',
|
||||
'discussion' => 'Discussion',
|
||||
'contact_person' => 'Contact Person',
|
||||
'payment_status' => 'Payment Status',
|
||||
'sam_comment' => 'Sam Comment',
|
||||
'status' => 'status',
|
||||
'client' => 'Client',
|
||||
'auth_user_id' => 'User',
|
||||
'payment_type' => 'Payment Type',
|
||||
];
|
||||
|
||||
if (!empty($request->filter) && !empty($request->keyword)) {
|
||||
$market_reports = $this->resolveAppQuery($market_reports, $request);
|
||||
}
|
||||
|
||||
$market_reports = $market_reports->orderBy('market_reports.created_at', 'DESC')->paginate(20);
|
||||
|
||||
$data = [
|
||||
'page_title' => 'Click Apps',
|
||||
'market_reports' => $market_reports,
|
||||
'columns' => $columns,
|
||||
'payment_type' => $payment_type
|
||||
];
|
||||
|
||||
return view('marketer_report.index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$clients = Models\Client::pluck('name', 'id');
|
||||
$service = Models\Service::pluck('name', 'name');
|
||||
$payment_type = Models\PaymentType::pluck('name', 'id');
|
||||
$payment_status = ['paid' => 'Paid', 'unpaid' => 'Unpaid'];
|
||||
|
||||
$data = [
|
||||
'page_title' => 'Marketing Report',
|
||||
'service' => $service,
|
||||
'clients' => $clients,
|
||||
'payment_type' => $payment_type,
|
||||
'payment_status' => $payment_status
|
||||
];
|
||||
|
||||
return view('marketer_report.create', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate($this->mkrtRrptValidations());
|
||||
$reportData = $request->only($this->mkrtRrptWhiteListParms());
|
||||
$reportData['auth_user_id'] = session('current_user.id');
|
||||
|
||||
DB::transaction(function () use ($reportData) {
|
||||
Models\MarketReport::create($reportData);
|
||||
});
|
||||
|
||||
Session::flash('success_message', 'Report successfully added');
|
||||
return redirect(url('marketreport'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$market_report = Models\MarketReport::with('client_info', 'auth_user_info')->where('id', $id)->first();
|
||||
$data = [
|
||||
'page_title' => 'Report Details',
|
||||
'market_report' => $market_report
|
||||
];
|
||||
return view('marketer_report.show', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$market_report = Models\MarketReport::find($id);
|
||||
if (!$market_report) {
|
||||
Session::flash('error_message', "Record with ID: {$id} not found");
|
||||
return redirect(url('marketreport'));
|
||||
}
|
||||
$clients = Models\Client::pluck('name', 'id');
|
||||
$service = Models\Service::pluck('name', 'name');
|
||||
$payment_type = Models\PaymentType::pluck('name', 'id');
|
||||
$payment_status = ['paid' => 'Paid', 'unpaid' => 'Unpaid'];
|
||||
|
||||
$data = [
|
||||
'page_title' => 'Edit Meeting Report',
|
||||
'market_report' => $market_report,
|
||||
'service' => $service,
|
||||
'clients' => $clients,
|
||||
'payment_type' => $payment_type,
|
||||
'payment_status' => $payment_status
|
||||
];
|
||||
|
||||
return view('marketer_report.edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$market_report = Models\MarketReport::find($id);
|
||||
if (!$market_report) {
|
||||
Session::flash('error_message', "Record with ID: {$id} not found");
|
||||
return redirect(url('marketreport'));
|
||||
}
|
||||
$request->validate($this->mkrtRrptValidations());
|
||||
$reportData = $request->only($this->mkrtRrptWhiteListParms());
|
||||
$reportData['auth_user_id'] = session('current_user.id');
|
||||
|
||||
DB::transaction(function () use ($reportData, $market_report) {
|
||||
$market_report->update($reportData);
|
||||
});
|
||||
|
||||
Session::flash('success_message', 'Market report updated successfully');
|
||||
return redirect(url('marketreport'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
Models\MarketReport::destroy($id);
|
||||
if (request()->ajax()) {
|
||||
$res = ['code' => 1];
|
||||
return response()->json($res);
|
||||
}
|
||||
Session::flash('success_message', 'Market report successfully deleted!');
|
||||
return redirect(url('clickapps'));
|
||||
}
|
||||
|
||||
public function mkrtRrptValidations()
|
||||
{
|
||||
return [
|
||||
'client' => 'required',
|
||||
'service' => 'required',
|
||||
'contact_person' => 'required',
|
||||
'email' => 'required',
|
||||
'discussion' => 'required',
|
||||
'payment_type' => 'required',
|
||||
'current_balance' => 'required|numeric',
|
||||
'payment_status' => 'required',
|
||||
'next_follow_up_date' => 'required',
|
||||
'last_follow_up_date' => 'required'
|
||||
];
|
||||
}
|
||||
|
||||
public function mkrtRrptWhiteListParms()
|
||||
{
|
||||
return [
|
||||
'client',
|
||||
'service',
|
||||
'contact_person',
|
||||
'email',
|
||||
'discussion',
|
||||
'payment_type',
|
||||
'current_balance',
|
||||
'payment_status',
|
||||
'next_follow_up_date',
|
||||
'last_follow_up_date',
|
||||
];
|
||||
}
|
||||
|
||||
function resolveAppQuery($clients, $request)
|
||||
{
|
||||
switch ($request->filter) {
|
||||
case 'service':
|
||||
return $clients
|
||||
->where('service', 'like', "%$request->keyword%");
|
||||
break;
|
||||
case 'email':
|
||||
return $clients
|
||||
->where('email', 'like', "%$request->keyword%");
|
||||
break;
|
||||
case 'discussion':
|
||||
return $clients
|
||||
->where('discussion', 'like', "%$request->keyword%");
|
||||
break;
|
||||
case 'contact_person':
|
||||
return $clients
|
||||
->where('contact_person', 'like', "%$request->keyword%");
|
||||
break;
|
||||
case 'payment_status':
|
||||
return $clients
|
||||
->where('payment_status', 'like', "%$request->keyword%");
|
||||
break;
|
||||
case 'sam_comment':
|
||||
return $clients
|
||||
->where('sam_comment', 'like', "%$request->keyword%");
|
||||
break;
|
||||
case 'status':
|
||||
return $clients
|
||||
->where('status', 'like', "%$request->keyword%");
|
||||
break;
|
||||
case 'client':
|
||||
return $clients
|
||||
->join('clients', 'clients.id', '=', 'market_reports.client')
|
||||
->where('clients.name', 'like', "%$request->keyword%");
|
||||
break;
|
||||
case 'auth_user_id':
|
||||
return $clients
|
||||
->join('auth_users', 'auth_users.id', '=', 'market_reports.auth_user_id')
|
||||
->where('auth_users.name', 'like', "%$request->keyword%");
|
||||
break;
|
||||
case 'payment_type':
|
||||
return $clients
|
||||
->join('payment_type', 'payment_type.id', '=', 'market_reports.payment_type')
|
||||
->where('payment_type.name', 'like', "%$request->keyword%");
|
||||
break;
|
||||
default:
|
||||
# code...
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// payment_type
|
||||
461
app/Http/Controllers/MeetingReportsController.php
Executable file
461
app/Http/Controllers/MeetingReportsController.php
Executable file
@@ -0,0 +1,461 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models;
|
||||
use Session;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
|
||||
class MeetingReportsController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
if (request()->has('filter', 'keyword')){ // == true && request()->keyword = ) {
|
||||
// dd('foo detected');
|
||||
$keyword = request()->keyword;
|
||||
$filter = request()->filter;
|
||||
if ($filter == 'Location') {
|
||||
$keyword = Models\Country::where('en_short_name', 'LIKE', $keyword)->get();
|
||||
}
|
||||
$clients = Models\Client::with('report_info')->where($filter, $keyword)
|
||||
->orderBy('name', 'ASC')->paginate(1);
|
||||
}
|
||||
$clients = Models\Client::with('report_info')->orderBy('name', 'ASC')->paginate(1);
|
||||
|
||||
$data = [
|
||||
'page_title' => 'Meeting Report',
|
||||
'columns' => ['Name' => 'Client Name', 'Location' => 'Client Location'],
|
||||
'clients' => $clients
|
||||
];
|
||||
// dd($clients[0]);
|
||||
return view('report.dashboardreport', $data);
|
||||
}
|
||||
public function search()
|
||||
{
|
||||
dd(request()->has('filter', 'keyword'));
|
||||
dd(request()->all());
|
||||
|
||||
$clients = Models\Client::with('report_info')->orderBy('name', 'ASC')->paginate(1);
|
||||
|
||||
$data = [
|
||||
'page_title' => 'Meeting Report',
|
||||
'columns' => ['Name' => 'Client Name', 'Location' => 'Client Location'],
|
||||
'clients' => $clients
|
||||
];
|
||||
// dd($clients[0]);
|
||||
return view('report.dashboardreport', $data);
|
||||
}
|
||||
public function indexBKTwo()
|
||||
{
|
||||
$clients = Models\Client::with('report_info')->get();
|
||||
dd($clients);
|
||||
$meeting_report_arr = new Models\MeetingReport;
|
||||
$table_columns = \DB::select(\DB::raw("show full columns from meeting_reports"));
|
||||
$exclude_arr = [
|
||||
'updated_at', 'id','created_at'
|
||||
];
|
||||
$columns = [];
|
||||
$queries = [];
|
||||
foreach ($table_columns as $key) {
|
||||
if ($key->Field == 'auth_user_id') {
|
||||
$columns[$key->Field] = 'Account Manager';
|
||||
}
|
||||
else{
|
||||
$columns[$key->Field] = ucwords(str_replace('_', ' ', $key->Field));
|
||||
}
|
||||
}
|
||||
foreach ($columns as $col) {
|
||||
if (request('filter') == $col) {
|
||||
$filter = request('filter');
|
||||
$keyword = request('keyword');
|
||||
$table_arr = ['staff_id', 'payment_type'];
|
||||
if (in_array($col, $table_arr)) {
|
||||
$key = $this->get_filter_ids($filter, $keyword);
|
||||
if (!empty($key)) {
|
||||
$keyword = $key;
|
||||
}
|
||||
}
|
||||
$meeting_report_arr = $meeting_report_arr->where($col, 'like', '%'.$keyword.'%');
|
||||
$queries[$col] = request('keyword');
|
||||
}
|
||||
}
|
||||
/*
|
||||
if (session('current_user.designation') == 'administrator') {
|
||||
$meeting_report_arr = $meeting_report_arr->with('client_info', 'auth_user_info', 'sam_comment_info')->orderBy('created_at', 'DESC')->paginate(40)->appends($queries);
|
||||
}
|
||||
else{
|
||||
$meeting_report_arr = $meeting_report_arr->with('client_info', 'auth_user_info', 'sam_comment_info')
|
||||
->where('auth_user_id', session('current_user.id'))
|
||||
->orderBy('created_at', 'DESC')->paginate(40)->appends($queries);
|
||||
}
|
||||
*/
|
||||
$meeting_report_arr = $meeting_report_arr->with('client_info', 'auth_user_info', 'sam_comment_info')->orderBy('created_at', 'DESC')->paginate(40)->appends($queries);
|
||||
|
||||
$payment_type = [ 1 => 'Prepaid', 2 => 'Postpaid'];
|
||||
$data = [
|
||||
'page_title' => 'Meeting Report',
|
||||
'columns' => Arr::except($columns, $exclude_arr),
|
||||
'meeting_report_arr' => $meeting_report_arr,
|
||||
'payment_type' => $payment_type
|
||||
];
|
||||
return view('report.index', $data);
|
||||
}
|
||||
|
||||
public function indexBK()
|
||||
{
|
||||
$meeting_report_arr = new Models\MeetingReport;
|
||||
$table_columns = \DB::select(\DB::raw("show full columns from meeting_reports"));
|
||||
$exclude_arr = [
|
||||
'updated_at', 'id','created_at'
|
||||
];
|
||||
$columns = [];
|
||||
$queries = [];
|
||||
foreach ($table_columns as $key) {
|
||||
if ($key->Field == 'auth_user_id') {
|
||||
$columns[$key->Field] = 'Account Manager';
|
||||
}
|
||||
else{
|
||||
$columns[$key->Field] = ucwords(str_replace('_', ' ', $key->Field));
|
||||
}
|
||||
}
|
||||
foreach ($columns as $col) {
|
||||
if (request('filter') == $col) {
|
||||
$filter = request('filter');
|
||||
$keyword = request('keyword');
|
||||
$table_arr = ['staff_id', 'payment_type'];
|
||||
if (in_array($col, $table_arr)) {
|
||||
$key = $this->get_filter_ids($filter, $keyword);
|
||||
if (!empty($key)) {
|
||||
$keyword = $key;
|
||||
}
|
||||
}
|
||||
$meeting_report_arr = $meeting_report_arr->where($col, 'like', '%'.$keyword.'%');
|
||||
$queries[$col] = request('keyword');
|
||||
}
|
||||
}
|
||||
if (session('current_user.designation') == 'administrator') {
|
||||
$meeting_report_arr = $meeting_report_arr->with('client_info', 'auth_user_info', 'sam_comment_info')->orderBy('created_at', 'DESC')->paginate(40)->appends($queries);
|
||||
}
|
||||
else{
|
||||
$meeting_report_arr = $meeting_report_arr->with('client_info', 'auth_user_info', 'sam_comment_info')
|
||||
->where('auth_user_id', session('current_user.id'))
|
||||
->orderBy('created_at', 'DESC')->paginate(40)->appends($queries);
|
||||
}
|
||||
|
||||
$payment_type = [ 1 => 'Prepaid', 2 => 'Postpaid'];
|
||||
$data = [
|
||||
'page_title' => 'Meeting Report',
|
||||
'columns' => Arr::except($columns, $exclude_arr),
|
||||
'meeting_report_arr' => $meeting_report_arr,
|
||||
'payment_type' => $payment_type
|
||||
];
|
||||
return view('report.index', $data);
|
||||
}
|
||||
public function showDetails($id = '')
|
||||
{
|
||||
// dump(session('current_user'));
|
||||
$selected_user = '';
|
||||
$meeting_report_arr = new Models\MeetingReport;
|
||||
$current_user = session('current_user.id');
|
||||
|
||||
if (session('current_user.designation') == 'administrator') {
|
||||
$meeting_report_arr = $meeting_report_arr->with('client_info', 'auth_user_info', 'sam_comment_info')->orderBy('created_at', 'DESC')->paginate(20);
|
||||
}
|
||||
else{
|
||||
$meeting_report_arr = $meeting_report_arr->with('client_info', 'auth_user_info', 'sam_comment_info')->where('auth_user_id', $current_user)->orderBy('created_at', 'DESC')->paginate(20);
|
||||
}
|
||||
|
||||
if ($id !== '') {
|
||||
//->where('auth_user_id', $current_user)
|
||||
$main_discussion = Models\MeetingReport::with('client_info', 'auth_user_info')->where('id', $id)->first();
|
||||
}
|
||||
else{
|
||||
if (session('current_user.designation') == 'administrator') {
|
||||
$main_discussion = Models\MeetingReport::with('client_info', 'auth_user_info')->get()->last();
|
||||
}
|
||||
else{
|
||||
$main_discussion = Models\MeetingReport::with('client_info', 'auth_user_info')->where('auth_user_id', $current_user)->get()->last();
|
||||
}
|
||||
|
||||
}
|
||||
// dump($current_user);
|
||||
//$main_discussion = Models\MeetingReport::with('client_info', 'auth_user_info')->where('auth_user_id', $current_user)->get()->last();
|
||||
// dd($main_discussion);
|
||||
// \Log::info('foo bar in the app');
|
||||
if (!$main_discussion) {
|
||||
return redirect(url('reports'));
|
||||
}
|
||||
$payment_type = [ 1 => 'Prepaid', 2 => 'Postpaid'];
|
||||
$data = [
|
||||
'page_title' => 'Meeting Report',
|
||||
'main_discussion' => $main_discussion,
|
||||
'meeting_report_arr' => $meeting_report_arr,
|
||||
'payment_type' => $payment_type
|
||||
];
|
||||
|
||||
return view('report.details', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$clients = Models\Client::pluck('name','id');
|
||||
$service = Models\Service::pluck('name','name');
|
||||
$payment_type = Models\PaymentType::pluck('name', 'id');
|
||||
$payment_status = ['paid' => 'Paid', 'unpaid' => 'Unpaid'];
|
||||
|
||||
$data = [
|
||||
'page_title' => 'Create Meeting Report',
|
||||
'service' => $service,
|
||||
'clients' => $clients,
|
||||
'payment_type' => $payment_type,
|
||||
'payment_status' => $payment_status
|
||||
];
|
||||
|
||||
return view('report.create', $data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'client' => 'required',
|
||||
'service' => 'required',
|
||||
'contact_person' => 'required',
|
||||
'email' => 'required',
|
||||
'discussion' => 'required',
|
||||
'payment_type' => 'required',
|
||||
'current_balance' => 'required|numeric',
|
||||
'payment_status' => 'required',
|
||||
'next_follow_up_date' => 'required',
|
||||
'last_follow_up_date' => 'required'
|
||||
]);
|
||||
// dd($request->all());
|
||||
|
||||
$the_report = $request->except('_token');
|
||||
$the_report['auth_user_id'] = session('current_user.id');
|
||||
|
||||
$savereport = Models\MeetingReport::create($the_report);
|
||||
|
||||
Session::flash('success_message', 'Report successfully added');
|
||||
return redirect(url('dashboard'));
|
||||
|
||||
}
|
||||
|
||||
public function store_sam_comment(Request $request){
|
||||
|
||||
$comment = Models\SamComment::create(
|
||||
[
|
||||
'report_id' => $request->report_id,
|
||||
'created_by_id' => $request->created_by_id,
|
||||
'message' => $request->message
|
||||
]
|
||||
);
|
||||
|
||||
return response()->json(['code' => 1, 'msg' => $comment]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
//return redirect()->back()->withErrors(array("This section is under development. Kindly use the dashboard to view details of the reports"))->withInput();
|
||||
$meetingreport = Models\MeetingReport::with('client_info', 'auth_user_info')->where('id', $id)->first();
|
||||
$data = [
|
||||
'page_title' => 'Report Details',
|
||||
'showreport' => $meetingreport
|
||||
];
|
||||
return view('report.show', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$report_arr = Models\MeetingReport::find($id);
|
||||
$clients = Models\Client::pluck('name','id');
|
||||
$service = Models\Service::pluck('name','type');
|
||||
$payment_type = Models\PaymentType::pluck('name', 'id');
|
||||
$payment_status = ['paid' => 'Paid', 'unpaid' => 'Unpaid'];
|
||||
|
||||
$data = [
|
||||
'page_title' => 'Edit Meeting Report',
|
||||
'report_arr' => $report_arr,
|
||||
'service' => $service,
|
||||
'clients' => $clients,
|
||||
'payment_type' => $payment_type,
|
||||
'payment_status' => $payment_status
|
||||
];
|
||||
|
||||
return view('report.edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$request->validate([
|
||||
'client' => 'required',
|
||||
'service' => 'required',
|
||||
'contact_person' => 'required',
|
||||
'email' => 'required',
|
||||
'discussion' => 'required',
|
||||
'payment_type' => 'required',
|
||||
'current_balance' => 'required',
|
||||
'payment_status' => 'required',
|
||||
]);
|
||||
$report_update = Models\MeetingReport::find($id);
|
||||
$report_update->client = $request->client;
|
||||
$report_update->service = $request->service;
|
||||
$report_update->contact_person = $request->contact_person;
|
||||
$report_update->email = $request->email;
|
||||
$report_update->discussion = $request->discussion;
|
||||
$report_update->payment_type = $request->payment_type;
|
||||
$report_update->current_balance = $request->current_balance;
|
||||
$report_update->payment_status = $request->payment_status;
|
||||
|
||||
$report_update->auth_user_id = session('current_user.id');
|
||||
|
||||
$result = $report_update->save();
|
||||
|
||||
Session::flash('success_message', 'Report successfully Updated');
|
||||
return redirect(url('reports'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$result = Models\MeetingReport::destroy($id);
|
||||
if (request()->ajax()) {
|
||||
$result_arr = ['code' => 1];
|
||||
return response()->json($result_arr);
|
||||
}
|
||||
Session::flash('success_message', 'Report successfully deleted!');
|
||||
return redirect(route('reports.index'));
|
||||
}
|
||||
|
||||
|
||||
public function get_filter_ids($filter, $keyword)
|
||||
{
|
||||
switch ($filter) {
|
||||
case 'client':
|
||||
$id = Models\Client::where('name', 'like', "%$keyword%")->get(['id']);
|
||||
if ($id->isEmpty()) {
|
||||
return '';
|
||||
}
|
||||
$step = json_decode($id);
|
||||
$the_id = $step[0]->id;
|
||||
return (count($step) > 0 ) ? $step[0]->id : "";
|
||||
break;
|
||||
case 'service':
|
||||
$id = Models\MeetingReport::where('service', 'like', "%$keyword%")->get(['id']);
|
||||
if ($id->isEmpty()) {
|
||||
return '';
|
||||
}
|
||||
$step = json_decode($id);
|
||||
$the_id = $step[0]->id;
|
||||
return (count($step) > 0 ) ? $step[0]->id : "";
|
||||
break;
|
||||
case 'contact_person':
|
||||
$id = Models\MeetingReport::where('contact_person', 'like', "%$keyword%")->get(['id']);
|
||||
if ($id->isEmpty()) {
|
||||
return '';
|
||||
}
|
||||
$step = json_decode($id);
|
||||
$the_id = $step[0]->id;
|
||||
return (count($step) > 0 ) ? $step[0]->id : "";
|
||||
break;
|
||||
case 'email':
|
||||
$id = Models\MeetingReport::where('email', 'like', "%$keyword%")->get(['id']);
|
||||
if ($id->isEmpty()) {
|
||||
return '';
|
||||
}
|
||||
$step = json_decode($id);
|
||||
$the_id = $step[0]->id;
|
||||
return (count($step) > 0 ) ? $step[0]->id : "";
|
||||
break;
|
||||
case 'discussion':
|
||||
$id = Models\MeetingReport::where('discussion', 'like', "%$keyword%")->get(['id']);
|
||||
if ($id->isEmpty()) {
|
||||
return '';
|
||||
}
|
||||
$step = json_decode($id);
|
||||
$the_id = $step[0]->id;
|
||||
return (count($step) > 0 ) ? $step[0]->id : "";
|
||||
break;
|
||||
case 'payment_type':
|
||||
$id = Models\PaymentType::where('name', 'like', "%$keyword%")->get(['id']);
|
||||
if ($id->isEmpty()) {
|
||||
return '';
|
||||
}
|
||||
$step = json_decode($id);
|
||||
$the_id = $step[0]->id;
|
||||
return (count($step) > 0 ) ? $step[0]->id : "";
|
||||
break;
|
||||
case 'current_balance':
|
||||
$id = Models\MeetingReport::where('current_balance', 'like', "%$keyword%")->get(['id']);
|
||||
if ($id->isEmpty()) {
|
||||
return '';
|
||||
}
|
||||
$step = json_decode($id);
|
||||
$the_id = $step[0]->id;
|
||||
return (count($step) > 0 ) ? $step[0]->id : "";
|
||||
break;
|
||||
case 'payment_status':
|
||||
$id = Models\MeetingReport::where('payment_status', 'like', "%$keyword%")->get(['id']);
|
||||
if ($id->isEmpty()) {
|
||||
return '';
|
||||
}
|
||||
$step = json_decode($id);
|
||||
$the_id = $step[0]->id;
|
||||
return (count($step) > 0 ) ? $step[0]->id : "";
|
||||
break;
|
||||
case 'sam_comment':
|
||||
$id = Models\MeetingReport::where('sam_comment', 'like', "%$keyword%")->get(['id']);
|
||||
if ($id->isEmpty()) {
|
||||
return '';
|
||||
}
|
||||
$step = json_decode($id);
|
||||
return (count($step) > 0 ) ? $step[0]->id : "";
|
||||
break;
|
||||
default:
|
||||
return '';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
215
app/Http/Controllers/NetworkOperatorsController.php
Executable file
215
app/Http/Controllers/NetworkOperatorsController.php
Executable file
@@ -0,0 +1,215 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models;
|
||||
use Session;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
|
||||
class NetworkOperatorsController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$network_operators = new Models\NetworkOps;
|
||||
$table_columns = \DB::select(\DB::raw("show full columns from network_operators"));
|
||||
$exclude_arr = [
|
||||
'updated_at', 'id', 'account_manager_id', 'created_at'
|
||||
];
|
||||
$columns = [];
|
||||
$queries = [];
|
||||
foreach ($table_columns as $key) {
|
||||
$columns[$key->Field] = $key->Field;
|
||||
}
|
||||
foreach ($columns as $col) {
|
||||
if (request('filter') == $col) {
|
||||
$filter = request('filter');
|
||||
$keyword = request('keyword');
|
||||
$table_arr = ['staff_id'];
|
||||
if (in_array($col, $table_arr)) {
|
||||
$key = $this->get_filter_ids($filter, $keyword);
|
||||
if (!empty($key)) {
|
||||
$keyword = $key;
|
||||
}
|
||||
}
|
||||
$network_operators = $network_operators->where($col, 'like', '%'.$keyword.'%');
|
||||
$queries[$col] = request('keyword');
|
||||
}
|
||||
}
|
||||
|
||||
$network_operators = $network_operators->with('account_manager_info', 'country_info')->orderBy('created_at', 'DESC')->paginate(40)->appends($queries);
|
||||
$data = [
|
||||
'page_title' => 'Network Operators',
|
||||
'columns' => Arr::except($columns, $exclude_arr),
|
||||
'network_operators' => $network_operators
|
||||
];
|
||||
|
||||
return view('network_ops.index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$countries = Models\Country::pluck('en_short_name','alpha_2_code');
|
||||
$account_manager = Models\SystemUser::pluck('name', 'id');
|
||||
$data = [
|
||||
'page_title' => 'Create Network Operator',
|
||||
'countries'=> $countries,
|
||||
'account_manager' => $account_manager
|
||||
];
|
||||
|
||||
return view('network_ops.create', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'name' => 'required',
|
||||
'country' => 'required',
|
||||
'account_manager_id' => 'required',
|
||||
]);
|
||||
|
||||
$operator_arr = [
|
||||
'name' => $request->name,
|
||||
'country' => $request->country,
|
||||
'account_manager_id' => $request->account_manager_id
|
||||
];
|
||||
$saved = Models\NetworkOps::create($operator_arr);
|
||||
Session::flash('success_message', 'Network Operator successfully added');
|
||||
return redirect(url('network_ops'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$operator_arr = Models\NetworkOps::find($id);
|
||||
$data = [
|
||||
'page_title' => 'Network Operator Show',
|
||||
'operator_arr' => $operator_arr
|
||||
];
|
||||
|
||||
return view('network_ops.show', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$network_arr = Models\NetworkOps::findOrFail($id);
|
||||
$countries = Models\Country::pluck('en_short_name','alpha_2_code');
|
||||
$account_manager = Models\SystemUser::pluck('name', 'id');
|
||||
|
||||
$data = [
|
||||
'page_title' => 'Edit Network Operator',
|
||||
'network_arr' => $network_arr,
|
||||
'countries'=> $countries,
|
||||
'account_manager' => $account_manager
|
||||
];
|
||||
|
||||
return view('network_ops.edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$request->validate([
|
||||
'name' => 'required',
|
||||
'country' => 'required',
|
||||
'account_manager_id' => 'required',
|
||||
]);
|
||||
|
||||
$operator_update = Models\NetworkOps::find($id);
|
||||
$operator_update->name = $request->name;
|
||||
$operator_update->country = $request->country;
|
||||
$operator_update->account_manager_id = $request->account_manager_id;
|
||||
$result = $operator_update->save();
|
||||
|
||||
Session::flash('success_message', 'Network Operator successfully Updated');
|
||||
return redirect(url('network_ops'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$result = Models\NetworkOps::destroy($id);
|
||||
if (request()->ajax()) {
|
||||
$result_arr = ['code' => 1];
|
||||
return response()->json($result_arr);
|
||||
}
|
||||
Session::flash('success_message', 'Network Operator successfully deleted!');
|
||||
return redirect(route('network_ops.index'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function get_filter_ids($filter, $keyword){
|
||||
switch ($filter) {
|
||||
case 'name':
|
||||
$id = Models\NetworkOps::where('name', 'like', "%$keyword%")->get(['id']);
|
||||
if ($id->isEmpty()) {
|
||||
return '';
|
||||
}
|
||||
$step = json_decode($id);
|
||||
$the_id = $step[0]->id;
|
||||
return (count($step) > 0 ) ? $step[0]->id : "";
|
||||
break;
|
||||
case 'country':
|
||||
$id = Models\Country::where('alpha_2_code', 'like', "%$keyword%")->orWhere('alpha_3_code', 'like', "%$keyword%")->orWhere('en_short_name', 'like', "%$keyword%")->get(['id']);
|
||||
if ($id->isEmpty()) {
|
||||
return '';
|
||||
}
|
||||
$step = json_decode($id);
|
||||
$the_id = $step[0]->id;
|
||||
return (count($step) > 0 ) ? $step[0]->id : "";
|
||||
break;
|
||||
case 'account_manager_id':
|
||||
$id = Models\SyatemUser::where('name', 'like', "%$keyword%")->get(['id']);
|
||||
if ($id->isEmpty()) {
|
||||
return '';
|
||||
}
|
||||
$step = json_decode($id);
|
||||
$the_id = $step[0]->id;
|
||||
return (count($step) > 0 ) ? $step[0]->id : "";
|
||||
break;
|
||||
default:
|
||||
return '';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
201
app/Http/Controllers/ServicesController.php
Executable file
201
app/Http/Controllers/ServicesController.php
Executable file
@@ -0,0 +1,201 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models;
|
||||
use Session;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
|
||||
class ServicesController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$service_arr = new Models\Service;
|
||||
$table_columns = \DB::select(\DB::raw("show full columns from services"));
|
||||
$exclude_arr = [
|
||||
'updated_at', 'id'
|
||||
];
|
||||
$columns = [];
|
||||
$queries = [];
|
||||
foreach ($table_columns as $key) {
|
||||
$columns[$key->Field] = $key->Field;
|
||||
}
|
||||
foreach ($columns as $col) {
|
||||
if (request('filter') == $col) {
|
||||
$filter = request('filter');
|
||||
$keyword = request('keyword');
|
||||
$table_arr = ['staff_id'];
|
||||
if (in_array($col, $table_arr)) {
|
||||
$key = $this->get_filter_ids($filter, $keyword);
|
||||
if (!empty($key)) {
|
||||
$keyword = $key;
|
||||
}
|
||||
}
|
||||
$service_arr = $service_arr->where($col, 'like', '%'.$keyword.'%');
|
||||
$queries[$col] = request('keyword');
|
||||
}
|
||||
}
|
||||
|
||||
$service_arr = $service_arr->orderBy('created_at', 'DESC')->paginate(40)->appends($queries);
|
||||
|
||||
$data = [
|
||||
'page_title' => 'Services',
|
||||
'columns' => Arr::except($columns, $exclude_arr),
|
||||
'service_arr' => $service_arr
|
||||
];
|
||||
|
||||
return view('service.index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$service_type = ['regular' => 'Regular', 'advanced' => 'Advanced'];
|
||||
$data = [
|
||||
'page_title' => 'Create Service',
|
||||
'service_type' => $service_type
|
||||
];
|
||||
|
||||
return view('service.create', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'name' => 'required',
|
||||
'type' => 'required',
|
||||
]);
|
||||
|
||||
$service_arr = [
|
||||
'name' => $request->name,
|
||||
'type' => $request->type
|
||||
];
|
||||
$saved = Models\Service::create($service_arr);
|
||||
Session::flash('success_message', 'Service successfully added');
|
||||
return redirect(url('services'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
|
||||
$showservice = Models\Service::find($id);
|
||||
$data = [
|
||||
'page_title' => 'Show Service',
|
||||
'showservice' => $showservice
|
||||
];
|
||||
|
||||
return view('service.show', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$service_arr = Models\Service::findOrFail($id);
|
||||
$service_type = ['regular' => 'Regular', 'advanced' => 'Advanced'];
|
||||
|
||||
$data = [
|
||||
'page_title' => 'Edit Service',
|
||||
'service_arr' => $service_arr,
|
||||
'service_type' => $service_type
|
||||
];
|
||||
|
||||
return view('service.edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$request->validate([
|
||||
'name' => 'required',
|
||||
'type' => 'required',
|
||||
]);
|
||||
|
||||
$service_update = Models\Service::find($id);
|
||||
$service_update->name = $request->name;
|
||||
$operator_update->type = $request->type;
|
||||
$result = $service_update->save();
|
||||
|
||||
Session::flash('success_message', 'Service successfully Updated');
|
||||
return redirect(url('services'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$result = Models\Service::destroy($id);
|
||||
if (request()->ajax()) {
|
||||
$result_arr = ['code' => 1];
|
||||
return response()->json($result_arr);
|
||||
}
|
||||
Session::flash('success_message', 'Service successfully deleted!');
|
||||
return redirect(route('services.index'));
|
||||
}
|
||||
|
||||
|
||||
public function get_filter_ids($filter, $keyword)
|
||||
{
|
||||
switch ($filter) {
|
||||
case 'name':
|
||||
$id = Models\Service::where('name', 'like', "%$keyword%")->get(['id']);
|
||||
if ($id->isEmpty()) {
|
||||
return '';
|
||||
}
|
||||
$step = json_decode($id);
|
||||
$the_id = $step[0]->id;
|
||||
return (count($step) > 0 ) ? $step[0]->id : "";
|
||||
break;
|
||||
case 'type':
|
||||
$id = Models\Service::where('type', 'like', "%$keyword%")->get(['id']);
|
||||
if ($id->isEmpty()) {
|
||||
return '';
|
||||
}
|
||||
$step = json_decode($id);
|
||||
$the_id = $step[0]->id;
|
||||
return (count($step) > 0 ) ? $step[0]->id : "";
|
||||
break;
|
||||
|
||||
default:
|
||||
return '';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
237
app/Http/Controllers/SystemUsersController.php
Executable file
237
app/Http/Controllers/SystemUsersController.php
Executable file
@@ -0,0 +1,237 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models;
|
||||
use Session;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
|
||||
class SystemUsersController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$allusers = new Models\SystemUser;
|
||||
$table_columns = \DB::select(\DB::raw("show full columns from auth_users"));
|
||||
$exclude_arr = [
|
||||
'updated_at', 'id', 'password'
|
||||
];
|
||||
$columns = [];
|
||||
$queries = [];
|
||||
foreach ($table_columns as $key) {
|
||||
$columns[$key->Field] = $key->Field;
|
||||
}
|
||||
foreach ($columns as $col) {
|
||||
if (request('filter') == $col) {
|
||||
$filter = request('filter');
|
||||
$keyword = request('keyword');
|
||||
$table_arr = ['staff_id'];
|
||||
if (in_array($col, $table_arr)) {
|
||||
$key = $this->get_filter_ids($filter, $keyword);
|
||||
if (!empty($key)) {
|
||||
$keyword = $key;
|
||||
}
|
||||
}
|
||||
$allusers = $allusers->where($col, 'like', '%'.$keyword.'%');
|
||||
$queries[$col] = request('keyword');
|
||||
}
|
||||
}
|
||||
|
||||
$allusers = $allusers->orderBy('created_at', 'DESC')->paginate(40)->appends($queries);
|
||||
|
||||
$data = [
|
||||
'page_title' => 'Users',
|
||||
'columns' => Arr::except($columns, $exclude_arr),
|
||||
'allusers' => $allusers
|
||||
];
|
||||
|
||||
return view('account.index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$designation = Models\Designation::pluck('name', 'id');
|
||||
$data = [
|
||||
'page_title' => 'Create Users',
|
||||
'designation' => $designation
|
||||
];
|
||||
|
||||
return view('account.create', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'name' => 'required',
|
||||
'designation' => 'required',
|
||||
'email' => 'required',
|
||||
// 'phone' => 'required',
|
||||
'password' => 'required',
|
||||
'confirm_password' => 'same:password',
|
||||
|
||||
]);
|
||||
|
||||
$make_account = [
|
||||
'name' => $request->name,
|
||||
'designation' => $request->designation,
|
||||
'email' => $request->email,
|
||||
// 'phone' => $request->phone,
|
||||
'password' => md5($request->password)
|
||||
];
|
||||
|
||||
$inserted = Models\Account::create($make_account);
|
||||
Session::flash('success_message', 'Account successfully added');
|
||||
return redirect(url('accountmanagers'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$account_arr = Models\Account::find($id);
|
||||
$data = [
|
||||
'page_title' => 'Show Service',
|
||||
'account_arr' => $account_arr
|
||||
];
|
||||
|
||||
return view('account.show', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$designation = Models\Designation::pluck('name', 'id');
|
||||
$account_arr = Models\SystemUser::find($id);
|
||||
$data = [
|
||||
'page_title' => 'Edit Users',
|
||||
'designation' => $designation,
|
||||
'account_arr' => $account_arr
|
||||
];
|
||||
|
||||
return view('account.edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$account_arr = Models\Account::find($id);
|
||||
$account_arr->name = $request->name;
|
||||
$account_arr->designation = $request->designation;
|
||||
$account_arr->email = $request->email;
|
||||
// $account_arr->phone = $request->phone;
|
||||
$account_arr->password = md5($request->password);
|
||||
$account_arr->save();
|
||||
Session::flash('success_message', 'Account successfully Updated');
|
||||
return redirect(url('accountmanagers'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$result = Models\Account::destroy($id);
|
||||
if (request()->ajax()) {
|
||||
$result_arr = ['code' => 1];
|
||||
return response()->json($result_arr);
|
||||
}
|
||||
Session::flash('success_message', 'Account successfully deleted!');
|
||||
return redirect(route('accounts.index'));
|
||||
}
|
||||
|
||||
// public function showRegisterPage()
|
||||
// {
|
||||
// $designation = Models\Designation::pluck('name', 'id');
|
||||
// $data = [
|
||||
// 'page_title' => 'Register User',
|
||||
// 'designation' => $designation
|
||||
// ];
|
||||
// // dd($data);
|
||||
|
||||
// return view('account.register', $data);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
public function get_filter_ids($filter, $keyword)
|
||||
{
|
||||
switch ($filter) {
|
||||
case 'name':
|
||||
$id = Models\SystemUser::where('name', 'like', "%$keyword%")->get(['id']);
|
||||
if ($id->isEmpty()) {
|
||||
return '';
|
||||
}
|
||||
$step = json_decode($id);
|
||||
$the_id = $step[0]->id;
|
||||
return (count($step) > 0 ) ? $step[0]->id : "";
|
||||
break;
|
||||
case 'designation':
|
||||
$id = Models\SystemUser::where('designation', 'like', "%$keyword%")->get(['id']);
|
||||
if ($id->isEmpty()) {
|
||||
return '';
|
||||
}
|
||||
$step = json_decode($id);
|
||||
$the_id = $step[0]->id;
|
||||
return (count($step) > 0 ) ? $step[0]->id : "";
|
||||
break;
|
||||
case 'email':
|
||||
$id = Models\SystemUser::where('email', 'like', "%$keyword%")->get(['id']);
|
||||
if ($id->isEmpty()) {
|
||||
return '';
|
||||
}
|
||||
$step = json_decode($id);
|
||||
$the_id = $step[0]->id;
|
||||
return (count($step) > 0 ) ? $step[0]->id : "";
|
||||
break;
|
||||
case 'phone':
|
||||
$id = Models\SystemUser::where('phone', 'like', "%$keyword%")->get(['id']);
|
||||
if ($id->isEmpty()) {
|
||||
return '';
|
||||
}
|
||||
$step = json_decode($id);
|
||||
$the_id = $step[0]->id;
|
||||
return (count($step) > 0 ) ? $step[0]->id : "";
|
||||
break;
|
||||
default:
|
||||
return '';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
108
app/Http/Controllers/UssdClientsPaymentsController.php
Executable file
108
app/Http/Controllers/UssdClientsPaymentsController.php
Executable file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models;
|
||||
use Session;
|
||||
use Illuminate\Http\Request;
|
||||
use DB;
|
||||
|
||||
class UssdClientsPaymentsController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$columns = [
|
||||
'payment_type' => 'Payment Type',
|
||||
'name' => 'Client Name',
|
||||
'client_email' => 'Client Email',
|
||||
'account_mgr' => 'Account Manager',
|
||||
];
|
||||
|
||||
$clients = Models\UssdClientPayment::with('client_info');
|
||||
$account_managers = Models\SystemUser::pluck('name', 'id');
|
||||
|
||||
if (!empty($request->filter) && !empty($request->keyword)) {
|
||||
$clients = $this->resolveClientQuery($clients, $request);
|
||||
}
|
||||
|
||||
$clients = $clients->orderBy('ussd_client_payments.created_at', 'DESC')->paginate(20);
|
||||
|
||||
$data = [
|
||||
'page_title' => 'Ussd Clients Payments',
|
||||
'client_arr' => $clients,
|
||||
'account_managers' => $account_managers,
|
||||
'columns' => $columns
|
||||
];
|
||||
return view('ussdclients.index', $data);
|
||||
}
|
||||
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$client = Models\UssdClientPayment::find($id);
|
||||
|
||||
$data = [
|
||||
'client' => $client,
|
||||
];
|
||||
return view('ussdclients.edit', $data);
|
||||
}
|
||||
|
||||
|
||||
public function show($id)
|
||||
{
|
||||
$client = Models\UssdClientPayment::find($id);
|
||||
$data = [
|
||||
'client' => $client,
|
||||
];
|
||||
return view('ussdclients.edit', $data);
|
||||
}
|
||||
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
|
||||
$request->validate([
|
||||
'amount_paid' => 'required|numeric',
|
||||
'payment_type' => 'required',
|
||||
'remarks' => 'sometimes',
|
||||
]);
|
||||
$ussd_client = Models\UssdClientPayment::find($id);
|
||||
|
||||
|
||||
$ussd_client->payment_type = $request->payment_type;
|
||||
$ussd_client->amount_paid = $request->amount_paid;
|
||||
$ussd_client->remarks = $request->remarks;
|
||||
$ussd_client->last_modified_by_id = session('current_user.id');
|
||||
|
||||
$result = $ussd_client->save();
|
||||
|
||||
Session::flash('success_message', 'Client successfully Updated');
|
||||
return redirect(url('ussdclients'));
|
||||
}
|
||||
|
||||
|
||||
public function resolveClientQuery($clients, $request)
|
||||
{
|
||||
switch ($request->filter) {
|
||||
case 'name':
|
||||
return $clients
|
||||
->join('clients', 'clients.id', '=', 'ussd_client_payments.client_id')
|
||||
->where('clients.name', 'like', "%$request->keyword%");
|
||||
break;
|
||||
case 'client_email':
|
||||
return $clients
|
||||
->join('clients', 'clients.id', '=', 'ussd_client_payments.client_id')
|
||||
->where('clients.email', 'like', "%$request->keyword%");
|
||||
break;
|
||||
case 'account_mgr':
|
||||
return $clients
|
||||
->join('clients', 'clients.id', '=', 'ussd_client_payments.client_id')
|
||||
->join('auth_users', 'auth_users.id', '=', 'clients.auth_user_id')
|
||||
->where('auth_users.name', 'like', "%$request->keyword%");
|
||||
break;
|
||||
default:
|
||||
# code...
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
15
app/Http/Controllers/UssdDashboardController.php
Executable file
15
app/Http/Controllers/UssdDashboardController.php
Executable file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UssdDashboardController extends Controller
|
||||
{
|
||||
public function index(){
|
||||
$data = [
|
||||
'page_title' => 'Dashboard'
|
||||
];
|
||||
return view('ussddashboard.index', $data);
|
||||
}
|
||||
}
|
||||
62
app/Http/Kernel.php
Executable file
62
app/Http/Kernel.php
Executable file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http;
|
||||
|
||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||
|
||||
class Kernel extends HttpKernel
|
||||
{
|
||||
/**
|
||||
* The application's global HTTP middleware stack.
|
||||
*
|
||||
* These middleware are run during every request to your application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $middleware = [
|
||||
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||
\App\Http\Middleware\TrimStrings::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
||||
\App\Http\Middleware\TrustProxies::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware groups.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $middlewareGroups = [
|
||||
'web' => [
|
||||
\App\Http\Middleware\EncryptCookies::class,
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
// \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
],
|
||||
|
||||
'api' => [
|
||||
'throttle:60,1',
|
||||
'bindings',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware.
|
||||
*
|
||||
* These middleware may be assigned to groups or used individually.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $routeMiddleware = [
|
||||
'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'checklogin' => \App\Http\Middleware\CheckLogin::class,
|
||||
];
|
||||
}
|
||||
23
app/Http/Middleware/CheckLogin.php
Executable file
23
app/Http/Middleware/CheckLogin.php
Executable file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
|
||||
class CheckLogin
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if(!$request->session()->has('current_user')){
|
||||
return redirect(url('login'))->withErrors("You need to be logged in");
|
||||
}
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
17
app/Http/Middleware/EncryptCookies.php
Executable file
17
app/Http/Middleware/EncryptCookies.php
Executable file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
|
||||
|
||||
class EncryptCookies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the cookies that should not be encrypted.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
||||
26
app/Http/Middleware/RedirectIfAuthenticated.php
Executable file
26
app/Http/Middleware/RedirectIfAuthenticated.php
Executable file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class RedirectIfAuthenticated
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @param string|null $guard
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next, $guard = null)
|
||||
{
|
||||
if (Auth::guard($guard)->check()) {
|
||||
return redirect('/home');
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
18
app/Http/Middleware/TrimStrings.php
Executable file
18
app/Http/Middleware/TrimStrings.php
Executable file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
|
||||
|
||||
class TrimStrings extends Middleware
|
||||
{
|
||||
/**
|
||||
* The names of the attributes that should not be trimmed.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
}
|
||||
29
app/Http/Middleware/TrustProxies.php
Executable file
29
app/Http/Middleware/TrustProxies.php
Executable file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Fideloper\Proxy\TrustProxies as Middleware;
|
||||
|
||||
class TrustProxies extends Middleware
|
||||
{
|
||||
/**
|
||||
* The trusted proxies for this application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $proxies;
|
||||
|
||||
/**
|
||||
* The current proxy header mappings.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $headers = [
|
||||
Request::HEADER_FORWARDED => 'FORWARDED',
|
||||
Request::HEADER_X_FORWARDED_FOR => 'X_FORWARDED_FOR',
|
||||
Request::HEADER_X_FORWARDED_HOST => 'X_FORWARDED_HOST',
|
||||
Request::HEADER_X_FORWARDED_PORT => 'X_FORWARDED_PORT',
|
||||
Request::HEADER_X_FORWARDED_PROTO => 'X_FORWARDED_PROTO',
|
||||
];
|
||||
}
|
||||
17
app/Http/Middleware/VerifyCsrfToken.php
Executable file
17
app/Http/Middleware/VerifyCsrfToken.php
Executable file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
||||
|
||||
class VerifyCsrfToken extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be excluded from CSRF verification.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
||||
58
app/Jobs/SendNewUssdClientEmail.php
Executable file
58
app/Jobs/SendNewUssdClientEmail.php
Executable file
@@ -0,0 +1,58 @@
|
||||
<?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 SendNewUssdClientEmail implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
protected $ussd_client;
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Models\Client $client)
|
||||
{
|
||||
$this->ussd_client = $client;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(Mailer $mailer)
|
||||
{
|
||||
$client = $this->ussd_client;
|
||||
$emails = ['jim@click-mobile.com', 'priscilla@click-mobile.com','samuel@click-mobile.com'];
|
||||
$name = ucwords($client->name);
|
||||
$status = $client->status;
|
||||
$data = [
|
||||
'email' => strtolower($client->email),
|
||||
'name' => $name,
|
||||
'status' => $status
|
||||
];
|
||||
$mailer->send('emails.new_ussd_client', $data, function ($message) use ($data, $emails) {
|
||||
$message->from('support@click-mobile.com', 'Click Mobile Account Manager Tracker');
|
||||
$message->to($emails)->subject('New USSD Client Details');
|
||||
});
|
||||
|
||||
/*
|
||||
$emails = ['myoneemail@esomething.com', 'myother@esomething.com','myother2@esomething.com'];
|
||||
|
||||
Mail::send('emails.welcome', [], function($message) use ($emails)
|
||||
{
|
||||
$message->to($emails)->subject('This is test e-mail');
|
||||
});
|
||||
*/
|
||||
|
||||
}
|
||||
}
|
||||
49
app/Jobs/SendUssdClientActiveEmail.php
Executable file
49
app/Jobs/SendUssdClientActiveEmail.php
Executable file
@@ -0,0 +1,49 @@
|
||||
<?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 SendUssdClientActiveEmail implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
protected $ussd_client;
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Models\Client $client)
|
||||
{
|
||||
$this->ussd_client = $client;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(Mailer $mailer)
|
||||
{
|
||||
$client = $this->ussd_client;
|
||||
$emails = ['jim@click-mobile.com', 'priscilla@click-mobile.com','samuel@click-mobile.com'];
|
||||
$name = ucwords($client->name);
|
||||
$status = $client->status;
|
||||
$data = [
|
||||
'email' => strtolower($client->email),
|
||||
'name' => $name,
|
||||
'status' => $status
|
||||
];
|
||||
$mailer->send('emails.active_ussd_client', $data, function ($message) use ($data, $emails) {
|
||||
$message->from('support@click-mobile.com', 'Click Mobile Account Manager Tracker');
|
||||
$message->to($emails)->subject('New USSD Client Details');
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
13
app/Models/Account.php
Executable file
13
app/Models/Account.php
Executable file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Account extends Model
|
||||
{
|
||||
protected $guarded = array('id');
|
||||
public $table = "auth_users";
|
||||
|
||||
|
||||
}
|
||||
26
app/Models/ClickApps.php
Executable file
26
app/Models/ClickApps.php
Executable file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ClickApps extends Model
|
||||
{
|
||||
protected $guarded = array('id');
|
||||
public $table = "apps";
|
||||
protected $fillable = [
|
||||
'app_name',
|
||||
'app_type',
|
||||
'client',
|
||||
'code',
|
||||
'country',
|
||||
'operator',
|
||||
'tollfree',
|
||||
'app_path',
|
||||
'launch_date',
|
||||
'status',
|
||||
'other_info',
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
11
app/Models/ClickFile.php
Executable file
11
app/Models/ClickFile.php
Executable file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ClickFile extends Model
|
||||
{
|
||||
protected $guarded = array('id');
|
||||
public $table = "click_files";
|
||||
}
|
||||
33
app/Models/ClickServer.php
Executable file
33
app/Models/ClickServer.php
Executable file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ClickServer extends Model
|
||||
{
|
||||
protected $guarded = array('id');
|
||||
public $table = "click_servers";
|
||||
|
||||
protected $appends = ['root_password'];
|
||||
|
||||
public function direct_connections_info(){
|
||||
return $this->hasMany('App\Models\DirectConnection', 'server_id', 'id');
|
||||
}
|
||||
public function credentials_info(){
|
||||
return $this->hasMany('App\Models\ServerCredential', 'server_id', 'id');
|
||||
}
|
||||
public function modified_by_info(){
|
||||
return $this->hasOne('App\Models\Account', 'id', 'last_modified_by_id');
|
||||
}
|
||||
|
||||
|
||||
public function getRootPasswordAttribute(){
|
||||
$credentials = $this->credentials_info;
|
||||
foreach ($credentials as $value) {
|
||||
if ($value->username == 'root') {
|
||||
return $value->password;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
48
app/Models/Client.php
Executable file
48
app/Models/Client.php
Executable file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Models;
|
||||
class Client extends Model
|
||||
{
|
||||
protected $guarded = array('id');
|
||||
public $table = "clients";
|
||||
protected $appends = ['client_services'];
|
||||
|
||||
public function country_info(){
|
||||
return $this->hasOne('App\Models\Country', 'alpha_2_code', 'country');
|
||||
}
|
||||
public function payment_type_info(){
|
||||
return $this->hasOne('App\Models\PaymentType', 'id', 'pay_mode');
|
||||
}
|
||||
|
||||
public function service_info(){
|
||||
#return $this->hasMany('App\Comment', 'foreign_key', 'local_key');
|
||||
return $this->hasMany('App\Models\ClientCategory', 'client_id', 'id');
|
||||
}
|
||||
public function report_info(){
|
||||
return $this->hasMany('App\Models\MeetingReport', 'client', 'id');
|
||||
}
|
||||
public function auth_user_info(){
|
||||
return $this->hasOne('App\Models\Account', 'id', 'auth_user_id');
|
||||
}
|
||||
public function created_by_info(){
|
||||
return $this->hasOne('App\Models\Account', 'id', 'created_by');
|
||||
}
|
||||
public function modified_by_info(){
|
||||
return $this->hasOne('App\Models\Account', 'id', 'last_modified_by');
|
||||
}
|
||||
|
||||
|
||||
public function getClientServicesAttribute(){
|
||||
$services = $this->service_info;
|
||||
$service_name_arr = [];
|
||||
foreach ($services as $value) {
|
||||
$service_name = Models\Service::find($value['category_id']);
|
||||
$service_name_arr[] = $service_name->name;
|
||||
}
|
||||
return $service_name_arr;
|
||||
}
|
||||
|
||||
}
|
||||
16
app/Models/ClientCategory.php
Executable file
16
app/Models/ClientCategory.php
Executable file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ClientCategory extends Model
|
||||
{
|
||||
protected $guarded = array('id');
|
||||
public $table = "client_categories";
|
||||
|
||||
public function client_info(){
|
||||
return $this->hasOne('App\Models\Client', 'id', 'client_id');
|
||||
}
|
||||
|
||||
}
|
||||
18
app/Models/ClientNote.php
Normal file
18
app/Models/ClientNote.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ClientNote extends Model
|
||||
{
|
||||
protected $guarded = array('id');
|
||||
|
||||
public function client_info(){
|
||||
return $this->hasOne('App\Models\Client', 'id', 'client_id');
|
||||
}
|
||||
public function created_by_info(){
|
||||
return $this->hasOne('App\Models\Account', 'id', 'auth_user_id');
|
||||
}
|
||||
|
||||
}
|
||||
11
app/Models/Country.php
Executable file
11
app/Models/Country.php
Executable file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Country extends Model
|
||||
{
|
||||
protected $guarded = array('id');
|
||||
public $table = "countries";
|
||||
}
|
||||
13
app/Models/Currency.php
Executable file
13
app/Models/Currency.php
Executable file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Currency extends Model
|
||||
{
|
||||
protected $guarded = array('id');
|
||||
public $table = "currencies";
|
||||
|
||||
|
||||
}
|
||||
11
app/Models/Designation.php
Executable file
11
app/Models/Designation.php
Executable file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Designation extends Model
|
||||
{
|
||||
protected $guarded = array('id');
|
||||
public $table = "designations";
|
||||
}
|
||||
11
app/Models/DirectConnection.php
Executable file
11
app/Models/DirectConnection.php
Executable file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class DirectConnection extends Model
|
||||
{
|
||||
protected $guarded = array('id');
|
||||
public $table = "direct_connections";
|
||||
}
|
||||
24
app/Models/MarketReport.php
Executable file
24
app/Models/MarketReport.php
Executable file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class MarketReport extends Model
|
||||
{
|
||||
protected $guarded = array('id');
|
||||
public $table = "market_reports";
|
||||
|
||||
public function client_info(){
|
||||
return $this->hasOne('App\Models\Client', 'id', 'client');
|
||||
}
|
||||
public function payment_info(){
|
||||
return $this->hasOne('App\Models\PaymentType', 'id', 'payment_type');
|
||||
}
|
||||
public function auth_user_info(){
|
||||
return $this->hasOne('App\Models\Account', 'id', 'auth_user_id');
|
||||
}
|
||||
public function sam_comment_info(){
|
||||
return $this->hasMany('App\Models\SamComment', 'report_id', 'id');
|
||||
}
|
||||
}
|
||||
21
app/Models/MeetingReport.php
Executable file
21
app/Models/MeetingReport.php
Executable file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class MeetingReport extends Model
|
||||
{
|
||||
protected $guarded = array('id');
|
||||
public $table = "meeting_reports";
|
||||
|
||||
public function client_info(){
|
||||
return $this->hasOne('App\Models\Client', 'id', 'client');
|
||||
}
|
||||
public function auth_user_info(){
|
||||
return $this->hasOne('App\Models\Account', 'id', 'auth_user_id');
|
||||
}
|
||||
public function sam_comment_info(){
|
||||
return $this->hasMany('App\Models\SamComment', 'report_id', 'id');
|
||||
}
|
||||
}
|
||||
19
app/Models/NetworkOps.php
Executable file
19
app/Models/NetworkOps.php
Executable file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class NetworkOps extends Model
|
||||
{
|
||||
protected $guarded = array('id');
|
||||
public $table = "network_operators";
|
||||
|
||||
public function country_info(){
|
||||
return $this->hasOne('App\Models\Country', 'alpha_2_code', 'country');
|
||||
}
|
||||
|
||||
public function account_manager_info(){
|
||||
return $this->hasOne('App\Models\SystemUser', 'id', 'account_manager_id');
|
||||
}
|
||||
}
|
||||
11
app/Models/Networkstatus.php
Executable file
11
app/Models/Networkstatus.php
Executable file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Networkstatus extends Model
|
||||
{
|
||||
protected $guarded = array('id');
|
||||
public $table = "network_status_responses";
|
||||
}
|
||||
11
app/Models/PaymentType.php
Executable file
11
app/Models/PaymentType.php
Executable file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class PaymentType extends Model
|
||||
{
|
||||
protected $guarded = array('id');
|
||||
public $table = "payment_type";
|
||||
}
|
||||
13
app/Models/SamComment.php
Executable file
13
app/Models/SamComment.php
Executable file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SamComment extends Model
|
||||
{
|
||||
protected $guarded = array('id');
|
||||
public $table = "sam_comments";
|
||||
|
||||
|
||||
}
|
||||
16
app/Models/ServerCredential.php
Executable file
16
app/Models/ServerCredential.php
Executable file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ServerCredential extends Model
|
||||
{
|
||||
|
||||
protected $guarded = array('id');
|
||||
public $table = "server_credentials";
|
||||
|
||||
public function server_info(){
|
||||
return $this->hasOne('App\Models\ClickServer', 'id', 'server_id');
|
||||
}
|
||||
}
|
||||
11
app/Models/Service.php
Executable file
11
app/Models/Service.php
Executable file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Service extends Model
|
||||
{
|
||||
protected $guarded = array('id');
|
||||
public $table = "services";
|
||||
}
|
||||
14
app/Models/SystemUser.php
Executable file
14
app/Models/SystemUser.php
Executable file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SystemUser extends Model
|
||||
{
|
||||
protected $guarded = array('id');
|
||||
public $table = "auth_users";
|
||||
public function designation_info(){
|
||||
return $this->hasOne('App\Models\Designation', 'id', 'designation');
|
||||
}
|
||||
}
|
||||
15
app/Models/UssdClientPayment.php
Executable file
15
app/Models/UssdClientPayment.php
Executable file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class UssdClientPayment extends Model
|
||||
{
|
||||
protected $guarded = array('id');
|
||||
public $table = "ussd_client_payments";
|
||||
|
||||
public function client_info(){
|
||||
return $this->hasOne('App\Models\Client', 'id', 'client_id');
|
||||
}
|
||||
}
|
||||
34
app/Providers/AppServiceProvider.php
Executable file
34
app/Providers/AppServiceProvider.php
Executable file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$monolog = \Log::getMonolog();
|
||||
//new --- > xoxp-677819906294-675678554016-693747277911-5166bcbb9a5fc3d5434b42a10c4d358a
|
||||
//old ---> xoxp-677819906294-675678554016-720956680656-4a6b5d0fcb00e9e0512c14341d3a7563
|
||||
$slackHandler = new \Monolog\Handler\SlackHandler('xoxp-677819906294-675678554016-720956680656-4a6b5d0fcb00e9e0512c14341d3a7563', '#click_tracker', 'Monolog', true, null, \Monolog\Logger::ERROR);
|
||||
$slackHandler = new \Monolog\Handler\SlackHandler('xoxp-677819906294-675678554016-720956680656-4a6b5d0fcb00e9e0512c14341d3a7563', '#click_tracker', 'Monolog', true, null, \Monolog\Logger::INFO);
|
||||
$slackHandler = new \Monolog\Handler\SlackHandler('xoxp-677819906294-675678554016-720956680656-4a6b5d0fcb00e9e0512c14341d3a7563', '#click_tracker', 'Monolog', true, null, \Monolog\Logger::DEBUG);
|
||||
$monolog->pushHandler($slackHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
30
app/Providers/AuthServiceProvider.php
Executable file
30
app/Providers/AuthServiceProvider.php
Executable file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||
|
||||
class AuthServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The policy mappings for the application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $policies = [
|
||||
'App\Model' => 'App\Policies\ModelPolicy',
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any authentication / authorization services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->registerPolicies();
|
||||
|
||||
//
|
||||
}
|
||||
}
|
||||
21
app/Providers/BroadcastServiceProvider.php
Executable file
21
app/Providers/BroadcastServiceProvider.php
Executable file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Facades\Broadcast;
|
||||
|
||||
class BroadcastServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
Broadcast::routes();
|
||||
|
||||
require base_path('routes/channels.php');
|
||||
}
|
||||
}
|
||||
32
app/Providers/EventServiceProvider.php
Executable file
32
app/Providers/EventServiceProvider.php
Executable file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The event listener mappings for the application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $listen = [
|
||||
'App\Events\Event' => [
|
||||
'App\Listeners\EventListener',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any events for your application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
//
|
||||
}
|
||||
}
|
||||
73
app/Providers/RouteServiceProvider.php
Executable file
73
app/Providers/RouteServiceProvider.php
Executable file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* This namespace is applied to your controller routes.
|
||||
*
|
||||
* In addition, it is set as the URL generator's root namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $namespace = 'App\Http\Controllers';
|
||||
|
||||
/**
|
||||
* Define your route model bindings, pattern filters, etc.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
//
|
||||
|
||||
parent::boot();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the routes for the application.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function map()
|
||||
{
|
||||
$this->mapApiRoutes();
|
||||
|
||||
$this->mapWebRoutes();
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "web" routes for the application.
|
||||
*
|
||||
* These routes all receive session state, CSRF protection, etc.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function mapWebRoutes()
|
||||
{
|
||||
Route::middleware('web')
|
||||
->namespace($this->namespace)
|
||||
->group(base_path('routes/web.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "api" routes for the application.
|
||||
*
|
||||
* These routes are typically stateless.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function mapApiRoutes()
|
||||
{
|
||||
Route::prefix('api')
|
||||
->middleware('api')
|
||||
->namespace($this->namespace)
|
||||
->group(base_path('routes/api.php'));
|
||||
}
|
||||
}
|
||||
29
app/User.php
Executable file
29
app/User.php
Executable file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
use Notifiable;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name', 'email', 'password',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for arrays.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password', 'remember_token',
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user