mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-04 01:24:36 -04:00
Added basic task report
This commit is contained in:
parent
d57117477c
commit
ec963e0823
@ -11,6 +11,7 @@ use App\Models\Account;
|
||||
use App\Models\Client;
|
||||
use App\Models\Payment;
|
||||
use App\Models\Expense;
|
||||
use App\Models\Task;
|
||||
|
||||
/**
|
||||
* Class ReportController
|
||||
@ -71,6 +72,7 @@ class ReportController extends BaseController
|
||||
ENTITY_PRODUCT => trans('texts.product'),
|
||||
ENTITY_PAYMENT => trans('texts.payment'),
|
||||
ENTITY_EXPENSE => trans('texts.expense'),
|
||||
ENTITY_TASK => trans('texts.task'),
|
||||
ENTITY_TAX_RATE => trans('texts.tax'),
|
||||
];
|
||||
|
||||
@ -121,9 +123,36 @@ class ReportController extends BaseController
|
||||
return $this->generateTaxRateReport($startDate, $endDate, $dateField, $isExport);
|
||||
} elseif ($reportType == ENTITY_EXPENSE) {
|
||||
return $this->generateExpenseReport($startDate, $endDate, $isExport);
|
||||
} elseif ($reportType == ENTITY_TASK) {
|
||||
return $this->generateTaskReport($startDate, $endDate, $isExport);
|
||||
}
|
||||
}
|
||||
|
||||
private function generateTaskReport($startDate, $endDate, $isExport)
|
||||
{
|
||||
$columns = ['client', 'date', 'duration'];
|
||||
$displayData = [];
|
||||
|
||||
$tasks = Task::scope()
|
||||
->with('client.contacts')
|
||||
->withArchived()
|
||||
->dateRange($startDate, $endDate);
|
||||
|
||||
foreach ($tasks->get() as $task) {
|
||||
$displayData[] = [
|
||||
$task->client ? ($isExport ? $task->client->getDisplayName() : $task->client->present()->link) : trans('texts.unassigned'),
|
||||
$task->getStartTime(),
|
||||
Utils::formatTime($task->getDuration()),
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'columns' => $columns,
|
||||
'displayData' => $displayData,
|
||||
'reportTotals' => [],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $startDate
|
||||
* @param $endDate
|
||||
|
@ -165,6 +165,14 @@ class Task extends EntityModel
|
||||
|
||||
return '#' . $this->public_id;
|
||||
}
|
||||
|
||||
public function scopeDateRange($query, $startDate, $endDate)
|
||||
{
|
||||
$query->whereRaw('cast(substring(time_log, 3, 10) as unsigned) >= ' . $startDate->format('U'));
|
||||
$query->whereRaw('cast(substring(time_log, 3, 10) as unsigned) <= ' . $endDate->format('U'));
|
||||
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
<style type="text/css">
|
||||
|
||||
input.time-input {
|
||||
width: 110px;
|
||||
width: 200px;
|
||||
font-size: 14px !important;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user