tsks
This commit is contained in:
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
+1
@@ -20,6 +20,7 @@
|
||||
/storage/*.key
|
||||
/storage/pail
|
||||
/vendor
|
||||
/redis_data
|
||||
Homestead.json
|
||||
Homestead.yaml
|
||||
Thumbs.db
|
||||
|
||||
Regular → Executable
+41
-41
@@ -28,47 +28,47 @@ class RunAiJob extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$response = Http::withHeaders([
|
||||
'Authorization' => 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjA2OWZlZGJiLTk2ZDctNGU4MC1iMDA0LWFmZDZjMmU4YmZkZiIsImxhc3RfcGFzc3dvcmRfY2hhbmdlIjoxNzUwNjYwODczLCJleHAiOjE3NTQ3NTcxMDR9.qAQF8XDOU8NRz5vSiFlQfnrj8dhGhJ5uvJqjblQWmr8',
|
||||
'Cookie' => 'x-ap=eu-central-1; acw_tc=0a03e56c17521661095906021e3cacb270c127c80eb3a20489a465ab4beae1',
|
||||
])->post('https://chat.qwen.ai/api/v2/chat/completions?chat_id=7ce2a60a-2b40-4ae8-8536-0cd346642de3', [
|
||||
'stream' => false,
|
||||
'incremental_output' => true,
|
||||
'chat_id' => '7ce2a60a-2b40-4ae8-8536-0cd346642de3',
|
||||
'chat_mode' => 'normal',
|
||||
'model' => 'qwen3-235b-a22b',
|
||||
'messages' => [
|
||||
[
|
||||
'role' => 'user',
|
||||
'content' => 'یه جمله انگیزشی بده که خاص، کوبنده و غیرکلیشهای باشه. نه مثل بقیه.',
|
||||
'user_action' => 'chat',
|
||||
'files' => [],
|
||||
'timestamp' => 1752165316,
|
||||
'models' => ['qwen3-235b-a22b'],
|
||||
'chat_type' => 't2t',
|
||||
'feature_config' => [
|
||||
'thinking_enabled' => false,
|
||||
'output_schema' => 'phase'
|
||||
],
|
||||
'extra' => [
|
||||
'meta' => [
|
||||
'subChatType' => 't2t'
|
||||
]
|
||||
],
|
||||
'sub_chat_type' => 't2t',
|
||||
'parent_id' => 'df0a0c91-53d5-4a04-b5da-b8ac53d6d821'
|
||||
]
|
||||
],
|
||||
'timestamp' => 1752165316
|
||||
]);
|
||||
// Get the response
|
||||
$responseData = $response->json();
|
||||
$content = $responseData['data']['choices'][0]['message']['content'];
|
||||
$ai = new ai(); // Or use your correct namespace
|
||||
$ai->key = 'angizeh'; // Assuming you fixed 'kay' to 'key' in migration
|
||||
$ai->prompt = 'فقط یک جمله کوتاه انگیزشی بگو';
|
||||
$ai->response = $content;
|
||||
$ai->save();
|
||||
// $response = Http::withHeaders([
|
||||
// 'Authorization' => 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjA2OWZlZGJiLTk2ZDctNGU4MC1iMDA0LWFmZDZjMmU4YmZkZiIsImxhc3RfcGFzc3dvcmRfY2hhbmdlIjoxNzUwNjYwODczLCJleHAiOjE3NTQ3NTcxMDR9.qAQF8XDOU8NRz5vSiFlQfnrj8dhGhJ5uvJqjblQWmr8',
|
||||
// 'Cookie' => 'x-ap=eu-central-1; acw_tc=0a03e56c17521661095906021e3cacb270c127c80eb3a20489a465ab4beae1',
|
||||
// ])->post('https://chat.qwen.ai/api/v2/chat/completions?chat_id=7ce2a60a-2b40-4ae8-8536-0cd346642de3', [
|
||||
// 'stream' => false,
|
||||
// 'incremental_output' => true,
|
||||
// 'chat_id' => '7ce2a60a-2b40-4ae8-8536-0cd346642de3',
|
||||
// 'chat_mode' => 'normal',
|
||||
// 'model' => 'qwen3-235b-a22b',
|
||||
// 'messages' => [
|
||||
// [
|
||||
// 'role' => 'user',
|
||||
// 'content' => 'یه جمله انگیزشی بده که خاص، کوبنده و غیرکلیشهای باشه. نه مثل بقیه.',
|
||||
// 'user_action' => 'chat',
|
||||
// 'files' => [],
|
||||
// 'timestamp' => 1752165316,
|
||||
// 'models' => ['qwen3-235b-a22b'],
|
||||
// 'chat_type' => 't2t',
|
||||
// 'feature_config' => [
|
||||
// 'thinking_enabled' => false,
|
||||
// 'output_schema' => 'phase'
|
||||
// ],
|
||||
// 'extra' => [
|
||||
// 'meta' => [
|
||||
// 'subChatType' => 't2t'
|
||||
// ]
|
||||
// ],
|
||||
// 'sub_chat_type' => 't2t',
|
||||
// 'parent_id' => 'df0a0c91-53d5-4a04-b5da-b8ac53d6d821'
|
||||
// ]
|
||||
// ],
|
||||
// 'timestamp' => 1752165316
|
||||
// ]);
|
||||
//// Get the response
|
||||
// $responseData = $response->json();
|
||||
// $content = $responseData['data']['choices'][0]['message']['content'];
|
||||
// $ai = new ai(); // Or use your correct namespace
|
||||
// $ai->key = 'angizeh'; // Assuming you fixed 'kay' to 'key' in migration
|
||||
// $ai->prompt = 'فقط یک جمله کوتاه انگیزشی بگو';
|
||||
// $ai->response = $content;
|
||||
// $ai->save();
|
||||
$this->info('AI Job dispatched successfully!');
|
||||
}
|
||||
}
|
||||
|
||||
Regular → Executable
Regular → Executable
@@ -4,9 +4,12 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class Attendance extends Model
|
||||
{
|
||||
// protected $appends = ['full_time'];
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'user_identity',
|
||||
@@ -21,6 +24,7 @@ class Attendance extends Model
|
||||
'ip_address',
|
||||
'entered_at',
|
||||
'exited_at',
|
||||
'requested',
|
||||
];
|
||||
|
||||
public function setEntryLocationAttribute($value)
|
||||
@@ -42,5 +46,39 @@ class Attendance extends Model
|
||||
{
|
||||
return $this->hasMany(AttendanceBreak::class);
|
||||
}
|
||||
|
||||
public function duration($start,$end)
|
||||
{
|
||||
// dd($start,$end, $date);
|
||||
$fakedate = '2020/02/20';
|
||||
$start = Carbon::parse($start)->format('Y/m/d') ? Carbon::parse($start) : Carbon::parse($start . $fakedate);
|
||||
$end = Carbon::parse($end)->format('Y/m/d') ? Carbon::parse($end) : Carbon::parse($end . $fakedate);
|
||||
|
||||
|
||||
$diffInSeconds = $start->diffInSeconds($end); // فاصله به ثانیه
|
||||
$hours = floor($diffInSeconds / 3600);
|
||||
$minutes = floor(($diffInSeconds % 3600) / 60);
|
||||
$seconds = $diffInSeconds % 60;
|
||||
|
||||
$duration = sprintf('%02d:%02d:%02d', $hours, $minutes, $seconds);
|
||||
return $duration;
|
||||
}
|
||||
// public function attendanceBreak()
|
||||
// {
|
||||
//
|
||||
// return $this->hasMany(AttendanceBreak::class, 'attendance_id', 'id')
|
||||
// ->select('attendance_id', 'break_start', 'break_end', 'duration')
|
||||
// ->orderBy('break_start', 'desc');
|
||||
//
|
||||
//
|
||||
// }
|
||||
public function attendanceBreaks()
|
||||
{
|
||||
return $this->hasMany(AttendanceBreak::class, 'attendance_id', 'id')
|
||||
->orderBy('break_start', 'desc');
|
||||
}
|
||||
|
||||
|
||||
|
||||
public $timestamps = true;
|
||||
}
|
||||
|
||||
Regular → Executable
+1
@@ -11,6 +11,7 @@ class AttendanceBreak extends Model
|
||||
'attendance_id',
|
||||
'break_start',
|
||||
'break_end',
|
||||
'duration',
|
||||
];
|
||||
|
||||
// رابطه به حضور
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Tasks extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'tasks';
|
||||
|
||||
// protected $primaryKey = 'id'; // چون جدول UUID داره
|
||||
// public $incrementing = false;
|
||||
// protected $keyType = 'int';
|
||||
|
||||
protected $fillable = [
|
||||
'task_id',
|
||||
'name',
|
||||
'description',
|
||||
'workspace_slug',
|
||||
'assignees',
|
||||
'start_date',
|
||||
'target_date',
|
||||
'priority',
|
||||
'description_html',
|
||||
'completed_at',
|
||||
'project',
|
||||
'workspace',
|
||||
'state',
|
||||
'json',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'deleted_at',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'deleted_by',
|
||||
|
||||
];
|
||||
|
||||
// رابطه many-to-many با users
|
||||
public function users()
|
||||
{
|
||||
// return $this->belongsToMany(User::class, 'pivot_tasks', 'task_id', 'user_id');
|
||||
return $this->belongsToMany(
|
||||
User::class, // مدل مقصد
|
||||
'pivot_tasks', // جدول واسط
|
||||
'task_id', // ستون جدول واسط که به جدول tasks اشاره میکنه
|
||||
'user_id', // ستون جدول واسط که به جدول users اشاره میکنه
|
||||
'task_id', // ستون جدول tasks که ستون واسط بهش اشاره میکنه (local key)
|
||||
'plain_id' // ستون جدول users که ستون واسط بهش اشاره میکنه (related key)
|
||||
);
|
||||
}
|
||||
}
|
||||
Regular → Executable
+74
-9
@@ -3,24 +3,36 @@
|
||||
namespace App\Models;
|
||||
|
||||
// use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Morilog\Jalali\Jalalian;
|
||||
|
||||
|
||||
class User extends Authenticatable
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\UserFactory> */
|
||||
use HasFactory, Notifiable;
|
||||
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'email',
|
||||
'chatid',
|
||||
'name',
|
||||
'number',
|
||||
'password',
|
||||
'user_name',
|
||||
'is_admin',
|
||||
'plain_id',
|
||||
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -28,10 +40,7 @@ class User extends Authenticatable
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
protected $hidden = [];
|
||||
|
||||
/**
|
||||
* Get the attributes that should be cast.
|
||||
@@ -40,9 +49,65 @@ class User extends Authenticatable
|
||||
*/
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'email_verified_at' => 'datetime',
|
||||
'password' => 'hashed',
|
||||
];
|
||||
return [];
|
||||
}
|
||||
|
||||
public function tasks()
|
||||
{
|
||||
// return $this->belongsToMany(Tasks::class, 'pivot_tasks', 'user_id', 'task_id');
|
||||
return $this->belongsToMany(
|
||||
Tasks::class, // مدل مقصد
|
||||
'pivot_tasks', // جدول واسط
|
||||
'user_id', // ستون جدول واسط که به جدول users اشاره میکنه
|
||||
'task_id', // ستون جدول واسط که به جدول tasks اشاره میکنه
|
||||
'plain_id', // ستون جدول users که ستون جدول واسط بهش اشاره میکنه (local key)
|
||||
'task_id' // ستون جدول tasks که ستون جدول واسط بهش اشاره میکنه (related key)
|
||||
);
|
||||
}
|
||||
|
||||
public function attendances()
|
||||
{
|
||||
|
||||
return $this->hasMany(Attendance::class, 'user_identity', 'user_name')
|
||||
->select('id', 'user_identity', 'entered_at', 'exited_at', 'duration','requested')
|
||||
->orderBy('entered_at', 'desc');
|
||||
|
||||
|
||||
}
|
||||
public function attendanceBreaks()
|
||||
{
|
||||
return $this->hasManyThrough(AttendanceBreak::class,Attendance::class,'user_identity','attendance_id',
|
||||
'user_name', // local key در users
|
||||
'id' // local key در attendances
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function thismonth($data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function everymonth($data)
|
||||
{
|
||||
$result = [];
|
||||
|
||||
foreach ($data->attendances as $att) {
|
||||
if ($att->entered_at) {
|
||||
$date = \Morilog\Jalali\Jalalian::fromCarbon(\Carbon\Carbon::parse($att->entered_at));
|
||||
$month = $date->format('%B');
|
||||
|
||||
if (!isset($result[$month])) {
|
||||
$result[$month] = [];
|
||||
}
|
||||
|
||||
$result[$month][] = $att;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Regular → Executable
Regular → Executable
+1
-1
@@ -19,6 +19,6 @@ class AppServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function boot(): void
|
||||
{
|
||||
//
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+22
-4
@@ -6,13 +6,31 @@ use Illuminate\Foundation\Configuration\Middleware;
|
||||
|
||||
return Application::configure(basePath: dirname(__DIR__))
|
||||
->withRouting(
|
||||
web: __DIR__.'/../routes/web.php',
|
||||
commands: __DIR__.'/../routes/console.php',
|
||||
web: __DIR__ . '/../routes/web.php',
|
||||
commands: __DIR__ . '/../routes/console.php',
|
||||
api: __DIR__ . '/../routes/api.php',
|
||||
health: '/up',
|
||||
)
|
||||
->withMiddleware(function (Middleware $middleware): void {
|
||||
//
|
||||
$middleware->group('web', [
|
||||
\Illuminate\Cookie\Middleware\EncryptCookies::class,
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ValidateCsrfToken::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
// \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
]);
|
||||
|
||||
$middleware->group('api', [
|
||||
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
|
||||
// 'throttle:api',
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
]);
|
||||
$middleware->group('admin', [
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class
|
||||
]);
|
||||
})
|
||||
->withExceptions(function (Exceptions $exceptions): void {
|
||||
//
|
||||
|
||||
})->create();
|
||||
|
||||
Regular → Executable
+2
-1
@@ -9,7 +9,8 @@
|
||||
"php": "^8.2",
|
||||
"laravel/framework": "^12.0",
|
||||
"laravel/tinker": "^2.10.1",
|
||||
"morilog/jalali": "^3.4"
|
||||
"morilog/jalali": "^3.4",
|
||||
"predis/predis": "^3.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"fakerphp/faker": "^1.23",
|
||||
|
||||
+64
-1
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "a2ec9a62fadff86c2c1515530c75f8e2",
|
||||
"content-hash": "611e1c3c1211e46afd5c8aa1c11d2332",
|
||||
"packages": [
|
||||
{
|
||||
"name": "beberlei/assert",
|
||||
@@ -2714,6 +2714,69 @@
|
||||
],
|
||||
"time": "2024-07-20T21:41:07+00:00"
|
||||
},
|
||||
{
|
||||
"name": "predis/predis",
|
||||
"version": "v3.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/predis/predis.git",
|
||||
"reference": "9e9deec4dfd3ebf65d32eb368f498c646ba2ecd8"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/predis/predis/zipball/9e9deec4dfd3ebf65d32eb368f498c646ba2ecd8",
|
||||
"reference": "9e9deec4dfd3ebf65d32eb368f498c646ba2ecd8",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.2 || ^8.0",
|
||||
"psr/http-message": "^1.0|^2.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"friendsofphp/php-cs-fixer": "^3.3",
|
||||
"phpstan/phpstan": "^1.9",
|
||||
"phpunit/phpcov": "^6.0 || ^8.0",
|
||||
"phpunit/phpunit": "^8.0 || ~9.4.4"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-relay": "Faster connection with in-memory caching (>=0.6.2)"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Predis\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Till Krüss",
|
||||
"homepage": "https://till.im",
|
||||
"role": "Maintainer"
|
||||
}
|
||||
],
|
||||
"description": "A flexible and feature-complete Redis/Valkey client for PHP.",
|
||||
"homepage": "http://github.com/predis/predis",
|
||||
"keywords": [
|
||||
"nosql",
|
||||
"predis",
|
||||
"redis"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/predis/predis/issues",
|
||||
"source": "https://github.com/predis/predis/tree/v3.2.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/sponsors/tillkruss",
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2025-08-06T06:41:24+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/clock",
|
||||
"version": "1.0.0",
|
||||
|
||||
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
+1
-1
@@ -147,7 +147,7 @@ return [
|
||||
|
||||
'options' => [
|
||||
'cluster' => env('REDIS_CLUSTER', 'redis'),
|
||||
'prefix' => env('REDIS_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')).'-database-'),
|
||||
'prefix' => "WOLOG-TEMPBASE",//env('REDIS_PREFIX', Str::slug((string) env('APP_NAME', 'laravel')).'-database-'),
|
||||
'persistent' => env('REDIS_PERSISTENT', false),
|
||||
],
|
||||
|
||||
|
||||
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Executable
+11
@@ -0,0 +1,11 @@
|
||||
version: "3.8"
|
||||
|
||||
services:
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
ports:
|
||||
- "6363:6379"
|
||||
volumes:
|
||||
- /home/liman/server/redis_data:/data
|
||||
restart: always
|
||||
command: ["redis-server", "--appendonly", "yes"]
|
||||
Regular → Executable
Regular → Executable
@@ -0,0 +1,2 @@
|
||||
<?php
|
||||
phpinfo();
|
||||
Regular → Executable
Regular → Executable
Regular → Executable
Executable
+235
@@ -0,0 +1,235 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Attendance;
|
||||
use App\Models\AttendanceBreak;
|
||||
use Morilog\Jalali\Jalalian;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//dd($reqs);
|
||||
$now = Jalalian::fromCarbon(Carbon::now());
|
||||
foreach ($users as $user) {
|
||||
$totaltime = 0;
|
||||
$tsec = 0;
|
||||
foreach ($user->attendances as $att) {
|
||||
$date = $att->entered_at != null ? Jalalian::fromCarbon(Carbon::parse($att->entered_at)) : null;
|
||||
$att->date = $date != null ? $date->format('Y/m/d') : null;
|
||||
if ($att->duration != null && $date != null && $now->getMonth() == $date->getMonth()) {
|
||||
[$h, $m, $s] = explode(':', $att->duration);
|
||||
$tsec += $h * 3600 + $m * 60 + $s;
|
||||
}
|
||||
}
|
||||
$hours = floor($tsec / 3600);
|
||||
$minutes = floor(($tsec % 3600) / 60);
|
||||
$seconds = $tsec % 60;
|
||||
|
||||
$totalTime = sprintf('%02d:%02d', $hours, $minutes);
|
||||
$user->totaltime = $totalTime;
|
||||
|
||||
}
|
||||
//dd($users);
|
||||
foreach ($users as $u) {
|
||||
|
||||
$us = $u->attendances()
|
||||
->whereNull('exited_at')
|
||||
->latest('entered_at')
|
||||
->exists();
|
||||
$u->working = $us ? 1 : 0;
|
||||
|
||||
foreach ($u->attendances as $u_att) {
|
||||
$break = AttendanceBreak::wherenull('break_end')->where('attendance_id', $u_att->id)->exists();
|
||||
if ($break)
|
||||
$u->working = 2;
|
||||
}
|
||||
|
||||
}
|
||||
//dd($users);
|
||||
$users = $users->sortByDesc('working');
|
||||
//$users = json_decode(json: $users);
|
||||
// $users = collect($users);
|
||||
$usersChunked = $users->chunk(3);
|
||||
//dd($users);
|
||||
?>
|
||||
|
||||
|
||||
@extends('app')
|
||||
@section('content')
|
||||
<div class="container w-full flex flex-col items-center">
|
||||
|
||||
@if(!collect($reqs)->pluck('attendances')->flatten()->isEmpty())
|
||||
<div class="mt-10 bg-white rounded-lg shadow-md max-w-[350px] flex flex-col items-center">
|
||||
<p style="min-font-size: 30; text-align: center; margin-bottom: 10px">درخواست ها</p>
|
||||
{{-- {{dd($reqs)}}--}}
|
||||
|
||||
@foreach ($reqs as $u)
|
||||
@if(!empty($u['attendances']))
|
||||
|
||||
<button type="button"
|
||||
class="w-[150px] p-3 font-bold text-white bg-blue-500 hover:bg-blue-700 rounded transition duration-150 text-center "
|
||||
onclick="togglerequests('attendance-{{ $loop->index }}')"
|
||||
style="margin: 10px 0; text-align: center; background-color: #00bcd4">
|
||||
{{ $u['name'] }}
|
||||
</button>
|
||||
{{-- @else--}}
|
||||
{{-- <p class="text-stone-400" style="text-align: center">درخواستی ثبت نشده</p>--}}
|
||||
{{-- @break--}}
|
||||
@endif
|
||||
<div id="attendance-{{ $loop->index }}" class="hidden-content pt-4">
|
||||
<table style="max-width: 350px; margin: auto; text-align: center" class="w-[350px] table-auto">
|
||||
|
||||
<thead>
|
||||
<tr class="text-sm" style="background-color: #00a3ba; color: white; text-align: center;">
|
||||
|
||||
<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>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
{{-- {{dd($u['attendances'])}}--}}
|
||||
@forelse($u['attendances'] as $rec)
|
||||
<tr style="background-color: {{$rec->id=='new' ? 'lightblue' : 'white'}}">
|
||||
|
||||
<td class="px-4 py-2 border">{{ match ($rec->function) {
|
||||
'edit' => "تغییر ساعت",
|
||||
'delete' => "حذف",
|
||||
'new' => "جدید",
|
||||
default => "نامشخص",
|
||||
} }}</td>
|
||||
<td class="px-4 py-2 border">{{ Jalalian::fromCarbon(Carbon::parse($rec->oldenter))->format('Y/m/d') }}</td>
|
||||
@if(Carbon::parse($rec->oldenter)->format('H:i') == Carbon::parse($rec->newenter)->format('H:i') || $rec->newenter=='')
|
||||
<td class="px-4 py-2 border">{{ $rec->oldenter ? Carbon::parse($rec->oldenter)->format('H:i') : '-' }}</td>
|
||||
@else
|
||||
<td class="px-4 py-2 border">{{ $rec->oldenter ? ($rec->id=='new' || $rec->oldenter==($rec->newenter ?? '') ? Carbon::parse($rec->oldenter)->format('H:i') : Carbon::parse($rec->oldenter)->format('H:i').'👇🏻'.Carbon::parse($rec->newenter)->format('H:i')) : '-' }}</td>
|
||||
@endif
|
||||
|
||||
@if(Carbon::parse($rec->oldexit)->format('H:i') == Carbon::parse($rec->newexit)->format('H:i') || $rec->newenter=='')
|
||||
<td class="px-4 py-2 border">{{$rec->oldexit ? Carbon::parse($rec->oldexit)->format('H:i') : '-'}}</td>
|
||||
@else
|
||||
<td class="px-4 py-2 border">{{ $rec->oldexit ? ($rec->id=='new' || $rec->oldexit==($rec->newexit ?? '') ? Carbon::parse($rec->oldexit)->format('H:i') : Carbon::parse($rec->oldexit)->format('H:i').'👇🏻'.Carbon::parse($rec->newexit)->format('H:i')) : '-' }}</td>
|
||||
@endif
|
||||
|
||||
{{-- @if(Carbon::parse($rec->oldenter)->format('H:i') == Carbon::parse($rec->newenter)->format('H:i') || $rec->newenter=='')--}}
|
||||
{{-- {{}}--}}
|
||||
{{-- <td class="px-4 py-2 border">{{ Carbon::parse($rec->oldenter)->format('H:i') }}</td>--}}
|
||||
{{-- @else--}}
|
||||
{{-- <td class="px-4 py-2 border">{{ $rec->oldenter ? ($rec->id=='new' ? Carbon::parse($rec->oldenter)->format('H:i') :Carbon::parse($rec->oldenter)->format('H:i').'👇🏻'.Carbon::parse($rec->newenter)->format('H:i')) : '-' }} </td>--}}
|
||||
{{-- @endif--}}
|
||||
{{-- @if(Carbon::parse($rec->oldexit)->format('H:i') == Carbon::parse($rec->newexit)->format('H:i') || $rec->newenter=='')--}}
|
||||
{{-- <td class="px-4 py-2 border">{{Carbon::parse($rec->oldexit)->format('H:i')}}</td>--}}
|
||||
{{-- @else--}}
|
||||
{{-- <td class="px-4 py-2 border">{{ $rec->oldexit ? ($rec->id=='new' ? Carbon::parse($rec->oldexit)->format('H:i') :Carbon::parse($rec->oldexit)->format('H:i').'👇🏻'.$rec->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>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td class="px-4 py-2 border text-center" colspan="6">هیچ رکوردی ثبت نشده</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div> {{-- پایان hidden-content --}}
|
||||
@endforeach
|
||||
{{-- @if(collect($reqs)->pluck('attendances')->flatten()->isEmpty())--}}
|
||||
{{-- <p class="text-stone-400" style="text-align: center">درخواستی ثبت نشده</p>--}}
|
||||
</div>
|
||||
@endif
|
||||
|
||||
|
||||
<div class="container" style="padding-top: 20px">
|
||||
<div class="grid grid-cols-2 grid-rows-none ">
|
||||
@foreach ($usersChunked as $chunk)
|
||||
@foreach ($chunk as $u)
|
||||
<div class="form m-6 justify-evenly rounded-lg shadow-md"
|
||||
style="align-items: center; text-align: center; border: 2px solid
|
||||
{{ $u->working == 1 ? '#16c8ce' : ($u->working == 2 ? 'orange' : 'white' ) }}; padding: 10px; ">
|
||||
@php
|
||||
@endphp
|
||||
<a href="/admin/{{ $u->user_name }}"
|
||||
class="bg-cyan-500/15 rounded-xl"
|
||||
style="text-decoration: none; color: inherit;">
|
||||
<h3 style="font-family:Tahoma; color:#333;">
|
||||
{{ $u->name ?? $u->user_name }}
|
||||
</h3>
|
||||
|
||||
<p>
|
||||
کارکرد ماه جاری:
|
||||
{{ $u->totaltime }}
|
||||
</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;
|
||||
display: inline-block; font-size: 16px; margin: 4px 2px; cursor: pointer; ">
|
||||
ویرایش
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@endforeach
|
||||
@endforeach
|
||||
<a class="form m-6 justify-evenly rounded-lg shadow-md " href="{{route('admin.new')}}"
|
||||
style="align-items: center; text-align: center; ">
|
||||
<i class="fa-regular fa-plus "
|
||||
style="font-size: 80px; width: 90%; height: 90%;"></i>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
{{-- {{dd($reqs)}}--}}
|
||||
|
||||
|
||||
|
||||
{{--MODAL--}}
|
||||
|
||||
@endsection
|
||||
|
||||
@section('script')
|
||||
<script>
|
||||
// این تابع اکنون یک DIV را باز و بسته میکند
|
||||
function togglerequests(elementId) {
|
||||
var contentDiv = document.getElementById(elementId);
|
||||
|
||||
// بررسی میکند اگر عنصر دارای کلاس 'hidden-content' هست، آن را حذف و نمایش دهد، وگرنه اضافه و پنهان کند.
|
||||
if (contentDiv.classList.contains('hidden-content')) {
|
||||
contentDiv.classList.remove('hidden-content');
|
||||
// اگر از Tailwind استفاده میکنید، ممکن است بخواهید: contentDiv.classList.remove('hidden');
|
||||
} else {
|
||||
contentDiv.classList.add('hidden-content');
|
||||
// contentDiv.classList.add('hidden');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
/* نیاز به این کلاس برای پنهان کردن اولیه محتوا */
|
||||
.hidden-content {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
@endsection
|
||||
@@ -0,0 +1,58 @@
|
||||
@extends('app')
|
||||
@section('content')
|
||||
<div class=" flex flex-col items-center justify-center p-4 " dir="rtl"
|
||||
style="padding-top: 50px">
|
||||
|
||||
<div class="bg-white p-6 md:p-8 rounded-2xl shadow-2xl w-full max-w-sm border-t-8 border-[#16c8ce]">
|
||||
|
||||
<div class="text-center mb-6">
|
||||
<h1 class="text-2xl font-extrabold text-gray-800 border-b pb-2">کاربر جدید</h1>
|
||||
</div>
|
||||
|
||||
<form id="attendanceForm" action="{{route('admin.new')}}" method="post" class="space-y-4">
|
||||
@csrf
|
||||
|
||||
<div>
|
||||
<label for="name" class="block text-sm font-medium text-gray-700">اسم:</label>
|
||||
<input type="text" name="name" id="name" required
|
||||
class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-cyan-500 focus:border-cyan-500 sm:text-sm transition duration-150">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="email" class="block text-sm font-medium text-gray-700">ایمیل:</label>
|
||||
<input type="email" name="email" id="email" placeholder="example@domain.com"
|
||||
pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$"
|
||||
class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-cyan-500 focus:border-cyan-500 sm:text-sm transition duration-150">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="username" class="block text-sm font-medium text-gray-700">نام کاربری:</label>
|
||||
<input type="text" name="username" id="username" placeholder="user_name" required
|
||||
class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-cyan-500 focus:border-cyan-500 sm:text-sm transition duration-150">
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col sm:flex-row sm:space-x-4 sm:space-x-reverse space-y-4 sm:space-y-0">
|
||||
|
||||
<div class="w-full sm:w-1/2">
|
||||
<label for="chatid" class="block text-sm font-medium text-gray-700">چت آیدی تلگرام:</label>
|
||||
<input type="text" name="chatid" id="chatid" placeholder="Telegram chat ID"
|
||||
class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-cyan-500 focus:border-cyan-500 sm:text-sm transition duration-150">
|
||||
</div>
|
||||
|
||||
<div class="w-full sm:w-1/2">
|
||||
<label for="number" class="block text-sm font-medium text-gray-700">شماره تماس:</label>
|
||||
<input type="tel" name="number" id="number" placeholder=" ۰۹۱2xxxxxxx" pattern="[0-9]{11}" required
|
||||
class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-cyan-500 focus:border-cyan-500 sm:text-sm transition duration-150">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<button type="submit"
|
||||
class="col-span-2 bg-cyan-500 hover:bg-cyan-700 cursor-pointer rounded-xl border border-400 justify-self-center text-white px-2 py-1.5">
|
||||
ثبت اطلاعات
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@endsection
|
||||
Regular → Executable
+237
-81
@@ -1,5 +1,13 @@
|
||||
<?php
|
||||
use App\Models\User;
|
||||
if(isset($_COOKIE['token-0']))
|
||||
$user_p = User::select('name')->where('user_name', $_COOKIE['user_identity'])->first();
|
||||
//dd($user_p);
|
||||
|
||||
?>
|
||||
<!doctype html>
|
||||
<html lang="en" dir="rtl">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport"
|
||||
@@ -7,12 +15,25 @@
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<script src="{{url('/src/tailwindcss.js')}}"></script>
|
||||
<title>سامانه حضور و غیاب</title>
|
||||
|
||||
{{--ساعت--}}
|
||||
<link rel="stylesheet"
|
||||
href="https://cdnjs.cloudflare.com/ajax/libs/clockpicker/0.0.7/bootstrap-clockpicker.min.css">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/clockpicker/0.0.7/bootstrap-clockpicker.min.js"></script>
|
||||
{{--تاریخ--}}
|
||||
<link rel="stylesheet" href="https://unpkg.com/persian-datepicker@1.2.0/dist/css/persian-datepicker.css">
|
||||
|
||||
<script src="https://unpkg.com/persian-date@1.1.0/dist/persian-date.js"></script>
|
||||
<script src="https://unpkg.com/persian-datepicker@1.2.0/dist/js/persian-datepicker.js"></script>
|
||||
|
||||
|
||||
<link rel="manifest" href="manifest.json">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css" rel="stylesheet"/>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Baloo+Bhaijaan+2:wght@600&display=swap" rel="stylesheet">
|
||||
|
||||
|
||||
<style>
|
||||
/* Ignore CSS variable inspection */
|
||||
:root {
|
||||
@@ -21,6 +42,25 @@
|
||||
--text-color: #ffffff;
|
||||
|
||||
}
|
||||
|
||||
.clockpicker-popover {
|
||||
position: fixed !important;
|
||||
/* مهم: fixed نسبت به viewport */
|
||||
left: 50% !important;
|
||||
/* افقی وسط */
|
||||
top: 50% !important;
|
||||
/* عمودی وسط */
|
||||
transform: translate(-50%, -50%) !important;
|
||||
/* دقیقاً وسط */
|
||||
z-index: 99999 !important;
|
||||
direction: ltr !important;
|
||||
/* چپ به راست */
|
||||
}
|
||||
|
||||
.hidden-row {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -32,6 +72,7 @@
|
||||
position: relative;
|
||||
}
|
||||
|
||||
|
||||
.title {
|
||||
padding-right: 28px;
|
||||
font-size: 28px;
|
||||
@@ -44,7 +85,8 @@
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.title::before, .title::after {
|
||||
.title::before,
|
||||
.title::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
height: 16px;
|
||||
@@ -65,7 +107,8 @@
|
||||
animation: pulse 1s linear infinite;
|
||||
}
|
||||
|
||||
.message, .signin {
|
||||
.message,
|
||||
.signin {
|
||||
color: rgba(88, 87, 87, 0.822);
|
||||
font-size: 14px;
|
||||
}
|
||||
@@ -114,7 +157,8 @@
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
.form label .input:focus + span, .form label .input:valid + span {
|
||||
.form label .input:focus + span,
|
||||
.form label .input:valid + span {
|
||||
left: 10px;
|
||||
top: 30px;
|
||||
font-size: 0.7em;
|
||||
@@ -145,6 +189,7 @@
|
||||
transform: scale(0.9);
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
to {
|
||||
transform: scale(1.8);
|
||||
opacity: 0;
|
||||
@@ -153,7 +198,8 @@
|
||||
|
||||
@font-face {
|
||||
font-family: 'MyCustomFont';
|
||||
src: url('{{url('/src/fonts/woff/iranyekanwebregularfanum.woff')}}') format('woff2'), url('{{url('/src/fonts/woff/iranyekanwebregularfanum.woff')}}') format('woff');
|
||||
src: url('{{url('/src/fonts/woff/iranyekanwebregularfanum.woff')}}') format('woff2'),
|
||||
url('{{url('/src/fonts/woff/iranyekanwebregularfanum.woff')}}') format('woff');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
@@ -176,59 +222,157 @@
|
||||
max-width: 420px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
|
||||
/* Style the tab */
|
||||
.tab {
|
||||
overflow: hidden;
|
||||
/*border: 1px solid #ccc;*/
|
||||
/*background-color: #f1f1f1;*/
|
||||
}
|
||||
|
||||
/* Style the buttons inside the tab */
|
||||
.tab button {
|
||||
background-color: #cfcfcf;
|
||||
float: left;
|
||||
border: 1px solid rgba(0, 0, 0, 0);
|
||||
outline: none;
|
||||
cursor: pointer;
|
||||
padding: 10px 16px 8px 16px;
|
||||
transition: 0.3s;
|
||||
font-size: 17px;
|
||||
}
|
||||
|
||||
/* Change background color of buttons on hover */
|
||||
.tab button:hover {
|
||||
background-color: #ededed;
|
||||
}
|
||||
|
||||
/* Create an active/current tablink class */
|
||||
.tab button.active {
|
||||
background-color: #feffff;
|
||||
|
||||
}
|
||||
|
||||
/* Style the tab content */
|
||||
.tabcontent {
|
||||
display: none;
|
||||
padding: 0px 0px;
|
||||
/*border: 1px solid #ccc;*/
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</style>
|
||||
@yield('style')
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@if (session('message'))
|
||||
<div id="error-box"
|
||||
class="bg-red-500 text-white p-4 rounded shadow-md fixed top-5 left-1/2 transform -translate-x-1/2 transition-opacity duration-1000 ease-in-out opacity-100"
|
||||
style="z-index: 100; background:{{ session('message.color') }};width: 80%;">
|
||||
{{ session('message.text') }}
|
||||
</div>
|
||||
<center>
|
||||
<div id="error-box"
|
||||
class="bg-red-500 text-white p-4 rounded shadow-md fixed top-5 left-1/2 transform -translate-x-1/2 transition-opacity
|
||||
duration-1000 ease-in-out opacity-100"
|
||||
style="z-index: 100; background:{{ session('message.color') }};width: 90%;">
|
||||
{{ session('message.text') }}
|
||||
</div>
|
||||
</center>
|
||||
@endif
|
||||
|
||||
|
||||
|
||||
<div style="max-width: 420px; width: 100%;">
|
||||
<div class="header"
|
||||
style="position: fixed;padding: 6px; top: 0;max-width: 420px; width: 100%; z-index: 11; background-color: #16c8ce;font-size: 24px;font-weight: 600; color: #FFFFFF">
|
||||
<div style="max-width: 420px; width: 100%; ">
|
||||
@if(url()->current() != url('/tasks'))
|
||||
<div class="flex mr-6 object-right-bottom bottom-20 fixed z-10 ">
|
||||
<a class="bg-cyan-500 rounded-full size-14 flex justify-center items-center "
|
||||
href="/tasks">
|
||||
<i class=" fa-solid fa-list-check " style="color: white"></i>
|
||||
</a>
|
||||
</div>
|
||||
@endif
|
||||
<div class="header bg-cyan-500"
|
||||
style="position: fixed;padding: 6px; top: 0;max-width: 420px; width: 100%; z-index: 11;
|
||||
/*background-color: #16c8ce;*/
|
||||
font-size: 24px;font-weight: 600; color: #FFFFFF">
|
||||
<div style="padding: 5px 30px 5px 30px; display: flex;justify-content:center">
|
||||
<div class="headerItems">
|
||||
<label>wolog</label>
|
||||
{{-- <label>{{$user->name}}</label>--}}
|
||||
{{-- @if(isset($_COOKIE['token_0']) || isset($_COOKIE['token_1']) || isset($_COOKIE['token_2']))--}}
|
||||
{{-- <label style="font-size: 12px">({{ $user->type == 0 ? 'ادمین' : ($user->type == 1 ? 'میزبان' :($user->type == 2 ? 'دعوت کننده' : 'مهمان')) }}--}}
|
||||
{{-- )</label>--}}
|
||||
{{-- @endif--}}
|
||||
<div class="headerItems flex items-center justify-between text-white">
|
||||
<!-- Logout -->
|
||||
<label class=" items-center space-x-2 cursor-pointer"
|
||||
onclick="window.location.href = '{{url('attendance/logMeOut')}}'">
|
||||
<i class="fa-solid fa-right-from-bracket"></i>
|
||||
</label>
|
||||
|
||||
<!-- Logo وسط -->
|
||||
@if(isset($_COOKIE['token-0']))
|
||||
<label class="mx-auto font-bold">{{$user_p->name}}<br>
|
||||
</label>
|
||||
@else
|
||||
<label class="mx-auto font-bold">مُنتسک<br>
|
||||
</label>
|
||||
@endif
|
||||
|
||||
|
||||
<!-- Refresh -->
|
||||
<label class=" items-center cursor-pointer"
|
||||
onclick="window.location.href = '{{url('')}}'">
|
||||
<i class="fa-solid fa-arrows-rotate"></i>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div style="margin-bottom: 48px;"></div>
|
||||
|
||||
@if(isset($attendance_recorder) and $attendance_recorder==1 or true)
|
||||
|
||||
@else
|
||||
<div class="fixed bottom-0 max-w-[420px] w-full z-20">
|
||||
<form id="actionForm" method="POST" class="flex justify-around gap-4 items-center px-4 py-1 bg-[#16c8ce] text-[25px]" style="padding: 15px 0 10px 0">
|
||||
@csrf
|
||||
@if(isset($_COOKIE['token_0']) || isset($_COOKIE['token_1']) || isset($_COOKIE['token_2']))
|
||||
<button type="button" onclick="submitForm('up')"><i class="fa-solid fa-arrow-up text-white"></i></button>
|
||||
@endif
|
||||
<button type="button" onclick="submitForm('logout')"><i class="fa-solid fa-right-from-bracket text-white"></i></button>
|
||||
<button type="button" onclick="submitForm('', 'GET')"><i class="fa-solid fa-house text-white"></i></button>
|
||||
{{-- @if(isset($attendance_recorder) and $attendance_recorder == 1 or true)--}}
|
||||
|
||||
<button type="button" onclick="submitForm('edit')"><i class="fa-solid fa-user text-white"></i></button>
|
||||
</form>
|
||||
</div>
|
||||
@endif
|
||||
{{-- @else--}}
|
||||
<div class="fixed bottom-0 max-w-[420px] w-full z-20">
|
||||
<form id="actionForm" method="POST"
|
||||
class="flex justify-around gap-4 items-center px-4 py-1 bg-cyan-500 text-[25px]"
|
||||
style="padding: 15px 0 10px 0">
|
||||
@csrf
|
||||
@if(isset($_COOKIE['token_0']) || isset($_COOKIE['token_1']) || isset($_COOKIE['token_2']))
|
||||
<button type="button" onclick="submitForm('up')"><i
|
||||
class="fa-solid fa-arrow-up text-white"></i></button>
|
||||
@endif
|
||||
{{-- attendances list--}}
|
||||
@if(isset($_COOKIE['token-0']))
|
||||
<button type="button" onclick="submitForm('/back')"><i
|
||||
class="fa-solid fa-backward-step text-white"></i>
|
||||
</button>
|
||||
@endif
|
||||
@if(isset($_COOKIE['user_identity']))
|
||||
<button type="button" onclick="submitForm('{{route('attendance.show')}}','')"><i
|
||||
class="fa-solid fa-clipboard-user text-white"></i></button>
|
||||
@endif
|
||||
|
||||
<button type="button" onclick="submitForm('/', 'GET')"><i
|
||||
class="fa-solid fa-house text-white"></i></button>
|
||||
@if(!request()->is("admin") && (isset($_COOKIE['ad']) && $_COOKIE['ad']==1))
|
||||
|
||||
<button type="button" onclick="submitForm('{{route('admin.dashboard')}}', 'GET')"><i
|
||||
class="fa-solid fa-users text-white"></i></button>
|
||||
@elseif(request()->is("admin") && (isset($_COOKIE['ad']) && $_COOKIE['ad']==1))
|
||||
<button type="button" onclick="submitForm('/', 'GET')"><i
|
||||
class="fa-solid fa-users text-white"></i></button>
|
||||
@endif
|
||||
@if(isset($_COOKIE['user_identity']))
|
||||
|
||||
<button type="button" onclick="submitForm('{{route('user.profile')}}', 'GET')"><i
|
||||
class="fa-solid fa-user text-white"></i></button>
|
||||
@endif
|
||||
</form>
|
||||
</div>
|
||||
{{-- @endif--}}
|
||||
|
||||
<script>
|
||||
function submitForm(action, method = 'POST') {
|
||||
const form = document.getElementById('actionForm');
|
||||
form.action = `{{ url('/') }}/${action}`;
|
||||
form.action = `${action}`;
|
||||
form.method = method; // Sets method dynamically
|
||||
if (method === 'GET') {
|
||||
window.location.href = form.action; // Redirect for GET request
|
||||
@@ -238,58 +382,70 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
{{-- {{dd(session('admin'))}}--}}
|
||||
|
||||
@yield('content')
|
||||
<div style="margin-top: 88px;"></div>
|
||||
<script>
|
||||
function openModal(title, id) {
|
||||
// Set the modal content
|
||||
const modalTitle = document.getElementById('modal-title')
|
||||
const modalBody = document.getElementById('modal-body')
|
||||
modalTitle.innerText = title
|
||||
{{-- <div class="flex justify-center items-center mt-20">--}}
|
||||
{{-- @if(!request()->is("admin") && (isset($_COOKIE['ad']) && $_COOKIE['ad']==1))--}}
|
||||
|
||||
// Set the correct link for Panel Access based on the item's ID
|
||||
const panelLink = document.getElementById('panel-access-link')
|
||||
panelLink.href = `/go_down/${id}`
|
||||
{{-- onclick="window.location.href='{{ route('admin.dashboard') }}'">--}}
|
||||
{{-- ورود به پنل ادمین--}}
|
||||
{{-- </button>--}}
|
||||
|
||||
// Show the modal
|
||||
document.getElementById('modal-container').classList.remove('hidden')
|
||||
}
|
||||
{{-- @elseif(request()->is("admin") && (isset($_COOKIE['ad']) && $_COOKIE['ad']==1))--}}
|
||||
{{-- <button class=" bg-white rounded-[23px] shadow-lg flex justify-center px-4 py-2"--}}
|
||||
{{-- style="max-width: 150px; margin: 0 0 20px 0"--}}
|
||||
{{-- onclick="window.location.href='/'">--}}
|
||||
{{-- ثبت ساعت کاری--}}
|
||||
{{-- </button>--}}
|
||||
{{-- @endif--}}
|
||||
{{-- </div>--}}
|
||||
|
||||
// Close modal function
|
||||
function closeModal() {
|
||||
document.getElementById('modal-container').classList.add('hidden')
|
||||
}
|
||||
@yield('content')
|
||||
<div style="margin-top: 88px;"></div>
|
||||
<script>
|
||||
function openModal(title, id) {
|
||||
// Set the modal content
|
||||
const modalTitle = document.getElementById('modal-title')
|
||||
const modalBody = document.getElementById('modal-body')
|
||||
modalTitle.innerText = title
|
||||
|
||||
// Close modal when clicking outside the modal content
|
||||
document.getElementById('modal-container').addEventListener('click', (e) => {
|
||||
if (e.target === document.getElementById('modal-container')) {
|
||||
closeModal()
|
||||
// Set the correct link for Panel Access based on the item's ID
|
||||
const panelLink = document.getElementById('panel-access-link')
|
||||
panelLink.href = `/go_down/${id}`
|
||||
|
||||
// Show the modal
|
||||
document.getElementById('modal-container').classList.remove('hidden')
|
||||
}
|
||||
})
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const errorBox = document.getElementById('error-box')
|
||||
if (errorBox) {
|
||||
// Fade out the error box after 3 seconds
|
||||
setTimeout(() => {
|
||||
errorBox.classList.add('opacity-0') // Add fade-out class
|
||||
// Remove the error box after the fade-out transition ends
|
||||
errorBox.addEventListener('transitionend', () => {
|
||||
errorBox.remove()
|
||||
})
|
||||
}, 3000) // Duration before starting fade out
|
||||
|
||||
// Close modal function
|
||||
function closeModal() {
|
||||
document.getElementById('modal-container').classList.add('hidden')
|
||||
}
|
||||
})
|
||||
</script>
|
||||
@yield('script')
|
||||
|
||||
// Close modal when clicking outside the modal content
|
||||
document.getElementById('modal-container').addEventListener('click', (e) => {
|
||||
if (e.target === document.getElementById('modal-container')) {
|
||||
closeModal()
|
||||
}
|
||||
})
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const errorBox = document.getElementById('error-box')
|
||||
if (errorBox) {
|
||||
// Fade out the error box after 3 seconds
|
||||
setTimeout(() => {
|
||||
errorBox.classList.add('opacity-0') // Add fade-out class
|
||||
// Remove the error box after the fade-out transition ends
|
||||
errorBox.addEventListener('transitionend', () => {
|
||||
errorBox.remove()
|
||||
})
|
||||
}, 3000) // Duration before starting fade out
|
||||
}
|
||||
})
|
||||
</script>
|
||||
@yield('script')
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</html>
|
||||
Regular → Executable
+696
-265
File diff suppressed because it is too large
Load Diff
Executable
+532
@@ -0,0 +1,532 @@
|
||||
<!doctype html>
|
||||
<html lang="en" dir="rtl">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport"
|
||||
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<script src="{{url('/src/tailwindcss.js')}}"></script>
|
||||
<title>سامانه حضور و غیاب</title>
|
||||
|
||||
|
||||
<style>
|
||||
/* Ignore CSS variable inspection */
|
||||
:root {
|
||||
/* @phpstorm-ignore */
|
||||
--primary-color: #16c8ce;
|
||||
--text-color: #ffffff;
|
||||
|
||||
}
|
||||
|
||||
.clockpicker-popover {
|
||||
position: fixed !important;
|
||||
/* مهم: fixed نسبت به viewport */
|
||||
left: 50% !important;
|
||||
/* افقی وسط */
|
||||
top: 50% !important;
|
||||
/* عمودی وسط */
|
||||
transform: translate(-50%, -50%) !important;
|
||||
/* دقیقاً وسط */
|
||||
z-index: 99999 !important;
|
||||
direction: ltr !important;
|
||||
/* چپ به راست */
|
||||
}
|
||||
|
||||
.hidden-row {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
max-width: 350px;
|
||||
background-color: #fff;
|
||||
padding: 20px;
|
||||
border-radius: 20px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
|
||||
.title {
|
||||
padding-right: 28px;
|
||||
font-size: 28px;
|
||||
color: #424e54;
|
||||
font-weight: 600;
|
||||
letter-spacing: -1px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding-left: 30px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.title::before,
|
||||
.title::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
height: 16px;
|
||||
width: 16px;
|
||||
border-radius: 50%;
|
||||
right: 0;
|
||||
background-color: #16c8ce;
|
||||
}
|
||||
|
||||
.title::before {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
}
|
||||
|
||||
.title::after {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
animation: pulse 1s linear infinite;
|
||||
}
|
||||
|
||||
.message,
|
||||
.signin {
|
||||
color: rgba(88, 87, 87, 0.822);
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.signin {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.signin a {
|
||||
color: royalblue;
|
||||
}
|
||||
|
||||
.signin a:hover {
|
||||
text-decoration: underline royalblue;
|
||||
}
|
||||
|
||||
.flex {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.form label {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.form label .input {
|
||||
width: 100%;
|
||||
padding: 10px 10px 14px 10px;
|
||||
outline: 0;
|
||||
border: 1px solid rgba(105, 105, 105, 0.397);
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.form label .input + span {
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
color: grey;
|
||||
font-size: 0.9em;
|
||||
cursor: text;
|
||||
transition: 0.3s ease;
|
||||
}
|
||||
|
||||
.form label .input:placeholder-shown + span {
|
||||
top: 15px;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
.form label .input:focus + span,
|
||||
.form label .input:valid + span {
|
||||
left: 10px;
|
||||
top: 30px;
|
||||
font-size: 0.7em;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.form label .input:valid + span {
|
||||
color: green;
|
||||
}
|
||||
|
||||
.submit {
|
||||
border: none;
|
||||
outline: none;
|
||||
background-color: #16c8ce;
|
||||
padding: 10px;
|
||||
border-radius: 10px;
|
||||
color: #fff;
|
||||
font-size: 16px;
|
||||
transform: .3s ease;
|
||||
}
|
||||
|
||||
.submit:hover {
|
||||
background-color: rgb(255, 0, 0);
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
from {
|
||||
transform: scale(0.9);
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
to {
|
||||
transform: scale(1.8);
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'MyCustomFont';
|
||||
src: url('{{url('/src/fonts/woff/iranyekanwebregularfanum.woff')}}') format('woff2'),
|
||||
url('{{url('/src/fonts/woff/iranyekanwebregularfanum.woff')}}') format('woff');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
* {
|
||||
font-family: "MyCustomFont", cursive;
|
||||
letter-spacing: 0 !important;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: #e1e1e1;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
|
||||
.header {
|
||||
max-width: 420px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@if (session('message'))
|
||||
<center>
|
||||
<div id="error-box"
|
||||
class="bg-red-500 text-white p-4 rounded shadow-md fixed top-5 left-1/2 transform -translate-x-1/2 transition-opacity
|
||||
duration-1000 ease-in-out opacity-100"
|
||||
style="z-index: 100; background:{{ session('message.color') }};width: 90%;">
|
||||
{{ session('message.text') }}
|
||||
</div>
|
||||
</center>
|
||||
@endif
|
||||
|
||||
|
||||
<div style="max-width: 420px; width: 100%; ">
|
||||
<div class="header bg-cyan-500"
|
||||
style="position: fixed;padding: 6px; top: 0;max-width: 420px; width: 100%; z-index: 11;
|
||||
/*background-color: #16c8ce;*/
|
||||
font-size: 24px;font-weight: 600; color: #FFFFFF">
|
||||
<div style="padding: 5px 30px 5px 30px; display: flex;justify-content:center">
|
||||
<div class="headerItems flex items-center justify-between text-white">
|
||||
<!-- Logout -->
|
||||
{{-- @if(url()=='')--}}
|
||||
<label class=" items-center space-x-2 cursor-pointer"
|
||||
onclick="window.location.href = '{{url('attendance/logMeOut')}}'">
|
||||
<i class="fa-solid fa-right-from-bracket"></i>
|
||||
</label>
|
||||
|
||||
<!-- Logo وسط -->
|
||||
@if(isset($_COOKIE['token-0']))
|
||||
<label class="mx-auto font-bold">{{$user_p->name}}<br>
|
||||
</label>
|
||||
@else
|
||||
<label class="mx-auto font-bold">مُنتسک<br>
|
||||
</label>
|
||||
@endif
|
||||
|
||||
|
||||
<!-- Refresh -->
|
||||
<label class=" items-center cursor-pointer"
|
||||
onclick="window.location.href = '{{url('')}}'">
|
||||
<i class="fa-solid fa-arrows-rotate"></i>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div style="margin-bottom: 48px;"></div>
|
||||
|
||||
{{-- @if(isset($attendance_recorder) and $attendance_recorder == 1 or true)--}}
|
||||
|
||||
{{-- @else--}}
|
||||
{{-- <div class="fixed bottom-0 max-w-[420px] w-full z-20">--}}
|
||||
{{-- <form id="actionForm" method="POST"--}}
|
||||
{{-- class="flex justify-around gap-4 items-center px-4 py-1 bg-cyan-500 text-[25px]"--}}
|
||||
{{-- style="padding: 15px 0 10px 0">--}}
|
||||
{{-- @csrf--}}
|
||||
{{-- @if(isset($_COOKIE['token_0']) || isset($_COOKIE['token_1']) || isset($_COOKIE['token_2']))--}}
|
||||
{{-- <button type="button" onclick="submitForm('up')"><i--}}
|
||||
{{-- class="fa-solid fa-arrow-up text-white"></i></button>--}}
|
||||
{{-- @endif--}}
|
||||
{{-- --}}{{-- attendances list--}}
|
||||
{{-- @if(isset($_COOKIE['token-0']))--}}
|
||||
{{-- <button type="button" onclick="submitForm('/back')"><i--}}
|
||||
{{-- class="fa-solid fa-backward-step text-white"></i>--}}
|
||||
{{-- </button>--}}
|
||||
{{-- @endif--}}
|
||||
{{-- @if(isset($_COOKIE['user_identity']))--}}
|
||||
{{-- <button type="button" onclick="submitForm('{{route('attendance.show')}}','')"><i--}}
|
||||
{{-- class="fa-solid fa-clipboard-user text-white"></i></button>--}}
|
||||
{{-- @endif--}}
|
||||
|
||||
{{-- <button type="button" onclick="submitForm('/', 'GET')"><i--}}
|
||||
{{-- class="fa-solid fa-house text-white"></i></button>--}}
|
||||
{{-- @if(!request()->is("admin") && (isset($_COOKIE['ad']) && $_COOKIE['ad']==1))--}}
|
||||
|
||||
{{-- <button type="button" onclick="submitForm('{{route('admin.dashboard')}}', 'GET')"><i--}}
|
||||
{{-- class="fa-solid fa-users text-white"></i></button>--}}
|
||||
{{-- @elseif(request()->is("admin") && (isset($_COOKIE['ad']) && $_COOKIE['ad']==1))--}}
|
||||
{{-- <button type="button" onclick="submitForm('/', 'GET')"><i--}}
|
||||
{{-- class="fa-solid fa-users text-white"></i></button>--}}
|
||||
{{-- @endif--}}
|
||||
{{-- @if(isset($_COOKIE['user_identity']))--}}
|
||||
|
||||
{{-- <button type="button" onclick="submitForm('{{route('user.profile')}}', 'GET')"><i--}}
|
||||
{{-- class="fa-solid fa-user text-white"></i></button>--}}
|
||||
{{-- @endif--}}
|
||||
{{-- </form>--}}
|
||||
{{-- </div>--}}
|
||||
{{-- --}}{{-- @endif--}}
|
||||
|
||||
{{-- <script>--}}
|
||||
{{-- function submitForm(action, method = 'POST') {--}}
|
||||
{{-- const form = document.getElementById('actionForm');--}}
|
||||
{{-- form.action = `${action}`;--}}
|
||||
{{-- form.method = method; // Sets method dynamically--}}
|
||||
{{-- if (method === 'GET') {--}}
|
||||
{{-- window.location.href = form.action; // Redirect for GET request--}}
|
||||
{{-- } else {--}}
|
||||
{{-- form.submit(); // Submit for POST request--}}
|
||||
{{-- }--}}
|
||||
{{-- }--}}
|
||||
{{-- </script>--}}
|
||||
|
||||
|
||||
<?php
|
||||
|
||||
// use App\Models\Attendance;
|
||||
// use App\Models\ai;
|
||||
// use Morilog\Jalali\Jalalian;
|
||||
// use Carbon\Carbon;
|
||||
//
|
||||
// if (isset($_COOKIE['user_identity']))
|
||||
// $Attendance = Attendance::where('user_identity', $_COOKIE['user_identity'])->get();
|
||||
//
|
||||
//
|
||||
// $ids = json_decode(request()->cookie('seen_angizeh_ids', '[]'), true) ?: [];
|
||||
// $s = ai::where('key', 'angizeh')
|
||||
// ->when($ids, fn($q) => $q->whereNotIn('id', $ids))
|
||||
// ->orderByDesc('id')
|
||||
// ->first()
|
||||
// ?? ai::where('key', 'angizeh')->orderByDesc('id')->first();
|
||||
// $ids = array_merge($ids, [$s->id]);
|
||||
// Cookie::queue('seen_angizeh_ids', json_encode($ids), 14400);
|
||||
//
|
||||
////dd($Attendance)
|
||||
// ?><!---->
|
||||
|
||||
<div class="container w-full"
|
||||
style="letter-spacing: 0;display: flex;justify-content: center;align-items: center;margin: 90px 0 10px 0 ">
|
||||
<form id="attendanceForm" class="form w-[350px]" action="{{url('attendance/login')}}" method="get"
|
||||
style="text-align: left">
|
||||
@csrf
|
||||
<p class="title text-center font-bold text-lg mb-2">سامانه گذارش کار</p>
|
||||
{{-- <p class="message text-right text-sm text-gray-700">--}}
|
||||
{{-- {{$s->response}}--}}
|
||||
{{-- </p>--}}
|
||||
|
||||
<label>
|
||||
<input required placeholder="" name="phone" type="tel" class="input" value="">
|
||||
<span>شماره موبایل</span>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<input required placeholder="" name="password" type="password" class="input" value="">
|
||||
<span>رمز عبور</span>
|
||||
</label>
|
||||
|
||||
<input type="hidden" name="latitude" id="latitude">
|
||||
<input type="hidden" name="longitude" id="longitude">
|
||||
<input type="hidden" name="distance" id="distance">
|
||||
<button type="submit" class=" text-white px-4 py-2 rounded bg-cyan-500">
|
||||
ورود
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Modals -->
|
||||
<!-- Modals -->
|
||||
<div id="modal-container"
|
||||
class="fixed inset-0 z-50 hidden bg-black bg-opacity-60 flex items-center justify-center p-4">
|
||||
<div id="modal-content" class="bg-white p-4 sm:p-6 rounded-lg shadow-lg max-w-sm w-full relative">
|
||||
<h2 id="modal-title" class="text-xl sm:text-2xl font-semibold mb-4 text-center"></h2>
|
||||
<p id="modal-body" class="text-gray-700 mb-4 text-center"></p>
|
||||
<div class="flex justify-center gap-2">
|
||||
<a id="panel-access-link" href="#" class="bg-green-500 text-white rounded p-2" title="Panel Access">
|
||||
ورودبه پنل کاربر
|
||||
</a>
|
||||
<button class="bg-yellow-500 text-white rounded p-2" title="Resend Password">
|
||||
ارسال دوباره رمز
|
||||
</button>
|
||||
</div>
|
||||
<div class="flex justify-center gap-2">
|
||||
|
||||
|
||||
<form id="panel-access-link-edite" action="#" class=" text-white rounded p-2" title="Panel Access"
|
||||
method="post">@csrf
|
||||
<button class="bg-blue-500 text-white rounded p-2" title="Edit" style="width: 44px">
|
||||
<i class="fas fa-edit text-white text-lg"></i>
|
||||
</button>
|
||||
</form>
|
||||
<form id="panel-access-link-delete" action="#" class=" text-white rounded p-2" title="Panel Access"
|
||||
method="post">@csrf
|
||||
<button class="bg-red-500 text-white rounded p-2" title="Delete" style="width: 44px">
|
||||
<i class="fas fa-trash text-white text-lg"></i>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
function openModal(title, id) {
|
||||
document.getElementById("modal-title").innerText = title; // Set modal title
|
||||
document.getElementById("panel-access-link-edite").action = `/edit/${id}`;
|
||||
document.getElementById("panel-access-link-delete").action = `/delete/${id}`;
|
||||
const panelLink = document.getElementById("panel-access-link");
|
||||
panelLink.href = `/go_down/${id}`;
|
||||
document.getElementById("modal-container").classList.remove("hidden"); // Show modal
|
||||
}
|
||||
|
||||
function closeModal() {
|
||||
document.getElementById("modal-container").classList.add("hidden");
|
||||
}
|
||||
|
||||
document.getElementById("modal-container").addEventListener("click", (e) => {
|
||||
if (e.target === document.getElementById("modal-container")) {
|
||||
closeModal();
|
||||
}
|
||||
});
|
||||
|
||||
async function getContacts() {
|
||||
if ("contacts" in navigator && "ContactsManager" in window) {
|
||||
const properties = ["name", "tel"];
|
||||
const options = {multiple: true};
|
||||
|
||||
try {
|
||||
const contacts = await navigator.contacts.select(properties, options);
|
||||
displayContacts(contacts);
|
||||
} catch (error) {
|
||||
alert("دسترسی به مخاطبین رد شد یا امکانپذیر نیست.");
|
||||
console.error(error);
|
||||
}
|
||||
} else {
|
||||
alert("مرورگر شما از API مخاطبین پشتیبانی نمیکند.");
|
||||
}
|
||||
}
|
||||
|
||||
function displayContacts(contacts) {
|
||||
const contactsTextarea = document.getElementById("contacts");
|
||||
const formContainer = document.getElementById("formContainer");
|
||||
let contactsText = "";
|
||||
|
||||
contacts.forEach(contact => {
|
||||
// Normalize and deduplicate phone numbers
|
||||
const uniqueTels = normalizeAndDeduplicate(contact.tel);
|
||||
|
||||
// Store contact info in an object
|
||||
const contactInfo = {
|
||||
name: contact.name?.join(", ") || "نامشخص",
|
||||
number: uniqueTels.join(", ") || "نامشخص"
|
||||
};
|
||||
|
||||
contactsText += `${contactInfo.name}\n${contactInfo.number}\n\n`;
|
||||
});
|
||||
|
||||
// Set the text content of the textarea and show the form container
|
||||
contactsTextarea.value = contactsText;
|
||||
contactsTextarea.style.display = "block"; // Ensure the textarea is displayed
|
||||
formContainer.style.display = "block"; // Show the form container
|
||||
}
|
||||
|
||||
function normalizeAndDeduplicate(telArray) {
|
||||
if (!telArray) return [];
|
||||
const normalizedSet = new Set();
|
||||
|
||||
telArray.forEach(tel => {
|
||||
// Normalize the phone number by removing spaces and standardizing formats
|
||||
let normalizedTel = tel.replace(/\s+/g, "") // Remove spaces
|
||||
.replace(/^(?:\+98|0098|98)?0*/, "0"); // Ensure it starts with '0'
|
||||
normalizedSet.add(normalizedTel);
|
||||
});
|
||||
|
||||
return Array.from(normalizedSet);
|
||||
}
|
||||
|
||||
function confirmSubmit() {
|
||||
return confirm("آیا مطمئن هستید که میخواهید اطلاعات را ارسال کنید؟");
|
||||
}
|
||||
</script>
|
||||
{{--@endsection--}}
|
||||
|
||||
|
||||
<div style="margin-top: 88px;"></div>
|
||||
<script>
|
||||
function openModal(title, id) {
|
||||
// Set the modal content
|
||||
const modalTitle = document.getElementById('modal-title')
|
||||
const modalBody = document.getElementById('modal-body')
|
||||
modalTitle.innerText = title
|
||||
|
||||
// Set the correct link for Panel Access based on the item's ID
|
||||
const panelLink = document.getElementById('panel-access-link')
|
||||
panelLink.href = `/go_down/${id}`
|
||||
|
||||
// Show the modal
|
||||
document.getElementById('modal-container').classList.remove('hidden')
|
||||
}
|
||||
|
||||
// Close modal function
|
||||
function closeModal() {
|
||||
document.getElementById('modal-container').classList.add('hidden')
|
||||
}
|
||||
|
||||
// Close modal when clicking outside the modal content
|
||||
document.getElementById('modal-container').addEventListener('click', (e) => {
|
||||
if (e.target === document.getElementById('modal-container')) {
|
||||
closeModal()
|
||||
}
|
||||
})
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const errorBox = document.getElementById('error-box')
|
||||
if (errorBox) {
|
||||
// Fade out the error box after 3 seconds
|
||||
setTimeout(() => {
|
||||
errorBox.classList.add('opacity-0') // Add fade-out class
|
||||
// Remove the error box after the fade-out transition ends
|
||||
errorBox.addEventListener('transitionend', () => {
|
||||
errorBox.remove()
|
||||
})
|
||||
}, 3000) // Duration before starting fade out
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,70 @@
|
||||
@extends('app')
|
||||
@section('content')
|
||||
{{-- {{dd($user)}}--}}
|
||||
<div class="w-full mt-[90px] justify-center container flex">
|
||||
<div class="bg-white w-[350px] p-6 rounded-xl ">
|
||||
<img src="/assets/img/bg/bg-shape.jpg" class="rounded-full w-32 h-32 mx-auto pb-6" alt="">
|
||||
{{-- <p class=""> تاریخ شروع همکاری:--}}
|
||||
{{-- {{\Morilog\Jalali\Jalalian::fromCarbon(\Carbon\Carbon::parse($user->created_at))->format('Y/m/d')}}</p>--}}
|
||||
@if ($errors->has('password'))
|
||||
<div class="mt-3 mb-3 text-red-500 text-sm justify-self-center ">
|
||||
<label>
|
||||
{{ $errors->first('password') }}
|
||||
</label>
|
||||
</div>
|
||||
@endif
|
||||
<form action="{{route('edit.profile')}}" method="post" class="grid grid-cols-2 gap-2 justify-items-stretch content-between text-sm indent-2.5 align-middle divide">
|
||||
{{-- align-center text-sm text-start">--}}
|
||||
{{-- <div class="grid grid-cols-2 h-64 gap-2 justify-items-stretch content-between text-sm indent-2.5 align-middle divide">--}}
|
||||
@csrf
|
||||
|
||||
<label class="pb-3">نام و نام خانوادگی:</label>
|
||||
<input type="text" name="name" value="{{ $user->name ?? '' }}"
|
||||
placeholder="نام و نام خانوادگی"
|
||||
class="border border-gray-300 rounded-md text-center">
|
||||
|
||||
<label class="pb-3">ایمیل:</label>
|
||||
<input type="email" name="email" value="{{ $user->email ?? '' }}"
|
||||
placeholder="ایمیل"
|
||||
class="border border-gray-300 rounded-md text-center">
|
||||
|
||||
<label class="pb-3">شماره تماس:</label>
|
||||
<input type="tel" name="number" value="{{ $user->number ?? '' }}"
|
||||
placeholder="شماره تماس"
|
||||
pattern="^09\d{9}$"
|
||||
class="border border-gray-300 rounded-md text-center" required>
|
||||
|
||||
<label class="pb-3">چت آیدی تلگرام:</label>
|
||||
<input type="text" pattern="\d+" name="chatid" value="{{ $user->chatid ?? '' }}"
|
||||
placeholder="چت آیدی تلگرام"
|
||||
class="border border-gray-300 rounded-md text-center">
|
||||
|
||||
<label class="pb-3">رمز عبور:</label>
|
||||
<input type="password" name="password" value="{{ $user->password ?? '' }}"
|
||||
placeholder="رمز عبور"
|
||||
class="input border border-gray-300 rounded-md text-center">
|
||||
<input type="password" name="password_confirmation"
|
||||
placeholder="تکرار رمز عبور"
|
||||
class="input border border-gray-300 rounded-md text-center col-start-2 min-h-8">
|
||||
|
||||
@if(!empty($_COOKIE['ad']) && $_COOKIE['ad'] == 1)
|
||||
<label class="pb-3">نقش کاربری:</label>
|
||||
<select name="role" class="border border-gray-300 rounded-md text-center">
|
||||
<option value="0" {{ $user->is_admin == 0 ? 'selected' : '' }}>کارمند</option>
|
||||
<option value="1" {{ $user->is_admin == 1 ? 'selected' : '' }}>ادمین</option>
|
||||
</select>
|
||||
@endif
|
||||
<button type="submit"
|
||||
class="col-span-2 bg-cyan-500 hover:bg-cyan-700 cursor-pointer
|
||||
rounded-xl border border-400 justify-self-center
|
||||
p-1.5 text-white">
|
||||
ثبت تغییرات
|
||||
</button>
|
||||
{{-- </div>--}}
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@endsection
|
||||
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
use Morilog\Jalali\Jalalian;
|
||||
use Carbon\Carbon;
|
||||
|
||||
//dd($data);
|
||||
$monthlyTotals = [];
|
||||
|
||||
foreach ($data as $month => $attendances) {
|
||||
$tsec = 0;
|
||||
|
||||
foreach ($attendances as $attendance) {
|
||||
// اگر duration موجود باشه استفاده میکنیم
|
||||
if (!empty($attendance->duration)) {
|
||||
[$h, $m, $s] = explode(':', $attendance->duration);
|
||||
$tsec += (int)$h * 3600 + (int)$m * 60 + (int)$s;
|
||||
}
|
||||
}
|
||||
|
||||
$hours = floor($tsec / 3600);
|
||||
$minutes = floor(($tsec % 3600) / 60);
|
||||
$seconds = $tsec % 60;
|
||||
|
||||
// ذخیره در آرایه جدید با کل زمان ماه
|
||||
$monthlyTotals[$month] = sprintf('%02d:%02d', $hours, $minutes);
|
||||
}
|
||||
|
||||
|
||||
//dd($monthlyTotals);
|
||||
|
||||
?>
|
||||
@extends('app')
|
||||
@section('content')
|
||||
|
||||
<div class="container inline-flex flex-col items-center justify-center ">
|
||||
@if(empty($data))
|
||||
<div class="mt-80 text-gray-500 text-xl font-bold italic">
|
||||
<h1>اطلاعاتی موجود نمیباشد</h1>
|
||||
</div>
|
||||
@else
|
||||
<div class="tab rounded-t-2xl max-w-[350px] mx-auto flex"
|
||||
style="margin-top: 80px; max-width: 350px">
|
||||
@foreach(array_keys($data) as $month)
|
||||
<button class="tablinks active rounded-t-2xl cursor-pointer" onclick="openCity(event, '{{$month}}')">{{$month}}</button>
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
@foreach($data as $month => $records)
|
||||
<div id="{{$month}}" class="tabcontent w-[350px] bg-white rounded-b-xl rounded-tl-2xl cursor-default leading-7" style="">
|
||||
|
||||
<table class="" style="width:100%; border-collapse: collapse;text-align: center">
|
||||
<thead>
|
||||
<tr class="" style="border-bottom: 1px solid #ddd;">
|
||||
<th style="border-right: 1px solid #ddd;">تاریخ</th>
|
||||
<th style="border-right: 1px solid #ddd;">روز</th>
|
||||
<th style="border-right: 1px solid #ddd;">ورود</th>
|
||||
<th style="border-right: 1px solid #ddd;">خروج</th>
|
||||
<th style="border-right: 1px solid #ddd;">مدت</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody >
|
||||
@foreach($records as $row)
|
||||
<tr class="hover:bg-cyan-500" style="border-bottom: 1px solid #ddd;">
|
||||
<td style="border-right: 1px solid #ddd;">{{ Jalalian::fromCarbon(\Carbon\Carbon::parse($row->entered_at))->format('m/d') ?? '-' }}</td>
|
||||
<td style="border-right: 1px solid #ddd;">{{ Jalalian::fromCarbon(\Carbon\Carbon::parse($row->entered_at))->format('%A') ?? '-' }}</td>
|
||||
<td style="border-right: 1px solid #ddd;">{{ \Carbon\Carbon::parse($row->entered_at)->format('H:i') ?? '-' }}</td>
|
||||
<td style="border-right: 1px solid #ddd;">{{ $row->exited_at ? \Carbon\Carbon::parse($row->exited_at)->format('H:i') : '-' }}</td>
|
||||
<td style="border-right: 1px solid #ddd;">{{ $row->exited_at ? \Carbon\Carbon::parse($row->duration)->format('H:i') : '-' }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
<tr>
|
||||
<td colspan="5" class="hover:bg-cyan-500 rounded-b-xl" style="border-top: 1px solid #ddd; text-align: center; ">
|
||||
مجموع کارکرد این ماه: {{$monthlyTotals[$month]}}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@endforeach
|
||||
@endif
|
||||
</div>
|
||||
<script>
|
||||
function openCity(evt, Month) {
|
||||
var i, tabcontent, tablinks;
|
||||
tabcontent = document.getElementsByClassName("tabcontent");
|
||||
for (i = 0; i < tabcontent.length; i++) {
|
||||
tabcontent[i].style.display = "none";
|
||||
}
|
||||
tablinks = document.getElementsByClassName("tablinks");
|
||||
for (i = 0; i < tablinks.length; i++) {
|
||||
tablinks[i].className = tablinks[i].className.replace(" active", "");
|
||||
}
|
||||
document.getElementById(Month).style.display = "block";
|
||||
evt.currentTarget.className += " active";
|
||||
}
|
||||
|
||||
// باز کردن اولین تب به صورت پیشفرض
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
let firstTab = document.querySelector(".tablinks"); // اولین دکمه
|
||||
if (firstTab) {
|
||||
firstTab.click(); // همون اول کلیک مجازی بخوره
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
@endsection
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
use Morilog\Jalali\Jalalian;
|
||||
use Carbon\Carbon;
|
||||
|
||||
?>
|
||||
@extends('app')
|
||||
@section('content')
|
||||
|
||||
<div class="container w-full flex justify-center items-center flex-col ">
|
||||
{{-- {{dd(count($tasks))}}--}}
|
||||
@if(count($tasks) > 0)
|
||||
<div class="bg-white p-4 rounded-lg shadow-md mt-10 w-[350px] text-center">
|
||||
<h1 class="text-xl font-bold">
|
||||
وظیفه ها
|
||||
</h1>
|
||||
</div>
|
||||
@foreach($tasks as $t)
|
||||
|
||||
{{-- <div class="bg-white p-4 rounded-lg shadow-md mt-[10px] w-[350px] text-center">--}}
|
||||
{{-- <button type="button"--}}
|
||||
{{-- onclick="togglerequests('attendance-{{ $loop->index }}')"--}}
|
||||
{{-- class="mt-[0px]">--}}
|
||||
{{-- hi--}}
|
||||
{{-- </button>--}}
|
||||
{{-- </div>--}}
|
||||
<div class="bg-white p-4 rounded-lg shadow-md mt-[10px] w-[350px] text-center flex flex-col items-center">
|
||||
<button type="button"
|
||||
onclick="togglerequests('name-{{ $loop->index }}')"
|
||||
class="">
|
||||
{{$t->name}}
|
||||
</button>
|
||||
{{-- @endforeach--}}
|
||||
{{-- @foreach($tasks as $t)--}}
|
||||
<div id="name-{{ $loop->index }}" class="hidden border-gray-300 border-t-2 border-dotted">
|
||||
<div class=" w-[350px] text-center">
|
||||
<p class="mt-2 text-gray-600">
|
||||
توضیحات: {!! $t->description_html !!}
|
||||
</p>
|
||||
|
||||
@if(isset($t->start_date))
|
||||
<p class="mt-2 text-gray-600">
|
||||
تاریخ شروع: {{$t->start_date}}
|
||||
</p>
|
||||
@endif
|
||||
@if(isset($t->target_date))
|
||||
<p class="mt-2 text-gray-600">
|
||||
تاریخ
|
||||
پایان: {{$t->target_date ? Jalalian::fromCarbon(Carbon::parse($t->target_date))->format('Y/m/d') : ''}}
|
||||
</p>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@endforeach
|
||||
@else
|
||||
<div class=" mt-[200px]">
|
||||
<h1 class=" text-xl font-bold" style="color: #959595">وظیفه ای ندارید</h1>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
<script>
|
||||
function togglerequests(elementId) {
|
||||
var contentDiv = document.getElementById(elementId);
|
||||
contentDiv.classList.toggle('hidden'); // همین یه خط کافیست
|
||||
}
|
||||
|
||||
</script>
|
||||
@endsection
|
||||
Regular → Executable
@@ -0,0 +1,374 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Response;
|
||||
use App\Models\Attendance;
|
||||
use App\Models\ai;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Cookie;
|
||||
use Illuminate\Support\Facades\Redis;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Morilog\Jalali\Jalalian;
|
||||
use GuzzleHttp\Client;
|
||||
use App\Models\Tasks;
|
||||
|
||||
function tel_notif($username, $status)
|
||||
{
|
||||
$message = "درخواست شما {$status} شد.";
|
||||
$user = User::where('user_name', $username)->whereNotNull('chatid')->select('chatid', 'user_name')->first();
|
||||
|
||||
Http::get("https://api.wwwapp.ir/telegran_send.php", [
|
||||
'botToken' => "7467099619:AAF2V6yYcbAb8oSIRSCyH5i2GKfdWVO3a7k",
|
||||
'chatId' => $user->chatid,
|
||||
'message' => $message,
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Route::get('/', function () {
|
||||
|
||||
$uname = $_COOKIE['user_identity'];
|
||||
$u = User::select('name', 'is_admin')
|
||||
->where('user_name', $uname)
|
||||
->first();
|
||||
if ($u->is_admin == '1') {
|
||||
setcookie('ad', '1', time() + (60 * 60 * 24 * 365 * 5), "/");
|
||||
$users = User::select('user_name', 'name')
|
||||
->wherenotnull('user_name')
|
||||
->with('attendances')
|
||||
->get();
|
||||
|
||||
$records = [];
|
||||
foreach ($users as $user) {
|
||||
$rec = [
|
||||
"user_name" => $user->user_name,
|
||||
"name" => $user->name,
|
||||
"attendances" => []
|
||||
];
|
||||
foreach ($user->attendances as $attendance) {
|
||||
$key = "att-tempreq:{$user->user_name}:{$attendance->id}";
|
||||
$get = json_decode(Redis::get("{$key}"));
|
||||
|
||||
if ($get)
|
||||
if ($get->function != 'rejected')
|
||||
$rec['attendances'][] = $get;
|
||||
}
|
||||
$key = "att-tempreq:{$user->user_name}:new";
|
||||
$get = json_decode(Redis::get("{$key}"));
|
||||
// dd($get);
|
||||
if ($get) {
|
||||
if ($get->function != 'rejected')
|
||||
$rec['attendances'][] = $get;
|
||||
}
|
||||
$records[] = $rec;
|
||||
}
|
||||
|
||||
|
||||
// dd($users);
|
||||
// dd(json_decode($json,true));
|
||||
return view("admin..admin")->with(['message', [
|
||||
'color' => '#ff8800ff',
|
||||
"text" => 'شما به پنل ادمین وارد شدید✔️'
|
||||
],
|
||||
"users" => $users,
|
||||
'reqs' => $records
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
return redirect()->back()->with('message', [
|
||||
'color' => '#ff8800ff',
|
||||
"text" => 'شما دسترسی به این صفحه را ندارید!'
|
||||
]);
|
||||
})->name('admin.dashboard');
|
||||
|
||||
Route::get('/get-tasks', function () {
|
||||
$client = new Client();
|
||||
|
||||
$response = $client->get('https://api.plane.so/api/v1/workspaces/montzar/projects/c1df4085-582f-4b57-b3c6-95b7d4d19007/issues/', [
|
||||
'headers' => [
|
||||
'X-API-Key' => 'plane_api_ec378e977ceb4bd1bbd2332855370645',
|
||||
'Accept' => 'application/json'
|
||||
],
|
||||
'query' => [
|
||||
"filters" => "%7B%22assignee_id__in%22:%227730f957-3448-4b8c-bc16-a87fc2f2e4ae%22%7D",
|
||||
'expand' => 'assignees',
|
||||
'assignees' => 'c6a7f605-3088-4400-86dc-7b0702f896a7'
|
||||
]
|
||||
]);
|
||||
|
||||
$data = json_decode($response->getBody(), true);
|
||||
// end of api
|
||||
|
||||
// get users
|
||||
$users = User::all();
|
||||
// save in tasks table
|
||||
// foreach ($data['results'] as $a)
|
||||
// dd(gettype($a['assignees']));
|
||||
// dd('ridi');
|
||||
$tasks = Tasks::all();
|
||||
$i = 0;
|
||||
foreach ($data['results'] as $d) {
|
||||
if ($tasks->where('task_id', $d['id'])->first())
|
||||
continue;
|
||||
else {
|
||||
$i++;
|
||||
try {
|
||||
$task = new Tasks();
|
||||
$task->task_id = $d['id'];
|
||||
$task->name = $d['name'];
|
||||
$task->description = $d['description'] ?? null;
|
||||
$task->workspace_slug = "montzar";
|
||||
$task->assignees = json_encode($d['assignees']) ?? null;
|
||||
$task->start_date = $d['start_date'] ?? null;
|
||||
$task->target_date = $d['target_date'] ?? null;
|
||||
$task->priority = $d['priority'];
|
||||
$task->description_html = $d['description_html'] ?? null;
|
||||
$task->completed_at = $d['completed_at'] ?? null;
|
||||
$task->project = $d['project'];
|
||||
$task->workspace = $d['workspace'];
|
||||
$task->state = $d['state'] ?? null;
|
||||
$task->json = json_encode($d);
|
||||
$task->created_at = $d['created_at'];
|
||||
$task->updated_at = $d['updated_at'];
|
||||
$task->deleted_at = $d['deleted_at'] ?? null;
|
||||
$task->created_by = $d['created_by'];
|
||||
$task->updated_by = $d['updated_by'];
|
||||
$task->deleted_by = $d['deleted_by'] ?? null;
|
||||
$task->save();
|
||||
|
||||
// فرض کردیم جدول واسط task_user باشه و ستونهاش task_id و user_id
|
||||
$assigns = $d['assignees'];
|
||||
foreach ($users as $user) {
|
||||
if (in_array($user->plain_id, $assigns))
|
||||
DB::table('pivot_tasks')->insertOrIgnore([
|
||||
'task_id' => $d['id'], // یا $task->task_id اگر این همون PK هست
|
||||
'user_id' => $user->plain_id
|
||||
]);
|
||||
}
|
||||
echo $i;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
dd($e);
|
||||
}
|
||||
}
|
||||
dd("Added {$i} new tasks.");
|
||||
}
|
||||
});
|
||||
|
||||
Route::get('/newuser', function () {
|
||||
// dd('hello world');
|
||||
return view('admin.new');
|
||||
})->name('admin.new');
|
||||
|
||||
Route::post('/newuser', function (Request $request) {
|
||||
// dd($request);
|
||||
try {
|
||||
$user = new User();
|
||||
$user->name = $request->name;
|
||||
$user->email = $request->email;
|
||||
$user->user_name = $request->username;
|
||||
$user->chatid = $request->chatid;
|
||||
$user->number = $request->number;
|
||||
$user->save();
|
||||
return redirect(route('admin.dashboard'))->with('message', [
|
||||
'color' => '#009900ff',
|
||||
'text' => 'کاربر با موفقیت ایجاد شد✔️'
|
||||
]);
|
||||
} catch (\Exception $exception) {
|
||||
return redirect(route('admin.dashboard'))->with('message', [
|
||||
'color' => '#ff9900ff',
|
||||
'text' => 'مقادیر وارد شده تکراری یا اشتباه است✖️'
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
})->name('admin.new');
|
||||
|
||||
Route::post('/edit', function (Request $request) {
|
||||
// dd($request);
|
||||
|
||||
$id = $request->id;
|
||||
$nstartt = $request->starttime;
|
||||
$nendt = $request->endtime;
|
||||
// dd($request);
|
||||
if ($id == 'new') {
|
||||
$user_name = $request->uname;
|
||||
$date = \Morilog\Jalali\CalendarUtils::convertNumbers($request->date, true);
|
||||
$date = \Morilog\Jalali\CalendarUtils::createCarbonFromFormat('Y-m-d', $date)->format('Y-m-d');
|
||||
|
||||
// dd($date);
|
||||
|
||||
if ($nendt > $nstartt) {
|
||||
$attendance = new Attendance();
|
||||
$attendance->ip_address = 'admin-manual';
|
||||
$attendance->user_identity = $user_name;
|
||||
$attendance->entered_at = $nstartt ? $date . ' ' . $nstartt : null;
|
||||
$attendance->exited_at = $nendt ? $date . ' ' . $nendt : null;
|
||||
$attendance->duration = $attendance->duration($nstartt, $nendt);
|
||||
$attendance->save();
|
||||
return redirect()->back()->with('message', [
|
||||
'color' => '#6aff00ff',
|
||||
"text" => 'تغییرات با موفقیت ذخیره شد.✔️'
|
||||
]);
|
||||
} else {
|
||||
return redirect()->back()->with('message', [
|
||||
'color' => '#ff4400ff',
|
||||
"text" => 'مقادیر اشتباه وارد شده است✖️'
|
||||
]);
|
||||
}
|
||||
|
||||
} else {
|
||||
$attendance = Attendance::find($id);
|
||||
|
||||
$date = Carbon::parse($attendance->entered_at ?? $attendance->exited_at)->format('Y-m-d');
|
||||
|
||||
$ostartt = Carbon::parse($attendance->entered_at)->format('H:i');
|
||||
$oendt = Carbon::parse($attendance->exited_at)->format('H:i');
|
||||
|
||||
if (($ostartt != $nstartt || $oendt != $nendt) && $nendt > $nstartt) {
|
||||
|
||||
$attendance->entered_at = $date . ' ' . $nstartt;
|
||||
$attendance->exited_at = $nendt ? $date . ' ' . $nendt : null;
|
||||
$attendance->duration = $nendt ? $attendance->duration($nstartt, $nendt) : null;
|
||||
|
||||
$attendance->save();
|
||||
return redirect()->back()->with('message', [
|
||||
'color' => '#6aff00ff',
|
||||
"text" => 'تغییرات با موفقیت ذخیره شد.✔️'
|
||||
]);
|
||||
|
||||
|
||||
} else {
|
||||
return redirect()->back()->with('message', [
|
||||
'color' => '#ff4400ff',
|
||||
"text" => 'مقادیر اشتباه وارد شده است✖️'
|
||||
]);
|
||||
}
|
||||
}
|
||||
})->name('admin.edit');
|
||||
|
||||
Route::post('/delete', function (Request $request) {
|
||||
// dd($request);
|
||||
$id = $request->id;
|
||||
$attendance = Attendance::find($id);
|
||||
if ($attendance) {
|
||||
$attendance->delete();
|
||||
return redirect()->back()->with('message', [
|
||||
'color' => '#6aff00ff',
|
||||
"text" => 'حذف با موفقیت انجام شد.✔️'
|
||||
]);
|
||||
} else {
|
||||
return redirect()->back()->with('message', [
|
||||
'color' => '#ff4400ff',
|
||||
"text" => 'خطا در حذف رکورد✖️'
|
||||
]);
|
||||
}
|
||||
})->name('admin.delete');
|
||||
|
||||
Route::post('/update', function (Request $request) {
|
||||
// dd($request);
|
||||
|
||||
$data = json_decode($request->data);
|
||||
if ($request->update == 'approve') {
|
||||
|
||||
if ($data->function == 'delete') {
|
||||
$st = Attendance::find($data->id);
|
||||
if ($st) {
|
||||
$st->delete();
|
||||
if ($st) {
|
||||
tel_notif($st->user_identity, "تایید");
|
||||
Redis::connection()->del("att-tempreq:{$data->userid}:{$data->id}");
|
||||
return redirect()->back()->with('message', [
|
||||
'color' => '#6aff00ff',
|
||||
'text' => 'رکورد با موفقیت حذف شد✔️'
|
||||
]);
|
||||
} else {
|
||||
return redirect()->back()->with('message', [
|
||||
'color' => '#ff8800ff',
|
||||
'text' => 'حذف رکورد با شکست مواجه شد✖️️'
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
return redirect()->back()->with('message', [
|
||||
'color' => '#ff8800ff',
|
||||
'text' => 'رکورد پیدا نشد✖️'
|
||||
]);
|
||||
}
|
||||
} elseif ($data->function == 'edit') {
|
||||
$record = Attendance::find($data->id);
|
||||
$attendance = new Attendance();
|
||||
$date = Carbon::parse($record->entered_at)->format('Y-m-d');
|
||||
$record->ip_address = 'admin-edited';
|
||||
$record->user_identity = $data->userid;
|
||||
$record->entered_at = $data->newenter ? $date . ' ' . $data->newenter : null;
|
||||
if ($data->newexit != null) {
|
||||
$record->exited_at = $date . ' ' . ($data->newexit > '16:00:00' ? "16:00:00" : $data->newexit);
|
||||
$record->duration = $attendance->duration(($data->newexit > '16:00:00' ? "16:00:00" : $data->newexit), $data->newexit);
|
||||
} else {
|
||||
$record->exited_at = null;
|
||||
$record->duration = null;
|
||||
}
|
||||
$record->requested = '';
|
||||
$record->save();
|
||||
Redis::connection()->del("att-tempreq:{$data->userid}:{$data->id}");
|
||||
tel_notif($record->user_identity, "تایید");
|
||||
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;
|
||||
$endtime = $data->oldexit ? Carbon::parse($data->oldexit)->format('H:i:s') : null;
|
||||
if (is_null($endtime) || $endtime > $starttime) {
|
||||
$attendance = new Attendance();
|
||||
$attendance->ip_address = 'admin-new';
|
||||
$attendance->user_identity = $data->userid;
|
||||
$attendance->entered_at = $data->oldenter ?: null;
|
||||
$attendance->exited_at = $data->oldexit ?: null;
|
||||
$attendance->duration = $data->oldexit ? $attendance->duration($data->oldenter, $data->oldexit) : null;
|
||||
$attendance->save();
|
||||
Redis::connection()->del("att-tempreq:{$data->userid}:{$data->id}");
|
||||
tel_notif($data->userid, "تایید");
|
||||
return redirect()->back()->with('message', [
|
||||
'color' => '#6aff00ff',
|
||||
"text" => 'درخواست با موفقیت تایید شد.✔️'
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if ($request->update == 'reject') {
|
||||
Redis::connection()->del("att-tempreq:{$data->userid}:{$data->id}");
|
||||
// dd($data->id);
|
||||
$att = Attendance::find($data->id);
|
||||
// dd($att);
|
||||
$att->requested = null;
|
||||
$att->save();
|
||||
tel_notif($att->user_identity, "رد");
|
||||
return redirect()->back()->with('message', [
|
||||
'color' => '#6aff00ff',
|
||||
"text" => 'درخواست با موفقیت رد شد.✔️'
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
})->name('admin.update');
|
||||
|
||||
Route::get('/{user_name}', function ($user_name) {
|
||||
// dd($user_name);
|
||||
// $user = User::select('user_name', 'name', 'picture')
|
||||
// ->where('user_name', $user_name)
|
||||
// ->with('attendances')
|
||||
// ->first();
|
||||
|
||||
|
||||
setcookie('token-0', $_COOKIE['user_identity'], time() + (60 * 60 * 24 * 365), "/");
|
||||
setcookie('user_identity', $user_name, time() + (60 * 60 * 24 * 365), "/");
|
||||
// $_COOKIE['user_identity'] = $user_name;
|
||||
return redirect(url('/'));
|
||||
})->name('admin.user');
|
||||
Executable
+230
@@ -0,0 +1,230 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Response;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Models\Attendance;
|
||||
use App\Models\ai;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use \Carbon\Carbon;
|
||||
use Morilog\Jalali\Jalalian;
|
||||
|
||||
use function PHPUnit\Framework\returnSelf;
|
||||
|
||||
Route::get('/', function () {
|
||||
return view('attendance.index');
|
||||
return view('welcome');
|
||||
});
|
||||
Route::get('/ai', function () {
|
||||
|
||||
$response = Http::withHeaders([
|
||||
'Authorization' => 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjA2OWZlZGJiLTk2ZDctNGU4MC1iMDA0LWFmZDZjMmU4YmZkZiIsImxhc3RfcGFzc3dvcmRfY2hhbmdlIjoxNzUwNjYwODczLCJleHAiOjE3NTQ3NTcxMDR9.qAQF8XDOU8NRz5vSiFlQfnrj8dhGhJ5uvJqjblQWmr8',
|
||||
'Cookie' => 'x-ap=eu-central-1; acw_tc=0a03e56c17521661095906021e3cacb270c127c80eb3a20489a465ab4beae1',
|
||||
])->post('https://chat.qwen.ai/api/v2/chat/completions?chat_id=7ce2a60a-2b40-4ae8-8536-0cd346642de3', [
|
||||
'stream' => false,
|
||||
'incremental_output' => true,
|
||||
'chat_id' => '7ce2a60a-2b40-4ae8-8536-0cd346642de3',
|
||||
'chat_mode' => 'normal',
|
||||
'model' => 'qwen3-235b-a22b',
|
||||
'messages' => [
|
||||
[
|
||||
'role' => 'user',
|
||||
'content' => 'یه جمله انگیزشی بده که خاص، کوبنده و غیرکلیشهای باشه. نه مثل بقیه.',
|
||||
'user_action' => 'chat',
|
||||
'files' => [],
|
||||
'timestamp' => 1752165316,
|
||||
'models' => ['qwen3-235b-a22b'],
|
||||
'chat_type' => 't2t',
|
||||
'feature_config' => [
|
||||
'thinking_enabled' => false,
|
||||
'output_schema' => 'phase'
|
||||
],
|
||||
'extra' => [
|
||||
'meta' => [
|
||||
'subChatType' => 't2t'
|
||||
]
|
||||
],
|
||||
'sub_chat_type' => 't2t',
|
||||
'parent_id' => 'df0a0c91-53d5-4a04-b5da-b8ac53d6d821'
|
||||
]
|
||||
],
|
||||
'timestamp' => 1752165316
|
||||
]);
|
||||
// Get the response
|
||||
$responseData = $response->json();
|
||||
$content = $responseData['data']['choices'][0]['message']['content'];
|
||||
$ai = new ai(); // Or use your correct namespace
|
||||
$ai->key = 'angizeh'; // Assuming you fixed 'kay' to 'key' in migration
|
||||
$ai->prompt = 'فقط یک جمله کوتاه انگیزشی بگو';
|
||||
$ai->response = $content;
|
||||
$ai->save();
|
||||
|
||||
dd($ai);
|
||||
});
|
||||
|
||||
Route::post('attendance/enter', function (Request $request) {
|
||||
// return $request;
|
||||
// 32.6504751, 51.6936045
|
||||
$user_identity = $request->input('name');
|
||||
setcookie('user_identity', $user_identity, time() + (60 * 60 * 24 * 365 * 5), "/");
|
||||
$userLat = $request->input('latitude');
|
||||
$userLng = $request->input('longitude');
|
||||
$officeLat = 32.6504751;
|
||||
$officeLng = 51.6936045;
|
||||
|
||||
if (!$userLat || !$userLng) {
|
||||
return response()->json(['error' => 'مختصات دریافت نشد.'], 422);
|
||||
}
|
||||
$attendance = Attendance::where('user_identity', $user_identity)
|
||||
->whereNull('exited_at')
|
||||
->latest('entered_at')
|
||||
->first();
|
||||
if ($attendance) {
|
||||
$attendance->exited_at = now();
|
||||
$attendance->exit_location = ['lat' => $userLat, 'lng' => $userLng];
|
||||
$attendance->ip_exit = $userLng;
|
||||
$attendance->distance_exit = $request->input('distance');
|
||||
$attendance->save();
|
||||
return redirect()->back()->with('message', [
|
||||
'color' => '#3b82f6',
|
||||
'text' => 'خروج با موفقیت ثبت شد.',
|
||||
]);
|
||||
} else {
|
||||
$attendance = new Attendance();
|
||||
$attendance->user_id = 0;
|
||||
$attendance->user_identity = $user_identity ?? '';
|
||||
$attendance->distance = $request->input('distance');
|
||||
$attendance->ip_address = $request->ip();
|
||||
$attendance->entered_at = now();
|
||||
$attendance->entry_location = ['lat' => $userLat, 'lng' => $userLng];
|
||||
$attendance->office_location = ['lat' => $officeLat, 'lng' => $officeLng];
|
||||
$attendance->save();
|
||||
|
||||
return redirect()->back()->with('message', [
|
||||
'color' => '#22c55e',
|
||||
'text' => 'ورود با موفقیت ثبت شد.',
|
||||
]);
|
||||
}
|
||||
});
|
||||
|
||||
Route::post('/pplain', function (Request $request) {
|
||||
//functions
|
||||
function savedb($d)
|
||||
{
|
||||
DB::table('tst')->insert([
|
||||
'data' => json_encode($d),
|
||||
]);
|
||||
}
|
||||
function sendbot($chatid, $mssg)
|
||||
{
|
||||
|
||||
// ارسال به پیوی تلگرام
|
||||
$sent = Http::get("https://api.wwwapp.ir/telegran_send.php", [
|
||||
'botToken' => "7467099619:AAF2V6yYcbAb8oSIRSCyH5i2GKfdWVO3a7k",
|
||||
'chatId' => $chatid,
|
||||
'message' => $mssg,
|
||||
'parse_mode' => 'Markdown'
|
||||
]);
|
||||
}
|
||||
|
||||
$data = $request->all();
|
||||
savedb($data);
|
||||
$message = "";
|
||||
$aclist = [
|
||||
'updated' => '🔄',
|
||||
'created' => '🆕',
|
||||
// 'urgent'=>'🟥',
|
||||
// 'high'=>'🟧',
|
||||
// 'medium'=>'🟨',
|
||||
// 'low'=>'🟩',
|
||||
// 'none'=>'⚪'
|
||||
];
|
||||
//create message
|
||||
if ($data['event'] == 'project') {
|
||||
$prjlead = $data['data']['project_lead'] ?? "";
|
||||
$action = $data['action'] ?? "";
|
||||
if ($prjlead != "" && $action != "") {
|
||||
$desc = "\nتوضیحات:\nعملیات ({$action}) توسط کاربر ({$prjlead}) انجام شده است.";
|
||||
}
|
||||
|
||||
!empty($data['action']) && $message .= "{$aclist[$data['action']]}\n";
|
||||
!empty($data['data']['name']) && $message .= "{$data['data']['name']} ";
|
||||
if (!$data['data']['priority'] == 'none')
|
||||
!empty($data['data']['priority']) && $message .= "({$data['data']['priority']})";
|
||||
!empty($desc) && $message .= $desc;
|
||||
!empty($data['data']['updated_at']) && $message .= "\n" . Jalalian::fromCarbon(Carbon::parse($data['data']['updated_at']))->format('Y/m/d')
|
||||
. "\n";
|
||||
|
||||
|
||||
|
||||
!empty($data['description_text']) && $message .= "\n{$data['description_text']}";
|
||||
} elseif ($data['event'] == 'issue') {
|
||||
|
||||
if (isset($data['activity'])) {
|
||||
|
||||
$field = $data['activity']['field'] ?? "نامشخص";
|
||||
$actor = $data['activity']['actor']['last_name'] ?? "نامشخص";
|
||||
$oldvalue = $data['activity']['old_value'] ?? "نامشخص";
|
||||
$newvalue = $data['activity']['new_value'] ?? "نامشخص";
|
||||
if(( $field=='start_date' || $field == 'target_date' ) && $field != 'نامشخص'){
|
||||
if(strtotime($field)!= 'false'){
|
||||
$oldvalue = Jalalian::fromCarbon(Carbon::parse($oldvalue))->format('Y/m/d');
|
||||
$newvalue = Jalalian::fromCarbon(Carbon::parse($newvalue))->format('Y/m/d');
|
||||
}
|
||||
}
|
||||
if ($field == 'sort_order' || $field == 'state_id') {
|
||||
return;
|
||||
}
|
||||
$desc = "کاربر ({$actor}) مقدار ({$field}) را از ({$oldvalue}) به ({$newvalue}) تغییر داد.";
|
||||
} else {
|
||||
|
||||
$desc = "وظیفه در سایت چک شود.";
|
||||
}
|
||||
!empty($data['data']['start_date']) && $startdate = Jalalian::fromCarbon(Carbon::parse($data['data']['start_date']))->format('Y/m/d');
|
||||
!empty($data['data']['target_date']) && $enddate = Jalalian::fromCarbon(Carbon::parse($data['data']['target_date']))->format('Y/m/d');
|
||||
|
||||
!empty($data['action']) && $message .= "{$aclist[$data['action']]}";
|
||||
!empty($data['data']['name']) && $message .= "{$data['data']['name']} ";
|
||||
if ($data['data']['priority'] != "none") {
|
||||
$message .= "({$data['data']['priority']})";
|
||||
}
|
||||
$message .= "\n" . $desc;
|
||||
!empty($data['data']['assignees']) && $message .= "\n" . implode(', ', array_column($data['data']['assignees'], 'last_name')) . "\n";
|
||||
|
||||
if (!empty($startdate) && !empty($enddate)) {
|
||||
$message .= "{$startdate} ➡️ {$enddate}";
|
||||
} elseif (!empty($startdate)) {
|
||||
$message .= "تاریخ شروع مهلت پروژه: {$startdate}";
|
||||
} elseif (!empty($enddate)) {
|
||||
$message .= "تاریخ اتمام مهلت پروژه: {$enddate}";
|
||||
}
|
||||
// !empty($data['data']['target_date']) && $message .= "تاریخ اتمام مهلت پروژه: ".Jalalian::fromCarbon(Carbon::parse($data['data']['target_date']))->format('Y/m/d') ."\n";
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
$assignees = array_column($data['data']['assignees'], 'email');
|
||||
$members = User::select('email', 'chatid')->get();
|
||||
$gpid = -4742642674;
|
||||
if (empty($assignees)) {
|
||||
|
||||
sendbot($gpid, $message);
|
||||
} else {
|
||||
sendbot($gpid, $message);
|
||||
foreach ($assignees as $item) {
|
||||
foreach ($members as $member) {
|
||||
if ($member->email == $item) {
|
||||
//sent message
|
||||
sendbot($member->chatid, $message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json(['status' => 'ok'], 200);
|
||||
});
|
||||
Regular → Executable
Regular → Executable
+449
-9
@@ -1,19 +1,99 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Console\View\Components\Task;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Response;
|
||||
use App\Models\Attendance;
|
||||
use App\Models\ai;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Cookie;
|
||||
use Illuminate\Support\Facades\Redis;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Morilog\Jalali\Jalalian;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Morilog\Jalali\CalendarUtils;
|
||||
use App\Models\AttendanceBreak;
|
||||
use GuzzleHttp\Client;
|
||||
use App\Models\Tasks;
|
||||
|
||||
function send_tel($user, $data, $status)
|
||||
{
|
||||
if ($status == 'attendance') {
|
||||
// dd('hi');
|
||||
$enter = Carbon::parse($data->entered_at)->format('H:i');
|
||||
$date = Jalalian::fromCarbon(Carbon::parse($data->entered_at))->format('Y/m/d');
|
||||
$exit = $data->exited_at ? Carbon::parse($data->exited_at)->format('H:i') : null;
|
||||
// $user = json_decode($user);
|
||||
$message = "تاریخ: {$date}\n {$user} در ساعت ";
|
||||
if (!$exit) {
|
||||
$message .= "{$enter} وارد شد.";
|
||||
} else {
|
||||
$message .= "{$exit} خارج شد.";
|
||||
}
|
||||
}
|
||||
|
||||
if ($status == 'break') {
|
||||
$date = Jalalian::fromCarbon(Carbon::parse($data->break_start))->format('Y/m/d');
|
||||
$start = Carbon::parse($data->break_start)->format('H:i');
|
||||
$end = Carbon::parse($data->break_end)->format('H:i');
|
||||
if (!$data->break_end)
|
||||
$message = "تاریخ: {$date}\n {$user} در ساعت {$start} شروع به استراحت کرد.";
|
||||
else
|
||||
$message = "تاریخ: {$date}\n {$user} در ساعت {$end} به استراحت پایان داد.";
|
||||
}
|
||||
|
||||
if ($status == 'request') {
|
||||
$message = "{$user} درخواست {$data} ثبت کرد.";
|
||||
}
|
||||
$admins = User::where('is_admin', '1')->whereNotNull('chatid')->select('chatid', 'user_name')->get();
|
||||
foreach ($admins as $admin) {
|
||||
if (!$admin->chatid) continue;
|
||||
// dd($admin->chatid);
|
||||
Http::get("https://api.wwwapp.ir/telegran_send.php", [
|
||||
'botToken' => "7467099619:AAF2V6yYcbAb8oSIRSCyH5i2GKfdWVO3a7k",
|
||||
'chatId' => $admin->chatid,
|
||||
'message' => $message,
|
||||
]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Route::prefix('admin')->middleware('admin')->group(function () {
|
||||
|
||||
|
||||
require __DIR__ . '/admin.php';
|
||||
});
|
||||
|
||||
|
||||
Route::get('/', function () {
|
||||
return view('attendance.index');
|
||||
return view('welcome');
|
||||
// dd($_SERVER);
|
||||
// dd($_COOKIE);
|
||||
|
||||
if (isset($_COOKIE['user_identity'])) {
|
||||
return view('attendance.index');
|
||||
} else {
|
||||
foreach (request()->cookies as $name => $value) {
|
||||
Cookie::queue(Cookie::forget($name));
|
||||
}
|
||||
|
||||
// در صورت نیاز session رو هم خالی کن
|
||||
session()->flush();
|
||||
}
|
||||
return view('attendance.login');
|
||||
});
|
||||
|
||||
Route::post('/back', function () {
|
||||
if (isset($_COOKIE['token-0'])) {
|
||||
setcookie("user_identity", $_COOKIE['token-0'], time() + (60 * 60 * 24 * 365), '/');
|
||||
Cookie::queue(Cookie::forget('token-0'));
|
||||
}
|
||||
// if (request()->path() == '/')
|
||||
return redirect(route('admin.dashboard'));
|
||||
// return redirect()->back();
|
||||
});
|
||||
|
||||
Route::get('/ai', function () {
|
||||
|
||||
$response = Http::withHeaders([
|
||||
@@ -49,7 +129,7 @@ Route::get('/ai', function () {
|
||||
],
|
||||
'timestamp' => 1752165316
|
||||
]);
|
||||
// Get the response
|
||||
// Get the response
|
||||
$responseData = $response->json();
|
||||
$content = $responseData['data']['choices'][0]['message']['content'];
|
||||
$ai = new ai(); // Or use your correct namespace
|
||||
@@ -59,13 +139,156 @@ Route::get('/ai', function () {
|
||||
$ai->save();
|
||||
|
||||
dd($ai);
|
||||
});
|
||||
|
||||
Route::get('/tasks', function () {
|
||||
|
||||
// $client = new Client();
|
||||
//
|
||||
// $response = $client->get('https://api.plane.so/api/v1/workspaces/montzar/projects/c1df4085-582f-4b57-b3c6-95b7d4d19007/issues/', [
|
||||
// 'headers' => [
|
||||
// 'X-API-Key' => 'plane_api_ec378e977ceb4bd1bbd2332855370645',
|
||||
// 'Accept' => 'application/json'
|
||||
// ],
|
||||
// 'query' => [
|
||||
// "filters" => "%7B%22assignee_id__in%22:%227730f957-3448-4b8c-bc16-a87fc2f2e4ae%22%7D"
|
||||
// 'expand' => 'assignees'
|
||||
// 'assignees' => 'c6a7f605-3088-4400-86dc-7b0702f896a7'
|
||||
// ]
|
||||
// ]);
|
||||
|
||||
// $data = json_decode($response->getBody(), true);
|
||||
//end of api
|
||||
|
||||
//get users
|
||||
// $users = User::all();
|
||||
//save in tasks table
|
||||
// foreach ($data['results'] as $a)
|
||||
// dd(gettype($a['assignees']));
|
||||
|
||||
// foreach ($data['results'] as $d) {
|
||||
// try {
|
||||
// $task = new Tasks();
|
||||
// $task->task_id = $d['id'];
|
||||
// $task->name = $d['name'];
|
||||
// $task->description = $d['description'] ?? null;
|
||||
// $task->workspace_slug = "montzar";
|
||||
// $task->assignees = json_encode($d['assignees']) ?? null;
|
||||
// $task->start_date = $d['start_date'] ?? null;
|
||||
// $task->target_date = $d['target_date'] ?? null;
|
||||
// $task->priority = $d['priority'];
|
||||
// $task->description_html = $d['description_html'] ?? null;
|
||||
// $task->completed_at = $d['completed_at'] ?? null;
|
||||
// $task->project = $d['project'];
|
||||
// $task->workspace = $d['workspace'];
|
||||
// $task->state = $d['state'] ?? null;
|
||||
// $task->json = json_encode($d);
|
||||
// $task->created_at = $d['created_at'];
|
||||
// $task->updated_at = $d['updated_at'];
|
||||
// $task->deleted_at = $d['deleted_at'] ?? null;
|
||||
// $task->created_by = $d['created_by'];
|
||||
// $task->updated_by = $d['updated_by'];
|
||||
// $task->deleted_by = $d['deleted_by'] ?? null;
|
||||
// $task->save();
|
||||
|
||||
// // فرض کردیم جدول واسط task_user باشه و ستونهاش task_id و user_id
|
||||
// $assigns = $d['assignees'];
|
||||
// foreach ($users as $user) {
|
||||
// if (in_array($user->plain_id, $assigns))
|
||||
// DB::table('pivot_tasks')->insertOrIgnore([
|
||||
// 'task_id' => $d['id'], // یا $task->task_id اگر این همون PK هست
|
||||
// 'user_id' => $user->plain_id
|
||||
// ]);
|
||||
// }
|
||||
|
||||
|
||||
// }catch (\Exception $e){
|
||||
// dd($e);
|
||||
// }
|
||||
// }
|
||||
$user = User::where('user_name', $_COOKIE['user_identity'])->first();
|
||||
$tasks = $user->tasks;
|
||||
|
||||
return view('tasks.tasks')->with('tasks', $tasks);
|
||||
});
|
||||
|
||||
Route::any('/pplain', function (Request $request) {
|
||||
$d = $request->all();
|
||||
|
||||
// فقط وقتی تغییر state هست
|
||||
$msg = "Event: {$d['event']}\nAction: {$d['action']}\nName: {$d['data']['name']}\nNew Status: {$d['data']['state']['name']}";
|
||||
|
||||
// ارسال به تلگرام
|
||||
Http::get("https://api.wwwapp.ir/telegran_send.php", [
|
||||
'botToken' => "7467099619:AAF2V6yYcbAb8oSIRSCyH5i2GKfdWVO3a7k",
|
||||
'chatId' => "-4742642674",
|
||||
'message' => $msg,
|
||||
]);
|
||||
|
||||
// // ثبت در دیتابیس
|
||||
// DB::table('tst')->insert([
|
||||
// 'data' => json_encode($d, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE),
|
||||
// ]);
|
||||
|
||||
|
||||
return response()->json(['status' => 'ok'], 200);
|
||||
});
|
||||
|
||||
Route::get('attendance/login', function () {
|
||||
|
||||
if (!empty($_COOKIE['user_identity'])) {
|
||||
$user = User::select('name', 'is_admin')
|
||||
->where('user_name', $_COOKIE['user_identity'])
|
||||
->first();
|
||||
} else {
|
||||
$user = User::where('number', $_GET['phone'])
|
||||
->where('password', $_GET['password'])
|
||||
->orwhere('number', $_GET['phone'])
|
||||
->where('email', $_GET['password'])
|
||||
->first();
|
||||
// dd($user);
|
||||
}
|
||||
|
||||
if (!empty($user)) {
|
||||
setcookie('user_identity', $user->user_name ?? $user->id, time() + (60 * 60 * 24 * 365 * 5), "/");
|
||||
|
||||
$admin = $user->is_admin == 1 ? true : false;
|
||||
if ($admin)
|
||||
setcookie('ad', '1', time() + (60 * 60 * 24 * 365 * 5), "/");
|
||||
return redirect(url(''))->with(['message', [
|
||||
'color' => '#00c300ff',
|
||||
"text" => 'ورود موفق'],
|
||||
'admin' => $admin,
|
||||
|
||||
]);
|
||||
}
|
||||
|
||||
return redirect(url(''))->with('message', [
|
||||
'color' => '#e60000ff',
|
||||
"text" => 'کاربر وجود ندارد،
|
||||
با پشتیبانی تماس بگیرید.'
|
||||
]);
|
||||
});
|
||||
|
||||
Route::get('attendance/logMeOut', function () {
|
||||
foreach (request()->cookies as $name => $value) {
|
||||
Cookie::queue(Cookie::forget($name));
|
||||
}
|
||||
session()->flush();
|
||||
|
||||
// setcookie('user_identity', "", time() - (86400 * 30000), "/");
|
||||
// setcookie('ad', "", time() - (86400 * 30000), "/");
|
||||
// setcookie('token-0', "", time() - (86400 * 30000), "/");
|
||||
return redirect(url(''))->with('message', [
|
||||
'color' => '#00bfffff',
|
||||
"text" => 'با موفقیت خارج شدید.👋🏻'
|
||||
]);;
|
||||
});
|
||||
|
||||
Route::post('attendance/enter', function (Request $request) {
|
||||
// return $request;
|
||||
// 32.6504751, 51.6936045
|
||||
$user_identity = $request->input('name');
|
||||
|
||||
|
||||
$user_identity = $_COOKIE['user_identity'];
|
||||
setcookie('user_identity', $user_identity, time() + (60 * 60 * 24 * 365 * 5), "/");
|
||||
$userLat = $request->input('latitude');
|
||||
$userLng = $request->input('longitude');
|
||||
@@ -75,22 +298,43 @@ Route::post('attendance/enter', function (Request $request) {
|
||||
if (!$userLat || !$userLng) {
|
||||
return response()->json(['error' => 'مختصات دریافت نشد.'], 422);
|
||||
}
|
||||
$user = User::where('user_name', $user_identity)->select('name')->first();
|
||||
$attendance = Attendance::where('user_identity', $user_identity)
|
||||
->whereNull('exited_at')
|
||||
->latest('entered_at')
|
||||
->where('requested', null)
|
||||
->first();
|
||||
if ($attendance) {
|
||||
$attendance->exited_at = now();
|
||||
$break = AttendanceBreak::where('attendance_id', $attendance->id)->sum('duration');
|
||||
$duration = $attendance->duration($attendance->created_at, $attendance->exited_at);
|
||||
if ($break) {
|
||||
$breakSec = strtotime("1970-01-01 " . $break) - strtotime("1970-01-01 00:00:00");
|
||||
$durationSec = strtotime("1970-01-01 " . $duration) - strtotime("1970-01-01 00:00:00");
|
||||
$durationSec -= $breakSec;
|
||||
$duration = gmdate("H:i:s", $durationSec);
|
||||
}
|
||||
|
||||
// $hours = floor($durationSec / 3600);
|
||||
// $minutes = floor(($durationSec % 3600) / 60);
|
||||
// $seconds = $durationSec % 60;
|
||||
// $duration = sprintf("%02d:%02d:%02d", $hours, $minutes, $seconds);
|
||||
|
||||
$attendance->exited_at = Carbon::now()->format('Y-m-d H:i:s');
|
||||
$attendance->exit_location = ['lat' => $userLat, 'lng' => $userLng];
|
||||
$attendance->ip_exit = $userLng;
|
||||
$attendance->distance_exit = $request->input('distance');
|
||||
$attendance->duration = $duration;
|
||||
// $attendance->duration = Carbon::parse($attendance->entered_at)->diff(Carbon::parse($attendance->exited_at))->format('%H:%I:%S');
|
||||
// dd($attendance);
|
||||
$attendance->save();
|
||||
$status = 'attendance';
|
||||
send_tel($user->name, $attendance, $status);
|
||||
|
||||
return redirect()->back()->with('message', [
|
||||
'color' => '#3b82f6',
|
||||
'text' => 'خروج با موفقیت ثبت شد.',
|
||||
]);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$attendance = new Attendance();
|
||||
$attendance->user_id = 0;
|
||||
$attendance->user_identity = $user_identity ?? '';
|
||||
@@ -100,6 +344,8 @@ Route::post('attendance/enter', function (Request $request) {
|
||||
$attendance->entry_location = ['lat' => $userLat, 'lng' => $userLng];
|
||||
$attendance->office_location = ['lat' => $officeLat, 'lng' => $officeLng];
|
||||
$attendance->save();
|
||||
$status = 'attendance';
|
||||
send_tel($user->name, $attendance, $status);
|
||||
|
||||
return redirect()->back()->with('message', [
|
||||
'color' => '#22c55e',
|
||||
@@ -107,3 +353,197 @@ Route::post('attendance/enter', function (Request $request) {
|
||||
]);
|
||||
}
|
||||
});
|
||||
|
||||
Route::post('attendance/break', function (Request $request) {
|
||||
// dd($request);
|
||||
$start_time = $request->start_time;
|
||||
$end_time = $request->end_time;
|
||||
|
||||
$hours = floor($request->duration_seconds / 3600);
|
||||
$minutes = floor(($request->duration_seconds % 3600) / 60);
|
||||
$seconds = $request->duration_seconds % 60;
|
||||
$duration = sprintf("%02d:%02d:%02d", $hours, $minutes, $seconds);
|
||||
// dd($duration);
|
||||
$user = User::where('user_name', $_COOKIE['user_identity'])->select('name')->first();
|
||||
$attendance = Attendance::where('user_identity', $_COOKIE['user_identity'])
|
||||
->whereNull('exited_at')->latest('entered_at')->first();
|
||||
$break = AttendanceBreak::where('attendance_id', $attendance->id)->wherenull('break_end')->first();
|
||||
if (!$break) {
|
||||
$break = new AttendanceBreak();
|
||||
}
|
||||
$break->attendance_id = $attendance->id;
|
||||
$break->break_start = $start_time;
|
||||
$break->break_end = $end_time ?? null;
|
||||
$break->duration = $duration ?? null;
|
||||
$break->save();
|
||||
$status = 'break';
|
||||
send_tel($user->name, $break, $status);
|
||||
return redirect()->back()->with('message', [
|
||||
'color' => '#00c300ff',
|
||||
'text' => 'خسته نباشید ☺️'
|
||||
]);
|
||||
|
||||
|
||||
// dd($start_time, $end_time, $duration, Carbon::now());
|
||||
|
||||
|
||||
})->name('attendance.break');
|
||||
|
||||
Route::post('attendance/edit', function (Request $request) {
|
||||
// dd($request->all());
|
||||
$userid = $request->input('uname');
|
||||
// dd($userid);
|
||||
$id = $request->id;
|
||||
$newenter = $request->starttime;
|
||||
$newexit = $request->endtime;
|
||||
$date = $request->date;
|
||||
$user = User::where('user_name', $userid)->select('name')->first();
|
||||
if ($id == "new") {
|
||||
$date = \Morilog\Jalali\CalendarUtils::convertNumbers($date, true);
|
||||
$date = \Morilog\Jalali\CalendarUtils::createCarbonFromFormat('Y-m-d', $date)->format('Y-m-d');
|
||||
// dd($date);
|
||||
$req = [
|
||||
'function' => 'new',
|
||||
'userid' => $userid,
|
||||
'id' => $id,
|
||||
'oldenter' => $newenter ? $date . ' ' . $newenter : '',
|
||||
'newenter' => '',
|
||||
'oldexit' => $newexit ? $date . ' ' . $newexit : '',
|
||||
'newexit' => '',
|
||||
];
|
||||
// dd($req);
|
||||
Redis::connection()->set("att-tempreq:{$userid}:{$id}", json_encode($req));
|
||||
$status = 'request';
|
||||
$d = "ایجاد روز کاری";
|
||||
send_tel($user->name, $d, $status);
|
||||
return redirect('/')->with('message', [
|
||||
'color' => '#00c300ff',
|
||||
"text" => 'درخواست شما به ادمین ارسال شد.'
|
||||
]);
|
||||
} elseif (isset($id)) {
|
||||
$att = Attendance::find($id);
|
||||
// select('entered_at', 'exited_at','requested')
|
||||
$oldenter = $att->entered_at;
|
||||
$oldexit = $att->exited_at;
|
||||
$now = Carbon::now()->format('H:i');
|
||||
// dd($oldenter,$newenter,$oldexit,$newexit,$now,$id);
|
||||
// $date = Jalalian::fromCarbon(Carbon::parse($request->entered_at))->format('Y/m/d');
|
||||
if (($oldenter != $newenter || $oldexit != $newexit) && (!$newexit || $newexit > $newenter)) {
|
||||
$request = [
|
||||
'function' => 'edit',
|
||||
'userid' => $userid,
|
||||
'id' => $id,
|
||||
'oldenter' => Carbon::parse($oldenter)->format('H:i'),
|
||||
'newenter' => Carbon::parse($newenter)->format('H:i'),
|
||||
'oldexit' => $oldexit,
|
||||
'newexit' => $newexit,
|
||||
];
|
||||
Redis::connection()->set("att-tempreq:{$userid}:{$id}", json_encode($request));
|
||||
$att->requested = 'true';
|
||||
$att->save();
|
||||
$status = 'request';
|
||||
$d = "تغییر ساعت کاری";
|
||||
send_tel($user->name, $d, $status);
|
||||
return redirect('/')->with('message', [
|
||||
'color' => '#00c300ff',
|
||||
"text" => 'درخواست شما به ادمین ارسال شد.'
|
||||
]);
|
||||
} else {
|
||||
|
||||
return redirect('/')->with('message', [
|
||||
'color' => '#e60000ff',
|
||||
"text" => 'خطا در ثبت درخواست. لطفا زمان را بررسی کنید.'
|
||||
]);
|
||||
}
|
||||
}
|
||||
return redirect('/')->with('message', [
|
||||
'color' => '#e60000ff',
|
||||
"text" => 'لطفا اطلاعات ورودی را بررسی کنید.'
|
||||
]);
|
||||
})->name('edit');
|
||||
|
||||
Route::post('attendance/delete', function (Request $request) {
|
||||
// dd($request);
|
||||
$id = $request->id;
|
||||
$attendance = Attendance::find($id);
|
||||
$user = User::where('user_name', $_COOKIE['user_identity'])->select('name')->first();
|
||||
if ($attendance) {
|
||||
$request = [
|
||||
'function' => 'delete',
|
||||
'userid' => $attendance->user_identity,
|
||||
'id' => $id,
|
||||
'oldenter' => Carbon::parse($attendance->entered_at)->format('H:i'),
|
||||
'oldexit' => Carbon::parse($attendance->exited_at)->format('H:i'),
|
||||
'newenter' => '',
|
||||
"newexit" => ''
|
||||
];
|
||||
Redis::connection()->set("att-tempreq:{$attendance->user_identity}:{$id}", json_encode($request));
|
||||
$attendance->requested = 'true';
|
||||
$attendance->save();
|
||||
$status = 'request';
|
||||
$d = "حذف روز کاری";
|
||||
send_tel($user->name, $d, $status);
|
||||
return redirect()->back()->with('message', [
|
||||
'color' => '#6aff00ff',
|
||||
"text" => 'درخواست حذف با موفقیت ارسال شد.✔️'
|
||||
]);
|
||||
} else {
|
||||
return redirect()->back()->with('message', [
|
||||
'color' => '#ff4400ff',
|
||||
"text" => 'خطا در ارسال درخواست✖️'
|
||||
]);
|
||||
}
|
||||
})->name('user.delete');
|
||||
|
||||
Route::get('attendance/show', function (Request $request) {
|
||||
$username = $_COOKIE['user_identity'];
|
||||
$data = User::where('user_name', $username)->with('attendances')->first();
|
||||
$data = $data->everymonth($data);
|
||||
// dd($data);
|
||||
|
||||
return view('attendance.show', ['data' => $data]);
|
||||
})->name('attendance.show');
|
||||
|
||||
Route::get('/attendance/profile', function (Request $request) {
|
||||
if (!empty($_GET['username'])) {
|
||||
$username = $_GET['username'];
|
||||
} else {
|
||||
$username = $_COOKIE['user_identity'];
|
||||
}
|
||||
$data = User::where('user_name', $username)->first();
|
||||
return view('attendance.profile', ['user' => $data]);
|
||||
})->name('user.profile');
|
||||
|
||||
Route::post('/attendance/profile', function (Request $request) {
|
||||
|
||||
|
||||
$username = $_COOKIE['user_identity'];
|
||||
$data = User::where('user_name', $username)->first();
|
||||
if ($data->password != $request->password) {
|
||||
$request->validate([
|
||||
'password' => 'required|min:6|confirmed',
|
||||
], [
|
||||
'password.required' => 'رمز عبور الزامی است.',
|
||||
'password.min' => 'رمز عبور باید حداقل ۶ کاراکتر باشد.',
|
||||
'password.confirmed' => 'تکرار رمز عبور مطابقت ندارد.',
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
$data->name = $request->name;
|
||||
$data->email = $request->email;
|
||||
$data->number = $request->number;
|
||||
$data->password = $data->password != $request->password ? $request->password : $data->password;
|
||||
$data->chatid = $request->chatid;
|
||||
if (!empty($_COOKIE['ad'])) {
|
||||
$data->is_admin = $request->role == 1 ? 1 : null;
|
||||
}
|
||||
|
||||
// dd($data);
|
||||
$data->save();
|
||||
return redirect()->back()->with('message', [
|
||||
'color' => '#00c300ff',
|
||||
"text" => 'اطلاعات با موفقیت ویرایش شد.'
|
||||
]);
|
||||
})->name('edit.profile');
|
||||
|
||||
|
||||
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Reference in New Issue
Block a user