Исправлен индикатор заполненного отчета в статистике
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ReportDuty extends Model
|
||||
@@ -25,6 +26,25 @@ class ReportDuty extends Model
|
||||
'period_end' => 'datetime:Y-m-d H:i:s',
|
||||
];
|
||||
|
||||
public function scopeWithinPeriod(Builder $query, string $startAt, string $endAt): Builder
|
||||
{
|
||||
return $query
|
||||
->where('period_end', '>=', $startAt)
|
||||
->where('period_start', '<=', $endAt);
|
||||
}
|
||||
|
||||
public function scopeExactPeriod(Builder $query, string $startAt, string $endAt): Builder
|
||||
{
|
||||
return $query
|
||||
->where('period_start', '>=', $startAt)
|
||||
->where('period_end', '<=', $endAt);
|
||||
}
|
||||
|
||||
public function scopeOnlySubmitted(Builder $query): Builder
|
||||
{
|
||||
return $query->where('status_id', 2);
|
||||
}
|
||||
|
||||
public function department()
|
||||
{
|
||||
return $this->belongsTo(Department::class, 'rf_department_id', 'department_id');
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace App\Services;
|
||||
use App\Models\Department;
|
||||
use App\Models\MetrikaResult;
|
||||
use App\Models\Report;
|
||||
use App\Models\ReportDuty;
|
||||
use App\Models\User;
|
||||
use App\Models\UserDepartment;
|
||||
use Carbon\Carbon;
|
||||
@@ -119,7 +120,7 @@ class StatisticsService
|
||||
|
||||
foreach ($deptList as $dept) {
|
||||
$deptId = $dept->department_id;
|
||||
$lastReportQuery = Report::where('rf_department_id', $deptId);
|
||||
$lastReportQuery = ReportDuty::where('rf_department_id', $deptId);
|
||||
if ($isRangeOneDay) {
|
||||
$lastReportQuery->exactPeriod($startDate, $endDate);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user