Commit 9143ea28566d947632f655c397371e2998b5cdee

Authored by Андрей Ларионов
1 parent ad6e7ea054

Баг с работниками без данных

Showing 1 changed file with 3 additions and 0 deletions Inline Diff

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') 42 @include('admin.find')
43 @endsection 43 @endsection
44 44
45 @section('content') 45 @section('content')
46 <div class="w-full overflow-hidden rounded-lg shadow-xs" id="ajax_block"> 46 <div class="w-full overflow-hidden rounded-lg shadow-xs" id="ajax_block">
47 <div class="w-full overflow-x-auto"> 47 <div class="w-full overflow-x-auto">
48 <table class="w-full whitespace-no-wrap"> 48 <table class="w-full whitespace-no-wrap">
49 <thead> 49 <thead>
50 <tr 50 <tr
51 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" 51 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"
52 > 52 >
53 <th class="px-4 py-3">№</th> 53 <th class="px-4 py-3">№</th>
54 <th class="px-4 py-3">Имя</th> 54 <th class="px-4 py-3">Имя</th>
55 <th class="px-4 py-3">Email/Телефон</th> 55 <th class="px-4 py-3">Email/Телефон</th>
56 <th class="px-4 py-3">% заполнения анкеты</th> 56 <th class="px-4 py-3">% заполнения анкеты</th>
57 <th class="px-4 py-3">Дата регистрации</th> 57 <th class="px-4 py-3">Дата регистрации</th>
58 <th class="px-4 py-3">Изменить</th> 58 <th class="px-4 py-3">Изменить</th>
59 <th class="px-4 py-3">Бан</th> 59 <th class="px-4 py-3">Бан</th>
60 </tr> 60 </tr>
61 </thead> 61 </thead>
62 <tbody class="bg-white divide-y dark:divide-gray-700 dark:bg-gray-800"> 62 <tbody class="bg-white divide-y dark:divide-gray-700 dark:bg-gray-800">
63 @foreach($users as $user) 63 @foreach($users as $user)
64 <tr class="text-gray-700 dark:text-gray-400"> 64 <tr class="text-gray-700 dark:text-gray-400">
65 <td class="px-4 py-3"> 65 <td class="px-4 py-3">
66 {{$user->id}} 66 {{$user->id}}
67 </td> 67 </td>
68 <td class="px-4 py-3"> 68 <td class="px-4 py-3">
69 {{ !empty($user->name_man) ? $user->name_man : $user->name }} 69 {{ !empty($user->name_man) ? $user->name_man : $user->name }}
70 </td> 70 </td>
71 <td class="px-4 py-3 text-sm"> 71 <td class="px-4 py-3 text-sm">
72 <div class="flex items-center text-sm"> 72 <div class="flex items-center text-sm">
73 <div> 73 <div>
74 <p class="font-semibold">{{ empty($user->workers->email) ? $user->email : $user->workers->email }}</p> 74 <p class="font-semibold">{{ empty($user->workers->email) ? $user->email : $user->workers->email }}</p>
75 <p class="text-xs text-gray-600 dark:text-gray-400"> 75 <p class="text-xs text-gray-600 dark:text-gray-400">
76 {{ empty($user->workers->telephone) ? $user->telephone : $user->workers->telephone }} 76 {{ empty($user->workers->telephone) ? $user->telephone : $user->workers->telephone }}
77 </p> 77 </p>
78 </div> 78 </div>
79 </div> 79 </div>
80 </td> 80 </td>
81 <td class="px-4 py-3 text-xs"> 81 <td class="px-4 py-3 text-xs">
82 @if (!empty($user->workers->persent_anketa)) 82 @if (!empty($user->workers->persent_anketa))
83 @if ($user->workers->persent_anketa > 40) 83 @if ($user->workers->persent_anketa > 40)
84 <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"> 84 <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">
85 {{$user->workers->persent_anketa}}% 85 {{$user->workers->persent_anketa}}%
86 </span> 86 </span>
87 @else 87 @else
88 <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"> 88 <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">
89 {{$user->workers->persent_anketa}}% 89 {{$user->workers->persent_anketa}}%
90 </span> 90 </span>
91 @endif 91 @endif
92 @else 92 @else
93 <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"> 93 <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">
94 10% 94 10%
95 </span> 95 </span>
96 @endif 96 @endif
97 </td> 97 </td>
98 <td class="px-4 py-3 text-sm"> 98 <td class="px-4 py-3 text-sm">
99 {{ $user->created_at }} 99 {{ $user->created_at }}
100 </td> 100 </td>
101 <td class="px-4 py-3 text-sm"> 101 <td class="px-4 py-3 text-sm">
102 @if ($user->id > 1) 102 @if ($user->id > 1)
103 @if (isset($user->workers[0]->id))
103 <a href="{{ route('admin.worker-profile-edit', ['worker' => $user->workers[0]->id]) }}">Изменить</a> 104 <a href="{{ route('admin.worker-profile-edit', ['worker' => $user->workers[0]->id]) }}">Изменить</a>
105
106 @endif
104 @endif 107 @endif
105 </td> 108 </td>
106 <td class="px-4 py-3 text-sm"> 109 <td class="px-4 py-3 text-sm">
107 @if ($user->id > 1) 110 @if ($user->id > 1)
108 <input type="checkbox" class="checkban" value="{{$user->id}}" name="ban_{{$user->id}}" {{ ($user->is_ban) ? "checked" : "" }}/> 111 <input type="checkbox" class="checkban" value="{{$user->id}}" name="ban_{{$user->id}}" {{ ($user->is_ban) ? "checked" : "" }}/>
109 @endif 112 @endif
110 </td> 113 </td>
111 </tr> 114 </tr>
112 @endforeach 115 @endforeach
113 </tbody> 116 </tbody>
114 </table> 117 </table>
115 </div> 118 </div>
116 119
117 <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 <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">
118 <?=$users->appends($_GET)->links('admin.pagginate'); ?> 121 <?=$users->appends($_GET)->links('admin.pagginate'); ?>
119 </div> 122 </div>
120 123
121 124
122 <!--<div 125 <!--<div
123 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" 126 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 > 127 >
125 <span class="flex items-center col-span-3"> 128 <span class="flex items-center col-span-3">
126 Showing 21-30 of 100 129 Showing 21-30 of 100
127 </span> 130 </span>
128 <span class="col-span-2"></span> 131 <span class="col-span-2"></span>
129 132
130 <span class="flex col-span-4 mt-2 sm:mt-auto sm:justify-end"> 133 <span class="flex col-span-4 mt-2 sm:mt-auto sm:justify-end">
131 <nav aria-label="Table navigation"> 134 <nav aria-label="Table navigation">
132 <ul class="inline-flex items-center"> 135 <ul class="inline-flex items-center">
133 <li> 136 <li>
134 <button 137 <button
135 class="px-3 py-1 rounded-md rounded-l-lg focus:outline-none focus:shadow-outline-purple" 138 class="px-3 py-1 rounded-md rounded-l-lg focus:outline-none focus:shadow-outline-purple"
136 aria-label="Previous" 139 aria-label="Previous"
137 > 140 >
138 <svg 141 <svg
139 aria-hidden="true" 142 aria-hidden="true"
140 class="w-4 h-4 fill-current" 143 class="w-4 h-4 fill-current"
141 viewBox="0 0 20 20" 144 viewBox="0 0 20 20"
142 > 145 >
143 <path 146 <path
144 d="M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z" 147 d="M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z"
145 clip-rule="evenodd" 148 clip-rule="evenodd"
146 fill-rule="evenodd" 149 fill-rule="evenodd"
147 ></path> 150 ></path>
148 </svg> 151 </svg>
149 </button> 152 </button>
150 </li> 153 </li>
151 <li> 154 <li>
152 <button 155 <button
153 class="px-3 py-1 rounded-md focus:outline-none focus:shadow-outline-purple" 156 class="px-3 py-1 rounded-md focus:outline-none focus:shadow-outline-purple"
154 > 157 >
155 1 158 1
156 </button> 159 </button>
157 </li> 160 </li>
158 <li> 161 <li>
159 <button 162 <button
160 class="px-3 py-1 rounded-md focus:outline-none focus:shadow-outline-purple" 163 class="px-3 py-1 rounded-md focus:outline-none focus:shadow-outline-purple"
161 > 164 >
162 2 165 2
163 </button> 166 </button>
164 </li> 167 </li>
165 <li> 168 <li>
166 <button 169 <button
167 class="px-3 py-1 text-white transition-colors duration-150 bg-purple-600 border border-r-0 border-purple-600 rounded-md focus:outline-none focus:shadow-outline-purple" 170 class="px-3 py-1 text-white transition-colors duration-150 bg-purple-600 border border-r-0 border-purple-600 rounded-md focus:outline-none focus:shadow-outline-purple"
168 > 171 >
169 3 172 3
170 </button> 173 </button>
171 </li> 174 </li>
172 <li> 175 <li>
173 <button 176 <button
174 class="px-3 py-1 rounded-md focus:outline-none focus:shadow-outline-purple" 177 class="px-3 py-1 rounded-md focus:outline-none focus:shadow-outline-purple"
175 > 178 >
176 4 179 4
177 </button> 180 </button>
178 </li> 181 </li>
179 <li> 182 <li>
180 <span class="px-3 py-1">...</span> 183 <span class="px-3 py-1">...</span>
181 </li> 184 </li>
182 <li> 185 <li>
183 <button 186 <button
184 class="px-3 py-1 rounded-md focus:outline-none focus:shadow-outline-purple" 187 class="px-3 py-1 rounded-md focus:outline-none focus:shadow-outline-purple"
185 > 188 >
186 8 189 8
187 </button> 190 </button>
188 </li> 191 </li>
189 <li> 192 <li>
190 <button 193 <button
191 class="px-3 py-1 rounded-md focus:outline-none focus:shadow-outline-purple" 194 class="px-3 py-1 rounded-md focus:outline-none focus:shadow-outline-purple"
192 > 195 >
193 9 196 9
194 </button> 197 </button>
195 </li> 198 </li>
196 <li> 199 <li>
197 <button 200 <button
198 class="px-3 py-1 rounded-md rounded-r-lg focus:outline-none focus:shadow-outline-purple" 201 class="px-3 py-1 rounded-md rounded-r-lg focus:outline-none focus:shadow-outline-purple"
199 aria-label="Next" 202 aria-label="Next"
200 > 203 >
201 <svg 204 <svg
202 class="w-4 h-4 fill-current" 205 class="w-4 h-4 fill-current"
203 aria-hidden="true" 206 aria-hidden="true"
204 viewBox="0 0 20 20" 207 viewBox="0 0 20 20"
205 > 208 >
206 <path 209 <path
207 d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" 210 d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z"
208 clip-rule="evenodd" 211 clip-rule="evenodd"
209 fill-rule="evenodd" 212 fill-rule="evenodd"
210 ></path> 213 ></path>
211 </svg> 214 </svg>
212 </button> 215 </button>
213 </li> 216 </li>
214 </ul> 217 </ul>
215 </nav> 218 </nav>
216 </span> 219 </span>
217 </div>--> 220 </div>-->
218 </div> 221 </div>
219 222
220 <?//=$users->appends($_GET)->links('catalogs.paginate'); ?> 223 <?//=$users->appends($_GET)->links('catalogs.paginate'); ?>
221 224
222 225
223 @endsection 226 @endsection
224 227