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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user