Browse Source

add discount_id

pull/1/head
farhantock 9 months ago
parent
commit
53b37f87ea
  1. 3
      app/Models/Company.php
  2. 71
      app/Models/User.php

3
app/Models/Company.php

@ -34,6 +34,7 @@ class Company extends Model
'updated_by', 'updated_by',
'cluster', 'cluster',
'type_account', 'type_account',
'date_register' 'date_register',
'discount_id'
]; ];
} }

71
app/Models/User.php

@ -11,7 +11,7 @@ use Illuminate\Database\Eloquent\Model;
use Laravel\Lumen\Auth\Authorizable; use Laravel\Lumen\Auth\Authorizable;
use Carbon\Carbon; use Carbon\Carbon;
class User extends Model implements AuthenticatableContract, AuthorizableContract,JWTSubject class User extends Model implements AuthenticatableContract, AuthorizableContract, JWTSubject
{ {
use Authenticatable, Authorizable, HasFactory; use Authenticatable, Authorizable, HasFactory;
@ -24,7 +24,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
protected $fillable = [ protected $fillable = [
'name', 'email', 'role_id', 'username', 'session_login', 'phone_number', 'email', 'address', 'name', 'email', 'role_id', 'username', 'session_login', 'phone_number', 'email', 'address',
'fcm_token', 'gender', 'birth_place', 'birth_date', 'blood_type', 'ktp_number', 'working_hours', 'fcm_token', 'gender', 'birth_place', 'birth_date', 'blood_type', 'ktp_number', 'working_hours',
'created_at', 'created_by', 'updated_at', 'updated_by', 'status_resource' 'created_at', 'created_by', 'updated_at', 'updated_by', 'status_resource', 'discount_id'
]; ];
const CREATED_AT = 'created_at'; const CREATED_AT = 'created_at';
@ -74,41 +74,39 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
public function getWorkingTime(Carbon $ts, $f = "08:00", $t = "17:00", $tz = self::DEFAULT_TZ) public function getWorkingTime(Carbon $ts, $f = "08:00", $t = "17:00", $tz = self::DEFAULT_TZ)
{ {
$workingTime = array( $workingTime = array(
"from"=> Carbon::createFromTimeString($f, $tz), "from" => Carbon::createFromTimeString($f, $tz),
"to"=> Carbon::createFromTimeString($t, $tz) "to" => Carbon::createFromTimeString($t, $tz)
); );
$userShift = UserShift::where('user_id', ) $userShift = UserShift::where('user_id',)
->orderByDesc('from_date') ->orderByDesc('from_date')
->first(); ->first();
$shift = null; $shift = null;
if ($userShift !== null) if ($userShift !== null) {
{
$shiftId = null; $shiftId = null;
switch ($ts->shortEnglishDayOfWeek) switch ($ts->shortEnglishDayOfWeek) {
{ case "Mon":
case "Mon": $shiftId = $userShift->mon_shift_id;
$shiftId = $userShift->mon_shift_id; break;
break; case "Tue":
case "Tue": $shiftId = $userShift->tue_shift_id;
$shiftId = $userShift->tue_shift_id; break;
break; case "Wed":
case "Wed": $shiftId = $userShift->wed_shift_id;
$shiftId = $userShift->wed_shift_id; break;
break; case "Thu":
case "Thu": $shiftId = $userShift->thu_shift_id;
$shiftId = $userShift->thu_shift_id; break;
break; case "Fri":
case "Fri": $shiftId = $userShift->fri_shift_id;
$shiftId = $userShift->fri_shift_id; break;
break; case "Sat":
case "Sat": $shiftId = $userShift->sat_shift_id;
$shiftId = $userShift->sat_shift_id; break;
break; case "Sun":
case "Sun": $shiftId = $userShift->sun_shift_id;
$shiftId = $userShift->sun_shift_id; break;
break;
} }
if ($shiftId === null) { if ($shiftId === null) {
@ -123,8 +121,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
} }
if ($shift !== null) if ($shift !== null) {
{
$from = Carbon::createFromTimeString($shift->start_time, $tz) $from = Carbon::createFromTimeString($shift->start_time, $tz)
->subMinutes($shift->flex_time_minute); ->subMinutes($shift->flex_time_minute);
$to = Carbon::createFromTimeString($shift->end_time, $tz) $to = Carbon::createFromTimeString($shift->end_time, $tz)
@ -150,16 +147,14 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
{ {
$ts = $at; $ts = $at;
if ($at !== null) if ($at !== null) {
{
$ts = Carbon::now($tz); $ts = Carbon::now($tz);
} }
$tsSec = $ts->secondsSinceMidnight(); $tsSec = $ts->secondsSinceMidnight();
$status = ""; $status = "";
$wt = $this->getWorkingTime($ts, $tz); $wt = $this->getWorkingTime($ts, $tz);
if ($wt === null) if ($wt === null) {
{
$status = self::HOLIDAY; $status = self::HOLIDAY;
} else { } else {
$from = $wt->from; $from = $wt->from;
@ -168,7 +163,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
$tsTo = $to->secondsSinceMidnight(); $tsTo = $to->secondsSinceMidnight();
if ($from->greaterThan($to)) { if ($from->greaterThan($to)) {
$tsMid = 24*60*60 - $tsFrom; $tsMid = 24 * 60 * 60 - $tsFrom;
if ($tsSec >= $tsFrom || $tsSec < $tsTo) { if ($tsSec >= $tsFrom || $tsSec < $tsTo) {
$status = self::INSIDE; $status = self::INSIDE;
} else { } else {
@ -194,7 +189,7 @@ class User extends Model implements AuthenticatableContract, AuthorizableContrac
} }
return array( return array(
"status"=>$status, "status" => $status,
"ts" => $ts, "ts" => $ts,
"clock_in" => $clockIn, "clock_in" => $clockIn,
"clock_out" => $clockOut "clock_out" => $clockOut

Loading…
Cancel
Save