staff members,senderid, documents,bug fixes, etc
This commit is contained in:
@@ -56,7 +56,8 @@ class ClientsController extends Controller
|
||||
$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')
|
||||
->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')
|
||||
->orderBy('name', 'ASC')
|
||||
->paginate(15);
|
||||
|
||||
@@ -65,7 +66,8 @@ class ClientsController extends Controller
|
||||
$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')
|
||||
->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%'")
|
||||
->orderBy('name', 'ASC')
|
||||
->paginate(15);
|
||||
@@ -106,7 +108,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');
|
||||
$auth_users = Models\Account::pluck('name', 'id');
|
||||
$auth_users = Models\SystemUser::pluck('name', 'id');
|
||||
$status = ['Live' => 'Live', 'inactive' => 'Inactive', 'Prospective' => 'Prospective'];
|
||||
$currency = Models\Currency::pluck('name','name');
|
||||
$company_types = ['Aggregator/Supplier' => 'Aggregator/Supplier', 'Enterprise' => 'Enterprise', 'Hybrid' => 'Hybrid'];
|
||||
@@ -192,7 +194,15 @@ class ClientsController extends Controller
|
||||
}
|
||||
#save services this has been moved to the main client table
|
||||
//$retval = $this->store_services($request->services, $result->id);
|
||||
|
||||
$client_name = $result->name;
|
||||
$activity_arr = [
|
||||
'type' => 'staff',
|
||||
'content' => session('current_user.name') . " added a new client ($client_name) successfully!",
|
||||
'user_id' => session('current_user.id'),
|
||||
'ip_address' => \Request::ip(),
|
||||
'device' => $request->header('User-Agent')
|
||||
];
|
||||
$retval = Models\UserActivity::create($activity_arr);
|
||||
Session::flash('success_message', 'Client successfully added');
|
||||
return redirect(url('clients'));
|
||||
}
|
||||
@@ -230,6 +240,64 @@ class ClientsController extends Controller
|
||||
}
|
||||
return response()->json($data, 200);
|
||||
}
|
||||
public function getSingleNote($id)
|
||||
{
|
||||
$note = Models\ClientNote::find($id);
|
||||
if ($note) {
|
||||
|
||||
$current_date = date_create(date('Y-m-d'));
|
||||
|
||||
$expiry_date = date_create($note->created_at);
|
||||
|
||||
$diff = date_diff($current_date, $expiry_date);
|
||||
$days = $diff->format("%a");
|
||||
if ($days > 7) {
|
||||
return response()->json([ 'code' => 5, 'msg' => 'This Note has been locked for editing']);
|
||||
}
|
||||
|
||||
$services_arr = explode(',', $note->services);
|
||||
|
||||
return response()->json([ 'code' => 1, 'result' => $note, 'services_arr' => $services_arr, 'days' => $days]);
|
||||
}
|
||||
else{
|
||||
return response()->json([ 'code' => 3, 'msg' => 'Request could not be handled at this time']);
|
||||
}
|
||||
|
||||
}
|
||||
public function notesUpdate(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'client_id' => 'required',
|
||||
'notes_body' => 'required'
|
||||
]);
|
||||
$auth_user = session('current_user');
|
||||
$notes_arr = [
|
||||
'notes_body' => $request->notes_body,
|
||||
'services' => implode(',', $request->services),
|
||||
'auth_user_id' => $auth_user['id'],
|
||||
'client_id' => $request->client_id
|
||||
];
|
||||
if ($request->has('highlight')) {
|
||||
$notes_arr['highlight'] = 'YES';
|
||||
}
|
||||
|
||||
|
||||
//dd($notes_arr);
|
||||
// change this to update
|
||||
$result = Models\ClientNote::create($notes_arr);
|
||||
|
||||
$notes = Models\ClientNote::with('client_info', 'created_by_info')->find($result->id);
|
||||
//todo : send emails
|
||||
//dispatch(new SendNewNotesEmailAlert($notes));
|
||||
|
||||
if ($result) {
|
||||
$data = ['code' => 1, 'msg' => 'Notes successfully added'];
|
||||
}
|
||||
else{
|
||||
$data = ['code' => 3, 'msg' => 'Your request could not be handled at this time'];
|
||||
}
|
||||
return response()->json($data, 200);
|
||||
}
|
||||
public function financeStore(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
@@ -280,15 +348,45 @@ class ClientsController extends Controller
|
||||
'launch_date' => 'required'
|
||||
]);
|
||||
$auth_user = session('current_user');
|
||||
$network = Models\NetworkOps::find($request->network);
|
||||
// dump($network);
|
||||
// dd($request->all());
|
||||
#$network = Models\NetworkOps::find($request->network);
|
||||
|
||||
$networks_raw = [
|
||||
'AirtelTigo GH' => 'AirtelTigo GH',
|
||||
'MTN GH' => 'MTN GH',
|
||||
'Airtel MW' => 'Airtel MW',
|
||||
'Airtel Zambia' => 'Airtel Zambia',
|
||||
'TNM MW' => 'TNM MW',
|
||||
'Airtel MW' => 'Airtel MW',
|
||||
'Safaricom Kenya' => 'Safaricom Kenya',
|
||||
'Airtel Kenya' => 'Airtel Kenya',
|
||||
'Telkom Kenya' => 'Telkom Kenya',
|
||||
'Orange Kenya' => 'Orange Kenya'
|
||||
];
|
||||
if (stripos($request->network, 'MW') !== false ) {
|
||||
$country = 'Malawi';
|
||||
}
|
||||
elseif (stripos($request->network, 'GH') !== false) {
|
||||
$country = 'Ghana';
|
||||
}
|
||||
elseif (stripos($request->network, 'Zambia') !== false) {
|
||||
$country = 'Zambia';
|
||||
}
|
||||
elseif (stripos($request->network, 'Bots') !== false) {
|
||||
$country = 'Botswana';
|
||||
}
|
||||
elseif (stripos($request->network, 'KE') !== false) {
|
||||
$country = 'Kenya';
|
||||
}
|
||||
else{
|
||||
$data = ['code' => 3, 'msg' => 'Your request could not be handled at this time'];
|
||||
return response()->json($data, 200);
|
||||
}
|
||||
|
||||
$shortcode_arr = [
|
||||
'name' => $request->name,
|
||||
'client_id' => $request->client_id,
|
||||
'network' => $network->name,
|
||||
'country' => $network->country,
|
||||
'network' => $request->network,
|
||||
'country' => $country, //$network->country,
|
||||
'shortcode' => $request->shortcode,
|
||||
'code_type' => $request->code_type,
|
||||
'toll_free' => $request->toll_free,
|
||||
@@ -331,23 +429,6 @@ class ClientsController extends Controller
|
||||
$payment->services = implode(',', $request->services);
|
||||
$result = $payment->save();
|
||||
|
||||
//'email' => 'unique:users,email_address'
|
||||
/*
|
||||
$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'],
|
||||
'client_id' => $request->client_id
|
||||
];
|
||||
if ($request->has('remarks')) {
|
||||
$finance_arr['remarks'] = $request->remarks;
|
||||
}
|
||||
*/
|
||||
|
||||
#$payments = Models\ClientPayment::with('client_info', 'created_by_info')->find($result->id);
|
||||
if ($result) {
|
||||
$data = ['code' => 1, 'msg' => 'Payment Details successfully updated'];
|
||||
}
|
||||
@@ -365,11 +446,24 @@ class ClientsController extends Controller
|
||||
public function show($id)
|
||||
{
|
||||
//with('short_code_info')->
|
||||
$showclient = Models\Client::with('service_info', 'country_info', 'auth_user_info', 'short_code_info')->find($id);
|
||||
$showclient = Models\Client::with('service_info', 'country_flag_info', 'auth_user_info', 'short_code_info')->find($id);
|
||||
// dd($showclient);
|
||||
$service_type = Models\Service::pluck('name', 'id');
|
||||
$service_type_names = Models\Service::pluck('name', 'name');
|
||||
$show_services = Models\ClientCategory::where('client_id', $id)->get();
|
||||
|
||||
//$networks_raw = ['AirtelTigo GH' => 'AirtelTigo GH','MTN GH' => 'MTN GH', 'Airtel MW' => 'Airtel MW', 'Airtel Zambia' => 'Airtel Zambia', 'TNM MW' => 'TNM MW', 'Airtel MW' => 'Airtel MW'];
|
||||
$networks_raw = [
|
||||
'AirtelTigo GH' => 'AirtelTigo GH',
|
||||
'MTN GH' => 'MTN GH',
|
||||
'Airtel MW' => 'Airtel MW',
|
||||
'Airtel Zambia' => 'Airtel Zambia',
|
||||
'TNM MW' => 'TNM MW',
|
||||
'Airtel MW' => 'Airtel MW',
|
||||
'Safaricom Kenya' => 'Safaricom Kenya',
|
||||
'Airtel Kenya' => 'Airtel Kenya',
|
||||
'Telkom Kenya' => 'Telkom Kenya',
|
||||
'Orange Kenya' => 'Orange Kenya'
|
||||
];
|
||||
//->where('highlight', 'NO')
|
||||
$show_notes = Models\ClientNote::with('created_by_info', 'client_info')->where('client_id', $id)->orderBy('id', 'DESC')->get()->take(20);
|
||||
$voice_codes = Models\ClientShortCode::where('client_id', $id)->where('code_type', 'voice')->get();
|
||||
@@ -429,6 +523,8 @@ class ClientsController extends Controller
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sort($networks_raw);
|
||||
$data = [
|
||||
'page_title' => 'Client Profile',
|
||||
'showclient' => $showclient,
|
||||
@@ -442,12 +538,12 @@ class ClientsController extends Controller
|
||||
'ussd_codes' => $ussd_codes,
|
||||
'countries' => $countries,
|
||||
'networks' => $networks,
|
||||
'networks_raw' => array_combine($networks_raw, $networks_raw),
|
||||
'renewal_due' => $renewal_due,
|
||||
'recent_payments' => $recent_payments,
|
||||
'highlight_colour' => $highlight_colour,
|
||||
'showdocuments' => $showdocuments
|
||||
];
|
||||
|
||||
return view('client.show', $data);
|
||||
}
|
||||
public function showReadonly($id)
|
||||
@@ -456,7 +552,7 @@ class ClientsController extends Controller
|
||||
$showclient = Models\Client::with('service_info', 'country_info', 'auth_user_info', 'short_code_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_services = json_decode($showclient->services, true); //Models\ClientCategory::where('client_id', $id)->get();
|
||||
|
||||
//->where('highlight', 'NO')
|
||||
$show_notes = Models\ClientNote::with('created_by_info', 'client_info')->where('client_id', $id)->orderBy('id', 'DESC')->get()->take(20);
|
||||
@@ -574,6 +670,7 @@ class ClientsController extends Controller
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function getShortCodes(){
|
||||
//$auth_users = Models\SystemUser::pluck('name', 'id');
|
||||
|
||||
@@ -593,6 +690,7 @@ class ClientsController extends Controller
|
||||
'sms_codes' => $sms_codes,
|
||||
'ussd_codes' => $ussd_codes,
|
||||
];
|
||||
// dd($data);
|
||||
return view('client.shortcodes', $data);
|
||||
}
|
||||
/**
|
||||
@@ -605,15 +703,16 @@ class ClientsController extends Controller
|
||||
{
|
||||
$client = Models\Client::find($id);
|
||||
|
||||
$service_type = Models\Service::pluck('name', 'name');
|
||||
$countries = Models\Country::pluck('en_short_name','en_short_name');
|
||||
$service_type = Models\Service::orderBy('name', 'ASC')->pluck('name', 'name');
|
||||
|
||||
$countries = Models\Country::orderBy('en_short_name', 'ASC')->pluck('en_short_name','en_short_name');
|
||||
|
||||
$payment_type = ['Prepaid' => 'Prepaid', 'Postpaid' => 'Postpaid']; // Models\PaymentType::pluck('name', 'id')->toArray();
|
||||
$status = ['Live' => 'Live', 'inactive' => 'Inactive', 'Prospective' => 'Prospective'];
|
||||
$currency = Models\Currency::pluck('name', 'name'); //
|
||||
$currency = Models\Currency::orderBy('name', 'ASC')->pluck('name', 'name');
|
||||
|
||||
$company_types = ['Aggregator/Supplier' => 'Aggregator/Supplier', 'Enterprise' => 'Enterprise'];
|
||||
$auth_users = Models\Account::pluck('name', 'id');
|
||||
$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'];
|
||||
|
||||
@@ -754,6 +853,8 @@ class ClientsController extends Controller
|
||||
'auth_user_id' => 'required'
|
||||
]);
|
||||
*/
|
||||
// dump($request->has('other_document_name'));
|
||||
// dd($request->all());
|
||||
$client_update = Models\Client::find($id);
|
||||
if ($request->has('document_one') && $request->has('document_one_name')) {
|
||||
if ($request->file('document_one')->isValid()) {
|
||||
@@ -800,6 +901,21 @@ class ClientsController extends Controller
|
||||
$result = Models\ClientFile::create($document_arr);
|
||||
}
|
||||
}
|
||||
if ($request->has('other_document') && $request->has('other_document_name')) {
|
||||
if ($request->file('other_document')->isValid()) {
|
||||
$filename = "erp_" . time() . str_random(6) . "." . $request->other_document->extension();
|
||||
$request->other_document->storeAs('client_files', $filename, 'public');
|
||||
$document_arr['file_path'] = $filename;
|
||||
$client_update->name = $request->name;
|
||||
|
||||
$document_arr['file_extension'] = $request->other_document->extension();
|
||||
$document_arr['file_reff'] = time() . uniqid();
|
||||
$document_arr['name'] = $request->document_three_name;
|
||||
$document_arr['created_by'] = session('current_user.id');
|
||||
$document_arr['client_id'] = $id;
|
||||
$result = Models\ClientFile::create($document_arr);
|
||||
}
|
||||
}
|
||||
|
||||
$client_update->name = $request->name;
|
||||
$client_update->email = $request->email;
|
||||
@@ -869,6 +985,14 @@ class ClientsController extends Controller
|
||||
}
|
||||
$retval = $this->update_services($request->services, $client_update->id);
|
||||
*/
|
||||
$activity_arr = [
|
||||
'type' => 'staff',
|
||||
'content' => session('current_user.name') . " updated ($client_update->name) details successfully!",
|
||||
'user_id' => session('current_user.id'),
|
||||
'ip_address' => \Request::ip(),
|
||||
'device' => $request->header('User-Agent')
|
||||
];
|
||||
$retval = Models\UserActivity::create($activity_arr);
|
||||
Session::flash('success_message', 'Client successfully Updated');
|
||||
return redirect(url('clients', $id));
|
||||
}
|
||||
@@ -953,14 +1077,14 @@ class ClientsController extends Controller
|
||||
return \Response::download($file, $filename, $headers);
|
||||
}
|
||||
public function cleanStr($string){
|
||||
// Replaces all spaces with hyphens.
|
||||
$string = str_replace(' ', '-', $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;
|
||||
}
|
||||
// Removes special chars.
|
||||
$string = preg_replace('/[^A-Za-z0-9\-]/', '', $string);
|
||||
// Replaces multiple hyphens with single one.
|
||||
$string = preg_replace('/-+/', '_', $string);
|
||||
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,14 +3,42 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models;
|
||||
use Session;
|
||||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
public function index(){
|
||||
$data = [
|
||||
'page_title' => 'Dashboard'
|
||||
];
|
||||
|
||||
$total_clients = Models\Client::count();
|
||||
$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();
|
||||
$data = [
|
||||
'page_title' => 'Dashboard',
|
||||
'sms' => $sms_clients,
|
||||
'ussd' => $ussd_clients,
|
||||
'voice' => $voice_clients,
|
||||
'total' => $total_clients
|
||||
];
|
||||
|
||||
// dd($data);
|
||||
return view('dashboard.index', $data);
|
||||
return view('dashboard.index_two', $data);
|
||||
}
|
||||
|
||||
public function getEvents(){
|
||||
$event_arr = [
|
||||
[
|
||||
"title" => 'Airtel MW Top Up',
|
||||
"start" => date("Y, m, d")
|
||||
],
|
||||
[
|
||||
"title" => 'Airtel MW Top Down',
|
||||
"start" => date("Y, m, d")
|
||||
],
|
||||
];
|
||||
|
||||
return response()->json($event_arr);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
199
app/Http/Controllers/GeneralDocumentsController.php
Normal file
199
app/Http/Controllers/GeneralDocumentsController.php
Normal file
@@ -0,0 +1,199 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models;
|
||||
use Session;
|
||||
use App\Http\Requests;
|
||||
|
||||
class GeneralDocumentsController extends Controller
|
||||
{
|
||||
public function index(){
|
||||
//$document_arr = new Models\GeneralDocument;
|
||||
$data = [
|
||||
'page_title' => 'General Documents',
|
||||
'current_user' => session('current_user')
|
||||
];
|
||||
return view('generaldocuments.index', $data);
|
||||
}
|
||||
public function listcategory($category){
|
||||
//$document_arr = new Models\GeneralDocument;
|
||||
//dd($category);
|
||||
$data = [
|
||||
'page_title' => ucfirst($category) . ' Documents',
|
||||
'current_user' => session('current_user'),
|
||||
'category' => $category
|
||||
];
|
||||
return view('generaldocuments.list-index', $data);
|
||||
}
|
||||
|
||||
public function getDocumentsJson(Request $request)
|
||||
{
|
||||
#$this->log_query();
|
||||
$document_arr = \DB::table('general_documents')
|
||||
->join('auth_users', 'auth_users.id', '=', 'general_documents.uploaded_by')
|
||||
->select('general_documents.id', 'general_documents.name', 'general_documents.filename', 'auth_users.name AS UploadedBy', 'general_documents.created_at')
|
||||
->orderBy('general_documents.name', 'ASC')
|
||||
->paginate(15);
|
||||
|
||||
if($request->has('keyword')){
|
||||
$keyword = $request->keyword;
|
||||
$document_arr = \DB::table('general_documents')
|
||||
->join('auth_users', 'auth_users.id', '=', 'general_documents.uploaded_by')
|
||||
->select('general_documents.id', 'general_documents.name', 'general_documents.filename', 'auth_users.name AS UploadedBy', 'general_documents.created_at')
|
||||
->orderBy('general_documents.name', 'ASC')
|
||||
->whereRaw("general_documents.name LIKE '%$keyword%' OR general_documents.description LIKE '%$keyword%' OR general_documents.filename LIKE '%$keyword%' OR auth_users.name LIKE '%$keyword%'")
|
||||
->paginate(15);
|
||||
}
|
||||
return response()->json($document_arr);
|
||||
}
|
||||
public function getDocumentsCategoryJson(Request $request)
|
||||
{
|
||||
$this->log_query();
|
||||
$category = $request->category;
|
||||
$document_arr = \DB::table('general_documents')
|
||||
->join('auth_users', 'auth_users.id', '=', 'general_documents.uploaded_by')
|
||||
->select('general_documents.id', 'general_documents.name', 'general_documents.filename', 'auth_users.name AS UploadedBy', 'general_documents.created_at')
|
||||
->where('general_documents.category', $category)
|
||||
->orderBy('general_documents.name', 'ASC')
|
||||
->paginate(15);
|
||||
|
||||
if($request->has('keyword')){
|
||||
$keyword = $request->keyword;
|
||||
$document_arr = \DB::table('general_documents')
|
||||
->join('auth_users', 'auth_users.id', '=', 'general_documents.uploaded_by')
|
||||
->select('general_documents.id', 'general_documents.name', 'general_documents.filename', 'auth_users.name AS UploadedBy', 'general_documents.created_at')
|
||||
->orderBy('general_documents.name', 'ASC')
|
||||
->where('general_documents.category', $category)
|
||||
->whereRaw("general_documents.name LIKE '%$keyword%' OR general_documents.description LIKE '%$keyword%' OR general_documents.filename LIKE '%$keyword%' OR auth_users.name LIKE '%$keyword%'")
|
||||
->paginate(15);
|
||||
}
|
||||
return response()->json($document_arr);
|
||||
}
|
||||
public function create()
|
||||
{
|
||||
//$auth_users = Models\SystemUser::pluck('name', 'id');
|
||||
$data = [
|
||||
'page_title' => 'Upload Document',
|
||||
//'auth_users' => $auth_users
|
||||
];
|
||||
return view('generaldocuments.create', $data);
|
||||
}
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Requests\GeneralDocumentsRequest $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('general_files', $filename, 'public');
|
||||
$document_arr['filename'] = $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\GeneralDocument::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('general_files', $filename, 'public');
|
||||
$document_arr['filename'] = $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\GeneralDocument::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('general_files', $filename, 'public');
|
||||
$document_arr['filename'] = $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\GeneralDocument::create($document_arr);
|
||||
}
|
||||
}
|
||||
Session::flash('success_message', 'Document(s) successfully uploaded');
|
||||
return redirect(url('generaldocuments'));
|
||||
}
|
||||
public function storeBak(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'file' => 'required|mimes:csv,txt,xlx,xls,pdf|max:2048'
|
||||
]);
|
||||
|
||||
$fileName = time().'.'.$request->file->extension();
|
||||
|
||||
$request->file->move(public_path('uploads'), $fileName);
|
||||
|
||||
return back()
|
||||
->with('success','You have successfully uploaded the file.');
|
||||
}
|
||||
public function edit($id){
|
||||
$document = Models\GeneralDocument::findOrFail($id);
|
||||
$data = [
|
||||
'page_title' => 'Update Document',
|
||||
'document' => $document
|
||||
];
|
||||
return view('generaldocuments.edit', $data);
|
||||
}
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$document = Models\GeneralDocument::findOrFail($id);
|
||||
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('general_files', $filename, 'public');
|
||||
$document->filename = $filename;
|
||||
$document->file_extension = $request->document_one->extension();
|
||||
$document->file_reff = time() . uniqid();
|
||||
}
|
||||
}
|
||||
$document->uploaded_by = session('current_user.id');
|
||||
$document->name = $request->name;
|
||||
$document->save();
|
||||
Session::flash('success_message', 'Document successfully Updated');
|
||||
return redirect(url('generaldocuments'));
|
||||
}
|
||||
public function getDocument($id)
|
||||
{
|
||||
$general_file = Models\GeneralDocument::find($id);
|
||||
if (!$general_file) {
|
||||
return redirect(url('generaldocuments'));
|
||||
}
|
||||
//PDF file is stored under project/public/download/info.pdf
|
||||
$file = public_path('documents/general_files/') . $general_file->filename;
|
||||
|
||||
$headers = []; //['Content-Type: application/pdf'];
|
||||
$filename = $general_file->name; // . "_" . $general_file->file_reff;
|
||||
$filename = $this->cleanStr($filename);
|
||||
$filename = $filename . "_Click_ERP_FILE" . "." . $general_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;
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,16 @@ class LoginController extends Controller
|
||||
|
||||
\Log::info($logged_in->name . ' successfully logged in at : ' . date('Y-m-d H:i:s'));
|
||||
// return redirect(url('dashboard'));
|
||||
return redirect(url('clients'));
|
||||
|
||||
$activity_arr = [
|
||||
'type' => 'staff',
|
||||
'content' => "User ID : " . $logged_in->id . " (" . $logged_in->name . ") Logged In",
|
||||
'user_id' => $logged_in->id,
|
||||
'ip_address' => \Request::ip(),
|
||||
'device' => $request->header('User-Agent')
|
||||
];
|
||||
$retval = Models\UserActivity::create($activity_arr);
|
||||
return redirect(url('/'));
|
||||
}
|
||||
|
||||
public function handle_logout(Request $request) {
|
||||
@@ -42,6 +51,7 @@ class LoginController extends Controller
|
||||
$request->session()->forget('current_user');
|
||||
$request->session()->flush();
|
||||
$request->session()->regenerate(true);
|
||||
|
||||
return redirect("/");
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,10 @@ use Illuminate\Http\Request;
|
||||
use App\Models;
|
||||
use Session;
|
||||
use Illuminate\Support\Arr;
|
||||
// use App\Http\Requests;
|
||||
use App\Http\Requests;
|
||||
// use Illuminate\Http\Request as Requests;
|
||||
|
||||
|
||||
|
||||
class NetworkOperatorsController extends Controller
|
||||
@@ -162,11 +166,96 @@ class NetworkOperatorsController extends Controller
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$operator_arr = Models\NetworkOps::find($id);
|
||||
//$operator_arr = Models\NetworkOps::findOrFail($id);
|
||||
$network_arr = Models\NetworkOps::with('account_manager_info')->findOrFail($id);
|
||||
$countries = Models\Country::orderBy('en_short_name')->pluck('en_short_name','en_short_name');
|
||||
$account_manager = Models\SystemUser::orderBy('name')->pluck('name', 'id');
|
||||
$services = Models\Service::orderBy('name')->pluck('name', 'name');
|
||||
$connection_types = ['VPN' => 'VPN', 'DIRECT' => 'DIRECT'];
|
||||
$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();
|
||||
|
||||
if ($network_arr->support_emails) {
|
||||
$support_emails = json_decode($network_arr->support_emails, true);
|
||||
$support_emails = array_combine($support_emails, $support_emails);
|
||||
$old_support_emails = json_decode($network_arr->support_emails, true);
|
||||
}
|
||||
else{
|
||||
$support_emails = [];
|
||||
$old_support_emails = [];
|
||||
}
|
||||
if ($network_arr->finance_emails) {
|
||||
$finance_emails = json_decode($network_arr->finance_emails, true);
|
||||
$finance_emails = array_combine($finance_emails, $finance_emails);
|
||||
$old_finance_emails = json_decode($network_arr->finance_emails, true);
|
||||
}
|
||||
else{
|
||||
$finance_emails = [];
|
||||
$old_finance_emails = [];
|
||||
}
|
||||
if ($network_arr->support_phones) {
|
||||
$support_phones = json_decode($network_arr->support_phones, true);
|
||||
$support_phones = array_combine($support_phones, $support_phones);
|
||||
$old_support_phones = json_decode($network_arr->support_phones, true);
|
||||
}
|
||||
else{
|
||||
$support_phones = [];
|
||||
$old_support_phones = [];
|
||||
}
|
||||
|
||||
if ($network_arr->support_skype) {
|
||||
$support_skype_arr = json_decode($network_arr->support_skype, true);
|
||||
$support_skype_arr = array_combine($support_skype_arr, $support_skype_arr);
|
||||
$old_support_skype_arr = json_decode($network_arr->support_skype, true);
|
||||
}
|
||||
else{
|
||||
$support_skype_arr = [];
|
||||
$old_support_skype_arr = [];
|
||||
}
|
||||
$old_connection_type = [];
|
||||
if ($network_arr->connection_type) {
|
||||
$connection_type = json_decode($network_arr->connection_type, true);
|
||||
$connection_type = array_combine($connection_type, $connection_type);
|
||||
$old_connection_type = json_decode($network_arr->connection_type, true);
|
||||
}
|
||||
else{
|
||||
$old_connection_type = [];
|
||||
}
|
||||
|
||||
if ($network_arr->connection_status == 'Active') {
|
||||
$status_bg = "info";
|
||||
}
|
||||
elseif ($network_arr->connection_status == 'Pending') {
|
||||
$status_bg = "warning";
|
||||
}
|
||||
else{
|
||||
$status_bg = "danger";
|
||||
}
|
||||
$data = [
|
||||
'page_title' => 'Network Operator Show',
|
||||
'operator_arr' => $operator_arr
|
||||
'page_title' => 'Network Operator Details',
|
||||
'showdocuments' => $showdocuments,
|
||||
'mnoshow' => $network_arr,
|
||||
'countries'=> $countries,
|
||||
'account_manager' => $account_manager,
|
||||
'current_services' => json_decode($network_arr->services, true),
|
||||
'services' => $services->toArray(),
|
||||
'support_emails' => $support_emails,
|
||||
'finance_emails' => $finance_emails,
|
||||
'support_skype_arr' => $support_skype_arr,
|
||||
'support_phones' => $support_phones,
|
||||
'old_support_emails' => $old_support_emails,
|
||||
'old_finance_emails' => $old_finance_emails,
|
||||
'old_support_skype_arr' => $old_support_skype_arr,
|
||||
'old_support_phones' => $old_support_phones,
|
||||
'status_bg' => $status_bg,
|
||||
'connection_types' => $connection_types,
|
||||
'old_connection_type' => $old_connection_type,
|
||||
'ip_addresses' => $ip_addresses,
|
||||
'recent_payments' => [],
|
||||
'show_notes' => $show_notes
|
||||
];
|
||||
// dd($data);
|
||||
|
||||
return view('network_ops.show', $data);
|
||||
}
|
||||
@@ -180,11 +269,13 @@ class NetworkOperatorsController extends Controller
|
||||
public function edit($id)
|
||||
{
|
||||
$network_arr = Models\NetworkOps::findOrFail($id);
|
||||
$countries = Models\Country::pluck('en_short_name','en_short_name');
|
||||
$account_manager = Models\SystemUser::pluck('name', 'id');
|
||||
$services = Models\Service::pluck('name', 'name');
|
||||
$countries = Models\Country::orderBy('en_short_name')->pluck('en_short_name','en_short_name');
|
||||
$account_manager = Models\SystemUser::orderBy('name')->pluck('name', 'id');
|
||||
$services = Models\Service::orderBy('name')->pluck('name', 'name');
|
||||
$connection_types = ['VPN' => 'VPN', 'DIRECT' => 'DIRECT'];
|
||||
$ip_addresses = Models\Mnoips::where('mno_id', $id)->get();
|
||||
$notes_arr = Models\Mnonote::where('mno_id', $id)->get();
|
||||
//dd($notes_arr); //with('mno_info')->
|
||||
if ($network_arr->support_emails) {
|
||||
$support_emails = json_decode($network_arr->support_emails, true);
|
||||
$support_emails = array_combine($support_emails, $support_emails);
|
||||
@@ -194,6 +285,15 @@ class NetworkOperatorsController extends Controller
|
||||
$support_emails = [];
|
||||
$old_support_emails = [];
|
||||
}
|
||||
if ($network_arr->finance_emails) {
|
||||
$finance_emails = json_decode($network_arr->finance_emails, true);
|
||||
$finance_emails = array_combine($finance_emails, $finance_emails);
|
||||
$old_finance_emails = json_decode($network_arr->finance_emails, true);
|
||||
}
|
||||
else{
|
||||
$finance_emails = [];
|
||||
$old_finance_emails = [];
|
||||
}
|
||||
if ($network_arr->support_phones) {
|
||||
$support_phones = json_decode($network_arr->support_phones, true);
|
||||
$support_phones = array_combine($support_phones, $support_phones);
|
||||
@@ -239,16 +339,19 @@ class NetworkOperatorsController extends Controller
|
||||
'account_manager' => $account_manager,
|
||||
'current_services' => json_decode($network_arr->services, true),
|
||||
'services' => $services->toArray(),
|
||||
'support_emails' => $support_emails,
|
||||
'support_emails' => $support_emails,
|
||||
'finance_emails' => $finance_emails,
|
||||
'support_skype_arr' => $support_skype_arr,
|
||||
'support_phones' => $support_phones,
|
||||
'old_support_emails' => $old_support_emails,
|
||||
'old_finance_emails' => $old_finance_emails,
|
||||
'old_support_skype_arr' => $old_support_skype_arr,
|
||||
'old_support_phones' => $old_support_phones,
|
||||
'status_bg' => $status_bg,
|
||||
'connection_types' => $connection_types,
|
||||
'old_connection_type' => $old_connection_type,
|
||||
'ip_addresses' => $ip_addresses
|
||||
'ip_addresses' => $ip_addresses,
|
||||
'notes_arr' => $notes_arr
|
||||
];
|
||||
return view('network_ops.edit', $data);
|
||||
}
|
||||
@@ -260,29 +363,59 @@ class NetworkOperatorsController extends Controller
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
public function update(Requests\UpdateMnoRequest $request, $id)
|
||||
{
|
||||
$request->validate([
|
||||
'name' => 'required',
|
||||
'country' => 'required',
|
||||
'account_manager_id' => 'required',
|
||||
'services' => 'required',
|
||||
'contact_person' => 'required',
|
||||
'contact_person_email' => 'required',
|
||||
'contact_person_phone' => 'required'
|
||||
]);
|
||||
|
||||
// dd($request->all());
|
||||
$operator_update = Models\NetworkOps::find($id);
|
||||
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('mno_files', $filename, 'public');
|
||||
$document_arr['file_path'] = $filename;
|
||||
$operator_update->name = $request->name;
|
||||
|
||||
$document_arr['file_extension'] = $request->document_one->extension();
|
||||
$document_arr['file_reff'] = time() . uniqid();
|
||||
$document_arr['name'] = $request->document_one_name;
|
||||
$document_arr['created_by'] = session('current_user.id');
|
||||
$document_arr['mno_id'] = $id;
|
||||
$result = Models\MnoFile::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('mno_files', $filename, 'public');
|
||||
$document_arr['file_path'] = $filename;
|
||||
$operator_update->name = $request->name;
|
||||
|
||||
$document_arr['file_extension'] = $request->document_two->extension();
|
||||
$document_arr['file_reff'] = time() . uniqid();
|
||||
$document_arr['name'] = $request->document_two_name;
|
||||
$document_arr['created_by'] = session('current_user.id');
|
||||
$document_arr['mno_id'] = $id;
|
||||
$result = Models\MnoFile::create($document_arr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$operator_update->name = $request->name;
|
||||
$operator_update->country = $request->country;
|
||||
$operator_update->account_manager_id = $request->account_manager_id;
|
||||
$operator_update->mno_account_manager = $request->mno_account_manager;
|
||||
|
||||
|
||||
|
||||
$operator_update->contact_person_email = $request->contact_person_email;
|
||||
$operator_update->contact_person_phone = $request->contact_person_phone;
|
||||
$operator_update->contact_person = $request->contact_person;
|
||||
$operator_update->connection_status = $request->connection_status ?? "";
|
||||
|
||||
$operator_update->technical_support_person = $request->technical_support_person ?? "";
|
||||
$operator_update->contact_person_finance = $request->contact_person_finance ?? "";
|
||||
|
||||
|
||||
$operator_update->contract_validity = $request->contract_validity ?? "";
|
||||
$operator_update->contract_auto_renew = $request->contract_auto_renew ?? "";
|
||||
|
||||
$operator_update->connection_type = ($request->connection_type) ? json_encode($request->connection_type) : "";
|
||||
|
||||
$operator_update->contact_person_skype = $request->contact_person_skype ?? "";
|
||||
@@ -290,9 +423,10 @@ class NetworkOperatorsController extends Controller
|
||||
#$operator_update->connections = ($request->connections) ? json_encode($request->connections) : "";
|
||||
$operator_update->services = ($request->services) ? json_encode($request->services) : "";
|
||||
$operator_update->support_emails = ($request->support_emails) ? json_encode($request->support_emails) : "";
|
||||
$operator_update->finance_emails = ($request->finance_emails) ? json_encode($request->finance_emails) : "";
|
||||
$operator_update->support_phones = ($request->support_phones) ? json_encode($request->support_phones) : "";
|
||||
$operator_update->support_skype = ($request->support_skype) ? json_encode($request->support_skype) : "";
|
||||
|
||||
|
||||
|
||||
$result = $operator_update->save();
|
||||
|
||||
@@ -337,6 +471,97 @@ class NetworkOperatorsController extends Controller
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function notesStore(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'mno_id' => 'required',
|
||||
'notes_body' => 'required'
|
||||
]);
|
||||
$auth_user = session('current_user');
|
||||
//'email' => 'unique:users,email_address'
|
||||
$notes_arr = [
|
||||
'notes_body' => $request->notes_body,
|
||||
'services' => implode(',', $request->services),
|
||||
'user_id' => $auth_user['id'],
|
||||
'mno_id' => $request->mno_id
|
||||
];
|
||||
if ($request->has('highlight')) {
|
||||
$notes_arr['highlight'] = 'YES';
|
||||
}
|
||||
|
||||
|
||||
//dd($notes_arr);
|
||||
$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));
|
||||
|
||||
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);
|
||||
}
|
||||
public function getSingleNote($id)
|
||||
{
|
||||
$note = Models\Mnonote::find($id);
|
||||
if ($note) {
|
||||
|
||||
$current_date = date_create(date('Y-m-d'));
|
||||
|
||||
$expiry_date = date_create($note->created_at);
|
||||
|
||||
$diff = date_diff($current_date, $expiry_date);
|
||||
$days = $diff->format("%a");
|
||||
if ($days > 7) {
|
||||
return response()->json([ 'code' => 5, 'msg' => 'This Note has been locked for editing']);
|
||||
}
|
||||
|
||||
$services_arr = explode(',', $note->services);
|
||||
|
||||
return response()->json([ 'code' => 1, 'result' => $note, 'services_arr' => $services_arr, 'days' => $days]);
|
||||
}
|
||||
else{
|
||||
return response()->json([ 'code' => 3, 'msg' => 'Request could not be handled at this time']);
|
||||
}
|
||||
|
||||
}
|
||||
public function notesUpdate(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'mno_id' => 'required',
|
||||
'notes_body' => 'required'
|
||||
]);
|
||||
$auth_user = session('current_user');
|
||||
$notes_arr = [
|
||||
'notes_body' => $request->notes_body,
|
||||
'services' => implode(',', $request->services),
|
||||
'user_id' => $auth_user['id'],
|
||||
'mno_id' => $request->mno_id
|
||||
];
|
||||
if ($request->has('highlight')) {
|
||||
$notes_arr['highlight'] = 'YES';
|
||||
}
|
||||
|
||||
|
||||
//dd($notes_arr);
|
||||
$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));
|
||||
|
||||
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);
|
||||
}
|
||||
public function destroy($id)
|
||||
{
|
||||
$result = Models\NetworkOps::destroy($id);
|
||||
|
||||
132
app/Http/Controllers/OfficeLocationsController.php
Normal file
132
app/Http/Controllers/OfficeLocationsController.php
Normal file
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
use App\Models;
|
||||
use Session;
|
||||
|
||||
class OfficeLocationsController extends Controller
|
||||
{
|
||||
public function index(){
|
||||
// $offices_arr = new Models\OfficeLocation;
|
||||
$offices_arr = Models\OfficeLocation::with( 'created_by_info', 'country_manager_info')->orderBy('country', 'ASC')->paginate(15);
|
||||
$data = [
|
||||
'page_title' => 'Office Locations',
|
||||
'offices_arr' => $offices_arr,
|
||||
'current_user' => session('current_user')
|
||||
];
|
||||
// dd($offices_arr->isEmpty());
|
||||
return view('officelocations.index', $data);
|
||||
}
|
||||
public function getSenderIdsJson(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')
|
||||
->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);
|
||||
}
|
||||
public function create()
|
||||
{
|
||||
|
||||
$countries = Models\Country::pluck('en_short_name','en_short_name');
|
||||
$staffmembers = Models\StaffMember::pluck('name', 'id');
|
||||
$data = [
|
||||
'page_title' => 'Add Office Location',
|
||||
'countries' => $countries,
|
||||
'staffmembers' => $staffmembers
|
||||
];
|
||||
|
||||
return view('officelocations.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([
|
||||
'street_name' => 'required',
|
||||
'house_number' => 'required',
|
||||
'block_number' => 'sometimes',
|
||||
'country' => 'required|unique:office_locations,country',
|
||||
'country_manager_id' => 'required|unique:office_locations,country_manager_id',
|
||||
'office_phone' => 'required'
|
||||
]);
|
||||
$flag = Models\CountryFlag::where('country', $request->country)->first();
|
||||
if ($flag) {
|
||||
$flag_url = $flag->url;
|
||||
}
|
||||
else{
|
||||
$flag_url = "https://via.placeholder.com/100x60";
|
||||
}
|
||||
$office_arr = $request->except('_token');
|
||||
$office_arr['user_id'] = session('current_user.id');
|
||||
|
||||
$office_arr['flag_url'] = $flag_url;
|
||||
$result = Models\OfficeLocation::create($office_arr);
|
||||
Session::flash('success_message', 'Office Location successfully added');
|
||||
return redirect(url('officelocations'));
|
||||
}
|
||||
public function edit($id){
|
||||
$office = Models\OfficeLocation::findOrFail($id);
|
||||
|
||||
$countries = Models\Country::pluck('en_short_name','en_short_name');
|
||||
$staffmembers = Models\StaffMember::pluck('name', 'id');
|
||||
|
||||
$data = [
|
||||
'page_title' => 'Edit Office Location',
|
||||
'countries' => $countries,
|
||||
'staffmembers' => $staffmembers
|
||||
];
|
||||
return view('officelocations.edit', $data);
|
||||
}
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
|
||||
$request->validate([
|
||||
'street_name' => 'required',
|
||||
'house_number' => 'required',
|
||||
'block_number' => 'sometimes',
|
||||
'country' => 'sometimes',
|
||||
'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->block_number = $request->block_number;
|
||||
$office->country = $request->country;
|
||||
$office->country_manager_id = $request->country_manager_id;
|
||||
$office->office_phone = $request->office_phone;
|
||||
|
||||
$office->save();
|
||||
|
||||
Session::flash('success_message', 'Office Location details successfully Updated');
|
||||
return redirect(url('officelocations'));
|
||||
}
|
||||
}
|
||||
@@ -69,7 +69,7 @@ class StaffMembersController extends Controller
|
||||
'gender' => 'required',
|
||||
'department_id' => 'required',
|
||||
'email' => 'required',
|
||||
'personal_email' => 'required',
|
||||
'personal_email' => 'sometimes',
|
||||
'phone' => 'required',
|
||||
'location_country' => 'required',
|
||||
'hire_date' => 'sometimes|date',
|
||||
@@ -117,7 +117,7 @@ class StaffMembersController extends Controller
|
||||
'location_country' => 'required',
|
||||
'hire_date' => 'sometimes|date'
|
||||
]);
|
||||
|
||||
//dd($request->all());
|
||||
$staff_member = Models\StaffMember::findOrFail($id);
|
||||
|
||||
$staff_member->name = $request->name;
|
||||
@@ -130,6 +130,12 @@ class StaffMembersController extends Controller
|
||||
$staff_member->hire_date = $request->hire_date;
|
||||
$staff_member->staff_number = $request->staff_number;
|
||||
$staff_member->gender = $request->gender;
|
||||
|
||||
$staff_member->emergency_contact_person = $request->emergency_contact_person;
|
||||
$staff_member->emergency_contact_phone = $request->emergency_contact_phone;
|
||||
$staff_member->known_health_condition = $request->known_health_condition;
|
||||
$staff_member->blood_group = $request->blood_group;
|
||||
|
||||
if ($request->has('profile_pic')) {
|
||||
$staff_member->profile_pic = $request->profile_pic;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ class SystemUsersController extends Controller
|
||||
'allusers' => $allusers
|
||||
];
|
||||
|
||||
return view('account.index', $data);
|
||||
return view('systemusers.index', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -67,7 +67,7 @@ class SystemUsersController extends Controller
|
||||
'designation' => $designation
|
||||
];
|
||||
|
||||
return view('account.create', $data);
|
||||
return view('systemusers.create', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -96,9 +96,9 @@ class SystemUsersController extends Controller
|
||||
'password' => md5($request->password)
|
||||
];
|
||||
|
||||
$inserted = Models\Account::create($make_account);
|
||||
$inserted = Models\SystemUser::create($make_account);
|
||||
Session::flash('success_message', 'Account successfully added');
|
||||
return redirect(url('accountmanagers'));
|
||||
return redirect(url('systemusers'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,13 +109,13 @@ class SystemUsersController extends Controller
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$account_arr = Models\Account::find($id);
|
||||
$account_arr = Models\SystemUser::find($id);
|
||||
$data = [
|
||||
'page_title' => 'Show Service',
|
||||
'account_arr' => $account_arr
|
||||
];
|
||||
|
||||
return view('account.show', $data);
|
||||
return view('systemusers.show', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,7 +134,7 @@ class SystemUsersController extends Controller
|
||||
'account_arr' => $account_arr
|
||||
];
|
||||
|
||||
return view('account.edit', $data);
|
||||
return view('systemusers.edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -146,7 +146,7 @@ class SystemUsersController extends Controller
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$account_arr = Models\Account::find($id);
|
||||
$account_arr = Models\SystemUser::find($id);
|
||||
$account_arr->name = $request->name;
|
||||
$account_arr->designation = $request->designation;
|
||||
$account_arr->email = $request->email;
|
||||
@@ -154,7 +154,7 @@ class SystemUsersController extends Controller
|
||||
$account_arr->password = md5($request->password);
|
||||
$account_arr->save();
|
||||
Session::flash('success_message', 'Account successfully Updated');
|
||||
return redirect(url('accountmanagers'));
|
||||
return redirect(url('systemusers'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -165,7 +165,7 @@ class SystemUsersController extends Controller
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
$result = Models\Account::destroy($id);
|
||||
$result = Models\SystemUser::destroy($id);
|
||||
if (request()->ajax()) {
|
||||
$result_arr = ['code' => 1];
|
||||
return response()->json($result_arr);
|
||||
@@ -173,21 +173,6 @@ class SystemUsersController extends Controller
|
||||
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) {
|
||||
|
||||
35
app/Http/Requests/GeneralDocumentsRequest.php
Normal file
35
app/Http/Requests/GeneralDocumentsRequest.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class GeneralDocumentsRequest 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.*'
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,22 @@ class UpdateClientRequest extends FormRequest
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public function messages(){
|
||||
return [
|
||||
'other_document_name.required_with' => 'You need to enter a name for the other document.',
|
||||
//'document_two_name.required_with' => 'Please select a file to upload.',
|
||||
//'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_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_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.',
|
||||
'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.',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
@@ -30,12 +46,16 @@ class UpdateClientRequest extends FormRequest
|
||||
'status' => 'required',
|
||||
'currency' => 'required',
|
||||
'auth_user_id' => 'required',
|
||||
/*
|
||||
'document_one_name' => 'required_with:document_one.*',
|
||||
'document_two_name' => 'required_with:document_two.*',
|
||||
'document_two_name' => 'required_with:document_three.*',
|
||||
'document_one' => 'max:2000|mimes:png,jpg,jpeg,bmp,pdf,doc,docx',
|
||||
'document_three' => 'max:2000|mimes:png,jpg,jpeg,bmp,pdf,doc,docx',
|
||||
'document_three' => 'max:2000|mimes:png,jpg,jpeg,bmp,pdf,doc,docx'
|
||||
'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'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
30
app/Http/Requests/UpdateGeneralDocumentRequest.php
Normal file
30
app/Http/Requests/UpdateGeneralDocumentRequest.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateGeneralDocumentRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
46
app/Http/Requests/UpdateMnoRequest.php
Normal file
46
app/Http/Requests/UpdateMnoRequest.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateMnoRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
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_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.',
|
||||
];
|
||||
}
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => 'required',
|
||||
'country' => 'required',
|
||||
'account_manager_id' => 'required',
|
||||
'services' => 'required',
|
||||
'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',
|
||||
];
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user