bugfixes and improvements (#2660)
This commit is contained in:
@@ -276,8 +276,6 @@ class TimesheetController extends BaseApiController
|
||||
* required=true,
|
||||
* )
|
||||
*
|
||||
* @Security("is_granted('view_own_timesheet') or is_granted('view_other_timesheet')")
|
||||
*
|
||||
* @ApiSecurity(name="apiUser")
|
||||
* @ApiSecurity(name="apiToken")
|
||||
*
|
||||
@@ -497,7 +495,7 @@ class TimesheetController extends BaseApiController
|
||||
}
|
||||
|
||||
if (null !== ($reqLimit = $paramFetcher->get('size'))) {
|
||||
$limit = $reqLimit;
|
||||
$limit = (int) $reqLimit;
|
||||
}
|
||||
|
||||
if (null !== ($reqBegin = $paramFetcher->get('begin'))) {
|
||||
|
||||
@@ -90,6 +90,10 @@ class ImportTimesheetCommand extends Command
|
||||
* @var User[]
|
||||
*/
|
||||
private $userCache = [];
|
||||
/**
|
||||
* @var Tag[]
|
||||
*/
|
||||
private $tagCache = [];
|
||||
/**
|
||||
* Comment that will be added to new customers, projects and activities.
|
||||
*
|
||||
@@ -371,9 +375,7 @@ class ImportTimesheetCommand extends Command
|
||||
continue;
|
||||
}
|
||||
|
||||
if (null === ($tag = $this->tagRepository->findTagByName($tagName))) {
|
||||
$tag = (new Tag())->setName($tagName);
|
||||
}
|
||||
$tag = $this->getTag($tagName);
|
||||
|
||||
$timesheet->addTag($tag);
|
||||
}
|
||||
@@ -469,6 +471,23 @@ class ImportTimesheetCommand extends Command
|
||||
return $this->userCache[$user];
|
||||
}
|
||||
|
||||
private function getTag(string $tagName): Tag
|
||||
{
|
||||
if (\array_key_exists($tagName, $this->tagCache)) {
|
||||
return $this->tagCache[$tagName];
|
||||
}
|
||||
|
||||
$tag = $this->tagRepository->findTagByName($tagName);
|
||||
|
||||
if ($tag === null) {
|
||||
$tag = (new Tag())->setName($tagName);
|
||||
}
|
||||
|
||||
$this->tagCache[$tagName] = $tag;
|
||||
|
||||
return $this->tagCache[$tagName];
|
||||
}
|
||||
|
||||
private function getActivity($activity, Project $project, $activityType): Activity
|
||||
{
|
||||
$tmpActivity = null;
|
||||
@@ -497,8 +516,9 @@ class ImportTimesheetCommand extends Command
|
||||
|
||||
private function getProject($project, $customer, $fallbackCustomer): Project
|
||||
{
|
||||
if (!\array_key_exists($project, $this->projectCache)) {
|
||||
/** @var Customer $tmpCustomer */
|
||||
$cacheKey = $project . '_____' . $customer;
|
||||
|
||||
if (!\array_key_exists($cacheKey, $this->projectCache)) {
|
||||
$tmpCustomer = $this->getCustomer($customer, $fallbackCustomer);
|
||||
/** @var Project $tmpProject */
|
||||
$tmpProject = null;
|
||||
@@ -533,10 +553,10 @@ class ImportTimesheetCommand extends Command
|
||||
$this->createdProjects++;
|
||||
}
|
||||
|
||||
$this->projectCache[$project] = $tmpProject;
|
||||
$this->projectCache[$cacheKey] = $tmpProject;
|
||||
}
|
||||
|
||||
return $this->projectCache[$project];
|
||||
return $this->projectCache[$cacheKey];
|
||||
}
|
||||
|
||||
private function getCustomer($customer, $fallback): Customer
|
||||
@@ -560,42 +580,44 @@ class ImportTimesheetCommand extends Command
|
||||
}
|
||||
}
|
||||
|
||||
if (null === $this->customerFallback) {
|
||||
$tmpFallback = null;
|
||||
|
||||
if (!empty($fallback)) {
|
||||
if (\is_int($customer)) {
|
||||
$tmpFallback = $this->customers->find($fallback);
|
||||
} else {
|
||||
/** @var Customer|null $tmpFallback */
|
||||
$tmpFallback = $this->customers->findOneBy(['name' => $fallback]);
|
||||
}
|
||||
}
|
||||
|
||||
if (null === $tmpFallback) {
|
||||
$newName = $customer;
|
||||
if (empty($customer)) {
|
||||
$newName = self::DEFAULT_CUSTOMER;
|
||||
if (!empty($fallback) && \is_string($fallback)) {
|
||||
$newName = $fallback;
|
||||
}
|
||||
}
|
||||
$tmpFallback = new Customer();
|
||||
$tmpFallback->setName(sprintf($newName, $this->dateTime));
|
||||
$tmpFallback->setComment($this->comment);
|
||||
$tmpFallback->setCountry($this->configuration->getCustomerDefaultCountry());
|
||||
$timezone = date_default_timezone_get();
|
||||
if (null !== $this->configuration->getCustomerDefaultTimezone()) {
|
||||
$timezone = $this->configuration->getCustomerDefaultTimezone();
|
||||
}
|
||||
$tmpFallback->setTimezone($timezone);
|
||||
$this->customers->saveCustomer($tmpFallback);
|
||||
$this->createdCustomers++;
|
||||
}
|
||||
|
||||
$this->customerFallback = $tmpFallback;
|
||||
if (null !== $this->customerFallback && !empty($fallback)) {
|
||||
return $this->customerFallback;
|
||||
}
|
||||
|
||||
$tmpFallback = null;
|
||||
|
||||
if (!empty($fallback)) {
|
||||
if (is_numeric($fallback)) {
|
||||
$tmpFallback = $this->customers->find((int) $fallback);
|
||||
} else {
|
||||
/** @var Customer|null $tmpFallback */
|
||||
$tmpFallback = $this->customers->findOneBy(['name' => $fallback]);
|
||||
}
|
||||
}
|
||||
|
||||
if (null === $tmpFallback) {
|
||||
$newName = $customer;
|
||||
if (empty($customer)) {
|
||||
$newName = self::DEFAULT_CUSTOMER;
|
||||
if (!empty($fallback) && \is_string($fallback)) {
|
||||
$newName = $fallback;
|
||||
}
|
||||
}
|
||||
$tmpFallback = new Customer();
|
||||
$tmpFallback->setName(sprintf($newName, $this->dateTime));
|
||||
$tmpFallback->setComment($this->comment);
|
||||
$tmpFallback->setCountry($this->configuration->getCustomerDefaultCountry());
|
||||
$timezone = date_default_timezone_get();
|
||||
if (null !== $this->configuration->getCustomerDefaultTimezone()) {
|
||||
$timezone = $this->configuration->getCustomerDefaultTimezone();
|
||||
}
|
||||
$tmpFallback->setTimezone($timezone);
|
||||
$this->customers->saveCustomer($tmpFallback);
|
||||
$this->createdCustomers++;
|
||||
}
|
||||
|
||||
$this->customerFallback = $tmpFallback;
|
||||
|
||||
return $this->customerFallback;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ final class ProjectViewController extends AbstractController
|
||||
'title' => 'report_project_view',
|
||||
'tableName' => 'project_view_reporting',
|
||||
'now' => $this->getDateTimeFactory()->createDateTime(),
|
||||
'showDurations' => true,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ class ProjectSubscriber extends AbstractActionsSubscriber
|
||||
$event->addDelete($this->path('admin_project_delete', ['id' => $project->getId()]));
|
||||
}
|
||||
|
||||
if ($project->isVisible() && $this->isGranted('view_reporting') && $this->isGranted('details_project')) {
|
||||
if ($project->isVisible() && $this->isGranted('view_reporting') && $this->isGranted('details', $project)) {
|
||||
$event->addAction('report_project_details', ['url' => $this->path('report_project_details', ['project' => $project->getId()]), 'icon' => 'reporting', 'translation_domain' => 'reporting']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,10 +43,13 @@ abstract class AbstractSpreadsheetRenderer
|
||||
public const DATETIME_FORMAT = 'yyyy-mm-dd hh:mm';
|
||||
public const TIME_FORMAT = 'hh:mm';
|
||||
public const DURATION_FORMAT = '[hh]:mm';
|
||||
public const DURATION_DECIMAL = '#0.00';
|
||||
public const RATE_FORMAT_DEFAULT = '#.##0,00 [$%1$s];-#.##0,00 [$%1$s]';
|
||||
public const RATE_FORMAT_LEFT = '_("%1$s"* #,##0.00_);_("%1$s"* \(#,##0.00\);_("%1$s"* "-"??_);_(@_)';
|
||||
public const RATE_FORMAT = self::RATE_FORMAT_LEFT;
|
||||
|
||||
protected $durationFormat = self::DURATION_FORMAT;
|
||||
protected $durationBase = 86400;
|
||||
/**
|
||||
* @var LocaleFormatExtensions
|
||||
*/
|
||||
@@ -183,7 +186,7 @@ abstract class AbstractSpreadsheetRenderer
|
||||
{
|
||||
$sheet->setCellValueByColumnAndRow($column, $row, sprintf('=SUM(%s:%s)', $startCoordinate, $endCoordinate));
|
||||
$style = $sheet->getStyleByColumnAndRow($column, $row);
|
||||
$style->getNumberFormat()->setFormatCode(self::DURATION_FORMAT);
|
||||
$style->getNumberFormat()->setFormatCode($this->durationFormat);
|
||||
}
|
||||
|
||||
protected function setDuration(Worksheet $sheet, $column, $row, $duration)
|
||||
@@ -191,8 +194,8 @@ abstract class AbstractSpreadsheetRenderer
|
||||
if (null === $duration) {
|
||||
$duration = 0;
|
||||
}
|
||||
$sheet->setCellValueByColumnAndRow($column, $row, sprintf('=%s/86400', $duration));
|
||||
$sheet->getStyleByColumnAndRow($column, $row)->getNumberFormat()->setFormatCode(self::DURATION_FORMAT);
|
||||
$sheet->setCellValueByColumnAndRow($column, $row, sprintf('=%s/%s', $duration, $this->durationBase));
|
||||
$sheet->getStyleByColumnAndRow($column, $row)->getNumberFormat()->setFormatCode($this->durationFormat);
|
||||
}
|
||||
|
||||
protected function setRateTotal(Worksheet $sheet, $column, $row, $startCoordinate, $endCoordinate)
|
||||
@@ -232,6 +235,11 @@ abstract class AbstractSpreadsheetRenderer
|
||||
*/
|
||||
protected function getColumns(array $exportItems, TimesheetQuery $query, array $columns): array
|
||||
{
|
||||
if (null !== $query->getCurrentUser() && $query->getCurrentUser()->isExportDecimal()) {
|
||||
$this->durationFormat = self::DURATION_DECIMAL;
|
||||
$this->durationBase = 3600;
|
||||
}
|
||||
|
||||
$showRates = $this->isRenderRate($query);
|
||||
|
||||
if (isset($columns['date']) && !isset($columns['date']['render'])) {
|
||||
|
||||
@@ -21,7 +21,7 @@ final class Version20210605154245 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Cleans up User table';
|
||||
return 'Cleans up the user table';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
|
||||
@@ -15,7 +15,7 @@ use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
* @version 1.15
|
||||
*/
|
||||
final class Version20210704111542 extends AbstractMigration
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user