Commit e2907a5767314335bf4860c2cf3a968b37831e8c

Authored by Hayk Nazaryan
1 parent e262a331f3
Exists in master

workers fixes

Showing 5 changed files with 166 additions and 16 deletions Inline Diff

app/Console/Commands/ResetData.php
File was created 1 <?php
2
3 namespace App\Console\Commands;
4
5 use App\Models\Ad_employer;
6 use App\Models\Ad_jobs;
7 use App\Models\ad_response;
8 use App\Models\Answer;
9 use App\Models\Chat;
10 use App\Models\Contacts;
11 use App\Models\Dop_info;
12 use App\Models\Employer;
13 use App\Models\EmployerAutoliftOption;
14 use App\Models\employers_main;
15 use App\Models\Flot;
16 use App\Models\Group_user;
17 use App\Models\Group_works;
18 use App\Models\Like_vacancy;
19 use App\Models\Like_worker;
20 use App\Models\Media;
21 use App\Models\Message;
22 use App\Models\MessagesRequests;
23 use App\Models\PrevCompany;
24 use App\Models\ResponseWork;
25 use App\Models\Static_ad;
26 use App\Models\Static_worker;
27 use App\Models\Title_worker;
28 use App\Models\User;
29 use App\Models\WorkerAutoliftOption;
30 use Illuminate\Console\Command;
31 use Illuminate\Support\Facades\Hash;
32
33 class ResetData extends Command
34 {
35 /**
36 * The name and signature of the console command.
37 *
38 * @var string
39 */
40 protected $signature = 'reset:data';
41
42 /**
43 * The console command description.
44 *
45 * @var string
46 */
47 protected $description = 'Command description';
48
49 /**
50 * Execute the console command.
51 *
52 * @return int
53 */
54 public function handle()
55 {
56 $users = User::query()
57 ->whereHas('workers')
58 ->where('is_bd', 0)
59 ->where('created_at', '<', '2024-11-30 00:00:00')
60 ->whereNotIn('email', [
61 'vkontakte@rekamore.su',
62 '2anketa@rekamore.su'
63 ])
64 ->get();
65
66 foreach ($users as $user) {
67 Answer::query()->where(['user_id' => $user->id])->delete();
68
69 Chat::query()->where(['user_id' => $user->id])->delete();
70 Chat::query()->where(['to_user_id' => $user->id])->delete();
71 Message::query()->where(['user_id' => $user->id])->delete();
72 Message::query()->where(['to_user_id' => $user->id])->delete();
73 MessagesRequests::query()->where(['user_id' => $user->id])->delete();
74
75 Group_user::query()->where(['user_id' => $user->id])->get()->map(function ($groupUser) {
76 Group_works::query()->where(['group_user_id' => $groupUser->id])->delete();
77 $groupUser->delete();
78 });
79
80 Like_vacancy::query()->where(['user_id' => (string)$user->id])->delete();
81 Like_worker::query()->where(['user_id' => (string)$user->id])->delete();
82 Media::query()->where(['user_id' => $user->id])->delete();
83 Static_worker::query()->where(['user_id' => $user->id])->delete();
84
85 // $user->employers()->get()->map(function ($employer) {
86 // Answer::query()->where(['employer_id' => $employer->id])->delete();
87 //
88 // Ad_employer::query()->where(['employer_id' => $employer->id])->get()->map(function ($adEmployer) {
89 // Ad_jobs::query()->where(['ad_employer_id' => $adEmployer->id])->delete();
90 // ad_response::query()->where(['ad_employer_id' => $adEmployer->id])->delete();
91 // Static_ad::query()->where(['ad_employer_id' => $adEmployer->id])->delete();
92 // Like_vacancy::query()->where(['code_record' => $adEmployer->id])->delete();
93 //
94 // $adEmployer->delete();
95 // });
96 //
97 // Contacts::query()->where(['employer_id' => $employer->id])->delete();
98 // employers_main::query()->where(['employer_id' => $employer->id])->delete();
99 // EmployerAutoliftOption::query()->where(['employer_id' => $employer->id])->delete();
100 //
101 // Flot::query()->where(['employer_id' => $employer->id])->delete();
102 //
103 // $employer->delete();
104 // });
105
106 $user->workers()->get()->map(function ($worker) {
107 Dop_info::query()->where(['worker_id' => $worker->id])->delete();
108 PrevCompany::query()->where(['worker_id' => $worker->id])->delete();
109 ResponseWork::query()->where(['worker_id' => $worker->id])->delete();
110 Like_worker::query()->where(['code_record' => $worker->id])->delete();
111 Title_worker::query()->where(['worker_id' => $worker->id])->delete();
112 WorkerAutoliftOption::query()->where(['worker_id' => $worker->id])->delete();
113 $worker->delete();
114 });
115
116 $user->delete();
117
118 }
119
120 User::query()->where('password', 1234567890)->get()->map(function ($userBd) {
121 $password = $userBd->password;
122
123 $userBd->update([
124 'password' => Hash::make($password),
125 'pubpassword' => base64_encode($password),
126 ]);
127 });
128
129 return Command::SUCCESS;
130 }
131 }
132
app/Http/Controllers/Admin/UsersController.php
1 <?php 1 <?php
2 2
3 namespace App\Http\Controllers\Admin; 3 namespace App\Http\Controllers\Admin;
4 4
5 use App\Http\Controllers\Controller; 5 use App\Http\Controllers\Controller;
6 use App\Http\Requests\BaseUserRequest; 6 use App\Http\Requests\BaseUserRequest;
7 use App\Models\ContentRoles; 7 use App\Models\ContentRoles;
8 use App\Models\Job_title; 8 use App\Models\Job_title;
9 use App\Models\User; 9 use App\Models\User;
10 use App\Models\Worker; 10 use App\Models\Worker;
11 use Illuminate\Http\Request; 11 use Illuminate\Http\Request;
12 use Illuminate\Support\Facades\Auth; 12 use Illuminate\Support\Facades\Auth;
13 use Illuminate\Support\Facades\Hash;
13 use Illuminate\Support\Facades\Storage; 14 use Illuminate\Support\Facades\Storage;
14 use PhpOffice\PhpSpreadsheet\Spreadsheet; 15 use PhpOffice\PhpSpreadsheet\Spreadsheet;
15 use PhpOffice\PhpSpreadsheet\Style\Alignment; 16 use PhpOffice\PhpSpreadsheet\Style\Alignment;
16 use PhpOffice\PhpSpreadsheet\Style\Border; 17 use PhpOffice\PhpSpreadsheet\Style\Border;
17 use PhpOffice\PhpSpreadsheet\Style\Font; 18 use PhpOffice\PhpSpreadsheet\Style\Font;
18 use PhpOffice\PhpSpreadsheet\Writer\Xlsx; 19 use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
19 20
20 class UsersController extends Controller 21 class UsersController extends Controller
21 { 22 {
22 public function index(Request $request) { 23 public function index(Request $request) {
23 $title = 'Админка - Пользователи системы'; 24 $title = 'Админка - Пользователи системы';
24 $id_admin = Auth::user()->id; 25 $id_admin = Auth::user()->id;
25 if ($request->ajax()) { 26 if ($request->ajax()) {
26 $user = User::find($request->id); 27 $user = User::find($request->id);
27 $request->offsetUnset('id'); 28 $request->offsetUnset('id');
28 $user->update($request->all()); 29 $user->update($request->all());
29 } 30 }
30 31
31 $find_key = ""; 32 $find_key = "";
32 $users = User::query(); 33 $users = User::query();
33 if (isset($request->find)) { 34 if (isset($request->find)) {
34 $find_key = $request->find; 35 $find_key = $request->find;
35 $users = $users->where('name', 'LIKE', "%$find_key%") 36 $users = $users->where('name', 'LIKE', "%$find_key%")
36 ->orWhere('email', 'LIKE', "%$find_key%"); 37 ->orWhere('email', 'LIKE', "%$find_key%");
37 } 38 }
38 39
39 $users = $users->paginate(15); 40 $users = $users->paginate(15);
40 41
41 if ($request->ajax()) { 42 if ($request->ajax()) {
42 return view('admin.users.index_ajax', compact('users', 'id_admin')); 43 return view('admin.users.index_ajax', compact('users', 'id_admin'));
43 } else { 44 } else {
44 return view('admin.users.index', compact('users', 'title', 'id_admin', 'find_key')); 45 return view('admin.users.index', compact('users', 'title', 'id_admin', 'find_key'));
45 } 46 }
46 } 47 }
47 48
48 public function user_delete(User $user) { 49 public function user_delete(User $user) {
49 50
50 $worker = $user->workers()->first(); 51 $worker = $user->workers()->first();
51 $employer = $user->employers()->first(); 52 $employer = $user->employers()->first();
52 53
53 if ($worker) { 54 if ($worker) {
54 55
55 $worker->delete(); 56 $worker->delete();
56 57
57 } elseif ($employer) { 58 } elseif ($employer) {
58 59
59 $employer->delete(); 60 $employer->delete();
60 61
61 } 62 }
62 63
63 $user->delete(); 64 $user->delete();
64 65
65 return redirect()->route('admin.users')->with('Пользователь был удален из системы'); 66 return redirect()->route('admin.users')->with('Пользователь был удален из системы');
66 } 67 }
67 68
68 public function index_bd(Request $request) { 69 public function index_bd(Request $request) {
69 $title = 'Админка - Пользователи базы данных'; 70 $title = 'Админка - Пользователи базы данных';
70 71
71 $find_key = ""; 72 $find_key = "";
72 $users = User::query(); 73 $users = User::query();
73 if (isset($request->find)) { 74 if (isset($request->find)) {
74 $find_key = $request->find; 75 $find_key = $request->find;
75 $users = $users->where('name', 'LIKE', "%$find_key%") 76 $users = $users->where('name', 'LIKE', "%$find_key%")
76 ->orWhere('email', 'LIKE', "%$find_key%") 77 ->orWhere('email', 'LIKE', "%$find_key%")
77 ->orWhere('telephone', 'LIKE', "%$find_key%"); 78 ->orWhere('telephone', 'LIKE', "%$find_key%");
78 } 79 }
79 80
80 $users = $users->Baseuser() 81 $users = $users->Baseuser()
81 ->orderByDesc(Worker::select('created_at')->whereColumn('workers.user_id', 'users.id')) 82 ->orderByDesc(Worker::select('created_at')->whereColumn('workers.user_id', 'users.id'))
82 ->paginate(15); 83 ->paginate(15);
83 84
84 if ($request->ajax()) { 85 if ($request->ajax()) {
85 return view('admin.users.index_bd_ajax', compact('users')); 86 return view('admin.users.index_bd_ajax', compact('users'));
86 } else { 87 } else {
87 return view('admin.users.index_bd', compact('users', 'title', 'find_key')); 88 return view('admin.users.index_bd', compact('users', 'title', 'find_key'));
88 } 89 }
89 } 90 }
90 91
91 public function add_bd() { 92 public function add_bd() {
92 $list_job_titles = Job_title::query()->active()->where('is_bd', '=' , '2')->orderBy('name', 'asc')->get(); 93 $list_job_titles = Job_title::query()->active()->where('is_bd', '=' , '2')->orderBy('name', 'asc')->get();
93 return view('admin.users.add', compact('list_job_titles')); 94 return view('admin.users.add', compact('list_job_titles'));
94 } 95 }
95 96
96 public function add_store_bd(BaseUserRequest $request) { 97 public function add_store_bd(BaseUserRequest $request) {
97 $params = $request->all(); 98 $params = $request->all();
98 99
99 if ($request->has('file')) { 100 if ($request->has('file')) {
100 $params['file'] = $request->file('file')->store('basedata', 'public'); 101 $params['file'] = $request->file('file')->store('basedata', 'public');
101 } 102 }
102 103
103 if (isset($request->name)) { 104 if (isset($request->name)) {
104 $params['name'] = $request->surname." ".$request->name_man." ".$request->surname2; 105 $params['name'] = $request->surname." ".$request->name_man." ".$request->surname2;
105 } 106 }
106 107
108 $password = $params['password'];
109 $params['password'] = Hash::make($password);
110 $params['pubpassword'] = base64_encode($password);
111
107 $user = User::create($params); 112 $user = User::create($params);
108 $worker = new Worker(); 113 $worker = new Worker();
109 $worker->positions_work = isset($params['positions_work']) ? json_encode($params['positions_work']) : []; 114 $worker->positions_work = isset($params['positions_work']) ? json_encode($params['positions_work']) : [];
110 $worker->user_id = $user->id; 115 $worker->user_id = $user->id;
111 $worker->comment = isset($params['comment']) ? $params['comment'] : null; 116 $worker->comment = isset($params['comment']) ? $params['comment'] : null;
112 $worker->save(); 117 $worker->save();
113 118
114 return redirect()->route('admin.basedata'); 119 return redirect()->route('admin.basedata');
115 } 120 }
116 121
117 public function edit_bd(User $user) { 122 public function edit_bd(User $user) {
118 $list_job_titles = Job_title::query() 123 $list_job_titles = Job_title::query()
119 ->active() 124 ->active()
120 ->where('is_bd', '=' , '2') 125 ->where('is_bd', '=' , '2')
121 ->orderByDesc('sort') 126 ->orderByDesc('sort')
122 ->orderBy('name', 'asc') 127 ->orderBy('name', 'asc')
123 ->get(); 128 ->get();
124 return view('admin.users.edit', compact('user', 'list_job_titles')); 129 return view('admin.users.edit', compact('user', 'list_job_titles'));
125 } 130 }
126 131
127 public function update_bd(BaseUserRequest $request, User $user) { 132 public function update_bd(BaseUserRequest $request, User $user) {
128 $params = $request->all(); 133 $params = $request->all();
129 $positions_work = $request->input('positions_work', []); 134 $positions_work = $request->input('positions_work', []);
130 135
131 if ($request->has('file')) { 136 if ($request->has('file')) {
132 if (!empty($user->file)) Storage::delete($user->file); 137 if (!empty($user->file)) Storage::delete($user->file);
133 $params['file'] = $request->file('file')->store('basedata', 'public'); 138 $params['file'] = $request->file('file')->store('basedata', 'public');
134 } else { 139 } else {
135 if (!empty($user->image)) $params['file'] = $user->file; 140 if (!empty($user->image)) $params['file'] = $user->file;
136 } 141 }
137 142
138 if (isset($request->name)) { 143 if (isset($request->name)) {
139 $params['name'] = $request->surname." ".$request->name_man." ".$request->surname2; 144 $params['name'] = $request->surname." ".$request->name_man." ".$request->surname2;
140 } 145 }
141 146
142 $user->update($params); 147 $user->update($params);
143 if (isset($user->workers[0]->id)) { 148 if (isset($user->workers[0]->id)) {
144 $worker = Worker::find($user->workers[0]->id); 149 $worker = Worker::find($user->workers[0]->id);
145 $worker->positions_work = $positions_work; 150 $worker->positions_work = $positions_work;
146 $worker->comment = isset($params['comment']) ? $params['comment'] : null; 151 $worker->comment = isset($params['comment']) ? $params['comment'] : null;
147 $worker->save(); 152 $worker->save();
148 } else { 153 } else {
149 $worker = new Worker(); 154 $worker = new Worker();
150 $worker->user_id = $user->id; 155 $worker->user_id = $user->id;
151 $worker->positions_work = $positions_work; 156 $worker->positions_work = $positions_work;
152 $worker->comment = isset($params['comment']) ? $params['comment'] : null; 157 $worker->comment = isset($params['comment']) ? $params['comment'] : null;
153 $worker->save(); 158 $worker->save();
154 } 159 }
155 160
156 return redirect()->route('admin.basedata'); 161 return redirect()->route('admin.basedata');
157 } 162 }
158 163
159 public function destroy_bd(User $user) { 164 public function destroy_bd(User $user) {
160 $user->delete(); 165 $user->delete();
161 return redirect()->route('admin.basedata'); 166 return redirect()->route('admin.basedata');
162 } 167 }
163 168
164 public function roles(Request $request) { 169 public function roles(Request $request) {
165 if ($request->ajax()) { 170 if ($request->ajax()) {
166 $user = User::find($request->id); 171 $user = User::find($request->id);
167 $request->offsetUnset('id'); 172 $request->offsetUnset('id');
168 $user->update($request->all()); 173 $user->update($request->all());
169 } 174 }
170 175
171 $users = User::query()->Realuser()->paginate(15); 176 $users = User::query()->Realuser()->paginate(15);
172 177
173 if ($request->ajax()) { 178 if ($request->ajax()) {
174 return view('admin.users.roles.index_ajax', compact('users')); 179 return view('admin.users.roles.index_ajax', compact('users'));
175 } else { 180 } else {
176 return view('admin.users.roles.index', compact('users')); 181 return view('admin.users.roles.index', compact('users'));
177 } 182 }
178 } 183 }
179 184
180 public function admin_roles(Request $request) { 185 public function admin_roles(Request $request) {
181 186
182 if ($request->ajax()) { 187 if ($request->ajax()) {
183 $id = $request->id; 188 $id = $request->id;
184 $request->offsetUnset('id'); 189 $request->offsetUnset('id');
185 ContentRoles::where('id', '=', $id)->update($request->all()); 190 ContentRoles::where('id', '=', $id)->update($request->all());
186 } 191 }
187 $roles = ContentRoles::query()->OrderBy('id')->paginate(25); 192 $roles = ContentRoles::query()->OrderBy('id')->paginate(25);
188 193
189 194
190 if ($request->ajax()) { 195 if ($request->ajax()) {
191 return view('admin.content.roles_index_ajax', compact('roles')); 196 return view('admin.content.roles_index_ajax', compact('roles'));
192 } else { 197 } else {
193 return view('admin.content.roles_index', compact('roles')); 198 return view('admin.content.roles_index', compact('roles'));
194 } 199 }
195 } 200 }
196 201
197 public function doc_bd(User $user) { 202 public function doc_bd(User $user) {
198 $id = $user->id; 203 $id = $user->id;
199 $spreadsheet = new Spreadsheet(); 204 $spreadsheet = new Spreadsheet();
200 $activeWorksheet = $spreadsheet->getActiveSheet(); 205 $activeWorksheet = $spreadsheet->getActiveSheet();
201 $activeWorksheet->setCellValue('A1', 'Отчет по соискателю'); 206 $activeWorksheet->setCellValue('A1', 'Отчет по соискателю');
202 $activeWorksheet->getStyle('A1')->applyFromArray([ 207 $activeWorksheet->getStyle('A1')->applyFromArray([
203 'font' => [ 208 'font' => [
204 'name' => 'Arial', 209 'name' => 'Arial',
205 'bold' => true, 210 'bold' => true,
206 'italic' => false, 211 'italic' => false,
207 'underline' => Font::UNDERLINE_DOUBLE, 212 'underline' => Font::UNDERLINE_DOUBLE,
208 'strikethrough' => false, 213 'strikethrough' => false,
209 'color' => [ 214 'color' => [
210 'rgb' => '808080' 215 'rgb' => '808080'
211 ] 216 ]
212 ], 217 ],
213 'borders' => [ 218 'borders' => [
214 'allBorders' => [ 219 'allBorders' => [
215 'borderStyle' => Border::BORDER_THIN, 220 'borderStyle' => Border::BORDER_THIN,
216 'color' => [ 221 'color' => [
217 'rgb' => '808080' 222 'rgb' => '808080'
218 ] 223 ]
219 ], 224 ],
220 'outline' => array( 225 'outline' => array(
221 'style' => Border::BORDER_THIN, 226 'style' => Border::BORDER_THIN,
222 'color' => array('rgb' => '000000') 227 'color' => array('rgb' => '000000')
223 ), 228 ),
224 ], 229 ],
225 230
226 'alignment' => [ 231 'alignment' => [
227 'horizontal' => Alignment::HORIZONTAL_CENTER, 232 'horizontal' => Alignment::HORIZONTAL_CENTER,
228 'vertical' => Alignment::VERTICAL_CENTER, 233 'vertical' => Alignment::VERTICAL_CENTER,
229 'wrapText' => true, 234 'wrapText' => true,
230 ] 235 ]
231 ]); 236 ]);
232 237
233 $activeWorksheet->setCellValue('A2', "Псевдоним/имя: ".$user->name); 238 $activeWorksheet->setCellValue('A2', "Псевдоним/имя: ".$user->name);
234 $activeWorksheet->setCellValue('A3', "Фамилия: ".$user->surname); 239 $activeWorksheet->setCellValue('A3', "Фамилия: ".$user->surname);
235 $activeWorksheet->setCellValue('A4', "Имя: ".$user->name_man); 240 $activeWorksheet->setCellValue('A4', "Имя: ".$user->name_man);
236 $activeWorksheet->setCellValue('A5', "Отчество: ".$user->surname2); 241 $activeWorksheet->setCellValue('A5', "Отчество: ".$user->surname2);
237 $activeWorksheet->setCellValue('A6', "Телефон: ".$user->telephone); 242 $activeWorksheet->setCellValue('A6', "Телефон: ".$user->telephone);
238 $activeWorksheet->setCellValue('A7', "Емайл: ".$user->email); 243 $activeWorksheet->setCellValue('A7', "Емайл: ".$user->email);
239 244
240 if (isset($user->workers[0]->id)) { 245 if (isset($user->workers[0]->id)) {
241 $activeWorksheet->setCellValue('A9', "Анкета: "); 246 $activeWorksheet->setCellValue('A9', "Анкета: ");
242 $activeWorksheet->setCellValue('A10', "Телефон: " . $user->workers[0]->telephone); 247 $activeWorksheet->setCellValue('A10', "Телефон: " . $user->workers[0]->telephone);
243 $activeWorksheet->setCellValue('A11', "Емайл: " . $user->workers[0]->email); 248 $activeWorksheet->setCellValue('A11', "Емайл: " . $user->workers[0]->email);
244 } 249 }
245 250
246 if (isset($user->jobtitles[0]->id)) { 251 if (isset($user->jobtitles[0]->id)) {
247 $activeWorksheet->setCellValue('A12', "Должность: " . $user->jobtitles[0]->name); 252 $activeWorksheet->setCellValue('A12', "Должность: " . $user->jobtitles[0]->name);
248 } 253 }
249 $activeWorksheet->getColumnDimension("A")->setWidth(100); 254 $activeWorksheet->getColumnDimension("A")->setWidth(100);
250 $writer = new Xlsx($spreadsheet); 255 $writer = new Xlsx($spreadsheet);
251 256
252 header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); 257 header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
253 header('Content-Disposition: attachment; filename="user'.$id.'.xlsx"'); 258 header('Content-Disposition: attachment; filename="user'.$id.'.xlsx"');
254 header('Cache-Control: no-cache'); 259 header('Cache-Control: no-cache');
255 260
256 $writer->save('php://output'); 261 $writer->save('php://output');
257 $writer->save(storage_path("app/public/export/user$id.xlsx")); 262 $writer->save(storage_path("app/public/export/user$id.xlsx"));
258 263
259 //$spreadsheet->disconnectWorksheets(); 264 //$spreadsheet->disconnectWorksheets();
260 return redirect()->route('admin.basedata'); 265 return redirect()->route('admin.basedata');
261 266
262 } 267 }
263 } 268 }
264 269
app/Http/Controllers/Admin/WorkersController.php
1 <?php 1 <?php
2 2
3 namespace App\Http\Controllers\Admin; 3 namespace App\Http\Controllers\Admin;
4 4
5 use App\Http\Controllers\Controller; 5 use App\Http\Controllers\Controller;
6 use App\Http\Requests\WorkerRequest; 6 use App\Http\Requests\WorkerRequest;
7 use App\Models\Company; 7 use App\Models\Company;
8 use App\Models\Job_title; 8 use App\Models\Job_title;
9 use App\Models\Static_worker; 9 use App\Models\Static_worker;
10 use App\Models\User; 10 use App\Models\User;
11 use App\Models\Worker; 11 use App\Models\Worker;
12 use Carbon\Carbon; 12 use Carbon\Carbon;
13 use Illuminate\Database\Eloquent\Builder; 13 use Illuminate\Database\Eloquent\Builder;
14 use Illuminate\Http\Request; 14 use Illuminate\Http\Request;
15 use Illuminate\Support\Facades\Storage; 15 use Illuminate\Support\Facades\Storage;
16 use Illuminate\Support\Facades\Validator; 16 use Illuminate\Support\Facades\Validator;
17 use App\Enums\WorkerStatuses; 17 use App\Enums\WorkerStatuses;
18 18
19 class WorkersController extends Controller 19 class WorkersController extends Controller
20 { 20 {
21 public function index(Request $request) { 21 public function index(Request $request) {
22 if ($request->ajax()) { 22 if ($request->ajax()) {
23 $user = User::find($request->id); 23 $user = User::find($request->id);
24 $request->offsetUnset('id'); 24 $request->offsetUnset('id');
25 $user->update($request->all()); 25 $user->update($request->all());
26 } 26 }
27 27
28 $status_work = Job_title::query()->active()->orderBy('name')->get(); 28 $status_work = Job_title::query()->active()->orderBy('name')->get();
29 $users = User::with(['jobtitles', 'workers'])->realuser(); 29 $users = User::with(['jobtitles', 'workers'])->realuser();
30 $all_worker = $users->count(); 30 $all_worker = $users->count();
31 31
32 $find_status_work = ""; 32 $find_status_work = "";
33 if (isset($request->status_work)) { 33 if (isset($request->status_work)) {
34 $find_status_work = $request->status_work; 34 $find_status_work = $request->status_work;
35 35
36 if ($request->status_work > 0) { 36 if ($request->status_work > 0) {
37 $users = $users->with('workers')-> 37 $users = $users->
38 whereHas('workers', 38 whereHas('workers',
39 function (Builder $query) use ($find_status_work) { 39 function (Builder $query) use ($find_status_work) {
40 $query->where('position_work', $find_status_work); 40 $query->where('position_work', $find_status_work);
41 } 41 }
42 ); 42 );
43 } else { 43 } else {
44 $users = $users->with('workers'); 44 $users = $users->whereHas('workers');
45 } 45 }
46 46
47 } else { 47 } else {
48 $users = $users->with('workers'); 48 $users = $users->whereHas('workers');
49 } 49 }
50 50
51 $find_key = ""; 51 $find_key = "";
52 if (isset($request->find)) { 52 if (isset($request->find)) {
53 $find_key = $request->find; 53 $find_key = $request->find;
54 $users = $users->where(function($query) use($find_key) { 54 $users = $users->where(function($query) use($find_key) {
55 $query->Where('name_man', 'LIKE', "%$find_key%") 55 $query->where('name_man', 'LIKE', "%$find_key%")
56 ->orWhere('email', 'LIKE', "%$find_key%") 56 ->orWhere('email', 'LIKE', "%$find_key%")
57 ->orWhere('telephone', 'LIKE', "%$find_key%") 57 ->orWhere('telephone', 'LIKE', "%$find_key%")
58 ->orWhere('surname', 'LIKE', "%$find_key%") 58 ->orWhere('surname', 'LIKE', "%$find_key%")
59 ->orWhere('surname2', 'LIKE', "%$find_key%"); 59 ->orWhere('surname2', 'LIKE', "%$find_key%");
60 }); 60 });
61 } 61 }
62 62
63 $users = $users->orderByDesc('id')->Realuser()->paginate(15); 63 $all_worker = $users->count();
64
65 $users = $users->orderByDesc('id')->paginate(15);
64 66
65 $status_wor = WorkerStatuses::getWorkerStatuses(); 67 $status_wor = WorkerStatuses::getWorkerStatuses();
66 68
67 if ($request->ajax()) { 69 if ($request->ajax()) {
68 return view('admin.worker.index_ajax', compact('users', 'status_wor')); 70 return view('admin.worker.index_ajax', compact('users', 'status_wor'));
69 } else { 71 } else {
70 return view('admin.worker.index', compact('users', 72 return view('admin.worker.index', compact('users',
71 'find_key', 73 'find_key',
72 'find_status_work', 74 'find_status_work',
73 'status_work', 75 'status_work',
74 'status_wor', 76 'status_wor',
75 'all_worker')); 77 'all_worker'));
76 } 78 }
77 } 79 }
78 80
79 public function form_add_worker(User $user) { 81 public function form_add_worker(User $user) {
80 $job_titles = Job_title::query()->active()->orderBy('name')->get(); 82 $job_titles = Job_title::query()->active()->orderBy('name')->get();
81 83
82 $time_end_anketa = 'Создана только'; 84 $time_end_anketa = 'Создана только';
83 $long_days = Company::find(1)->time_resume; 85 $long_days = Company::find(1)->time_resume;
84 $time_end_anketa = date("d.m.Y H:i:s", strtotime(Carbon::now() . "+$long_days days")); 86 $time_end_anketa = date("d.m.Y H:i:s", strtotime(Carbon::now() . "+$long_days days"));
85 87
86 return view('admin.worker.add', compact('user', 'job_titles', 'time_end_anketa')); 88 return view('admin.worker.add', compact('user', 'job_titles', 'time_end_anketa'));
87 } 89 }
88 90
89 public function form_store_worker(WorkerRequest $request, User $user) { 91 public function form_store_worker(WorkerRequest $request, User $user) {
90 $params = $request->all(); 92 $params = $request->all();
91 $worker = Worker::create($params); 93 $worker = Worker::create($params);
92 return redirect()->route('admin.basedata'); 94 return redirect()->route('admin.basedata');
93 } 95 }
94 96
95 public function form_edit_worker(Worker $worker) { 97 public function form_edit_worker(Worker $worker) {
96 $job_titles = Job_title::query()->active()->orderBy('name')->get(); 98 $job_titles = Job_title::query()->active()->orderBy('name')->get();
97 99
98 $time_end_anketa = 'Бессрочно'; 100 $time_end_anketa = 'Бессрочно';
99 if (!empty($worker->updated_at)) { 101 if (!empty($worker->updated_at)) {
100 $long_days = Company::find(1)->time_resume; 102 $long_days = Company::find(1)->time_resume;
101 $time_end_anketa = date("d.m.Y H:i:s", strtotime($worker->updated_at . "+$long_days days")); 103 $time_end_anketa = date("d.m.Y H:i:s", strtotime($worker->updated_at . "+$long_days days"));
102 } 104 }
103 return view('admin.worker.edit', compact('worker', 'job_titles', 'time_end_anketa')); 105 return view('admin.worker.edit', compact('worker', 'job_titles', 'time_end_anketa'));
104 } 106 }
105 107
106 public function form_update_worker(Request $request, Worker $worker) 108 public function form_update_worker(Request $request, Worker $worker)
107 { 109 {
108 $params = $request->all(); 110 $params = $request->all();
109 111
110 $rules = [ 112 $rules = [
111 'email' => 'email|string|max:255', 113 'email' => 'email|string|max:255',
112 //'photo' => 'mimes:jpeg,jpg,png|max:15000', 114 //'photo' => 'mimes:jpeg,jpg,png|max:15000',
113 ]; 115 ];
114 116
115 $messages = [ 117 $messages = [
116 'required' => 'Укажите обязательное поле «:attribute»', 118 'required' => 'Укажите обязательное поле «:attribute»',
117 'confirmed' => 'Пароли не совпадают', 119 'confirmed' => 'Пароли не совпадают',
118 'email' => 'Введите корректный email', 120 'email' => 'Введите корректный email',
119 'min' => [ 121 'min' => [
120 'string' => 'Поле «:attribute» должно быть не меньше :min символов', 122 'string' => 'Поле «:attribute» должно быть не меньше :min символов',
121 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт' 123 'file' => 'Файл «:attribute» должен быть не меньше :min Кбайт'
122 ], 124 ],
123 'max' => [ 125 'max' => [
124 'string' => 'Поле «:attribute» должно быть не больше :max символов', 126 'string' => 'Поле «:attribute» должно быть не больше :max символов',
125 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт' 127 'file' => 'Файл «:attribute» должен быть не больше :max Кбайт'
126 ], 128 ],
127 ]; 129 ];
128 130
129 $validator = Validator::make($params, $rules, $messages); 131 $validator = Validator::make($params, $rules, $messages);
130 132
131 if ($validator->fails()) { 133 if ($validator->fails()) {
132 return back()->withErrors($validator)->withInput(); 134 return back()->withErrors($validator)->withInput();
133 } else { 135 } else {
134 $user_id = $worker->user_id; 136 $user_id = $worker->user_id;
135 if ($request->has('photo')) { 137 if ($request->has('photo')) {
136 if (!empty($worker->photo)) { 138 if (!empty($worker->photo)) {
137 Storage::delete($worker->photo); 139 Storage::delete($worker->photo);
138 } 140 }
139 if (!empty($request->photo)) 141 if (!empty($request->photo))
140 $params['photo'] = $request->file('photo')->store("workers/$user_id", 'public'); 142 $params['photo'] = $request->file('photo')->store("workers/$user_id", 'public');
141 } 143 }
142 $worker->update($params); 144 $worker->update($params);
143 145
144 return redirect()->route('admin.workers'); 146 return redirect()->route('admin.workers');
145 } 147 }
146 } 148 }
147 149
148 // кабинет - статистика работников 150 // кабинет - статистика работников
149 public function static_workers(Request $request) { 151 public function static_workers(Request $request) {
150 $stat = Static_worker::with('users'); 152 $stat = Static_worker::with('users');
151 //->join('users', 'users.id', '=', 'static_workers.user_id'); 153 //->join('users', 'users.id', '=', 'static_workers.user_id');
152 $users = User::query()->active()->OrderBy('id')->get(); 154 $users = User::query()->active()->OrderBy('id')->get();
153 $periods = Static_worker::query()->distinct('year_month')->select('year_month')->get(); 155 $periods = Static_worker::query()->distinct('year_month')->select('year_month')->get();
154 if ($request->ajax()) { 156 if ($request->ajax()) {
155 if (isset($request->user_id)) 157 if (isset($request->user_id))
156 if (!$request->user_id == "0") 158 if (!$request->user_id == "0")
157 $stat = $stat->Where('user_id', '=', $request->user_id); 159 $stat = $stat->Where('user_id', '=', $request->user_id);
158 if (isset($request->year_month)) { 160 if (isset($request->year_month)) {
159 if (!$request->year_month == "0") 161 if (!$request->year_month == "0")
160 $stat = $stat->Where('year_month', '=', $request->year_month); 162 $stat = $stat->Where('year_month', '=', $request->year_month);
161 } 163 }
162 } 164 }
163 165
164 $stat = $stat->OrderByDesc('year_month'); 166 $stat = $stat->OrderByDesc('year_month');
165 //->OrderBy('users.name'); 167 //->OrderBy('users.name');
166 //OrderBy('users.name')-> 168 //OrderBy('users.name')->
167 /*$stat->implode() loadMissing(['users' => function (Builder $query) { 169 /*$stat->implode() loadMissing(['users' => function (Builder $query) {
168 $query->orderBy('name', 'asc'); 170 $query->orderBy('name', 'asc');
169 }]);*/ 171 }]);*/
170 172
171 $stat = $stat->paginate(15); 173 $stat = $stat->paginate(15);
172 174
173 if ($request->ajax()) 175 if ($request->ajax())
174 return view('admin.static.index_workers_ajax', compact('stat')); 176 return view('admin.static.index_workers_ajax', compact('stat'));
175 else 177 else
176 return view('admin.static.index_workers', compact('stat', 'users', 'periods')); 178 return view('admin.static.index_workers', compact('stat', 'users', 'periods'));
177 179
178 } 180 }
179 181
180 } 182 }
181 183
resources/views/admin/worker/index.blade.php
1 @extends('layout.admin', ['title' => 'Админка - Работники']) 1 @extends('layout.admin', ['title' => 'Админка - Работники'])
2 2
3 @section('script') 3 @section('script')
4 <script> 4 <script>
5 $(document).ready(function() { 5 $(document).ready(function() {
6 $(document).on('click', '.checkban', function () { 6 $(document).on('click', '.checkban', function () {
7 var this_ = $(this); 7 var this_ = $(this);
8 var value = this_.val(); 8 var value = this_.val();
9 var ajax_block = $('#ajax_block'); 9 var ajax_block = $('#ajax_block');
10 var bool = 0; 10 var bool = 0;
11 11
12 if(this.checked){ 12 if(this.checked){
13 bool = 1; 13 bool = 1;
14 } else { 14 } else {
15 bool = 0; 15 bool = 0;
16 } 16 }
17 17
18 $.ajax({ 18 $.ajax({
19 type: "GET", 19 type: "GET",
20 url: "{{ url()->full()}}", 20 url: "{{ url()->full()}}",
21 data: "id=" + value + "&is_ban=" + bool, 21 data: "id=" + value + "&is_ban=" + bool,
22 success: function (data) { 22 success: function (data) {
23 console.log('Обновление таблицы работников '); 23 console.log('Обновление таблицы работников ');
24 //data = JSON.parse(data); 24 //data = JSON.parse(data);
25 console.log(data); 25 console.log(data);
26 ajax_block.html(data); 26 ajax_block.html(data);
27 }, 27 },
28 headers: { 28 headers: {
29 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') 29 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
30 }, 30 },
31 error: function (data) { 31 error: function (data) {
32 console.log('Error: ' + data); 32 console.log('Error: ' + data);
33 } 33 }
34 }); 34 });
35 }); 35 });
36 36
37 }); 37 });
38 </script> 38 </script>
39 @endsection 39 @endsection
40 40
41 @section('search') 41 @section('search')
42 @include('admin.find_worker', ['find_status_work' => $find_status_work]) 42 @include('admin.find_worker', ['find_status_work' => $find_status_work])
43 @endsection 43 @endsection
44 44
45 @section('content') 45 @section('content')
46 <div class="grid gap-6 mb-8 md:grid-cols-2 xl:grid-cols-4"> 46 <div class="grid gap-6 mb-8 md:grid-cols-2 xl:grid-cols-4">
47 47
48 <div class="flex items-center p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800"> 48 <div class="flex items-center p-4 bg-white rounded-lg shadow-xs dark:bg-gray-800">
49 <div class="p-3 mr-4 text-orange-500 bg-orange-100 rounded-full dark:text-orange-100 dark:bg-orange-500"> 49 <div class="p-3 mr-4 text-orange-500 bg-orange-100 rounded-full dark:text-orange-100 dark:bg-orange-500">
50 <svg class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20"> 50 <svg class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20">
51 <path 51 <path
52 d="M13 6a3 3 0 11-6 0 3 3 0 016 0zM18 8a2 2 0 11-4 0 2 2 0 014 0zM14 15a4 4 0 00-8 0v3h8v-3zM6 8a2 2 0 11-4 0 2 2 0 014 0zM16 18v-3a5.972 5.972 0 00-.75-2.906A3.005 3.005 0 0119 15v3h-3zM4.75 12.094A5.973 5.973 0 004 15v3H1v-3a3 3 0 013.75-2.906z"></path> 52 d="M13 6a3 3 0 11-6 0 3 3 0 016 0zM18 8a2 2 0 11-4 0 2 2 0 014 0zM14 15a4 4 0 00-8 0v3h8v-3zM6 8a2 2 0 11-4 0 2 2 0 014 0zM16 18v-3a5.972 5.972 0 00-.75-2.906A3.005 3.005 0 0119 15v3h-3zM4.75 12.094A5.973 5.973 0 004 15v3H1v-3a3 3 0 013.75-2.906z"></path>
53 </svg> 53 </svg>
54 </div> 54 </div>
55 <div> 55 <div>
56 <p class="mb-2 text-sm font-medium text-gray-600 dark:text-gray-400"> 56 <p class="mb-2 text-sm font-medium text-gray-600 dark:text-gray-400">
57 Всего соискателей 57 Всего соискателей
58 </p> 58 </p>
59 <p class="text-lg font-semibold text-gray-700 dark:text-gray-200"> 59 <p class="text-lg font-semibold text-gray-700 dark:text-gray-200">
60 {{ $all_worker }} 60 {{ $all_worker }}
61 </p> 61 </p>
62 </div> 62 </div>
63 </div> 63 </div>
64 </div> 64 </div>
65 65
66 <div class="w-full overflow-hidden rounded-lg shadow-xs" id="ajax_block"> 66 <div class="w-full overflow-hidden rounded-lg shadow-xs" id="ajax_block">
67 <div class="w-full overflow-x-auto"> 67 <div class="w-full overflow-x-auto">
68 <table class="w-full whitespace-no-wrap"> 68 <table class="w-full whitespace-no-wrap">
69 <thead> 69 <thead>
70 <tr 70 <tr
71 class="text-xs font-semibold tracking-wide text-left text-gray-500 uppercase border-b dark:border-gray-700 bg-gray-50 dark:text-gray-400 dark:bg-gray-800" 71 class="text-xs font-semibold tracking-wide text-left text-gray-500 uppercase border-b dark:border-gray-700 bg-gray-50 dark:text-gray-400 dark:bg-gray-800"
72 > 72 >
73 <th class="px-4 py-3">№</th> 73 <th class="px-4 py-3">№</th>
74 <th class="px-4 py-3">Лого</th> 74 <th class="px-4 py-3">Лого</th>
75 <th class="px-4 py-3">ФИО/Email/Телефон</th> 75 <th class="px-4 py-3">ФИО/Email/Телефон/Пароль</th>
76 <th class="px-4 py-3">Статус</th> 76 <th class="px-4 py-3">Статус</th>
77 <th class="px-4 py-3">% анкеты</th> 77 <th class="px-4 py-3">% анкеты</th>
78 <th class="px-4 py-3">Должность</th> 78 <th class="px-4 py-3">Должность</th>
79 <th class="px-4 py-3">Дата регистрации</th> 79 <th class="px-4 py-3">Дата регистрации</th>
80 <th class="px-4 py-3">Изменить</th> 80 <th class="px-4 py-3">Изменить</th>
81 </tr> 81 </tr>
82 </thead> 82 </thead>
83 <tbody class="bg-white divide-y dark:divide-gray-700 dark:bg-gray-800"> 83 <tbody class="bg-white divide-y dark:divide-gray-700 dark:bg-gray-800">
84 @foreach($users as $user) 84 @foreach($users as $user)
85 @if (!isset($user->workers[0])) 85 @if (!isset($user->workers[0]))
86 @continue(1) 86 @continue(1)
87 @endif 87 @endif
88 <tr class="text-gray-700 dark:text-gray-400"> 88 <tr class="text-gray-700 dark:text-gray-400">
89 <td class="px-4 py-3 text-xs"> 89 <td class="px-4 py-3 text-xs">
90 {{$user->id}} 90 {{$user->id}}
91 </td> 91 </td>
92 <td class="px-4 py-3 text-xs"> 92 <td class="px-4 py-3 text-xs">
93 @if (isset($user->workers[0]->photo)) 93 @if (isset($user->workers[0]->photo))
94 <div class="flex items-center text-sm"> 94 <div class="flex items-center text-sm">
95 <div 95 <div
96 class="relative hidden w-8 h-8 mr-3 rounded-full md:block" 96 class="relative hidden w-8 h-8 mr-3 rounded-full md:block"
97 > 97 >
98 <img 98 <img
99 class="object-cover w-full h-full rounded-full" 99 class="object-cover w-full h-full rounded-full"
100 src="{{ asset(Storage::url($user->workers[0]->photo)) }}" 100 src="{{ asset(Storage::url($user->workers[0]->photo)) }}"
101 alt="" 101 alt=""
102 loading="lazy" 102 loading="lazy"
103 /> 103 />
104 <div 104 <div
105 class="absolute inset-0 rounded-full shadow-inner" 105 class="absolute inset-0 rounded-full shadow-inner"
106 aria-hidden="true" 106 aria-hidden="true"
107 ></div> 107 ></div>
108 </div> 108 </div>
109 </div> 109 </div>
110 @else 110 @else
111 - 111 -
112 @endif 112 @endif
113 </td> 113 </td>
114 114
115 <td class="px-4 py-3 text-xs"> 115 <td class="px-4 py-3 text-xs">
116 <div class="flex items-center text-sm"> 116 <div class="flex items-center text-sm">
117 <div> 117 <div>
118 <p class="font-semibold"> 118 <p class="font-semibold">
119 @if (isset($user->id)) 119 @if (isset($user->id))
120 <a style="text-decoration: underline;" href="{{ route('admin.user-profile', ['user' => $user->id]) }}}">{{ $user->surname }} {{ !empty($user->name_man) ? $user->name_man : $user->name }} {{ $user->surname2 }}</a> 120 <a style="text-decoration: underline;"
121 @else 121 href="{{ route('admin.user-profile', ['user' => $user->id]) }}}">{{ $user->surname }} {{ !empty($user->name_man) ? $user->name_man : $user->name }} {{ $user->surname2 }}</a>
122 {{ $user->surname }} {{ !empty($user->name_man) ? $user->name_man : $user->name }} {{ $user->surname2 }} 122 @else
123 @endif 123 {{ $user->surname }} {{ !empty($user->name_man) ? $user->name_man : $user->name }} {{ $user->surname2 }}
124 @endif
125 </p>
126 {{-- <p class="font-semibold">{{ empty($user->workers->email) ? $user->email : $user->workers->email }}</p>--}}
127 <p class="font-semibold">{{ $user->email }}</p>
128 <p class="text-xs text-gray-600 dark:text-gray-400">
129 {{ empty($user->workers->telephone) ? $user->telephone : $user->workers->telephone }}
130 </p>
131 <p class="text-xs text-gray-600 dark:text-gray-400">
132 @if (!empty($user->pubpassword))
133 {{ base64_decode($user->pubpassword) }}
134 @endif
124 </p> 135 </p>
125 <p class="font-semibold">{{ empty($user->workers->email) ? $user->email : $user->workers->email }}</p>
126 <p class="text-xs text-gray-600 dark:text-gray-400">
127 {{ empty($user->workers->telephone) ? $user->telephone : $user->workers->telephone }}
128 </p>
129 </div> 136 </div>
130 </div> 137 </div>
131 </td> 138 </td>
132 139
133 <td class="px-4 py-3 text-xs"> 140 <td class="px-4 py-3 text-xs">
134 @if (isset($user->workers[0]->status_work)) 141 @if (isset($user->workers[0]->status_work))
135 {{ $status_wor[$user->workers[0]->status_work] }} 142 {{ $status_wor[$user->workers[0]->status_work] }}
136 @else 143 @else
137 - 144 -
138 @endif 145 @endif
139 </td> 146 </td>
140 147
141 <td class="px-4 py-3 text-xs"> 148 <td class="px-4 py-3 text-xs">
142 <span class="px-2 py-1 font-semibold leading-tight text-orange-700 bg-orange-100 rounded-full @if(($persent = \App\Classes\Tools::getWorkerProfilePercent($user->workers[0])) > 50) dark:bg-green-700 dark:text-green-100 @else dark:text-white dark:bg-orange-600 @endif"> 149 <span class="px-2 py-1 font-semibold leading-tight text-orange-700 bg-orange-100 rounded-full @if(($persent = \App\Classes\Tools::getWorkerProfilePercent($user->workers[0])) > 50) dark:bg-green-700 dark:text-green-100 @else dark:text-white dark:bg-orange-600 @endif">
143 {{ $persent }}% 150 {{ $persent }}%
144 </span> 151 </span>
145 </td> 152 </td>
146 153
147 <td class="px-4 py-3 text-xs"> 154 <td class="px-4 py-3 text-xs">
148 @if ($user->job !== null) 155 @if ($user->job !== null)
149 {{ $user->job }} 156 {{ $user->job }}
150 @else 157 @else
151 Не задана 158 Не задана
152 @endif 159 @endif
153 </td> 160 </td>
154 <td class="px-4 py-3 text-xs"> 161 <td class="px-4 py-3 text-xs">
155 {{ date('d.m.Y h:i:s', strtotime($user->created_at)) }} 162 {{ date('d.m.Y h:i:s', strtotime($user->created_at)) }}
156 </td> 163 </td>
157 <td class="px-4 py-3 text-xs"> 164 <td class="px-4 py-3 text-xs">
158 @if (isset($user->workers[0]->id)) 165 @if (isset($user->workers[0]->id))
159 <a href="{{ route('admin.worker-profile-edit', ['worker' => $user->workers[0]->id]) }}">Изменить</a> 166 <a href="{{ route('admin.worker-profile-edit', ['worker' => $user->workers[0]->id]) }}">Изменить</a>
160 167
161 @endif 168 @endif
162 </td> 169 </td>
163 </tr> 170 </tr>
164 @endforeach 171 @endforeach
165 </tbody> 172 </tbody>
166 </table> 173 </table>
167 </div> 174 </div>
168 175
169 <div class="grid px-4 py-3 text-xs font-semibold tracking-wide text-gray-500 uppercase border-t dark:border-gray-700 bg-gray-50 sm:grid-cols-9 dark:text-gray-400 dark:bg-gray-800"> 176 <div class="grid px-4 py-3 text-xs font-semibold tracking-wide text-gray-500 uppercase border-t dark:border-gray-700 bg-gray-50 sm:grid-cols-9 dark:text-gray-400 dark:bg-gray-800">
170 <?=$users->appends($_GET)->links('admin.pagginate'); ?> 177 <?=$users->appends($_GET)->links('admin.pagginate'); ?>
resources/views/admin/worker/index_ajax.blade.php
1 1
2 <div class="w-full overflow-x-auto"> 2 <div class="w-full overflow-x-auto">
3 <table class="w-full whitespace-no-wrap"> 3 <table class="w-full whitespace-no-wrap">
4 <thead> 4 <thead>
5 <tr 5 <tr
6 class="text-xs font-semibold tracking-wide text-left text-gray-500 uppercase border-b dark:border-gray-700 bg-gray-50 dark:text-gray-400 dark:bg-gray-800" 6 class="text-xs font-semibold tracking-wide text-left text-gray-500 uppercase border-b dark:border-gray-700 bg-gray-50 dark:text-gray-400 dark:bg-gray-800"
7 > 7 >
8 <th class="px-4 py-3">№</th> 8 <th class="px-4 py-3">№</th>
9 <th class="px-4 py-3">Лого</th> 9 <th class="px-4 py-3">Лого</th>
10 <th class="px-4 py-3">ФИО/Email/Телефон</th> 10 <th class="px-4 py-3">ФИО/Email/Телефон/Пароль</th>
11 <th class="px-4 py-3">Статус</th> 11 <th class="px-4 py-3">Статус</th>
12 <th class="px-4 py-3">% анкеты</th> 12 <th class="px-4 py-3">% анкеты</th>
13 <th class="px-4 py-3">Должность</th> 13 <th class="px-4 py-3">Должность</th>
14 <th class="px-4 py-3">Дата регистрации</th> 14 <th class="px-4 py-3">Дата регистрации</th>
15 <th class="px-4 py-3">Изменить</th> 15 <th class="px-4 py-3">Изменить</th>
16 </tr> 16 </tr>
17 </thead> 17 </thead>
18 <tbody class="bg-white divide-y dark:divide-gray-700 dark:bg-gray-800"> 18 <tbody class="bg-white divide-y dark:divide-gray-700 dark:bg-gray-800">
19 @foreach($users as $user) 19 @foreach($users as $user)
20 <tr class="text-gray-700 dark:text-gray-400"> 20 <tr class="text-gray-700 dark:text-gray-400">
21 <td class="px-4 py-3"> 21 <td class="px-4 py-3">
22 {{$user->id}} 22 {{$user->id}}
23 </td> 23 </td>
24 <td class="px-4 py-3"> 24 <td class="px-4 py-3">
25 @if (isset($user->workers[0]->photo)) 25 @if (isset($user->workers[0]->photo))
26 <div class="flex items-center text-sm"> 26 <div class="flex items-center text-sm">
27 <div 27 <div
28 class="relative hidden w-8 h-8 mr-3 rounded-full md:block" 28 class="relative hidden w-8 h-8 mr-3 rounded-full md:block"
29 > 29 >
30 <img 30 <img
31 class="object-cover w-full h-full rounded-full" 31 class="object-cover w-full h-full rounded-full"
32 src="{{ asset(Storage::url($user->workers[0]->photo)) }}" 32 src="{{ asset(Storage::url($user->workers[0]->photo)) }}"
33 alt="" 33 alt=""
34 loading="lazy" 34 loading="lazy"
35 /> 35 />
36 <div 36 <div
37 class="absolute inset-0 rounded-full shadow-inner" 37 class="absolute inset-0 rounded-full shadow-inner"
38 aria-hidden="true" 38 aria-hidden="true"
39 ></div> 39 ></div>
40 </div> 40 </div>
41 </div> 41 </div>
42 @else 42 @else
43 - 43 -
44 @endif 44 @endif
45 </td> 45 </td>
46 46
47 <td class="px-4 py-3"> 47 <td class="px-4 py-3">
48 <div class="flex items-center text-sm"> 48 <div class="flex items-center text-sm">
49 <div> 49 <div>
50 <p class="font-semibold"> 50 <p class="font-semibold">
51 @if (isset($user->id)) 51 @if (isset($user->id))
52 <a style="text-decoration: underline;" href="{{ route('admin.user-profile', ['user' => $user->id]) }}}">{{ $user->surname }} {{ !empty($user->name_man) ? $user->name_man : $user->name }} {{ $user->surname2 }}</a> 52 <a style="text-decoration: underline;" href="{{ route('admin.user-profile', ['user' => $user->id]) }}}">{{ $user->surname }} {{ !empty($user->name_man) ? $user->name_man : $user->name }} {{ $user->surname2 }}</a>
53 @else 53 @else
54 {{ $user->surname }} {{ !empty($user->name_man) ? $user->name_man : $user->name }} {{ $user->surname2 }} 54 {{ $user->surname }} {{ !empty($user->name_man) ? $user->name_man : $user->name }} {{ $user->surname2 }}
55 @endif 55 @endif
56 </p> 56 </p>
57 <p class="font-semibold">{{ empty($user->workers->email) ? $user->email : $user->workers->email }}</p> 57 <p class="font-semibold">{{ empty($user->workers->email) ? $user->email : $user->workers->email }}</p>
58 <p class="text-xs text-gray-600 dark:text-gray-400"> 58 <p class="text-xs text-gray-600 dark:text-gray-400">
59 {{ empty($user->workers->telephone) ? $user->telephone : $user->workers->telephone }} 59 {{ empty($user->workers->telephone) ? $user->telephone : $user->workers->telephone }}
60 </p> 60 </p>
61 <p class="text-xs text-gray-600 dark:text-gray-400">
62 @if (!empty($user->pubpassword))
63 {{ base64_decode($user->pubpassword) }}
64 @endif
65 </p>
61 </div> 66 </div>
62 </div> 67 </div>
63 </td> 68 </td>
64 69
65 <td class="px-4 py-3"> 70 <td class="px-4 py-3">
66 @if (isset($user->workers[0]->status_work)) 71 @if (isset($user->workers[0]->status_work))
67 {{ $status_wor[$user->workers[0]->status_work] }} 72 {{ $status_wor[$user->workers[0]->status_work] }}
68 @else 73 @else
69 - 74 -
70 @endif 75 @endif
71 </td> 76 </td>
72 77
73 <td class="px-4 py-3 text-xs"> 78 <td class="px-4 py-3 text-xs">
74 @if (isset($user->workers[0]->persent_anketa)) 79 @if (isset($user->workers[0]->persent_anketa))
75 @if ($user->workers[0]->persent_anketa > 40) 80 @if ($user->workers[0]->persent_anketa > 40)
76 <span class="px-2 py-1 font-semibold leading-tight text-green-700 bg-green-100 rounded-full dark:bg-green-700 dark:text-green-100"> 81 <span class="px-2 py-1 font-semibold leading-tight text-green-700 bg-green-100 rounded-full dark:bg-green-700 dark:text-green-100">
77 {{$user->workers[0]->persent_anketa}}% 82 {{$user->workers[0]->persent_anketa}}%
78 </span> 83 </span>
79 @else 84 @else
80 <span class="px-2 py-1 font-semibold leading-tight text-orange-700 bg-orange-100 rounded-full dark:text-white dark:bg-orange-600"> 85 <span class="px-2 py-1 font-semibold leading-tight text-orange-700 bg-orange-100 rounded-full dark:text-white dark:bg-orange-600">
81 {{$user->workers[0]->persent_anketa}}% 86 {{$user->workers[0]->persent_anketa}}%
82 </span> 87 </span>
83 @endif 88 @endif
84 @else 89 @else
85 <span class="px-2 py-1 font-semibold leading-tight text-orange-700 bg-orange-100 rounded-full dark:text-white dark:bg-orange-600"> 90 <span class="px-2 py-1 font-semibold leading-tight text-orange-700 bg-orange-100 rounded-full dark:text-white dark:bg-orange-600">
86 0% 91 0%
87 </span> 92 </span>
88 @endif 93 @endif
89 </td> 94 </td>
90 <td class="px-4 py-3 text-sm"> 95 <td class="px-4 py-3 text-sm">
91 @if (isset($user->jobtitles[0]->name)) 96 @if (isset($user->jobtitles[0]->name))
92 {{ $user->jobtitles[0]->name }} 97 {{ $user->jobtitles[0]->name }}
93 @else 98 @else
94 Не задана 99 Не задана
95 @endif 100 @endif
96 </td> 101 </td>
97 <td class="px-4 py-3 text-sm"> 102 <td class="px-4 py-3 text-sm">
98 {{ date('d.m.Y h:i:s', strtotime($user->created_at)) }} 103 {{ date('d.m.Y h:i:s', strtotime($user->created_at)) }}
99 </td> 104 </td>
100 <td class="px-4 py-3 text-sm"> 105 <td class="px-4 py-3 text-sm">
101 <!--if ($user->id > 1)--> 106 <!--if ($user->id > 1)-->
102 @if (isset($user->workers[0]->id)) 107 @if (isset($user->workers[0]->id))
103 <a href="{{ route('admin.worker-profile-edit', ['worker' => $user->workers[0]->id]) }}">Изменить</a> 108 <a href="{{ route('admin.worker-profile-edit', ['worker' => $user->workers[0]->id]) }}">Изменить</a>
104 109
105 @endif 110 @endif
106 <!--endif--> 111 <!--endif-->
107 </td> 112 </td>
108 <!--<td class="px-4 py-3 text-sm"> 113 <!--<td class="px-4 py-3 text-sm">
109 @if ($user->id > 1) 114 @if ($user->id > 1)
110 <input type="checkbox" class="checkban" value="{{$user->id}}" name="ban_{{$user->id}}" {{ ($user->is_ban) ? "checked" : "" }}/> 115 <input type="checkbox" class="checkban" value="{{$user->id}}" name="ban_{{$user->id}}" {{ ($user->is_ban) ? "checked" : "" }}/>
111 @endif 116 @endif
112 </td>--> 117 </td>-->
113 </tr> 118 </tr>
114 @endforeach 119 @endforeach
115 </tbody> 120 </tbody>
116 </table> 121 </table>
117 </div> 122 </div>
118 123
119 <div class="grid px-4 py-3 text-xs font-semibold tracking-wide text-gray-500 uppercase border-t dark:border-gray-700 bg-gray-50 sm:grid-cols-9 dark:text-gray-400 dark:bg-gray-800"> 124 <div class="grid px-4 py-3 text-xs font-semibold tracking-wide text-gray-500 uppercase border-t dark:border-gray-700 bg-gray-50 sm:grid-cols-9 dark:text-gray-400 dark:bg-gray-800">
120 <?=$users->appends($_GET)->links('admin.pagginate'); ?> 125 <?=$users->appends($_GET)->links('admin.pagginate'); ?>
121 </div> 126 </div>
122 127