Skip to content

Commit 0dc3a4d

Browse files
committed
Merge branch 'members' into dev
# Conflicts: # src/Translations/ca/admin.php # src/Translations/ca/lang.php # src/Translations/en/lang.php # src/Views/shared/nav.blade.php
2 parents 20bba89 + e60e3a2 commit 0dc3a4d

9 files changed

Lines changed: 441 additions & 22 deletions

File tree

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<?php
2+
3+
namespace PanicHD\PanicHD\Controllers;
4+
5+
use App\Http\Controllers\Controller;
6+
use App\User;
7+
use Illuminate\Http\Request;
8+
use Illuminate\Validation\Rule;
9+
use PanicHD\PanicHD\Models;
10+
11+
class MembersController extends Controller
12+
{
13+
/**
14+
* Display a listing of the resource.
15+
*
16+
* @return Response
17+
*/
18+
public function index(Request $request)
19+
{
20+
$a_members = Models\Member::withCount(['userTickets', 'agentTotalTickets'])->orderBy('name')->get();
21+
22+
return view('panichd::admin.member.index', compact('a_members'));
23+
}
24+
25+
/**
26+
* Store a newly created resource in storage.
27+
*
28+
* @param Request $request
29+
*
30+
* @return \Illuminate\Http\RedirectResponse
31+
*/
32+
public function store(Request $request)
33+
{
34+
$rules = [
35+
'name' => 'required',
36+
'email' => 'bail|required|unique:panichd_members|email',
37+
'password' => 'required|confirmed',
38+
'password_confirmation' => 'required'
39+
];
40+
41+
$this->validate($request, $rules);
42+
43+
$member = new User;
44+
$member->name = $request->name;
45+
$member->email = $request->email;
46+
$member->password = bcrypt($request->password);
47+
$member->save();
48+
49+
\Session::flash('status', trans('panichd::admin.member-added-ok', ['name' => $member->name]));
50+
51+
return redirect()->back();
52+
}
53+
54+
public function update(Request $request, $id)
55+
{
56+
$member = User::findOrFail($id);
57+
58+
$rules = [
59+
'id' => 'exists:users',
60+
'name' => 'required',
61+
'email' => [
62+
'bail',
63+
'required',
64+
Rule::unique('users')->ignore($id),
65+
'email'
66+
]
67+
];
68+
if ($request->password != ""){
69+
$rules['password'] = 'required|confirmed';
70+
$rules['password_confirmation'] = 'required';
71+
}
72+
73+
$this->validate($request, $rules);
74+
75+
$member->name = $request->name;
76+
$member->email = $request->email;
77+
if ($request->password != ""){
78+
$member->password = bcrypt($request->password);
79+
}
80+
$member->save();
81+
82+
\Session::flash('status', trans('panichd::admin.member-updated-ok', ['name' => $member->name]));
83+
84+
return redirect()->back();
85+
}
86+
87+
public function destroy(Request $request, $id)
88+
{
89+
$member = User::findOrFail($id);
90+
if (auth()->user()->id == $id){
91+
\Session::flash('warning', 'You cannot delete your own user account');
92+
return redirect()->back();
93+
}
94+
$member->delete();
95+
96+
\Session::flash('status', trans('panichd::admin.member-deleted', ['name' => $member->name]));
97+
98+
return redirect()->back();
99+
}
100+
}

src/Translations/ca/admin.php

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@
55
/*
66
* Constants
77
*/
8-
'nav-settings' => 'Paràmetres',
8+
'nav-administrators' => 'Administradors',
99
'nav-agents' => 'Agents',
10+
'nav-categories' => 'Categories',
11+
'nav-configuration' => 'Configuració',
1012
'nav-dashboard' => 'Panell admin.',
1113
'nav-dashboard-title' => 'Panell d\'administrador',
12-
'nav-categories' => 'Categories',
14+
'nav-members' => 'Membres',
15+
'nav-notices' => 'Avisos',
1316
'nav-priorities' => 'Prioritats',
17+
'nav-settings' => 'Paràmetres',
1418
'nav-statuses' => 'Estats',
15-
'nav-notices' => 'Avisos',
16-
'nav-configuration' => 'Configuració',
17-
'nav-administrator' => 'Administrador',
1819

1920
'table-hash' => '#',
2021
'table-id' => 'Id',
@@ -23,6 +24,7 @@
2324
'table-action' => 'Acció',
2425
'table-categories' => 'Categories',
2526
'table-categories-autoasg-title'=> 'Assignació automàtica de nous tiquets',
27+
'table-email' => 'E-mail',
2628
'table-magnitude' => 'Magnitud',
2729
'table-num-tickets' => 'Núm. tiquets',
2830
'table-remove-agent' => 'Excloure d\'agents',
@@ -34,6 +36,7 @@
3436
'table-lang' => 'Idioma',
3537
'table-edit' => 'Editar',
3638

39+
'btn-add-new' => 'Afegir nou',
3740
'btn-back' => 'Endarrere',
3841
'btn-change' => 'Canviar',
3942
'btn-create' => 'Crear',
@@ -45,7 +48,10 @@
4548
'btn-save' => 'Desar',
4649
'btn-update' => 'Actualitzar',
4750

51+
// Vocabulary
52+
'admin' => 'Admin',
4853
'colon' => ': ',
54+
'role' => 'Rol',
4955

5056
/* Access Levels */
5157
'level-1' => 'Tothom',
@@ -166,6 +172,20 @@
166172
'category-reason-no-status' => 'La raó de tancament :number amb el nom ":name" requereix un estat definit',
167173
'category-tag-not-valid-format' => 'L\'etiqueta ":tag" no té un format vàlid',
168174

175+
// $admin_route_path/member/____
176+
'member-index-title' => 'Gestió d\'usuaris Membres',
177+
'member-index-help' => 'Els membres son tots els usuaris registrats a la base de dades. L\'administrador d\'aquest lloc web pot haver filtrat la llista',
178+
'member-index-empty' => 'No s\'ha trobat usuaris registrats. Si us plau, revisa si hi ha algun error a la vista de la base de dades "panichd_members"',
179+
'member-modal-update-title' => 'Actualitzar usuari membre',
180+
'member-modal-create-title' => 'Crear usuari membre',
181+
'member-delete-confirmation' => 'Estàs segur que vols eliminar l\'usuari de la base de dades?',
182+
'member-password-label' => 'Contrasenya',
183+
'member-new-password-label' => 'Contrasenya nova (opcional)',
184+
'member-password-repeat-label' => 'Repetir contrasenya',
185+
'member-added-ok' => 'L\'usuari membre ":name" s\'ha creat correctament',
186+
'member-updated-ok' => 'L\'usuari membre ":name" s\'ha actualitzat correctament',
187+
'member-deleted' => 'L\'usuari membre ":name" s\'ha ELIMINAT',
188+
169189
// $admin_route_path/priority/____
170190
'priority-index-title' => 'Gestió de prioritats',
171191
'priority-index-help' => 'Pots canviar l\'ordre de les prioritats arrosegant les files d\'aquesta taula. Aquest ordre s\'utilitzarà també a la llista de tiquets quan es seleccioni',

src/Translations/ca/lang.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,14 @@
140140
'dept-descendant' => 'Departament',
141141
'description' => 'Descripció',
142142
'discard' => 'Descartar',
143+
'email' => 'E-mail',
143144
'email-resend-abbr' => 'RV',
144145
'flash-x' => '×', // &times;
145146
'intervention' => 'Actuació',
146147
'last-update' => 'Última actualització',
147148
'limit-date' => 'Data límit',
148149
'list' => 'Llista',
150+
'name' => 'Nom',
149151
'newest-tickets-adjective' => 'Nous',
150152
'no' => 'No',
151153
'no-replies' => 'Sense respostes.',
@@ -159,6 +161,7 @@
159161
'subject' => 'Tema',
160162
'tags' => 'Etiquetes',
161163
'ticket' => 'Tiquet',
164+
'tickets' => 'Tiquets',
162165
'today' => 'Avui',
163166
'tomorrow' => 'Demà',
164167
'update' => 'Actualitzar',

src/Translations/en/admin.php

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@
55
/*
66
* Constants
77
*/
8-
'nav-settings' => 'Settings',
8+
'nav-administrators' => 'Administrators',
99
'nav-agents' => 'Agents',
10+
'nav-categories' => 'Categories',
11+
'nav-configuration' => 'Configuration',
1012
'nav-dashboard' => 'Dashboard',
1113
'nav-dashboard-title' => 'Administrator dashboard',
12-
'nav-categories' => 'Categories',
14+
'nav-members' => 'Members',
15+
'nav-notices' => 'Notices',
1316
'nav-priorities' => 'Priorities',
17+
'nav-settings' => 'Settings',
1418
'nav-statuses' => 'Statuses',
15-
'nav-notices' => 'Notices',
16-
'nav-configuration' => 'Configuration',
17-
'nav-administrator' => 'Administrator', //new
1819

1920
'table-hash' => '#',
2021
'table-id' => 'ID',
@@ -23,6 +24,7 @@
2324
'table-action' => 'Action',
2425
'table-categories' => 'Categories',
2526
'table-categories-autoasg-title'=> 'New tickets automatic assignment',
27+
'table-email' => 'E-mail',
2628
'table-magnitude' => 'Magnitude',
2729
'table-num-tickets' => 'Tickets count',
2830
'table-remove-agent' => 'Remove from agents',
@@ -34,6 +36,7 @@
3436
'table-lang' => 'Lang',
3537
'table-edit' => 'Edit',
3638

39+
'btn-add-new' => 'Add new one',
3740
'btn-back' => 'Back',
3841
'btn-change' => 'Change',
3942
'btn-create' => 'Create',
@@ -44,8 +47,11 @@
4447
'btn-submit' => 'Submit',
4548
'btn-save' => 'Save',
4649
'btn-update' => 'Update',
47-
50+
51+
// Vocabulary
52+
'admin' => 'Admin',
4853
'colon' => ': ',
54+
'role' => 'Role',
4955

5056
/* Access Levels */
5157
'level-1' => 'Everyone',
@@ -74,8 +80,8 @@
7480
'index-category' => 'Category',
7581
'index-agents' => 'Agents',
7682
'index-agent' => 'Agent',
77-
'index-administrators' => 'Administrators', //new
78-
'index-administrator' => 'Administrator', //new
83+
'index-administrators' => 'Administrators',
84+
'index-administrator' => 'Administrator',
7985
'index-users' => 'Users',
8086
'index-user' => 'User',
8187
'index-tickets' => 'Tickets',
@@ -91,7 +97,7 @@
9197
'index-view-user-tickets' => 'View user own :list tickets',
9298

9399
// $admin_route_path/agent/____
94-
'agent-index-title' => 'Agent Management',
100+
'agent-index-title' => 'Agents Management',
95101
'agent-index-no-agents' => 'There are no agents',
96102
'agent-index-create-new' => 'Add agent',
97103
'agent-create-form-agent' => 'User',
@@ -111,14 +117,14 @@
111117

112118

113119
// $admin_route_path/administrators/____
114-
'administrator-index-title' => 'Administrator Management', //new
115-
'btn-create-new-administrator' => 'Create new administrator', //new
116-
'administrator-index-no-administrators' => 'There are no administrators, ', //new
117-
'administrator-index-create-new' => 'Add administrators', //new
118-
'administrator-create-title' => 'Add Administrator', //new
119-
'administrator-create-add-administrators' => 'Add Administrators', //new
120-
'administrator-create-no-users' => 'There are no user accounts, create user accounts first.', //new
121-
'administrator-create-select-user' => 'Select user accounts to be added as administrators', //new
120+
'administrator-index-title' => 'Administrators Management',
121+
'btn-create-new-administrator' => 'Create new administrator',
122+
'administrator-index-no-administrators' => 'There are no administrators, ',
123+
'administrator-index-create-new' => 'Add administrators',
124+
'administrator-create-title' => 'Add Administrator',
125+
'administrator-create-add-administrators' => 'Add Administrators',
126+
'administrator-create-no-users' => 'There are no user accounts, create user accounts first.',
127+
'administrator-create-select-user' => 'Select user accounts to be added as administrators',
122128

123129
// $admin_route_path/category/____
124130
'category-index-title' => 'Categories Management',
@@ -167,6 +173,20 @@
167173
'category-reason-no-status' => 'Closing reason :number with name ":name" requires a defined status',
168174
'category-tag-not-valid-format' => 'Tag ":tag" format is not valid',
169175

176+
// $admin_route_path/member/____
177+
'member-index-title' => 'Member users management',
178+
'member-index-help' => 'Members are all registered users in database. This website administrator may have filtered the list',
179+
'member-index-empty' => 'No registered members were found. Please, check if there is any error in database "panichd_members" view',
180+
'member-modal-update-title' => 'Update member user',
181+
'member-modal-create-title' => 'Create member user',
182+
'member-delete-confirmation' => 'Are you sure you want to delete this user from database?',
183+
'member-password-label' => 'Password',
184+
'member-new-password-label' => 'New password (optional)',
185+
'member-password-repeat-label' => 'Repeat password',
186+
'member-added-ok' => 'Member user ":name" has been created correctly',
187+
'member-updated-ok' => 'Member user ":name" has been updated correctly',
188+
'member-deleted' => 'Member user ":name" has been DELETED',
189+
170190
// $admin_route_path/priority/____
171191
'priority-index-title' => 'Priorities Management',
172192
'priority-index-help' => 'You may change priority order dragging this table rows. This order will be used also in ticket list when checking this field',

src/Translations/en/lang.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,14 @@
141141
'dept-descendant' => 'Subdepartment',
142142
'description' => 'Description',
143143
'discard' => 'Discard',
144+
'email' => 'E-mail',
144145
'email-resend-abbr' => 'FW',
145146
'flash-x' => '×', // &times;
146147
'intervention' => 'Intervention',
147148
'last-update' => 'Last Update',
148149
'limit-date' => 'Limit date',
149150
'list' => 'List',
151+
'name' => 'Name',
150152
'newest-tickets-adjective' => 'New',
151153
'no' => 'No',
152154
'no-replies' => 'No replies.',
@@ -160,6 +162,7 @@
160162
'subject' => 'Subject',
161163
'tags' => 'Tags',
162164
'ticket' => 'Ticket',
165+
'tickets' => 'Tickets',
163166
'today' => 'Today',
164167
'tomorrow' => 'Tomorrow',
165168
'update' => 'Update',

0 commit comments

Comments
 (0)