1
0
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:
David Bomba 2020-11-07 06:58:26 +11:00 committed by GitHub
commit 7e7d142eba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 95 additions and 13 deletions

View File

@ -203,7 +203,7 @@ class Design extends BaseDesign
return $item->type_id == 1; return $item->type_id == 1;
}); });
if ($product_items->count() == 0) { if (count($product_items) == 0) {
return []; return [];
} }
@ -224,7 +224,7 @@ class Design extends BaseDesign
return $item->type_id = 2; return $item->type_id = 2;
}); });
if ($task_items->count() == 0) { if (count($task_items) == 0) {
return []; return [];
} }
@ -269,8 +269,6 @@ class Design extends BaseDesign
return []; return [];
} }
//info($this->context);
foreach ($items as $row) { foreach ($items as $row) {
$element = ['element' => 'tr', 'elements' => []]; $element = ['element' => 'tr', 'elements' => []];
@ -309,6 +307,16 @@ class Design extends BaseDesign
$element['elements'][] = ['element' => 'td', 'content' => $row['$task.cost']]; $element['elements'][] = ['element' => 'td', 'content' => $row['$task.cost']];
} else if ($cell == '$task.hours') { } else if ($cell == '$task.hours') {
$element['elements'][] = ['element' => 'td', 'content' => $row['$task.quantity']]; $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 { } else {
$element['elements'][] = ['element' => 'td', 'content' => $row[$cell]]; $element['elements'][] = ['element' => 'td', 'content' => $row[$cell]];
} }

View File

@ -12,12 +12,16 @@
namespace App\Services\PdfMaker\Designs\Utilities; namespace App\Services\PdfMaker\Designs\Utilities;
use App\Models\Task;
use App\Utils\Traits\MakesHash;
use DOMDocument; use DOMDocument;
use DOMXPath; use DOMXPath;
use Exception; use Exception;
trait DesignHelpers trait DesignHelpers
{ {
use MakesHash;
public $document; public $document;
public $xpath; public $xpath;
@ -219,4 +223,24 @@ trait DesignHelpers
return $html; 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;
}
} }

View File

@ -666,6 +666,8 @@ trait MakesInvoiceValues
$data[$key][$table_type.'.tax_rate3'] = ''; $data[$key][$table_type.'.tax_rate3'] = '';
$data[$key][$table_type.'.tax3'] = &$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; return $data;

View File

@ -88,7 +88,13 @@
table-layout: fixed; table-layout: fixed;
overflow-wrap: break-word; overflow-wrap: break-word;
margin-top: 3rem; margin-top: 3rem;
margin-bottom: 200px; /* margin-bottom: 200px; */
}
.task-duration {
display: block;
margin-top: 5px;
color: grey;
} }
#product-table > thead, #product-table > thead,

View File

@ -95,12 +95,18 @@
#product-table, #product-table,
#task-table { #task-table {
margin-top: 3.5rem; margin-top: 3.5rem;
margin-bottom: 200px; /* margin-bottom: 200px; */
min-width: 100%; min-width: 100%;
table-layout: fixed; table-layout: fixed;
overflow-wrap: break-word; overflow-wrap: break-word;
} }
.task-duration {
display: block;
margin-top: 5px;
color: grey;
}
#product-table > thead, #product-table > thead,
#task-table > thead { #task-table > thead {
text-align: left; text-align: left;

View File

@ -80,12 +80,18 @@
#product-table, #product-table,
#task-table { #task-table {
margin-top: 3rem; margin-top: 3rem;
margin-bottom: 200px; /* margin-bottom: 200px; */
min-width: 100%; min-width: 100%;
table-layout: fixed; table-layout: fixed;
overflow-wrap: break-word; overflow-wrap: break-word;
} }
.task-duration {
display: block;
margin-top: 5px;
color: grey;
}
#product-table > thead, #product-table > thead,
#task-table > thead { #task-table > thead {
text-align: left; text-align: left;

View File

@ -89,13 +89,19 @@
#product-table, #product-table,
#task-table { #task-table {
margin-top: 3rem; margin-top: 3rem;
margin-bottom: 200px; /* margin-bottom: 200px; */
min-width: 100%; min-width: 100%;
table-layout: fixed; table-layout: fixed;
overflow-wrap: break-word; overflow-wrap: break-word;
border-top: 5px solid var(--primary-color); border-top: 5px solid var(--primary-color);
} }
.task-duration {
display: block;
margin-top: 5px;
color: grey;
}
#product-table > thead, #product-table > thead,
#task-table > thead { #task-table > thead {
text-align: left; text-align: left;

View File

@ -82,12 +82,18 @@
#product-table, #product-table,
#task-table { #task-table {
margin-top: 3rem; margin-top: 3rem;
margin-bottom: 200px; /* margin-bottom: 200px; */
min-width: 100%; min-width: 100%;
table-layout: fixed; table-layout: fixed;
overflow-wrap: break-word; overflow-wrap: break-word;
} }
.task-duration {
display: block;
margin-top: 5px;
color: grey;
}
#product-table > thead, #product-table > thead,
#task-table > thead { #task-table > thead {
text-align: left; text-align: left;

View File

@ -100,12 +100,18 @@
#product-table, #product-table,
#task-table { #task-table {
margin-top: 3rem; margin-top: 3rem;
margin-bottom: 200px; /* margin-bottom: 200px; */
min-width: 100%; min-width: 100%;
table-layout: fixed; table-layout: fixed;
overflow-wrap: break-word; overflow-wrap: break-word;
} }
.task-duration {
display: block;
margin-top: 5px;
color: grey;
}
#product-table > thead, #product-table > thead,
#task-table > thead { #task-table > thead {
text-align: left; text-align: left;

View File

@ -63,7 +63,13 @@
table-layout: fixed; table-layout: fixed;
overflow-wrap: break-word; overflow-wrap: break-word;
margin-top: 3rem; margin-top: 3rem;
margin-bottom: 200px; /* margin-bottom: 200px; */
}
.task-duration {
display: block;
margin-top: 5px;
color: grey;
} }
#product-table, #task-table > thead { #product-table, #task-table > thead {

View File

@ -90,12 +90,18 @@
#product-table, #product-table,
#task-table { #task-table {
margin-top: 3rem; margin-top: 3rem;
margin-bottom: 200px; /* margin-bottom: 200px; */
min-width: 100%; min-width: 100%;
table-layout: fixed; table-layout: fixed;
overflow-wrap: break-word; overflow-wrap: break-word;
} }
.task-duration {
display: block;
margin-top: 5px;
color: grey;
}
#product-table > thead, #product-table > thead,
#task-table > thead { #task-table > thead {
text-align: left; text-align: left;