CKEditorField::new('description') | CKEditorField::new('description') | ||||
->hideOnIndex(), | ->hideOnIndex(), | ||||
BooleanField::new('isDefault'), | BooleanField::new('isDefault'), | ||||
BooleanField::new('isCommon'), | |||||
StatusField::new('status'), | StatusField::new('status'), | ||||
], | ], | ||||
$this->getSeoPanel(), | $this->getSeoPanel(), |
class DistributionFactory extends AbstractFactory | class DistributionFactory extends AbstractFactory | ||||
{ | { | ||||
public function create(int $cycleNumber, int $year, SectionInterface $section):Distribution | |||||
public function create(int $cycleNumber, int $year, string $cycleType, SectionInterface $section):Distribution | |||||
{ | { | ||||
$distribution = new Distribution(); | $distribution = new Distribution(); | ||||
$distribution->setSection($section); | $distribution->setSection($section); | ||||
$distribution->setCycleNumber($cycleNumber); | $distribution->setCycleNumber($cycleNumber); | ||||
$distribution->setCycleType($cycleType); | |||||
$distribution->setYear($year); | $distribution->setYear($year); | ||||
return $distribution; | return $distribution; |
return $this; | return $this; | ||||
} | } | ||||
public function addAndWhere($whereClause, $parameter): self | |||||
public function addAndWhere($whereClause, $key, $value): self | |||||
{ | { | ||||
$this->queryBuilderParameters['leftJoin'][] = [ | |||||
$this->queryBuilderParameters['andWhere'][] = [ | |||||
'whereClause' => $whereClause, | 'whereClause' => $whereClause, | ||||
'parameter' => $parameter | |||||
'key' => $key, | |||||
'value' => $value | |||||
]; | ]; | ||||
return $this; | return $this; | ||||
if (isset($param['andWhere'])) { | if (isset($param['andWhere'])) { | ||||
foreach ($param['andWhere'] as $i => $whereClause) { | foreach ($param['andWhere'] as $i => $whereClause) { | ||||
$qb->andWhere($whereClause['whereClause'])->setParamater($whereClause['parameter']); | |||||
$qb->andWhere($whereClause['whereClause'])->setParameter($whereClause['key'], $whereClause['value']); | |||||
} | } | ||||
} | } | ||||
*/ | */ | ||||
protected $year; | protected $year; | ||||
/** | |||||
* @ORM\Column(type="string", length=32) | |||||
*/ | |||||
protected $cycleType; | |||||
public function getSection(): ?SectionInterface | public function getSection(): ?SectionInterface | ||||
{ | { | ||||
return $this->section; | return $this->section; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getCycleType(): ?string | |||||
{ | |||||
return $this->cycleType; | |||||
} | |||||
public function setCycleType(string $cycleType): self | |||||
{ | |||||
$this->cycleType = $cycleType; | |||||
return $this; | |||||
} | |||||
} | } |
*/ | */ | ||||
protected $openings; | protected $openings; | ||||
/** | |||||
* @ORM\Column(type="boolean", nullable=true) | |||||
*/ | |||||
protected $isCommon; | |||||
/** | /** | ||||
* @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductFamilySectionPropertyInterface", mappedBy="section") | * @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductFamilySectionPropertyInterface", mappedBy="section") | ||||
*/ | */ | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getIsCommon(): ?bool | |||||
{ | |||||
return $this->isCommon; | |||||
} | |||||
public function setIsCommon(?bool $isCommon): self | |||||
{ | |||||
$this->isCommon = $isCommon; | |||||
return $this; | |||||
} | |||||
/** | /** | ||||
* @return Collection|ProductFamilySectionPropertyInterface[] | * @return Collection|ProductFamilySectionPropertyInterface[] | ||||
*/ | */ |
->andWhere('.cycleNumber = :cycleNumber') | ->andWhere('.cycleNumber = :cycleNumber') | ||||
->setParameter('cycleNumber', $cycleNumber); | ->setParameter('cycleNumber', $cycleNumber); | ||||
} | } | ||||
public function filterByCycleType(string $cycleType): self | |||||
{ | |||||
return $this | |||||
->andWhere('.cycleType = :cycleType') | |||||
->setParameter('cycleType', $cycleType); | |||||
} | |||||
} | } |
public function getOneByCycleNumberYearAndSection( | public function getOneByCycleNumberYearAndSection( | ||||
int $cycleNumber, | int $cycleNumber, | ||||
int $year, | int $year, | ||||
string $cycleType, | |||||
SectionInterface $section | SectionInterface $section | ||||
): ?Distribution { | ): ?Distribution { | ||||
$query = $this->createQuery(); | $query = $this->createQuery(); | ||||
$query->filterByCycleNumber($cycleNumber); | $query->filterByCycleNumber($cycleNumber); | ||||
$query->filterByYear($year); | $query->filterByYear($year); | ||||
$query->filterByCycleType($cycleType); | |||||
$query->filterBySection($section); | $query->filterBySection($section); | ||||
return $query->findOne(); | return $query->findOne(); |
public function filterBySection(SectionInterface $section) | public function filterBySection(SectionInterface $section) | ||||
{ | { | ||||
$this->joinProductFamilySectionProperties(); | $this->joinProductFamilySectionProperties(); | ||||
return $this->andWhereSection('pfsp', $section); | |||||
$this->andWhereSection('pfsp', $section); | |||||
$this->andWhere('pfsp.status = 1'); | |||||
} | } | ||||
return $this->andWhereEqual('isDefault', $isDefault); | return $this->andWhereEqual('isDefault', $isDefault); | ||||
} | } | ||||
public function filterByIsCommon(bool $isCommon) | |||||
{ | |||||
return $this->andWhereEqual('isCommon', $isCommon); | |||||
} | |||||
} | } |
// @TODO : à implémenter avec le nouveau système d'ouverture des commandes | // @TODO : à implémenter avec le nouveau système d'ouverture des commandes | ||||
} | } | ||||
public function getOnlineWithoutCommon($query = null) | |||||
{ | |||||
$query = $this->createDefaultQuery($query); | |||||
$query->filterByIsCommon(false); | |||||
return $query->find(); | |||||
} | |||||
} | } |
} | } | ||||
} | } | ||||
public function getDefault():SectionInterface | |||||
{ | |||||
return $this->sectionStore->setMerchant($this->merchantResolver->getCurrent())->getOneDefault(); | |||||
} | |||||
} | } |
fields: | fields: | ||||
cycle: Cycle de vente | cycle: Cycle de vente | ||||
isDefault: Section par défaut | isDefault: Section par défaut | ||||
isCommon: Section commune | |||||
TaxRate: | TaxRate: | ||||
label: Règle de taxe | label: Règle de taxe | ||||
label_plurial: Règles de taxes | label_plurial: Règles de taxes |