| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414 |
- <?php
- namespace AppBundle\Entity\Product;
- use AppBundle\Annotation\ExportSplitFields;
- use AppBundle\Entity\AccessAndFunction\Access;
- use AppBundle\Entity\Core\Tagg;
- use AppBundle\Entity\Person\Person;
- use AppBundle\Entity\Traits\ActivityPeriodTrait;
- use AppBundle\Entity\Traits\BillingRuleTrait;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\ORM\Mapping as ORM;
- use Dunglas\ApiBundle\Annotation\Iri;
- use Symfony\Component\Serializer\Annotation\Groups;
- use Symfony\Component\Validator\Constraints as Assert;
- use AppBundle\Entity\Traits\TimestampableEntity;
- use AppBundle\Entity\Traits\CreatorUpdaterEntity;
- use AppBundle\Validator\Constraints\Product as OpentalentAssert;
- /**
- * Location d'éaquipement,
- * Fait le lien entre un Access et un Equipment sur une période donnée
- *
- * @Iri("http://schema.org/EquipmentLoan")
- * @OpentalentAssert\EquipmentLoanAvailableRent
- */
- #[ORM\Entity]
- class EquipmentLoan
- {
- use TimestampableEntity;
- use CreatorUpdaterEntity;
- use ActivityPeriodTrait;
- use BillingRuleTrait;
- /**
- * @var int
- */
- #[ORM\Column(type: 'integer')]
- #[ORM\Id]
- #[ORM\GeneratedValue(strategy: 'AUTO')]
- #[Groups(['equipmentloan', 'equipmentrent_list', 'equipmentloan_list', 'accessequipment_grid', 'own_access', 'access_details', 'equipment_details', 'own_student_access', 'equipment_list', 'equipmentmediatheque_list', 'equipmentcostume_list', 'equipment_availability_form'])]
- private $id;
- /**
- * @var Access
- */
- #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\AccessAndFunction\Access', inversedBy: 'equipmentLoans', cascade: ['persist'])]
- #[ORM\JoinColumn(nullable: false)]
- #[Assert\NotNull]
- #[Groups(['equipmentloan', 'equipmentrent_list', 'equipmentloan_list', 'equipment_details_equipmentloanfiltered', 'equipment_list_equipmentloan', 'equipmentmediatheque_list_equipmentloan', 'equipmentcostume_list_equipmentloan', 'equipment_availability_form', 'equipmentloan_list', 'equipmentrent_list'])]
- private $borrower;
- /**
- * @var Equipment
- */
- #[ORM\ManyToOne(targetEntity: 'AppBundle\Entity\Product\Equipment', inversedBy: 'equipmentLoan')]
- #[Groups(['equipmentloan', 'equipmentrent_list', 'equipmentloan_list', 'accessequipment_grid_equipmentloans', 'own_access_equipmentloans', 'access_details_equipmentloans', 'own_student_access_equipmentloans', 'equipment_availability_form'])]
- private $equipment;
- /**
- * @var \DateTime
- */
- #[ORM\Column(type: 'date', nullable: true)]
- #[Assert\Date]
- #[Groups(['equipmentloan', 'equipmentrent_list', 'equipmentloan_list', 'accessequipment_grid_equipmentloans', 'own_access_equipmentloans', 'access_details_equipmentloans', 'own_student_access_equipmentloans', 'equipment_availability_form'])]
- private $endDateTheorical;
- /**
- * @var string
- */
- #[ORM\Column(type: 'string', nullable: true)]
- #[Assert\Type(type: 'string')]
- #[Assert\Choice(callback: ['\AppBundle\Enum\Product\LoanTypeEnum', 'toArray'])]
- #[Groups(['equipmentloan', 'accessequipment_grid_equipmentloans', 'own_access_equipmentloans', 'access_details_equipmentloans', 'own_student_access_equipmentloans', 'equipmentloan_list', 'equipment_list_equipmentloan', 'equipmentmediatheque_list_equipmentloan', 'equipmentcostume_list_equipmentloan', 'equipment_availability_form'])]
- private $type;
- /**
- * @var float
- *
- *
- */
- #[ORM\Column(type: 'float', nullable: true)]
- #[Assert\Type(type: 'float')]
- #[Groups(['equipmentloan', 'equipmentrent_list', 'equipmentloan_list', 'accessequipment_grid_equipmentloans', 'own_access_equipmentloans', 'own_student_access_equipmentloans', 'equipment_availability_form'])]
- private $deposit;
- /**
- * @var float
- */
- #[ORM\Column(type: 'float', nullable: true)]
- #[Assert\Type(type: 'float')]
- #[Groups(['equipmentloan', 'equipmentrent_list', 'accessequipment_grid_equipmentloans', 'own_access_equipmentloans', 'own_student_access_equipmentloans', 'equipment_availability_form'])]
- private $amount;
- /**
- * @var bool
- */
- #[ORM\Column(type: 'boolean', nullable: true)]
- #[Assert\Type(type: 'boolean')]
- #[Groups(['equipmentloan', 'accessequipment_grid_equipmentloans', 'own_access_equipmentloans', 'own_student_access_equipmentloans', 'equipment_availability_form'])]
- private $forcingAmount = false;
- /**
- * @var ArrayCollection<BillLine>
- */
- #[ORM\OneToMany(targetEntity: 'AppBundle\Entity\Billing\BillLine', mappedBy: 'equipmentLoan', orphanRemoval: true)]
- #[Groups(['equipmentloan_billline'])]
- private $billLines;
- /**
- * @var ArrayCollection<BillingIntangibleExcludeDate>
- */
- #[Assert\Valid]
- #[ORM\OneToMany(targetEntity: 'AppBundle\Entity\Billing\BillingIntangibleExcludeDate', mappedBy: 'equipmentLoan', cascade: ['persist'], orphanRemoval: true)]
- #[Groups(['accessfictionalintangible', 'accessequipment_grid_equipmentloans', 'own_access_equipmentloans'])]
- private $billingIntangibleExcludeDates;
- /**
- * @var string
- * @ExportSplitFields({"borrower.person.name","borrower.person.givenName","type","startDate","endDate"})
- *
- */
- #[Groups(['template'])]
- private $fullLabelTemplate;
- /**
- * @var ArrayCollection<Tagg>
- */
- #[ORM\ManyToMany(targetEntity: 'AppBundle\Entity\Core\Tagg', cascade: ['persist'], inversedBy: 'equipmentLoans')]
- #[Assert\Valid]
- #[ORM\JoinTable(name: 'tag_equipmentLoan', joinColumns: [], inverseJoinColumns: [])]
- #[ORM\JoinColumn(name: 'equipmentLoan_id', referencedColumnName: 'id')]
- #[ORM\JoinColumn(name: 'tag_id', referencedColumnName: 'id')]
- #[Groups(['equipmentloan_tags', 'manage_tags', 'equipmentloan_list', 'equipmentrent_list'])]
- private $tags;
- public function __construct()
- {
- $this->billLines = new ArrayCollection();
- $this->billingIntangibleExcludeDates = new ArrayCollection();
- $this->tags = new ArrayCollection();
- }
- /**
- * Sets id.
- *
- * @param int $id
- *
- * @return $this
- */
- public function setId($id)
- {
- $this->id = $id;
- return $this;
- }
- /**
- * Gets id.
- *
- * @return int
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * @param Access|null $borrower
- * @return $this
- */
- public function setBorrower(Access $borrower = null)
- {
- $this->borrower = $borrower;
- return $this;
- }
- /**
- * Gets Borrower.
- *
- * @return Access
- */
- public function getBorrower()
- {
- return $this->borrower;
- }
- /**
- * Sets equipment.
- *
- * @param Equipment $equipment
- *
- * @return $this
- */
- public function setEquipment(Equipment $equipment = null)
- {
- $this->equipment = $equipment;
- return $this;
- }
- /**
- * Gets equipment.
- *
- * @return Equipment
- */
- public function getEquipment()
- {
- return $this->equipment;
- }
- /**
- * Sets endDateTheorical.
- *
- * @param \DateTime $endDateTheorical
- *
- * @return $this
- */
- public function setEndDateTheorical(\DateTime $endDateTheorical = null)
- {
- $this->endDateTheorical = $endDateTheorical;
- return $this;
- }
- /**
- * Gets endDateTheorical.
- *
- * @return \DateTime
- */
- public function getEndDateTheorical()
- {
- return $this->endDateTheorical ? $this->endDateTheorical->format('Y-m-d') : $this->endDateTheorical;
- }
- /**
- * Sets type.
- *
- * @param string $type
- *
- * @return $this
- */
- public function setType($type)
- {
- $this->type = $type;
- return $this;
- }
- /**
- * Gets type.
- *
- * @return string
- */
- public function getType()
- {
- return $this->type;
- }
- /**
- * Sets deposit.
- *
- * @param float $deposit
- *
- * @return $this
- */
- public function setDeposit($deposit)
- {
- $this->deposit = floatval($deposit);
- return $this;
- }
- /**
- * Gets deposit.
- *
- * @return float
- */
- public function getDeposit()
- {
- return $this->deposit;
- }
- /**
- * Sets amount.
- *
- * @param float $amount
- *
- * @return $this
- */
- public function setAmount($amount)
- {
- $this->amount = floatval($amount);
- return $this;
- }
- /**
- * Gets amount.
- *
- * @return float
- */
- public function getAmount()
- {
- return $this->amount;
- }
- /**
- * Add billLine
- *
- * @param \AppBundle\Entity\Billing\BillLine $billLine
- *
- * @return EquipmentLoan
- */
- public function addBillLine(\AppBundle\Entity\Billing\BillLine $billLine)
- {
- $this->billLines[] = $billLine;
- return $this;
- }
- /**
- * Remove billLine
- *
- * @param \AppBundle\Entity\Billing\BillLine $billLine
- */
- public function removeBillLine(\AppBundle\Entity\Billing\BillLine $billLine)
- {
- $this->billLines->removeElement($billLine);
- }
- /**
- * Get billLines
- *
- * @return \Doctrine\Common\Collections\Collection
- */
- public function getBillLines()
- {
- return $this->billLines;
- }
- /**
- * Add billingIntangibleExcludeDate
- *
- * @param \AppBundle\Entity\Billing\BillingIntangibleExcludeDate $billingIntangibleExcludeDate
- *
- * @return EquipmentLoan
- */
- public function addBillingIntangibleExcludeDate(\AppBundle\Entity\Billing\BillingIntangibleExcludeDate $billingIntangibleExcludeDate)
- {
- $this->billingIntangibleExcludeDates[] = $billingIntangibleExcludeDate;
- return $this;
- }
- /**
- * Remove billingIntangibleExcludeDate
- *
- * @param \AppBundle\Entity\Billing\BillingIntangibleExcludeDate $billingIntangibleExcludeDate
- */
- public function removeBillingIntangibleExcludeDate(\AppBundle\Entity\Billing\BillingIntangibleExcludeDate $billingIntangibleExcludeDate)
- {
- $this->billingIntangibleExcludeDates->removeElement($billingIntangibleExcludeDate);
- }
- /**
- * Get billingIntangibleExcludeDates
- *
- * @return \Doctrine\Common\Collections\Collection
- */
- public function getBillingIntangibleExcludeDates()
- {
- return $this->billingIntangibleExcludeDates;
- }
- /**
- * Set forcingAmount
- *
- * @param boolean $forcingAmount
- *
- * @return EquipmentLoan
- */
- public function setForcingAmount($forcingAmount)
- {
- $this->forcingAmount = $forcingAmount;
- return $this;
- }
- /**
- * Get forcingAmount
- *
- * @return boolean
- */
- public function getForcingAmount()
- {
- return $this->forcingAmount;
- }
- /**
- * Gets full label.
- *
- * @return array
- */
- public function getFullLabelTemplate()
- {
- $fullLabel = [];
- $fullLabel[] = $this->getBorrower() ? $this->getBorrower()->getPerson()->getFullNameTemplate() : '';
- $fullLabel[] = ['value' => $this->getType(), 'translate' => true];
- $fullLabel[] = ['type' => 'date', 'value' => $this->getStartDate()];
- if(!empty($this->getEndDate()))
- $fullLabel[] = ['type' => 'date', 'value' => $this->getEndDate()];
- return $fullLabel;
- }
- /**
- * Add tag
- *
- * @param \AppBundle\Entity\Core\Tagg $tag
- *
- * @return EquipmentLoan
- */
- public function addTag(\AppBundle\Entity\Core\Tagg $tag)
- {
- $this->tags[] = $tag;
- return $this;
- }
- /**
- * Remove tag
- *
- * @param \AppBundle\Entity\Core\Tagg $tag
- */
- public function removeTag(\AppBundle\Entity\Core\Tagg $tag)
- {
- $this->tags->removeElement($tag);
- }
- /**
- * Get tags
- *
- * @return \Doctrine\Common\Collections\Collection
- */
- public function getTags()
- {
- return $this->tags;
- }
- }
|