|
|
@@ -18,18 +18,41 @@ class OrderReferenceGenerator |
|
|
|
|
|
|
|
public function buildReference(OrderShopInterface $orderShop): string |
|
|
|
{ |
|
|
|
$complementaryIndex = null; |
|
|
|
|
|
|
|
if ($orderShop->getMainOrderShop()) { |
|
|
|
$complementaryIndex = 1; |
|
|
|
foreach ($orderShop->getMainOrderShop()->getComplementaryOrderShops() as $complementaryOrder) { |
|
|
|
if ($complementaryOrder->isValid()) $complementaryIndex++; |
|
|
|
} |
|
|
|
$orderShop = $complementaryOrder->getMainOrderShop(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
switch ($orderShop->getSection()->getCycleType()) { |
|
|
|
case SectionModel::CYCLE_TYPE_DAY: |
|
|
|
return $this->buildReferenceCycleDay($orderShop); |
|
|
|
$reference = $this->buildReferenceCycleDay($orderShop); |
|
|
|
break; |
|
|
|
case SectionModel::CYCLE_TYPE_WEEK: |
|
|
|
return $this->buildReferenceCycleWeek($orderShop); |
|
|
|
$reference = $this->buildReferenceCycleWeek($orderShop,); |
|
|
|
break; |
|
|
|
case SectionModel::CYCLE_TYPE_MONTH: |
|
|
|
return $this->buildReferenceCycleMonth($orderShop); |
|
|
|
$reference = $this->buildReferenceCycleMonth($orderShop); |
|
|
|
break; |
|
|
|
case SectionModel::CYCLE_TYPE_YEAR: |
|
|
|
return $this->buildReferenceCycleYear($orderShop); |
|
|
|
$reference = $this->buildReferenceCycleYear($orderShop); |
|
|
|
break; |
|
|
|
default: |
|
|
|
$reference = 'C' . $orderShop->getId(); |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
return 'C' . $orderShop->getId(); |
|
|
|
if($complementaryIndex){ |
|
|
|
$reference = $reference.'C'.$this->numberPad($complementaryIndex, 1); |
|
|
|
} |
|
|
|
|
|
|
|
return $reference; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public function buildReferenceCycleDay(OrderShopInterface $orderShop): string |