Commit ec6a2e54 authored by Guillaume Wauquier's avatar Guillaume Wauquier
Browse files

Ajout de la colonne date de creation et de la date de modification pour de...

Ajout de la colonne date de creation et de la date de modification pour de nombreuse table, alimentation automatique de ces champs grace aux evenements doctrine
parent 912e57c3
......@@ -27,6 +27,7 @@ use \Pasteque\Server\System\DAO\DoctrineModel;
* @package Pasteque
* @SWG\Definition(type="object")
* @Entity
* @HasLifecycleCallbacks
* @Table(name="cashregisters")
*/
class CashRegister extends DoctrineModel
......@@ -126,4 +127,43 @@ class CashRegister extends DoctrineModel
return $this->getNextSessionId();
}
/**
* Date and time of creation
* @var string|null
* @SWG\Property(format="date-time")
* @Column(type="datetime", name="created_at")
*/
protected $createdAt;
public function getCreatedAt() { return $this->createdAt; }
public function setCreatedAt($datetime) { $this->createdAt = $datetime; }
/**
* Date and time of the last update
* @var string|null
* @SWG\Property(format="date-time")
* @Column(type="datetime", name="updated_at", nullable=true)
*/
protected $updatedAt;
public function getUpdateAt() { return $this->updatedAt; }
public function setUpdatedAt($datetime) { $this->updatedAt = $datetime; }
/**
* @PrePersist()
*/
public function doStuffOnPrePersist() {
$this->setCreatedAt(new \DateTime());
}
/**
* @PreUpdate()
*/
public function doStuffOnPreUpdate() {
$this->setUpdatedAt(new \DateTime());
}
}
......@@ -28,6 +28,7 @@ use \Pasteque\Server\System\DAO\DoctrineModel;
* @package Pasteque
* @SWG\Definition(type="object")
* @Entity
* @HasLifecycleCallbacks
* @Table(name="categories")
*/
class Category extends DoctrineModel
......@@ -36,20 +37,17 @@ class Category extends DoctrineModel
protected function getDirectFieldNames() {
return ['id', 'reference', 'label', 'dispOrder', 'hasImage'];
}
protected function getAssociationFields() {
return [
[
'name' => 'parent',
'class' => '\Pasteque\Server\Model\Category',
'null' => true
]
];
return [];
}
public function __construct() {
$this->children = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Internal ID of the category for performance issues.
* @var integer
......@@ -101,7 +99,7 @@ class Category extends DoctrineModel
$this->setReference($label);
}
}
/**
* True if an image can be found for this model.
* @var bool
......@@ -123,4 +121,43 @@ class Category extends DoctrineModel
public function getDispOrder() { return $this->dispOrder; }
public function setDispOrder($dispOrder) { $this->dispOrder = $dispOrder; }
/**
* Date and time of creation
* @var string|null
* @SWG\Property(format="date-time")
* @Column(type="datetime", name="created_at")
*/
protected $createdAt;
public function getCreatedAt() { return $this->createdAt; }
public function setCreatedAt($datetime) { $this->createdAt = $datetime; }
/**
* Date and time of the last update
* @var string|null
* @SWG\Property(format="date-time")
* @Column(type="datetime", name="updated_at", nullable=true)
*/
protected $updatedAt;
public function getUpdateAt() { return $this->updatedAt; }
public function setUpdatedAt($datetime) { $this->updatedAt = $datetime; }
/**
* @PrePersist()
*/
public function doStuffOnPrePersist()
{
$this->setCreatedAt(new \DateTime());
}
/**
* @PreUpdate()
*/
public function doStuffOnPreUpdate()
{
$this->setUpdatedAt(new \DateTime());
}
}
......@@ -28,6 +28,7 @@ use \Pasteque\Server\System\DAO\DoctrineModel;
* @package Pasteque
* @SWG\Definition(type="object")
* @Entity
* @HasLifecycleCallbacks
* @Table(name="compositiongroups")
*/
class CompositionGroup extends DoctrineModel
......@@ -123,4 +124,42 @@ class CompositionGroup extends DoctrineModel
$compositionProduct->setCompositionGroup($this);
}
/**
* Date and time of creation
* @var string|null
* @SWG\Property(format="date-time")
* @Column(type="datetime", name="created_at")
*/
protected $createdAt;
public function getCreatedAt() { return $this->createdAt; }
public function setCreatedAt($datetime) { $this->createdAt = $datetime; }
/**
* Date and time of the last update
* @var string|null
* @SWG\Property(format="date-time")
* @Column(type="datetime", name="updated_at", nullable=true)
*/
protected $updatedAt;
public function getUpdateAt() { return $this->updatedAt; }
public function setUpdatedAt($datetime) { $this->updatedAt = $datetime; }
/**
* @PrePersist()
*/
public function doStuffOnPrePersist()
{
$this->setCreatedAt(new \DateTime());
}
/**
* @PreUpdate()
*/
public function doStuffOnPreUpdate()
{
$this->setUpdatedAt(new \DateTime());
}
}
......@@ -28,6 +28,7 @@ use \Pasteque\Server\System\DAO\DoctrineModel;
* @package Pasteque
* @SWG\Definition(type="object")
* @Entity
* @HasLifecycleCallbacks
* @Table(name="compositionproducts")
*/
class CompositionProduct extends DoctrineModel
......@@ -85,4 +86,42 @@ class CompositionProduct extends DoctrineModel
public function getProduct() { return $this->product; }
public function setProduct($product) { $this->product = $product; }
/**
* Date and time of creation
* @var string|null
* @SWG\Property(format="date-time")
* @Column(type="datetime", name="created_at")
*/
protected $createdAt;
public function getCreatedAt() { return $this->createdAt; }
public function setCreatedAt($datetime) { $this->createdAt = $datetime; }
/**
* Date and time of the last update
* @var string|null
* @SWG\Property(format="date-time")
* @Column(type="datetime", name="updated_at", nullable=true)
*/
protected $updatedAt;
public function getUpdateAt() { return $this->updatedAt; }
public function setUpdatedAt($datetime) { $this->updatedAt = $datetime; }
/**
* @PrePersist()
*/
public function doStuffOnPrePersist()
{
$this->setCreatedAt(new \DateTime());
}
/**
* @PreUpdate()
*/
public function doStuffOnPreUpdate()
{
$this->setUpdatedAt(new \DateTime());
}
}
......@@ -29,6 +29,7 @@ use \Pasteque\Server\System\DAO\DoctrineModel;
* @package Pasteque
* @SWG\Definition(type="object")
* @Entity
* @HasLifecycleCallbacks
* @Table(name="currencies")
*/
class Currency extends DoctrineModel
......@@ -151,4 +152,42 @@ class Currency extends DoctrineModel
public function isVisible() { return $this->getVisible(); }
public function setVisible($visible) { $this->visible = $visible; }
/**
* Date and time of creation
* @var string|null
* @SWG\Property(format="date-time")
* @Column(type="datetime", name="created_at")
*/
protected $createdAt;
public function getCreatedAt() { return $this->createdAt; }
public function setCreatedAt($datetime) { $this->createdAt = $datetime; }
/**
* Date and time of the last update
* @var string|null
* @SWG\Property(format="date-time")
* @Column(type="datetime", name="updated_at", nullable=true)
*/
protected $updatedAt;
public function getUpdateAt() { return $this->updatedAt; }
public function setUpdatedAt($datetime) { $this->updatedAt = $datetime; }
/**
* @PrePersist()
*/
public function doStuffOnPrePersist()
{
$this->setCreatedAt(new \DateTime());
}
/**
* @PreUpdate()
*/
public function doStuffOnPreUpdate()
{
$this->setUpdatedAt(new \DateTime());
}
}
......@@ -29,6 +29,7 @@ use \Pasteque\Server\System\DAO\DoctrineModel;
* @package Pasteque
* @SWG\Definition(type="object")
* @Entity
* @HasLifecycleCallbacks
* @Table(name="customers")
*/
class Customer extends DoctrineModel
......@@ -314,6 +315,7 @@ class Customer extends DoctrineModel
public function getExpireDate() { return $this->expireDate; }
public function setExpireDate($expireDate) { $this->expireDate = $expireDate; }
/**
* True if an image can be found for this model.
* @var bool
......@@ -325,6 +327,46 @@ class Customer extends DoctrineModel
public function hasImage() { return $this->getHasImage(); }
public function setHasImage($hasImage) { $this->hasImage = $hasImage; }
/**
* Date and time of creation
* @var string|null
* @SWG\Property(format="date-time")
* @Column(type="datetime", name="created_at")
*/
protected $createdAt;
public function getCreatedAt() { return $this->createdAt; }
public function setCreatedAt($datetime) { $this->createdAt = $datetime; }
/**
* Date and time of the last update
* @var string|null
* @SWG\Property(format="date-time")
* @Column(type="datetime", name="updated_at", nullable=true)
*/
protected $updatedAt;
public function getUpdateAt() { return $this->updatedAt; }
public function setUpdatedAt($datetime) { $this->updatedAt = $datetime; }
/**
* @PrePersist()
*/
public function doStuffOnPrePersist()
{
$this->setCreatedAt(new \DateTime());
}
/**
* @PreUpdate()
*/
public function doStuffOnPreUpdate()
{
$this->setUpdatedAt(new \DateTime());
}
/** Add some old deprecated virtual fields */
public function toStruct() {
$struct = parent::toStruct();
......@@ -334,4 +376,5 @@ class Customer extends DoctrineModel
return $struct;
}
}
......@@ -30,6 +30,7 @@ use \Pasteque\Server\System\DAO\DoctrineModel;
* @package Pasteque
* @SWG\Definition(type="object")
* @Entity
* @HasLifecycleCallbacks
* @Table(name="discounts")
*/
class Discount extends DoctrineModel
......@@ -109,4 +110,43 @@ class Discount extends DoctrineModel
public function getDispOrder() { return $this->dispOrder; }
public function setDispOrder($dispOrder) { $this->dispOrder = $dispOrder; }
/**
* Date and time of creation
* @var string|null
* @SWG\Property(format="date-time")
* @Column(type="datetime", name="created_at")
*/
protected $createdAt;
public function getCreatedAt() { return $this->createdAt; }
public function setCreatedAt($datetime) { $this->createdAt = $datetime; }
/**
* Date and time of the last update
* @var string|null
* @SWG\Property(format="date-time")
* @Column(type="datetime", name="updated_at", nullable=true)
*/
protected $updatedAt;
public function getUpdateAt() { return $this->updatedAt; }
public function setUpdatedAt($datetime) { $this->updatedAt = $datetime; }
/**
* @PrePersist()
*/
public function doStuffOnPrePersist() {
$this->setCreatedAt(new \DateTime());
}
/**
* @PreUpdate()
*/
public function doStuffOnPreUpdate() {
$this->setUpdatedAt(new \DateTime());
}
}
......@@ -28,6 +28,7 @@ use \Pasteque\Server\System\DAO\DoctrineModel;
* @package Pasteque
* @SWG\Definition(type="object")
* @Entity
* @HasLifecycleCallbacks
* @Table(name="discountprofiles")
*/
class DiscountProfile extends DoctrineModel
......@@ -69,4 +70,42 @@ class DiscountProfile extends DoctrineModel
public function getRate() { return $this->rate; }
public function setRate($rate) { $this->rate = $rate; }
/**
* Date and time of creation
* @var string|null
* @SWG\Property(format="date-time")
* @Column(type="datetime", name="created_at")
*/
protected $createdAt;
public function getCreatedAt() { return $this->createdAt; }
public function setCreatedAt($datetime) { $this->createdAt = $datetime; }
/**
* Date and time of the last update
* @var string|null
* @SWG\Property(format="date-time")
* @Column(type="datetime", name="updated_at", nullable=true)
*/
protected $updatedAt;
public function getUpdateAt() { return $this->updatedAt; }
public function setUpdatedAt($datetime) { $this->updatedAt = $datetime; }
/**
* @PrePersist()
*/
public function doStuffOnPrePersist() {
$this->setCreatedAt(new \DateTime());
}
/**
* @PreUpdate()
*/
public function doStuffOnPreUpdate() {
$this->setUpdatedAt(new \DateTime());
}
}
......@@ -28,6 +28,7 @@ use \Pasteque\Server\System\DAO\DoctrineModel;
* @package Pasteque
* @SWG\Definition(type="object")
* @Entity
* @HasLifecycleCallbacks
* @Table(name="floors")
*/
class Floor extends DoctrineModel
......@@ -108,4 +109,41 @@ class Floor extends DoctrineModel
$place->setFloor($this);
}
/**
* Date and time of creation
* @var string|null
* @SWG\Property(format="date-time")
* @Column(type="datetime", name="created_at")
*/
protected $createdAt;
public function getCreatedAt() { return $this->createdAt; }
public function setCreatedAt($datetime) { $this->createdAt = $datetime; }
/**
* Date and time of the last update
* @var string|null
* @SWG\Property(format="date-time")
* @Column(type="datetime", name="updated_at", nullable=true)
*/
protected $updatedAt;
public function getUpdateAt() { return $this->updatedAt; }
public function setUpdatedAt($datetime) { $this->updatedAt = $datetime; }
/**
* @PrePersist()
*/
public function doStuffOnPrePersist() {
$this->setCreatedAt(new \DateTime());
}
/**
* @PreUpdate()
*/
public function doStuffOnPreUpdate() {
$this->setUpdatedAt(new \DateTime());
}
}
......@@ -34,6 +34,7 @@ use \Pasteque\Server\System\DAO\DoctrineModel;
* @package Pasteque
* @SWG\Definition(type="object")
* @Entity
* @HasLifecycleCallbacks
* @Table(name="images")
*/
class Image extends DoctrineModel
......@@ -105,4 +106,41 @@ class Image extends DoctrineModel
public function getImage() { return $this->image; }
public function setImage($image) { $this->image = $image; }
/**
* Date and time of creation
* @var string|null
* @SWG\Property(format="date-time")
* @Column(type="datetime", name="created_at")
*/
protected $createdAt;
public function getCreatedAt() { return $this->createdAt; }
public function setCreatedAt($datetime) { $this->createdAt = $datetime; }
/**
* Date and time of the last update
* @var string|null
* @SWG\Property(format="date-time")
* @Column(type="datetime", name="updated_at", nullable=true)
*/
protected $updatedAt;
public function getUpdateAt() { return $this->updatedAt; }
public function setUpdatedAt($datetime) { $this->updatedAt = $datetime; }
/**
* @PrePersist()
*/
public function doStuffOnPrePersist() {
$this->setCreatedAt(new \DateTime());
}
/**
* @PreUpdate()
*/
public function doStuffOnPreUpdate() {
$this->setUpdatedAt(new \DateTime());
}
}
......@@ -29,6 +29,7 @@ use \Pasteque\Server\System\DAO\DoctrineModel;
* @package Pasteque
* @SWG\Definition(type="object")
* @Entity
* @HasLifecycleCallbacks
* @Table(name="options")
*/
class Option extends DoctrineModel
......@@ -74,4 +75,29 @@ class Option extends DoctrineModel
public function getContent() { return $this->content; }
public function setContent($content) { $this->content = $content; }
/**
* Date and time of the last update
* @var string|null
* @SWG\Property(format="date-time")
* @Column(type="datetime", name="updated_at", nullable=true)
*/
protected $updatedAt;
public function getUpdateAt() { return $this->updatedAt; }
public function setUpdatedAt($datetime) { $this->updatedAt = $datetime; }
/**
* @PrePersist()
*/
public function doStuffOnPrePersist() {
$this->setCreatedAt(new \DateTime());
}
/**
* @PreUpdate()
*/
public function doStuffOnPreUpdate() {
$this->setUpdatedAt(new \DateTime());
}
}
......@@ -34,6 +34,7 @@ use \Pasteque\Server\System\DAO\DoctrineModel;
* @package Pasteque
* @SWG\Definition(type="object")
* @Entity
* @HasLifecycleCallbacks
* @Table(name="paymentmodes")
*/
class PaymentMode extends DoctrineModel
......@@ -220,4 +221,43 @@ class PaymentMode extends DoctrineModel
}
return $model;
}
/**
* Date and time of creation
* @var string|null
* @SWG\Property(format="date-time")
* @Column(type="datetime", name="created_at")
*/
protected $createdAt;
public function getCreatedAt() { return $this->createdAt; }
public function setCreatedAt($datetime) { $this->createdAt = $datetime; }
/**
* Date and time of the last update
* @var string|null
* @SWG\Property(format="date-time")