mirror of
https://github.com/kevinpapst/kimai2.git
synced 2025-04-18 03:14:02 +00:00
fixed broken query
This commit is contained in:
parent
72b172bf7a
commit
a1d7ca2bbd
8 changed files with 77 additions and 15 deletions
src/Repository/Query
templates/invoice/renderer
|
@ -71,7 +71,7 @@ class ActivityQuery extends ProjectQuery
|
|||
* @param Project|int $project
|
||||
* @return self
|
||||
*/
|
||||
public function addProject(Project|int $project): self
|
||||
public function addProject($project): self
|
||||
{
|
||||
$this->projects[] = $project;
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ abstract class BaseFormTypeQuery
|
|||
* @param Project|int $project
|
||||
* @return self
|
||||
*/
|
||||
public function addProject(Project|int $project): self
|
||||
public function addProject($project): self
|
||||
{
|
||||
if (null !== $project) {
|
||||
$this->projects[] = $project;
|
||||
|
|
|
@ -9,7 +9,10 @@
|
|||
|
||||
namespace App\Repository\Query;
|
||||
|
||||
use App\Entity\Activity;
|
||||
use App\Entity\Customer;
|
||||
use App\Entity\InvoiceTemplate;
|
||||
use App\Entity\Project;
|
||||
|
||||
/**
|
||||
* Find items (eg timesheets) for creating a new invoice.
|
||||
|
@ -60,4 +63,58 @@ class InvoiceQuery extends TimesheetQuery
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method ONLY exists, because many templates out there access {{ model.query.customer }} directly.
|
||||
*
|
||||
* @return Customer|null
|
||||
*/
|
||||
public function getCustomer(): ?Customer
|
||||
{
|
||||
$customers = $this->getCustomers();
|
||||
if (\count($customers) === 1) {
|
||||
$customer = $customers[0];
|
||||
if ($customer instanceof Customer) {
|
||||
return $customer;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method ONLY exists, because many templates out there access {{ model.query.project }} directly.
|
||||
*
|
||||
* @return Project|null
|
||||
*/
|
||||
public function getProject(): ?Project
|
||||
{
|
||||
$projects = $this->getProjects();
|
||||
if (\count($projects) === 1) {
|
||||
$project = $projects[0];
|
||||
if ($project instanceof Project) {
|
||||
return $project;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method ONLY exists, because many templates out there access {{ model.query.activity }} directly.
|
||||
*
|
||||
* @return Activity|null
|
||||
*/
|
||||
public function getActivity(): ?Activity
|
||||
{
|
||||
$activities = $this->getActivities();
|
||||
if (\count($activities) === 1) {
|
||||
$activity = $activities[0];
|
||||
if ($activity instanceof Activity) {
|
||||
return $activity;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ class ProjectQuery extends BaseQuery implements VisibilityInterface
|
|||
* @param Customer|int $customer
|
||||
* @return $this
|
||||
*/
|
||||
public function addCustomer(Customer|int $customer)
|
||||
public function addCustomer($customer)
|
||||
{
|
||||
$this->customers[] = $customer;
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
{% set language = model.template.language|default(fallback) %}
|
||||
{% set isDecimal = model.template.decimalDuration|default(false) %}
|
||||
{% set currency = model.currency %}
|
||||
{% set project = model.query.project %}
|
||||
<html lang="{{ language }}">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
|
@ -86,10 +87,10 @@ mpdf-->
|
|||
{{ model.customer.number }}
|
||||
{% endif %}
|
||||
|
||||
{% if model.query.project is not empty and model.query.project.orderNumber is not empty %}
|
||||
{% if project is not null and project.orderNumber is not empty %}
|
||||
<br>
|
||||
{{ 'label.orderNumber'|trans }}:
|
||||
{{ model.query.project.orderNumber }}
|
||||
{{ project.orderNumber }}
|
||||
{% endif %}
|
||||
</p>
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
{% block invoice %}
|
||||
{% set isDecimal = model.template.decimalDuration|default(false) %}
|
||||
{% set currency = model.currency %}
|
||||
{% set project = model.query.project %}
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<h2 class="page-header">
|
||||
|
@ -26,9 +27,9 @@
|
|||
<br>
|
||||
{{ 'label.number'|trans }}: {{ model.customer.number }}
|
||||
{% endif %}
|
||||
{% if model.query.project is not empty and model.query.project.orderNumber is not empty %}
|
||||
{% if project is not null and project.orderNumber is not empty %}
|
||||
<br>
|
||||
{{ 'label.orderNumber'|trans }}: {{ model.query.project.orderNumber }}
|
||||
{{ 'label.orderNumber'|trans }}: {{ project.orderNumber }}
|
||||
{% endif %}
|
||||
</address>
|
||||
</div>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
{% set language = model.template.language|default(fallback) %}
|
||||
{% set isDecimal = model.template.decimalDuration|default(false) %}
|
||||
{% set currency = model.currency %}
|
||||
{% set project = model.query.project %}
|
||||
<html lang="{{ language }}">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
|
@ -85,10 +86,10 @@ mpdf-->
|
|||
<td class="{{ classRight }}">{{ model.customer.number }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if model.query.project is not empty and model.query.project.orderNumber is not empty %}
|
||||
{% if project is not null and project.orderNumber is not empty %}
|
||||
<tr>
|
||||
<td class="{{ classLeft }}">{{ 'label.orderNumber'|trans }}</td>
|
||||
<td class="{{ classRight }}">{{ model.query.project.orderNumber }}</td>
|
||||
<td class="{{ classRight }}">{{ project.orderNumber }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if model.customer.vatId is not empty %}
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
{% block invoice %}
|
||||
{% set isDecimal = model.template.decimalDuration|default(false) %}
|
||||
{% set project = model.query.project %}
|
||||
{% set activity = model.query.activity %}
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<h2 class="page-header">
|
||||
|
@ -41,22 +43,22 @@
|
|||
{{ model.customer.name }}{% if model.customer.contact is not empty %} / {{ model.customer.contact }}{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% if model.query.project is not empty %}
|
||||
{% if project is not null %}
|
||||
<tr>
|
||||
<th>{{ 'label.project'|trans }}</th>
|
||||
<td contenteditable="true">
|
||||
{{ model.query.project.name }}
|
||||
{% if model.query.project.orderNumber is not empty %}
|
||||
({{ 'label.orderNumber'|trans }}: {{ model.query.project.orderNumber }})
|
||||
{{ project.name }}
|
||||
{% if project.orderNumber is not empty %}
|
||||
({{ 'label.orderNumber'|trans }}: {{ project.orderNumber }})
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if model.query.activity is not empty %}
|
||||
{% if activity is not null %}
|
||||
<tr>
|
||||
<th>{{ 'label.activity'|trans }}</th>
|
||||
<td contenteditable="true">
|
||||
{{ model.query.activity.name }}
|
||||
{{ activity.name }}
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
|
|
Loading…
Add table
Reference in a new issue