Moved ShortCodes to a new controller, added Tabulator, bug fixes
This commit is contained in:
151
app/Http/Controllers/ShortCodesController.php
Normal file
151
app/Http/Controllers/ShortCodesController.php
Normal file
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Http\Requests;
|
||||
use Carbon\Carbon;
|
||||
use App\Models;
|
||||
use Session;
|
||||
|
||||
class ShortCodesController extends Controller{
|
||||
|
||||
public function indexTab(){
|
||||
$data = [
|
||||
'page_title' => 'Short Codes',
|
||||
'type' => 'SMS',
|
||||
'current_user' => session('current_user')
|
||||
];
|
||||
return view('shortcodes.index', $data);
|
||||
}
|
||||
|
||||
public function smsindex(){
|
||||
// $codes_data = Models\ClientShortCode::groupBy('code_type')->get();
|
||||
$codes_data = \DB::table('client_short_codes')
|
||||
->select('code_type', \DB::raw('count(*) as total'))
|
||||
->groupBy('code_type')
|
||||
->get();
|
||||
$data = [
|
||||
'page_title' => 'Short Codes',
|
||||
'type' => 'SMS',
|
||||
'codes_data' => $codes_data,
|
||||
'current_user' => session('current_user')
|
||||
];
|
||||
return view('shortcodes.smsindex', $data);
|
||||
}
|
||||
public function getShortCodesJson(Request $request){
|
||||
#$this->log_query();
|
||||
//$codes_data = Models\ClientShortCode::with('client_info', 'update_info')->where('code_type', 'sms')->orderBy('id', 'DESC')->get();
|
||||
|
||||
$shortcode_arr = \DB::table('client_short_codes')
|
||||
->join('auth_users', 'auth_users.id', '=', 'client_short_codes.last_updated_by')
|
||||
->join('clients', 'clients.id', '=', 'client_short_codes.client_id')
|
||||
->select('client_short_codes.id', 'client_short_codes.name', 'client_short_codes.shortcode', 'clients.name AS clientName', 'client_short_codes.network', 'client_short_codes.toll_free', 'client_short_codes.status', 'client_short_codes.remarks', 'client_short_codes.launch_date', 'client_short_codes.expiry_date', 'client_short_codes.last_updated_by', 'auth_users.name AS modifiedBy')
|
||||
->where('client_short_codes.code_type', 'sms')
|
||||
->orderBy('client_short_codes.shortcode', 'ASC')
|
||||
->paginate(15);
|
||||
|
||||
if($request->has('keyword')){
|
||||
$keyword = $request->keyword;
|
||||
$code_type = 'sms';
|
||||
$shortcode_arr = \DB::table('client_short_codes')
|
||||
->join('auth_users', 'auth_users.id', '=', 'client_short_codes.last_updated_by')
|
||||
->join('clients', 'clients.id', '=', 'client_short_codes.client_id')
|
||||
->select('client_short_codes.id', 'client_short_codes.name', 'client_short_codes.shortcode', 'clients.name AS clientName', 'client_short_codes.network', 'client_short_codes.toll_free', 'client_short_codes.status', 'client_short_codes.remarks', 'client_short_codes.launch_date', 'client_short_codes.expiry_date', 'client_short_codes.last_updated_by', 'auth_users.name AS modifiedBy')
|
||||
->whereRaw("code_type = '$code_type' AND (client_short_codes.name LIKE '%$keyword%' OR client_short_codes.shortcode LIKE '%$keyword%' OR client_short_codes.status LIKE '%$keyword%' OR client_short_codes.network LIKE '%$keyword%' OR client_short_codes.toll_free LIKE '%$keyword%' OR client_short_codes.launch_date LIKE '%$keyword%' OR client_short_codes.expiry_date LIKE '%$keyword%' OR clients.name LIKE '%$keyword%' OR auth_users.name LIKE '%$keyword%')")
|
||||
// ->where('code_type', $code_type)
|
||||
->orderBy('client_short_codes.shortcode', 'ASC')
|
||||
->paginate(15);
|
||||
}
|
||||
return response()->json($shortcode_arr);
|
||||
}
|
||||
|
||||
public function ussdindex(){
|
||||
// $codes_data = Models\ClientShortCode::groupBy('code_type')->get();
|
||||
$codes_data = \DB::table('client_short_codes')
|
||||
->select('code_type', \DB::raw('count(*) as total'))
|
||||
->groupBy('code_type')
|
||||
->get();
|
||||
$data = [
|
||||
'page_title' => 'Short Codes',
|
||||
'type' => 'USSD',
|
||||
'codes_data' => $codes_data,
|
||||
'current_user' => session('current_user')
|
||||
];
|
||||
return view('shortcodes.ussdindex', $data);
|
||||
}
|
||||
public function getUssdShortCodesJson(Request $request){
|
||||
#$this->log_query();
|
||||
//$codes_data = Models\ClientShortCode::with('client_info', 'update_info')->where('code_type', 'sms')->orderBy('id', 'DESC')->get();
|
||||
|
||||
$shortcode_arr = \DB::table('client_short_codes')
|
||||
->join('auth_users', 'auth_users.id', '=', 'client_short_codes.last_updated_by')
|
||||
->join('clients', 'clients.id', '=', 'client_short_codes.client_id')
|
||||
->select('client_short_codes.id', 'client_short_codes.name', 'client_short_codes.shortcode', 'clients.name AS clientName', 'client_short_codes.network', 'client_short_codes.toll_free', 'client_short_codes.status', 'client_short_codes.remarks', 'client_short_codes.launch_date', 'client_short_codes.expiry_date', 'client_short_codes.last_updated_by', 'auth_users.name AS modifiedBy')
|
||||
->where('client_short_codes.code_type', 'ussd')
|
||||
->orderBy('client_short_codes.shortcode', 'ASC')
|
||||
->paginate(15);
|
||||
|
||||
if($request->has('keyword')){
|
||||
$keyword = $request->keyword;
|
||||
$code_type = 'ussd';
|
||||
$shortcode_arr = \DB::table('client_short_codes')
|
||||
->join('auth_users', 'auth_users.id', '=', 'client_short_codes.last_updated_by')
|
||||
->join('clients', 'clients.id', '=', 'client_short_codes.client_id')
|
||||
->select('client_short_codes.id', 'client_short_codes.name', 'client_short_codes.shortcode', 'clients.name AS clientName', 'client_short_codes.network', 'client_short_codes.toll_free', 'client_short_codes.status', 'client_short_codes.remarks', 'client_short_codes.launch_date', 'client_short_codes.expiry_date', 'client_short_codes.last_updated_by', 'auth_users.name AS modifiedBy')
|
||||
->whereRaw("code_type = '$code_type' AND (client_short_codes.name LIKE '%$keyword%' OR client_short_codes.shortcode LIKE '%$keyword%' OR client_short_codes.status LIKE '%$keyword%' OR client_short_codes.network LIKE '%$keyword%' OR client_short_codes.toll_free LIKE '%$keyword%' OR client_short_codes.launch_date LIKE '%$keyword%' OR client_short_codes.expiry_date LIKE '%$keyword%' OR clients.name LIKE '%$keyword%' OR auth_users.name LIKE '%$keyword%')")
|
||||
// ->where('code_type', $code_type)
|
||||
->orderBy('client_short_codes.shortcode', 'ASC')
|
||||
->paginate(15);
|
||||
}
|
||||
return response()->json($shortcode_arr);
|
||||
}
|
||||
|
||||
|
||||
public function voiceindex(){
|
||||
// $codes_data = Models\ClientShortCode::groupBy('code_type')->get();
|
||||
$codes_data = \DB::table('client_short_codes')
|
||||
->select('code_type', \DB::raw('count(*) as total'))
|
||||
->groupBy('code_type')
|
||||
->get();
|
||||
$data = [
|
||||
'page_title' => 'Short Codes',
|
||||
'type' => 'Voice',
|
||||
'codes_data' => $codes_data,
|
||||
'current_user' => session('current_user')
|
||||
];
|
||||
return view('shortcodes.voiceindex', $data);
|
||||
}
|
||||
public function getVoiceShortCodesJson(Request $request){
|
||||
#$this->log_query();
|
||||
//$codes_data = Models\ClientShortCode::with('client_info', 'update_info')->where('code_type', 'sms')->orderBy('id', 'DESC')->get();
|
||||
|
||||
$shortcode_arr = \DB::table('client_short_codes')
|
||||
->join('auth_users', 'auth_users.id', '=', 'client_short_codes.last_updated_by')
|
||||
->join('clients', 'clients.id', '=', 'client_short_codes.client_id')
|
||||
->select('client_short_codes.id', 'client_short_codes.name', 'client_short_codes.shortcode', 'clients.name AS clientName', 'client_short_codes.network', 'client_short_codes.toll_free', 'client_short_codes.status', 'client_short_codes.remarks', 'client_short_codes.launch_date', 'client_short_codes.expiry_date', 'client_short_codes.last_updated_by', 'auth_users.name AS modifiedBy')
|
||||
->where('client_short_codes.code_type', 'voice')
|
||||
->orderBy('client_short_codes.shortcode', 'ASC')
|
||||
->paginate(15);
|
||||
|
||||
if($request->has('keyword')){
|
||||
$keyword = $request->keyword;
|
||||
$code_type = 'voice';
|
||||
$shortcode_arr = \DB::table('client_short_codes')
|
||||
->join('auth_users', 'auth_users.id', '=', 'client_short_codes.last_updated_by')
|
||||
->join('clients', 'clients.id', '=', 'client_short_codes.client_id')
|
||||
->select('client_short_codes.id', 'client_short_codes.name', 'client_short_codes.shortcode', 'clients.name AS clientName', 'client_short_codes.network', 'client_short_codes.toll_free', 'client_short_codes.status', 'client_short_codes.remarks', 'client_short_codes.launch_date', 'client_short_codes.expiry_date', 'client_short_codes.last_updated_by', 'auth_users.name AS modifiedBy')
|
||||
->whereRaw("code_type = '$code_type' AND (client_short_codes.name LIKE '%$keyword%' OR client_short_codes.shortcode LIKE '%$keyword%' OR client_short_codes.status LIKE '%$keyword%' OR client_short_codes.network LIKE '%$keyword%' OR client_short_codes.toll_free LIKE '%$keyword%' OR client_short_codes.launch_date LIKE '%$keyword%' OR client_short_codes.expiry_date LIKE '%$keyword%' OR clients.name LIKE '%$keyword%' OR auth_users.name LIKE '%$keyword%')")
|
||||
// ->where('code_type', $code_type)
|
||||
->orderBy('client_short_codes.shortcode', 'ASC')
|
||||
->paginate(15);
|
||||
}
|
||||
return response()->json($shortcode_arr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user