bug fixes, AM change feature, refactoring
This commit is contained in:
@@ -15,6 +15,7 @@ use App\Http\Requests;
|
||||
use Carbon\Carbon;
|
||||
use App\Libs\PaperLessNgx;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
use Config;
|
||||
|
||||
class ClientsController extends Controller
|
||||
{
|
||||
@@ -23,7 +24,7 @@ class ClientsController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index(){
|
||||
public function index(){
|
||||
$data = [
|
||||
'page_title' => 'Clients',
|
||||
'current_user' => session('current_user')
|
||||
@@ -715,7 +716,7 @@ class ClientsController extends Controller
|
||||
$country_networks = \DB::table('network_operators')->Select(\DB::raw('id, concat(name, " (", country, ")") AS network'))->orderBy('network')->pluck('network', 'network');
|
||||
// $country_networks = \DB::table('network_operators')->Select(\DB::raw('concat(name, " (", country, ")") AS network)')->orderBy('network')->get()->toArray();
|
||||
// $country_networks = \DB::table('network_operators')->Select(\DB::raw('concat(name, " (", country, ")") AS network)'))->pluck('network', 'network');
|
||||
|
||||
$auth_users = Models\SystemUser::orderBy('name', 'ASC')->pluck('name', 'id');
|
||||
$networks_raw = [
|
||||
'AirtelTigo GH' => 'AirtelTigo GH',
|
||||
'MTN GH' => 'MTN GH',
|
||||
@@ -814,6 +815,8 @@ class ClientsController extends Controller
|
||||
sort($networks_raw);
|
||||
$recurring_arr = ['NO' => 'NO', 'Monthly' => 'Monthly', 'Quarterly' => 'Quarterly', 'Semiannual' => 'Semiannual', 'Yearly' => 'Yearly'];
|
||||
$sender_id_statuses = ['Pending' => 'Pending', 'Inactive' => 'Inactive', 'Approved' => 'Approved'];
|
||||
$change_account_mgr_permisson = Config::get('permissions.CHANGE_ACCOUNT_MANAGERS');
|
||||
$change_account_mgr_permisson = ($this->hasAnyAccess([$change_account_mgr_permisson])) ? 'YES' : 'NO';
|
||||
$data = [
|
||||
'page_title' => 'Client Profile',
|
||||
'showclient' => $showclient,
|
||||
@@ -839,6 +842,8 @@ class ClientsController extends Controller
|
||||
'recurring_arr' => $recurring_arr,
|
||||
// 'client_sender_ids' => $client_sender_ids,
|
||||
// 'sender_id_statuses' => $sender_id_statuses,
|
||||
'change_account_mgr_permisson' => $change_account_mgr_permisson,
|
||||
'am_list_arr' => $auth_users,
|
||||
'country_network_arr' => $country_networks,
|
||||
'mnos_arr' => ['' => '-- Select Country first --']
|
||||
];
|
||||
@@ -1198,26 +1203,29 @@ class ClientsController extends Controller
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Requests\UpdateClientRequest $request, $id){
|
||||
// dd($request->all());
|
||||
// dump($request->all());
|
||||
// \DB::connection()->enableQueryLog();
|
||||
$client_update = Models\Client::find($id);
|
||||
// dump($client_update->progress_indicator);
|
||||
$paperless = new PaperLessNgx();
|
||||
if ($client_update->progress_indicator != 'COMPLETED') {
|
||||
$current_pending_stage_details = Models\ClientOnboardingMainStage::where('stage', $request->current_pending_stage)->first();
|
||||
$get_stage_subs_items = Models\ClientOnboardingSubItem::where('stage_id', $current_pending_stage_details->stage_id)->get();
|
||||
#update the table for onboarding progress
|
||||
foreach ($request->onboarding_sub_items_progress as $value) {
|
||||
$stage_id = [
|
||||
'stage_id' => $current_pending_stage_details->stage_id,
|
||||
'client_id' => $id,
|
||||
'name' => $value
|
||||
];
|
||||
$progress_arr = [
|
||||
'status' => 'COMPLETED'
|
||||
];
|
||||
$clients_onboarding_progress = Models\ClientOnboardingProgress::updateOrCreate($stage_id, $progress_arr);
|
||||
// dump($request->onboarding_sub_items_progress);
|
||||
if ($request->onboarding_sub_items_progress) {
|
||||
foreach ($request->onboarding_sub_items_progress as $value) {
|
||||
$stage_id = [
|
||||
'stage_id' => $current_pending_stage_details->stage_id,
|
||||
'client_id' => $id,
|
||||
'name' => $value
|
||||
];
|
||||
$progress_arr = [
|
||||
'status' => 'COMPLETED'
|
||||
];
|
||||
$clients_onboarding_progress = Models\ClientOnboardingProgress::updateOrCreate($stage_id, $progress_arr);
|
||||
}
|
||||
}
|
||||
|
||||
//update the status of onboarding progress stage in clients
|
||||
$get_stage_onboarding_status = Models\ClientOnboardingProgress::where('client_id', $id)->where('stage_id', $current_pending_stage_details->stage_id)->where('status', 'COMPLETED')->get();
|
||||
$onboarding_progress_stage = json_decode($client_update->onboarding_progress_stage, true);
|
||||
@@ -1450,6 +1458,45 @@ class ClientsController extends Controller
|
||||
$result = Models\ClientCategory::create($client_arr);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public function changeAccountManagers(Request $request){
|
||||
|
||||
$new_account_manager = Models\SystemUser::find($request->account_manager);
|
||||
|
||||
$client = Models\Client::with('auth_user_info')->find($request->client_id);
|
||||
$client->auth_user_id = $request->account_manager;
|
||||
$client->last_modified_by = session('current_user.id');
|
||||
$result = $client->save();
|
||||
|
||||
if ($result) {
|
||||
|
||||
$log_text = session('current_user.name') . " changed the account manager of ";
|
||||
$log_text .= " " . $client->name . " from " . $client->auth_user_info->name;
|
||||
$log_text .= " to " . $new_account_manager->name;
|
||||
|
||||
$activity_arr = [
|
||||
'type' => 'staff',
|
||||
'content' => $log_text,
|
||||
'user_id' => session('current_user.id'),
|
||||
'ip_address' => \Request::ip(),
|
||||
'device' => $request->header('User-Agent')
|
||||
];
|
||||
$retval = Models\UserActivity::create($activity_arr);
|
||||
|
||||
$user_id = session('current_user.id');
|
||||
$username = session('current_user.name');
|
||||
$content = $log_text;
|
||||
$this->logUsersActivity($type = 'staff', $content);
|
||||
|
||||
$data = ['code' => 1, $msg = 'success'];
|
||||
return response()->json($data, 200);
|
||||
}
|
||||
else{
|
||||
$data = ['code' => 3, $msg = 'fail'];
|
||||
return response()->json($data, 200);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public function storeFiles(AddFilesRequest $request){
|
||||
$document_arr = $request->except('document');
|
||||
|
||||
@@ -7,7 +7,7 @@ use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use App\Models;
|
||||
|
||||
use Config;
|
||||
class Controller extends BaseController{
|
||||
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
@@ -92,4 +92,20 @@ class Controller extends BaseController{
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function hasAnyAccess($permissions){
|
||||
// dump(Config::get('permissions.' ));
|
||||
$required_permission = array_sum($permissions);
|
||||
#$system_permissions = Models\Permission::where('status', 'active')->get();
|
||||
|
||||
if (session('current_user.permissions') <> '') {
|
||||
if ((int)session('current_user.permissions') & $required_permission) {
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ class LoginController extends Controller
|
||||
$request->session()->put('current_otpuser.email', $logged_in->email);
|
||||
$request->session()->put('current_otpuser.phone', $logged_in->phone);
|
||||
$request->session()->put('current_otpuser.datetime_sent', date('Y-m-d H:i:s'));
|
||||
$request->session()->put('current_otpuser.permissions', $logged_in->permissions);
|
||||
$request->session()->put('current_otpuser.designation', $logged_in->designation_info->name);
|
||||
|
||||
$otp_set = ['otp' => $otp_code, 'email' => $logged_in->email, 'auth_name' => $logged_in->name];
|
||||
@@ -109,6 +110,7 @@ class LoginController extends Controller
|
||||
$request->session()->put('current_user.name', $otp_user['name']);
|
||||
$request->session()->put('current_user.email', $otp_user['email']);
|
||||
$request->session()->put('current_user.phone', $otp_user['phone']);
|
||||
$request->session()->put('current_user.permissions', $otp_user['permissions']);
|
||||
$request->session()->put('current_user.designation', $otp_user['designation']);
|
||||
|
||||
|
||||
|
||||
@@ -69,8 +69,8 @@ class NetworkOperatorsController extends Controller
|
||||
public function getMnosJson(Request $request){
|
||||
//$this->log_query();
|
||||
$mno_arr = \DB::table('network_operators')
|
||||
->join('staff_members AS staffam', 'staffam.id', '=', 'network_operators.account_manager_id')
|
||||
->join('staff_members AS staffmodify', 'staffmodify.id', '=', 'network_operators.last_modified_by')
|
||||
->join('auth_users AS staffam', 'staffam.id', '=', 'network_operators.account_manager_id')
|
||||
->join('auth_users AS staffmodify', 'staffmodify.id', '=', 'network_operators.last_modified_by')
|
||||
->select('network_operators.id', 'staffam.name AS accountManager', 'network_operators.name AS networkName', 'network_operators.country','network_operators.contract_validity', 'network_operators.connection_status', 'staffmodify.name AS modifiedBy')
|
||||
->orderBy('network_operators.name', 'ASC')
|
||||
->paginate(15);
|
||||
@@ -78,8 +78,8 @@ class NetworkOperatorsController extends Controller
|
||||
if($request->has('keyword')){
|
||||
$keyword = $request->keyword;
|
||||
$mno_arr = \DB::table('network_operators')
|
||||
->join('staff_members AS staffam', 'staffam.id', '=', 'network_operators.account_manager_id')
|
||||
->join('staff_members AS staffmodify', 'staffmodify.id', '=', 'network_operators.last_modified_by')
|
||||
->join('auth_users AS staffam', 'staffam.id', '=', 'network_operators.account_manager_id')
|
||||
->join('auth_users AS staffmodify', 'staffmodify.id', '=', 'network_operators.last_modified_by')
|
||||
->select('network_operators.id', 'staffam.name AS accountManager', 'network_operators.name AS networkName', 'network_operators.country','network_operators.contract_validity', 'network_operators.connection_status', 'staffmodify.name AS modifiedBy')
|
||||
->whereRaw("network_operators.name LIKE '%$keyword%' OR network_operators.connection_status LIKE '%$keyword%' OR network_operators.country LIKE '%$keyword%' OR staffam.name LIKE '%$keyword%' ")
|
||||
->orderBy('network_operators.name', 'ASC')
|
||||
|
||||
@@ -18,8 +18,9 @@ class OfficeLocationsController extends Controller
|
||||
'offices_arr' => $offices_arr,
|
||||
'current_user' => session('current_user')
|
||||
];
|
||||
// dd($data);
|
||||
// dd($offices_arr->isEmpty());
|
||||
return view('officelocations.index', $data);
|
||||
return view('officelocations.index-new', $data);
|
||||
}
|
||||
public function showfiles($id){
|
||||
$branch_files = Models\BranchFile::where('branch_id', $id)->get();
|
||||
@@ -55,7 +56,7 @@ class OfficeLocationsController extends Controller
|
||||
public function create()
|
||||
{
|
||||
$countries = Models\Country::pluck('en_short_name','en_short_name');
|
||||
$staffmembers = Models\StaffMember::pluck('name', 'id');
|
||||
$staffmembers = Models\SystemUser::pluck('name', 'id'); //system users
|
||||
$data = [
|
||||
'page_title' => 'Add Office Location',
|
||||
'countries' => $countries,
|
||||
@@ -85,7 +86,6 @@ class OfficeLocationsController extends Controller
|
||||
'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',
|
||||
@@ -102,6 +102,7 @@ class OfficeLocationsController extends Controller
|
||||
$office_arr['user_id'] = session('current_user.id');
|
||||
|
||||
$office_arr['flag_url'] = $flag_url;
|
||||
$office_arr['city'] = $request->city_town;
|
||||
$result = Models\OfficeLocation::create($office_arr);
|
||||
Session::flash('success_message', 'Office Location successfully added');
|
||||
return redirect(url('officelocations'));
|
||||
@@ -133,13 +134,13 @@ class OfficeLocationsController extends Controller
|
||||
'country_manager_id' => 'required',
|
||||
'office_phone' => 'required'
|
||||
]);
|
||||
|
||||
// dd($request->all());
|
||||
$office = Models\OfficeLocation::findOrFail($id);
|
||||
|
||||
$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->city = $request->city_town;
|
||||
$office->country = $request->country;
|
||||
$office->country_manager_id = $request->country_manager_id;
|
||||
$office->office_phone = $request->office_phone;
|
||||
@@ -208,10 +209,12 @@ class OfficeLocationsController extends Controller
|
||||
$request->validate([
|
||||
'document_one_name' => 'required',
|
||||
'id' => 'required',
|
||||
'validity_period_one' => 'sometimes',
|
||||
'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;
|
||||
$document->validity_period = $request->validity_period_one;
|
||||
if ($request->has('document_one')) {
|
||||
if ($request->file('document_one')->isValid()) {
|
||||
$filename = "erp_" . time() . str_random(6) . "." . $request->document_one->extension();
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Http\Request;
|
||||
use App\Models;
|
||||
use Session;
|
||||
use Excel;
|
||||
use App\Imports\Senderidimport;
|
||||
use App\Imports\SenderidImport;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class SenderIdController extends Controller
|
||||
@@ -35,8 +35,10 @@ class SenderIdController extends Controller
|
||||
->paginate(15);
|
||||
|
||||
if($request->has('keyword')){
|
||||
|
||||
$queries = [];
|
||||
$keyword = $request->keyword;
|
||||
$request->session()->put('current_user.senderid_keyword', $keyword);
|
||||
$queries['keyword'] = $keyword;
|
||||
$senderid_arr = \DB::table('sender_ids')
|
||||
->join('staff_members AS staffcreate', 'staffcreate.id', '=', 'sender_ids.created_by')
|
||||
@@ -109,14 +111,35 @@ class SenderIdController extends Controller
|
||||
'status' => 'required',
|
||||
'remarks' => 'sometimes',
|
||||
]);
|
||||
// dump($request->all());
|
||||
/*
|
||||
$check_duplicate = Models\SenderId::where('senderid', $request->senderid)
|
||||
->where('mno_name', $request->mno_name)
|
||||
->first();
|
||||
|
||||
if($check_duplicate){
|
||||
return redirect()->back()->withInput()->withErrors("Sender ID already exist for " . $request->mno_name );
|
||||
*/
|
||||
|
||||
$check_duplicate = Models\SenderId::where('senderid', $request->senderid)->first();
|
||||
// dd($check_duplicate);
|
||||
if ($check_duplicate) {
|
||||
// code...
|
||||
if ($request->direct_mno == 'YES' && $check_duplicate->direct_mno == 'YES') {
|
||||
if ($request->mno_name == $check_duplicate->mno_name) {
|
||||
return redirect()->back()->withInput()->withErrors("Sender ID already exist for " . $request->mno_name );
|
||||
}
|
||||
}
|
||||
if ($request->direct_mno == 'NO' && $check_duplicate->direct_mno == 'NO') {
|
||||
if ($request->supplier_name == $check_duplicate->supplier_name) {
|
||||
return redirect()->back()->withInput()->withErrors("Sender ID already exist for " . $request->supplier_name );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// dd('foo stop');
|
||||
// if($check_duplicate){
|
||||
// return redirect()->back()->withInput()->withErrors("Sender ID already exist for " . $request->mno_name );
|
||||
// }
|
||||
|
||||
$senderid_arr = $request->except('_token');
|
||||
$senderid_arr['created_by'] = session('current_user.id');
|
||||
$senderid_arr['last_modified_by'] = session('current_user.id');
|
||||
@@ -179,7 +202,7 @@ class SenderIdController extends Controller
|
||||
$request->senderid_file->storeAs('general_files', $filename, 'public');
|
||||
|
||||
$stored_file = public_path('documents/general_files/'.$filename);
|
||||
$extracted_arr = Excel::toArray(new Senderidimport, $stored_file);
|
||||
$extracted_arr = Excel::toArray(new SenderidImport, $stored_file);
|
||||
// dd($extracted_arr[0]);
|
||||
$row_count = $extracted_arr[0];
|
||||
$main = [];
|
||||
@@ -227,6 +250,7 @@ class SenderIdController extends Controller
|
||||
// dd('foo bar');
|
||||
$senderid_arr['senderid'] = $value['senderid'];
|
||||
$senderid_arr['mno_name'] = $value['mno_name'];
|
||||
$senderid_arr['status'] = $value['status'];
|
||||
$senderid_arr['created_by'] = session('current_user.id');
|
||||
$senderid_arr['last_modified_by'] = session('current_user.id');
|
||||
$senderid_arr['remarks'] = $value['remarks'];
|
||||
@@ -235,6 +259,7 @@ class SenderIdController extends Controller
|
||||
else{
|
||||
$senderid_arr['senderid'] = $value['senderid'];
|
||||
$senderid_arr['supplier_name'] = $value['supplier_name'];
|
||||
$senderid_arr['status'] = $value['status'];
|
||||
$senderid_arr['created_by'] = session('current_user.id');
|
||||
$senderid_arr['last_modified_by'] = session('current_user.id');
|
||||
$senderid_arr['remarks'] = $value['remarks'];
|
||||
@@ -261,7 +286,7 @@ class SenderIdController extends Controller
|
||||
return \Response::download($file, 'Sender ID Upload Report', $headers);
|
||||
}
|
||||
public function getSampleFile(){
|
||||
$file = public_path('documents/general_files/senderid_sample_file.xlsx');
|
||||
$file = public_path('helper_documents/senderid_sample_file.xlsx');
|
||||
|
||||
#$extension = pathinfo($file, PATHINFO_EXTENSION);
|
||||
$headers = ['Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'];
|
||||
@@ -374,6 +399,65 @@ class SenderIdController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function exportSenderIdCsv(){
|
||||
$fileName = 'senderid_list.csv';
|
||||
$users = Models\SenderId::all()->toArray(); // Adjust model as needed
|
||||
|
||||
$headers = [
|
||||
'Content-Type' => 'text/csv',
|
||||
'Content-Disposition' => "attachment; filename=\"$fileName\"",
|
||||
'Pragma' => 'no-cache',
|
||||
'Cache-Control' => 'must-revalidate, post-check=0, pre-check=0',
|
||||
'Expires' => '0',
|
||||
];
|
||||
|
||||
$keyword = session('current_user.senderid_keyword');
|
||||
// dd(request('keyword'));
|
||||
// dd($keyword);
|
||||
request()->session()->put('current_user.senderid_keyword', null);
|
||||
// dump($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')
|
||||
->select('sender_ids.id', 'mno_name', 'supplier_name', 'sender_ids.senderid', 'sender_ids.status', 'sender_ids.remarks', 'staffcreate.name As createdBy', 'sender_ids.direct_mno', 'staffmodify.name AS modifiedBy')
|
||||
->whereRaw("sender_ids.senderid LIKE '%$keyword%' OR sender_ids.status LIKE '%$keyword%' OR mno_name LIKE '%$keyword%' OR supplier_name LIKE '%$keyword%' OR staffcreate.name LIKE '%$keyword%' OR staffmodify.name LIKE '%$keyword%' OR sender_ids.direct_mno LIKE '%$keyword%'")
|
||||
->orderBy('sender_ids.senderid', 'ASC')
|
||||
->get()->toArray();
|
||||
|
||||
// dd($senderid_arr);
|
||||
|
||||
# add headers for each column in the CSV download
|
||||
array_unshift($senderid_arr, array_keys((array)$senderid_arr[0]));
|
||||
|
||||
$callback = function() use ($senderid_arr){
|
||||
$file_handle = fopen('php://output', 'w');
|
||||
foreach ($senderid_arr as $row) {
|
||||
$row = (array)$row;
|
||||
fputcsv($file_handle, $row);
|
||||
}
|
||||
fclose($file_handle);
|
||||
};
|
||||
|
||||
// return Response::stream($callback, 200, $headers);
|
||||
return response()->stream($callback, 200, $headers);
|
||||
|
||||
|
||||
|
||||
// $callback = function() use ($senderid_arr) {
|
||||
// $file = fopen('php://output', 'w');
|
||||
// // Add CSV headers
|
||||
// fputcsv($file, array_keys($senderid_arr[0]));
|
||||
// // Add data rows
|
||||
// foreach ($senderid_arr as $row) {
|
||||
// fputcsv($file, $row);
|
||||
// }
|
||||
// fclose($file);
|
||||
|
||||
// };
|
||||
|
||||
// return response()->stream($callback, 200, $headers);
|
||||
}
|
||||
|
||||
|
||||
public function getMNOList($type){
|
||||
if ($type == 'YES') {
|
||||
|
||||
273
app/Http/Controllers/SupportTicketsController.php
Normal file
273
app/Http/Controllers/SupportTicketsController.php
Normal file
@@ -0,0 +1,273 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models;
|
||||
use Session;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
|
||||
class SupportTicketsController extends Controller
|
||||
{
|
||||
//
|
||||
public function index(){
|
||||
$data = [
|
||||
'page_title' => 'Support Tickets Home',
|
||||
'current_user' => session('current_user')
|
||||
];
|
||||
return view('support-ticket.landing', $data);
|
||||
}
|
||||
public function ticketlist(){
|
||||
$data = [
|
||||
'page_title' => 'Support Tickets List',
|
||||
'current_user' => session('current_user')
|
||||
];
|
||||
return view('support-ticket.index', $data);
|
||||
}
|
||||
public function getSuppoerTicketJson(Request $request)
|
||||
{
|
||||
#$this->log_query();
|
||||
$supportticket_arr = \DB::table('support_tickets')
|
||||
->join('staff_members AS staffcreate', 'staffcreate.id', '=', 'support_tickets.created_by_id')
|
||||
->join('staff_members AS assignedTo', 'assignedTo.id', '=', 'support_tickets.assigned_to_id')
|
||||
// ->join('network_operators', 'network_operators.id', '=', 'support_tickets.network_id')
|
||||
// ->join('clients', 'clients.id', '=', 'support_tickets.client_id')
|
||||
->select('support_tickets.id', 'support_tickets.case_number', 'support_tickets.subject', 'support_tickets.body', 'support_tickets.created_by_id', 'support_tickets.status', 'support_tickets.created_at', 'support_tickets.assigned_to_id', 'staffcreate.name As createdBy', 'assignedTo.name AS assignedToName')
|
||||
->orderBy('support_tickets.id', 'ASC')
|
||||
->paginate(15);
|
||||
|
||||
if($request->has('keyword')){
|
||||
$queries = [];
|
||||
$keyword = $request->keyword;
|
||||
$queries['keyword'] = $keyword;
|
||||
|
||||
$supportticket_arr = \DB::table('support_tickets')
|
||||
->join('staff_members AS staffcreate', 'staffcreate.id', '=', 'support_tickets.created_by_id')
|
||||
->join('staff_members AS assignedTo', 'assignedTo.id', '=', 'support_tickets.assigned_to_id')
|
||||
->select('support_tickets.id', 'support_tickets.case_number', 'support_tickets.subject', 'support_tickets.body', 'support_tickets.created_by_id', 'support_tickets.status', 'support_tickets.created_at', 'support_tickets.assigned_to_id', 'staffcreate.name As createdBy', 'assignedTo.name AS assignedToName')
|
||||
->whereRaw("support_tickets.case_number LIKE '%$keyword%' OR assignedTo.name LIKE '%$keyword%' OR support_tickets.status LIKE '%$keyword%' OR support_tickets.body LIKE '%$keyword%' OR staffcreate.name LIKE '%$keyword%' OR support_tickets.created_at LIKE '%$keyword%'")
|
||||
->orderBy('support_tickets.id', 'ASC')
|
||||
->paginate(15)->appends($queries);
|
||||
}
|
||||
return response()->json($supportticket_arr);
|
||||
}
|
||||
public function create()
|
||||
{
|
||||
#$network_arr = Models\NetworkOps::pluck('name','country');
|
||||
|
||||
$networks = \DB::table('network_operators')->Select(\DB::raw('concat(name, " (", country, ")") AS networkvalue, concat(name, " (", country, ")") AS network'))->orderBy('network')->get()->toArray();
|
||||
$network_arr = array_pluck($networks, 'network', 'networkvalue');
|
||||
$direct_mno_arr = ['YES' => 'YES', 'NO' => 'NO'];
|
||||
|
||||
// dd($network_arr);
|
||||
#$network_arr = array_combine($network_arr, $network_arr);
|
||||
|
||||
|
||||
// $clients = Models\Client::pluck('name', 'name');
|
||||
$clients = \DB::table('clients')->Select(\DB::raw('concat(name, " (", country, ")") AS clientvalue, concat(name, " (", country, ")") AS client'))->orderBy('client')->get()->toArray();
|
||||
$client_arr = array_pluck($clients, 'client', 'clientvalue');
|
||||
$staffmembers = Models\StaffMember::pluck('name', 'id');
|
||||
#$status = ['Pending' => 'Pending', 'Inactive' => 'Inactive', 'Approved' => 'Approved'];
|
||||
#$status = ['Applied to MNO', 'Applied to Aggregator', 'Approved on MNO', 'Approved on Aggregator', 'Active', 'InActive'];
|
||||
$status = [
|
||||
'Applied to MNO' => 'Applied to MNO',
|
||||
'Applied to Aggregator' => 'Applied to Aggregator',
|
||||
'Approved on MNO' => 'Approved on MNO',
|
||||
'Approved on Aggregator' => 'Approved on Aggregator',
|
||||
'Active' => 'Active',
|
||||
'Inactive' => 'InActive'
|
||||
];
|
||||
|
||||
$data = [
|
||||
'page_title' => 'Create Sender ID',
|
||||
'network_arr' => $network_arr,
|
||||
'status' => $status,
|
||||
'clients' => $client_arr,
|
||||
'direct_mno_arr' => $direct_mno_arr,
|
||||
'staffmembers' => $staffmembers
|
||||
];
|
||||
// dd($data);
|
||||
return view('support-ticket.create', $data);
|
||||
}
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'subject' => 'sometimes',
|
||||
'body' => 'required',
|
||||
'attachment' => 'sometimes',
|
||||
//max:10240|mimes:png,jpg,jpeg,bmp,pdf,doc,docx,xlx,xlsx,pptx,ppt
|
||||
]);
|
||||
// dd($request->all());
|
||||
//Generate case number here
|
||||
$case_number = "ERP-" . date('Y-m-d-') . time();
|
||||
$ticket_arr = $request->except('_token');
|
||||
$ticket_arr['case_number'] = $case_number;
|
||||
$ticket_arr['assigned_to_id'] = 1; // change this
|
||||
$ticket_arr['created_by_id'] = session('current_user.id'); // change this
|
||||
|
||||
$result = Models\SupportTicket::create($ticket_arr);
|
||||
|
||||
if ($request->attachment !== null) {
|
||||
if ($request->file('attachment')->isValid()) {
|
||||
//dd($request->all());
|
||||
$filename = "erp_" . time() . str_random(4) . "." . $request->attachment->extension();
|
||||
$request->attachment->storeAs('supportticket_files', $filename, 'public');
|
||||
$document_arr['filename'] = $filename;
|
||||
|
||||
$document_arr['file_extension'] = $request->document_one->extension();
|
||||
$document_arr['file_reff'] = time() . uniqid();
|
||||
$document_arr['case_number'] = $case_number;
|
||||
$document_arr['uploaded_by'] = session('current_user.id');
|
||||
|
||||
$result = Models\SupportTicketsDocument::create($document_arr);
|
||||
}
|
||||
}
|
||||
Session::flash('success_message', 'Support Ticket successfully created');
|
||||
return redirect(url('supporttickets/list'));
|
||||
}
|
||||
public function edit($id){
|
||||
$support_ticket = Models\SupportTicket::findOrFail($id);
|
||||
|
||||
$data = [
|
||||
'page_title' => 'Edit Support',
|
||||
'support_ticket' => $support_ticket,
|
||||
];
|
||||
return view('support-ticket.edit', $data);
|
||||
}
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
|
||||
$request->validate([
|
||||
'subject' => 'sometimes',
|
||||
'body' => 'required',
|
||||
'attachment' => 'sometimes',
|
||||
]);
|
||||
|
||||
$support_ticket = Models\SupportTicket::findOrFail($id);
|
||||
|
||||
$support_ticket->body = $request->body;
|
||||
$support_ticket->body = $request->subject;
|
||||
|
||||
$support_ticket->save();
|
||||
|
||||
Session::flash('success_message', 'Support Ticket successfully Updated');
|
||||
return redirect(url('supporttickets/list'));
|
||||
}
|
||||
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['validity_period'] = $request->validity_period_one;
|
||||
$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['validity_period'] = $request->validity_period_two;
|
||||
$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['validity_period'] = $request->validity_period_third;
|
||||
$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('supporttickets/list'));
|
||||
}
|
||||
public function filesUpdate(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
'document_one_name' => 'required',
|
||||
'id' => 'required',
|
||||
'validity_period_one' => 'sometimes',
|
||||
'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;
|
||||
$document->validity_period = $request->validity_period_one;
|
||||
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('supporttickets/list'));
|
||||
}
|
||||
|
||||
public function show_edit_files_form($id){
|
||||
$document = Models\BranchFile::findOrFail($id);
|
||||
$data = [
|
||||
'page_title' => 'Update Document',
|
||||
'document' => $document
|
||||
];
|
||||
return view('supporttickets.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;
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Support\Collection;
|
||||
use Maatwebsite\Excel\Concerns\ToCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
|
||||
class Senderidimport implements ToCollection, WithHeadingRow
|
||||
class SenderidImport implements ToCollection, WithHeadingRow
|
||||
{
|
||||
/**
|
||||
* @param Collection $collection
|
||||
|
||||
@@ -9,9 +9,10 @@ class OfficeLocation extends Model
|
||||
protected $guarded = array('id');
|
||||
|
||||
public function created_by_info(){
|
||||
return $this->hasOne('App\Models\StaffMember', 'id', 'user_id');
|
||||
return $this->hasOne('App\Models\SystemUser', 'id', 'user_id');
|
||||
}
|
||||
public function country_manager_info(){
|
||||
return $this->hasOne('App\Models\StaffMember', 'id', 'country_manager_id');
|
||||
// return $this->hasOne('App\Models\StaffMember', 'id', 'country_manager_id');
|
||||
return $this->hasOne('App\Models\SystemUser', 'id', 'country_manager_id');
|
||||
}
|
||||
}
|
||||
|
||||
11
app/Models/Permission.php
Normal file
11
app/Models/Permission.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Permission extends Model
|
||||
{
|
||||
protected $guarded = array('id');
|
||||
public $table = "hlp_permissions";
|
||||
}
|
||||
25
app/Models/SupportTicket.php
Normal file
25
app/Models/SupportTicket.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SupportTicket extends Model
|
||||
{
|
||||
protected $guarded = array('id');
|
||||
public $table = "support_tickets";
|
||||
|
||||
|
||||
|
||||
|
||||
public function modified_by_info(){
|
||||
return $this->hasOne('App\Models\StaffMember', 'id', 'last_modified_by');
|
||||
}
|
||||
|
||||
public function created_by_info(){
|
||||
return $this->hasOne('App\Models\StaffMember', 'id', 'created_by');
|
||||
}
|
||||
public function assignedTo(){
|
||||
return $this->hasOne('App\Models\StaffMember', 'id', 'assigned_to');
|
||||
}
|
||||
}
|
||||
14
app/Models/SupportTicketsDocument.php
Normal file
14
app/Models/SupportTicketsDocument.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class SupportTicketsDocument extends Model
|
||||
{
|
||||
//
|
||||
protected $guarded = array('id');
|
||||
public $table = "support_ticket_attachments";
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user