first commit

This commit is contained in:
Sampanna Rimal
2024-08-27 17:48:06 +05:45
commit 53c0140f58
10839 changed files with 1125847 additions and 0 deletions

View File

@ -0,0 +1,242 @@
<?php
namespace Modules\Attendance\Http\Controllers;
use App\Http\Controllers\Controller;
use Carbon\Carbon;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Modules\Admin\Models\Holiday;
use Modules\Attendance\Models\Attendance;
use Modules\Attendance\Repositories\AttendanceInterface;
use Modules\Attendance\Repositories\AttendanceRepository;
use Modules\Employee\Repositories\EmployeeInterface;
use Modules\Leave\Models\Leave;
class AttendanceController extends Controller
{
private $attendanceRepository;
private $employeeRepository;
public function __construct(
AttendanceInterface $attendanceRepository, EmployeeInterface $employeeRepository) {
$this->attendanceRepository = $attendanceRepository;
$this->employeeRepository = $employeeRepository;
}
/**
* Display a listing of the resource.
*/
public function index()
{
$data['title'] = 'Attendance Lists';
$data['employees'] = $this->employeeRepository->findAll()
->transform(function ($employee) use ($data) {
$employee->status = 'Absent';
$leave = Leave::
where('employee_id', $employee->id)
->whereDate('start_date', date('Y-m-d'))
->whereStatus(2)
->first();
if ($leave) {
$employee->status = 'Leave';
}
$holiday = Holiday::
whereDate('start_date', date('Y-m-d'))
->first();
if ($holiday) {
$employee->status = 'Holiday';
}
$attendances = Attendance::
where('employee_id', $employee->id)
->whereDate('date', date('Y-m-d'))
->first();
if ($attendances) {
$employee->atd_date = $attendances->date;
$employee->clock_in = $attendances->clock_in_time;
$employee->clock_out = $attendances->clock_out_time;
$employee->total_hrs = Carbon::parse($employee->clock_out)->diffInMinutes(Carbon::parse($employee->clock_in));
$employee->status = 'Present';
}
return $employee;
});
return view('attendance::attendances.index', $data);
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
$data['title'] = 'Create Attendance';
$data['editable'] = false;
$data['employeeList'] = $this->employeeRepository->pluck();
return view('attendance::attendances.create', $data);
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request): RedirectResponse
{
try {
$attendance = Attendance::whereDate('date', now())->where('employee_id', $request->employee_id)->first();
if ($attendance) {
toastr()->error("Attendance Already Exists");
return redirect()->back();
}
$request->merge([
'date' => $request->date ? $request->date : now()->format('Y-m-d'),
// 'clock_in_time' => $request->clock_in_time ? $request->clock_in_time : now()->format('H:i:s'),
'clock_in_ip' => request()->ip(),
'clock_out_ip' => request()->ip(),
'createdBy' => auth()->user()->id,
]);
$this->attendanceRepository->create($request->all());
toastr()->success('Attendance Created Successfully');
} catch (\Throwable $th) {
toastr()->error($th->getMessage());
}
return redirect()->route('attendance.index');
}
/**
* Show the specified resource.
*/
public function show($id)
{
return view('attendance::attendances.show');
}
/**
* Show the form for editing the specified resource.
*/
public function edit($id)
{
try {
$data['title'] = 'Edit Attendance';
$data['editable'] = true;
$data['employeeList'] = $this->employeeRepository->pluck();
$data['attendance'] = $this->attendanceRepository->getAttendanceById($id);
} catch (\Throwable $th) {
toastr()->error($th->getMessage());
}
return view('attendance::attendances.edit', $data);
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, $id): RedirectResponse
{
try {
$this->attendanceRepository->update($id, $request->all());
toastr()->success('Attendance Updated Successfully');
} catch (\Throwable $th) {
toastr()->error($th->getMessage());
}
return redirect()->route('attendance.index');
}
/**
* Remove the specified resource from storage.
*/
public function destroy($id)
{
try {
$this->attendanceRepository->delete($id);
toastr()->success('Attendance Deleted Successfully');
} catch (\Throwable $th) {
toastr()->error($th->getMessage());
}
return redirect()->route('attendance.index');
}
public function clockInOut(Request $request): RedirectResponse
{
$request->merge([
'date' => now()->format('Y-m-d'),
'employee_id' => auth()->user()->employee_id,
'createdBy' => auth()->user()->id,
]);
$attendance = Attendance::whereDate('date', now())->where('employee_id', auth()->user()->employee_id)->first();
if ($attendance) {
if ($request->type == 'clockin') {
$request->merge([
'clock_in_time' => now()->format('H:i:s'),
'clock_in_ip' => request()->ip(),
]);
}
if ($request->type == 'clockout') {
$request->merge([
'clock_out_time' => now()->format('H:i:s'),
'clock_out_ip' => request()->ip(),
]);
}
$attendance->update($request->all());
} else {
if ($request->type == 'clockin') {
$request->merge([
'clock_in_time' => now()->format('H:i:s'),
'clock_in_ip' => request()->ip(),
]);
}
$this->attendanceRepository->create($request->all());
}
// dd('asd');
// try {
// $attendance = Attendance::whereDate('date', now())->where('employee_id', auth()->user()->employee_id)->latest()->first();
// if ($attendance && $attendance->clock_out_time == null) {
// $request->merge([
// 'clock_out_time' => now()->format('H:i:s'),
// 'clock_out_ip' => request()->ip(),
// 'updatedBy' => auth()->user()->id,
// ]);
// $this->attendanceRepository->update($attendance->attendance_id, $request->except('_token'));
// toastr()->success('Clocked Out Successfully.');
// } else {
// $request->merge([
// 'date' => now()->format('Y-m-d'),
// 'clock_in_time' => now()->format('H:i:s'),
// 'clock_in_ip' => request()->ip(),
// 'employee_id' => auth()->user()->employee_id,
// 'createdBy' => auth()->user()->id,
// ]);
// $this->attendanceRepository->create($request->all());
// toastr()->success('Clocked In Successfully');
// }
// } catch (\Throwable $th) {
// toastr()->error($th->getMessage());
// }
return redirect()->back();
}
}

View File

@ -0,0 +1,67 @@
<?php
namespace Modules\Attendance\Http\Controllers;
use App\Http\Controllers\Controller;
use Carbon\Carbon;
use Modules\Attendance\Models\Attendance;
use Modules\Attendance\Repositories\AttendanceInterface;
use Modules\Attendance\Repositories\AttendanceRepository;
use Modules\Employee\Repositories\EmployeeInterface;
use Modules\Leave\Models\Leave;
class ReportController extends Controller
{
private $attendanceRepository;
private $employeeRepository;
public function __construct(
AttendanceInterface $attendanceRepository,
EmployeeInterface $employeeRepository) {
$this->attendanceRepository = $attendanceRepository;
$this->employeeRepository = $employeeRepository;
}
public function monthly()
{
$data['title'] = 'Employee Attendance Lists';
$firstDayOfMonth = Carbon::createFromDate(date('Y'), date('m'), 1)->startOfMonth();
$lastDayOfMonth = Carbon::createFromDate(date('Y'), date('m'), 1)->endOfMonth();
for ($day = $firstDayOfMonth; $day <= $lastDayOfMonth; $day->addDay()) {
$data['dayLists'][] = $day->format('Y-m-d');
}
$data['employees'] = $this->employeeRepository->findAll()
->transform(function ($employee) use ($data) {
$attendances = Attendance::
where('employee_id', $employee->id)
->whereIn('date', $data['dayLists'])
->select('clock_in_time', 'clock_out_time', 'date')
->get()
// ->groupBy('date')
->mapWithKeys(function ($atd) {
return [$atd['date'] => 'P'];
});
$leave = Leave::
where('employee_id', $employee->id)
->whereIn('start_date', $data['dayLists'])
->whereStatus(2)
->get()
->mapWithKeys(function ($atd) {
return [$atd['start_date'] => 'L'];
});
$final = $attendances->push($leave);
$attendanceArray = [];
foreach ($data['dayLists'] as $date) {
$attendanceArray[$date] = array_key_exists($date, $final->toArray()) ? $final[$date] : '';
}
$employee->dates = $attendanceArray;
return $employee;
});
return view('attendance::report.monthly', $data);
}
}

View File

View File

@ -0,0 +1,39 @@
<?php
namespace Modules\Attendance\Models;
use App\Models\Scopes\CreatedByScope;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Attendance extends Model
{
use HasFactory;
protected $table = 'tbl_attendances';
protected $primaryKey = 'attendance_id';
/**
* The attributes that are mass assignable.
*/
protected $fillable = [
'employee_id',
'clock_in_time',
'clock_out_time',
'clock_in_ip',
'clock_out_ip',
'work_from_type',
'type',
'date',
'status',
'total_hours',
'description',
'remarks',
'createdBy',
'updatedBy',
];
protected static function booted(): void
{
static::addGlobalScope(new CreatedByScope);
}
}

View File

@ -0,0 +1,120 @@
<?php
namespace Modules\Attendance\Providers;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
use Modules\Attendance\Repositories\AttendanceInterface;
use Modules\Attendance\Repositories\AttendanceRepository;
use Modules\Employee\Repositories\EmployeeInterface;
use Modules\Employee\Repositories\EmployeeRepository;
class AttendanceServiceProvider extends ServiceProvider
{
protected string $moduleName = 'Attendance';
protected string $moduleNameLower = 'attendance';
/**
* Boot the application events.
*/
public function boot(): void
{
$this->registerCommands();
$this->registerCommandSchedules();
$this->registerTranslations();
$this->registerConfig();
$this->registerViews();
$this->loadMigrationsFrom(module_path($this->moduleName, 'database/migrations'));
}
/**
* Register the service provider.
*/
public function register(): void
{
$this->app->register(RouteServiceProvider::class);
$this->app->bind(AttendanceInterface::class, AttendanceRepository::class);
}
/**
* Register commands in the format of Command::class
*/
protected function registerCommands(): void
{
// $this->commands([]);
}
/**
* Register command Schedules.
*/
protected function registerCommandSchedules(): void
{
// $this->app->booted(function () {
// $schedule = $this->app->make(Schedule::class);
// $schedule->command('inspire')->hourly();
// });
}
/**
* Register translations.
*/
public function registerTranslations(): void
{
$langPath = resource_path('lang/modules/'.$this->moduleNameLower);
if (is_dir($langPath)) {
$this->loadTranslationsFrom($langPath, $this->moduleNameLower);
$this->loadJsonTranslationsFrom($langPath);
} else {
$this->loadTranslationsFrom(module_path($this->moduleName, 'lang'), $this->moduleNameLower);
$this->loadJsonTranslationsFrom(module_path($this->moduleName, 'lang'));
}
}
/**
* Register config.
*/
protected function registerConfig(): void
{
$this->publishes([module_path($this->moduleName, 'config/config.php') => config_path($this->moduleNameLower.'.php')], 'config');
$this->mergeConfigFrom(module_path($this->moduleName, 'config/config.php'), $this->moduleNameLower);
}
/**
* Register views.
*/
public function registerViews(): void
{
$viewPath = resource_path('views/modules/'.$this->moduleNameLower);
$sourcePath = module_path($this->moduleName, 'resources/views');
$this->publishes([$sourcePath => $viewPath], ['views', $this->moduleNameLower.'-module-views']);
$this->loadViewsFrom(array_merge($this->getPublishableViewPaths(), [$sourcePath]), $this->moduleNameLower);
$componentNamespace = str_replace('/', '\\', config('modules.namespace').'\\'.$this->moduleName.'\\'.ltrim(config('modules.paths.generator.component-class.path'), config('modules.paths.app_folder','')));
Blade::componentNamespace($componentNamespace, $this->moduleNameLower);
}
/**
* Get the services provided by the provider.
*/
public function provides(): array
{
return [];
}
private function getPublishableViewPaths(): array
{
$paths = [];
foreach (config('view.paths') as $path) {
if (is_dir($path.'/modules/'.$this->moduleNameLower)) {
$paths[] = $path.'/modules/'.$this->moduleNameLower;
}
}
return $paths;
}
}

View File

@ -0,0 +1,49 @@
<?php
namespace Modules\Attendance\Providers;
use Illuminate\Support\Facades\Route;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
class RouteServiceProvider extends ServiceProvider
{
/**
* Called before routes are registered.
*
* Register any model bindings or pattern based filters.
*/
public function boot(): void
{
parent::boot();
}
/**
* Define the routes for the application.
*/
public function map(): void
{
$this->mapApiRoutes();
$this->mapWebRoutes();
}
/**
* Define the "web" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*/
protected function mapWebRoutes(): void
{
Route::middleware('web')->group(module_path('Attendance', '/routes/web.php'));
}
/**
* Define the "api" routes for the application.
*
* These routes are typically stateless.
*/
protected function mapApiRoutes(): void
{
Route::middleware('api')->prefix('api')->name('api.')->group(module_path('Attendance', '/routes/api.php'));
}
}

View File

@ -0,0 +1,12 @@
<?php
namespace Modules\Attendance\Repositories;
interface AttendanceInterface
{
public function findAll();
public function getAttendanceById($attendanceId);
public function delete($attendanceId);
public function create(array $attendanceDetails);
public function update($attendanceId, array $newDetails);
}

View File

@ -0,0 +1,35 @@
<?php
namespace Modules\Attendance\Repositories;
use Modules\Attendance\Models\Attendance;
class AttendanceRepository implements AttendanceInterface
{
public function findAll()
{
return Attendance::get();
}
public function getAttendanceById($attendanceId)
{
return Attendance::findOrFail($attendanceId);
}
public function delete($attendanceId)
{
Attendance::destroy($attendanceId);
}
public function create(array $attendanceDetails)
{
return Attendance::create($attendanceDetails);
}
public function update($attendanceId, array $newDetails)
{
return Attendance::where('attendance_id', $attendanceId)->update($newDetails);
}
}

View File

@ -0,0 +1,30 @@
{
"name": "nwidart/attendance",
"description": "",
"authors": [
{
"name": "Nicolas Widart",
"email": "n.widart@gmail.com"
}
],
"extra": {
"laravel": {
"providers": [],
"aliases": {
}
}
},
"autoload": {
"psr-4": {
"Modules\\Attendance\\": "app/",
"Modules\\Attendance\\Database\\Factories\\": "database/factories/",
"Modules\\Attendance\\Database\\Seeders\\": "database/seeders/"
}
},
"autoload-dev": {
"psr-4": {
"Modules\\Attendance\\Tests\\": "tests/"
}
}
}

View File

View File

@ -0,0 +1,5 @@
<?php
return [
'name' => 'Attendance',
];

View File

@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('tbl_attendances', function (Blueprint $table) {
$table->unsignedTinyInteger('attendance_id')->autoIncrement();
$table->unsignedBigInteger('employee_id')->nullable();
$table->time('clock_in_time')->nullable();
$table->time('clock_out_time')->nullable();
$table->string('clock_in_ip')->nullable();
$table->string('clock_out_ip')->nullable();
$table->string('work_from_type')->nullable();
$table->date('date')->nullable();
$table->integer('total_hours')->nullable();
$table->integer('status')->default(11);
$table->mediumText('description')->nullable();
$table->mediumText('remarks')->nullable();
$table->unsignedBigInteger('createdBy')->nullable();
$table->unsignedBigInteger('updatedBy')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('tbl_attendances');
}
};

View File

@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('tbl_attendances', function (Blueprint $table) {
$table->string('type')->nullable()->after('work_from_type');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('tbl_attendances', function (Blueprint $table) {
});
}
};

View File

@ -0,0 +1,16 @@
<?php
namespace Modules\Attendance\database\seeders;
use Illuminate\Database\Seeder;
class AttendanceDatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
// $this->call([]);
}
}

View File

@ -0,0 +1,17 @@
{
"name": "Attendance",
"alias": "attendance",
"description": "",
"keywords": [],
"priority": 0,
"providers": [
"Modules\\Attendance\\Providers\\AttendanceServiceProvider"
],
"files": [],
"migration": {
"seeds": [
"Modules\\Admin\\database\\seeders\\AdminDatabaseSeeder",
"Modules\\Admin\\database\\seeders\\GenderSeeder"
]
}
}

View File

@ -0,0 +1,15 @@
{
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build"
},
"devDependencies": {
"axios": "^1.1.2",
"laravel-vite-plugin": "^0.7.5",
"sass": "^1.69.5",
"postcss": "^8.3.7",
"vite": "^4.0.0"
}
}

View File

@ -0,0 +1,23 @@
@extends('layouts.app')
@section('content')
<div class="page-content">
<div class="container-fluid">
<!-- start page title -->
@include('layouts.partials.breadcrumb', ['title' => $title])
<!-- end page title -->
<div class='card'>
<div class='card-body'>
{{ html()->form('POST')->route('attendance.store')->class(['needs-validation'])->attributes(['novalidate'])->open() }}
@include('attendance::partials.attendances.action')
{{ html()->form()->close() }}
</div>
</div>
</div>
@endsection

View File

@ -0,0 +1,23 @@
@extends('layouts.app')
@section('content')
<div class="page-content">
<div class="container-fluid">
<!-- start page title -->
@include('layouts.partials.breadcrumb', ['title' => $title])
<!-- end page title -->
<div class='card'>
<div class='card-body'>
{{ html()->modelForm($attendance, 'PUT')->route('attendance.update', $attendance->attendance_id)->class(['needs-validation'])->attributes(['novalidate'])->open() }}
@include('attendance::partials.attendances.action')
{{ html()->form()->close() }}
</div>
</div>
</div>
@endsection

View File

@ -0,0 +1,72 @@
@extends('layouts.app')
@section('content')
<div class="page-content">
<div class="container-fluid">
<!-- start page title -->
@include('layouts.partials.breadcrumb', ['title' => $title])
<!-- end page title -->
<div class="card">
<div class="card-header align-items-center d-flex">
<h5 class="card-title flex-grow-1 mb-0">{{ $title }}</h5>
<div class="flex-shrink-0">
<a href="{{ route('attendance.create') }}" class="btn btn-success waves-effect waves-light"><i
class="ri-add-fill me-1 align-bottom"></i>Add Attendance</a>
</div>
</div>
<div class="card-body">
<div class="row">
<div class="col-md-12">
<div class="table-responsive">
<table id="buttons-datatables" class="display table-sm table-bordered table">
<thead class="table-light">
<tr>
<th class="tb-col"><span class="overline-title p-1">Name</span></th>
<th class="tb-col"><span class="overline-title">Date</span></th>
<th class="tb-col"><span class="overline-title">Shift</span></th>
<th class="tb-col"><span class="overline-title">Clock In</span></th>
<th class="tb-col"><span class="overline-title">Clock In</span></th>
<th class="tb-col"><span class="overline-title">Total Hours</span></th>
<th class="tb-col"><span class="overline-title">Status</span></th>
<th class="tb-col"><span class="overline-title">Action</span></th>
</tr>
</thead>
<tbody>
@foreach ($employees as $employee)
<tr>
<td class="p-1">
<div class="d-flex align-items-center">
<div class="me-2 flex-shrink-0">
<img src="{{ $employee->profile_pic }}" alt="" class="avatar-sm p-2">
</div>
<div>
<h5 class="fs-14 fw-medium my-1">
<a href="#"
class="text-reset text-hover-success small">{{ $employee->full_name }}</a>
</h5>
<span class="text-muted">{{ $employee->email }}</span>
</div>
</div>
</td>
@foreach ($employee->dates as $date)
@if ($date)
<td><span class="text-success"><i class="ri-check-line"></i></span></td>
@else
<td><span class="text-danger"><i class="ri-close-line"></i></span></td>
@endif
@endforeach
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection

View File

@ -0,0 +1,69 @@
@extends('layouts.app')
@section('content')
<div class="page-content">
<div class="container-fluid">
<!-- start page title -->
@include('layouts.partials.breadcrumb', ['title' => $title])
<!-- end page title -->
<div class="card">
<div class="card-header align-items-center d-flex">
<h5 class="card-title flex-grow-1 mb-0">{{ $title }}</h5>
<div class="flex-shrink-0">
<a href="{{ route('attendance.create') }}" class="btn btn-success waves-effect waves-light"><i
class="ri-add-fill me-1 align-bottom"></i>Add</a>
</div>
</div>
<div class="card-body">
<div class="row">
<div class="col-md-12">
<div class="table-responsive">
<table id="buttons-datatables" class="display table-sm table-bordered table">
<thead class="table-light">
<tr>
<th class="tb-col"><span class="overline-title">Name</span></th>
<th class="tb-col"><span class="overline-title">Date</span></th>
{{-- <th class="tb-col"><span class="overline-title">Shift</span></th> --}}
<th class="tb-col"><span class="overline-title">Clock In</span></th>
<th class="tb-col"><span class="overline-title">Clock In</span></th>
<th class="tb-col"><span class="overline-title">Working Hours(min)</span></th>
<th class="tb-col"><span class="overline-title">Status</span></th>
</tr>
</thead>
<tbody>
@foreach ($employees as $employee)
<tr style=" vertical-align: middle;">
<td class="p-1">
<div class="d-flex align-items-center">
<div class="me-2 flex-shrink-0">
<img src="{{ $employee->profile_pic }}" alt="" class="avatar-sm p-2">
</div>
<div>
<h5 class="fs-14 fw-medium my-1">
<a href="#"
class="text-reset text-hover-success small">{{ $employee->full_name }}</a>
</h5>
<span class="text-muted">{{ $employee->email }}</span>
</div>
</div>
</td>
<td>{{ $employee->atd_date }}</td>
<td class="text-success">{{ $employee->clock_in }}</td>
<td class="text-danger">{{ $employee->clock_out }}</td>
<td>{{ $employee->total_hrs }}</td>
<td>{{ $employee->status }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection

View File

@ -0,0 +1,7 @@
@extends('attendance::layouts.master')
@section('content')
<h1>Hello World</h1>
<p>Module: {!! config('attendance.name') !!}</p>
@endsection

View File

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-token" content="{{ csrf_token() }}">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Attendance Module - {{ config('app.name', 'Laravel') }}</title>
<meta name="description" content="{{ $description ?? '' }}">
<meta name="keywords" content="{{ $keywords ?? '' }}">
<meta name="author" content="{{ $author ?? '' }}">
<!-- Fonts -->
<link rel="preconnect" href="https://fonts.bunny.net">
<link href="https://fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet" />
{{-- Vite CSS --}}
{{-- {{ module_vite('build-attendance', 'resources/assets/sass/app.scss') }} --}}
</head>
<body>
@yield('content')
{{-- Vite JS --}}
{{-- {{ module_vite('build-attendance', 'resources/assets/js/app.js') }} --}}
</body>

View File

@ -0,0 +1,43 @@
<div class="row gy-3">
<div class="col-lg-4 col-md-6">
{{ html()->label('Employee')->class('form-label') }}
{{ html()->select('employee_id', $employeeList)->class('form-select select2')->placeholder('Select Employee')->required() }}
{{ html()->div('Please Select Employee')->class('invalid-feedback') }}
</div>
<div class="col-lg-4 col-md-6">
{{ html()->label('Clock In')->class('form-label') }}
{{ html()->time('clock_in_time')->class('form-control')->required() }}
{{ html()->div('Please Select Clock In')->class('invalid-feedback') }}
</div>
<div class="col-lg-4 col-md-6">
{{ html()->label('Clock Out')->class('form-label') }}
{{ html()->time('clock_out_time')->class('form-control')->required() }}
{{ html()->div('Please Select Clock Out')->class('invalid-feedback') }}
</div>
<div class="col-lg-4 col-md-6">
{{ html()->label('Date')->class('form-label') }}
{{ html()->date('date')->class('form-control')->placeholder('Attendance Date')->required() }}
{{ html()->div('Please Choose Date')->class('invalid-feedback') }}
</div>
<div class="col-lg-4 col-md-6">
{{ html()->label('Working From')->class('form-label') }}
{{ html()->select('work_from_type', ['home' => 'Home', 'office' => 'Office', 'other' => 'Other'])->class('form-select select2')->placeholder('Working From') }}
</div>
<input type="hidden" name="type" value="clockout">
<div class="text-end">
{{ html()->button($editable ? 'Update' : 'Mark Attendance', 'submit')->class('btn btn-success') }}
</div>
</div>
@push('js')
<script src="{{ asset('assets/js/pages/form-validation.init.js') }}"></script>
@endpush

View File

@ -0,0 +1,68 @@
@extends('layouts.app')
@section('content')
<div class="page-content">
<div class="container-fluid">
<!-- start page title -->
@include('layouts.partials.breadcrumb', ['title' => $title])
<!-- end page title -->
<div class="card">
<div class="card-header align-items-center d-flex">
<h5 class="card-title flex-grow-1 mb-0">{{ $title }}</h5>
<div class="flex-shrink-0">
<a href="{{ route('attendance.create') }}" class="btn btn-success waves-effect waves-light"><i
class="ri-add-fill me-1 align-bottom"></i>Mark Attendance</a>
</div>
</div>
<div class="card-body">
<div class="row">
<div class="col-md-12">
<div class="table-responsive">
<table id="buttons-datatables" class="display table-sm table-bordered table">
<thead class="table-light">
<tr>
<th class="tb-col"><span class="overline-title p-1">Name</span></th>
@foreach ($dayLists as $day)
<th class="small">{{ \Carbon\Carbon::parse($day)->format('d D') }}</th>
@endforeach
</tr>
</thead>
<tbody>
@foreach ($employees as $employee)
<tr>
<td class="p-1">
<div class="d-flex align-items-center">
<div class="me-2 flex-shrink-0">
<img src="{{ $employee->profile_pic }}" alt="" class="avatar-sm p-2">
</div>
<div>
<h5 class="fs-14 fw-medium my-1">
<a href="#"
class="text-reset text-hover-success small">{{ $employee->full_name }}</a>
</h5>
<span class="text-muted">{{ $employee->email }}</span>
</div>
</div>
</td>
@foreach ($employee->dates as $date)
@if ($date)
<td><span class="text-success"><i class="ri-check-line"></i></span></td>
@else
<td><span class="text-danger"><i class="ri-close-line"></i></span></td>
@endif
@endforeach
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection

View File

View File

@ -0,0 +1,19 @@
<?php
use Illuminate\Support\Facades\Route;
use Modules\Attendance\Http\Controllers\AttendanceController;
/*
*--------------------------------------------------------------------------
* API Routes
*--------------------------------------------------------------------------
*
* Here is where you can register API routes for your application. These
* routes are loaded by the RouteServiceProvider within a group which
* is assigned the "api" middleware group. Enjoy building your API!
*
*/
Route::middleware(['auth:sanctum'])->prefix('v1')->group(function () {
Route::apiResource('attendance', AttendanceController::class)->names('attendance');
});

View File

@ -0,0 +1,26 @@
<?php
use Illuminate\Support\Facades\Route;
use Modules\Attendance\Http\Controllers\AttendanceController;
use Modules\Attendance\Http\Controllers\ReportController;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::group([], function () {
Route::post('/clock-in-out', [AttendanceController::class, 'clockInOut'])->name('attendance.clockInOut');
Route::resource('attendance', AttendanceController::class)->names('attendance');
Route::group(['prefix' => 'attendance-report'], function () {
Route::get('/monthly', [ReportController::class, 'monthly'])->name('attendanceReport.monthly');
});
});

View File

@ -0,0 +1,26 @@
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
export default defineConfig({
build: {
outDir: '../../public/build-attendance',
emptyOutDir: true,
manifest: true,
},
plugins: [
laravel({
publicDirectory: '../../public',
buildDirectory: 'build-attendance',
input: [
__dirname + '/resources/assets/sass/app.scss',
__dirname + '/resources/assets/js/app.js'
],
refresh: true,
}),
],
});
//export const paths = [
// 'Modules/Attendance/resources/assets/sass/app.scss',
// 'Modules/Attendance/resources/assets/js/app.js',
//];