|
|
@@ -47,18 +47,8 @@ class LaborReport extends Model
|
|
|
public function laborReportStatus(){
|
|
|
return $this->hasMany('App\LaborReportStatus','labor_report_id','id');
|
|
|
}
|
|
|
- public function 未审核(){
|
|
|
- return $this->hasOne('App\LaborReportStatus','labor_report_id','id')
|
|
|
- ->where('status','未审核');
|
|
|
- }
|
|
|
- public function 已退场(){
|
|
|
- return $this->hasOne('App\LaborReportStatus','labor_report_id','id')
|
|
|
- ->where('status','已退场');
|
|
|
- }
|
|
|
- public function remarks(){
|
|
|
- return $this->hasOne('App\Sign','signable_id','id')
|
|
|
- ->where('field','remark')->where('signable_type','labor_reports');
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
public function getRoundCheckInAtAttribute(){
|
|
|
if (!$this['check_in_at'])return null;
|
|
|
$round_check_in_at=Carbon::parse($this['check_in_at'])->format('i');
|
|
|
@@ -73,11 +63,6 @@ class LaborReport extends Model
|
|
|
if ($round_check_out_at>=25&&$round_check_out_at<=55) return Carbon::parse($this['check_out_at'])->clone()->setMinutes(30)->setSeconds(00)->format('Y-m-d H:i:s');
|
|
|
if ($round_check_out_at>55&&$round_check_out_at<=59) return Carbon::parse($this['check_out_at'])->clone()->addHour()->setMinutes(00)->setSeconds(00)->format('Y-m-d H:i:s');
|
|
|
}
|
|
|
-// public function getRemarkAttribute(){
|
|
|
-//// $this->hasOne('App\Sign','signable_id','id')
|
|
|
-//// ->where('field','remark')->where('signable_type','labor_reports')->value('mark');
|
|
|
-// return $this['remarks']?$this['remarks']['mark']:null;
|
|
|
-// }
|
|
|
public function getHasGroupVerifyRightAttribute(){
|
|
|
if (!Gate::allows('人事管理-临时工报表')){return null; }
|
|
|
if (Gate::allows('人事管理-临时工报表-管理全部组')){return true;}
|
|
|
@@ -217,10 +202,11 @@ class LaborReport extends Model
|
|
|
//进场时间
|
|
|
public function getEnterAtAttribute()
|
|
|
{
|
|
|
+ if ($this['userDutyCheck']&&$this['userDutyCheck']['type']=='登入')
|
|
|
+ return $this['userDutyCheck']?$this['userDutyCheck']['checked_at']:null;
|
|
|
// $laborReportStatus=LaborReportStatus::where('labor_report_id',$this['id'])->where('status','未审核')->orderBy('id','desc')->first();
|
|
|
// if (empty($laborReportStatus))return null;
|
|
|
// return Carbon::parse($laborReportStatus['created_at'])->format('Y-m-d H:i:s');
|
|
|
- return $this['未审核']?Carbon::parse($this['未审核']['created_at'])->format('Y-m-d H:i:s'):null;
|
|
|
}
|
|
|
|
|
|
public function getEnteringRecordAttribute()
|
|
|
@@ -235,10 +221,11 @@ class LaborReport extends Model
|
|
|
|
|
|
public function getExitAtAttribute()
|
|
|
{
|
|
|
- //$laborReportStatus=LaborReportStatus::where('labor_report_id',$this['id'])->where('status','已退场')->orderBy('id','desc')->first();
|
|
|
- //if (empty($laborReportStatus))return null;
|
|
|
- //return Carbon::parse($laborReportStatus['created_at'])->format('Y-m-d H:i:s');
|
|
|
- return $this['已退场']?Carbon::parse($this['已退场']['created_at'])->format('Y-m-d H:i:s'):null;
|
|
|
+ if ($this['userDutyCheck']&&$this['userDutyCheck']['type']=='登出')
|
|
|
+ return $this['userDutyCheck']?$this['userDutyCheck']['checked_at']:null;
|
|
|
+// $laborReportStatus=LaborReportStatus::where('labor_report_id',$this['id'])->where('status','已退场')->orderBy('id','desc')->first();
|
|
|
+// if (empty($laborReportStatus))return null;
|
|
|
+// return Carbon::parse($laborReportStatus['created_at'])->format('Y-m-d H:i:s');
|
|
|
}
|
|
|
|
|
|
//创建或获取进场编号
|
|
|
@@ -252,9 +239,8 @@ class LaborReport extends Model
|
|
|
}
|
|
|
|
|
|
public function getIsExportAttribute(){
|
|
|
-// $laborReportStatus=LaborReportStatus::where('labor_report_id',$this['id'])->orderBy('id','desc')->first();
|
|
|
-// return $laborReportStatus['status']=='已退场'?true:false;
|
|
|
- return $this['已退场']?true:false;
|
|
|
+ $laborReportStatus=$this->laborReportStatus()->where('labor_report_id',$this['id'])->orderBy('id','desc')->first();
|
|
|
+ return $laborReportStatus['status']=='已退场'?true:false;
|
|
|
}
|
|
|
//出场更新临时工报表信息
|
|
|
static function exitAndChangeLaborReport($laborReport,$userDutyCheck){
|