67 lines
2.0 KiB
PHP
67 lines
2.0 KiB
PHP
<?php
|
|
|
|
class stDiscountCouponCodeBackendActions extends autoStDiscountCouponCodeBackendActions
|
|
{
|
|
protected function addFiltersCriteria($c)
|
|
{
|
|
parent::addFiltersCriteria($c);
|
|
|
|
if (isset($this->filters['generated_for']) && $this->filters['generated_for'] !== '')
|
|
{
|
|
$cc = $c->getNewCriterion(OrderPeer::NUMBER, $this->filters['generated_for'].'%', Criteria::LIKE);
|
|
|
|
$cc->addOr($c->getNewCriterion(OrderPeer::OPT_CLIENT_EMAIL, '%'.$this->filters['generated_for'].'%', Criteria::LIKE));
|
|
|
|
$c->add($cc);
|
|
}
|
|
}
|
|
|
|
protected function saveDiscountCouponCode($discount_coupon_code)
|
|
{
|
|
$isNew = $discount_coupon_code->isNew();
|
|
|
|
$result = parent::saveDiscountCouponCode($discount_coupon_code);
|
|
|
|
$categories = stJQueryToolsHelper::parseTokensFromRequest($this->getRequestParameter('categories'));
|
|
|
|
if (!$isNew)
|
|
{
|
|
$c = new Criteria();
|
|
|
|
$c->add(DiscountCouponCodeHasCategoryPeer::DISCOUNT_COUPON_CODE_ID, $discount_coupon_code->getId());
|
|
|
|
DiscountCouponCodeHasCategoryPeer::doDelete($c);
|
|
}
|
|
|
|
foreach ($categories as $token)
|
|
{
|
|
|
|
$ghc = new DiscountCouponCodeHasCategory();
|
|
$ghc->setDiscountCouponCode($discount_coupon_code);
|
|
$ghc->setCategoryId($token['id']);
|
|
$ghc->save();
|
|
}
|
|
|
|
$producers = stJQueryToolsHelper::parseTokensFromRequest($this->getRequestParameter('producers'));
|
|
|
|
if (!$isNew)
|
|
{
|
|
$c = new Criteria();
|
|
|
|
$c->add(DiscountCouponCodeHasProducerPeer::DISCOUNT_COUPON_CODE_ID, $discount_coupon_code->getId());
|
|
|
|
DiscountCouponCodeHasProducerPeer::doDelete($c);
|
|
}
|
|
|
|
foreach ($producers as $token)
|
|
{
|
|
$ghp = new DiscountCouponCodeHasProducer();
|
|
$ghp->setDiscountCouponCode($discount_coupon_code);
|
|
$ghp->setProducerId($token['id']);
|
|
$ghp->save();
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
}
|