staff members,senderid, documents,bug fixes, etc
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user