{ | { | ||||
$displayError =false; | $displayError =false; | ||||
foreach ($entity->getCodes() as $code) { | foreach ($entity->getCodes() as $code) { | ||||
if ($reductionCart = $this->orderUtils->getReductionCartByCode($code)) { | |||||
$this->addFlash('success', "Le code " . $code . " est déjà utilisé dans la réduction #" . $reductionCart->getId() . " " . $reductionCart->getTitle()); | |||||
$reductionCart = $this->orderUtils->getReductionCartByCode($code); | |||||
if ($reductionCart && $reductionCart->getId() != $entity->getId()) { | |||||
$this->addFlash('error', "Le code " . $code . " est déjà utilisé dans la réduction #" . $reductionCart->getId() . " " . $reductionCart->getTitle()); | |||||
$displayError = true; | $displayError = true; | ||||
} | } | ||||
} | } |
foreach($reductionCarts as $reductionCart) { | foreach($reductionCarts as $reductionCart) { | ||||
if($this->orderUtils->isReductionCartMatchWithUser($reductionCart, $user) | if($this->orderUtils->isReductionCartMatchWithUser($reductionCart, $user) | ||||
&& $this->orderUtils->isReductionCartMatchWithGroupUser($reductionCart, $user) | && $this->orderUtils->isReductionCartMatchWithGroupUser($reductionCart, $user) | ||||
&& $this->orderUtils->countReductionCartAvailableForUser($reductionCart, $user)) { | |||||
&& $this->orderUtils->countReductionCartAvailableForUser($reductionCart, $user) | |||||
&& ($reductionCart->getUsers()->count() > 0 || $reductionCart->getGroupUsers()->count() > 0)) { | |||||
$reductionCartsArray[] = $reductionCart ; | $reductionCartsArray[] = $reductionCart ; | ||||
} | } |
<div class="col-12"> | <div class="col-12"> | ||||
{{ form_row(form.type) }} | {{ form_row(form.type) }} | ||||
</div> | </div> | ||||
<div class="col-4"> | |||||
<div class="col-6"> | |||||
{{ form_row(form.availableQuantity) }} | {{ form_row(form.availableQuantity) }} | ||||
</div> | </div> | ||||
<div class="col-4"> | |||||
<div class="col-6"> | |||||
{{ form_row(form.availableQuantityPerUser) }} | {{ form_row(form.availableQuantityPerUser) }} | ||||
</div> | </div> | ||||
{# | |||||
<div class="col-4"> | <div class="col-4"> | ||||
{{ form_row(form.availableQuantityPerCode) }} | {{ form_row(form.availableQuantityPerCode) }} | ||||
</div> | |||||
</div>#} | |||||
<div class="col-12"> | <div class="col-12"> | ||||
{{ form_row(form.codes, {"attr":{'v-on:keyup' : 'updateCodes'}}) }} | {{ form_row(form.codes, {"attr":{'v-on:keyup' : 'updateCodes'}}) }} | ||||
</div> | </div> |