mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 12:12:48 +01:00
Improve task descriptions when invoiced
This commit is contained in:
parent
1337b8130a
commit
21795b683d
@ -253,10 +253,11 @@ class TaskController extends BaseController
|
||||
Session::flash('message', trans('texts.stopped_task'));
|
||||
return Redirect::to('tasks');
|
||||
} else if ($action == 'invoice' || $action == 'add_to_invoice') {
|
||||
$tasks = Task::scope($ids)->with('client')->get();
|
||||
$tasks = Task::scope($ids)->with('client')->orderBy('project_id', 'id')->get();
|
||||
$clientPublicId = false;
|
||||
$data = [];
|
||||
|
||||
$lastProjectId = false;
|
||||
foreach ($tasks as $task) {
|
||||
if ($task->client) {
|
||||
if (!$clientPublicId) {
|
||||
@ -276,11 +277,13 @@ class TaskController extends BaseController
|
||||
}
|
||||
|
||||
$account = Auth::user()->account;
|
||||
$showProject = $lastProjectId != $task->project_id;
|
||||
$data[] = [
|
||||
'publicId' => $task->public_id,
|
||||
'description' => $task->description . "\n\n" . $task->present()->times($account),
|
||||
'description' => $task->present()->invoiceDescription($account, $showProject),
|
||||
'duration' => $task->getHours(),
|
||||
];
|
||||
$lastProjectId = $task->project_id;
|
||||
}
|
||||
|
||||
if ($action == 'invoice') {
|
||||
|
@ -35,8 +35,18 @@ class TaskPresenter extends EntityPresenter
|
||||
* @param $account
|
||||
* @return mixed
|
||||
*/
|
||||
public function times($account)
|
||||
public function invoiceDescription($account, $showProject)
|
||||
{
|
||||
$str = '';
|
||||
|
||||
if ($showProject && $project = $this->project()) {
|
||||
$str .= "##{$project}\n\n";
|
||||
}
|
||||
|
||||
if ($description = trim($this->entity->description)) {
|
||||
$str .= $description . "\n\n";
|
||||
}
|
||||
|
||||
$parts = json_decode($this->entity->time_log) ?: [];
|
||||
$times = [];
|
||||
|
||||
@ -54,7 +64,6 @@ class TaskPresenter extends EntityPresenter
|
||||
$times[] = "### {$start} - {$end}";
|
||||
}
|
||||
|
||||
return implode("\n", $times);
|
||||
return $str . implode("\n", $times);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user