Skip to content

Commit a160588

Browse files
committed
frontend-fixing-admin-part-2
1 parent 6360d66 commit a160588

90 files changed

Lines changed: 1344 additions & 969 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/Http/Controllers/Admin/helpdesk/BanlistController.php

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
//classes
1313
use Exception;
1414
use Lang;
15+
use Yajra\DataTables\Facades\DataTables;
1516

1617
/**
1718
* BanlistController
@@ -46,14 +47,41 @@ public function __construct()
4647
public function index()
4748
{
4849
try {
49-
$bans = User::where('ban', '=', 1)->get();
50-
51-
return view('themes.default1.admin.helpdesk.emails.banlist.index', compact('bans'));
50+
return view('themes.default1.admin.helpdesk.emails.banlist.index');
5251
} catch (Exception $e) {
5352
return redirect()->back()->with('fails', $e->getMessage());
5453
}
5554
}
5655

56+
/**
57+
* Return banned users list as DataTables JSON for the index AJAX endpoint.
58+
*
59+
* @return \Illuminate\Http\JsonResponse
60+
*/
61+
public function getBanList()
62+
{
63+
try {
64+
$bans = User::where('ban', '=', 1)->select('id', 'email', 'updated_at')->get();
65+
66+
return DataTables::of($bans)
67+
->addColumn('email', function ($model) {
68+
return '<a href="' . route('banlist.edit', $model->id) . '">' . e($model->email) . '</a>';
69+
})
70+
->addColumn('updated_at', function ($model) {
71+
return \UTC::usertimezone($model->updated_at);
72+
})
73+
->addColumn('action', function ($model) {
74+
$edit = '<a href="' . route('banlist.edit', $model->id) . '" class="btn btn-primary btn-xs"><i class="fa-solid fa-edit"></i> ' . Lang::get('lang.edit') . '</a> ';
75+
$delete = '<a href="' . route('banlist.delete', $model->id) . '" class="btn btn-danger btn-xs"><i class="fa-solid fa-trash"></i> ' . Lang::get('lang.delete') . '</a>';
76+
return $edit . $delete;
77+
})
78+
->rawColumns(['email', 'updated_at', 'action'])
79+
->make(true);
80+
} catch (Exception $e) {
81+
return response()->json(['error' => $e->getMessage()], 500);
82+
}
83+
}
84+
5785
/**
5886
* Show the form for creating a banned user.
5987
*

app/Http/Controllers/Admin/helpdesk/EmailsController.php

Lines changed: 63 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use App\Http\Controllers\Admin\MailFetch as Fetch;
77
use App\Http\Controllers\Controller;
88
use App\Http\Requests\helpdesk\EmailsRequest;
9+
use Yajra\DataTables\Facades\DataTables;
910
// model
1011
use App\Http\Requests\helpdesk\Mail\MailRequest;
1112
use App\Model\helpdesk\Agent\Department;
@@ -48,18 +49,75 @@ public function __construct()
4849
*
4950
* @return type view
5051
*/
51-
public function index(Emails $email)
52+
public function index()
5253
{
5354
try {
54-
// fetch all the emails from emails table
55-
$emails = $email->get();
56-
57-
return view('themes.default1.admin.helpdesk.emails.emails.index', compact('emails'));
55+
return view('themes.default1.admin.helpdesk.emails.emails.index');
5856
} catch (Exception $e) {
5957
return redirect()->back()->with('fails', $e->getMessage());
6058
}
6159
}
6260

61+
/**
62+
* Return emails list as DataTables JSON for the index AJAX endpoint.
63+
*
64+
* @return \Illuminate\Http\JsonResponse
65+
*/
66+
public function getEmailList()
67+
{
68+
try {
69+
$default_system_email = Email::where('id', '=', '1')->first();
70+
$default_email = $default_system_email->sys_email ?? null;
71+
72+
$emails = Emails::select('id', 'email_address', 'priority', 'department', 'created_at', 'updated_at')->get();
73+
74+
return DataTables::of($emails)
75+
->addColumn('email_address', function ($model) use ($default_email) {
76+
$label = '<a href="' . route('emails.edit', $model->id) . '">' . e($model->email_address) . '</a>';
77+
if ($default_email == $model->id) {
78+
$label .= ' ( Default )';
79+
}
80+
return $label;
81+
})
82+
->addColumn('priority', function ($model) {
83+
if ($model->priority === null) {
84+
return '<a href="' . url('getticket') . '">System Default</a>';
85+
}
86+
$priority = Ticket_Priority::where('priority_id', '=', $model->priority)->first();
87+
return $priority ? ucfirst($priority->priority_desc) : '-';
88+
})
89+
->addColumn('department', function ($model) {
90+
if ($model->department === null) {
91+
return '<a href="' . url('getsystem') . '">System Default</a>';
92+
}
93+
$dept = Department::where('id', '=', $model->department)->first();
94+
return $dept ? e($dept->name) : '-';
95+
})
96+
->addColumn('created_at', function ($model) {
97+
return \UTC::usertimezone($model->created_at);
98+
})
99+
->addColumn('updated_at', function ($model) {
100+
return \UTC::usertimezone($model->updated_at);
101+
})
102+
->addColumn('action', function ($model) use ($default_email) {
103+
$edit = '<a href="' . route('emails.edit', $model->id) . '" class="btn btn-primary btn-xs"><i class="fa-solid fa-edit"></i> ' . \Lang::get('lang.edit') . '</a> ';
104+
if ($default_email == $model->id) {
105+
$delete = '<button class="btn btn-danger btn-xs" disabled><i class="fa-solid fa-trash"></i> ' . \Lang::get('lang.delete') . '</button>';
106+
} else {
107+
$form_open = \Form::open(['method' => 'DELETE', 'url' => route('emails.destroy', $model->id), 'style' => 'display:inline']);
108+
$delete = $form_open
109+
. '<button type="submit" class="btn btn-danger btn-xs" onclick="return confirm(\'Are you sure?\')"><i class="fa-solid fa-trash"></i> ' . \Lang::get('lang.delete') . '</button>'
110+
. \Form::close();
111+
}
112+
return $edit . $delete;
113+
})
114+
->rawColumns(['email_address', 'priority', 'department', 'created_at', 'updated_at', 'action'])
115+
->make(true);
116+
} catch (Exception $e) {
117+
return response()->json(['error' => $e->getMessage()], 500);
118+
}
119+
}
120+
63121
/**
64122
* Show the form for creating a new resource.
65123
*

app/Model/MailJob/QueueService.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ public function getAction()
5353
{
5454
$id = $this->attributes['id'];
5555
$status = $this->attributes['status'];
56-
$html = '<a href='.url('queue/'.$id.'/activate')." class='btn btn-primary'>".Lang::get('lang.activate').'</a>';
56+
$html = '<a href='.url('queue/'.$id.'/activate')." class='btn btn-primary btn-sm'>".Lang::get('lang.activate').'</a>';
5757
if ($status == 1) {
58-
$html = "<a href='#' class='btn btn-primary' disabled>".Lang::get('lang.activate').'</a>';
58+
$html = "<a href='#' class='btn btn-primary btn-sm' disabled>".Lang::get('lang.activate').'</a>';
5959
}
6060

6161
return $html;

0 commit comments

Comments
 (0)