|
|
@@ -21,7 +21,7 @@ class LaborReport extends Model
|
|
|
];
|
|
|
protected $appends = [
|
|
|
'is_exportGroup','is_export', 'exit_at','enter_at','sequence', 'amountOfJoined','remark','thisRecordOnlineTime','thisRecordWorkingTime','thisRoundRecordWorkingTime',
|
|
|
- 'totalOnlineTime','verifyPerson','userDutyCheckVerifyUserId','isAdult','round_check_in_at','round_check_out_at','has_group_verify_right'
|
|
|
+ 'totalOnlineTime','verifyPerson','userDutyCheckVerifyUserId','isAdult','round_check_in_at','round_check_out_at','has_group_verify_right',
|
|
|
];
|
|
|
protected $tempFields = [
|
|
|
'temEnteringRecord',
|
|
|
@@ -47,12 +47,23 @@ 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');
|
|
|
if ($round_check_in_at>=0&&$round_check_in_at<=5) return Carbon::parse($this['check_in_at'])->clone()->setMinutes(00)->setSeconds(00)->format('Y-m-d H:i:s');
|
|
|
if ($round_check_in_at>5&&$round_check_in_at<=35) return Carbon::parse($this['check_in_at'])->clone()->setMinutes(30)->setSeconds(00)->format('Y-m-d H:i:s');
|
|
|
- //if ($round_check_in_at==30) return Carbon::parse($this['check_in_at'])->clone()->setMinutes(30)->setSeconds(00)->format('Y-m-d H:i:s');
|
|
|
if ($round_check_in_at>35&&$round_check_in_at<=59) return Carbon::parse($this['check_in_at'])->clone()->addHour()->setMinutes(00)->setSeconds(00)->format('Y-m-d H:i:s');
|
|
|
}
|
|
|
public function getRoundCheckOutAtAttribute(){
|
|
|
@@ -60,12 +71,12 @@ class LaborReport extends Model
|
|
|
$round_check_out_at=Carbon::parse($this['check_out_at'])->format('i');
|
|
|
if ($round_check_out_at>=0&&$round_check_out_at<25) return Carbon::parse($this['check_out_at'])->clone()->setMinutes(00)->setSeconds(00)->format('Y-m-d H:i:s');
|
|
|
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==30) 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(){
|
|
|
- return $this->hasOne('App\Sign','signable_id','id')
|
|
|
- ->where('field','remark')->where('signable_type','labor_reports')->value('mark');
|
|
|
+// $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; }
|
|
|
@@ -210,9 +221,8 @@ class LaborReport extends Model
|
|
|
{
|
|
|
// $laborReportStatus=LaborReportStatus::where('labor_report_id',$this['id'])->where('status','未审核')->orderBy('id','desc')->first();
|
|
|
// if (empty($laborReportStatus))return null;
|
|
|
- $laborReportStatus=$this->laborReportStatus()->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 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()
|
|
|
@@ -227,11 +237,10 @@ 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;
|
|
|
- $laborReportStatus=$this->laborReportStatus()->where('status','已退场')->orderBy('id','desc')->first();
|
|
|
- if (empty($laborReportStatus))return null;
|
|
|
- return Carbon::parse($laborReportStatus['created_at'])->format('Y-m-d H:i:s');
|
|
|
+ //$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;
|
|
|
}
|
|
|
|
|
|
//创建或获取进场编号
|
|
|
@@ -245,8 +254,9 @@ class LaborReport extends Model
|
|
|
}
|
|
|
|
|
|
public function getIsExportAttribute(){
|
|
|
- $laborReportStatus=LaborReportStatus::where('labor_report_id',$this['id'])->orderBy('id','desc')->first();
|
|
|
- return $laborReportStatus['status']=='已退场'?true:false;
|
|
|
+// $laborReportStatus=LaborReportStatus::where('labor_report_id',$this['id'])->orderBy('id','desc')->first();
|
|
|
+// return $laborReportStatus['status']=='已退场'?true:false;
|
|
|
+ return $this['已退场']?true:false;
|
|
|
}
|
|
|
//出场更新临时工报表信息
|
|
|
static function exitAndChangeLaborReport($laborReport,$userDutyCheck){
|