NASER add admin levels & fix break button
This commit is contained in:
@@ -34,7 +34,12 @@ class AdminController extends Controller
|
||||
$u = User::select('name', 'is_admin')
|
||||
->where('user_name', $uname)
|
||||
->first();
|
||||
if ($u->is_admin == '1') {
|
||||
if ($u->is_admin == 1){
|
||||
$provider = 'admin';
|
||||
}elseif ($u->is_admin == 2){
|
||||
$provider = 'supervisor';
|
||||
}
|
||||
if ($u->is_admin == '1' || $u->is_admin == '2') {
|
||||
setcookie('ad', '1', time() + (60 * 60 * 24 * 365 * 5), "/");
|
||||
$users = User::wherenotnull('user_name')
|
||||
->with('attendances')
|
||||
@@ -83,7 +88,8 @@ class AdminController extends Controller
|
||||
"text" => 'شما به پنل ادمین وارد شدید✔️'
|
||||
],
|
||||
"users" => $users,
|
||||
'reqs' => $records
|
||||
'reqs' => $records,
|
||||
"userType" => $provider
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -136,6 +142,11 @@ class AdminController extends Controller
|
||||
$nstartt = $request->starttime;
|
||||
$nendt = $request->endtime;
|
||||
// dd($request);
|
||||
$user = User::where('user_name', $_COOKIE['user_identity'])->first();
|
||||
if ($user->is_admin == 2){
|
||||
$attController = new AttendanceController();
|
||||
return $attController->edit($request);
|
||||
}
|
||||
if ($id == 'new') {
|
||||
$user_name = $request->uname;
|
||||
if($request->display_date == null){
|
||||
@@ -276,15 +287,17 @@ class AdminController extends Controller
|
||||
}
|
||||
$record->requested = '';
|
||||
$record->save();
|
||||
$create_requests_key = "att-tempreq:creates:{$data->userid}";
|
||||
Redis::connection()->lrem($create_requests_key, 1, json_encode($data));
|
||||
// $create_requests_key = "att-tempreq:creates:{$data->userid}";
|
||||
// $create_requests_key = "att-tempreq:{$data->userid}:{$data->id}";
|
||||
// $t = Redis::connection()->lrem($create_requests_key, -1, json_encode($data));
|
||||
|
||||
// Redis::connection()->del("att-tempreq:{$data->userid}:{$data->id}");
|
||||
Redis::connection()->del("att-tempreq:{$data->userid}:{$data->id}");
|
||||
tel_notif($record->user_identity, "تایید");
|
||||
return redirect()->back()->with('message', [
|
||||
'color' => '#6aff00ff',
|
||||
"text" => 'رکورد با موفقیت ذخیره شد.✔️'
|
||||
]);
|
||||
return json_encode($data);
|
||||
// return redirect()->back()->with('message', [
|
||||
// 'color' => '#6aff00ff',
|
||||
// "text" => 'رکورد با موفقیت ذخیره شد.✔️'
|
||||
// ]);
|
||||
} elseif ($data->function == 'new') {
|
||||
// dd($data);
|
||||
$starttime = $data->oldenter ? Carbon::parse($data->oldenter)->format('H:i:s') : null;
|
||||
@@ -311,10 +324,13 @@ class AdminController extends Controller
|
||||
|
||||
}
|
||||
if ($request->update == 'reject') {
|
||||
$create_requests_key = "att-tempreq:creates:{$data->userid}";
|
||||
Redis::connection()->lrem($create_requests_key, 1, json_encode($data));
|
||||
if($data->function == 'delete' || $data->function == 'edit'){
|
||||
Redis::connection()->del("att-tempreq:{$data->userid}:{$data->id}");
|
||||
}elseif($data->function == 'new'){
|
||||
$create_requests_key = "att-tempreq:creates:{$data->userid}";
|
||||
Redis::connection()->lrem($create_requests_key, 1, json_encode($data));
|
||||
}
|
||||
|
||||
// Redis::connection()->del("att-tempreq:{$data->userid}:{$data->id}");
|
||||
// dd($data->id);
|
||||
if ($data->id !== "new") {
|
||||
$att = Attendance::find($data->id);
|
||||
|
||||
@@ -127,6 +127,48 @@ class AttendanceController extends Controller
|
||||
// return redirect(route('admin.dashboard'));
|
||||
// }
|
||||
|
||||
|
||||
// public function login1(Request $request)
|
||||
// {
|
||||
//
|
||||
// $credentials = $request->only(['phone', 'password']);
|
||||
// $user = User::where('number', $credentials['phone'])->first();
|
||||
// if($user->is_admin == 0){
|
||||
// $provider = 'employee';
|
||||
// }elseif ($user->is_admin == 1){
|
||||
// $provider = 'admin';
|
||||
// }elseif ($user->is_admin == 2){
|
||||
// $provider = 'supervisor';
|
||||
// }
|
||||
// return $this->_loginWithPassword($credentials, $provider);
|
||||
// }
|
||||
//
|
||||
// protected function _loginWithPassword($credentials, $provider)
|
||||
// {
|
||||
//
|
||||
//
|
||||
// $token = auth($provider)->attempt($credentials);
|
||||
// if (!$token) {
|
||||
// throw new UnprocessableEntityHttpException('شماره موبایل یا پسوورد وارد شده اشتباه است');
|
||||
// }
|
||||
// $user = auth($provider)->user();
|
||||
//
|
||||
//
|
||||
// return $this->respondWithToken($token);
|
||||
// }
|
||||
//
|
||||
// protected function respondWithToken($token)
|
||||
// {
|
||||
// return response()->json([
|
||||
// 'access_token' => $token,
|
||||
// 'token_type' => 'bearer',
|
||||
// 'expires_in' => auth()->factory()->getTTL()
|
||||
// ]);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
public function ai()
|
||||
{
|
||||
$response = Http::withHeaders([
|
||||
|
||||
+3
-1
@@ -10,7 +10,9 @@
|
||||
"laravel/framework": "^12.0",
|
||||
"laravel/tinker": "^2.10.1",
|
||||
"morilog/jalali": "^3.4",
|
||||
"predis/predis": "^3.2"
|
||||
"predis/predis": "^3.2",
|
||||
"tymon/jwt-auth": "^1.0"
|
||||
|
||||
},
|
||||
"require-dev": {
|
||||
"fakerphp/faker": "^1.23",
|
||||
|
||||
Generated
+8377
-8292
File diff suppressed because it is too large
Load Diff
+17
-2
@@ -14,8 +14,8 @@ return [
|
||||
*/
|
||||
|
||||
'defaults' => [
|
||||
'guard' => env('AUTH_GUARD', 'web'),
|
||||
'passwords' => env('AUTH_PASSWORD_BROKER', 'users'),
|
||||
'guard' => 'user',
|
||||
'passwords' => 'users',
|
||||
],
|
||||
|
||||
/*
|
||||
@@ -40,6 +40,21 @@ return [
|
||||
'driver' => 'session',
|
||||
'provider' => 'users',
|
||||
],
|
||||
'admin' => [
|
||||
'driver' => 'jwt',
|
||||
'provider' => 'admins',
|
||||
// 'hash' => true,
|
||||
],
|
||||
'supervisor' => [
|
||||
'driver' => 'jwt',
|
||||
'provider' => 'supervisors',
|
||||
// 'hash' => true,
|
||||
],
|
||||
'employee' => [
|
||||
'driver' => 'jwt',
|
||||
'provider' => 'employees',
|
||||
// 'hash' => true,
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
|
||||
@@ -42,7 +42,7 @@ foreach ($users as $u) {
|
||||
else
|
||||
$us = false;
|
||||
$u->working = $us ? 1 : 0;
|
||||
}else
|
||||
} else
|
||||
$u->working = 0;
|
||||
|
||||
foreach ($u->attendances as $u_att) {
|
||||
@@ -93,7 +93,9 @@ $usersChunked = $users->chunk(3);
|
||||
<th class="px-2 py-2 border w-1/6">تاریخ</th>
|
||||
<th class="px-2 py-2 border w-1/6">ورود</th>
|
||||
<th class="px-2 py-2 border w-1/6">خروج</th>
|
||||
<th class="px-2 py-2 border w-1/6">تعیین وضعیت</th>
|
||||
@if($userType == 'admin')
|
||||
<th class="px-2 py-2 border w-1/6">تعیین وضعیت</th>
|
||||
@endif
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@@ -115,7 +117,7 @@ $usersChunked = $users->chunk(3);
|
||||
$newEnter = $rec->newenter ? Carbon::parse($rec->newenter)->format('H:i') : null;
|
||||
$oldExit = $rec->oldexit ? Carbon::parse($rec->oldexit)->format('H:i') : null;
|
||||
$newExit = $rec->newexit ? Carbon::parse($rec->newexit)->format('H:i') : null;
|
||||
@endphp
|
||||
@endphp
|
||||
|
||||
@if( $oldEnter == $newEnter || $newEnter == null)
|
||||
<td class="px-4 py-2 border">{{ $oldEnter ?? '-' }}</td>
|
||||
@@ -129,28 +131,30 @@ $usersChunked = $users->chunk(3);
|
||||
<td class="px-4 py-2 border">{{ $oldExit || $newExit ? ($rec->id=='new' || $oldExit==($newExit ?? '') ? $oldExit : $oldExit.'👇🏻'.$newExit) : '-' }}</td>
|
||||
@endif
|
||||
|
||||
<td class="px-4 py-2 border">
|
||||
<form method="post" action="{{route('admin.update')}}">
|
||||
@csrf
|
||||
<input type="hidden" name="update" id="update" value="approve">
|
||||
<input type="hidden" name="data" id="data"
|
||||
value="{{json_encode($rec)}}">
|
||||
<button class="bg-white rounded w-full"
|
||||
style="background-color: #81ff65; margin-bottom: 5px">
|
||||
تایید
|
||||
</button>
|
||||
</form>
|
||||
<form method="post" action="{{route('admin.update')}}">
|
||||
@csrf
|
||||
<input type="hidden" name="update" id="update" value="reject">
|
||||
<input type="hidden" name="data" id="data"
|
||||
value="{{json_encode($rec)}}">
|
||||
<button class="bg-white rounded w-full"
|
||||
style="background-color: #ff6565">
|
||||
رد
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
@if($userType == 'admin')
|
||||
<td class="px-4 py-2 border">
|
||||
<form method="post" action="{{route('admin.update')}}">
|
||||
@csrf
|
||||
<input type="hidden" name="update" id="update" value="approve">
|
||||
<input type="hidden" name="data" id="data"
|
||||
value="{{json_encode($rec)}}">
|
||||
<button class="bg-white rounded w-full"
|
||||
style="background-color: #81ff65; margin-bottom: 5px">
|
||||
تایید
|
||||
</button>
|
||||
</form>
|
||||
<form method="post" action="{{route('admin.update')}}">
|
||||
@csrf
|
||||
<input type="hidden" name="update" id="update" value="reject">
|
||||
<input type="hidden" name="data" id="data"
|
||||
value="{{json_encode($rec)}}">
|
||||
<button class="bg-white rounded w-full"
|
||||
style="background-color: #ff6565">
|
||||
رد
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
@endif
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
@@ -196,13 +200,16 @@ $usersChunked = $users->chunk(3);
|
||||
</p>
|
||||
|
||||
</a>
|
||||
<button type="button"
|
||||
class="rounded-lg bg-cyan-500 hover:bg-cyan-600"
|
||||
onclick="window.location.href='{{ url('attendance/profile').'?username='.$u->user_name }}'"
|
||||
style=" border: none; color: white; padding: 5px 10px; text-align: center; text-decoration: none;
|
||||
@if($userType == 'admin')
|
||||
|
||||
<button type="button"
|
||||
class="rounded-lg bg-cyan-500 hover:bg-cyan-600"
|
||||
onclick="window.location.href='{{ url('attendance/profile').'?username='.$u->user_name }}'"
|
||||
style=" border: none; color: white; padding: 5px 10px; text-align: center; text-decoration: none;
|
||||
display: inline-block; font-size: 16px; margin: 4px 2px; cursor: pointer; ">
|
||||
ویرایش
|
||||
</button>
|
||||
ویرایش
|
||||
</button>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
@endforeach
|
||||
|
||||
@@ -8,35 +8,35 @@ use Carbon\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
|
||||
if (!empty($user->tasks)) {
|
||||
$in_progress = '#fca000';
|
||||
$todo = '#7d7d7d';
|
||||
$error = '#fc0000';
|
||||
$backlog = '#bababa';
|
||||
$done = '#40de02';
|
||||
$cancelled = 'black';
|
||||
|
||||
$state = [
|
||||
"c73c2044-ea14-42cb-b08d-cecf3d1fdfb5" => "$in_progress",// in progress
|
||||
"a9ce312f-cfca-491e-8e3d-1975aa6ebc10" => "$todo",//to do
|
||||
"dea1fb57-a281-4fe7-8f3e-ee5567637e35" => "$error",// error
|
||||
"770fbe42-99f6-41db-9b9e-773d9cced1a5" => "$backlog",//backlog
|
||||
"b0e464e1-34eb-41ea-b2f7-3ef7483bc9f0" => "$done",//done
|
||||
"d61d14a3-72f7-4f44-894b-efe8b2a75be1" => "$cancelled",//canceled
|
||||
];
|
||||
$state_order = [
|
||||
"c73c2044-ea14-42cb-b08d-cecf3d1fdfb5",
|
||||
"a9ce312f-cfca-491e-8e3d-1975aa6ebc10",
|
||||
"dea1fb57-a281-4fe7-8f3e-ee5567637e35",
|
||||
"770fbe42-99f6-41db-9b9e-773d9cced1a5",
|
||||
"b0e464e1-34eb-41ea-b2f7-3ef7483bc9f0",
|
||||
"d61d14a3-72f7-4f44-894b-efe8b2a75be1",
|
||||
];
|
||||
|
||||
$user->tasks = $user->tasks->sortBy(function ($task) use ($state_order) {
|
||||
return array_search($task->state, $state_order);
|
||||
});
|
||||
}
|
||||
//if (!empty($user->tasks)) {
|
||||
// $in_progress = '#fca000';
|
||||
// $todo = '#7d7d7d';
|
||||
// $error = '#fc0000';
|
||||
// $backlog = '#bababa';
|
||||
// $done = '#40de02';
|
||||
// $cancelled = 'black';
|
||||
//
|
||||
// $state = [
|
||||
// "c73c2044-ea14-42cb-b08d-cecf3d1fdfb5" => "$in_progress",// in progress
|
||||
// "a9ce312f-cfca-491e-8e3d-1975aa6ebc10" => "$todo",//to do
|
||||
// "dea1fb57-a281-4fe7-8f3e-ee5567637e35" => "$error",// error
|
||||
// "770fbe42-99f6-41db-9b9e-773d9cced1a5" => "$backlog",//backlog
|
||||
// "b0e464e1-34eb-41ea-b2f7-3ef7483bc9f0" => "$done",//done
|
||||
// "d61d14a3-72f7-4f44-894b-efe8b2a75be1" => "$cancelled",//canceled
|
||||
// ];
|
||||
// $state_order = [
|
||||
// "c73c2044-ea14-42cb-b08d-cecf3d1fdfb5",
|
||||
// "a9ce312f-cfca-491e-8e3d-1975aa6ebc10",
|
||||
// "dea1fb57-a281-4fe7-8f3e-ee5567637e35",
|
||||
// "770fbe42-99f6-41db-9b9e-773d9cced1a5",
|
||||
// "b0e464e1-34eb-41ea-b2f7-3ef7483bc9f0",
|
||||
// "d61d14a3-72f7-4f44-894b-efe8b2a75be1",
|
||||
// ];
|
||||
//
|
||||
// $user->tasks = $user->tasks->sortBy(function ($task) use ($state_order) {
|
||||
// return array_search($task->state, $state_order);
|
||||
// });
|
||||
//}
|
||||
//dd(count($break = $user->attendanceBreaks));
|
||||
if (count($user->attendanceBreaks) > 0){
|
||||
$break = $user->attendanceBreaks[0];
|
||||
@@ -111,13 +111,13 @@ if (count($user->attendanceBreaks) > 0){
|
||||
</button>
|
||||
{{--<p>{{Carbon::now()}}</p>--}}
|
||||
</form>
|
||||
@if(session('open_task_modal'))
|
||||
<script>
|
||||
window.onload = () => {
|
||||
openTaskModal();
|
||||
};
|
||||
</script>
|
||||
@endif
|
||||
{{-- @if(session('open_task_modal'))--}}
|
||||
{{-- <script>--}}
|
||||
{{-- window.onload = () => {--}}
|
||||
{{-- openTaskModal();--}}
|
||||
{{-- };--}}
|
||||
{{-- </script>--}}
|
||||
{{-- @endif--}}
|
||||
|
||||
@else
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@ Route::get('/', function () {
|
||||
return view('welcome');
|
||||
});
|
||||
|
||||
Route::post('/login', [\App\Http\Controllers\AttendanceController::class, 'login1']);
|
||||
|
||||
Route::post('/task/create', [TaskController::class, 'addTask'])->name('createTask');
|
||||
|
||||
Route::get('/ai', function () {
|
||||
|
||||
Reference in New Issue
Block a user