mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-28 02:23:51 +00:00
Raw integration of accompanying person (with respect of 'cahier de cahrge)
This commit is contained in:
@@ -30,47 +30,33 @@ use Symfony\Component\Validator\ExecutionContextInterface;
|
||||
*/
|
||||
class AccompanyingPeriod
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
*/
|
||||
/** @var integer */
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var \DateTime
|
||||
*/
|
||||
private $date_opening;
|
||||
/** @var \DateTime */
|
||||
private $openingDate;
|
||||
|
||||
/**
|
||||
* @var \DateTime
|
||||
*/
|
||||
private $date_closing;
|
||||
/** @var \DateTime */
|
||||
private $closingDate;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $memo = '';
|
||||
/** @var string */
|
||||
private $remark = '';
|
||||
|
||||
/**
|
||||
* @var \Chill\PersonBundle\Entity\Person
|
||||
*/
|
||||
/** @var \Chill\PersonBundle\Entity\Person */
|
||||
private $person;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var AccompanyingPeriod\ClosingMotive
|
||||
*/
|
||||
/** @var AccompanyingPeriod\ClosingMotive */
|
||||
private $closingMotive = null;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param \DateTime $dateOpening
|
||||
* @uses AccompanyingPeriod::setDateClosing()
|
||||
* @uses AccompanyingPeriod::setClosingDate()
|
||||
*/
|
||||
public function __construct(\DateTime $dateOpening) {
|
||||
$this->setDateOpening($dateOpening);
|
||||
$this->setOpeningDate($dateOpening);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
@@ -82,30 +68,30 @@ class AccompanyingPeriod
|
||||
}
|
||||
|
||||
/**
|
||||
* Set date_opening
|
||||
* Set openingDate
|
||||
*
|
||||
* @param \DateTime $dateOpening
|
||||
* @return AccompanyingPeriod
|
||||
*/
|
||||
public function setDateOpening($dateOpening)
|
||||
public function setOpeningDate($openingDate)
|
||||
{
|
||||
$this->date_opening = $dateOpening;
|
||||
$this->openingDate = $openingDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get date_opening
|
||||
* Get openingDate
|
||||
*
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getDateOpening()
|
||||
public function getOpeningDate()
|
||||
{
|
||||
return $this->date_opening;
|
||||
return $this->openingDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set date_closing
|
||||
* Set closingDate
|
||||
*
|
||||
* For closing a Person file, you should use Person::setClosed instead.
|
||||
*
|
||||
@@ -113,21 +99,21 @@ class AccompanyingPeriod
|
||||
* @return AccompanyingPeriod
|
||||
*
|
||||
*/
|
||||
public function setDateClosing($dateClosing)
|
||||
public function setClosingDate($closingDate)
|
||||
{
|
||||
$this->date_closing = $dateClosing;
|
||||
$this->closingDate = $closingDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get date_closing
|
||||
* Get closingDate
|
||||
*
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getDateClosing()
|
||||
public function getClosingDate()
|
||||
{
|
||||
return $this->date_closing;
|
||||
return $this->closingDate;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -135,7 +121,7 @@ class AccompanyingPeriod
|
||||
* @return boolean
|
||||
*/
|
||||
public function isOpen() {
|
||||
if ($this->getDateClosing() === null) {
|
||||
if ($this->getClosingDate() === null) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -143,30 +129,30 @@ class AccompanyingPeriod
|
||||
}
|
||||
|
||||
/**
|
||||
* Set memo
|
||||
* Set remark
|
||||
*
|
||||
* @param string $memo
|
||||
* @param string $remark
|
||||
* @return AccompanyingPeriod
|
||||
*/
|
||||
public function setMemo($memo)
|
||||
public function setRemark($remark)
|
||||
{
|
||||
if ($memo === null) {
|
||||
$memo = '';
|
||||
if ($remark === null) {
|
||||
$remark = '';
|
||||
}
|
||||
|
||||
$this->memo = $memo;
|
||||
$this->remark = $remark;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get memo
|
||||
* Get remark
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getMemo()
|
||||
public function getRemark()
|
||||
{
|
||||
return $this->memo;
|
||||
return $this->remark;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -225,7 +211,7 @@ class AccompanyingPeriod
|
||||
* @return boolean
|
||||
*/
|
||||
public function isClosingAfterOpening() {
|
||||
$diff = $this->getDateOpening()->diff($this->getDateClosing());
|
||||
$diff = $this->getOpeningDate()->diff($this->getClosingDate());
|
||||
|
||||
if ($diff->invert === 0) {
|
||||
return true;
|
||||
|
@@ -192,12 +192,12 @@ class Person implements HasCenterInterface {
|
||||
//order by date :
|
||||
usort($periods, function($a, $b) {
|
||||
|
||||
$dateA = $a->getDateOpening();
|
||||
$dateB = $b->getDateOpening();
|
||||
$dateA = $a->getOpeningDate();
|
||||
$dateB = $b->getOpeningDate();
|
||||
|
||||
if ($dateA == $dateB) {
|
||||
$dateEA = $a->getDateClosing();
|
||||
$dateEB = $b->getDateClosing();
|
||||
$dateEA = $a->getClosingDate();
|
||||
$dateEB = $b->getClosingDate();
|
||||
|
||||
if ($dateEA == $dateEB) {
|
||||
return 0;
|
||||
@@ -647,17 +647,17 @@ class Person implements HasCenterInterface {
|
||||
if($periodI->isOpen()) {
|
||||
return array(
|
||||
'result' => self::ERROR_ADDIND_PERIOD_AFTER_AN_OPEN_PERIOD,
|
||||
'dateOpening' => $periodAfterI->getDateOpening(),
|
||||
'dateClosing' => $periodAfterI->getDateClosing(),
|
||||
'date' => $periodI->getDateOpening()
|
||||
'dateOpening' => $periodAfterI->getOpeningDate(),
|
||||
'dateClosing' => $periodAfterI->getClosingDate(),
|
||||
'date' => $periodI->getOpeningDate()
|
||||
);
|
||||
} elseif ($periodI->getDateClosing() >= $periodAfterI->getDateOpening()) {
|
||||
} elseif ($periodI->getClosingDate() >= $periodAfterI->getOpeningDate()) {
|
||||
return array(
|
||||
'result' => self::ERROR_PERIODS_ARE_COLLAPSING,
|
||||
'dateOpening' => $periodI->getDateOpening(),
|
||||
'dateOpening' => $periodI->getOpeningDate(),
|
||||
|
||||
'dateClosing' => $periodI->getDateClosing(),
|
||||
'date' => $periodAfterI->getDateOpening()
|
||||
'dateClosing' => $periodI->getClosingDate(),
|
||||
'date' => $periodAfterI->getOpeningDate()
|
||||
);
|
||||
}
|
||||
$i++;
|
||||
|
Reference in New Issue
Block a user