added order-date field to project (#1186)
This commit is contained in:
@@ -36,7 +36,6 @@ class Project implements EntityWithMetaFields
|
||||
* @ORM\GeneratedValue(strategy="IDENTITY")
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var Customer
|
||||
*
|
||||
@@ -45,7 +44,6 @@ class Project implements EntityWithMetaFields
|
||||
* @Assert\NotNull()
|
||||
*/
|
||||
private $customer;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
@@ -56,7 +54,6 @@ class Project implements EntityWithMetaFields
|
||||
* @Assert\Length(min=2, max=150)
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
@@ -64,14 +61,18 @@ class Project implements EntityWithMetaFields
|
||||
* @Assert\Length(max=20)
|
||||
*/
|
||||
private $orderNumber;
|
||||
|
||||
/**
|
||||
* @var \DateTime
|
||||
*
|
||||
* @ORM\Column(name="order_date", type="datetime", nullable=true)
|
||||
*/
|
||||
private $orderDate;
|
||||
/**
|
||||
* @var string
|
||||
*
|
||||
* @ORM\Column(name="comment", type="text", nullable=true)
|
||||
*/
|
||||
private $comment;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*
|
||||
@@ -172,32 +173,37 @@ class Project implements EntityWithMetaFields
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since 1.4
|
||||
* @deprecated since 1.4, use isVisible() instead
|
||||
*/
|
||||
public function getVisible(): bool
|
||||
{
|
||||
return $this->visible;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getOrderNumber(): ?string
|
||||
{
|
||||
return $this->orderNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $orderNumber
|
||||
* @return Project
|
||||
*/
|
||||
public function setOrderNumber($orderNumber): Project
|
||||
public function setOrderNumber(?string $orderNumber): Project
|
||||
{
|
||||
$this->orderNumber = $orderNumber;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getOrderDate(): ?\DateTime
|
||||
{
|
||||
return $this->orderDate;
|
||||
}
|
||||
|
||||
public function setOrderDate(?\DateTime $orderDate): Project
|
||||
{
|
||||
$this->orderDate = $orderDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal only here for symfony forms
|
||||
* @return Collection|MetaTableTypeInterface[]
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace App\Form;
|
||||
use App\Entity\Customer;
|
||||
use App\Entity\Project;
|
||||
use App\Form\Type\CustomerType;
|
||||
use App\Form\Type\DateTimePickerType;
|
||||
use App\Repository\CustomerRepository;
|
||||
use App\Repository\Query\CustomerFormTypeQuery;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
@@ -58,6 +59,10 @@ class ProjectEditForm extends AbstractType
|
||||
'label' => 'label.orderNumber',
|
||||
'required' => false,
|
||||
])
|
||||
->add('orderDate', DateTimePickerType::class, [
|
||||
'label' => 'label.orderDate',
|
||||
'required' => false,
|
||||
])
|
||||
->add('customer', CustomerType::class, [
|
||||
'query_builder' => function (CustomerRepository $repo) use ($builder, $customer) {
|
||||
$query = new CustomerFormTypeQuery($customer);
|
||||
|
||||
55
src/Migrations/Version20191024100951.php
Normal file
55
src/Migrations/Version20191024100951.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of the Kimai time-tracking app.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace DoctrineMigrations;
|
||||
|
||||
use App\Doctrine\AbstractMigration;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
|
||||
/**
|
||||
* Adds the order_date column to the projects table.
|
||||
*
|
||||
* @version 1.5
|
||||
*/
|
||||
final class Version20191024100951 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Adds the order_date column to the projects table';
|
||||
}
|
||||
|
||||
protected function isSupportingForeignKeys(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isTransactional(): bool
|
||||
{
|
||||
if ($this->isPlatformSqlite()) {
|
||||
// does fail if we use transactions, as tables are re-created and foreign keys would fail
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$projects = $schema->getTable('kimai2_projects');
|
||||
$projects->addColumn('order_date', 'datetime', ['notnull' => false]);
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$projects = $schema->getTable('kimai2_projects');
|
||||
$projects->dropColumn('order_date');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user