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