$i18n->__("Poniedziałek"), 2 => $i18n->__("Wtorek"), 3 => $i18n->__("Środa"), 4 => $i18n->__("Czwartek"), 5 => $i18n->__("Piątek"), 6 => $i18n->__("Sobota"), 7 => $i18n->__("Niedziela"), ]; } /** * Zwraca liste płatności dla danej dostawy * * @param mixed $pk * @param mixed $con * @return PaymentType[] */ public static function doSelectPaymentsWithDeliveryHasPaymentsByPK($pk, $con = null) { $c = new Criteria(); $c->addJoin(PaymentTypePeer::ID, sprintf("%s AND %s = %d", DeliveryHasPaymentTypePeer::PAYMENT_TYPE_ID, DeliveryHasPaymentTypePeer::DELIVERY_ID, $pk), Criteria::LEFT_JOIN); $c->add(PaymentTypePeer::ACTIVE, true); $c->add(PaymentTypePeer::HIDE_FOR_DELIVERY_CONFIGURATION, false); $c->addDescendingOrderByColumn(DeliveryHasPaymentTypePeer::IS_ACTIVE); $c->addAscendingOrderByColumn(DeliveryHasPaymentTypePeer::ID); stEventDispatcher::getInstance()->notify(new sfEvent($c, 'DeliveryPeer.doSelectPaymentsWithDeliveryHasPaymentsByPK')); $joinHelper = new sfPropelCustomJoinHelper('PaymentType'); $joinHelper->addSelectTables('DeliveryHasPaymentType'); return $joinHelper->doSelect($c, $con); } public static function doSelectDefault(Criteria $c, $con = null) { $criteria = clone $c; $criteria->add(self::IS_DEFAULT, true); return self::doSelectOne($criteria, $con); } public static function retrieveIdsCached() { if (null === self::$cachedIds) { self::$cachedIds = stFunctionCache::getInstance('stDelivery')->cacheCall(array('DeliveryPeer', 'retrieveIds'), array(), array('id' => 'delivery-ids')); } return self::$cachedIds; } public static function retrieveAllowedIdsCached() { if (null === self::$cachedAllowedIds) { self::$cachedAllowedIds = stFunctionCache::getInstance('stDelivery')->cacheCall(array('DeliveryPeer', 'retrieveIds'), array(false), array('id' => 'delivery-allowed-ids')); } return self::$cachedAllowedIds; } public static function retrieveIds($allowed_in_selected_products = null) { $c = new Criteria(); $c->addSelectColumn(self::ID); $c->add(self::ACTIVE, true); if (null !== $allowed_in_selected_products) { $c->add(self::ALLOW_IN_SELECTED_PRODUCTS, $allowed_in_selected_products); } $rs = self::doSelectRS($c); $ids = array(); while($rs->next()) { $row = $rs->getRow(); $ids[$row[0]] = $row[0]; } return $ids; } public static function retrieveIdsFor(stDeliveryProductInfoAbstract $productInfo, Criteria $criteria) { $c = clone $criteria; $c->clearSelectColumns(); $c->addSelectColumn('MIN('.self::VOLUME.')'); $c->add(self::WIDTH, $productInfo->getMaxWidth(), Criteria::GREATER_EQUAL); $c->add(self::HEIGHT, $productInfo->getMaxHeight(), Criteria::GREATER_EQUAL); $c->add(self::DEPTH, $productInfo->getMaxDepth(), Criteria::GREATER_EQUAL); $c->add(self::VOLUME, $productInfo->getTotalVolume(), Criteria::GREATER_EQUAL); $c->addGroupByColumn(self::TYPE_ID); $sql = BasePeer::createSqlQuery($c); $c = clone $criteria; $c->clearSelectColumns(); $c->addSelectColumn(self::ID); $c->add(self::VOLUME, sprintf('(%s = 0 OR %s IN (%s))', self::VOLUME, self::VOLUME, $sql), Criteria::CUSTOM); $c->add(self::TYPE_ID, null, Criteria::ISNOTNULL); $c->addGroupByColumn(self::TYPE_ID); $rs = self::doSelectRS($c); $volumes = array(); while($rs->next()) { $row = $rs->getRow(); $volumes[] = $row[0]; } return $volumes; } /** * Dodaje kryteria filtrowania dostaw * * @param Criteria $c * @param stDeliveryProductInfoAbstract $productInfo * @return void * @throws PropelException * @throws SQLException */ public static function addMaxFilterCriteria(Criteria $c, stDeliveryProductInfoAbstract $productInfo) { $query = '((%1$s = 0 OR %1$s <= %3$s) AND (%2$s = 0 OR %2$s >= %3$s))'; $c->add(self::MAX_ORDER_AMOUNT, sprintf($query, self::MIN_ORDER_AMOUNT, self::MAX_ORDER_AMOUNT, $productInfo->getTotalAmount()), Criteria::CUSTOM); $c->add(self::MAX_ORDER_QUANTITY, sprintf($query, self::MIN_ORDER_QUANTITY, self::MAX_ORDER_QUANTITY, $productInfo->getTotalQuantity()), Criteria::CUSTOM); $c->add(self::MAX_ORDER_WEIGHT, sprintf($query, self::MIN_ORDER_WEIGHT, self::MAX_ORDER_WEIGHT, $productInfo->getTotalWeight()), Criteria::CUSTOM); if (!empty($productInfo->getAllowedDeliveries())) { $c->add(self::ID, $productInfo->getAllowedDeliveries(), Criteria::IN); } else { $c->add(self::ALLOW_IN_SELECTED_PRODUCTS, false); } $c1 = $c->getNewCriterion(self::VOLUME, 0); $ids = self::retrieveIdsFor($productInfo, $c); if ($ids) { $c1->addOr($c->getNewCriterion(self::ID, $ids, Criteria::IN)); } $c2 = $c->getNewCriterion(self::TYPE_ID, null, Criteria::ISNULL); $c2->addAnd($c->getNewCriterion(self::WIDTH, $productInfo->getMaxWidth(), Criteria::GREATER_EQUAL)); $c2->addAnd($c->getNewCriterion(self::HEIGHT, $productInfo->getMaxHeight(), Criteria::GREATER_EQUAL)); $c2->addAnd($c->getNewCriterion(self::DEPTH, $productInfo->getMaxDepth(), Criteria::GREATER_EQUAL)); $c2->addAnd($c->getNewCriterion(self::VOLUME, $productInfo->getTotalVolume(), Criteria::GREATER_EQUAL)); $c1->addOr($c2); $c->add($c1); if (stConfig::getInstance('stDeliveryBackend')->get('alternate_deliveries') && !self::doCount($c)) { $c->remove(self::MAX_ORDER_AMOUNT); $c->remove(self::MAX_ORDER_QUANTITY); $c->remove(self::MAX_ORDER_WEIGHT); $c->remove($c1); } } }