NASER add taskززطزSQLSTATE[42000]: Syntax error or access violation: 1305 FUNCTION montask.ST_SetSRID does not exist (Connection: mysql, SQL: update ttendances set ip_exit = 51.684726144224, distance_exit = 850, exited_at = 2026-04-23 13:59:46, exit_location = ST_SetSRID(ST_Point(51.684726144224, 32.652053279154), 4326), duration = 04:59:46, ttendances.updated_at = 2026-04-23 13:59:46 where id = 937)
This commit is contained in:
Notes:
mobinesaghi
2026-04-23 14:42:21 +03:30
NASER add task functions undepended
@@ -1,11 +1,127 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
use App\Models\Log;
|
||||
use App\Models\Setting;
|
||||
abstract class Controller
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
abstract class Controller
|
||||
{
|
||||
public static function Config($name)
|
||||
{
|
||||
return Setting::where('key',$name)->first()->value ?? false;
|
||||
}
|
||||
}
|
||||
|
||||
public function fa2en_numbers($input)
|
||||
{
|
||||
if (is_string($input)) {
|
||||
$fa_numbers = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹'];
|
||||
$en_numbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
|
||||
return str_replace($fa_numbers, $en_numbers, $input);
|
||||
} elseif (is_array($input)) {
|
||||
return array_map([$this, __FUNCTION__], $input);
|
||||
} else {
|
||||
return $input;
|
||||
}
|
||||
}
|
||||
|
||||
public function send($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::whereIn('is_admin', [1,2])->whereNotNull('chatid')->select('chatid', 'bale', 'user_name')->get();
|
||||
if ($_COOKIE['user_identity'] !== 'test') {
|
||||
foreach ($admins as $admin) {
|
||||
if (!$admin->bale) {continue;}
|
||||
// dd($admin->chatid);
|
||||
// Http::get("https://api.wwwapp.ir/telegran_send.php", [
|
||||
// 'botToken' => "7467099619:AAF2V6yYcbAb8oSIRSCyH5i2GKfdWVO3a7k",
|
||||
// 'chatId' => $admin->chatid,
|
||||
// 'message' => $message,
|
||||
// ]);
|
||||
if ($admin->bale) {
|
||||
try {
|
||||
$response = Http::post('https://tapi.bale.ai/1482838710:sYbLzby0tuLRzHvP4d3LsbcNwg2sjSDLTAU/sendMessage', [
|
||||
"chat_id" => $admin->bale,
|
||||
'text' => $message,
|
||||
]);
|
||||
}catch (\Exception $e){}
|
||||
}
|
||||
Log::create([
|
||||
'error' => $response->body(),
|
||||
'user' => "کاربر: $user
|
||||
ادمین: {$admin->user_name}",
|
||||
]);
|
||||
}
|
||||
}else{
|
||||
try {
|
||||
$response = Http::post('https://tapi.bale.ai/1482838710:sYbLzby0tuLRzHvP4d3LsbcNwg2sjSDLTAU/sendMessage', [
|
||||
"chat_id" => '985309723',
|
||||
'text' => $message,
|
||||
]);
|
||||
}catch (\Exception $e){}
|
||||
}
|
||||
// return $message;
|
||||
}
|
||||
|
||||
public function send_admins($message)
|
||||
{
|
||||
$admins = User::whereNotNull('is_admin')->whereNotNull('bale')->select('bale')->get();
|
||||
|
||||
foreach ($admins as $admin) {
|
||||
try{
|
||||
Http::/*withOptions([
|
||||
'curl' => [
|
||||
CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4,
|
||||
CURLOPT_TCP_FASTOPEN => 1,
|
||||
]
|
||||
])->*/withoutVerifying()->post('https://tapi.bale.ai/1482838710:sYbLzby0tuLRzHvP4d3LsbcNwg2sjSDLTAU/sendMessage', [
|
||||
"chat_id" => $admin->bale,
|
||||
'text' => $message,
|
||||
]);
|
||||
}catch (\Exception $e){}
|
||||
}
|
||||
}
|
||||
|
||||
public function send_level1_admins($message)
|
||||
{
|
||||
$admins = User::where('is_admin', 1)->whereNotNull('bale')->select('bale')->get();
|
||||
|
||||
foreach ($admins as $admin) {
|
||||
try {
|
||||
Http::withoutVerifying()->post('https://tapi.bale.ai/1482838710:sYbLzby0tuLRzHvP4d3LsbcNwg2sjSDLTAU/sendMessage', [
|
||||
"chat_id" => $admin->bale,
|
||||
'text' => $message,
|
||||
]);
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user