mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 20:22:42 +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'));
|
Session::flash('message', trans('texts.stopped_task'));
|
||||||
return Redirect::to('tasks');
|
return Redirect::to('tasks');
|
||||||
} else if ($action == 'invoice' || $action == 'add_to_invoice') {
|
} 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;
|
$clientPublicId = false;
|
||||||
$data = [];
|
$data = [];
|
||||||
|
|
||||||
|
$lastProjectId = false;
|
||||||
foreach ($tasks as $task) {
|
foreach ($tasks as $task) {
|
||||||
if ($task->client) {
|
if ($task->client) {
|
||||||
if (!$clientPublicId) {
|
if (!$clientPublicId) {
|
||||||
@ -276,11 +277,13 @@ class TaskController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
$account = Auth::user()->account;
|
$account = Auth::user()->account;
|
||||||
|
$showProject = $lastProjectId != $task->project_id;
|
||||||
$data[] = [
|
$data[] = [
|
||||||
'publicId' => $task->public_id,
|
'publicId' => $task->public_id,
|
||||||
'description' => $task->description . "\n\n" . $task->present()->times($account),
|
'description' => $task->present()->invoiceDescription($account, $showProject),
|
||||||
'duration' => $task->getHours(),
|
'duration' => $task->getHours(),
|
||||||
];
|
];
|
||||||
|
$lastProjectId = $task->project_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'invoice') {
|
if ($action == 'invoice') {
|
||||||
|
@ -35,8 +35,18 @@ class TaskPresenter extends EntityPresenter
|
|||||||
* @param $account
|
* @param $account
|
||||||
* @return mixed
|
* @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) ?: [];
|
$parts = json_decode($this->entity->time_log) ?: [];
|
||||||
$times = [];
|
$times = [];
|
||||||
|
|
||||||
@ -54,7 +64,6 @@ class TaskPresenter extends EntityPresenter
|
|||||||
$times[] = "### {$start} - {$end}";
|
$times[] = "### {$start} - {$end}";
|
||||||
}
|
}
|
||||||
|
|
||||||
return implode("\n", $times);
|
return $str . implode("\n", $times);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user