Bổ sung check nếu là WFH thì check in cho user
This commit is contained in:
parent
8b5eadfbcf
commit
688c521986
|
|
@ -13,8 +13,10 @@ use Carbon\Carbon;
|
|||
use Carbon\CarbonPeriod;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Modules\Admin\app\Models\Admin;
|
||||
use Modules\Admin\app\Models\Category;
|
||||
use Modules\Admin\app\Models\Ticket;
|
||||
use Modules\Admin\app\Models\Tracking;
|
||||
|
||||
class TicketController extends Controller
|
||||
{
|
||||
|
|
@ -288,9 +290,7 @@ class TicketController extends Controller
|
|||
// Update updated_by and admin_note in tickets table
|
||||
|
||||
// Send notification email to users
|
||||
|
||||
if ($action == "confirm") {
|
||||
// dd($results);
|
||||
foreach ($results as $result) {
|
||||
list($year, $month, $day) = explode('-', $result['date']);
|
||||
Notes::create([
|
||||
|
|
@ -303,35 +303,37 @@ class TicketController extends Controller
|
|||
'n_note' => $ticket->reason
|
||||
]);
|
||||
|
||||
if($ticket->type == "WFH"){
|
||||
// $user_ids = $request->users;
|
||||
// $year = $request->year;
|
||||
// $month = $request->month;
|
||||
// $day = $request->day;
|
||||
// $type = $request->type;
|
||||
// foreach ($user_ids as $id) {
|
||||
// $user = Admin::find($id);
|
||||
// $date = Carbon::create($year, $month, $day)->setTimezone(env('TIME_ZONE'));
|
||||
// $start = $date->copy()->setTime(7, 31, 11);
|
||||
// $end = $type == 'half' ? $date->copy()->setTime(11, 31, 11) : $date->copy()->setTime(17, 1, 11);
|
||||
// Tracking::insert([
|
||||
// [
|
||||
// 'name' => $user->name,
|
||||
// 'user_id' => $user->id,
|
||||
// 'status' => 'check in',
|
||||
// 'time_string' => $start->format('Y-m-d H:i:s'),
|
||||
// 'created_at' => $start->setTimezone('UTC')
|
||||
// ],
|
||||
// [
|
||||
// 'name' => $user->name,
|
||||
// 'user_id' => $user->id,
|
||||
// 'status' => 'check out',
|
||||
// 'time_string' => $end->format('Y-m-d H:i:s'),
|
||||
// 'created_at' => $end->setTimezone('UTC')
|
||||
// ]
|
||||
// ]);
|
||||
// }
|
||||
// $this->createOrUpdateRecordForCurrentMonth($month, $year);
|
||||
if ($ticket->type == "WFH") {
|
||||
$type = $result['period'];
|
||||
$user = Admin::find($ticket->user_id);
|
||||
$date = Carbon::create($year, $month, $day)->setTimezone(env('TIME_ZONE'));
|
||||
|
||||
//Default: ALL
|
||||
$start = $date->copy()->setTime(7, 31, 11);
|
||||
$end = $date->copy()->setTime(17, 1, 11);
|
||||
|
||||
if ($type == 'S') {
|
||||
$end = $date->copy()->setTime(11, 31, 11);
|
||||
} else if ($type == 'C') {
|
||||
$start = $date->copy()->setTime(11, 31, 11);
|
||||
}
|
||||
|
||||
Tracking::insert([
|
||||
[
|
||||
'name' => $user->name,
|
||||
'user_id' => $user->id,
|
||||
'status' => 'check in',
|
||||
'time_string' => $start->format('Y-m-d H:i:s'),
|
||||
'created_at' => $start->setTimezone('UTC')
|
||||
],
|
||||
[
|
||||
'name' => $user->name,
|
||||
'user_id' => $user->id,
|
||||
'status' => 'check out',
|
||||
'time_string' => $end->format('Y-m-d H:i:s'),
|
||||
'created_at' => $end->setTimezone('UTC')
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -911,6 +911,13 @@ const Timekeeping = () => {
|
|||
id: user.user.id,
|
||||
name: user.user.name,
|
||||
},
|
||||
notes:
|
||||
user.history.find(
|
||||
(h) =>
|
||||
h.day === d &&
|
||||
h.notes &&
|
||||
h.notes.length > 0,
|
||||
)?.notes ?? [],
|
||||
})
|
||||
}}
|
||||
/>
|
||||
|
|
@ -938,6 +945,13 @@ const Timekeeping = () => {
|
|||
id: user.user.id,
|
||||
name: user.user.name,
|
||||
},
|
||||
notes:
|
||||
user.history.find(
|
||||
(h) =>
|
||||
h.day === d &&
|
||||
h.notes &&
|
||||
h.notes.length > 0,
|
||||
)?.notes ?? [],
|
||||
})
|
||||
}}
|
||||
/>
|
||||
|
|
@ -966,6 +980,13 @@ const Timekeeping = () => {
|
|||
id: user.user.id,
|
||||
name: user.user.name,
|
||||
},
|
||||
notes:
|
||||
user.history.find(
|
||||
(h) =>
|
||||
h.day === d &&
|
||||
h.notes &&
|
||||
h.notes.length > 0,
|
||||
)?.notes ?? [],
|
||||
})
|
||||
}}
|
||||
/>
|
||||
|
|
@ -1029,6 +1050,13 @@ const Timekeeping = () => {
|
|||
id: user.user.id,
|
||||
name: user.user.name,
|
||||
},
|
||||
notes:
|
||||
user.history.find(
|
||||
(h) =>
|
||||
h.day === d &&
|
||||
h.notes &&
|
||||
h.notes.length > 0,
|
||||
)?.notes ?? [],
|
||||
})
|
||||
}}
|
||||
/>
|
||||
|
|
|
|||
Loading…
Reference in New Issue