progress indicators, bug fixes, after a while
This commit is contained in:
@@ -85,6 +85,13 @@ class ClickInfrastructureController extends Controller
|
||||
];
|
||||
return view('infrastructure.edit_direct_connection', $data);
|
||||
}
|
||||
public function create()
|
||||
{
|
||||
$data = [
|
||||
'page_title' => 'Add Server',
|
||||
];
|
||||
return view('infrastructure.create', $data);
|
||||
}
|
||||
public function update_direct(Request $request){
|
||||
|
||||
$request->validate([
|
||||
@@ -124,24 +131,43 @@ class ClickInfrastructureController extends Controller
|
||||
}
|
||||
public function server_list(){
|
||||
|
||||
$servers = Models\ClickServer::with('credentials_info')->get();
|
||||
//$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 getServerListJson(Request $request)
|
||||
{
|
||||
//$this->log_query();
|
||||
$server_arr = \DB::table('click_servers')
|
||||
->join('auth_users', 'auth_users.id', '=', 'click_servers.last_modified_by_id')
|
||||
->select('click_servers.id','click_servers.server_id', 'auth_users.name AS username', 'click_servers.friendly_name','click_servers.status', 'click_servers.public_ip_address', 'click_servers.private_ip_address', 'click_servers.main_use', 'click_servers.remarks', 'click_servers.updated_at')
|
||||
->orderBy('click_servers.friendly_name', 'ASC')
|
||||
->paginate(20);
|
||||
|
||||
if($request->has('keyword')){
|
||||
$keyword = $request->keyword;
|
||||
$server_arr = \DB::table('click_servers')
|
||||
->join('auth_users', 'auth_users.id', '=', 'click_servers.last_modified_by_id')
|
||||
->select('click_servers.id', 'click_servers.server_id', 'auth_users.name AS username', 'click_servers.friendly_name', 'click_servers.status', 'click_servers.public_ip_address', 'click_servers.private_ip_address', 'click_servers.main_use', 'click_servers.remarks', 'click_servers.updated_at')
|
||||
->whereRaw("click_servers.server_id LIKE '%$keyword%' OR click_servers.friendly_name LIKE '%$keyword%' OR click_servers.public_ip_address LIKE '%$keyword%' OR click_servers.private_ip_address LIKE '%$keyword%' OR auth_users.name LIKE '%$keyword%' OR click_servers.main_use LIKE '%$keyword%' OR click_servers.remarks LIKE '%$keyword%' OR click_servers.updated_at LIKE '%$keyword%' OR click_servers.updated_at LIKE '%$keyword%' OR click_servers.updated_at LIKE '%$keyword%' OR click_servers.status LIKE '%$keyword%' ")
|
||||
->orderBy('click_servers.friendly_name', 'ASC')
|
||||
->paginate(15);
|
||||
}
|
||||
return response()->json($server_arr);
|
||||
}
|
||||
public function edit_server($id)
|
||||
{
|
||||
$server = Models\ClickServer::find($id);
|
||||
$credentials = Models\ServerCredential::where('username', 'root')->where('server_id', $server->id) ->first();
|
||||
|
||||
//$credentials = Models\ServerCredential::where('username', 'root')->where('server_id', $server->id) ->first();
|
||||
// dd($server);
|
||||
$data = [
|
||||
'page_title' => 'Servers',
|
||||
'server' => $server,
|
||||
'credentials' => $credentials
|
||||
'status_arr' => ['Active' => 'Active', 'Inactive' => 'Inactive', 'Decommissioned' => 'Decommissioned']
|
||||
];
|
||||
return view('infrastructure.edit_server', $data);
|
||||
}
|
||||
@@ -153,11 +179,15 @@ class ClickInfrastructureController extends Controller
|
||||
'private_ip_address' => 'sometimes|nullable|ip',
|
||||
'main_use' => 'required',
|
||||
'remarks' => 'nullable',
|
||||
'password' => 'nullable',
|
||||
'status' => 'required',
|
||||
'server_number' => 'required',
|
||||
]);
|
||||
$server = Models\ClickServer::findOrFail($request->server_id);
|
||||
$server_arr = $request->except('_token', 'password', 'server_id');
|
||||
$server_arr['last_modified_by'] = session('current_user.id');
|
||||
$server_arr = $request->except('_token', 'server_id', 'server_number');
|
||||
$server_arr['last_modified_by_id'] = session('current_user.id');
|
||||
$server_arr['server_id'] = $request->server_number;
|
||||
//dd($server_arr);
|
||||
/*
|
||||
if ($request->password !== null) {
|
||||
// dd('foo bar');
|
||||
$credentials_arr = [
|
||||
@@ -174,10 +204,30 @@ class ClickInfrastructureController extends Controller
|
||||
$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 storeserver(Request $request){
|
||||
$request->validate([
|
||||
'friendly_name' => 'required',
|
||||
'server_number' => 'required',
|
||||
'public_ip_address' => 'sometimes|ip',
|
||||
'private_ip_address' => 'sometimes|nullable|ip',
|
||||
'main_use' => 'required',
|
||||
'remarks' => 'nullable',
|
||||
'server_number' => 'required',
|
||||
]);
|
||||
$server_arr = $request->except('_token', 'server_id', 'server_number');
|
||||
$server_arr['last_modified_by_id'] = session('current_user.id');
|
||||
$server_arr['server_id'] = $request->server_number;
|
||||
|
||||
|
||||
$result = Models\ClickServer::create($server_arr);
|
||||
Session::flash('success_message', 'Server Details successfully added');
|
||||
return redirect(url('infrastructure/server-list'));
|
||||
}
|
||||
public function reveal_password($id){
|
||||
$server = Models\ClickServer::find($id);
|
||||
if ($server) {
|
||||
@@ -194,7 +244,4 @@ class ClickInfrastructureController extends Controller
|
||||
}
|
||||
return response()->json($response_arr);
|
||||
}
|
||||
}
|
||||
//LJ School Location
|
||||
//5.637192,-0.158916
|
||||
//5.637093,-0.159269
|
||||
}
|
||||
39
app/Http/Controllers/ClientPaymentReportsController.php
Normal file
39
app/Http/Controllers/ClientPaymentReportsController.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ClientPaymentReportsController extends Controller
|
||||
{
|
||||
|
||||
public function index(){
|
||||
$data = [
|
||||
'page_title' => 'Client Payment Report',
|
||||
'current_user' => session('current_user')
|
||||
];
|
||||
return view('reports.index', $data);
|
||||
}
|
||||
public function getClientPaymentsJson(Request $request)
|
||||
{
|
||||
#$this->log_query();
|
||||
$payment_arr = \DB::table('client_finances')
|
||||
->join('auth_users AS staffcreate', 'staffcreate.id', '=', 'client_finances.user_id')
|
||||
->join('clients', 'clients.id', '=', 'client_finances.client_id')
|
||||
->select('client_finances.id', 'clients.name AS clientName', 'client_finances.invoice_number', 'client_finances.invoice_amount', 'client_finances.invoice_date', 'client_finances.services', 'client_finances.invoice_status', 'client_finances.remarks', 'staffcreate.name As createdBy', 'client_finances.created_at')
|
||||
->orderBy('client_finances.created_at', 'DESC')
|
||||
->paginate(15);
|
||||
|
||||
if($request->has('keyword')){
|
||||
$keyword = $request->keyword;
|
||||
$payment_arr = \DB::table('client_finances')
|
||||
->join('auth_users AS staffcreate', 'staffcreate.id', '=', 'client_finances.user_id')
|
||||
->join('clients', 'clients.id', '=', 'client_finances.client_id')
|
||||
->select('client_finances.id', 'clients.name AS clientName', 'client_finances.invoice_number', 'client_finances.invoice_amount', 'client_finances.invoice_date', 'client_finances.services', 'client_finances.invoice_status', 'client_finances.remarks', 'staffcreate.name As createdBy', 'client_finances.created_at')
|
||||
->whereRaw("client_finances.invoice_amount LIKE '%$keyword%' OR client_finances.invoice_status LIKE '%$keyword%' OR client_finances.invoice_number LIKE '%$keyword%' OR client_finances.invoice_amount LIKE '%$keyword%' OR staffcreate.name LIKE '%$keyword%' OR client_finances.created_at LIKE '%$keyword%'")
|
||||
->orderBy('client_finances.created_at', 'DESC')
|
||||
->paginate(15);
|
||||
}
|
||||
return response()->json($payment_arr);
|
||||
}
|
||||
}
|
||||
@@ -21,16 +21,14 @@ class ClientsController extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
|
||||
$client = Models\Client::find(3);
|
||||
$client_arr = new Models\Client;
|
||||
$client_arr = $client_arr->with('auth_user_info','country_info', 'created_by_info')->orderBy('name', 'ASC')->paginate(15);
|
||||
//dd($client_arr);
|
||||
$data = [
|
||||
'page_title' => 'Clients',
|
||||
'client_arr' => $client_arr,
|
||||
'current_user' => session('current_user')
|
||||
];
|
||||
// dd($data);
|
||||
return view('client.index-tabulator', $data);
|
||||
}
|
||||
public function indexBak(){
|
||||
@@ -57,18 +55,18 @@ class ClientsController extends Controller
|
||||
->join('auth_users AS aumngr', 'aumngr.id', '=', 'clients.auth_user_id')
|
||||
->join('auth_users AS aumodify', 'aumodify.id', '=', 'clients.last_modified_by')
|
||||
->join('flags AS flags', 'flags.country', '=', 'clients.country')
|
||||
->select('clients.id', 'clients.name', 'clients.status', 'clients.country', 'aumngr.name As accountMgr', 'aumodify.name AS modifiedBy', 'flags.url AS theflag')
|
||||
->select('clients.id', 'clients.name', 'clients.status','clients.progress_indicator_score', 'clients.country', 'aumngr.name As accountMgr', 'aumodify.name AS modifiedBy', 'flags.url AS theflag')
|
||||
->orderBy('name', 'ASC')
|
||||
->paginate(15);
|
||||
|
||||
if($request->has('keyword')){ // != ''
|
||||
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')
|
||||
->join('flags AS flags', 'flags.country', '=', 'clients.country')
|
||||
->select('clients.id','clients.name', 'clients.status', 'clients.country', 'aumngr.name As accountMgr', 'aumodify.name AS modifiedBy', 'flags.url AS theflag')
|
||||
->whereRaw("clients.name like '%$keyword%' or clients.status like '%$keyword%' OR clients.country like '%$keyword%' OR aumngr.name like '%$keyword%' OR aumodify.name like '%$keyword%'")
|
||||
->select('clients.id','clients.name', 'clients.status', 'clients.progress_indicators','clients.country', 'aumngr.name As accountMgr', 'aumodify.name AS modifiedBy', 'flags.url AS theflag')
|
||||
->whereRaw("clients.name like '%$keyword%' or clients.status like '%$keyword%' OR clients.country like '%$keyword%' OR aumngr.name like '%$keyword%' OR aumodify.name like '%$keyword%' OR clients.progress_indicators_score like '%$keyword%'")
|
||||
->orderBy('name', 'ASC')
|
||||
->paginate(15);
|
||||
}
|
||||
@@ -107,7 +105,7 @@ class ClientsController extends Controller
|
||||
{
|
||||
$countries = Models\Country::pluck('en_short_name','en_short_name');
|
||||
$service_type = Models\Service::pluck('name', 'name');
|
||||
$payment_type = Models\PaymentType::pluck('name', 'id');
|
||||
$payment_type = ['Prepaid' => 'Prepaid', 'Postpaid' => 'Postpaid']; //Models\PaymentType::pluck('name', 'id');
|
||||
$auth_users = Models\SystemUser::pluck('name', 'id');
|
||||
$status = ['Live' => 'Live', 'inactive' => 'Inactive', 'Prospective' => 'Prospective'];
|
||||
$currency = Models\Currency::pluck('name','name');
|
||||
@@ -150,6 +148,7 @@ class ClientsController extends Controller
|
||||
'industry' => 'required',
|
||||
'auth_user_id' => 'required', // account manager
|
||||
]);
|
||||
|
||||
$client_arr = [
|
||||
'name' => $request->name,
|
||||
'email' => $request->email,
|
||||
@@ -177,9 +176,18 @@ class ClientsController extends Controller
|
||||
$client_arr['linkedin_name'] = $request->linkedin_name;
|
||||
}
|
||||
if ($request->has('contact_person')) {
|
||||
$client_arr['contact_person'] = $request->contact_person;
|
||||
$client_arr['contact_person'] = $request->contact_person;
|
||||
}
|
||||
|
||||
if ($request->has('company_type')) {
|
||||
$client_arr['company_type'] = $request->company_type;
|
||||
}
|
||||
if ($request->has('industry')) {
|
||||
$client_arr['industry'] = $request->industry;
|
||||
}
|
||||
if ($request->has('payment_mode')) {
|
||||
$client_arr['pay_mode'] = $request->payment_mode;
|
||||
}
|
||||
|
||||
$result = Models\Client::create($client_arr);
|
||||
|
||||
if (in_array('3', $request->services)) {
|
||||
@@ -213,7 +221,6 @@ class ClientsController extends Controller
|
||||
'notes_body' => 'required'
|
||||
]);
|
||||
$auth_user = session('current_user');
|
||||
//'email' => 'unique:users,email_address'
|
||||
$notes_arr = [
|
||||
'notes_body' => $request->notes_body,
|
||||
'services' => implode(',', $request->services),
|
||||
@@ -238,19 +245,23 @@ class ClientsController extends Controller
|
||||
else{
|
||||
$data = ['code' => 3, 'msg' => 'Your request could not be handled at this time'];
|
||||
}
|
||||
$user_id = session('current_user.id');
|
||||
$username = session('current_user.name');
|
||||
$content = "User ID : " . $user_id . " (" . $username . ") Added a new Note";
|
||||
$this->logUsersActivity($type = 'staff', $content);
|
||||
return response()->json($data, 200);
|
||||
}
|
||||
public function getSingleNote($id)
|
||||
{
|
||||
public function getSingleNote($id){
|
||||
$note = Models\ClientNote::find($id);
|
||||
if ($note) {
|
||||
|
||||
$current_date = date_create(date('Y-m-d'));
|
||||
|
||||
// dump($current_date);
|
||||
$expiry_date = date_create($note->created_at);
|
||||
|
||||
// dump($expiry_date);
|
||||
$diff = date_diff($current_date, $expiry_date);
|
||||
$days = $diff->format("%a");
|
||||
// dd($days);
|
||||
if ($days > 7) {
|
||||
return response()->json([ 'code' => 5, 'msg' => 'This Note has been locked for editing']);
|
||||
}
|
||||
@@ -296,6 +307,10 @@ class ClientsController extends Controller
|
||||
else{
|
||||
$data = ['code' => 3, 'msg' => 'Your request could not be handled at this time'];
|
||||
}
|
||||
$user_id = session('current_user.id');
|
||||
$username = session('current_user.name');
|
||||
$content = "User ID : " . $user_id . " (" . $username . ") Updated a Note";
|
||||
$this->logUsersActivity($type = 'staff', $content);
|
||||
return response()->json($data, 200);
|
||||
}
|
||||
public function financeStore(Request $request)
|
||||
@@ -333,6 +348,10 @@ class ClientsController extends Controller
|
||||
else{
|
||||
$data = ['code' => 3, 'msg' => 'Your request could not be handled at this time'];
|
||||
}
|
||||
$user_id = session('current_user.id');
|
||||
$username = session('current_user.name');
|
||||
$content = "User ID : " . $user_id . " (" . $username . ") Added a payment record";
|
||||
$this->logUsersActivity($type = 'staff', $content);
|
||||
return response()->json($data, 200);
|
||||
}
|
||||
public function shortcodeStore(Request $request)
|
||||
@@ -406,6 +425,10 @@ class ClientsController extends Controller
|
||||
else{
|
||||
$data = ['code' => 3, 'msg' => 'Your request could not be handled at this time'];
|
||||
}
|
||||
$user_id = session('current_user.id');
|
||||
$username = session('current_user.name');
|
||||
$content = "User ID : " . $user_id . " (" . $username . ") Added new short code";
|
||||
$this->logUsersActivity($type = 'staff', $content);
|
||||
return response()->json($data, 200);
|
||||
}
|
||||
public function financeUpdate(Request $request)
|
||||
@@ -435,6 +458,10 @@ class ClientsController extends Controller
|
||||
else{
|
||||
$data = ['code' => 3, 'msg' => 'Your request could not be handled at this time'];
|
||||
}
|
||||
$user_id = session('current_user.id');
|
||||
$username = session('current_user.name');
|
||||
$content = "User ID : " . $user_id . " (" . $username . ") updated an existing payment record";
|
||||
$this->logUsersActivity($type = 'staff', $content);
|
||||
return response()->json($data, 200);
|
||||
}
|
||||
/**
|
||||
@@ -715,8 +742,8 @@ class ClientsController extends Controller
|
||||
$auth_users = Models\SystemUser::orderBy('name', 'ASC')->pluck('name', 'id');
|
||||
$industries = Models\Industry::orderBy('name', 'ASC')->pluck('name', 'name');
|
||||
$message_types_arr = ['International' => 'International', 'Local' => 'Local'];
|
||||
|
||||
|
||||
$progress_indicators = Models\ClientIndicator::pluck('name', 'name');
|
||||
$current_progress_indicators = json_decode($client->progress_indicators, true);
|
||||
|
||||
$how_we_got_clients_arr = ['Event : (GCCM) etc' => 'Event : (GCCM) etc', 'Referral' => 'Referral', 'Word of Mouth' => 'Word of Mouth', 'Marketing' => 'Marketing', 'Other' => 'Other'];
|
||||
|
||||
@@ -828,7 +855,9 @@ class ClientsController extends Controller
|
||||
'message_types_arr' => $message_types_arr,
|
||||
'industries' => $industries,
|
||||
'how_we_got_clients_arr' => $how_we_got_clients_arr,
|
||||
'current_services' => json_decode($client->services, true)
|
||||
'current_services' => json_decode($client->services, true),
|
||||
'progress_indicators' => $progress_indicators,
|
||||
'current_progress_indicators' => $current_progress_indicators
|
||||
];
|
||||
return view('client.edit', $data);
|
||||
}
|
||||
@@ -856,6 +885,8 @@ class ClientsController extends Controller
|
||||
// dump($request->has('other_document_name'));
|
||||
// dd($request->all());
|
||||
$client_update = Models\Client::find($id);
|
||||
$progress_indicators_arr = json_encode($request->progress_indicators);
|
||||
// dd($progress_indicators_arr);
|
||||
if ($request->has('document_one') && $request->has('document_one_name')) {
|
||||
if ($request->file('document_one')->isValid()) {
|
||||
$filename = "erp_" . time() . str_random(6) . "." . $request->document_one->extension();
|
||||
@@ -927,6 +958,13 @@ class ClientsController extends Controller
|
||||
$client_update->currency = $request->currency;
|
||||
$client_update->notes = $request->notes;
|
||||
$client_update->industry = $request->industry;
|
||||
$client_update->progress_indicators = $progress_indicators_arr;
|
||||
|
||||
$general_indicators = Models\ClientIndicator::count();
|
||||
$indicator_score = (count($request->progress_indicators)/$general_indicators) * 100;
|
||||
$indicator_score = number_format($indicator_score);
|
||||
// dd($indicator_score);
|
||||
$client_update->progress_indicator_score = $indicator_score;
|
||||
|
||||
$client_update->skype_name = $request->skype_name ?? "";
|
||||
$client_update->linkedin_name = $request->linkedin_name ?? "";
|
||||
@@ -1011,6 +1049,10 @@ class ClientsController extends Controller
|
||||
return response()->json($result_arr);
|
||||
}
|
||||
Session::flash('success_message', 'Client successfully deleted!');
|
||||
$user_id = session('current_user.id');
|
||||
$username = session('current_user.name');
|
||||
$content = "User ID : " . $user_id . " (" . $username . ") Deleted a client with ID $id";
|
||||
$this->logUsersActivity($type = 'staff', $content);
|
||||
return redirect(route('client.index'));
|
||||
}
|
||||
|
||||
|
||||
@@ -6,14 +6,57 @@ use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use App\Models;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
public function log_query() {
|
||||
public function log_queryBAK() {
|
||||
\DB::listen(function ($sql) {
|
||||
\Log::info('showing query', array('sql' => $sql));
|
||||
}
|
||||
);
|
||||
}
|
||||
public function log_query() {
|
||||
// , $binding, $timing 'bindings' => $binding)
|
||||
\DB::listen(function ($sql) {
|
||||
\Log::info('Showing query', array('sql' => $sql));
|
||||
$encoded_sql = json_encode($sql);
|
||||
$this->sendNtfy("Showing Query : " . $encoded_sql);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public function sendNtfy($data){
|
||||
$curl = curl_init();
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_HTTPHEADER => array(
|
||||
'Content-Type: application/json'
|
||||
),
|
||||
CURLOPT_URL => 'https://ntfy.sh/SansaTest',
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'POST',
|
||||
CURLOPT_POSTFIELDS => $data
|
||||
));
|
||||
$response = curl_exec($curl);
|
||||
return $response;
|
||||
|
||||
}
|
||||
public function logUsersActivity($type, $content){
|
||||
$user_id = session('current_user.id');
|
||||
$activity_arr = [
|
||||
'type' => $type,
|
||||
'content' => $content,
|
||||
'user_id' => $user_id,
|
||||
'ip_address' => \Request::ip(),
|
||||
'device' => request()->header('User-Agent')
|
||||
];
|
||||
$retval = Models\UserActivity::create($activity_arr);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,15 +14,18 @@ class DashboardController extends Controller
|
||||
$ussd_clients = Models\Client::where('services', 'LIKE', '%ussd%')->orwhere('services', 'LIKE', '%A2P%')->count();
|
||||
$sms_clients = Models\Client::where('services', 'LIKE', '%sms%')->count();
|
||||
$voice_clients = Models\Client::where('services', 'LIKE', '%ivr%')->count();
|
||||
$expiring_contracts = Models\Client::where('contract_auto_renew', '<>', 'YES')->where('contract_validity', '<>', null)->orwhere('contract_validity', '<>', '')->orderBy('contract_validity', 'ASC')->take(5)->get();
|
||||
//dd($expiring_contracts->isEmpty() == false);
|
||||
$data = [
|
||||
'page_title' => 'Dashboard',
|
||||
'sms' => $sms_clients,
|
||||
'ussd' => $ussd_clients,
|
||||
'voice' => $voice_clients,
|
||||
'total' => $total_clients
|
||||
'total' => $total_clients,
|
||||
'expiring_contracts' => $expiring_contracts
|
||||
];
|
||||
|
||||
// dd($data);
|
||||
//dd($data);
|
||||
return view('dashboard.index_two', $data);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,16 +10,45 @@ use App\Http\Requests;
|
||||
class GeneralDocumentsController extends Controller
|
||||
{
|
||||
public function index(){
|
||||
//$document_arr = new Models\GeneralDocument;
|
||||
$document_arr = \DB::table('general_documents')
|
||||
->select(\DB::raw('count(*) as docs_count, category'))
|
||||
->groupBy('category')
|
||||
->get();
|
||||
|
||||
$client_docs = \DB::table('client_files')
|
||||
->join('clients', 'clients.id', '=', 'client_files.client_id')
|
||||
->select(\DB::raw('count(*) as docs_count, clients.name, client_files.client_id'))
|
||||
->groupBy('clients.name', 'client_files.client_id')
|
||||
->get();
|
||||
|
||||
$mno_docs = \DB::table('mno_files')
|
||||
->join('network_operators', 'network_operators.id', '=', 'mno_files.mno_id')
|
||||
->select(\DB::raw('count(*) as docs_count, network_operators.name, mno_files.mno_id'))
|
||||
->groupBy('network_operators.name', 'mno_files.mno_id')
|
||||
->get();
|
||||
|
||||
$category_names = [
|
||||
'api' => 'API Documents',
|
||||
'presentations' => 'Presentations',
|
||||
'rates' => 'SMS/Voice Rates',
|
||||
'scfees' => 'Short Code Fees',
|
||||
'vpn_forms' => 'VPN Forms',
|
||||
'sidwl' => 'SID Whitelisting Letter',
|
||||
'others' => 'Others'
|
||||
];
|
||||
$data = [
|
||||
'page_title' => 'General Documents',
|
||||
'current_user' => session('current_user')
|
||||
'page_title' => 'All Documents',
|
||||
'document_arr' => $document_arr,
|
||||
'category_names' => $category_names,
|
||||
'current_user' => session('current_user'),
|
||||
'client_docs' => $client_docs,
|
||||
'mno_docs' => $mno_docs
|
||||
];
|
||||
return view('generaldocuments.index', $data);
|
||||
}
|
||||
public function listcategory($category){
|
||||
//$document_arr = new Models\GeneralDocument;
|
||||
//dd($category);
|
||||
// dd($category);
|
||||
$data = [
|
||||
'page_title' => ucfirst($category) . ' Documents',
|
||||
'current_user' => session('current_user'),
|
||||
@@ -50,7 +79,7 @@ class GeneralDocumentsController extends Controller
|
||||
}
|
||||
public function getDocumentsCategoryJson(Request $request)
|
||||
{
|
||||
$this->log_query();
|
||||
//$this->log_query();
|
||||
$category = $request->category;
|
||||
$document_arr = \DB::table('general_documents')
|
||||
->join('auth_users', 'auth_users.id', '=', 'general_documents.uploaded_by')
|
||||
@@ -72,11 +101,20 @@ class GeneralDocumentsController extends Controller
|
||||
return response()->json($document_arr);
|
||||
}
|
||||
public function create()
|
||||
{
|
||||
//$auth_users = Models\SystemUser::pluck('name', 'id');
|
||||
{
|
||||
$categories = [
|
||||
'sidwl' => 'Sender ID Whitelisting Letter',
|
||||
'api' => 'API Docs',
|
||||
'rates' => 'Rates',
|
||||
'scfees' => 'Short Code Fees',
|
||||
'presentations' => 'presentations',
|
||||
'vpn_forms' => 'VPN Forms',
|
||||
'others' => 'Others'
|
||||
];
|
||||
|
||||
$data = [
|
||||
'page_title' => 'Upload Document',
|
||||
//'auth_users' => $auth_users
|
||||
'page_title' => 'Upload Document',
|
||||
'categories' => $categories
|
||||
];
|
||||
return view('generaldocuments.create', $data);
|
||||
}
|
||||
@@ -88,13 +126,14 @@ class GeneralDocumentsController extends Controller
|
||||
*/
|
||||
public function store(Requests\GeneralDocumentsRequest $request)
|
||||
{
|
||||
|
||||
if ($request->has('document_one') && $request->has('document_one_name')) {
|
||||
|
||||
if ($request->has('document_one') && $request->has('document_one_name') && $request->has('document_one_category')) {
|
||||
if ($request->file('document_one')->isValid()) {
|
||||
$filename = "erp_" . time() . str_random(6) . "." . $request->document_one->extension();
|
||||
$request->document_one->storeAs('general_files', $filename, 'public');
|
||||
$document_arr['filename'] = $filename;
|
||||
|
||||
$document_arr['category'] = $request->document_one_category;
|
||||
|
||||
$document_arr['file_extension'] = $request->document_one->extension();
|
||||
$document_arr['file_reff'] = time() . uniqid();
|
||||
$document_arr['name'] = $request->document_one_name;
|
||||
@@ -102,11 +141,12 @@ class GeneralDocumentsController extends Controller
|
||||
$result = Models\GeneralDocument::create($document_arr);
|
||||
}
|
||||
}
|
||||
if ($request->has('document_two') && $request->has('document_two_name')) {
|
||||
if ($request->has('document_two') && $request->has('document_two_name') && $request->has('document_two_category')) {
|
||||
if ($request->file('document_two')->isValid()) {
|
||||
$filename = "erp_" . time() . str_random(6) . "." . $request->document_two->extension();
|
||||
$request->document_two->storeAs('general_files', $filename, 'public');
|
||||
$document_arr['filename'] = $filename;
|
||||
$document_arr['category'] = $request->document_two_category;
|
||||
|
||||
$document_arr['file_extension'] = $request->document_two->extension();
|
||||
$document_arr['file_reff'] = time() . uniqid();
|
||||
@@ -115,11 +155,12 @@ class GeneralDocumentsController extends Controller
|
||||
$result = Models\GeneralDocument::create($document_arr);
|
||||
}
|
||||
}
|
||||
if ($request->has('document_three') && $request->has('document_three_name')) {
|
||||
if ($request->has('document_three') && $request->has('document_three_name') && $request->has('document_three_category')) {
|
||||
if ($request->file('document_three')->isValid()) {
|
||||
$filename = "erp_" . time() . str_random(6) . "." . $request->document_three->extension();
|
||||
$request->document_three->storeAs('general_files', $filename, 'public');
|
||||
$document_arr['filename'] = $filename;
|
||||
$document_arr['category'] = $request->document_three_category;
|
||||
|
||||
$document_arr['file_extension'] = $request->document_three->extension();
|
||||
$document_arr['file_reff'] = time() . uniqid();
|
||||
|
||||
10
app/Http/Controllers/KwesiController.php
Normal file
10
app/Http/Controllers/KwesiController.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class KwesiController extends Controller
|
||||
{
|
||||
public function test
|
||||
}
|
||||
@@ -47,11 +47,15 @@ class LoginController extends Controller
|
||||
}
|
||||
|
||||
public function handle_logout(Request $request) {
|
||||
|
||||
$user_id = session('current_user.id');
|
||||
$username = session('current_user.name');
|
||||
$content = "User ID : " . $user_id . " (" . $username . ") Logged Out";
|
||||
|
||||
$request->session()->forget('current_user');
|
||||
$request->session()->flush();
|
||||
$request->session()->regenerate(true);
|
||||
|
||||
|
||||
$this->logUsersActivity($type = 'staff', $content);
|
||||
return redirect("/");
|
||||
}
|
||||
|
||||
|
||||
38
app/Http/Controllers/MnoPaymentsController.php
Normal file
38
app/Http/Controllers/MnoPaymentsController.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class MnoPaymentsController extends Controller
|
||||
{
|
||||
public function index(){
|
||||
$data = [
|
||||
'page_title' => 'MNO Payment Report',
|
||||
'current_user' => session('current_user')
|
||||
];
|
||||
return view('reports.mno-payments', $data);
|
||||
}
|
||||
public function getMnoPaymentsJson(Request $request)
|
||||
{
|
||||
#$this->log_query();
|
||||
$payment_arr = \DB::table('mno_payments')
|
||||
->join('auth_users AS staffcreate', 'staffcreate.id', '=', 'mno_payments.user_id')
|
||||
->join('network_operators', 'network_operators.id', '=', 'mno_payments.mno_id')
|
||||
->select('mno_payments.id', 'network_operators.name AS mnoName', 'mno_payments.invoice_number', 'mno_payments.invoice_amount', 'mno_payments.invoice_date', 'mno_payments.services', 'mno_payments.invoice_status', 'mno_payments.remarks', 'staffcreate.name As createdBy', 'mno_payments.created_at')
|
||||
->orderBy('mno_payments.created_at', 'DESC')
|
||||
->paginate(15);
|
||||
|
||||
if($request->has('keyword')){
|
||||
$keyword = $request->keyword;
|
||||
$payment_arr = \DB::table('mno_payments')
|
||||
->join('auth_users AS staffcreate', 'staffcreate.id', '=', 'mno_payments.user_id')
|
||||
->join('network_operators', 'network_operators.id', '=', 'mno_payments.mno_id')
|
||||
->select('mno_payments.id', 'network_operators.name AS mnoName', 'mno_payments.invoice_number', 'mno_payments.invoice_amount', 'mno_payments.invoice_date', 'mno_payments.services', 'mno_payments.invoice_status', 'mno_payments.remarks', 'staffcreate.name As createdBy', 'mno_payments.created_at')
|
||||
->whereRaw("mno_payments.invoice_amount LIKE '%$keyword%' OR mno_payments.invoice_status LIKE '%$keyword%' OR mno_payments.invoice_number LIKE '%$keyword%' OR mno_payments.invoice_amount LIKE '%$keyword%' OR staffcreate.name LIKE '%$keyword%' OR mno_payments.created_at LIKE '%$keyword%'")
|
||||
->orderBy('mno_payments.created_at', 'DESC')
|
||||
->paginate(15);
|
||||
}
|
||||
return response()->json($payment_arr);
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ use Session;
|
||||
use Illuminate\Support\Arr;
|
||||
// use App\Http\Requests;
|
||||
use App\Http\Requests;
|
||||
use App\Jobs\NewMnoNotesEmailAlerts;
|
||||
// use Illuminate\Http\Request as Requests;
|
||||
|
||||
|
||||
@@ -175,6 +176,7 @@ class NetworkOperatorsController extends Controller
|
||||
$ip_addresses = Models\Mnoips::where('mno_id', $id)->get();
|
||||
$show_notes = Models\Mnonote::where('mno_id', $id)->get();
|
||||
$showdocuments = Models\MnoFile::where('mno_id', $id)->get();
|
||||
$recent_payments = Models\Mnopayment::where('mno_id', $id)->orderBy('id', 'DESC')->get();
|
||||
|
||||
if ($network_arr->support_emails) {
|
||||
$support_emails = json_decode($network_arr->support_emails, true);
|
||||
@@ -253,7 +255,8 @@ class NetworkOperatorsController extends Controller
|
||||
'old_connection_type' => $old_connection_type,
|
||||
'ip_addresses' => $ip_addresses,
|
||||
'recent_payments' => [],
|
||||
'show_notes' => $show_notes
|
||||
'show_notes' => $show_notes,
|
||||
'recent_payments' => $recent_payments
|
||||
];
|
||||
// dd($data);
|
||||
|
||||
@@ -275,6 +278,8 @@ class NetworkOperatorsController extends Controller
|
||||
$connection_types = ['VPN' => 'VPN', 'DIRECT' => 'DIRECT'];
|
||||
$ip_addresses = Models\Mnoips::where('mno_id', $id)->get();
|
||||
$notes_arr = Models\Mnonote::where('mno_id', $id)->get();
|
||||
$recent_payments = Models\Mnopayment::where('mno_id', $id)->orderBy('id', 'DESC')->get();
|
||||
$service_type_names = Models\Service::pluck('name', 'name');
|
||||
//dd($notes_arr); //with('mno_info')->
|
||||
if ($network_arr->support_emails) {
|
||||
$support_emails = json_decode($network_arr->support_emails, true);
|
||||
@@ -351,7 +356,9 @@ class NetworkOperatorsController extends Controller
|
||||
'connection_types' => $connection_types,
|
||||
'old_connection_type' => $old_connection_type,
|
||||
'ip_addresses' => $ip_addresses,
|
||||
'notes_arr' => $notes_arr
|
||||
'notes_arr' => $notes_arr,
|
||||
'recent_payments' => $recent_payments,
|
||||
'service_type_names' => $service_type_names
|
||||
];
|
||||
return view('network_ops.edit', $data);
|
||||
}
|
||||
@@ -494,8 +501,9 @@ class NetworkOperatorsController extends Controller
|
||||
$result = Models\Mnonote::create($notes_arr);
|
||||
|
||||
$notes = Models\Mnonote::with('mno_info', 'created_by_info')->find($result->id);
|
||||
|
||||
//todo : send emails
|
||||
//dispatch(new SendNewNotesEmailAlert($notes));
|
||||
dispatch(new NewMnoNotesEmailAlerts($notes));
|
||||
|
||||
if ($result) {
|
||||
$data = ['code' => 1, 'msg' => 'Notes successfully added'];
|
||||
@@ -529,6 +537,83 @@ class NetworkOperatorsController extends Controller
|
||||
}
|
||||
|
||||
}
|
||||
public function getSinglePayment($id)
|
||||
{
|
||||
$payment = Models\MnoPayment::find($id);
|
||||
if ($payment) {
|
||||
$services_arr = explode(',', $payment->services);
|
||||
|
||||
return response()->json([ 'code' => 1, 'result' => $payment, 'services_arr' => $services_arr]);
|
||||
}
|
||||
else{
|
||||
return response()->json([ 'code' => 3, 'msg' => 'Request could not be handled at this time']);
|
||||
}
|
||||
|
||||
}
|
||||
public function financeStore(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'mno_id' => 'required',
|
||||
'services' => 'required',
|
||||
'invoice_number' => 'required',
|
||||
'invoice_amount' => 'required|numeric',
|
||||
'invoice_date' => 'required',
|
||||
'invoice_status' => 'required'
|
||||
]);
|
||||
$auth_user = session('current_user');
|
||||
|
||||
|
||||
$finance_arr = [
|
||||
'invoice_number' => $request->invoice_number,
|
||||
'invoice_amount' => $request->invoice_amount,
|
||||
'invoice_date' => $request->invoice_date,
|
||||
'invoice_status' => $request->invoice_status,
|
||||
'services' => implode(',', $request->services),
|
||||
'user_id' => $auth_user['id'],
|
||||
'mno_id' => $request->mno_id
|
||||
];
|
||||
if ($request->has('remarks')) {
|
||||
$finance_arr['remarks'] = $request->remarks;
|
||||
}
|
||||
|
||||
$result = Models\Mnopayment::create($finance_arr);
|
||||
if ($result) {
|
||||
$data = ['code' => 1, 'msg' => 'Payment Details successfully added'];
|
||||
}
|
||||
else{
|
||||
$data = ['code' => 3, 'msg' => 'Your request could not be handled at this time'];
|
||||
}
|
||||
return response()->json($data, 200);
|
||||
}
|
||||
public function financeUpdate(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'payment_id' => 'required',
|
||||
'mno_id' => 'required',
|
||||
'services' => 'required',
|
||||
'invoice_number' => 'required',
|
||||
'invoice_amount' => 'required|numeric',
|
||||
'invoice_date' => 'required',
|
||||
'invoice_status' => 'required'
|
||||
]);
|
||||
$auth_user = session('current_user');
|
||||
$payment = Models\Mnopayment::findOrFail($request->payment_id);
|
||||
|
||||
$payment->invoice_number = $request->invoice_number;
|
||||
$payment->invoice_amount = $request->invoice_amount;
|
||||
$payment->invoice_date = $request->invoice_date;
|
||||
$payment->invoice_status = $request->invoice_status;
|
||||
$payment->services = implode(',', $request->services);
|
||||
$result = $payment->save();
|
||||
|
||||
if ($result) {
|
||||
$data = ['code' => 1, 'msg' => 'Payment Details successfully updated'];
|
||||
}
|
||||
else{
|
||||
$data = ['code' => 3, 'msg' => 'Your request could not be handled at this time'];
|
||||
}
|
||||
return response()->json($data, 200);
|
||||
}
|
||||
public function notesUpdate(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
@@ -562,6 +647,29 @@ class NetworkOperatorsController extends Controller
|
||||
}
|
||||
return response()->json($data, 200);
|
||||
}
|
||||
public function getMnoFile($id)
|
||||
{
|
||||
$mno_file = Models\MnoFile::with('mno_info')->findOrFail($id);
|
||||
|
||||
|
||||
$file = public_path('documents/mno_files/') . $mno_file->file_path;
|
||||
$headers = []; //['Content-Type: application/pdf'];
|
||||
$filename = $mno_file->name . "_" . $mno_file->name;
|
||||
$filename = $this->cleanStr($filename);
|
||||
$filename = $filename . "." . $mno_file->file_extension;
|
||||
return \Response::download($file, $filename, $headers);
|
||||
}
|
||||
public function cleanStr($string){
|
||||
// Replaces all spaces with hyphens.
|
||||
$string = str_replace(' ', '-', $string);
|
||||
|
||||
// Removes special chars.
|
||||
$string = preg_replace('/[^A-Za-z0-9\-]/', '', $string);
|
||||
// Replaces multiple hyphens with single one.
|
||||
$string = preg_replace('/-+/', '_', $string);
|
||||
|
||||
return $string;
|
||||
}
|
||||
public function destroy($id)
|
||||
{
|
||||
$result = Models\NetworkOps::destroy($id);
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Http\Controllers;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use App\Models;
|
||||
use App\Http\Requests;
|
||||
use Session;
|
||||
|
||||
class OfficeLocationsController extends Controller
|
||||
@@ -20,35 +21,39 @@ class OfficeLocationsController extends Controller
|
||||
// dd($offices_arr->isEmpty());
|
||||
return view('officelocations.index', $data);
|
||||
}
|
||||
public function getSenderIdsJson(Request $request)
|
||||
public function showfiles($id){
|
||||
$branch_files = Models\BranchFile::where('branch_id', $id)->get();
|
||||
$data = [
|
||||
'page_title' => 'Branch Documents',
|
||||
'current_user' => session('current_user'),
|
||||
'branch_id' => $id
|
||||
];
|
||||
return view('officelocations.documents', $data);
|
||||
}
|
||||
public function getBranchFilesJson(Request $request)
|
||||
{
|
||||
#$this->log_query();
|
||||
$senderid_arr = \DB::table('sender_ids')
|
||||
->join('staff_members AS staffcreate', 'staffcreate.id', '=', 'sender_ids.created_by')
|
||||
->join('staff_members AS staffmodify', 'staffmodify.id', '=', 'sender_ids.last_modified_by')
|
||||
->join('network_operators', 'network_operators.id', '=', 'sender_ids.network_id')
|
||||
->join('clients', 'clients.id', '=', 'sender_ids.client_id')
|
||||
->select('sender_ids.id', 'clients.name AS clientName', 'network_operators.name AS networkName', 'network_operators.country', 'sender_ids.senderid', 'sender_ids.status', 'sender_ids.network_id', 'network_operators.country','sender_ids.remarks', 'staffcreate.name As createdBy', 'staffmodify.name AS modifiedBy')
|
||||
->orderBy('sender_ids.senderid', 'ASC')
|
||||
$id = $request->branch_id;
|
||||
$document_arr = \DB::table('branch_files')
|
||||
->join('auth_users', 'auth_users.id', '=', 'branch_files.uploaded_by')
|
||||
->select('branch_files.id', 'branch_files.name','branch_files.file_reff', 'auth_users.name AS UploadedBy', 'branch_files.created_at')
|
||||
->orderBy('branch_files.name', 'ASC')
|
||||
->where('branch_files.branch_id', $id)
|
||||
->paginate(15);
|
||||
|
||||
if($request->has('keyword')){
|
||||
$keyword = $request->keyword;
|
||||
$senderid_arr = \DB::table('sender_ids')
|
||||
->join('staff_members AS staffcreate', 'staffcreate.id', '=', 'sender_ids.created_by')
|
||||
->join('staff_members AS staffmodify', 'staffmodify.id', '=', 'sender_ids.last_modified_by')
|
||||
->join('network_operators', 'network_operators.id', '=', 'sender_ids.network_id')
|
||||
->join('clients', 'clients.id', '=', 'sender_ids.client_id')
|
||||
->select('sender_ids.id', 'clients.name AS clientName', 'network_operators.name AS networkName', 'network_operators.country', 'sender_ids.senderid', 'sender_ids.status', 'sender_ids.network_id', 'network_operators.country','sender_ids.remarks', 'staffcreate.name As createdBy', 'staffmodify.name AS modifiedBy')
|
||||
->whereRaw("sender_ids.senderid LIKE '%$keyword%' OR sender_ids.status LIKE '%$keyword%' OR network_operators.name LIKE '%$keyword%' OR network_operators.country LIKE '%$keyword%' OR staffcreate.name LIKE '%$keyword%' OR staffmodify.name LIKE '%$keyword%' OR clients.name LIKE '%$keyword%'")
|
||||
->orderBy('sender_ids.senderid', 'ASC')
|
||||
->paginate(15);
|
||||
}
|
||||
return response()->json($senderid_arr);
|
||||
$document_arr = \DB::table('branch_files')
|
||||
->join('auth_users', 'auth_users.id', '=', 'branch_files.uploaded_by')
|
||||
->select('branch_files.id', 'branch_files.name','branch_files.file_reff', 'auth_users.name AS UploadedBy', 'branch_files.created_at')
|
||||
->orderBy('branch_files.name', 'ASC')
|
||||
->where('branch_files.branch_id', $id)
|
||||
->whereRaw("branch_files.name LIKE '%$keyword%' OR branch_files.description LIKE '%$keyword%' OR branch_files.filename LIKE '%$keyword%' OR auth_users.name LIKE '%$keyword%'")
|
||||
->paginate(15);
|
||||
}
|
||||
return response()->json($document_arr);
|
||||
}
|
||||
public function create()
|
||||
{
|
||||
|
||||
$countries = Models\Country::pluck('en_short_name','en_short_name');
|
||||
$staffmembers = Models\StaffMember::pluck('name', 'id');
|
||||
$data = [
|
||||
@@ -56,9 +61,17 @@ class OfficeLocationsController extends Controller
|
||||
'countries' => $countries,
|
||||
'staffmembers' => $staffmembers
|
||||
];
|
||||
|
||||
return view('officelocations.create', $data);
|
||||
}
|
||||
public function createfiles($id)
|
||||
{
|
||||
//$auth_users = Models\SystemUser::pluck('name', 'id');
|
||||
$data = [
|
||||
'page_title' => 'Upload Document',
|
||||
'branch_id' => $id
|
||||
];
|
||||
return view('officelocations.filescreate', $data);
|
||||
}
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
@@ -68,11 +81,13 @@ class OfficeLocationsController extends Controller
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'street_name' => 'required',
|
||||
'house_number' => 'required',
|
||||
'street_name' => 'sometimes',
|
||||
'physical_address' => 'required',
|
||||
'postal_address' => 'required',
|
||||
'block_number' => 'sometimes',
|
||||
'city_town' => 'required',
|
||||
'country' => 'required|unique:office_locations,country',
|
||||
'country_manager_id' => 'required|unique:office_locations,country_manager_id',
|
||||
'country_manager_id' => 'required',
|
||||
'office_phone' => 'required'
|
||||
]);
|
||||
$flag = Models\CountryFlag::where('country', $request->country)->first();
|
||||
@@ -99,7 +114,8 @@ class OfficeLocationsController extends Controller
|
||||
$data = [
|
||||
'page_title' => 'Edit Office Location',
|
||||
'countries' => $countries,
|
||||
'staffmembers' => $staffmembers
|
||||
'staffmembers' => $staffmembers,
|
||||
'officelocation' => $office
|
||||
];
|
||||
return view('officelocations.edit', $data);
|
||||
}
|
||||
@@ -107,18 +123,21 @@ class OfficeLocationsController extends Controller
|
||||
{
|
||||
|
||||
$request->validate([
|
||||
'street_name' => 'required',
|
||||
'house_number' => 'required',
|
||||
'street_name' => 'sometimes',
|
||||
'physical_address' => 'required',
|
||||
'postal_address' => 'required',
|
||||
'block_number' => 'sometimes',
|
||||
'country' => 'sometimes',
|
||||
'city_town' => 'required',
|
||||
'country_manager_id' => 'required',
|
||||
'office_phone' => 'required'
|
||||
]);
|
||||
|
||||
$office = Models\OfficeLocation::findOrFail($id);
|
||||
|
||||
$office->street_name = $request->street_name;
|
||||
$office->house_number = $request->house_number;
|
||||
$office->street_name = $request->street_name ?? "";
|
||||
$office->physical_address = $request->physical_address;
|
||||
$office->postal_address = $request->postal_address;
|
||||
$office->block_number = $request->block_number;
|
||||
$office->country = $request->country;
|
||||
$office->country_manager_id = $request->country_manager_id;
|
||||
@@ -129,4 +148,115 @@ class OfficeLocationsController extends Controller
|
||||
Session::flash('success_message', 'Office Location details successfully Updated');
|
||||
return redirect(url('officelocations'));
|
||||
}
|
||||
public function fileStore(Requests\BranchFilesRequest $request)
|
||||
{
|
||||
|
||||
if ($request->has('document_one') && $request->has('document_one_name')) {
|
||||
if ($request->file('document_one')->isValid()) {
|
||||
$filename = "erp_" . time() . str_random(6) . "." . $request->document_one->extension();
|
||||
$request->document_one->storeAs('branch_files', $filename, 'public');
|
||||
$document_arr['filename'] = $filename;
|
||||
$document_arr['branch_id'] = $request->branch_id;
|
||||
$document_arr['file_path'] = $filename;
|
||||
|
||||
$document_arr['file_extension'] = $request->document_one->extension();
|
||||
$document_arr['file_reff'] = time() . uniqid();
|
||||
$document_arr['name'] = $request->document_one_name;
|
||||
$document_arr['uploaded_by'] = session('current_user.id');
|
||||
$result = Models\BranchFile::create($document_arr);
|
||||
}
|
||||
}
|
||||
if ($request->has('document_two') && $request->has('document_two_name')) {
|
||||
if ($request->file('document_two')->isValid()) {
|
||||
$filename = "erp_" . time() . str_random(6) . "." . $request->document_two->extension();
|
||||
$request->document_two->storeAs('branch_files', $filename, 'public');
|
||||
$document_arr['filename'] = $filename;
|
||||
$document_arr['branch_id'] = $request->branch_id;
|
||||
$document_arr['file_path'] = $filename;
|
||||
|
||||
$document_arr['file_extension'] = $request->document_two->extension();
|
||||
$document_arr['file_reff'] = time() . uniqid();
|
||||
$document_arr['name'] = $request->document_two_name;
|
||||
$document_arr['uploaded_by'] = session('current_user.id');
|
||||
$result = Models\BranchFile::create($document_arr);
|
||||
}
|
||||
}
|
||||
if ($request->has('document_three') && $request->has('document_three_name')) {
|
||||
if ($request->file('document_three')->isValid()) {
|
||||
$filename = "erp_" . time() . str_random(6) . "." . $request->document_three->extension();
|
||||
$request->document_three->storeAs('branch_files', $filename, 'public');
|
||||
$document_arr['filename'] = $filename;
|
||||
$document_arr['branch_id'] = $request->branch_id;
|
||||
$document_arr['file_path'] = $filename;
|
||||
|
||||
$document_arr['file_extension'] = $request->document_three->extension();
|
||||
$document_arr['file_reff'] = time() . uniqid();
|
||||
$document_arr['name'] = $request->document_three_name;
|
||||
$document_arr['uploaded_by'] = session('current_user.id');
|
||||
$result = Models\BranchFile::create($document_arr);
|
||||
}
|
||||
}
|
||||
Session::flash('success_message', 'Document(s) successfully uploaded');
|
||||
return redirect(url('officelocations'));
|
||||
}
|
||||
public function filesUpdate(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'document_one_name' => 'required',
|
||||
'id' => 'required',
|
||||
'document_one' => 'max:10240|mimes:png,jpg,jpeg,bmp,pdf,doc,docx,xlx,xlsx,pptx,ppt',
|
||||
]);
|
||||
$document = Models\BranchFile::findOrFail($request->id);
|
||||
$document->name = $request->document_one_name;
|
||||
if ($request->has('document_one')) {
|
||||
if ($request->file('document_one')->isValid()) {
|
||||
$filename = "erp_" . time() . str_random(6) . "." . $request->document_one->extension();
|
||||
$request->document_one->storeAs('branch_files', $filename, 'public');
|
||||
$document->file_path = $filename;
|
||||
|
||||
$document->file_extension = $request->document_one->extension();
|
||||
$document->file_reff = time() . uniqid();
|
||||
//$document->name = $request->document_one_name;
|
||||
$document->uploaded_by = session('current_user.id');
|
||||
}
|
||||
}
|
||||
$result = $document->save();
|
||||
Session::flash('success_message', 'Document(s) successfully updated');
|
||||
return redirect(url('officelocations'));
|
||||
}
|
||||
|
||||
public function show_edit_files_form($id){
|
||||
$document = Models\BranchFile::findOrFail($id);
|
||||
$data = [
|
||||
'page_title' => 'Update Document',
|
||||
'document' => $document
|
||||
];
|
||||
return view('officelocations.filesedit', $data);
|
||||
}
|
||||
|
||||
public function getDocument($id)
|
||||
{
|
||||
$branch_file = Models\BranchFile::with('branch_info')->findOrFail($id);
|
||||
|
||||
$file = public_path('documents/branch_files/') . $branch_file->file_path;
|
||||
|
||||
$headers = []; //['Content-Type: application/pdf'];
|
||||
$filename = $branch_file->branch_info->name . "_" . $branch_file->name;
|
||||
$filename = $this->cleanStr($filename);
|
||||
$filename = $filename . "." . $branch_file->file_extension;
|
||||
|
||||
// $filename = str_replace(' ', '_', $filename);
|
||||
return \Response::download($file, $filename, $headers);
|
||||
}
|
||||
public function cleanStr($string){
|
||||
// Replaces all spaces with hyphens.
|
||||
$string = str_replace(' ', '-', $string);
|
||||
|
||||
// Removes special chars.
|
||||
$string = preg_replace('/[^A-Za-z0-9\-]/', '', $string);
|
||||
// Replaces multiple hyphens with single one.
|
||||
$string = preg_replace('/-+/', '_', $string);
|
||||
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,4 +28,8 @@ class UtilityController extends Controller
|
||||
$message->to($emails)->subject('New Notes');
|
||||
});
|
||||
}
|
||||
public function maptest(){
|
||||
|
||||
return view('utility.map');
|
||||
}
|
||||
}
|
||||
|
||||
35
app/Http/Requests/BranchFilesRequest.php
Normal file
35
app/Http/Requests/BranchFilesRequest.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class BranchFilesRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'document_one' => 'max:10240|mimes:png,jpg,jpeg,bmp,pdf,doc,docx,xlx,xlsx,pptx,ppt',
|
||||
'document_two' => 'max:10240|mimes:png,jpg,jpeg,bmp,pdf,doc,docx,xlx,xlsx,pptx,ppt',
|
||||
'document_three' => 'max:10240|mimes:png,jpg,jpeg,bmp,pdf,doc,docx,xlx,xlsx,pptx,ppt',
|
||||
'document_one_name' => 'required_with:document_one.*',
|
||||
'document_two_name' => 'required_with:document_two.*',
|
||||
'document_three_name' => 'required_with:document_three.*'
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,12 @@ class GeneralDocumentsRequest extends FormRequest
|
||||
'document_one_name' => 'required_with:document_one.*',
|
||||
'document_two_name' => 'required_with:document_two.*',
|
||||
'document_three_name' => 'required_with:document_three.*'
|
||||
/*
|
||||
revisit this again and make it work: for now i will use a custom validation in the controller
|
||||
'document_one_name' => 'required_with_all:document_one.*,document_one_category.*',
|
||||
'document_two_name' => 'required_with_all:document_two.*,document_two_category.*',
|
||||
'document_three_name' => 'required_with:document_three,document_three_category'
|
||||
*/
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,13 +22,13 @@ class UpdateClientRequest extends FormRequest
|
||||
//'document_three_name.required_with' => 'Please select a file to upload.',
|
||||
|
||||
'document_one.mimes' => 'The uploaded file must be a PDF, An MS Word Document or An Image.',
|
||||
'document_one.max' => 'The uploaded file may not be larger than 10MB.',
|
||||
'document_one.max' => 'The uploaded file may not be larger than 20MB.',
|
||||
'document_two.mimes' => 'The uploaded file must be a PDF, An MS Word Document or An Image.',
|
||||
'document_two.max' => 'The uploaded file may not be larger than 10MB.',
|
||||
'document_two.max' => 'The uploaded file may not be larger than 20MB.',
|
||||
'document_three.mimes' => 'The uploaded file must be a PDF, An MS Word Document or An Image.',
|
||||
'document_three.max' => 'The uploaded file may not be larger than 10MB.',
|
||||
'document_three.max' => 'The uploaded file may not be larger than 20MB.',
|
||||
'other_document.mimes' => 'The uploaded file must be a PDF, An MS Word Document or An Image.',
|
||||
'other_document.max' => 'The uploaded file may not be larger than 10MB.',
|
||||
'other_document.max' => 'The uploaded file may not be larger than 20MB.',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -46,16 +46,18 @@ class UpdateClientRequest extends FormRequest
|
||||
'status' => 'required',
|
||||
'currency' => 'required',
|
||||
'auth_user_id' => 'required',
|
||||
'progress_indicators' => 'required',
|
||||
'contract_validity' => 'sometimes|date',
|
||||
/*
|
||||
'document_one_name' => 'required_with:document_one.*',
|
||||
'document_two_name' => 'required_with:document_two.*',
|
||||
'document_three_name' => 'required_with:document_three.*',
|
||||
*/
|
||||
'other_document_name' => 'required_with:other_document.*',
|
||||
'document_one' => 'max:10240|mimes:png,jpg,jpeg,bmp,pdf,doc,docx,xlx,xlsx',
|
||||
'document_two' => 'max:10240|mimes:png,jpg,jpeg,bmp,pdf,doc,docx,xlx,xlsx',
|
||||
'document_three' => 'max:10240|mimes:png,jpg,jpeg,bmp,pdf,doc,docx,xlx,xlsx',
|
||||
'other_document' => 'max:10240|mimes:png,jpg,jpeg,bmp,pdf,doc,docx,xlx,xlsx'
|
||||
'document_one' => 'max:20480|mimes:png,jpg,jpeg,bmp,pdf,doc,docx,xlx,xlsx',
|
||||
'document_two' => 'max:20480|mimes:png,jpg,jpeg,bmp,pdf,doc,docx,xlx,xlsx',
|
||||
'document_three' => 'max:20480|mimes:png,jpg,jpeg,bmp,pdf,doc,docx,xlx,xlsx',
|
||||
'other_document' => 'max:20480|mimes:png,jpg,jpeg,bmp,pdf,doc,docx,xlx,xlsx'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@ class UpdateMnoRequest extends FormRequest
|
||||
public function messages(){
|
||||
return [
|
||||
'document_one.mimes' => 'The uploaded file must be a PDF, An MS Word Document or An Image.',
|
||||
'document_one.max' => 'The uploaded file may not be larger than 10MB.',
|
||||
'document_one.max' => 'The uploaded file may not be larger than 20MB.',
|
||||
'document_two.mimes' => 'The uploaded file must be a PDF, An MS Word Document or An Image.',
|
||||
'document_two.max' => 'The uploaded file may not be larger than 10MB.',
|
||||
'document_two.max' => 'The uploaded file may not be larger than 20MB.',
|
||||
];
|
||||
}
|
||||
/**
|
||||
@@ -38,8 +38,8 @@ class UpdateMnoRequest extends FormRequest
|
||||
'contact_person' => 'required',
|
||||
'contact_person_email' => 'required',
|
||||
'contact_person_phone' => 'required',
|
||||
'document_one' => 'max:10240|mimes:png,jpg,jpeg,bmp,pdf,doc,docx,xlx,xlsx',
|
||||
'document_two' => 'max:10240|mimes:png,jpg,jpeg,bmp,pdf,doc,docx,xlx,xlsx',
|
||||
'document_one' => 'max:20480|mimes:png,jpg,jpeg,bmp,pdf,doc,docx,xlx,xlsx',
|
||||
'document_two' => 'max:20480|mimes:png,jpg,jpeg,bmp,pdf,doc,docx,xlx,xlsx',
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
15
app/Models/BranchFile.php
Normal file
15
app/Models/BranchFile.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class BranchFile extends Model
|
||||
{
|
||||
protected $guarded = array('id');
|
||||
public $table = "branch_files";
|
||||
|
||||
public function branch_info(){
|
||||
return $this->hasOne('App\Models\OfficeLocation', 'id', 'branch_id');
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,14 @@ class Client extends Model
|
||||
public $table = "clients";
|
||||
protected $appends = ['client_services'];
|
||||
|
||||
/*
|
||||
public function getprogressIndicatorsAttribute($value){
|
||||
$current_indicator_count = json_decode($value, true);
|
||||
$general_indicators = Models\ClientIndicator::count();
|
||||
$indicator_score = (count($current_indicator_count)/$general_indicators) * 100;
|
||||
return number_format($indicator_score);
|
||||
}
|
||||
*/
|
||||
public function country_info(){
|
||||
return $this->hasOne('App\Models\Country', 'alpha_2_code', 'country');
|
||||
}
|
||||
|
||||
10
app/Models/ClientIndicator.php
Normal file
10
app/Models/ClientIndicator.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ClientIndicator extends Model
|
||||
{
|
||||
protected $guarded = array('id');
|
||||
}
|
||||
19
app/Models/Mnopayment.php
Normal file
19
app/Models/Mnopayment.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Mnopayment extends Model
|
||||
{
|
||||
protected $guarded = array('id');
|
||||
public $table = "mno_payments";
|
||||
|
||||
public function client_info(){
|
||||
return $this->hasOne('App\Models\NetworkOps', 'id', 'mno_id');
|
||||
}
|
||||
|
||||
public function created_by_info(){
|
||||
return $this->hasOne('App\Models\SystemUser', 'id', 'user_id');
|
||||
}
|
||||
}
|
||||
@@ -17,9 +17,9 @@ class AppServiceProvider extends ServiceProvider
|
||||
//new --- > xoxp-677819906294-675678554016-693747277911-5166bcbb9a5fc3d5434b42a10c4d358a
|
||||
//old ---> xoxp-677819906294-675678554016-720956680656-4a6b5d0fcb00e9e0512c14341d3a7563
|
||||
/*
|
||||
$slackHandler = new \Monolog\Handler\SlackHandler('xoxp-677819906294-675678554016-693747277911-5166bcbb9a5fc3d5434b42a10c4d358a', '#click_tracker', 'Monolog', true, null, \Monolog\Logger::ERROR);
|
||||
$slackHandler = new \Monolog\Handler\SlackHandler('xoxp-677819906294-675678554016-693747277911-5166bcbb9a5fc3d5434b42a10c4d358a', '#click_tracker', 'Monolog', true, null, \Monolog\Logger::INFO);
|
||||
$slackHandler = new \Monolog\Handler\SlackHandler('xoxp-677819906294-675678554016-693747277911-5166bcbb9a5fc3d5434b42a10c4d358a', '#click_tracker', 'Monolog', true, null, \Monolog\Logger::DEBUG);
|
||||
$slackHandler = new \Monolog\Handler\SlackHandler('xoxp-677819906294-675678554016-693747277911-5166bcbb9a5fc3d5434b42a10c4d358a', '#click_erp_notify', 'Monolog', true, null, \Monolog\Logger::ERROR);
|
||||
$slackHandler = new \Monolog\Handler\SlackHandler('xoxp-677819906294-675678554016-693747277911-5166bcbb9a5fc3d5434b42a10c4d358a', '#click_erp_notify', 'Monolog', true, null, \Monolog\Logger::INFO);
|
||||
$slackHandler = new \Monolog\Handler\SlackHandler('xoxp-677819906294-675678554016-693747277911-5166bcbb9a5fc3d5434b42a10c4d358a', '#click_erp_notify', 'Monolog', true, null, \Monolog\Logger::DEBUG);
|
||||
|
||||
$monolog->pushHandler($slackHandler);
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user