mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 21:22:58 +01:00
Merge pull request #4272 from beganovich/v5-css-task-duration
(v5) Add support for task time logs
This commit is contained in:
commit
7e7d142eba
@ -203,7 +203,7 @@ class Design extends BaseDesign
|
||||
return $item->type_id == 1;
|
||||
});
|
||||
|
||||
if ($product_items->count() == 0) {
|
||||
if (count($product_items) == 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
@ -224,7 +224,7 @@ class Design extends BaseDesign
|
||||
return $item->type_id = 2;
|
||||
});
|
||||
|
||||
if ($task_items->count() == 0) {
|
||||
if (count($task_items) == 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
@ -269,8 +269,6 @@ class Design extends BaseDesign
|
||||
return [];
|
||||
}
|
||||
|
||||
//info($this->context);
|
||||
|
||||
foreach ($items as $row) {
|
||||
$element = ['element' => 'tr', 'elements' => []];
|
||||
|
||||
@ -309,6 +307,16 @@ class Design extends BaseDesign
|
||||
$element['elements'][] = ['element' => 'td', 'content' => $row['$task.cost']];
|
||||
} else if ($cell == '$task.hours') {
|
||||
$element['elements'][] = ['element' => 'td', 'content' => $row['$task.quantity']];
|
||||
} else if ($cell == '$task.notes') {
|
||||
$_element = ['element' => 'td', 'content' => '', 'elements' => [
|
||||
['element' => 'span', 'content' => $row[$cell]],
|
||||
]];
|
||||
|
||||
foreach ($this->getTaskTimeLogs($row) as $log) {
|
||||
$_element['elements'][] = ['element' => 'span', 'content' => $log, 'properties' => ['class' => 'task-duration']];
|
||||
}
|
||||
|
||||
$element['elements'][] = $_element;
|
||||
} else {
|
||||
$element['elements'][] = ['element' => 'td', 'content' => $row[$cell]];
|
||||
}
|
||||
|
@ -12,12 +12,16 @@
|
||||
|
||||
namespace App\Services\PdfMaker\Designs\Utilities;
|
||||
|
||||
use App\Models\Task;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use DOMDocument;
|
||||
use DOMXPath;
|
||||
use Exception;
|
||||
|
||||
trait DesignHelpers
|
||||
{
|
||||
use MakesHash;
|
||||
|
||||
public $document;
|
||||
|
||||
public $xpath;
|
||||
@ -219,4 +223,24 @@ trait DesignHelpers
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function getTaskTimeLogs(array $row)
|
||||
{
|
||||
if (!array_key_exists('task_id', $row)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$task = Task::find($this->decodePrimaryKey($row['task_id']));
|
||||
|
||||
if (!$task) {
|
||||
return [];
|
||||
}
|
||||
|
||||
foreach (json_decode($task['time_log']) as $log) {
|
||||
info($log);
|
||||
$logs[] = sprintf('%s - %s', \Carbon\Carbon::createFromTimestamp($log[0])->toDateTimeString(), \Carbon\Carbon::createFromTimestamp($log[1])->toDateTimeString());
|
||||
}
|
||||
|
||||
return $logs;
|
||||
}
|
||||
}
|
||||
|
@ -666,6 +666,8 @@ trait MakesInvoiceValues
|
||||
$data[$key][$table_type.'.tax_rate3'] = '';
|
||||
$data[$key][$table_type.'.tax3'] = &$data[$key][$table_type.'.tax_rate3'];
|
||||
}
|
||||
|
||||
$data[$key]['task_id'] = optional($item)->task_id;
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
@ -88,7 +88,13 @@
|
||||
table-layout: fixed;
|
||||
overflow-wrap: break-word;
|
||||
margin-top: 3rem;
|
||||
margin-bottom: 200px;
|
||||
/* margin-bottom: 200px; */
|
||||
}
|
||||
|
||||
.task-duration {
|
||||
display: block;
|
||||
margin-top: 5px;
|
||||
color: grey;
|
||||
}
|
||||
|
||||
#product-table > thead,
|
||||
|
@ -95,12 +95,18 @@
|
||||
#product-table,
|
||||
#task-table {
|
||||
margin-top: 3.5rem;
|
||||
margin-bottom: 200px;
|
||||
/* margin-bottom: 200px; */
|
||||
min-width: 100%;
|
||||
table-layout: fixed;
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
|
||||
.task-duration {
|
||||
display: block;
|
||||
margin-top: 5px;
|
||||
color: grey;
|
||||
}
|
||||
|
||||
#product-table > thead,
|
||||
#task-table > thead {
|
||||
text-align: left;
|
||||
|
@ -80,12 +80,18 @@
|
||||
#product-table,
|
||||
#task-table {
|
||||
margin-top: 3rem;
|
||||
margin-bottom: 200px;
|
||||
/* margin-bottom: 200px; */
|
||||
min-width: 100%;
|
||||
table-layout: fixed;
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
|
||||
.task-duration {
|
||||
display: block;
|
||||
margin-top: 5px;
|
||||
color: grey;
|
||||
}
|
||||
|
||||
#product-table > thead,
|
||||
#task-table > thead {
|
||||
text-align: left;
|
||||
|
@ -89,13 +89,19 @@
|
||||
#product-table,
|
||||
#task-table {
|
||||
margin-top: 3rem;
|
||||
margin-bottom: 200px;
|
||||
/* margin-bottom: 200px; */
|
||||
min-width: 100%;
|
||||
table-layout: fixed;
|
||||
overflow-wrap: break-word;
|
||||
border-top: 5px solid var(--primary-color);
|
||||
}
|
||||
|
||||
.task-duration {
|
||||
display: block;
|
||||
margin-top: 5px;
|
||||
color: grey;
|
||||
}
|
||||
|
||||
#product-table > thead,
|
||||
#task-table > thead {
|
||||
text-align: left;
|
||||
|
@ -82,12 +82,18 @@
|
||||
#product-table,
|
||||
#task-table {
|
||||
margin-top: 3rem;
|
||||
margin-bottom: 200px;
|
||||
/* margin-bottom: 200px; */
|
||||
min-width: 100%;
|
||||
table-layout: fixed;
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
|
||||
.task-duration {
|
||||
display: block;
|
||||
margin-top: 5px;
|
||||
color: grey;
|
||||
}
|
||||
|
||||
#product-table > thead,
|
||||
#task-table > thead {
|
||||
text-align: left;
|
||||
|
@ -100,12 +100,18 @@
|
||||
#product-table,
|
||||
#task-table {
|
||||
margin-top: 3rem;
|
||||
margin-bottom: 200px;
|
||||
/* margin-bottom: 200px; */
|
||||
min-width: 100%;
|
||||
table-layout: fixed;
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
|
||||
.task-duration {
|
||||
display: block;
|
||||
margin-top: 5px;
|
||||
color: grey;
|
||||
}
|
||||
|
||||
#product-table > thead,
|
||||
#task-table > thead {
|
||||
text-align: left;
|
||||
|
@ -63,7 +63,13 @@
|
||||
table-layout: fixed;
|
||||
overflow-wrap: break-word;
|
||||
margin-top: 3rem;
|
||||
margin-bottom: 200px;
|
||||
/* margin-bottom: 200px; */
|
||||
}
|
||||
|
||||
.task-duration {
|
||||
display: block;
|
||||
margin-top: 5px;
|
||||
color: grey;
|
||||
}
|
||||
|
||||
#product-table, #task-table > thead {
|
||||
|
@ -90,12 +90,18 @@
|
||||
#product-table,
|
||||
#task-table {
|
||||
margin-top: 3rem;
|
||||
margin-bottom: 200px;
|
||||
/* margin-bottom: 200px; */
|
||||
min-width: 100%;
|
||||
table-layout: fixed;
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
|
||||
.task-duration {
|
||||
display: block;
|
||||
margin-top: 5px;
|
||||
color: grey;
|
||||
}
|
||||
|
||||
#product-table > thead,
|
||||
#task-table > thead {
|
||||
text-align: left;
|
||||
|
Loading…
Reference in New Issue
Block a user