Merge pull request #4626 from beganovich/v5-remove-task-calculation-from-backend

(v5) Remove task hours calculation from the invoice/PDF
This commit is contained in:
David Bomba 2021-01-05 09:16:20 +11:00 committed by GitHub
commit f3e39a203d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 0 additions and 47 deletions

View File

@ -394,16 +394,6 @@ class Design extends BaseDesign
$element['elements'][] = ['element' => 'td', 'content' => $row['$product.quantity'], 'properties' => ['data-ref' => 'product_table-product.quantity-td', 'style' => 'display: none;']]; $element['elements'][] = ['element' => 'td', 'content' => $row['$product.quantity'], 'properties' => ['data-ref' => 'product_table-product.quantity-td', 'style' => 'display: none;']];
} elseif ($cell == '$task.hours') { } elseif ($cell == '$task.hours') {
$element['elements'][] = ['element' => 'td', 'content' => $row['$task.quantity'], 'properties' => ['data-ref' => 'task_table-task.hours-td']]; $element['elements'][] = ['element' => 'td', 'content' => $row['$task.quantity'], 'properties' => ['data-ref' => 'task_table-task.hours-td']];
} elseif ($cell == '$task.description') {
$_element = ['element' => 'td', 'content' => '', 'elements' => [
['element' => 'span', 'content' => $row[$cell], 'properties' => ['data-ref' => 'task_table-task.description-td']],
]];
foreach ($this->getTaskTimeLogs($row) as $log) {
$_element['elements'][] = ['element' => 'span', 'content' => $log, 'properties' => ['class' => 'task-duration', 'data-ref' => 'task_table-task.duration']];
}
$element['elements'][] = $_element;
} else { } else {
$element['elements'][] = ['element' => 'td', 'content' => $row[$cell], 'properties' => ['data-ref' => "{$_type}_table-" . substr($cell, 1) . '-td']]; $element['elements'][] = ['element' => 'td', 'content' => $row[$cell], 'properties' => ['data-ref' => "{$_type}_table-" . substr($cell, 1) . '-td']];
} }

View File

@ -230,43 +230,6 @@ 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 [];
}
$logs = [];
$_logs = json_decode($task->time_log);
if (!$_logs) {
$_logs = [];
}
foreach ($_logs as $log) {
$start = Carbon::createFromTimestamp($log[0]);
$finish = Carbon::createFromTimestamp($log[1]);
if ($start->isSameDay($finish)) {
$logs[] = sprintf('%s: %s - %s', $start->format($this->entity->client->date_format()), $start->format('h:i:s'), $finish->format('h:i:s'));
} else {
$logs[] = sprintf(
'%s - %s',
$start->format($this->entity->client->date_format() . ' h:i:s'),
$finish->format($this->entity->client->date_format() . ' h:i:s')
);
}
}
return $logs;
}
public function processCustomColumns(string $type): void public function processCustomColumns(string $type): void
{ {
$custom_columns = []; $custom_columns = [];