Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Bugfix: Apply rounding also after manual time edit
Browse files Browse the repository at this point in the history
  • Loading branch information
simonschaufi committed Sep 28, 2019
1 parent 3c5074f commit 0f16af9
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 53 deletions.
79 changes: 42 additions & 37 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion core/processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

$isCoreProcessor = 1;
$dir_templates = 'templates/core/';
require('../includes/kspi.php');
require '../includes/kspi.php';

$kga = Kimai_Registry::getConfig();
$database = Kimai_Registry::getDatabase();
Expand Down
21 changes: 14 additions & 7 deletions extensions/ki_timesheets/processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ function($activity) {
}

if (!$validateTime->isValid($_REQUEST['start_time'])) {
$_REQUEST['start_time'] = $_REQUEST['start_time'] . ':00';
$_REQUEST['start_time'] .= ':00';
if (!$validateTime->isValid($_REQUEST['start_time'])) {
$errors['start_time'] = $kga['lang']['TimeDateInputError'];
}
Expand All @@ -588,7 +588,7 @@ function($activity) {
}

if ($_REQUEST['end_time'] != '' && !$validateTime->isValid($_REQUEST['end_time'])) {
$_REQUEST['end_time'] = $_REQUEST['end_time'] . ':00';
$_REQUEST['end_time'] .= ':00';
if (!$validateTime->isValid($_REQUEST['end_time'])) {
$errors['end_time'] = $kga['lang']['TimeDateInputError'];
}
Expand Down Expand Up @@ -623,10 +623,17 @@ function($activity) {
$outDate = null;
}

$data['start'] = $inDate->getTimestamp();
$rounded = Kimai_Rounding::roundTimespan(
$inDate->getTimestamp(),
$outDate->getTimestamp(),
$kga->getRoundPrecisionRecorderTimes(),
$kga->isRoundDownRecorderTimes()
);

$data['start'] = $rounded['start'];

if ($outDate != null) {
$data['end'] = $outDate->getTimestamp();
if ($outDate !== null) {
$data['end'] = $rounded['end'];
$data['duration'] = $data['end'] - $data['start'];
}

Expand All @@ -637,7 +644,7 @@ function($activity) {
}

// TIME RIGHT - EDIT ENTRY
Kimai_Logger::logfile("timeEntry_edit: " . $id);
Kimai_Logger::logfile('timeEntry_edit: ' . $id);
$database->timeEntry_edit($id, $data);
} else {
// TIME RIGHT - NEW ENTRY
Expand All @@ -653,7 +660,7 @@ function($activity) {
break 2;
}

Kimai_Logger::logfile("timeEntry_create");
Kimai_Logger::logfile('timeEntry_create');
$createdId = $database->timeEntry_create($data);
if (!$createdId) {
$errors[''] = $kga['lang']['error'];
Expand Down
1 change: 0 additions & 1 deletion libraries/Kimai/Invoice/HtmlToPdfRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
*/
class Kimai_Invoice_HtmlToPdfRenderer extends Kimai_Invoice_HtmlRenderer
{

/**
* Render the invoice.
*/
Expand Down
11 changes: 5 additions & 6 deletions libraries/Kimai/Invoice/OdtRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
*/
class Kimai_Invoice_OdtRenderer extends Kimai_Invoice_AbstractRenderer
{

/**
* Render the invoice.
*
Expand All @@ -38,22 +37,22 @@ public function render()
if (class_exists('ZipArchive')) {
$doc->setZipMethod('ziparchive');
} else {
$doc->setZipMethod('shell');
$doc->setZipMethod();
try {
$doc->setZipBinary('zip');
$doc->setUnzipBinary('unzip');
$doc->setZipBinary();
$doc->setUnzipBinary();
} catch (tinyDocException $e) {
$doc->setZipMethod('pclzip');
}
}

$doc->setProcessDir($this->getTemporaryDirectory());

//This is where the template is selected
// This is where the template is selected

$templateForm = $this->getTemplateDir() . $this->getTemplateFile();
$doc->createFrom($templateForm);
$doc->loadXml('content.xml');
$doc->loadXml();

// fetch variables from model to get values
$customer = $this->getModel()->getCustomer();
Expand Down
1 change: 0 additions & 1 deletion libraries/Kimai/Invoice/PrintModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
*/
class Kimai_Invoice_PrintModel
{

/**
* @var array
*/
Expand Down

0 comments on commit 0f16af9

Please sign in to comment.