diff --git a/app/Services/PdfMaker/Design.php b/app/Services/PdfMaker/Design.php index 7f8cf81733..42dde49f3a 100644 --- a/app/Services/PdfMaker/Design.php +++ b/app/Services/PdfMaker/Design.php @@ -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' => []]; @@ -304,11 +302,21 @@ class Design extends BaseDesign // We want to keep aliases like these: // $task.cost => $task.rate // $task.quantity => $task.hours - + if ($cell == '$task.rate') { $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]]; } diff --git a/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php b/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php index 7e2e98f086..94dde6b323 100644 --- a/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php +++ b/app/Services/PdfMaker/Designs/Utilities/DesignHelpers.php @@ -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; + } } diff --git a/app/Utils/Traits/MakesInvoiceValues.php b/app/Utils/Traits/MakesInvoiceValues.php index edb30cc582..1b7e2e375f 100644 --- a/app/Utils/Traits/MakesInvoiceValues.php +++ b/app/Utils/Traits/MakesInvoiceValues.php @@ -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; diff --git a/resources/views/pdf-designs/bold.html b/resources/views/pdf-designs/bold.html index 1084bb5bd9..7eff09713e 100644 --- a/resources/views/pdf-designs/bold.html +++ b/resources/views/pdf-designs/bold.html @@ -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, diff --git a/resources/views/pdf-designs/business.html b/resources/views/pdf-designs/business.html index 2542ebd302..a18ff9bb44 100644 --- a/resources/views/pdf-designs/business.html +++ b/resources/views/pdf-designs/business.html @@ -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; diff --git a/resources/views/pdf-designs/clean.html b/resources/views/pdf-designs/clean.html index 9315ae4d7a..223cdbddeb 100644 --- a/resources/views/pdf-designs/clean.html +++ b/resources/views/pdf-designs/clean.html @@ -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; diff --git a/resources/views/pdf-designs/creative.html b/resources/views/pdf-designs/creative.html index 7c5886414c..faa2e3045b 100644 --- a/resources/views/pdf-designs/creative.html +++ b/resources/views/pdf-designs/creative.html @@ -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; diff --git a/resources/views/pdf-designs/elegant.html b/resources/views/pdf-designs/elegant.html index ada1f83733..f31e4aa3dc 100644 --- a/resources/views/pdf-designs/elegant.html +++ b/resources/views/pdf-designs/elegant.html @@ -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; diff --git a/resources/views/pdf-designs/hipster.html b/resources/views/pdf-designs/hipster.html index 17b1e71ef4..00b68b5772 100644 --- a/resources/views/pdf-designs/hipster.html +++ b/resources/views/pdf-designs/hipster.html @@ -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; diff --git a/resources/views/pdf-designs/plain.html b/resources/views/pdf-designs/plain.html index 4e556595c5..21692efec7 100644 --- a/resources/views/pdf-designs/plain.html +++ b/resources/views/pdf-designs/plain.html @@ -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 { diff --git a/resources/views/pdf-designs/playful.html b/resources/views/pdf-designs/playful.html index db7ed5279b..51297ad7d5 100644 --- a/resources/views/pdf-designs/playful.html +++ b/resources/views/pdf-designs/playful.html @@ -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;