first commit

This commit is contained in:
2025-03-12 17:06:23 +01:00
commit 2241f7131f
13185 changed files with 1692479 additions and 0 deletions

View File

@@ -0,0 +1,157 @@
<?php
/**
* SOTESHOP/stDelivery
*
* Ten plik należy do aplikacji stOrder opartej na licencji (Professional License SOTE).
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
*
* @package stOrder
* @subpackage helpers
* @copyright SOTE (www.sote.pl)
* @license http://www.sote.pl/license/sote (Professional License SOTE)
* @version $Id: stOrderHelper.php 13690 2011-06-20 06:58:55Z marcin $
*/
function getDeliveryDateFormat($date)
{
if ($date)
{
$date = explode(" ", $date);
if($date[0]!="1999-11-30")
{
$date_format = explode("-",$date[0]);
$delivery_date = $date_format[2]."-".$date_format[1]."-".$date_format[0];
}
else
{
$delivery_date = "";
}
if($date[1]!="00:00:00")
{
$time_format = explode(":",$date[1]);
$delivery_time = $time_format[0].":".$time_format[1];
}
else
{
$delivery_time = "";
}
return $delivery_date." ".$delivery_time;
}
else
{
return '';
}
}
function countries_select_tag($name, $selected = null)
{
$countries = CountriesPeer::doSelectActiveCached();
ob_start();
foreach ($countries as $country)
{
if ($country->getId() == $selected)
{
echo '<option value="'.$country->getId().'" selected="selected">'.$country->getName().'</option>';
}
else
{
echo '<option value="'.$country->getId().'">'.$country->getName().'</option>';
}
}
$options = ob_get_clean();
return '<select class="form-control" name="'.$name.'" id="'.get_id_from_name($name).'">'.$options.'</select>';
}
function delivery_countries_select_tag($name, $selected = null)
{
$basket = sfContext::getInstance()->getUser()->getBasket();
$delivery = stDeliveryFrontend::getInstance($basket);
$delivery_countries = $delivery->getDeliveryCountries(true);
$options = '';
ob_start();
foreach ($delivery_countries as $country)
{
if ($country->getId() == $selected)
{
echo '<option value="'.$country->getId().'" selected="selected">'.$country->getName().'</option>';
}
else
{
echo '<option value="'.$country->getId().'">'.$country->getName().'</option>';
}
}
$options = ob_get_clean();
return '<select class="form-control" name="'.$name.'" id="'.get_id_from_name($name).'">'.$options.'</select>';
}
function delivery_parcels_manager_tag($name, ?array $parcels, array $options)
{
$id = get_id_from_name($name);
if (null === $parcels)
{
$parcels = [];
}
foreach ($parcels as $index => $value)
{
$no = $index + 1;
$parcels[$index]['reference'] = ' #' . $no;
}
if (!isset($options['fields']))
{
throw new sfException('Opcja "fields" jest wymagana');
}
$defaultFields = array(
'reference' => array(
'label' => __('Paczka'),
'type' => 'plain',
),
);
$fields = $defaultFields + $options['fields'];
unset($options['fields']);
$content = st_admin_table_record_manager($name, $fields, $parcels, $options);
$content .= "
<script>
jQuery(function($) {
\$('#st_trm_$id')
.on('postAdd', function(e, row, fields, index, namespace) {
let name = namespace + '[' + index + '][reference]';
let no = row.parent().find('tr').length;
row.find('.st_trm_field_reference').html('#' + no);
}).on('postRemove', function() {
let no = 1;
\$(this).stTableRecordManager('rows').each(function() {
\$(this).find('.st_trm_field_reference').html('#' + no);
no++;
});
});
});
</script>";
return $content;
}

View File

@@ -0,0 +1,693 @@
<?php
/**
* SOTESHOP/stDelivery
*
* Ten plik należy do aplikacji stDelivery opartej na licencji (Professional License SOTE).
* Nie zmieniaj tego pliku, jeśli chcesz korzystać z automatycznych aktualizacji oprogramowania.
* Jeśli chcesz wprowadzać swoje modyfikacje do programu, zapoznaj się z dokumentacją, jak zmieniać
* oprogramowanie bez zmiany kodu bazowego http://www.sote.pl/modifications
*
* @package stDelivery
* @subpackage libs
* @copyright SOTE (www.sote.pl)
* @license http://www.sote.pl/license/sote (Professional License SOTE)
* @version $Id: Delivery.php 10244 2011-01-13 14:26:05Z michal $
* @author Marcin Olejniczak <marcin.olejniczak@sote.pl>
*/
/**
* Subclass for representing a row from the 'st_delivery' table.
*
* @package stDelivery
* @subpackage libs
*/
class Delivery extends BaseDelivery
{
protected static $currency = null;
protected $withEuTax = true;
public function __construct()
{
if (null === self::$currency && SF_APP == 'frontend')
{
self::$currency = stCurrency::getInstance(sfContext::getInstance())->get();
}
}
public function __toString()
{
return $this->getName();
}
/**
* Sprawdza czy dostawa jest Aktywna
*
* @return bool
*/
public function getIsActive()
{
return $this->active;
}
/**
* Ustawia aktywną dostawę
*
* @param bool $active
* @return void
*/
public function setIsActive($active)
{
$this->setActive($active);
}
public function isWeekendDeliveryAvailable()
{
$date = new DateTime();
$currentDay = $date->format('N');
$currentTime = $date->format('H:i');
$from = $this->getWeekendDeliveryAvailabilityFrom();
$to = $this->getWeekendDeliveryAvailabilityTo();
if (!empty($from) && "" !== $from['day'] && ($from['day'] > $currentDay || $from['day'] == $currentDay && strtotime($from['time']) > strtotime($currentTime)))
{
return false;
}
if (!empty($to) && "" !== $to['day'] && ($to['day'] < $currentDay || $to['day'] == $currentDay && strtotime($to['time']) < strtotime($currentTime)))
{
return false;
}
return $this->isWeekendDelivery();
}
public function getWeekendDeliveryAvailabilityFrom()
{
$params = $this->getWeekendDeliveryAvailability();
return !empty($params) && isset($params['from']) ? $params['from'] : null;
}
public function setWeekendDeliveryAvailabilityFrom($availability)
{
$params = !empty($this->getWeekendDeliveryAvailability()) ? $this->getWeekendDeliveryAvailability() : [];
$params['from'] = $availability;
$this->setWeekendDeliveryAvailability($params);
}
public function getWeekendDeliveryAvailabilityTo()
{
$params = $this->getWeekendDeliveryAvailability();
return !empty($params) && isset($params['to']) ? $params['to'] : null;
}
public function setWeekendDeliveryAvailabilityTo($availability)
{
$params = $this->getWeekendDeliveryAvailability();
$params['to'] = $availability;
$this->setWeekendDeliveryAvailability($params);
}
public function isWeekendDelivery()
{
return $this->getIsWeekendDelivery();
}
public function isExpressDelivery()
{
return $this->getIsExpressDelivery();
}
public function getIsWeekendDelivery()
{
$weekendDelivery = parent::getIsWeekendDelivery();
return null === $weekendDelivery && null !== $this->weekend_delivery_cost_netto || $weekendDelivery;
}
public function setWidth($v)
{
parent::setWidth($v);
$this->computeVolume();
}
public function setHeight($v)
{
parent::setHeight($v);
$this->computeVolume();
}
public function setDepth($v)
{
parent::setDepth($v);
$this->computeVolume();
}
public function getMaxOrderWeight()
{
return $this->format(parent::getMaxOrderWeight());
}
public function getMaxOrderAmount()
{
return $this->format(parent::getMaxOrderAmount());
}
public function getMinOrderWeight()
{
return $this->format(parent::getMinOrderWeight());
}
public function getMinOrderAmount()
{
return $this->format(parent::getMinOrderAmount());
}
public function getDefaultCost()
{
return $this->format(parent::getDefaultCost());
}
public function getCostNetto($with_currency = false)
{
$v = $this->getDefaultCost();
if ($with_currency)
{
$v = self::$currency->exchange($v);
}
return $v;
}
public function setCostNetto($v)
{
$this->setDefaultCost($v);
}
public function getCostBrutto($with_currency = false)
{
if (SF_APP == 'frontend' && (sfContext::getInstance()->getUser()->hasVatEu() || sfContext::getInstance()->getUser()->hasVatEx()))
{
return $this->getCostNetto($with_currency);
}
$cost = $this->getDefaultCostBrutto();
if (null === $cost)
{
$cost = stPrice::calculate($this->getCostNetto(), $this->getVat());
$this->setCostBrutto($cost);
}
$countryTaxRate = $this->getTax()->getTaxRateByCountry();
if (null !== $countryTaxRate)
{
$cost = stPrice::calculate(parent::getDefaultCost(), $countryTaxRate);
}
if ($with_currency)
{
$cost = self::$currency->exchange($cost);
}
return $this->format($cost);
}
public function getFreeDelivery()
{
if (SF_APP == 'frontend' && (sfContext::getInstance()->getUser()->hasVatEu() || sfContext::getInstance()->getUser()->hasVatEx()))
{
return stPrice::extract(parent::getFreeDelivery(), $this->getVat(false));
}
return parent::getFreeDelivery();
}
public function getVat($withEuTax = true)
{
$this->withEuTax = $withEuTax;
$tax = $this->getTax();
return $tax->getTaxRateByCountry() ? $tax->getTaxRateByCountry() : $tax->getDefaultTaxRate();
}
public function setCostBrutto($v)
{
$this->setDefaultCostBrutto($v);
}
public function getFreeFrom()
{
return $this->format($this->getFreeDelivery());
}
public function setFreeFrom($v)
{
$this->setFreeDelivery($v);
}
public function getService(): ?stDeliveryTypeInterface
{
return null !== $this->getType() ? stDeliveryTypeService::get($this->getType()) : null;
}
public function getType(): ?string
{
return DeliveryTypePeer::retrieveTypeById($this->getTypeId());
}
public function isType($type)
{
return $this->getType() == $type;
}
public function getSectionCostTypeDesc()
{
$tmp = DeliverySectionsPeer::getAdditionalSectionCosts();
return $this->getSectionCostType() ? $tmp[$this->getSectionCostType()] : null;
}
/**
* Zwraca typ płatności dla przypisany do dostawy
*
* @param int $paymentTypeId
* @return DeliveryHasPaymentType|null
* @throws PropelException
*/
public function getDeliveryPaymentType(int $paymentTypeId)
{
$c = new Criteria();
$c->add(DeliveryHasPaymentTypePeer::PAYMENT_TYPE_ID, $paymentTypeId);
$c->add(DeliveryHasPaymentTypePeer::IS_ACTIVE, true);
$c->setLimit(1);
$results = DeliveryHasPaymentTypePeer::doSelectJoinPaymentType($c);
return !empty($results) ? $results[0] : null;
}
/**
*
* Dodana na potrzeby admin generator
*
* @param int $v Id vat
*/
public function setEditTax($v)
{
$this->setTaxId($v);
}
/**
* @inheritDoc
*/
public function getTax($con = null)
{
if (SF_APP == 'frontend' && $this->withEuTax)
{
$user = sfContext::getInstance()->getUser();
if ($user->hasVatEu())
{
return stTax::getEu();
}
elseif ($user->hasVatEx())
{
return stTax::getEx();
}
}
$this->aTax = parent::getTax($con);
if (null === $this->aTax)
{
$this->aTax = TaxPeer::doSelectDefaultOne(new Criteria());
}
return $this->aTax;
}
public function isFree(stDeliveryProductInfoAbstract $productInfo)
{
return $this->getFreeFrom() > 0 && $productInfo->getTotalAmount() >= $this->getFreeFrom();
}
/**
* Zwraca całkowity koszt brutto
*
* @param stDeliveryProductInfoAbstract $productInfo
* @param bool $withCurrency
* @return float|string
* @throws PropelException
*/
public function getTotalCostBrutto(stDeliveryProductInfoAbstract $productInfo, $withCurrency = false)
{
return $this->getTotalCost($productInfo, true, $withCurrency);
}
/**
* Zwraca całkowity koszt netto
*
* @param stDeliveryProductInfoAbstract $productInfo
* @param bool $withCurrency
* @return float|string
* @throws PropelException
*/
public function getTotalCostNetto(stDeliveryProductInfoAbstract $productInfo, $withCurrency = false)
{
return $this->getTotalCost($productInfo, false, $withCurrency);
}
/**
* Zwraca całkowity koszt
*
* @param stDeliveryProductInfoAbstract $productInfo
* @param bool $withTax
* @param bool $withCurrency
* @return mixed
* @throws PropelException
*/
public function getTotalCost(stDeliveryProductInfoAbstract $productInfo, $withTax = false, $withCurrency = false)
{
if ($this->isFree($productInfo))
{
return 0;
}
$priceType = stConfig::getInstance('stProduct')->get('delivery_price_type', 'netto');
$totalProductDeliveryPrice = $productInfo->getTotalDeliveryPrice();
if ($priceType == 'netto' && $withTax)
{
$totalProductDeliveryPrice = stPrice::calculate($totalProductDeliveryPrice, $this->getVat());
}
if ($priceType == 'brutto' && !$withTax)
{
$totalProductDeliveryPrice = stPrice::extract($totalProductDeliveryPrice, $this->getVat());
}
if ($withCurrency)
{
$totalProductDeliveryPrice = self::$currency->exchange($totalProductDeliveryPrice);
}
$defaultCost = $withTax ? $this->getCostBrutto($withCurrency) : $this->getCostNetto($withCurrency);
return $defaultCost + $totalProductDeliveryPrice + $this->getAdditionaCost($productInfo, $withTax, $withCurrency);
}
/**
* Zwraca dodatkowy koszt
*
* @param stDeliveryProductInfoAbstract $productInfo
* @param bool $withTax
* @param bool $withCurrency
* @return mixed
* @throws PropelException
*/
public function getAdditionaCost(stDeliveryProductInfoAbstract $productInfo, $withTax = false, $withCurrency = false)
{
if ($this->isFree($productInfo))
{
return 0;
}
switch ($this->getSectionCostType())
{
case "ST_BY_ORDER_AMOUNT":
$fromValue = $productInfo->getTotalAmount();
break;
case "ST_BY_ORDER_QUANTITY":
$fromValue = $productInfo->getTotalQuantity();
break;
case "ST_BY_ORDER_WEIGHT":
$fromValue = $productInfo->getTotalWeight();
break;
default:
$fromValue = 0;
break;
}
$c = new Criteria();
$c->add(DeliverySectionsPeer::VALUE_FROM, $fromValue, Criteria::LESS_EQUAL);
$c->setLimit(1);
$c->addDescendingOrderByColumn(DeliverySectionsPeer::VALUE_FROM);
$results = $this->getDeliverySectionss($c);
if (empty($results))
{
return 0.00;
}
$results[0]->setDelivery($this);
return $withTax ? $results[0]->getCostBrutto($withCurrency) : $results[0]->getCostNetto($withCurrency);
}
/**
* Zwraca koszt dostawy w weekend
*
* @param stDeliveryProductInfoAbstract $productInfo
* @param bool $withTax
* @param bool $withCurrency
* @return float|string
*/
public function getWeekendDeliveryCost(stDeliveryProductInfoAbstract $productInfo, $withTax = false, $withCurrency = false)
{
if ($this->isFree($productInfo) && !$this->getAlwaysChargeWeekendDeliveryCost())
{
return 0;
}
if ($withTax && (SF_APP != 'frontend' || !sfContext::getInstance()->getUser()->hasVatEu() && !sfContext::getInstance()->getUser()->hasVatEx()))
{
$cost = $this->getWeekendDeliveryCostBrutto();
$countryTaxRate = $this->getTax()->getTaxRateByCountry();
if (null !== $countryTaxRate)
{
$cost = stPrice::calculate($this->getWeekendDeliveryCostNetto(), $countryTaxRate);
}
}
else
{
$cost = $this->getWeekendDeliveryCostNetto();
}
if ($withCurrency)
{
$cost = stCurrency::exchange($cost);
}
return $cost;
}
/**
* Zwraca koszt dostawy ekspresowej
*
* @param stDeliveryProductInfoAbstract $productInfo
* @param bool $withTax
* @param bool $withCurrency
* @return float|string
*/
public function getExpressDeliveryCost(stDeliveryProductInfoAbstract $productInfo, $withTax = false, $withCurrency = false)
{
if ($this->isFree($productInfo) && !$this->getAlwaysChargeExpressDeliveryCost())
{
return 0;
}
if ($withTax && (SF_APP != 'frontend' || !sfContext::getInstance()->getUser()->hasVatEu() && !sfContext::getInstance()->getUser()->hasVatEx()))
{
$cost = $this->getExpressDeliveryCostBrutto();
$countryTaxRate = $this->getTax()->getTaxRateByCountry();
if (null !== $countryTaxRate)
{
$cost = stPrice::calculate($this->getExpressDeliveryCostNetto(), $countryTaxRate);
}
}
else
{
$cost = $this->getExpressDeliveryCostNetto();
}
if ($withCurrency)
{
$cost = stCurrency::exchange($cost);
}
return $cost;
}
/**
* Przeciążenie hydrate
*
* @param ResultSet $rs
* @param int $startcol
* @return object
*/
public function hydrate(ResultSet $rs, $startcol = 1)
{
$this->setCulture(stLanguage::getHydrateCulture());
return parent::hydrate($rs, $startcol);
}
/**
* Przeciążenie getName
*
* @return string
*/
public function getName()
{
if ($this->getCulture() == stLanguage::getOptLanguage())
{
return stLanguage::getDefaultValue($this, __METHOD__);
}
$v = parent::getName();
if (is_null($v))
{
$v = stLanguage::getDefaultValue($this, __METHOD__);
}
return $v;
}
/**
* Przeciążenie setName
*
* @param string $v Nazwa producenta
*/
public function setName($v)
{
if ($this->getCulture() == stLanguage::getOptLanguage())
{
stLanguage::setDefaultValue($this, __METHOD__, $v);
}
parent::setName($v);
}
public function getParam($name, $default = null)
{
return $this->params && isset($this->params[$name]) ? $this->params[$name] : $default;
}
/**
* Przeciążenie getDescription
*
* @return string
*/
public function getDescription()
{
if ($this->getCulture() == stLanguage::getOptLanguage())
{
return stLanguage::getDefaultValue($this, __METHOD__);
}
$v = parent::getDescription();
if (is_null($v))
{
$v = stLanguage::getDefaultValue($this, __METHOD__);
}
return $v;
}
/**
* Przeciążenie setDescription
*
* @param string $v Nazwa producenta
*/
public function setDescription($v)
{
if ($this->getCulture() == stLanguage::getOptLanguage())
{
stLanguage::setDefaultValue($this, __METHOD__, $v);
}
parent::setDescription($v);
}
public function delete($con = null)
{
$ret = parent::delete($con);
self::clearCache();
return $ret;
}
public function save($con = null)
{
if ($this->getIsDefault() && $this->isColumnModified(DeliveryPeer::IS_DEFAULT))
{
$c = new Criteria();
$c->add(DeliveryPeer::COUNTRIES_AREA_ID, $this->getCountriesAreaId());
$delivery = DeliveryPeer::doSelectDefault($c);
if ($delivery)
{
$delivery->setIsDefault(false);
$delivery->save($con);
}
}
$ret = parent::save($con);
self::clearCache();
return $ret;
}
protected function format($v)
{
$v = $v ? $v : 0.00;
if (is_numeric($v))
{
return stPrice::round($v);
}
return $v;
}
protected function computeVolume()
{
$volume = $this->width * $this->height * $this->depth;
$this->setVolume($volume);
}
public static function clearCache()
{
$fc = new stFunctionCache('stDelivery');
$fc->removeAll();
}
}

View File

@@ -0,0 +1,142 @@
<?php
/**
* Subclass for representing a row from the 'st_delivery_has_payment_type' table.
*
*
*
* @package plugins.stDeliveryPlugin.lib.model
*/
class DeliveryHasPaymentType extends BaseDeliveryHasPaymentType
{
protected static
$currency = null,
$tax = array();
public function __construct()
{
if (null === self::$currency && SF_APP == 'frontend')
{
self::$currency = stCurrency::getInstance(sfContext::getInstance())->get();
}
}
public function getFreeFrom()
{
if (SF_APP == 'frontend' && sfContext::getInstance()->getUser()->hasVatEu())
{
return stPrice::extract(parent::getFreeFrom(), $this->getVat(false));
}
return $this->format(parent::getFreeFrom());
}
public function getCost()
{
return $this->format(parent::getCost());
}
public function getCostNetto($with_currency = false)
{
$v = $this->getCost();
if ($with_currency)
{
$v = self::$currency->exchange($v);
}
return $v;
}
public function setCostNetto($v)
{
$this->setCost($v);
}
public function getTax($con = null, $with_eu_tax = true)
{
if (SF_APP == 'frontend' && $with_eu_tax && sfContext::getInstance()->getUser()->hasVatEu())
{
return TaxPeer::retrieveByTax(0);
}
$id = $this->delivery_id;
if (!isset(self::$tax[$id]))
{
self::$tax[$id] = $this->getDelivery()->getTax(null, $with_eu_tax);
}
return self::$tax[$id];
}
public function getVat($with_eu_tax = true)
{
return $this->getTax(null, $with_eu_tax)->getVat();
}
public function getCostBrutto($with_currency = false)
{
$v = parent::getCostBrutto();
if (null === $v)
{
$v = stPrice::calculate($this->getCostNetto(), $this->getTax()->getVat());
$this->setCostBrutto($v);
}
if ($with_currency)
{
$v = self::$currency->exchange($v);
}
return $this->format($v);
}
public function getCourierCost($with_currency = false)
{
$v = parent::getCourierCost();
if ($with_currency)
{
$v = self::$currency->exchange($v);
}
return $this->format($v);
}
public function getPayment()
{
return $this->getPaymentType();
}
public function getPaymentTypeName()
{
return $this->getPaymentType()->getName();
}
public function getPaymentType($con = null)
{
if (null === $this->aPaymentType)
{
$payments = PaymentTypePeer::doSelectCached();
$this->aPaymentType = isset($payments[$this->getPaymentTypeId()]) ? $payments[$this->getPaymentTypeId()] : null;
}
return $this->aPaymentType;
}
protected function format($v)
{
$v = $v ? $v : 0.00;
if (is_numeric($v))
{
return stCurrency::formatPrice($v);
}
return $v;
}
}

View File

@@ -0,0 +1,12 @@
<?php
/**
* Subclass for performing query and update operations on the 'st_delivery_has_payment_type' table.
*
*
*
* @package plugins.stDeliveryPlugin.lib.model
*/
class DeliveryHasPaymentTypePeer extends BaseDeliveryHasPaymentTypePeer
{
}

View File

@@ -0,0 +1,12 @@
<?php
/**
* Subclass for representing a row from the 'st_delivery_i18n' table.
*
*
*
* @package plugins.stDeliveryPlugin.lib.model
*/
class DeliveryI18n extends BaseDeliveryI18n
{
}

View File

@@ -0,0 +1,12 @@
<?php
/**
* Subclass for performing query and update operations on the 'st_delivery_i18n' table.
*
*
*
* @package plugins.stDeliveryPlugin.lib.model
*/
class DeliveryI18nPeer extends BaseDeliveryI18nPeer
{
}

View File

@@ -0,0 +1,192 @@
<?php
/**
* Subclass for performing query and update operations on the 'st_delivery' table.
*
*
*
* @package plugins.stDeliveryPlugin.lib.model
*/
class DeliveryPeer extends BaseDeliveryPeer
{
protected static $cachedIds = null;
protected static $cachedAllowedIds = null;
public static function getDaysOfTheWeek(sfI18N $i18n)
{
return [
1 => $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);
}
}
}

View File

@@ -0,0 +1,127 @@
<?php
/**
* Subclass for representing a row from the 'st_delivery_sections' table.
*
*
*
* @package plugins.stDeliveryPlugin.lib.model
*/
class DeliverySections extends BaseDeliverySections
{
protected static
$currency = null;
public function __construct()
{
if (null === self::$currency && SF_APP == 'frontend')
{
self::$currency = stCurrency::getInstance(sfContext::getInstance())->get();
}
}
public function setFrom($v)
{
$this->setValueFrom($v);
}
public function setCost($v)
{
$this->setAmount($v);
}
public function getCostNetto($with_currency = false)
{
$v = $this->getAmount();
if ($with_currency)
{
$v = self::$currency->exchange($v);
}
return $v;
}
public function setCostNetto($v)
{
$this->setAmount($v);
}
public function getTax()
{
return $this->getDelivery()->getTax();
}
public function getCostBrutto($with_currency = false)
{
if (SF_APP == 'frontend' && (sfContext::getInstance()->getUser()->hasVatEu() || sfContext::getInstance()->getUser()->hasVatEx()))
{
return $this->getCostNetto($with_currency);
}
$costBrutto = $this->getAmountBrutto();
if (null === $costBrutto)
{
$costBrutto = stPrice::calculate($this->getCostNetto(), $this->getTax()->getVat());
$this->setCostBrutto($costBrutto);
}
$countryTaxRate = $this->getTax()->getTaxRateByCountry();
if (null !== $countryTaxRate)
{
$costBrutto = stPrice::calculate(parent::getAmount(), $countryTaxRate);
}
if ($with_currency)
{
$costBrutto = self::$currency->exchange($costBrutto);
}
return $this->format($costBrutto);
}
public function setCostBrutto($v)
{
$this->setAmountBrutto($v);
}
public function getFrom()
{
return $this->getValueFrom();
}
public function getCost()
{
return $this->getAmount();
}
public function getValueFrom()
{
$v = parent::getValueFrom();
if (strpos($v, '.') !== false)
{
return $this->format(parent::getValueFrom());
}
return parent::getValueFrom();
}
public function getAmount()
{
return $this->format(parent::getAmount());
}
protected function format($v)
{
if (is_numeric($v))
{
return stCurrency::formatPrice($v);
}
return $v;
}
}

View File

@@ -0,0 +1,22 @@
<?php
/**
* Subclass for performing query and update operations on the 'st_delivery_sections' table.
*
*
*
* @package plugins.stDeliveryPlugin.lib.model
*/
class DeliverySectionsPeer extends BaseDeliverySectionsPeer
{
public static function getAdditionalSectionCosts()
{
$i18n = sfContext::getInstance()->getI18N();
return array(
'ST_BY_ORDER_WEIGHT' => $i18n->__('Od wagi (kg)'),
'ST_BY_ORDER_QUANTITY' => $i18n->__('Od ilości sztuk'),
'ST_BY_ORDER_AMOUNT' => $i18n->__('Od kwoty zamówienia (brutto)')
);
}
}

View File

@@ -0,0 +1,76 @@
<?php
/**
* Subclass for representing a row from the 'st_delivery_type' table.
*
*
*
* @package plugins.stDeliveryPlugin.lib.model
*/
class DeliveryType extends BaseDeliveryType
{
protected $service;
public function __toString()
{
return $this->getName();
}
public function isAdminGeneratorActionVisible(string $actionName): bool
{
if ($actionName == '_edit' && $this->getIsSystemDefault())
{
return false;
}
return true;
}
public function getIsSystemDefault()
{
return null !== $this->type;
}
/**
* Zwraca klase odpowiedzialną za obsługę typu dostawy
*
* @return stDeliveryTypeAbstract|null
*/
public function getService()
{
if (null === $this->service && stDeliveryTypeConfiguration::has($this->type))
{
$this->service = stDeliveryTypeService::get($this->type);
}
return $this->service;
}
public function isType(string $type): bool
{
return $this->type == $type;
}
public function checkConfiguration(): bool
{
return null === $this->getService() || $this->getService()->checkConfiguration();
}
public function save($con = null)
{
$ret = parent::save($con);
DeliveryTypePeer::clearCache();
return $ret;
}
public function delete($con = null)
{
$ret = parent::delete($con);
DeliveryTypePeer::clearCache();
return $ret;
}
}

View File

@@ -0,0 +1,169 @@
<?php
/**
* Subclass for performing query and update operations on the 'st_delivery_type' table.
*
*
*
* @package plugins.stDeliveryPlugin.lib.model
*/
class DeliveryTypePeer extends BaseDeliveryTypePeer
{
protected static $arrayCached = null;
protected static $namesCached = null;
protected static $typesCached = null;
protected static $checkTypesIntegrityRun = false;
public static function doSelectRS(Criteria $criteria, $con = null)
{
self::checkTypesIntegrity();
$types = array_keys(stDeliveryTypeConfiguration::getTypes());
$criteria = clone $criteria;
$criterion = $criteria->getNewCriterion(self::TYPE, null, Criteria::ISNULL);
$criterion->addOr($criteria->getNewCriterion(self::TYPE, $types, Criteria::IN));
$criteria->add($criterion);
return parent::doSelectRS($criteria, $con);
}
public static function doSelectArrayNamesCached()
{
if (null === self::$namesCached)
{
$results = array();
foreach (self::doSelectArrayCached() as $id => $value)
{
$results[$id] = $value['name'];
}
self::$namesCached = $results;
}
return self::$namesCached;
}
public static function doSelectArrayCached()
{
if (null === self::$arrayCached)
{
$fc = new stFunctionCache('Delivery');
self::$arrayCached = $fc->cacheCall(array('DeliveryTypePeer', 'doSelectArray'));
}
return self::$arrayCached;
}
public static function retrieveTypeById($id): ?string
{
$types = self::doSelectArrayCached();
return isset($types[$id]) ? $types[$id]['type'] : null;
}
public static function retrieveIdByType($type)
{
if (null === self::$typesCached)
{
$results = array();
foreach (self::doSelectArrayCached() as $id => $value)
{
$results[$value['type']] = $id;
}
self::$typesCached = $results;
}
return self::$typesCached && isset(self::$typesCached[$type]) ? self::$typesCached[$type] : null;
}
public static function doSelectArray(Criteria $c = null)
{
$tokens = array();
$c = $c ? clone $c : new Criteria();
$c->addSelectColumn(self::ID);
$c->addSelectColumn(self::NAME);
$c->addSelectColumn(self::TYPE);
$c->addAscendingOrderByColumn(self::NAME);
$rs = self::doSelectRs($c);
while($rs->next())
{
$row = $rs->getRow();
$tokens[$row[0]] = array(
'name' => $row[1],
'type' => $row[2]
);
}
return $tokens;
}
public static function clearCache()
{
$fc = new stFunctionCache('Delivery');
$fc->removeAll();
}
protected static function checkTypesIntegrity()
{
if (self::$checkTypesIntegrityRun)
{
return;
}
self::$checkTypesIntegrityRun = true;
$deliveryConfig = stConfig::getInstance('stDeliveryBackend');
$hash = $deliveryConfig->get('types_integrity_hash');
if (null !== $hash && stDeliveryTypeConfiguration::checkTypesIntegrityHash($hash))
{
return;
}
$types = array_keys(stDeliveryTypeConfiguration::getTypes());
$existing = [];
foreach (self::doSelect(new Criteria()) as $deliveryType)
{
if (empty($deliveryType->getType()) || !stDeliveryTypeConfiguration::has($deliveryType->getType()))
{
continue;
}
$existing[$deliveryType->getType()] = true;
$configuration = stDeliveryTypeConfiguration::get($deliveryType->getType());
if ($deliveryType->getName() === $configuration->getLabel())
{
continue;
}
$deliveryType->setName($configuration->getLabel());
$deliveryType->save();
}
foreach ($types as $type)
{
if (!isset($existing[$type]))
{
$configuration = stDeliveryTypeConfiguration::get($type);
$deliveryType = new DeliveryType();
$deliveryType->setType($type);
$deliveryType->setName($configuration->getLabel());
$deliveryType->save();
}
}
$deliveryConfig->set('types_integrity_hash', stDeliveryTypeConfiguration::getTypesIntegrityHash());
$deliveryConfig->save();
}
}

View File

@@ -0,0 +1,86 @@
<?php
/**
* This class adds structure of 'st_delivery_has_payment_type' table to 'propel' DatabaseMap object.
*
*
*
* These statically-built map classes are used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
* @package plugins.stDeliveryPlugin.lib.model.map
*/
class DeliveryHasPaymentTypeMapBuilder {
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'plugins.stDeliveryPlugin.lib.model.map.DeliveryHasPaymentTypeMapBuilder';
/**
* The database map.
*/
private $dbMap;
/**
* Tells us if this DatabaseMapBuilder is built so that we
* don't have to re-build it every time.
*
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
*/
public function isBuilt()
{
return ($this->dbMap !== null);
}
/**
* Gets the databasemap this map builder built.
*
* @return the databasemap
*/
public function getDatabaseMap()
{
return $this->dbMap;
}
/**
* The doBuild() method builds the DatabaseMap
*
* @return void
* @throws PropelException
*/
public function doBuild()
{
$this->dbMap = Propel::getDatabaseMap('propel');
$tMap = $this->dbMap->addTable('st_delivery_has_payment_type');
$tMap->setPhpName('DeliveryHasPaymentType');
$tMap->setUseIdGenerator(true);
$tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null);
$tMap->addForeignKey('PAYMENT_TYPE_ID', 'PaymentTypeId', 'int', CreoleTypes::INTEGER, 'st_payment_type', 'ID', true, null);
$tMap->addForeignKey('DELIVERY_ID', 'DeliveryId', 'int', CreoleTypes::INTEGER, 'st_delivery', 'ID', true, null);
$tMap->addColumn('IS_ACTIVE', 'IsActive', 'boolean', CreoleTypes::BOOLEAN, false, null);
$tMap->addColumn('IS_DEFAULT', 'IsDefault', 'boolean', CreoleTypes::BOOLEAN, false, null);
$tMap->addColumn('COST', 'Cost', 'double', CreoleTypes::DECIMAL, false, 10);
$tMap->addColumn('COST_BRUTTO', 'CostBrutto', 'double', CreoleTypes::DECIMAL, false, 10);
$tMap->addColumn('FREE_FROM', 'FreeFrom', 'double', CreoleTypes::DECIMAL, false, 10);
$tMap->addColumn('COST_TYPE', 'CostType', 'string', CreoleTypes::CHAR, true, null);
$tMap->addColumn('COURIER_COST', 'CourierCost', 'double', CreoleTypes::DECIMAL, false, 10);
} // doBuild()
} // DeliveryHasPaymentTypeMapBuilder

View File

@@ -0,0 +1,74 @@
<?php
/**
* This class adds structure of 'st_delivery_i18n' table to 'propel' DatabaseMap object.
*
*
*
* These statically-built map classes are used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
* @package plugins.stDeliveryPlugin.lib.model.map
*/
class DeliveryI18nMapBuilder {
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'plugins.stDeliveryPlugin.lib.model.map.DeliveryI18nMapBuilder';
/**
* The database map.
*/
private $dbMap;
/**
* Tells us if this DatabaseMapBuilder is built so that we
* don't have to re-build it every time.
*
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
*/
public function isBuilt()
{
return ($this->dbMap !== null);
}
/**
* Gets the databasemap this map builder built.
*
* @return the databasemap
*/
public function getDatabaseMap()
{
return $this->dbMap;
}
/**
* The doBuild() method builds the DatabaseMap
*
* @return void
* @throws PropelException
*/
public function doBuild()
{
$this->dbMap = Propel::getDatabaseMap('propel');
$tMap = $this->dbMap->addTable('st_delivery_i18n');
$tMap->setPhpName('DeliveryI18n');
$tMap->setUseIdGenerator(false);
$tMap->addForeignPrimaryKey('ID', 'Id', 'int' , CreoleTypes::INTEGER, 'st_delivery', 'ID', true, null);
$tMap->addPrimaryKey('CULTURE', 'Culture', 'string', CreoleTypes::VARCHAR, true, 7);
$tMap->addColumn('NAME', 'Name', 'string', CreoleTypes::VARCHAR, false, 255);
$tMap->addColumn('DESCRIPTION', 'Description', 'string', CreoleTypes::LONGVARCHAR, false, null);
} // doBuild()
} // DeliveryI18nMapBuilder

View File

@@ -0,0 +1,144 @@
<?php
/**
* This class adds structure of 'st_delivery' table to 'propel' DatabaseMap object.
*
*
*
* These statically-built map classes are used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
* @package plugins.stDeliveryPlugin.lib.model.map
*/
class DeliveryMapBuilder {
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'plugins.stDeliveryPlugin.lib.model.map.DeliveryMapBuilder';
/**
* The database map.
*/
private $dbMap;
/**
* Tells us if this DatabaseMapBuilder is built so that we
* don't have to re-build it every time.
*
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
*/
public function isBuilt()
{
return ($this->dbMap !== null);
}
/**
* Gets the databasemap this map builder built.
*
* @return the databasemap
*/
public function getDatabaseMap()
{
return $this->dbMap;
}
/**
* The doBuild() method builds the DatabaseMap
*
* @return void
* @throws PropelException
*/
public function doBuild()
{
$this->dbMap = Propel::getDatabaseMap('propel');
$tMap = $this->dbMap->addTable('st_delivery');
$tMap->setPhpName('Delivery');
$tMap->setUseIdGenerator(true);
$tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null);
$tMap->addForeignKey('COUNTRIES_AREA_ID', 'CountriesAreaId', 'int', CreoleTypes::INTEGER, 'st_countries_area', 'ID', false, null);
$tMap->addForeignKey('TAX_ID', 'TaxId', 'int', CreoleTypes::INTEGER, 'st_tax', 'ID', false, null);
$tMap->addForeignKey('TYPE_ID', 'TypeId', 'int', CreoleTypes::INTEGER, 'st_delivery_type', 'ID', false, null);
$tMap->addColumn('FREE_DELIVERY', 'FreeDelivery', 'double', CreoleTypes::DECIMAL, false, 10);
$tMap->addColumn('IS_EXPRESS_DELIVERY', 'IsExpressDelivery', 'boolean', CreoleTypes::BOOLEAN, false, null);
$tMap->addColumn('ALWAYS_CHARGE_EXPRESS_DELIVERY_COST', 'AlwaysChargeExpressDeliveryCost', 'boolean', CreoleTypes::BOOLEAN, false, null);
$tMap->addColumn('EXPRESS_DELIVERY_COST_NETTO', 'ExpressDeliveryCostNetto', 'double', CreoleTypes::DECIMAL, false, 10);
$tMap->addColumn('EXPRESS_DELIVERY_COST_BRUTTO', 'ExpressDeliveryCostBrutto', 'double', CreoleTypes::DECIMAL, false, 10);
$tMap->addColumn('EXPRESS_DELIVERY_ORDER_TIME_LIMIT', 'ExpressDeliveryOrderTimeLimit', 'string', CreoleTypes::CHAR, false, 5);
$tMap->addColumn('IS_WEEKEND_DELIVERY', 'IsWeekendDelivery', 'boolean', CreoleTypes::BOOLEAN, false, null);
$tMap->addColumn('ALWAYS_CHARGE_WEEKEND_DELIVERY_COST', 'AlwaysChargeWeekendDeliveryCost', 'boolean', CreoleTypes::BOOLEAN, false, null);
$tMap->addColumn('WEEKEND_DELIVERY_COST_NETTO', 'WeekendDeliveryCostNetto', 'double', CreoleTypes::DECIMAL, false, 10);
$tMap->addColumn('WEEKEND_DELIVERY_COST_BRUTTO', 'WeekendDeliveryCostBrutto', 'double', CreoleTypes::DECIMAL, false, 10);
$tMap->addColumn('WEEKEND_DELIVERY_AVAILABILITY', 'WeekendDeliveryAvailability', 'array', CreoleTypes::VARCHAR, false, 255);
$tMap->addColumn('ACTIVE', 'Active', 'boolean', CreoleTypes::BOOLEAN, false, null);
$tMap->addColumn('ALLOW_IN_SELECTED_PRODUCTS', 'AllowInSelectedProducts', 'boolean', CreoleTypes::BOOLEAN, true, null);
$tMap->addColumn('DEFAULT_COST', 'DefaultCost', 'double', CreoleTypes::DECIMAL, false, 10);
$tMap->addColumn('DEFAULT_COST_BRUTTO', 'DefaultCostBrutto', 'double', CreoleTypes::DECIMAL, false, 10);
$tMap->addColumn('WIDTH', 'Width', 'int', CreoleTypes::INTEGER, true, null);
$tMap->addColumn('HEIGHT', 'Height', 'int', CreoleTypes::INTEGER, true, null);
$tMap->addColumn('DEPTH', 'Depth', 'int', CreoleTypes::INTEGER, true, null);
$tMap->addColumn('VOLUME', 'Volume', 'int', CreoleTypes::INTEGER, true, null);
$tMap->addColumn('IS_SYSTEM_DEFAULT', 'IsSystemDefault', 'boolean', CreoleTypes::BOOLEAN, false, null);
$tMap->addColumn('OPT_NAME', 'OptName', 'string', CreoleTypes::VARCHAR, false, 255);
$tMap->addColumn('OPT_DESCRIPTION', 'OptDescription', 'string', CreoleTypes::LONGVARCHAR, false, null);
$tMap->addColumn('IS_DEFAULT', 'IsDefault', 'boolean', CreoleTypes::BOOLEAN, false, null);
$tMap->addColumn('SECTION_COST_TYPE', 'SectionCostType', 'string', CreoleTypes::VARCHAR, false, 32);
$tMap->addColumn('MAX_ORDER_WEIGHT', 'MaxOrderWeight', 'double', CreoleTypes::DECIMAL, false, 6);
$tMap->addColumn('MAX_ORDER_AMOUNT', 'MaxOrderAmount', 'double', CreoleTypes::DECIMAL, false, 10);
$tMap->addColumn('MAX_ORDER_QUANTITY', 'MaxOrderQuantity', 'int', CreoleTypes::INTEGER, false, null);
$tMap->addColumn('MIN_ORDER_WEIGHT', 'MinOrderWeight', 'double', CreoleTypes::DECIMAL, false, 6);
$tMap->addColumn('MIN_ORDER_AMOUNT', 'MinOrderAmount', 'double', CreoleTypes::DECIMAL, false, 10);
$tMap->addColumn('MIN_ORDER_QUANTITY', 'MinOrderQuantity', 'int', CreoleTypes::INTEGER, false, null);
$tMap->addColumn('POSITION', 'Position', 'int', CreoleTypes::INTEGER, false, null);
$tMap->addColumn('PARAMS', 'Params', 'array', CreoleTypes::VARCHAR, false, 4096);
$tMap->addColumn('TRACKING_URL', 'TrackingUrl', 'string', CreoleTypes::VARCHAR, false, 255);
$tMap->addColumn('PACZKOMATY_TYPE', 'PaczkomatyType', 'string', CreoleTypes::VARCHAR, false, 5);
$tMap->addColumn('PACZKOMATY_SIZE', 'PaczkomatySize', 'string', CreoleTypes::VARCHAR, false, 5);
} // doBuild()
} // DeliveryMapBuilder

View File

@@ -0,0 +1,76 @@
<?php
/**
* This class adds structure of 'st_delivery_sections' table to 'propel' DatabaseMap object.
*
*
*
* These statically-built map classes are used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
* @package plugins.stDeliveryPlugin.lib.model.map
*/
class DeliverySectionsMapBuilder {
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'plugins.stDeliveryPlugin.lib.model.map.DeliverySectionsMapBuilder';
/**
* The database map.
*/
private $dbMap;
/**
* Tells us if this DatabaseMapBuilder is built so that we
* don't have to re-build it every time.
*
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
*/
public function isBuilt()
{
return ($this->dbMap !== null);
}
/**
* Gets the databasemap this map builder built.
*
* @return the databasemap
*/
public function getDatabaseMap()
{
return $this->dbMap;
}
/**
* The doBuild() method builds the DatabaseMap
*
* @return void
* @throws PropelException
*/
public function doBuild()
{
$this->dbMap = Propel::getDatabaseMap('propel');
$tMap = $this->dbMap->addTable('st_delivery_sections');
$tMap->setPhpName('DeliverySections');
$tMap->setUseIdGenerator(true);
$tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null);
$tMap->addForeignKey('DELIVERY_ID', 'DeliveryId', 'int', CreoleTypes::INTEGER, 'st_delivery', 'ID', true, null);
$tMap->addColumn('VALUE_FROM', 'ValueFrom', 'double', CreoleTypes::DECIMAL, false, 10);
$tMap->addColumn('AMOUNT', 'Amount', 'double', CreoleTypes::DECIMAL, false, 10);
$tMap->addColumn('AMOUNT_BRUTTO', 'AmountBrutto', 'double', CreoleTypes::DECIMAL, false, 10);
} // doBuild()
} // DeliverySectionsMapBuilder

View File

@@ -0,0 +1,72 @@
<?php
/**
* This class adds structure of 'st_delivery_type' table to 'propel' DatabaseMap object.
*
*
*
* These statically-built map classes are used by Propel to do runtime db structure discovery.
* For example, the createSelectSql() method checks the type of a given column used in an
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
* (i.e. if it's a text column type).
*
* @package plugins.stDeliveryPlugin.lib.model.map
*/
class DeliveryTypeMapBuilder {
/**
* The (dot-path) name of this class
*/
const CLASS_NAME = 'plugins.stDeliveryPlugin.lib.model.map.DeliveryTypeMapBuilder';
/**
* The database map.
*/
private $dbMap;
/**
* Tells us if this DatabaseMapBuilder is built so that we
* don't have to re-build it every time.
*
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
*/
public function isBuilt()
{
return ($this->dbMap !== null);
}
/**
* Gets the databasemap this map builder built.
*
* @return the databasemap
*/
public function getDatabaseMap()
{
return $this->dbMap;
}
/**
* The doBuild() method builds the DatabaseMap
*
* @return void
* @throws PropelException
*/
public function doBuild()
{
$this->dbMap = Propel::getDatabaseMap('propel');
$tMap = $this->dbMap->addTable('st_delivery_type');
$tMap->setPhpName('DeliveryType');
$tMap->setUseIdGenerator(true);
$tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null);
$tMap->addColumn('NAME', 'Name', 'string', CreoleTypes::VARCHAR, true, 128);
$tMap->addColumn('TYPE', 'Type', 'string', CreoleTypes::VARCHAR, false, 16);
} // doBuild()
} // DeliveryTypeMapBuilder

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,827 @@
<?php
/**
* Base class that represents a row from the 'st_delivery_i18n' table.
*
*
*
* @package plugins.stDeliveryPlugin.lib.model.om
*/
abstract class BaseDeliveryI18n extends BaseObject implements Persistent {
protected static $dispatcher = null;
/**
* The value for the id field.
* @var int
*/
protected $id;
/**
* The value for the culture field.
* @var string
*/
protected $culture;
/**
* The value for the name field.
* @var string
*/
protected $name;
/**
* The value for the description field.
* @var string
*/
protected $description;
/**
* @var Delivery
*/
protected $aDelivery;
/**
* Flag to prevent endless save loop, if this object is referenced
* by another object which falls in this transaction.
* @var boolean
*/
protected $alreadyInSave = false;
/**
* Flag to prevent endless validation loop, if this object is referenced
* by another object which falls in this transaction.
* @var boolean
*/
protected $alreadyInValidation = false;
/**
* Get the [id] column value.
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Get the [culture] column value.
*
* @return string
*/
public function getCulture()
{
return $this->culture;
}
/**
* Get the [name] column value.
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Get the [description] column value.
*
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* Set the value of [id] column.
*
* @param int $v new value
* @return void
*/
public function setId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->id !== $v) {
$this->id = $v;
$this->modifiedColumns[] = DeliveryI18nPeer::ID;
}
if ($this->aDelivery !== null && $this->aDelivery->getId() !== $v) {
$this->aDelivery = null;
}
} // setId()
/**
* Set the value of [culture] column.
*
* @param string $v new value
* @return void
*/
public function setCulture($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->culture !== $v) {
$this->culture = $v;
$this->modifiedColumns[] = DeliveryI18nPeer::CULTURE;
}
} // setCulture()
/**
* Set the value of [name] column.
*
* @param string $v new value
* @return void
*/
public function setName($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->name !== $v) {
$this->name = $v;
$this->modifiedColumns[] = DeliveryI18nPeer::NAME;
}
} // setName()
/**
* Set the value of [description] column.
*
* @param string $v new value
* @return void
*/
public function setDescription($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->description !== $v) {
$this->description = $v;
$this->modifiedColumns[] = DeliveryI18nPeer::DESCRIPTION;
}
} // setDescription()
/**
* Hydrates (populates) the object variables with values from the database resultset.
*
* An offset (1-based "start column") is specified so that objects can be hydrated
* with a subset of the columns in the resultset rows. This is needed, for example,
* for results of JOIN queries where the resultset row includes columns from two or
* more tables.
*
* @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos.
* @param int $startcol 1-based offset column which indicates which restultset column to start with.
* @return int next starting column
* @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
*/
public function hydrate(ResultSet $rs, $startcol = 1)
{
try {
if ($this->getDispatcher()->getListeners('DeliveryI18n.preHydrate')) {
$event = $this->getDispatcher()->notify(new sfEvent($this, 'DeliveryI18n.preHydrate', array('resultset' => $rs, 'startcol' => $startcol)));
$startcol = $event['startcol'];
}
$this->id = $rs->getInt($startcol + 0);
$this->culture = $rs->getString($startcol + 1);
$this->name = $rs->getString($startcol + 2);
$this->description = $rs->getString($startcol + 3);
$this->resetModified();
$this->setNew(false);
if ($this->getDispatcher()->getListeners('DeliveryI18n.postHydrate')) {
$event = $this->getDispatcher()->notify(new sfEvent($this, 'DeliveryI18n.postHydrate', array('resultset' => $rs, 'startcol' => $startcol + 4)));
return $event['startcol'];
}
// FIXME - using NUM_COLUMNS may be clearer.
return $startcol + 4; // 4 = DeliveryI18nPeer::NUM_COLUMNS - DeliveryI18nPeer::NUM_LAZY_LOAD_COLUMNS).
} catch (Exception $e) {
throw new PropelException("Error populating DeliveryI18n object", $e);
}
}
/**
* Removes this object from datastore and sets delete attribute.
*
* @param Connection $con
* @return void
* @throws PropelException
* @see BaseObject::setDeleted()
* @see BaseObject::isDeleted()
*/
public function delete($con = null)
{
if ($this->isDeleted()) {
throw new PropelException("This object has already been deleted.");
}
if ($this->getDispatcher()->getListeners('DeliveryI18n.preDelete')) {
$this->getDispatcher()->notify(new sfEvent($this, 'DeliveryI18n.preDelete', array('con' => $con)));
}
if (sfMixer::hasCallables('BaseDeliveryI18n:delete:pre'))
{
foreach (sfMixer::getCallables('BaseDeliveryI18n:delete:pre') as $callable)
{
$ret = call_user_func($callable, $this, $con);
if ($ret)
{
return;
}
}
}
if ($con === null) {
$con = Propel::getConnection(DeliveryI18nPeer::DATABASE_NAME);
}
try {
$con->begin();
DeliveryI18nPeer::doDelete($this, $con);
$this->setDeleted(true);
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
if ($this->getDispatcher()->getListeners('DeliveryI18n.postDelete')) {
$this->getDispatcher()->notify(new sfEvent($this, 'DeliveryI18n.postDelete', array('con' => $con)));
}
if (sfMixer::hasCallables('BaseDeliveryI18n:delete:post'))
{
foreach (sfMixer::getCallables('BaseDeliveryI18n:delete:post') as $callable)
{
call_user_func($callable, $this, $con);
}
}
}
/**
* Stores the object in the database. If the object is new,
* it inserts it; otherwise an update is performed. This method
* wraps the doSave() worker method in a transaction.
*
* @param Connection $con
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
* @throws PropelException
* @see doSave()
*/
public function save($con = null)
{
if ($this->isDeleted()) {
throw new PropelException("You cannot save an object that has been deleted.");
}
if (!$this->alreadyInSave) {
if ($this->getDispatcher()->getListeners('DeliveryI18n.preSave')) {
$this->getDispatcher()->notify(new sfEvent($this, 'DeliveryI18n.preSave', array('con' => $con)));
}
foreach (sfMixer::getCallables('BaseDeliveryI18n:save:pre') as $callable)
{
$affectedRows = call_user_func($callable, $this, $con);
if (is_int($affectedRows))
{
return $affectedRows;
}
}
}
if ($con === null) {
$con = Propel::getConnection(DeliveryI18nPeer::DATABASE_NAME);
}
try {
$con->begin();
$affectedRows = $this->doSave($con);
$con->commit();
if (!$this->alreadyInSave) {
if ($this->getDispatcher()->getListeners('DeliveryI18n.postSave')) {
$this->getDispatcher()->notify(new sfEvent($this, 'DeliveryI18n.postSave', array('con' => $con)));
}
foreach (sfMixer::getCallables('BaseDeliveryI18n:save:post') as $callable)
{
call_user_func($callable, $this, $con, $affectedRows);
}
}
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
/**
* Stores the object in the database.
*
* If the object is new, it inserts it; otherwise an update is performed.
* All related objects are also updated in this method.
*
* @param Connection $con
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
* @throws PropelException
* @see save()
*/
protected function doSave($con)
{
$affectedRows = 0; // initialize var to track total num of affected rows
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
// We call the save method on the following object(s) if they
// were passed to this object by their coresponding set
// method. This object relates to these object(s) by a
// foreign key reference.
if ($this->aDelivery !== null) {
if ($this->aDelivery->isModified() || $this->aDelivery->getCurrentDeliveryI18n()->isModified()) {
$affectedRows += $this->aDelivery->save($con);
}
$this->setDelivery($this->aDelivery);
}
// If this object has been modified, then save it to the database.
if ($this->isModified()) {
if ($this->isNew()) {
$pk = DeliveryI18nPeer::doInsert($this, $con);
$affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which
// should always be true here (even though technically
// BasePeer::doInsert() can insert multiple rows).
$this->setNew(false);
} else {
$affectedRows += DeliveryI18nPeer::doUpdate($this, $con);
}
$this->resetModified(); // [HL] After being saved an object is no longer 'modified'
}
$this->alreadyInSave = false;
}
return $affectedRows;
} // doSave()
/**
* Array of ValidationFailed objects.
* @var array ValidationFailed[]
*/
protected $validationFailures = array();
/**
* Gets any ValidationFailed objects that resulted from last call to validate().
*
*
* @return array ValidationFailed[]
* @see validate()
*/
public function getValidationFailures()
{
return $this->validationFailures;
}
/**
* Validates the objects modified field values and all objects related to this table.
*
* If $columns is either a column name or an array of column names
* only those columns are validated.
*
* @param mixed $columns Column name or an array of column names.
* @return boolean Whether all columns pass validation.
* @see doValidate()
* @see getValidationFailures()
*/
public function validate($columns = null)
{
$res = $this->doValidate($columns);
if ($res === true) {
$this->validationFailures = array();
return true;
} else {
$this->validationFailures = $res;
return false;
}
}
/**
* This function performs the validation work for complex object models.
*
* In addition to checking the current object, all related objects will
* also be validated. If all pass then <code>true</code> is returned; otherwise
* an aggreagated array of ValidationFailed objects will be returned.
*
* @param array $columns Array of column names to validate.
* @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
*/
protected function doValidate($columns = null)
{
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
// We call the validate method on the following object(s) if they
// were passed to this object by their coresponding set
// method. This object relates to these object(s) by a
// foreign key reference.
if ($this->aDelivery !== null) {
if (!$this->aDelivery->validate($columns)) {
$failureMap = array_merge($failureMap, $this->aDelivery->getValidationFailures());
}
}
if (($retval = DeliveryI18nPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
$this->alreadyInValidation = false;
}
return (!empty($failureMap) ? $failureMap : true);
}
/**
* Retrieves a field from the object by name passed in as a string.
*
* @param string $name name
* @param string $type The type of fieldname the $name is of:
* one of the class type constants TYPE_PHPNAME,
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
* @return mixed Value of field.
*/
public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
{
$pos = DeliveryI18nPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->getByPosition($pos);
}
/**
* Retrieves a field from the object by Position as specified in the xml schema.
* Zero-based.
*
* @param int $pos position in xml schema
* @return mixed Value of field at $pos
*/
public function getByPosition($pos)
{
switch($pos) {
case 0:
return $this->getId();
break;
case 1:
return $this->getCulture();
break;
case 2:
return $this->getName();
break;
case 3:
return $this->getDescription();
break;
default:
return null;
break;
} // switch()
}
/**
* Exports the object as an array.
*
* You can specify the key type of the array by passing one of the class
* type constants.
*
* @param string $keyType One of the class type constants TYPE_PHPNAME,
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
* @return an associative array containing the field names (as keys) and field values
*/
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
{
$keys = DeliveryI18nPeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getId(),
$keys[1] => $this->getCulture(),
$keys[2] => $this->getName(),
$keys[3] => $this->getDescription(),
);
return $result;
}
/**
* Sets a field from the object by name passed in as a string.
*
* @param string $name peer name
* @param mixed $value field value
* @param string $type The type of fieldname the $name is of:
* one of the class type constants TYPE_PHPNAME,
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
* @return void
*/
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
{
$pos = DeliveryI18nPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->setByPosition($pos, $value);
}
/**
* Sets a field from the object by Position as specified in the xml schema.
* Zero-based.
*
* @param int $pos position in xml schema
* @param mixed $value field value
* @return void
*/
public function setByPosition($pos, $value)
{
switch($pos) {
case 0:
$this->setId($value);
break;
case 1:
$this->setCulture($value);
break;
case 2:
$this->setName($value);
break;
case 3:
$this->setDescription($value);
break;
} // switch()
}
/**
* Populates the object using an array.
*
* This is particularly useful when populating an object from one of the
* request arrays (e.g. $_POST). This method goes through the column
* names, checking to see whether a matching key exists in populated
* array. If so the setByName() method is called for that column.
*
* You can specify the key type of the array by additionally passing one
* of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
* TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId')
*
* @param array $arr An array to populate the object from.
* @param string $keyType The type of keys the array uses.
* @return void
*/
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
{
$keys = DeliveryI18nPeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setCulture($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setName($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]);
}
/**
* Build a Criteria object containing the values of all modified columns in this object.
*
* @return Criteria The Criteria object containing all modified values.
*/
public function buildCriteria()
{
$criteria = new Criteria(DeliveryI18nPeer::DATABASE_NAME);
if ($this->isColumnModified(DeliveryI18nPeer::ID)) $criteria->add(DeliveryI18nPeer::ID, $this->id);
if ($this->isColumnModified(DeliveryI18nPeer::CULTURE)) $criteria->add(DeliveryI18nPeer::CULTURE, $this->culture);
if ($this->isColumnModified(DeliveryI18nPeer::NAME)) $criteria->add(DeliveryI18nPeer::NAME, $this->name);
if ($this->isColumnModified(DeliveryI18nPeer::DESCRIPTION)) $criteria->add(DeliveryI18nPeer::DESCRIPTION, $this->description);
return $criteria;
}
/**
* Builds a Criteria object containing the primary key for this object.
*
* Unlike buildCriteria() this method includes the primary key values regardless
* of whether or not they have been modified.
*
* @return Criteria The Criteria object containing value(s) for primary key(s).
*/
public function buildPkeyCriteria()
{
$criteria = new Criteria(DeliveryI18nPeer::DATABASE_NAME);
$criteria->add(DeliveryI18nPeer::ID, $this->id);
$criteria->add(DeliveryI18nPeer::CULTURE, $this->culture);
return $criteria;
}
/**
* Returns the composite primary key for this object.
* The array elements will be in same order as specified in XML.
* @return array
*/
public function getPrimaryKey()
{
return array($this->getId(), $this->getCulture());
}
/**
* Returns [composite] primary key fields
*
* @param string $keyType
* @return array
*/
public function getPrimaryKeyFields($keyType = BasePeer::TYPE_FIELDNAME)
{
return array(DeliveryI18nPeer::translateFieldName('id', BasePeer::TYPE_FIELDNAME, $keyType), DeliveryI18nPeer::translateFieldName('culture', BasePeer::TYPE_FIELDNAME, $keyType));
}
/**
* Set the [composite] primary key.
*
* @param array $keys The elements of the composite key (order must match the order in XML file).
* @return void
*/
public function setPrimaryKey($keys)
{
$this->setId($keys[0]);
$this->setCulture($keys[1]);
}
/**
* Sets contents of passed object to values from current object.
*
* If desired, this method can also make copies of all associated (fkey referrers)
* objects.
*
* @param object $copyObj An object of DeliveryI18n (or compatible) type.
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
* @throws PropelException
*/
public function copyInto($copyObj, $deepCopy = false)
{
$copyObj->setName($this->name);
$copyObj->setDescription($this->description);
$copyObj->setNew(true);
$copyObj->setId(NULL); // this is a pkey column, so set to default value
$copyObj->setCulture(NULL); // this is a pkey column, so set to default value
}
/**
* Makes a copy of this object that will be inserted as a new row in table when saved.
* It creates a new object filling in the simple attributes, but skipping any primary
* keys that are defined for the table.
*
* If desired, this method can also make copies of all associated (fkey referrers)
* objects.
*
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
* @return DeliveryI18n Clone of current object.
* @throws PropelException
*/
public function copy($deepCopy = false)
{
// we use get_class(), because this might be a subclass
$clazz = get_class($this);
$copyObj = new $clazz();
$this->copyInto($copyObj, $deepCopy);
return $copyObj;
}
/**
* Returns a peer instance associated with this om.
*
* @return string Peer class name
*/
public function getPeer()
{
return 'DeliveryI18nPeer';
}
/**
* Declares an association between this object and a Delivery object.
*
* @param Delivery $v
* @return void
* @throws PropelException
*/
public function setDelivery($v)
{
if ($v === null) {
$this->setId(NULL);
} else {
$this->setId($v->getId());
}
$this->aDelivery = $v;
}
/**
* Get the associated Delivery object
*
* @param Connection Optional Connection object.
* @return Delivery The associated Delivery object.
* @throws PropelException
*/
public function getDelivery($con = null)
{
if ($this->aDelivery === null && ($this->id !== null)) {
// include the related Peer class
$this->aDelivery = DeliveryPeer::retrieveByPK($this->id, $con);
/* The following can be used instead of the line above to
guarantee the related object contains a reference
to this object, but this level of coupling
may be undesirable in many circumstances.
As it can lead to a db query with many results that may
never be used.
$obj = DeliveryPeer::retrieveByPK($this->id, $con);
$obj->addDeliverys($this);
*/
}
return $this->aDelivery;
}
public function getDispatcher()
{
if (null === self::$dispatcher)
{
self::$dispatcher = stEventDispatcher::getInstance();
}
return self::$dispatcher;
}
public function __call($method, $arguments)
{
$event = $this->getDispatcher()->notifyUntil(new sfEvent($this, 'DeliveryI18n.' . $method, array('arguments' => $arguments, 'method' => $method)));
if ($event->isProcessed())
{
return $event->getReturnValue();
}
if (!$callable = sfMixer::getCallable('BaseDeliveryI18n:'.$method))
{
throw new sfException(sprintf('Call to undefined method BaseDeliveryI18n::%s', $method));
}
array_unshift($arguments, $this);
return call_user_func_array($callable, $arguments);
}
} // BaseDeliveryI18n

View File

@@ -0,0 +1,839 @@
<?php
/**
* Base static class for performing query and update operations on the 'st_delivery_i18n' table.
*
*
*
* @package plugins.stDeliveryPlugin.lib.model.om
*/
abstract class BaseDeliveryI18nPeer {
/** the default database name for this class */
const DATABASE_NAME = 'propel';
/** the table name for this class */
const TABLE_NAME = 'st_delivery_i18n';
/** A class that can be returned by this peer. */
const CLASS_DEFAULT = 'plugins.stDeliveryPlugin.lib.model.DeliveryI18n';
/** The total number of columns. */
const NUM_COLUMNS = 4;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
/** the column name for the ID field */
const ID = 'st_delivery_i18n.ID';
/** the column name for the CULTURE field */
const CULTURE = 'st_delivery_i18n.CULTURE';
/** the column name for the NAME field */
const NAME = 'st_delivery_i18n.NAME';
/** the column name for the DESCRIPTION field */
const DESCRIPTION = 'st_delivery_i18n.DESCRIPTION';
/** The PHP to DB Name Mapping */
private static $phpNameMap = null;
/**
* holds an array of fieldnames
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('Id', 'Culture', 'Name', 'Description', ),
BasePeer::TYPE_COLNAME => array (DeliveryI18nPeer::ID, DeliveryI18nPeer::CULTURE, DeliveryI18nPeer::NAME, DeliveryI18nPeer::DESCRIPTION, ),
BasePeer::TYPE_FIELDNAME => array ('id', 'culture', 'name', 'description', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, )
);
/**
* holds an array of keys for quick access to the fieldnames array
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
*/
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Culture' => 1, 'Name' => 2, 'Description' => 3, ),
BasePeer::TYPE_COLNAME => array (DeliveryI18nPeer::ID => 0, DeliveryI18nPeer::CULTURE => 1, DeliveryI18nPeer::NAME => 2, DeliveryI18nPeer::DESCRIPTION => 3, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'culture' => 1, 'name' => 2, 'description' => 3, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, )
);
protected static $hydrateMethod = null;
protected static $postHydrateMethod = null;
public static function setHydrateMethod($callback)
{
self::$hydrateMethod = $callback;
}
public static function setPostHydrateMethod($callback)
{
self::$postHydrateMethod = $callback;
}
/**
* @return MapBuilder the map builder for this peer
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function getMapBuilder()
{
return BasePeer::getMapBuilder('plugins.stDeliveryPlugin.lib.model.map.DeliveryI18nMapBuilder');
}
/**
* Gets a map (hash) of PHP names to DB column names.
*
* @return array The PHP to DB name map for this peer
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @deprecated Use the getFieldNames() and translateFieldName() methods instead of this.
*/
public static function getPhpNameMap()
{
if (self::$phpNameMap === null) {
$map = DeliveryI18nPeer::getTableMap();
$columns = $map->getColumns();
$nameMap = array();
foreach ($columns as $column) {
$nameMap[$column->getPhpName()] = $column->getColumnName();
}
self::$phpNameMap = $nameMap;
}
return self::$phpNameMap;
}
/**
* Translates a fieldname to another type
*
* @param string $name field name
* @param string $fromType One of the class type constants TYPE_PHPNAME,
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
* @param string $toType One of the class type constants
* @return string translated name of the field.
*/
static public function translateFieldName($name, $fromType, $toType)
{
$toNames = self::getFieldNames($toType);
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
if ($key === null) {
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
}
return $toNames[$key];
}
/**
* Returns an array of of field names.
*
* @param string $type The type of fieldnames to return:
* One of the class type constants TYPE_PHPNAME,
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
* @return array A list of field names
*/
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
{
if (!array_key_exists($type, self::$fieldNames)) {
throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
}
return self::$fieldNames[$type];
}
/**
* Convenience method which changes table.column to alias.column.
*
* Using this method you can maintain SQL abstraction while using column aliases.
* <code>
* $c->addAlias("alias1", TablePeer::TABLE_NAME);
* $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
* </code>
* @param string $alias The alias for the current table.
* @param string $column The column name for current table. (i.e. DeliveryI18nPeer::COLUMN_NAME).
* @return string
*/
public static function alias($alias, $column)
{
return str_replace(DeliveryI18nPeer::TABLE_NAME.'.', $alias.'.', $column);
}
/**
* Add all the columns needed to create a new object.
*
* Note: any columns that were marked with lazyLoad="true" in the
* XML schema will not be added to the select list and only loaded
* on demand.
*
* @param criteria object containing the columns to add.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function addSelectColumns(Criteria $criteria)
{
$criteria->addSelectColumn(DeliveryI18nPeer::ID);
$criteria->addSelectColumn(DeliveryI18nPeer::CULTURE);
$criteria->addSelectColumn(DeliveryI18nPeer::NAME);
$criteria->addSelectColumn(DeliveryI18nPeer::DESCRIPTION);
if (stEventDispatcher::getInstance()->getListeners('DeliveryI18nPeer.postAddSelectColumns')) {
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'DeliveryI18nPeer.postAddSelectColumns'));
}
}
const COUNT = 'COUNT(st_delivery_i18n.ID)';
const COUNT_DISTINCT = 'COUNT(DISTINCT st_delivery_i18n.ID)';
/**
* Returns the number of rows matching criteria.
*
* @param Criteria $criteria
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
* @param Connection $con
* @return int Number of matching rows.
*/
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
{
// we're going to modify criteria, so copy it first
$criteria = clone $criteria;
// clear out anything that might confuse the ORDER BY clause
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(DeliveryI18nPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(DeliveryI18nPeer::COUNT);
}
// just in case we're grouping: add those columns to the select statement
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$rs = DeliveryI18nPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
// no rows returned; we infer that means 0 matches.
return 0;
}
}
/**
* Method to select one object from the DB.
*
* @param Criteria $criteria object used to create the SELECT statement.
* @param Connection $con
* @return DeliveryI18n
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelectOne(Criteria $criteria, $con = null)
{
$critcopy = clone $criteria;
$critcopy->setLimit(1);
$objects = DeliveryI18nPeer::doSelect($critcopy, $con);
if ($objects) {
return $objects[0];
}
return null;
}
/**
* Method to do selects.
*
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
* @param Connection $con
* @return DeliveryI18n[]
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelect(Criteria $criteria, $con = null)
{
return DeliveryI18nPeer::populateObjects(DeliveryI18nPeer::doSelectRS($criteria, $con));
}
/**
* Prepares the Criteria object and uses the parent doSelect()
* method to get a ResultSet.
*
* Use this method directly if you want to just get the resultset
* (instead of an array of objects).
*
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
* @param Connection $con the connection to use
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @return ResultSet The resultset object with numerically-indexed fields.
* @see BasePeer::doSelect()
*/
public static function doSelectRS(Criteria $criteria, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if (!$criteria->getSelectColumns()) {
$criteria = clone $criteria;
DeliveryI18nPeer::addSelectColumns($criteria);
}
if (stEventDispatcher::getInstance()->getListeners('BasePeer.preDoSelectRs')) {
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'BasePeer.preDoSelectRs'));
}
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
// BasePeer returns a Creole ResultSet, set to return
// rows indexed numerically.
$rs = BasePeer::doSelect($criteria, $con);
if (stEventDispatcher::getInstance()->getListeners('BasePeer.postDoSelectRs')) {
stEventDispatcher::getInstance()->notify(new sfEvent($rs, 'BasePeer.postDoSelectRs'));
}
return $rs;
}
/**
* The returned array will contain objects of the default type or
* objects that inherit from the default.
*
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function populateObjects(ResultSet $rs)
{
if (self::$hydrateMethod)
{
return call_user_func(self::$hydrateMethod, $rs);
}
$results = array();
// set the class once to avoid overhead in the loop
$cls = DeliveryI18nPeer::getOMClass();
$cls = Propel::import($cls);
// populate the object(s)
while($rs->next()) {
$obj = new $cls();
$obj->hydrate($rs);
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj) : $obj;
}
return $results;
}
/**
* Returns the number of rows matching criteria, joining the related Delivery table
*
* @param Criteria $c
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
* @param Connection $con
* @return int Number of matching rows.
*/
public static function doCountJoinDelivery(Criteria $criteria, $distinct = false, $con = null)
{
// we're going to modify criteria, so copy it first
$criteria = clone $criteria;
// clear out anything that might confuse the ORDER BY clause
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(DeliveryI18nPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(DeliveryI18nPeer::COUNT);
}
// just in case we're grouping: add those columns to the select statement
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$criteria->addJoin(DeliveryI18nPeer::ID, DeliveryPeer::ID);
$rs = DeliveryI18nPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
// no rows returned; we infer that means 0 matches.
return 0;
}
}
/**
* Selects a collection of DeliveryI18n objects pre-filled with their Delivery objects.
*
* @return DeliveryI18n[] Array of DeliveryI18n objects.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelectJoinDelivery(Criteria $c, $con = null)
{
$c = clone $c;
// Set the correct dbName if it has not been overridden
if ($c->getDbName() == Propel::getDefaultDB()) {
$c->setDbName(self::DATABASE_NAME);
}
DeliveryI18nPeer::addSelectColumns($c);
DeliveryPeer::addSelectColumns($c);
$c->addJoin(DeliveryI18nPeer::ID, DeliveryPeer::ID);
$rs = DeliveryI18nPeer::doSelectRs($c, $con);
if (self::$hydrateMethod)
{
return call_user_func(self::$hydrateMethod, $rs);
}
$results = array();
while($rs->next()) {
$obj1 = new DeliveryI18n();
$startcol = $obj1->hydrate($rs);
if ($obj1->getId())
{
$obj2 = new Delivery();
$obj2->hydrate($rs, $startcol);
$obj2->addDeliveryI18n($obj1);
}
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj1) : $obj1;;
}
return $results;
}
/**
* Returns the number of rows matching criteria, joining all related tables
*
* @param Criteria $c
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
* @param Connection $con
* @return int Number of matching rows.
*/
public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
// clear out anything that might confuse the ORDER BY clause
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(DeliveryI18nPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(DeliveryI18nPeer::COUNT);
}
// just in case we're grouping: add those columns to the select statement
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$criteria->addJoin(DeliveryI18nPeer::ID, DeliveryPeer::ID);
$rs = DeliveryI18nPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
// no rows returned; we infer that means 0 matches.
return 0;
}
}
/**
* Selects a collection of DeliveryI18n objects pre-filled with all related objects.
*
* @return DeliveryI18n[]
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelectJoinAll(Criteria $c, $con = null)
{
$c = clone $c;
// Set the correct dbName if it has not been overridden
if ($c->getDbName() == Propel::getDefaultDB()) {
$c->setDbName(self::DATABASE_NAME);
}
DeliveryI18nPeer::addSelectColumns($c);
$startcol2 = (DeliveryI18nPeer::NUM_COLUMNS - DeliveryI18nPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
DeliveryPeer::addSelectColumns($c);
$startcol3 = $startcol2 + DeliveryPeer::NUM_COLUMNS;
$c->addJoin(DeliveryI18nPeer::ID, DeliveryPeer::ID);
$rs = BasePeer::doSelect($c, $con);
if (self::$hydrateMethod)
{
return call_user_func(self::$hydrateMethod, $rs);
}
$results = array();
while($rs->next()) {
$omClass = DeliveryI18nPeer::getOMClass();
$cls = Propel::import($omClass);
$obj1 = new $cls();
$obj1->hydrate($rs);
// Add objects for joined Delivery rows
$omClass = DeliveryPeer::getOMClass();
$cls = Propel::import($omClass);
$obj2 = new $cls();
$obj2->hydrate($rs, $startcol2);
$newObject = true;
for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
$temp_obj1 = $results[$j];
$temp_obj2 = $temp_obj1->getDelivery(); // CHECKME
if (null !== $temp_obj2 && $temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
$newObject = false;
$temp_obj2->addDeliveryI18n($obj1); // CHECKME
break;
}
}
if ($newObject) {
$obj2->initDeliveryI18ns();
$obj2->addDeliveryI18n($obj1);
}
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj1) : $obj1;
}
return $results;
}
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
* @return TableMap
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function getTableMap()
{
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
}
/**
* The class that the Peer will make instances of.
*
* This uses a dot-path notation which is tranalted into a path
* relative to a location on the PHP include_path.
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
*
* @return string path.to.ClassName
*/
public static function getOMClass()
{
return DeliveryI18nPeer::CLASS_DEFAULT;
}
/**
* Method perform an INSERT on the database, given a DeliveryI18n or Criteria object.
*
* @param mixed $values Criteria or DeliveryI18n object containing data that is used to create the INSERT statement.
* @param Connection $con the connection to use
* @return mixed The new primary key.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doInsert($values, $con = null)
{
foreach (sfMixer::getCallables('BaseDeliveryI18nPeer:doInsert:pre') as $callable)
{
$ret = call_user_func($callable, 'BaseDeliveryI18nPeer', $values, $con);
if (false !== $ret)
{
return $ret;
}
}
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; // rename for clarity
} else {
$criteria = $values->buildCriteria(); // build Criteria from DeliveryI18n object
}
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
try {
// use transaction because $criteria could contain info
// for more than one table (I guess, conceivably)
$con->begin();
$pk = BasePeer::doInsert($criteria, $con);
$con->commit();
} catch(PropelException $e) {
$con->rollback();
throw $e;
}
foreach (sfMixer::getCallables('BaseDeliveryI18nPeer:doInsert:post') as $callable)
{
call_user_func($callable, 'BaseDeliveryI18nPeer', $values, $con, $pk);
}
return $pk;
}
/**
* Method perform an UPDATE on the database, given a DeliveryI18n or Criteria object.
*
* @param mixed $values Criteria or DeliveryI18n object containing data that is used to create the UPDATE statement.
* @param Connection $con The connection to use (specify Connection object to exert more control over transactions).
* @return int The number of affected rows (if supported by underlying database driver).
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doUpdate($values, $con = null)
{
foreach (sfMixer::getCallables('BaseDeliveryI18nPeer:doUpdate:pre') as $callable)
{
$ret = call_user_func($callable, 'BaseDeliveryI18nPeer', $values, $con);
if (false !== $ret)
{
return $ret;
}
}
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$selectCriteria = new Criteria(self::DATABASE_NAME);
if ($values instanceof Criteria) {
$criteria = clone $values; // rename for clarity
$comparison = $criteria->getComparison(DeliveryI18nPeer::ID);
$selectCriteria->add(DeliveryI18nPeer::ID, $criteria->remove(DeliveryI18nPeer::ID), $comparison);
$comparison = $criteria->getComparison(DeliveryI18nPeer::CULTURE);
$selectCriteria->add(DeliveryI18nPeer::CULTURE, $criteria->remove(DeliveryI18nPeer::CULTURE), $comparison);
} else { // $values is DeliveryI18n object
$criteria = $values->buildCriteria(); // gets full criteria
$selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
}
// set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
$ret = BasePeer::doUpdate($selectCriteria, $criteria, $con);
foreach (sfMixer::getCallables('BaseDeliveryI18nPeer:doUpdate:post') as $callable)
{
call_user_func($callable, 'BaseDeliveryI18nPeer', $values, $con, $ret);
}
return $ret;
}
/**
* Method to DELETE all rows from the st_delivery_i18n table.
*
* @return int The number of affected rows (if supported by underlying database driver).
*/
public static function doDeleteAll($con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->begin();
$affectedRows += BasePeer::doDeleteAll(DeliveryI18nPeer::TABLE_NAME, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
/**
* Method perform a DELETE on the database, given a DeliveryI18n or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or DeliveryI18n object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param Connection $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doDelete($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(DeliveryI18nPeer::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; // rename for clarity
} elseif ($values instanceof DeliveryI18n) {
$criteria = $values->buildPkeyCriteria();
} else {
// it must be the primary key
$criteria = new Criteria(self::DATABASE_NAME);
// primary key is composite; we therefore, expect
// the primary key passed to be an array of pkey
// values
if(count($values) == count($values, COUNT_RECURSIVE))
{
// array is not multi-dimensional
$values = array($values);
}
$vals = array();
foreach($values as $value)
{
$vals[0][] = $value[0];
$vals[1][] = $value[1];
}
$criteria->add(DeliveryI18nPeer::ID, $vals[0], Criteria::IN);
$criteria->add(DeliveryI18nPeer::CULTURE, $vals[1], Criteria::IN);
}
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->begin();
$affectedRows += BasePeer::doDelete($criteria, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
/**
* Validates all modified columns of given DeliveryI18n object.
* If parameter $columns is either a single column name or an array of column names
* than only those columns are validated.
*
* NOTICE: This does not apply to primary or foreign keys for now.
*
* @param DeliveryI18n $obj The object to validate.
* @param mixed $cols Column name or array of column names.
*
* @return mixed TRUE if all columns are valid or the error message of the first invalid column.
*/
public static function doValidate(DeliveryI18n $obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(DeliveryI18nPeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(DeliveryI18nPeer::TABLE_NAME);
if (! is_array($cols)) {
$cols = array($cols);
}
foreach($cols as $colName) {
if ($tableMap->containsColumn($colName)) {
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
$columns[$colName] = $obj->$get();
}
}
} else {
}
$res = BasePeer::doValidate(DeliveryI18nPeer::DATABASE_NAME, DeliveryI18nPeer::TABLE_NAME, $columns);
if ($res !== true) {
$request = sfContext::getInstance()->getRequest();
foreach ($res as $failed) {
$col = DeliveryI18nPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
$request->setError($col, $failed->getMessage());
}
}
return $res;
}
/**
* Retrieve object using using composite pkey values.
* @param int $id
@param string $culture
* @param Connection $con
* @return DeliveryI18n
*/
public static function retrieveByPK( $id, $culture, $con = null) {
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$criteria = new Criteria();
$criteria->add(DeliveryI18nPeer::ID, $id);
$criteria->add(DeliveryI18nPeer::CULTURE, $culture);
$v = DeliveryI18nPeer::doSelect($criteria, $con);
return !empty($v) ? $v[0] : null;
}
} // BaseDeliveryI18nPeer
// static code to register the map builder for this Peer with the main Propel class
if (Propel::isInit()) {
// the MapBuilder classes register themselves with Propel during initialization
// so we need to load them here.
try {
BaseDeliveryI18nPeer::getMapBuilder();
} catch (Exception $e) {
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
}
} else {
// even if Propel is not yet initialized, the map builder class can be registered
// now and then it will be loaded when Propel initializes.
Propel::registerMapBuilder('plugins.stDeliveryPlugin.lib.model.map.DeliveryI18nMapBuilder');
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,886 @@
<?php
/**
* Base class that represents a row from the 'st_delivery_sections' table.
*
*
*
* @package plugins.stDeliveryPlugin.lib.model.om
*/
abstract class BaseDeliverySections extends BaseObject implements Persistent {
protected static $dispatcher = null;
/**
* The value for the id field.
* @var int
*/
protected $id;
/**
* The value for the delivery_id field.
* @var int
*/
protected $delivery_id;
/**
* The value for the value_from field.
* @var double
*/
protected $value_from = 0.0;
/**
* The value for the amount field.
* @var double
*/
protected $amount = 0.0;
/**
* The value for the amount_brutto field.
* @var double
*/
protected $amount_brutto;
/**
* @var Delivery
*/
protected $aDelivery;
/**
* Flag to prevent endless save loop, if this object is referenced
* by another object which falls in this transaction.
* @var boolean
*/
protected $alreadyInSave = false;
/**
* Flag to prevent endless validation loop, if this object is referenced
* by another object which falls in this transaction.
* @var boolean
*/
protected $alreadyInValidation = false;
/**
* Get the [id] column value.
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Get the [delivery_id] column value.
*
* @return int
*/
public function getDeliveryId()
{
return $this->delivery_id;
}
/**
* Get the [value_from] column value.
*
* @return double
*/
public function getValueFrom()
{
return null !== $this->value_from ? (string)$this->value_from : null;
}
/**
* Get the [amount] column value.
*
* @return double
*/
public function getAmount()
{
return null !== $this->amount ? (string)$this->amount : null;
}
/**
* Get the [amount_brutto] column value.
*
* @return double
*/
public function getAmountBrutto()
{
return null !== $this->amount_brutto ? (string)$this->amount_brutto : null;
}
/**
* Set the value of [id] column.
*
* @param int $v new value
* @return void
*/
public function setId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->id !== $v) {
$this->id = $v;
$this->modifiedColumns[] = DeliverySectionsPeer::ID;
}
} // setId()
/**
* Set the value of [delivery_id] column.
*
* @param int $v new value
* @return void
*/
public function setDeliveryId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->delivery_id !== $v) {
$this->delivery_id = $v;
$this->modifiedColumns[] = DeliverySectionsPeer::DELIVERY_ID;
}
if ($this->aDelivery !== null && $this->aDelivery->getId() !== $v) {
$this->aDelivery = null;
}
} // setDeliveryId()
/**
* Set the value of [value_from] column.
*
* @param double $v new value
* @return void
*/
public function setValueFrom($v)
{
if ($v !== null && !is_float($v) && is_numeric($v)) {
$v = (float) $v;
}
if ($this->value_from !== $v || $v === 0.0) {
$this->value_from = $v;
$this->modifiedColumns[] = DeliverySectionsPeer::VALUE_FROM;
}
} // setValueFrom()
/**
* Set the value of [amount] column.
*
* @param double $v new value
* @return void
*/
public function setAmount($v)
{
if ($v !== null && !is_float($v) && is_numeric($v)) {
$v = (float) $v;
}
if ($this->amount !== $v || $v === 0.0) {
$this->amount = $v;
$this->modifiedColumns[] = DeliverySectionsPeer::AMOUNT;
}
} // setAmount()
/**
* Set the value of [amount_brutto] column.
*
* @param double $v new value
* @return void
*/
public function setAmountBrutto($v)
{
if ($v !== null && !is_float($v) && is_numeric($v)) {
$v = (float) $v;
}
if ($this->amount_brutto !== $v) {
$this->amount_brutto = $v;
$this->modifiedColumns[] = DeliverySectionsPeer::AMOUNT_BRUTTO;
}
} // setAmountBrutto()
/**
* Hydrates (populates) the object variables with values from the database resultset.
*
* An offset (1-based "start column") is specified so that objects can be hydrated
* with a subset of the columns in the resultset rows. This is needed, for example,
* for results of JOIN queries where the resultset row includes columns from two or
* more tables.
*
* @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos.
* @param int $startcol 1-based offset column which indicates which restultset column to start with.
* @return int next starting column
* @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
*/
public function hydrate(ResultSet $rs, $startcol = 1)
{
try {
if ($this->getDispatcher()->getListeners('DeliverySections.preHydrate')) {
$event = $this->getDispatcher()->notify(new sfEvent($this, 'DeliverySections.preHydrate', array('resultset' => $rs, 'startcol' => $startcol)));
$startcol = $event['startcol'];
}
$this->id = $rs->getInt($startcol + 0);
$this->delivery_id = $rs->getInt($startcol + 1);
$this->value_from = $rs->getString($startcol + 2);
if (null !== $this->value_from && $this->value_from == intval($this->value_from))
{
$this->value_from = (string)intval($this->value_from);
}
$this->amount = $rs->getString($startcol + 3);
if (null !== $this->amount && $this->amount == intval($this->amount))
{
$this->amount = (string)intval($this->amount);
}
$this->amount_brutto = $rs->getString($startcol + 4);
if (null !== $this->amount_brutto && $this->amount_brutto == intval($this->amount_brutto))
{
$this->amount_brutto = (string)intval($this->amount_brutto);
}
$this->resetModified();
$this->setNew(false);
if ($this->getDispatcher()->getListeners('DeliverySections.postHydrate')) {
$event = $this->getDispatcher()->notify(new sfEvent($this, 'DeliverySections.postHydrate', array('resultset' => $rs, 'startcol' => $startcol + 5)));
return $event['startcol'];
}
// FIXME - using NUM_COLUMNS may be clearer.
return $startcol + 5; // 5 = DeliverySectionsPeer::NUM_COLUMNS - DeliverySectionsPeer::NUM_LAZY_LOAD_COLUMNS).
} catch (Exception $e) {
throw new PropelException("Error populating DeliverySections object", $e);
}
}
/**
* Removes this object from datastore and sets delete attribute.
*
* @param Connection $con
* @return void
* @throws PropelException
* @see BaseObject::setDeleted()
* @see BaseObject::isDeleted()
*/
public function delete($con = null)
{
if ($this->isDeleted()) {
throw new PropelException("This object has already been deleted.");
}
if ($this->getDispatcher()->getListeners('DeliverySections.preDelete')) {
$this->getDispatcher()->notify(new sfEvent($this, 'DeliverySections.preDelete', array('con' => $con)));
}
if (sfMixer::hasCallables('BaseDeliverySections:delete:pre'))
{
foreach (sfMixer::getCallables('BaseDeliverySections:delete:pre') as $callable)
{
$ret = call_user_func($callable, $this, $con);
if ($ret)
{
return;
}
}
}
if ($con === null) {
$con = Propel::getConnection(DeliverySectionsPeer::DATABASE_NAME);
}
try {
$con->begin();
DeliverySectionsPeer::doDelete($this, $con);
$this->setDeleted(true);
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
if ($this->getDispatcher()->getListeners('DeliverySections.postDelete')) {
$this->getDispatcher()->notify(new sfEvent($this, 'DeliverySections.postDelete', array('con' => $con)));
}
if (sfMixer::hasCallables('BaseDeliverySections:delete:post'))
{
foreach (sfMixer::getCallables('BaseDeliverySections:delete:post') as $callable)
{
call_user_func($callable, $this, $con);
}
}
}
/**
* Stores the object in the database. If the object is new,
* it inserts it; otherwise an update is performed. This method
* wraps the doSave() worker method in a transaction.
*
* @param Connection $con
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
* @throws PropelException
* @see doSave()
*/
public function save($con = null)
{
if ($this->isDeleted()) {
throw new PropelException("You cannot save an object that has been deleted.");
}
if (!$this->alreadyInSave) {
if ($this->getDispatcher()->getListeners('DeliverySections.preSave')) {
$this->getDispatcher()->notify(new sfEvent($this, 'DeliverySections.preSave', array('con' => $con)));
}
foreach (sfMixer::getCallables('BaseDeliverySections:save:pre') as $callable)
{
$affectedRows = call_user_func($callable, $this, $con);
if (is_int($affectedRows))
{
return $affectedRows;
}
}
}
if ($con === null) {
$con = Propel::getConnection(DeliverySectionsPeer::DATABASE_NAME);
}
try {
$con->begin();
$affectedRows = $this->doSave($con);
$con->commit();
if (!$this->alreadyInSave) {
if ($this->getDispatcher()->getListeners('DeliverySections.postSave')) {
$this->getDispatcher()->notify(new sfEvent($this, 'DeliverySections.postSave', array('con' => $con)));
}
foreach (sfMixer::getCallables('BaseDeliverySections:save:post') as $callable)
{
call_user_func($callable, $this, $con, $affectedRows);
}
}
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
/**
* Stores the object in the database.
*
* If the object is new, it inserts it; otherwise an update is performed.
* All related objects are also updated in this method.
*
* @param Connection $con
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
* @throws PropelException
* @see save()
*/
protected function doSave($con)
{
$affectedRows = 0; // initialize var to track total num of affected rows
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
// We call the save method on the following object(s) if they
// were passed to this object by their coresponding set
// method. This object relates to these object(s) by a
// foreign key reference.
if ($this->aDelivery !== null) {
if ($this->aDelivery->isModified() || $this->aDelivery->getCurrentDeliveryI18n()->isModified()) {
$affectedRows += $this->aDelivery->save($con);
}
$this->setDelivery($this->aDelivery);
}
// If this object has been modified, then save it to the database.
if ($this->isModified()) {
if ($this->isNew()) {
$pk = DeliverySectionsPeer::doInsert($this, $con);
$affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which
// should always be true here (even though technically
// BasePeer::doInsert() can insert multiple rows).
$this->setId($pk); //[IMV] update autoincrement primary key
$this->setNew(false);
} else {
$affectedRows += DeliverySectionsPeer::doUpdate($this, $con);
}
$this->resetModified(); // [HL] After being saved an object is no longer 'modified'
}
$this->alreadyInSave = false;
}
return $affectedRows;
} // doSave()
/**
* Array of ValidationFailed objects.
* @var array ValidationFailed[]
*/
protected $validationFailures = array();
/**
* Gets any ValidationFailed objects that resulted from last call to validate().
*
*
* @return array ValidationFailed[]
* @see validate()
*/
public function getValidationFailures()
{
return $this->validationFailures;
}
/**
* Validates the objects modified field values and all objects related to this table.
*
* If $columns is either a column name or an array of column names
* only those columns are validated.
*
* @param mixed $columns Column name or an array of column names.
* @return boolean Whether all columns pass validation.
* @see doValidate()
* @see getValidationFailures()
*/
public function validate($columns = null)
{
$res = $this->doValidate($columns);
if ($res === true) {
$this->validationFailures = array();
return true;
} else {
$this->validationFailures = $res;
return false;
}
}
/**
* This function performs the validation work for complex object models.
*
* In addition to checking the current object, all related objects will
* also be validated. If all pass then <code>true</code> is returned; otherwise
* an aggreagated array of ValidationFailed objects will be returned.
*
* @param array $columns Array of column names to validate.
* @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
*/
protected function doValidate($columns = null)
{
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
// We call the validate method on the following object(s) if they
// were passed to this object by their coresponding set
// method. This object relates to these object(s) by a
// foreign key reference.
if ($this->aDelivery !== null) {
if (!$this->aDelivery->validate($columns)) {
$failureMap = array_merge($failureMap, $this->aDelivery->getValidationFailures());
}
}
if (($retval = DeliverySectionsPeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
$this->alreadyInValidation = false;
}
return (!empty($failureMap) ? $failureMap : true);
}
/**
* Retrieves a field from the object by name passed in as a string.
*
* @param string $name name
* @param string $type The type of fieldname the $name is of:
* one of the class type constants TYPE_PHPNAME,
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
* @return mixed Value of field.
*/
public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
{
$pos = DeliverySectionsPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->getByPosition($pos);
}
/**
* Retrieves a field from the object by Position as specified in the xml schema.
* Zero-based.
*
* @param int $pos position in xml schema
* @return mixed Value of field at $pos
*/
public function getByPosition($pos)
{
switch($pos) {
case 0:
return $this->getId();
break;
case 1:
return $this->getDeliveryId();
break;
case 2:
return $this->getValueFrom();
break;
case 3:
return $this->getAmount();
break;
case 4:
return $this->getAmountBrutto();
break;
default:
return null;
break;
} // switch()
}
/**
* Exports the object as an array.
*
* You can specify the key type of the array by passing one of the class
* type constants.
*
* @param string $keyType One of the class type constants TYPE_PHPNAME,
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
* @return an associative array containing the field names (as keys) and field values
*/
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
{
$keys = DeliverySectionsPeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getId(),
$keys[1] => $this->getDeliveryId(),
$keys[2] => $this->getValueFrom(),
$keys[3] => $this->getAmount(),
$keys[4] => $this->getAmountBrutto(),
);
return $result;
}
/**
* Sets a field from the object by name passed in as a string.
*
* @param string $name peer name
* @param mixed $value field value
* @param string $type The type of fieldname the $name is of:
* one of the class type constants TYPE_PHPNAME,
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
* @return void
*/
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
{
$pos = DeliverySectionsPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->setByPosition($pos, $value);
}
/**
* Sets a field from the object by Position as specified in the xml schema.
* Zero-based.
*
* @param int $pos position in xml schema
* @param mixed $value field value
* @return void
*/
public function setByPosition($pos, $value)
{
switch($pos) {
case 0:
$this->setId($value);
break;
case 1:
$this->setDeliveryId($value);
break;
case 2:
$this->setValueFrom($value);
break;
case 3:
$this->setAmount($value);
break;
case 4:
$this->setAmountBrutto($value);
break;
} // switch()
}
/**
* Populates the object using an array.
*
* This is particularly useful when populating an object from one of the
* request arrays (e.g. $_POST). This method goes through the column
* names, checking to see whether a matching key exists in populated
* array. If so the setByName() method is called for that column.
*
* You can specify the key type of the array by additionally passing one
* of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
* TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId')
*
* @param array $arr An array to populate the object from.
* @param string $keyType The type of keys the array uses.
* @return void
*/
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
{
$keys = DeliverySectionsPeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setDeliveryId($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setValueFrom($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setAmount($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setAmountBrutto($arr[$keys[4]]);
}
/**
* Build a Criteria object containing the values of all modified columns in this object.
*
* @return Criteria The Criteria object containing all modified values.
*/
public function buildCriteria()
{
$criteria = new Criteria(DeliverySectionsPeer::DATABASE_NAME);
if ($this->isColumnModified(DeliverySectionsPeer::ID)) $criteria->add(DeliverySectionsPeer::ID, $this->id);
if ($this->isColumnModified(DeliverySectionsPeer::DELIVERY_ID)) $criteria->add(DeliverySectionsPeer::DELIVERY_ID, $this->delivery_id);
if ($this->isColumnModified(DeliverySectionsPeer::VALUE_FROM)) $criteria->add(DeliverySectionsPeer::VALUE_FROM, $this->value_from);
if ($this->isColumnModified(DeliverySectionsPeer::AMOUNT)) $criteria->add(DeliverySectionsPeer::AMOUNT, $this->amount);
if ($this->isColumnModified(DeliverySectionsPeer::AMOUNT_BRUTTO)) $criteria->add(DeliverySectionsPeer::AMOUNT_BRUTTO, $this->amount_brutto);
return $criteria;
}
/**
* Builds a Criteria object containing the primary key for this object.
*
* Unlike buildCriteria() this method includes the primary key values regardless
* of whether or not they have been modified.
*
* @return Criteria The Criteria object containing value(s) for primary key(s).
*/
public function buildPkeyCriteria()
{
$criteria = new Criteria(DeliverySectionsPeer::DATABASE_NAME);
$criteria->add(DeliverySectionsPeer::ID, $this->id);
return $criteria;
}
/**
* Returns the primary key for this object (row).
* @return int
*/
public function getPrimaryKey()
{
return $this->getId();
}
/**
* Returns [composite] primary key fields
*
* @param string $keyType
* @return array
*/
public function getPrimaryKeyFields($keyType = BasePeer::TYPE_FIELDNAME)
{
return array(DeliverySectionsPeer::translateFieldName('id', BasePeer::TYPE_FIELDNAME, $keyType));
}
/**
* Generic method to set the primary key (id column).
*
* @param int $key Primary key.
* @return void
*/
public function setPrimaryKey($key)
{
$this->setId($key);
}
/**
* Sets contents of passed object to values from current object.
*
* If desired, this method can also make copies of all associated (fkey referrers)
* objects.
*
* @param object $copyObj An object of DeliverySections (or compatible) type.
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
* @throws PropelException
*/
public function copyInto($copyObj, $deepCopy = false)
{
$copyObj->setDeliveryId($this->delivery_id);
$copyObj->setValueFrom($this->value_from);
$copyObj->setAmount($this->amount);
$copyObj->setAmountBrutto($this->amount_brutto);
$copyObj->setNew(true);
$copyObj->setId(NULL); // this is a pkey column, so set to default value
}
/**
* Makes a copy of this object that will be inserted as a new row in table when saved.
* It creates a new object filling in the simple attributes, but skipping any primary
* keys that are defined for the table.
*
* If desired, this method can also make copies of all associated (fkey referrers)
* objects.
*
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
* @return DeliverySections Clone of current object.
* @throws PropelException
*/
public function copy($deepCopy = false)
{
// we use get_class(), because this might be a subclass
$clazz = get_class($this);
$copyObj = new $clazz();
$this->copyInto($copyObj, $deepCopy);
return $copyObj;
}
/**
* Returns a peer instance associated with this om.
*
* @return string Peer class name
*/
public function getPeer()
{
return 'DeliverySectionsPeer';
}
/**
* Declares an association between this object and a Delivery object.
*
* @param Delivery $v
* @return void
* @throws PropelException
*/
public function setDelivery($v)
{
if ($v === null) {
$this->setDeliveryId(NULL);
} else {
$this->setDeliveryId($v->getId());
}
$this->aDelivery = $v;
}
/**
* Get the associated Delivery object
*
* @param Connection Optional Connection object.
* @return Delivery The associated Delivery object.
* @throws PropelException
*/
public function getDelivery($con = null)
{
if ($this->aDelivery === null && ($this->delivery_id !== null)) {
// include the related Peer class
$this->aDelivery = DeliveryPeer::retrieveByPK($this->delivery_id, $con);
/* The following can be used instead of the line above to
guarantee the related object contains a reference
to this object, but this level of coupling
may be undesirable in many circumstances.
As it can lead to a db query with many results that may
never be used.
$obj = DeliveryPeer::retrieveByPK($this->delivery_id, $con);
$obj->addDeliverys($this);
*/
}
return $this->aDelivery;
}
public function getDispatcher()
{
if (null === self::$dispatcher)
{
self::$dispatcher = stEventDispatcher::getInstance();
}
return self::$dispatcher;
}
public function __call($method, $arguments)
{
$event = $this->getDispatcher()->notifyUntil(new sfEvent($this, 'DeliverySections.' . $method, array('arguments' => $arguments, 'method' => $method)));
if ($event->isProcessed())
{
return $event->getReturnValue();
}
if (!$callable = sfMixer::getCallable('BaseDeliverySections:'.$method))
{
throw new sfException(sprintf('Call to undefined method BaseDeliverySections::%s', $method));
}
array_unshift($arguments, $this);
return call_user_func_array($callable, $arguments);
}
} // BaseDeliverySections

View File

@@ -0,0 +1,856 @@
<?php
/**
* Base static class for performing query and update operations on the 'st_delivery_sections' table.
*
*
*
* @package plugins.stDeliveryPlugin.lib.model.om
*/
abstract class BaseDeliverySectionsPeer {
/** the default database name for this class */
const DATABASE_NAME = 'propel';
/** the table name for this class */
const TABLE_NAME = 'st_delivery_sections';
/** A class that can be returned by this peer. */
const CLASS_DEFAULT = 'plugins.stDeliveryPlugin.lib.model.DeliverySections';
/** The total number of columns. */
const NUM_COLUMNS = 5;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
/** the column name for the ID field */
const ID = 'st_delivery_sections.ID';
/** the column name for the DELIVERY_ID field */
const DELIVERY_ID = 'st_delivery_sections.DELIVERY_ID';
/** the column name for the VALUE_FROM field */
const VALUE_FROM = 'st_delivery_sections.VALUE_FROM';
/** the column name for the AMOUNT field */
const AMOUNT = 'st_delivery_sections.AMOUNT';
/** the column name for the AMOUNT_BRUTTO field */
const AMOUNT_BRUTTO = 'st_delivery_sections.AMOUNT_BRUTTO';
/** The PHP to DB Name Mapping */
private static $phpNameMap = null;
/**
* holds an array of fieldnames
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('Id', 'DeliveryId', 'ValueFrom', 'Amount', 'AmountBrutto', ),
BasePeer::TYPE_COLNAME => array (DeliverySectionsPeer::ID, DeliverySectionsPeer::DELIVERY_ID, DeliverySectionsPeer::VALUE_FROM, DeliverySectionsPeer::AMOUNT, DeliverySectionsPeer::AMOUNT_BRUTTO, ),
BasePeer::TYPE_FIELDNAME => array ('id', 'delivery_id', 'value_from', 'amount', 'amount_brutto', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
);
/**
* holds an array of keys for quick access to the fieldnames array
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
*/
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'DeliveryId' => 1, 'ValueFrom' => 2, 'Amount' => 3, 'AmountBrutto' => 4, ),
BasePeer::TYPE_COLNAME => array (DeliverySectionsPeer::ID => 0, DeliverySectionsPeer::DELIVERY_ID => 1, DeliverySectionsPeer::VALUE_FROM => 2, DeliverySectionsPeer::AMOUNT => 3, DeliverySectionsPeer::AMOUNT_BRUTTO => 4, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'delivery_id' => 1, 'value_from' => 2, 'amount' => 3, 'amount_brutto' => 4, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, )
);
protected static $hydrateMethod = null;
protected static $postHydrateMethod = null;
public static function setHydrateMethod($callback)
{
self::$hydrateMethod = $callback;
}
public static function setPostHydrateMethod($callback)
{
self::$postHydrateMethod = $callback;
}
/**
* @return MapBuilder the map builder for this peer
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function getMapBuilder()
{
return BasePeer::getMapBuilder('plugins.stDeliveryPlugin.lib.model.map.DeliverySectionsMapBuilder');
}
/**
* Gets a map (hash) of PHP names to DB column names.
*
* @return array The PHP to DB name map for this peer
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @deprecated Use the getFieldNames() and translateFieldName() methods instead of this.
*/
public static function getPhpNameMap()
{
if (self::$phpNameMap === null) {
$map = DeliverySectionsPeer::getTableMap();
$columns = $map->getColumns();
$nameMap = array();
foreach ($columns as $column) {
$nameMap[$column->getPhpName()] = $column->getColumnName();
}
self::$phpNameMap = $nameMap;
}
return self::$phpNameMap;
}
/**
* Translates a fieldname to another type
*
* @param string $name field name
* @param string $fromType One of the class type constants TYPE_PHPNAME,
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
* @param string $toType One of the class type constants
* @return string translated name of the field.
*/
static public function translateFieldName($name, $fromType, $toType)
{
$toNames = self::getFieldNames($toType);
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
if ($key === null) {
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
}
return $toNames[$key];
}
/**
* Returns an array of of field names.
*
* @param string $type The type of fieldnames to return:
* One of the class type constants TYPE_PHPNAME,
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
* @return array A list of field names
*/
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
{
if (!array_key_exists($type, self::$fieldNames)) {
throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
}
return self::$fieldNames[$type];
}
/**
* Convenience method which changes table.column to alias.column.
*
* Using this method you can maintain SQL abstraction while using column aliases.
* <code>
* $c->addAlias("alias1", TablePeer::TABLE_NAME);
* $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
* </code>
* @param string $alias The alias for the current table.
* @param string $column The column name for current table. (i.e. DeliverySectionsPeer::COLUMN_NAME).
* @return string
*/
public static function alias($alias, $column)
{
return str_replace(DeliverySectionsPeer::TABLE_NAME.'.', $alias.'.', $column);
}
/**
* Add all the columns needed to create a new object.
*
* Note: any columns that were marked with lazyLoad="true" in the
* XML schema will not be added to the select list and only loaded
* on demand.
*
* @param criteria object containing the columns to add.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function addSelectColumns(Criteria $criteria)
{
$criteria->addSelectColumn(DeliverySectionsPeer::ID);
$criteria->addSelectColumn(DeliverySectionsPeer::DELIVERY_ID);
$criteria->addSelectColumn(DeliverySectionsPeer::VALUE_FROM);
$criteria->addSelectColumn(DeliverySectionsPeer::AMOUNT);
$criteria->addSelectColumn(DeliverySectionsPeer::AMOUNT_BRUTTO);
if (stEventDispatcher::getInstance()->getListeners('DeliverySectionsPeer.postAddSelectColumns')) {
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'DeliverySectionsPeer.postAddSelectColumns'));
}
}
const COUNT = 'COUNT(st_delivery_sections.ID)';
const COUNT_DISTINCT = 'COUNT(DISTINCT st_delivery_sections.ID)';
/**
* Returns the number of rows matching criteria.
*
* @param Criteria $criteria
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
* @param Connection $con
* @return int Number of matching rows.
*/
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
{
// we're going to modify criteria, so copy it first
$criteria = clone $criteria;
// clear out anything that might confuse the ORDER BY clause
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(DeliverySectionsPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(DeliverySectionsPeer::COUNT);
}
// just in case we're grouping: add those columns to the select statement
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$rs = DeliverySectionsPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
// no rows returned; we infer that means 0 matches.
return 0;
}
}
/**
* Method to select one object from the DB.
*
* @param Criteria $criteria object used to create the SELECT statement.
* @param Connection $con
* @return DeliverySections
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelectOne(Criteria $criteria, $con = null)
{
$critcopy = clone $criteria;
$critcopy->setLimit(1);
$objects = DeliverySectionsPeer::doSelect($critcopy, $con);
if ($objects) {
return $objects[0];
}
return null;
}
/**
* Method to do selects.
*
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
* @param Connection $con
* @return DeliverySections[]
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelect(Criteria $criteria, $con = null)
{
return DeliverySectionsPeer::populateObjects(DeliverySectionsPeer::doSelectRS($criteria, $con));
}
/**
* Prepares the Criteria object and uses the parent doSelect()
* method to get a ResultSet.
*
* Use this method directly if you want to just get the resultset
* (instead of an array of objects).
*
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
* @param Connection $con the connection to use
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @return ResultSet The resultset object with numerically-indexed fields.
* @see BasePeer::doSelect()
*/
public static function doSelectRS(Criteria $criteria, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if (!$criteria->getSelectColumns()) {
$criteria = clone $criteria;
DeliverySectionsPeer::addSelectColumns($criteria);
}
if (stEventDispatcher::getInstance()->getListeners('BasePeer.preDoSelectRs')) {
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'BasePeer.preDoSelectRs'));
}
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
// BasePeer returns a Creole ResultSet, set to return
// rows indexed numerically.
$rs = BasePeer::doSelect($criteria, $con);
if (stEventDispatcher::getInstance()->getListeners('BasePeer.postDoSelectRs')) {
stEventDispatcher::getInstance()->notify(new sfEvent($rs, 'BasePeer.postDoSelectRs'));
}
return $rs;
}
/**
* The returned array will contain objects of the default type or
* objects that inherit from the default.
*
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function populateObjects(ResultSet $rs)
{
if (self::$hydrateMethod)
{
return call_user_func(self::$hydrateMethod, $rs);
}
$results = array();
// set the class once to avoid overhead in the loop
$cls = DeliverySectionsPeer::getOMClass();
$cls = Propel::import($cls);
// populate the object(s)
while($rs->next()) {
$obj = new $cls();
$obj->hydrate($rs);
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj) : $obj;
}
return $results;
}
/**
* Returns the number of rows matching criteria, joining the related Delivery table
*
* @param Criteria $c
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
* @param Connection $con
* @return int Number of matching rows.
*/
public static function doCountJoinDelivery(Criteria $criteria, $distinct = false, $con = null)
{
// we're going to modify criteria, so copy it first
$criteria = clone $criteria;
// clear out anything that might confuse the ORDER BY clause
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(DeliverySectionsPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(DeliverySectionsPeer::COUNT);
}
// just in case we're grouping: add those columns to the select statement
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$criteria->addJoin(DeliverySectionsPeer::DELIVERY_ID, DeliveryPeer::ID);
$rs = DeliverySectionsPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
// no rows returned; we infer that means 0 matches.
return 0;
}
}
/**
* Selects a collection of DeliverySections objects pre-filled with their Delivery objects.
*
* @return DeliverySections[] Array of DeliverySections objects.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelectJoinDelivery(Criteria $c, $con = null)
{
$c = clone $c;
// Set the correct dbName if it has not been overridden
if ($c->getDbName() == Propel::getDefaultDB()) {
$c->setDbName(self::DATABASE_NAME);
}
DeliverySectionsPeer::addSelectColumns($c);
DeliveryPeer::addSelectColumns($c);
$c->addJoin(DeliverySectionsPeer::DELIVERY_ID, DeliveryPeer::ID);
$rs = DeliverySectionsPeer::doSelectRs($c, $con);
if (self::$hydrateMethod)
{
return call_user_func(self::$hydrateMethod, $rs);
}
$results = array();
while($rs->next()) {
$obj1 = new DeliverySections();
$startcol = $obj1->hydrate($rs);
if ($obj1->getDeliveryId())
{
$obj2 = new Delivery();
$obj2->hydrate($rs, $startcol);
$obj2->addDeliverySections($obj1);
}
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj1) : $obj1;;
}
return $results;
}
/**
* Returns the number of rows matching criteria, joining all related tables
*
* @param Criteria $c
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
* @param Connection $con
* @return int Number of matching rows.
*/
public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null)
{
$criteria = clone $criteria;
// clear out anything that might confuse the ORDER BY clause
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(DeliverySectionsPeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(DeliverySectionsPeer::COUNT);
}
// just in case we're grouping: add those columns to the select statement
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$criteria->addJoin(DeliverySectionsPeer::DELIVERY_ID, DeliveryPeer::ID);
$rs = DeliverySectionsPeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
// no rows returned; we infer that means 0 matches.
return 0;
}
}
/**
* Selects a collection of DeliverySections objects pre-filled with all related objects.
*
* @return DeliverySections[]
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelectJoinAll(Criteria $c, $con = null)
{
$c = clone $c;
// Set the correct dbName if it has not been overridden
if ($c->getDbName() == Propel::getDefaultDB()) {
$c->setDbName(self::DATABASE_NAME);
}
DeliverySectionsPeer::addSelectColumns($c);
$startcol2 = (DeliverySectionsPeer::NUM_COLUMNS - DeliverySectionsPeer::NUM_LAZY_LOAD_COLUMNS) + 1;
DeliveryPeer::addSelectColumns($c);
$startcol3 = $startcol2 + DeliveryPeer::NUM_COLUMNS;
$c->addJoin(DeliverySectionsPeer::DELIVERY_ID, DeliveryPeer::ID);
$rs = BasePeer::doSelect($c, $con);
if (self::$hydrateMethod)
{
return call_user_func(self::$hydrateMethod, $rs);
}
$results = array();
while($rs->next()) {
$omClass = DeliverySectionsPeer::getOMClass();
$cls = Propel::import($omClass);
$obj1 = new $cls();
$obj1->hydrate($rs);
// Add objects for joined Delivery rows
$omClass = DeliveryPeer::getOMClass();
$cls = Propel::import($omClass);
$obj2 = new $cls();
$obj2->hydrate($rs, $startcol2);
$newObject = true;
for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
$temp_obj1 = $results[$j];
$temp_obj2 = $temp_obj1->getDelivery(); // CHECKME
if (null !== $temp_obj2 && $temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
$newObject = false;
$temp_obj2->addDeliverySections($obj1); // CHECKME
break;
}
}
if ($newObject) {
$obj2->initDeliverySectionss();
$obj2->addDeliverySections($obj1);
}
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj1) : $obj1;
}
return $results;
}
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
* @return TableMap
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function getTableMap()
{
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
}
/**
* The class that the Peer will make instances of.
*
* This uses a dot-path notation which is tranalted into a path
* relative to a location on the PHP include_path.
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
*
* @return string path.to.ClassName
*/
public static function getOMClass()
{
return DeliverySectionsPeer::CLASS_DEFAULT;
}
/**
* Method perform an INSERT on the database, given a DeliverySections or Criteria object.
*
* @param mixed $values Criteria or DeliverySections object containing data that is used to create the INSERT statement.
* @param Connection $con the connection to use
* @return mixed The new primary key.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doInsert($values, $con = null)
{
foreach (sfMixer::getCallables('BaseDeliverySectionsPeer:doInsert:pre') as $callable)
{
$ret = call_user_func($callable, 'BaseDeliverySectionsPeer', $values, $con);
if (false !== $ret)
{
return $ret;
}
}
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; // rename for clarity
} else {
$criteria = $values->buildCriteria(); // build Criteria from DeliverySections object
}
$criteria->remove(DeliverySectionsPeer::ID); // remove pkey col since this table uses auto-increment
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
try {
// use transaction because $criteria could contain info
// for more than one table (I guess, conceivably)
$con->begin();
$pk = BasePeer::doInsert($criteria, $con);
$con->commit();
} catch(PropelException $e) {
$con->rollback();
throw $e;
}
foreach (sfMixer::getCallables('BaseDeliverySectionsPeer:doInsert:post') as $callable)
{
call_user_func($callable, 'BaseDeliverySectionsPeer', $values, $con, $pk);
}
return $pk;
}
/**
* Method perform an UPDATE on the database, given a DeliverySections or Criteria object.
*
* @param mixed $values Criteria or DeliverySections object containing data that is used to create the UPDATE statement.
* @param Connection $con The connection to use (specify Connection object to exert more control over transactions).
* @return int The number of affected rows (if supported by underlying database driver).
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doUpdate($values, $con = null)
{
foreach (sfMixer::getCallables('BaseDeliverySectionsPeer:doUpdate:pre') as $callable)
{
$ret = call_user_func($callable, 'BaseDeliverySectionsPeer', $values, $con);
if (false !== $ret)
{
return $ret;
}
}
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$selectCriteria = new Criteria(self::DATABASE_NAME);
if ($values instanceof Criteria) {
$criteria = clone $values; // rename for clarity
$comparison = $criteria->getComparison(DeliverySectionsPeer::ID);
$selectCriteria->add(DeliverySectionsPeer::ID, $criteria->remove(DeliverySectionsPeer::ID), $comparison);
} else { // $values is DeliverySections object
$criteria = $values->buildCriteria(); // gets full criteria
$selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
}
// set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
$ret = BasePeer::doUpdate($selectCriteria, $criteria, $con);
foreach (sfMixer::getCallables('BaseDeliverySectionsPeer:doUpdate:post') as $callable)
{
call_user_func($callable, 'BaseDeliverySectionsPeer', $values, $con, $ret);
}
return $ret;
}
/**
* Method to DELETE all rows from the st_delivery_sections table.
*
* @return int The number of affected rows (if supported by underlying database driver).
*/
public static function doDeleteAll($con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->begin();
$affectedRows += BasePeer::doDeleteAll(DeliverySectionsPeer::TABLE_NAME, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
/**
* Method perform a DELETE on the database, given a DeliverySections or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or DeliverySections object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param Connection $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doDelete($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(DeliverySectionsPeer::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; // rename for clarity
} elseif ($values instanceof DeliverySections) {
$criteria = $values->buildPkeyCriteria();
} else {
// it must be the primary key
$criteria = new Criteria(self::DATABASE_NAME);
$criteria->add(DeliverySectionsPeer::ID, (array) $values, Criteria::IN);
}
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->begin();
$affectedRows += BasePeer::doDelete($criteria, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
/**
* Validates all modified columns of given DeliverySections object.
* If parameter $columns is either a single column name or an array of column names
* than only those columns are validated.
*
* NOTICE: This does not apply to primary or foreign keys for now.
*
* @param DeliverySections $obj The object to validate.
* @param mixed $cols Column name or array of column names.
*
* @return mixed TRUE if all columns are valid or the error message of the first invalid column.
*/
public static function doValidate(DeliverySections $obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(DeliverySectionsPeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(DeliverySectionsPeer::TABLE_NAME);
if (! is_array($cols)) {
$cols = array($cols);
}
foreach($cols as $colName) {
if ($tableMap->containsColumn($colName)) {
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
$columns[$colName] = $obj->$get();
}
}
} else {
}
$res = BasePeer::doValidate(DeliverySectionsPeer::DATABASE_NAME, DeliverySectionsPeer::TABLE_NAME, $columns);
if ($res !== true) {
$request = sfContext::getInstance()->getRequest();
foreach ($res as $failed) {
$col = DeliverySectionsPeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
$request->setError($col, $failed->getMessage());
}
}
return $res;
}
/**
* Retrieve a single object by pkey.
*
* @param mixed $pk the primary key.
* @param Connection $con the connection to use
* @return DeliverySections
*/
public static function retrieveByPK($pk, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$criteria = new Criteria(DeliverySectionsPeer::DATABASE_NAME);
$criteria->add(DeliverySectionsPeer::ID, $pk);
$v = DeliverySectionsPeer::doSelect($criteria, $con);
return !empty($v) > 0 ? $v[0] : null;
}
/**
* Retrieve multiple objects by pkey.
*
* @param array $pks List of primary keys
* @param Connection $con the connection to use
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @return DeliverySections[]
*/
public static function retrieveByPKs($pks, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$objs = null;
if (empty($pks)) {
$objs = array();
} else {
$criteria = new Criteria();
$criteria->add(DeliverySectionsPeer::ID, $pks, Criteria::IN);
$objs = DeliverySectionsPeer::doSelect($criteria, $con);
}
return $objs;
}
} // BaseDeliverySectionsPeer
// static code to register the map builder for this Peer with the main Propel class
if (Propel::isInit()) {
// the MapBuilder classes register themselves with Propel during initialization
// so we need to load them here.
try {
BaseDeliverySectionsPeer::getMapBuilder();
} catch (Exception $e) {
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
}
} else {
// even if Propel is not yet initialized, the map builder class can be registered
// now and then it will be loaded when Propel initializes.
Propel::registerMapBuilder('plugins.stDeliveryPlugin.lib.model.map.DeliverySectionsMapBuilder');
}

View File

@@ -0,0 +1,936 @@
<?php
/**
* Base class that represents a row from the 'st_delivery_type' table.
*
*
*
* @package plugins.stDeliveryPlugin.lib.model.om
*/
abstract class BaseDeliveryType extends BaseObject implements Persistent {
protected static $dispatcher = null;
/**
* The value for the id field.
* @var int
*/
protected $id;
/**
* The value for the name field.
* @var string
*/
protected $name;
/**
* The value for the type field.
* @var string
*/
protected $type;
/**
* Collection to store aggregation of collDeliverys.
* @var array
*/
protected $collDeliverys;
/**
* The criteria used to select the current contents of collDeliverys.
* @var Criteria
*/
protected $lastDeliveryCriteria = null;
/**
* Flag to prevent endless save loop, if this object is referenced
* by another object which falls in this transaction.
* @var boolean
*/
protected $alreadyInSave = false;
/**
* Flag to prevent endless validation loop, if this object is referenced
* by another object which falls in this transaction.
* @var boolean
*/
protected $alreadyInValidation = false;
/**
* Get the [id] column value.
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Get the [name] column value.
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Get the [type] column value.
*
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* Set the value of [id] column.
*
* @param int $v new value
* @return void
*/
public function setId($v)
{
if ($v !== null && !is_int($v) && is_numeric($v)) {
$v = (int) $v;
}
if ($this->id !== $v) {
$this->id = $v;
$this->modifiedColumns[] = DeliveryTypePeer::ID;
}
} // setId()
/**
* Set the value of [name] column.
*
* @param string $v new value
* @return void
*/
public function setName($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->name !== $v) {
$this->name = $v;
$this->modifiedColumns[] = DeliveryTypePeer::NAME;
}
} // setName()
/**
* Set the value of [type] column.
*
* @param string $v new value
* @return void
*/
public function setType($v)
{
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->type !== $v) {
$this->type = $v;
$this->modifiedColumns[] = DeliveryTypePeer::TYPE;
}
} // setType()
/**
* Hydrates (populates) the object variables with values from the database resultset.
*
* An offset (1-based "start column") is specified so that objects can be hydrated
* with a subset of the columns in the resultset rows. This is needed, for example,
* for results of JOIN queries where the resultset row includes columns from two or
* more tables.
*
* @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos.
* @param int $startcol 1-based offset column which indicates which restultset column to start with.
* @return int next starting column
* @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
*/
public function hydrate(ResultSet $rs, $startcol = 1)
{
try {
if ($this->getDispatcher()->getListeners('DeliveryType.preHydrate')) {
$event = $this->getDispatcher()->notify(new sfEvent($this, 'DeliveryType.preHydrate', array('resultset' => $rs, 'startcol' => $startcol)));
$startcol = $event['startcol'];
}
$this->id = $rs->getInt($startcol + 0);
$this->name = $rs->getString($startcol + 1);
$this->type = $rs->getString($startcol + 2);
$this->resetModified();
$this->setNew(false);
if ($this->getDispatcher()->getListeners('DeliveryType.postHydrate')) {
$event = $this->getDispatcher()->notify(new sfEvent($this, 'DeliveryType.postHydrate', array('resultset' => $rs, 'startcol' => $startcol + 3)));
return $event['startcol'];
}
// FIXME - using NUM_COLUMNS may be clearer.
return $startcol + 3; // 3 = DeliveryTypePeer::NUM_COLUMNS - DeliveryTypePeer::NUM_LAZY_LOAD_COLUMNS).
} catch (Exception $e) {
throw new PropelException("Error populating DeliveryType object", $e);
}
}
/**
* Removes this object from datastore and sets delete attribute.
*
* @param Connection $con
* @return void
* @throws PropelException
* @see BaseObject::setDeleted()
* @see BaseObject::isDeleted()
*/
public function delete($con = null)
{
if ($this->isDeleted()) {
throw new PropelException("This object has already been deleted.");
}
if ($this->getDispatcher()->getListeners('DeliveryType.preDelete')) {
$this->getDispatcher()->notify(new sfEvent($this, 'DeliveryType.preDelete', array('con' => $con)));
}
if (sfMixer::hasCallables('BaseDeliveryType:delete:pre'))
{
foreach (sfMixer::getCallables('BaseDeliveryType:delete:pre') as $callable)
{
$ret = call_user_func($callable, $this, $con);
if ($ret)
{
return;
}
}
}
if ($con === null) {
$con = Propel::getConnection(DeliveryTypePeer::DATABASE_NAME);
}
try {
$con->begin();
DeliveryTypePeer::doDelete($this, $con);
$this->setDeleted(true);
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
if ($this->getDispatcher()->getListeners('DeliveryType.postDelete')) {
$this->getDispatcher()->notify(new sfEvent($this, 'DeliveryType.postDelete', array('con' => $con)));
}
if (sfMixer::hasCallables('BaseDeliveryType:delete:post'))
{
foreach (sfMixer::getCallables('BaseDeliveryType:delete:post') as $callable)
{
call_user_func($callable, $this, $con);
}
}
}
/**
* Stores the object in the database. If the object is new,
* it inserts it; otherwise an update is performed. This method
* wraps the doSave() worker method in a transaction.
*
* @param Connection $con
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
* @throws PropelException
* @see doSave()
*/
public function save($con = null)
{
if ($this->isDeleted()) {
throw new PropelException("You cannot save an object that has been deleted.");
}
if (!$this->alreadyInSave) {
if ($this->getDispatcher()->getListeners('DeliveryType.preSave')) {
$this->getDispatcher()->notify(new sfEvent($this, 'DeliveryType.preSave', array('con' => $con)));
}
foreach (sfMixer::getCallables('BaseDeliveryType:save:pre') as $callable)
{
$affectedRows = call_user_func($callable, $this, $con);
if (is_int($affectedRows))
{
return $affectedRows;
}
}
}
if ($con === null) {
$con = Propel::getConnection(DeliveryTypePeer::DATABASE_NAME);
}
try {
$con->begin();
$affectedRows = $this->doSave($con);
$con->commit();
if (!$this->alreadyInSave) {
if ($this->getDispatcher()->getListeners('DeliveryType.postSave')) {
$this->getDispatcher()->notify(new sfEvent($this, 'DeliveryType.postSave', array('con' => $con)));
}
foreach (sfMixer::getCallables('BaseDeliveryType:save:post') as $callable)
{
call_user_func($callable, $this, $con, $affectedRows);
}
}
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
/**
* Stores the object in the database.
*
* If the object is new, it inserts it; otherwise an update is performed.
* All related objects are also updated in this method.
*
* @param Connection $con
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
* @throws PropelException
* @see save()
*/
protected function doSave($con)
{
$affectedRows = 0; // initialize var to track total num of affected rows
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
// If this object has been modified, then save it to the database.
if ($this->isModified()) {
if ($this->isNew()) {
$pk = DeliveryTypePeer::doInsert($this, $con);
$affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which
// should always be true here (even though technically
// BasePeer::doInsert() can insert multiple rows).
$this->setId($pk); //[IMV] update autoincrement primary key
$this->setNew(false);
} else {
$affectedRows += DeliveryTypePeer::doUpdate($this, $con);
}
$this->resetModified(); // [HL] After being saved an object is no longer 'modified'
}
if ($this->collDeliverys !== null) {
foreach($this->collDeliverys as $referrerFK) {
if (!$referrerFK->isDeleted()) {
$affectedRows += $referrerFK->save($con);
}
}
}
$this->alreadyInSave = false;
}
return $affectedRows;
} // doSave()
/**
* Array of ValidationFailed objects.
* @var array ValidationFailed[]
*/
protected $validationFailures = array();
/**
* Gets any ValidationFailed objects that resulted from last call to validate().
*
*
* @return array ValidationFailed[]
* @see validate()
*/
public function getValidationFailures()
{
return $this->validationFailures;
}
/**
* Validates the objects modified field values and all objects related to this table.
*
* If $columns is either a column name or an array of column names
* only those columns are validated.
*
* @param mixed $columns Column name or an array of column names.
* @return boolean Whether all columns pass validation.
* @see doValidate()
* @see getValidationFailures()
*/
public function validate($columns = null)
{
$res = $this->doValidate($columns);
if ($res === true) {
$this->validationFailures = array();
return true;
} else {
$this->validationFailures = $res;
return false;
}
}
/**
* This function performs the validation work for complex object models.
*
* In addition to checking the current object, all related objects will
* also be validated. If all pass then <code>true</code> is returned; otherwise
* an aggreagated array of ValidationFailed objects will be returned.
*
* @param array $columns Array of column names to validate.
* @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
*/
protected function doValidate($columns = null)
{
if (!$this->alreadyInValidation) {
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
if (($retval = DeliveryTypePeer::doValidate($this, $columns)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
if ($this->collDeliverys !== null) {
foreach($this->collDeliverys as $referrerFK) {
if (!$referrerFK->validate($columns)) {
$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
}
}
}
$this->alreadyInValidation = false;
}
return (!empty($failureMap) ? $failureMap : true);
}
/**
* Retrieves a field from the object by name passed in as a string.
*
* @param string $name name
* @param string $type The type of fieldname the $name is of:
* one of the class type constants TYPE_PHPNAME,
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
* @return mixed Value of field.
*/
public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
{
$pos = DeliveryTypePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->getByPosition($pos);
}
/**
* Retrieves a field from the object by Position as specified in the xml schema.
* Zero-based.
*
* @param int $pos position in xml schema
* @return mixed Value of field at $pos
*/
public function getByPosition($pos)
{
switch($pos) {
case 0:
return $this->getId();
break;
case 1:
return $this->getName();
break;
case 2:
return $this->getType();
break;
default:
return null;
break;
} // switch()
}
/**
* Exports the object as an array.
*
* You can specify the key type of the array by passing one of the class
* type constants.
*
* @param string $keyType One of the class type constants TYPE_PHPNAME,
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
* @return an associative array containing the field names (as keys) and field values
*/
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
{
$keys = DeliveryTypePeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getId(),
$keys[1] => $this->getName(),
$keys[2] => $this->getType(),
);
return $result;
}
/**
* Sets a field from the object by name passed in as a string.
*
* @param string $name peer name
* @param mixed $value field value
* @param string $type The type of fieldname the $name is of:
* one of the class type constants TYPE_PHPNAME,
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
* @return void
*/
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
{
$pos = DeliveryTypePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
return $this->setByPosition($pos, $value);
}
/**
* Sets a field from the object by Position as specified in the xml schema.
* Zero-based.
*
* @param int $pos position in xml schema
* @param mixed $value field value
* @return void
*/
public function setByPosition($pos, $value)
{
switch($pos) {
case 0:
$this->setId($value);
break;
case 1:
$this->setName($value);
break;
case 2:
$this->setType($value);
break;
} // switch()
}
/**
* Populates the object using an array.
*
* This is particularly useful when populating an object from one of the
* request arrays (e.g. $_POST). This method goes through the column
* names, checking to see whether a matching key exists in populated
* array. If so the setByName() method is called for that column.
*
* You can specify the key type of the array by additionally passing one
* of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
* TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId')
*
* @param array $arr An array to populate the object from.
* @param string $keyType The type of keys the array uses.
* @return void
*/
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
{
$keys = DeliveryTypePeer::getFieldNames($keyType);
if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
if (array_key_exists($keys[1], $arr)) $this->setName($arr[$keys[1]]);
if (array_key_exists($keys[2], $arr)) $this->setType($arr[$keys[2]]);
}
/**
* Build a Criteria object containing the values of all modified columns in this object.
*
* @return Criteria The Criteria object containing all modified values.
*/
public function buildCriteria()
{
$criteria = new Criteria(DeliveryTypePeer::DATABASE_NAME);
if ($this->isColumnModified(DeliveryTypePeer::ID)) $criteria->add(DeliveryTypePeer::ID, $this->id);
if ($this->isColumnModified(DeliveryTypePeer::NAME)) $criteria->add(DeliveryTypePeer::NAME, $this->name);
if ($this->isColumnModified(DeliveryTypePeer::TYPE)) $criteria->add(DeliveryTypePeer::TYPE, $this->type);
return $criteria;
}
/**
* Builds a Criteria object containing the primary key for this object.
*
* Unlike buildCriteria() this method includes the primary key values regardless
* of whether or not they have been modified.
*
* @return Criteria The Criteria object containing value(s) for primary key(s).
*/
public function buildPkeyCriteria()
{
$criteria = new Criteria(DeliveryTypePeer::DATABASE_NAME);
$criteria->add(DeliveryTypePeer::ID, $this->id);
return $criteria;
}
/**
* Returns the primary key for this object (row).
* @return int
*/
public function getPrimaryKey()
{
return $this->getId();
}
/**
* Returns [composite] primary key fields
*
* @param string $keyType
* @return array
*/
public function getPrimaryKeyFields($keyType = BasePeer::TYPE_FIELDNAME)
{
return array(DeliveryTypePeer::translateFieldName('id', BasePeer::TYPE_FIELDNAME, $keyType));
}
/**
* Generic method to set the primary key (id column).
*
* @param int $key Primary key.
* @return void
*/
public function setPrimaryKey($key)
{
$this->setId($key);
}
/**
* Sets contents of passed object to values from current object.
*
* If desired, this method can also make copies of all associated (fkey referrers)
* objects.
*
* @param object $copyObj An object of DeliveryType (or compatible) type.
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
* @throws PropelException
*/
public function copyInto($copyObj, $deepCopy = false)
{
$copyObj->setName($this->name);
$copyObj->setType($this->type);
if ($deepCopy) {
// important: temporarily setNew(false) because this affects the behavior of
// the getter/setter methods for fkey referrer objects.
$copyObj->setNew(false);
foreach($this->getDeliverys() as $relObj) {
$copyObj->addDelivery($relObj->copy($deepCopy));
}
} // if ($deepCopy)
$copyObj->setNew(true);
$copyObj->setId(NULL); // this is a pkey column, so set to default value
}
/**
* Makes a copy of this object that will be inserted as a new row in table when saved.
* It creates a new object filling in the simple attributes, but skipping any primary
* keys that are defined for the table.
*
* If desired, this method can also make copies of all associated (fkey referrers)
* objects.
*
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
* @return DeliveryType Clone of current object.
* @throws PropelException
*/
public function copy($deepCopy = false)
{
// we use get_class(), because this might be a subclass
$clazz = get_class($this);
$copyObj = new $clazz();
$this->copyInto($copyObj, $deepCopy);
return $copyObj;
}
/**
* Returns a peer instance associated with this om.
*
* @return string Peer class name
*/
public function getPeer()
{
return 'DeliveryTypePeer';
}
/**
* Temporary storage of collDeliverys to save a possible db hit in
* the event objects are add to the collection, but the
* complete collection is never requested.
* @return void
*/
public function initDeliverys()
{
if ($this->collDeliverys === null) {
$this->collDeliverys = array();
}
}
/**
* If this collection has already been initialized with
* an identical criteria, it returns the collection.
* Otherwise if this DeliveryType has previously
* been saved, it will retrieve related Deliverys from storage.
* If this DeliveryType is new, it will return
* an empty collection or the current collection, the criteria
* is ignored on a new object.
*
* @param Connection $con
* @param Criteria $criteria
* @return Delivery[]
* @throws PropelException
*/
public function getDeliverys($criteria = null, $con = null)
{
// include the Peer class
if ($criteria === null) {
$criteria = new Criteria();
}
elseif ($criteria instanceof Criteria)
{
$criteria = clone $criteria;
}
if ($this->collDeliverys === null) {
if ($this->isNew()) {
$this->collDeliverys = array();
} else {
$criteria->add(DeliveryPeer::TYPE_ID, $this->getId());
DeliveryPeer::addSelectColumns($criteria);
$this->collDeliverys = DeliveryPeer::doSelect($criteria, $con);
}
} else {
// criteria has no effect for a new object
if (!$this->isNew()) {
// the following code is to determine if a new query is
// called for. If the criteria is the same as the last
// one, just return the collection.
$criteria->add(DeliveryPeer::TYPE_ID, $this->getId());
DeliveryPeer::addSelectColumns($criteria);
if (!isset($this->lastDeliveryCriteria) || !$this->lastDeliveryCriteria->equals($criteria)) {
$this->collDeliverys = DeliveryPeer::doSelect($criteria, $con);
}
}
}
$this->lastDeliveryCriteria = $criteria;
return $this->collDeliverys;
}
/**
* Returns the number of related Deliverys.
*
* @param Criteria $criteria
* @param boolean $distinct
* @param Connection $con
* @throws PropelException
*/
public function countDeliverys($criteria = null, $distinct = false, $con = null)
{
// include the Peer class
if ($criteria === null) {
$criteria = new Criteria();
}
elseif ($criteria instanceof Criteria)
{
$criteria = clone $criteria;
}
$criteria->add(DeliveryPeer::TYPE_ID, $this->getId());
return DeliveryPeer::doCount($criteria, $distinct, $con);
}
/**
* Method called to associate a Delivery object to this object
* through the Delivery foreign key attribute
*
* @param Delivery $l Delivery
* @return void
* @throws PropelException
*/
public function addDelivery(Delivery $l)
{
$this->collDeliverys[] = $l;
$l->setDeliveryType($this);
}
/**
* If this collection has already been initialized with
* an identical criteria, it returns the collection.
* Otherwise if this DeliveryType is new, it will return
* an empty collection; or if this DeliveryType has previously
* been saved, it will retrieve related Deliverys from storage.
*
* This method is protected by default in order to keep the public
* api reasonable. You can provide public methods for those you
* actually need in DeliveryType.
*
* @return Delivery[]
*/
public function getDeliverysJoinCountriesArea($criteria = null, $con = null)
{
// include the Peer class
if ($criteria === null) {
$criteria = new Criteria();
}
elseif ($criteria instanceof Criteria)
{
$criteria = clone $criteria;
}
if ($this->collDeliverys === null) {
if ($this->isNew()) {
$this->collDeliverys = array();
} else {
$criteria->add(DeliveryPeer::TYPE_ID, $this->getId());
$this->collDeliverys = DeliveryPeer::doSelectJoinCountriesArea($criteria, $con);
}
} else {
// the following code is to determine if a new query is
// called for. If the criteria is the same as the last
// one, just return the collection.
$criteria->add(DeliveryPeer::TYPE_ID, $this->getId());
if (!isset($this->lastDeliveryCriteria) || !$this->lastDeliveryCriteria->equals($criteria)) {
$this->collDeliverys = DeliveryPeer::doSelectJoinCountriesArea($criteria, $con);
}
}
$this->lastDeliveryCriteria = $criteria;
return $this->collDeliverys;
}
/**
* If this collection has already been initialized with
* an identical criteria, it returns the collection.
* Otherwise if this DeliveryType is new, it will return
* an empty collection; or if this DeliveryType has previously
* been saved, it will retrieve related Deliverys from storage.
*
* This method is protected by default in order to keep the public
* api reasonable. You can provide public methods for those you
* actually need in DeliveryType.
*
* @return Delivery[]
*/
public function getDeliverysJoinTax($criteria = null, $con = null)
{
// include the Peer class
if ($criteria === null) {
$criteria = new Criteria();
}
elseif ($criteria instanceof Criteria)
{
$criteria = clone $criteria;
}
if ($this->collDeliverys === null) {
if ($this->isNew()) {
$this->collDeliverys = array();
} else {
$criteria->add(DeliveryPeer::TYPE_ID, $this->getId());
$this->collDeliverys = DeliveryPeer::doSelectJoinTax($criteria, $con);
}
} else {
// the following code is to determine if a new query is
// called for. If the criteria is the same as the last
// one, just return the collection.
$criteria->add(DeliveryPeer::TYPE_ID, $this->getId());
if (!isset($this->lastDeliveryCriteria) || !$this->lastDeliveryCriteria->equals($criteria)) {
$this->collDeliverys = DeliveryPeer::doSelectJoinTax($criteria, $con);
}
}
$this->lastDeliveryCriteria = $criteria;
return $this->collDeliverys;
}
public function getDispatcher()
{
if (null === self::$dispatcher)
{
self::$dispatcher = stEventDispatcher::getInstance();
}
return self::$dispatcher;
}
public function __call($method, $arguments)
{
$event = $this->getDispatcher()->notifyUntil(new sfEvent($this, 'DeliveryType.' . $method, array('arguments' => $arguments, 'method' => $method)));
if ($event->isProcessed())
{
return $event->getReturnValue();
}
if (!$callable = sfMixer::getCallable('BaseDeliveryType:'.$method))
{
throw new sfException(sprintf('Call to undefined method BaseDeliveryType::%s', $method));
}
array_unshift($arguments, $this);
return call_user_func_array($callable, $arguments);
}
} // BaseDeliveryType

View File

@@ -0,0 +1,681 @@
<?php
/**
* Base static class for performing query and update operations on the 'st_delivery_type' table.
*
*
*
* @package plugins.stDeliveryPlugin.lib.model.om
*/
abstract class BaseDeliveryTypePeer {
/** the default database name for this class */
const DATABASE_NAME = 'propel';
/** the table name for this class */
const TABLE_NAME = 'st_delivery_type';
/** A class that can be returned by this peer. */
const CLASS_DEFAULT = 'plugins.stDeliveryPlugin.lib.model.DeliveryType';
/** The total number of columns. */
const NUM_COLUMNS = 3;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
/** the column name for the ID field */
const ID = 'st_delivery_type.ID';
/** the column name for the NAME field */
const NAME = 'st_delivery_type.NAME';
/** the column name for the TYPE field */
const TYPE = 'st_delivery_type.TYPE';
/** The PHP to DB Name Mapping */
private static $phpNameMap = null;
/**
* holds an array of fieldnames
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('Id', 'Name', 'Type', ),
BasePeer::TYPE_COLNAME => array (DeliveryTypePeer::ID, DeliveryTypePeer::NAME, DeliveryTypePeer::TYPE, ),
BasePeer::TYPE_FIELDNAME => array ('id', 'name', 'type', ),
BasePeer::TYPE_NUM => array (0, 1, 2, )
);
/**
* holds an array of keys for quick access to the fieldnames array
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
*/
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Name' => 1, 'Type' => 2, ),
BasePeer::TYPE_COLNAME => array (DeliveryTypePeer::ID => 0, DeliveryTypePeer::NAME => 1, DeliveryTypePeer::TYPE => 2, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'name' => 1, 'type' => 2, ),
BasePeer::TYPE_NUM => array (0, 1, 2, )
);
protected static $hydrateMethod = null;
protected static $postHydrateMethod = null;
public static function setHydrateMethod($callback)
{
self::$hydrateMethod = $callback;
}
public static function setPostHydrateMethod($callback)
{
self::$postHydrateMethod = $callback;
}
/**
* @return MapBuilder the map builder for this peer
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function getMapBuilder()
{
return BasePeer::getMapBuilder('plugins.stDeliveryPlugin.lib.model.map.DeliveryTypeMapBuilder');
}
/**
* Gets a map (hash) of PHP names to DB column names.
*
* @return array The PHP to DB name map for this peer
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @deprecated Use the getFieldNames() and translateFieldName() methods instead of this.
*/
public static function getPhpNameMap()
{
if (self::$phpNameMap === null) {
$map = DeliveryTypePeer::getTableMap();
$columns = $map->getColumns();
$nameMap = array();
foreach ($columns as $column) {
$nameMap[$column->getPhpName()] = $column->getColumnName();
}
self::$phpNameMap = $nameMap;
}
return self::$phpNameMap;
}
/**
* Translates a fieldname to another type
*
* @param string $name field name
* @param string $fromType One of the class type constants TYPE_PHPNAME,
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
* @param string $toType One of the class type constants
* @return string translated name of the field.
*/
static public function translateFieldName($name, $fromType, $toType)
{
$toNames = self::getFieldNames($toType);
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
if ($key === null) {
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
}
return $toNames[$key];
}
/**
* Returns an array of of field names.
*
* @param string $type The type of fieldnames to return:
* One of the class type constants TYPE_PHPNAME,
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
* @return array A list of field names
*/
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
{
if (!array_key_exists($type, self::$fieldNames)) {
throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
}
return self::$fieldNames[$type];
}
/**
* Convenience method which changes table.column to alias.column.
*
* Using this method you can maintain SQL abstraction while using column aliases.
* <code>
* $c->addAlias("alias1", TablePeer::TABLE_NAME);
* $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
* </code>
* @param string $alias The alias for the current table.
* @param string $column The column name for current table. (i.e. DeliveryTypePeer::COLUMN_NAME).
* @return string
*/
public static function alias($alias, $column)
{
return str_replace(DeliveryTypePeer::TABLE_NAME.'.', $alias.'.', $column);
}
/**
* Add all the columns needed to create a new object.
*
* Note: any columns that were marked with lazyLoad="true" in the
* XML schema will not be added to the select list and only loaded
* on demand.
*
* @param criteria object containing the columns to add.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function addSelectColumns(Criteria $criteria)
{
$criteria->addSelectColumn(DeliveryTypePeer::ID);
$criteria->addSelectColumn(DeliveryTypePeer::NAME);
$criteria->addSelectColumn(DeliveryTypePeer::TYPE);
if (stEventDispatcher::getInstance()->getListeners('DeliveryTypePeer.postAddSelectColumns')) {
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'DeliveryTypePeer.postAddSelectColumns'));
}
}
const COUNT = 'COUNT(st_delivery_type.ID)';
const COUNT_DISTINCT = 'COUNT(DISTINCT st_delivery_type.ID)';
/**
* Returns the number of rows matching criteria.
*
* @param Criteria $criteria
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
* @param Connection $con
* @return int Number of matching rows.
*/
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
{
// we're going to modify criteria, so copy it first
$criteria = clone $criteria;
// clear out anything that might confuse the ORDER BY clause
$criteria->clearSelectColumns()->clearOrderByColumns();
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
$criteria->addSelectColumn(DeliveryTypePeer::COUNT_DISTINCT);
} else {
$criteria->addSelectColumn(DeliveryTypePeer::COUNT);
}
// just in case we're grouping: add those columns to the select statement
foreach($criteria->getGroupByColumns() as $column)
{
$criteria->addSelectColumn($column);
}
$rs = DeliveryTypePeer::doSelectRS($criteria, $con);
if ($rs->next()) {
return $rs->getInt(1);
} else {
// no rows returned; we infer that means 0 matches.
return 0;
}
}
/**
* Method to select one object from the DB.
*
* @param Criteria $criteria object used to create the SELECT statement.
* @param Connection $con
* @return DeliveryType
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelectOne(Criteria $criteria, $con = null)
{
$critcopy = clone $criteria;
$critcopy->setLimit(1);
$objects = DeliveryTypePeer::doSelect($critcopy, $con);
if ($objects) {
return $objects[0];
}
return null;
}
/**
* Method to do selects.
*
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
* @param Connection $con
* @return DeliveryType[]
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doSelect(Criteria $criteria, $con = null)
{
return DeliveryTypePeer::populateObjects(DeliveryTypePeer::doSelectRS($criteria, $con));
}
/**
* Prepares the Criteria object and uses the parent doSelect()
* method to get a ResultSet.
*
* Use this method directly if you want to just get the resultset
* (instead of an array of objects).
*
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
* @param Connection $con the connection to use
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @return ResultSet The resultset object with numerically-indexed fields.
* @see BasePeer::doSelect()
*/
public static function doSelectRS(Criteria $criteria, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if (!$criteria->getSelectColumns()) {
$criteria = clone $criteria;
DeliveryTypePeer::addSelectColumns($criteria);
}
if (stEventDispatcher::getInstance()->getListeners('BasePeer.preDoSelectRs')) {
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'BasePeer.preDoSelectRs'));
}
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
// BasePeer returns a Creole ResultSet, set to return
// rows indexed numerically.
$rs = BasePeer::doSelect($criteria, $con);
if (stEventDispatcher::getInstance()->getListeners('BasePeer.postDoSelectRs')) {
stEventDispatcher::getInstance()->notify(new sfEvent($rs, 'BasePeer.postDoSelectRs'));
}
return $rs;
}
/**
* The returned array will contain objects of the default type or
* objects that inherit from the default.
*
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function populateObjects(ResultSet $rs)
{
if (self::$hydrateMethod)
{
return call_user_func(self::$hydrateMethod, $rs);
}
$results = array();
// set the class once to avoid overhead in the loop
$cls = DeliveryTypePeer::getOMClass();
$cls = Propel::import($cls);
// populate the object(s)
while($rs->next()) {
$obj = new $cls();
$obj->hydrate($rs);
$results[] = self::$postHydrateMethod ? call_user_func(self::$postHydrateMethod, $obj) : $obj;
}
return $results;
}
/**
* Returns the TableMap related to this peer.
* This method is not needed for general use but a specific application could have a need.
* @return TableMap
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function getTableMap()
{
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
}
/**
* The class that the Peer will make instances of.
*
* This uses a dot-path notation which is tranalted into a path
* relative to a location on the PHP include_path.
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
*
* @return string path.to.ClassName
*/
public static function getOMClass()
{
return DeliveryTypePeer::CLASS_DEFAULT;
}
/**
* Method perform an INSERT on the database, given a DeliveryType or Criteria object.
*
* @param mixed $values Criteria or DeliveryType object containing data that is used to create the INSERT statement.
* @param Connection $con the connection to use
* @return mixed The new primary key.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doInsert($values, $con = null)
{
foreach (sfMixer::getCallables('BaseDeliveryTypePeer:doInsert:pre') as $callable)
{
$ret = call_user_func($callable, 'BaseDeliveryTypePeer', $values, $con);
if (false !== $ret)
{
return $ret;
}
}
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; // rename for clarity
} else {
$criteria = $values->buildCriteria(); // build Criteria from DeliveryType object
}
$criteria->remove(DeliveryTypePeer::ID); // remove pkey col since this table uses auto-increment
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
try {
// use transaction because $criteria could contain info
// for more than one table (I guess, conceivably)
$con->begin();
$pk = BasePeer::doInsert($criteria, $con);
$con->commit();
} catch(PropelException $e) {
$con->rollback();
throw $e;
}
foreach (sfMixer::getCallables('BaseDeliveryTypePeer:doInsert:post') as $callable)
{
call_user_func($callable, 'BaseDeliveryTypePeer', $values, $con, $pk);
}
return $pk;
}
/**
* Method perform an UPDATE on the database, given a DeliveryType or Criteria object.
*
* @param mixed $values Criteria or DeliveryType object containing data that is used to create the UPDATE statement.
* @param Connection $con The connection to use (specify Connection object to exert more control over transactions).
* @return int The number of affected rows (if supported by underlying database driver).
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doUpdate($values, $con = null)
{
foreach (sfMixer::getCallables('BaseDeliveryTypePeer:doUpdate:pre') as $callable)
{
$ret = call_user_func($callable, 'BaseDeliveryTypePeer', $values, $con);
if (false !== $ret)
{
return $ret;
}
}
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$selectCriteria = new Criteria(self::DATABASE_NAME);
if ($values instanceof Criteria) {
$criteria = clone $values; // rename for clarity
$comparison = $criteria->getComparison(DeliveryTypePeer::ID);
$selectCriteria->add(DeliveryTypePeer::ID, $criteria->remove(DeliveryTypePeer::ID), $comparison);
} else { // $values is DeliveryType object
$criteria = $values->buildCriteria(); // gets full criteria
$selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
}
// set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
$ret = BasePeer::doUpdate($selectCriteria, $criteria, $con);
foreach (sfMixer::getCallables('BaseDeliveryTypePeer:doUpdate:post') as $callable)
{
call_user_func($callable, 'BaseDeliveryTypePeer', $values, $con, $ret);
}
return $ret;
}
/**
* Method to DELETE all rows from the st_delivery_type table.
*
* @return int The number of affected rows (if supported by underlying database driver).
*/
public static function doDeleteAll($con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->begin();
DeliveryTypePeer::doOnDeleteSetNull(new Criteria(), $con);
$affectedRows += BasePeer::doDeleteAll(DeliveryTypePeer::TABLE_NAME, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
/**
* Method perform a DELETE on the database, given a DeliveryType or Criteria object OR a primary key value.
*
* @param mixed $values Criteria or DeliveryType object or primary key or array of primary keys
* which is used to create the DELETE statement
* @param Connection $con the connection to use
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
* if supported by native driver or if emulated using Propel.
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
public static function doDelete($values, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(DeliveryTypePeer::DATABASE_NAME);
}
if ($values instanceof Criteria) {
$criteria = clone $values; // rename for clarity
} elseif ($values instanceof DeliveryType) {
$criteria = $values->buildPkeyCriteria();
} else {
// it must be the primary key
$criteria = new Criteria(self::DATABASE_NAME);
$criteria->add(DeliveryTypePeer::ID, (array) $values, Criteria::IN);
}
// Set the correct dbName
$criteria->setDbName(self::DATABASE_NAME);
$affectedRows = 0; // initialize var to track total num of affected rows
try {
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$con->begin();
DeliveryTypePeer::doOnDeleteSetNull($criteria, $con);
$affectedRows += BasePeer::doDelete($criteria, $con);
$con->commit();
return $affectedRows;
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
}
/**
* This is a method for emulating ON DELETE SET NULL DBs that don't support this
* feature (like MySQL or SQLite).
*
* This method is not very speedy because it must perform a query first to get
* the implicated records and then perform the deletes by calling those Peer classes.
*
* This method should be used within a transaction if possible.
*
* @param Criteria $criteria
* @param Connection $con
* @return void
*/
protected static function doOnDeleteSetNull(Criteria $criteria, Connection $con)
{
// first find the objects that are implicated by the $criteria
$objects = DeliveryTypePeer::doSelect($criteria, $con);
foreach($objects as $obj) {
// set fkey col in related Delivery rows to NULL
$selectCriteria = new Criteria(DeliveryTypePeer::DATABASE_NAME);
$updateValues = new Criteria(DeliveryTypePeer::DATABASE_NAME);
$selectCriteria->add(DeliveryPeer::TYPE_ID, $obj->getId());
$updateValues->add(DeliveryPeer::TYPE_ID, null);
BasePeer::doUpdate($selectCriteria, $updateValues, $con); // use BasePeer because generated Peer doUpdate() methods only update using pkey
}
}
/**
* Validates all modified columns of given DeliveryType object.
* If parameter $columns is either a single column name or an array of column names
* than only those columns are validated.
*
* NOTICE: This does not apply to primary or foreign keys for now.
*
* @param DeliveryType $obj The object to validate.
* @param mixed $cols Column name or array of column names.
*
* @return mixed TRUE if all columns are valid or the error message of the first invalid column.
*/
public static function doValidate(DeliveryType $obj, $cols = null)
{
$columns = array();
if ($cols) {
$dbMap = Propel::getDatabaseMap(DeliveryTypePeer::DATABASE_NAME);
$tableMap = $dbMap->getTable(DeliveryTypePeer::TABLE_NAME);
if (! is_array($cols)) {
$cols = array($cols);
}
foreach($cols as $colName) {
if ($tableMap->containsColumn($colName)) {
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
$columns[$colName] = $obj->$get();
}
}
} else {
}
$res = BasePeer::doValidate(DeliveryTypePeer::DATABASE_NAME, DeliveryTypePeer::TABLE_NAME, $columns);
if ($res !== true) {
$request = sfContext::getInstance()->getRequest();
foreach ($res as $failed) {
$col = DeliveryTypePeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
$request->setError($col, $failed->getMessage());
}
}
return $res;
}
/**
* Retrieve a single object by pkey.
*
* @param mixed $pk the primary key.
* @param Connection $con the connection to use
* @return DeliveryType
*/
public static function retrieveByPK($pk, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$criteria = new Criteria(DeliveryTypePeer::DATABASE_NAME);
$criteria->add(DeliveryTypePeer::ID, $pk);
$v = DeliveryTypePeer::doSelect($criteria, $con);
return !empty($v) > 0 ? $v[0] : null;
}
/**
* Retrieve multiple objects by pkey.
*
* @param array $pks List of primary keys
* @param Connection $con the connection to use
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @return DeliveryType[]
*/
public static function retrieveByPKs($pks, $con = null)
{
if ($con === null) {
$con = Propel::getConnection(self::DATABASE_NAME);
}
$objs = null;
if (empty($pks)) {
$objs = array();
} else {
$criteria = new Criteria();
$criteria->add(DeliveryTypePeer::ID, $pks, Criteria::IN);
$objs = DeliveryTypePeer::doSelect($criteria, $con);
}
return $objs;
}
} // BaseDeliveryTypePeer
// static code to register the map builder for this Peer with the main Propel class
if (Propel::isInit()) {
// the MapBuilder classes register themselves with Propel during initialization
// so we need to load them here.
try {
BaseDeliveryTypePeer::getMapBuilder();
} catch (Exception $e) {
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
}
} else {
// even if Propel is not yet initialized, the map builder class can be registered
// now and then it will be loaded when Propel initializes.
Propel::registerMapBuilder('plugins.stDeliveryPlugin.lib.model.map.DeliveryTypeMapBuilder');
}

View File

@@ -0,0 +1,34 @@
<?php
class stDeliveryBasketProductInfo extends stDeliveryProductInfoAbstract
{
/**
* Koszyk
* @var stBasket
*/
protected $basket;
public function __construct(stBasket $basket, stCurrencyModelInterface $currency)
{
$this->basket = $basket;
parent::__construct($currency);
}
protected function initialize(): void
{
foreach ($this->basket->getItems() as $item)
{
$this->addAmountWithCurrency($item->getTotalAmount(true, true));
$this->addWeight($item->getTotalWeight());
$this->addQuantity($item->getQuantity());
$this->addDimensions($item->getWidth(), $item->getHeight(), $item->getDepth(), $item->getQuantity());
$this->addDeliveryPrice($item->getTotalDeliveryPrice());
$this->addMaxTax($item->getProduct()->getTax());
if (!empty($item->getProduct()->getDeliveries()))
{
$this->addAllowedDeliveries($item->getProduct()->getDeliveries());
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,18 @@
<?php
class stDeliveryListener
{
public static function generateDeliveryType(sfEvent $event)
{
/**
* @var stAdminGenerator
*/
$generator = $event->getSubject();
$generator->setValueForParameter('edit.forward_parameters', array('order_id', 'type'));
$generator->setValueForParameter('edit.build_options', array(
'related_id' => 'forward_parameters.order_id',
'related_class' => 'Order',
));
// throw new Exception($generator->getModuleName());
}
}

View File

@@ -0,0 +1,34 @@
<?php
class stDeliveryOrderProductInfo extends stDeliveryProductInfoAbstract
{
/**
* Zamówienie
* @var Order
*/
protected $order;
public function __construct(Order $order, stCurrencyModelInterface $currency)
{
$this->order = $order;
parent::__construct($currency);
}
protected function initialize(): void
{
foreach ($this->order->getOrderProductsJoinProduct() as $orderProduct)
{
$this->addAmountWithCurrency($orderProduct->getTotalAmount(true, true));
$this->addWeight($orderProduct->getTotalWeight());
$this->addQuantity($orderProduct->getQuantity());
$this->addDimensions($orderProduct->getWidth(), $orderProduct->getHeight(), $orderProduct->getDepth(), $orderProduct->getQuantity());
$this->addDeliveryPrice($orderProduct->getTotalDeliveryPrice());
$this->addMaxTax($orderProduct->getTax());
if (!empty($orderProduct->getProduct()->getDeliveries()))
{
$this->addAllowedDeliveries($orderProduct->getProduct()->getDeliveries());
}
}
}
}

View File

@@ -0,0 +1,326 @@
<?php
abstract class stDeliveryProductInfoAbstract
{
/**
* Waluta
* @var stCurrencyModelInterface
*/
protected $currency;
/**
*
* @var stConfig
*/
protected $config;
private $initialized = false;
/**
* Łączna kwota produktów w danej walucie
* @var float|string
*/
private $totalAmountWithCurrency = 0;
/**
* Łączba waga produktów
* @var float|string
*/
private $totalWeight = 0;
/**
* Łączna ilość produktów
* @var int
*/
private $totalQuantity = 0;
/**
* Maksymalna szerokość produktów
* @var float|string
*/
private $maxWidth = 0;
/**
* Maksymalna wysokość produktów
* @var float|string
*/
private $maxHeight = 0;
/**
* Maksymalna głębokość produktów
* @var float|string
*/
private $maxDepth = 0;
/**
* Maksymalna wysokość podatku VAT w koszyku
* @var Tax|null
*/
private $maxTax = null;
/**
* Łączna objętość produktów
* @var float|string
*/
private $totalVolume = 0;
/**
* Łączna dodatkowa cena za dostawę
* @var float|string
*/
private $totalDeliveryPrice = 0;
/**
* Domyślne dozwolone dostawy
* @var mixed
*/
private $defaultAllowedDeliveries = [];
/**
* Dozwolone dostawy
* @var array|null
*/
private $allowedDeliveries = [];
private $allowedDeliveriesModified = false;
/**
* Konstruktor
* @param Currency $currency Waluta
*/
public function __construct(stCurrencyModelInterface $currency)
{
$this->currency = $currency;
$this->defaultAllowedDeliveries = array_values(DeliveryPeer::retrieveAllowedIdsCached());
$this->allowedDeliveries = $this->defaultAllowedDeliveries;
$this->config = stConfig::getInstance('stDeliveryBackend');
}
/**
* Zwraca łączny koszt brutto produktów
*
* @return float|string
*/
final public function getTotalAmount(bool $withCurrency = false)
{
$this->doInitialize();
return $withCurrency ? $this->totalAmountWithCurrency : $this->currency->exchange($this->totalAmountWithCurrency, true);
}
/**
* Zwraca łączną wagę produktów
* @return float|string
*/
final public function getTotalWeight()
{
$this->doInitialize();
return $this->totalWeight;
}
/**
* Zwraca łączną ilość produktów
* @return int
*/
final public function getTotalQuantity(): int
{
$this->doInitialize();
return $this->totalQuantity;
}
/**
* Zwraca maksymalną szerokość produktów
* @return float|string
*/
final public function getMaxWidth()
{
$this->doInitialize();
return $this->maxWidth;
}
/**
* Zwraca maksymalną wysokość produktów
* @return float|string
*/
final public function getMaxHeight()
{
$this->doInitialize();
return $this->maxHeight;
}
/**
* Zwraca maksymalną głębokość produktów
* @return float|string
*/
final public function getMaxDepth()
{
$this->doInitialize();
return $this->maxDepth;
}
/**
* Zwraca łączną objętość produktów
* @return float|string
*/
final public function getTotalVolume()
{
$this->doInitialize();
return $this->totalVolume;
}
/**
* Zwraca łączną dodatkową cenę dostawy produktów
* @return float|string
*/
final public function getTotalDeliveryPrice()
{
$this->doInitialize();
return $this->totalDeliveryPrice;
}
/**
* Zwraca dozwolone id dostaw dla wszystkich produktów
* @return array|null
*/
final public function getAllowedDeliveries(): ?array
{
$this->doInitialize();
if (empty($this->allowedDeliveries) && !empty($this->config->get('alternate_deliveries')))
{
$this->allowedDeliveries = $this->config->get('alternate_deliveries');
}
return $this->allowedDeliveries;
}
/**
* Zwraca maksymalna stawkę VAT
* @return Tax|null
*/
public function getMaxTax(): ?Tax
{
return $this->maxTax;
}
/**
* Wymusza odświeżenie informacji o produktach
* @return void
*/
public function refresh(): void
{
$this->initialized = false;
$this->totalAmountWithCurrency = 0;
$this->totalWeight = 0;
$this->totalQuantity = 0;
$this->maxWidth = 0;
$this->maxHeight = 0;
$this->maxDepth = 0;
$this->maxTax = null;
$this->totalVolume = 0;
$this->totalDeliveryPrice = 0;
$this->allowedDeliveries = $this->defaultAllowedDeliveries;
$this->allowedDeliveriesModified = false;
}
final protected function addAmountWithCurrency($amount): void
{
$this->totalAmountWithCurrency += $amount;
}
final protected function addWeight($weight): void
{
$this->totalWeight += $weight;
}
final protected function addMaxTax(Tax $tax)
{
if (null !== $tax->getTaxRateByCountry() && (null === $this->maxTax || $this->maxTax->getTaxRateByCountry() < $tax->getTaxRateByCountry()))
{
$this->maxTax = $tax;
}
}
final protected function addQuantity(int $quantity): void
{
$this->totalQuantity += $quantity;
}
final protected function addDimensions($width, $height, $depth, int $quantity)
{
if ($this->maxWidth < $width)
{
$this->maxWidth = $width;
}
if ($this->maxHeight < $height)
{
$this->maxHeight = $height;
}
if ($this->maxDepth < $depth)
{
$this->maxDepth = $depth;
}
$volume = $this->applyDimensionMargin($width) * $this->applyDimensionMargin($height) * $this->applyDimensionMargin($depth);
$this->totalVolume += $volume * $quantity;
}
final protected function addDeliveryPrice($deliveryPrice)
{
$this->totalDeliveryPrice += $deliveryPrice;
}
final protected function addAllowedDeliveries(array $allowedDelivieries)
{
if (!$allowedDelivieries || !$allowedDelivieries['ids'])
{
$allowedDelivieries = array('mode' => 'allow', 'ids' => $this->defaultAllowedDeliveries);
}
if ($allowedDelivieries)
{
if ($allowedDelivieries['ids'])
{
$ids = array_intersect(DeliveryPeer::retrieveIdsCached(), $allowedDelivieries['ids']);
if ($allowedDelivieries['mode'] == 'allow' && null !== $this->allowedDeliveries && $ids)
{
$this->allowedDeliveries = $this->allowedDeliveries && $this->allowedDeliveriesModified ? array_intersect($this->allowedDeliveries, $ids) : $ids;
$this->allowedDeliveriesModified = true;
}
elseif ($allowedDelivieries['mode'] == 'exclude' && $this->allowedDeliveries)
{
$this->allowedDeliveries = array_intersect($this->allowedDeliveries, array_diff($this->defaultAllowedDeliveries, $ids));
$this->allowedDeliveriesModified = true;
}
}
}
if (empty($this->allowedDeliveries))
{
$this->allowedDeliveries = null;
}
}
/**
* Initializuje informacje o produktach
* @return void
*/
abstract protected function initialize(): void;
private function doInitialize(): void
{
if (!$this->initialized)
{
$this->initialized = true;
$this->initialize();
}
}
private function applyDimensionMargin($value)
{
$margin = $this->config->get('product_package_margin');
return $margin > 0 ? $value + stPrice::percentValue($value, $margin) : $value;
}
}

View File

@@ -0,0 +1,133 @@
<?php
abstract class stDeliveryTypeAbstract implements stDeliveryTypeInterface
{
const DELIVERY_ERROR = 'delivery_error';
const PICKUP_POINT_IS_EMPTY = 'Musisz wybrać punkt odbioru';
const PICKUP_POINT_NO_WEEKEND_DELIVERY_ERROR_MSG = 'Wybrany punkt odbioru nie obsługuje dostawy w weekend.';
const PICKUP_POINT_HAS_NO_COD_SUPPORT_ERROR_MSG = 'Wybrany punkt odbioru nie obsługuje płatności przy odbiorze. Zmień płatność lub wybierz inny punkt odbioru.';
const PICKUP_POINT_DOES_NOT_EXIST_ERROR_MSG = 'Wybrany punkt odbioru nie istnieje lub jest czasowo niedostępny. Wybierz inny punkt odbioru.';
/**
* Konfiguracja
*
* @var stDeliveryTypeConfigurationInterface
*/
private $configuration;
/**
* Routing
*
* @var sfRouting
*/
private $routing;
/**
* Kotekst
*
* @var sfContext
*/
private $context;
public function __construct(sfContext $context, stDeliveryTypeConfigurationInterface $configuration)
{
$this->context = $context;
$this->configuration = $configuration;
$this->routing = sfRouting::getInstance();
}
public function getConfiguration(): stDeliveryTypeConfigurationInterface
{
return $this->configuration;
}
public function getType(): string
{
return $this->configuration->getType();
}
public function getLabel(): string
{
return $this->getI18N()->__($this->configuration->getLabel(), null, $this->configuration->getBackendModule());
}
public function pickupPointUpdate(stDeliveryTypePickupPoint $pickupPoint): ?stDeliveryTypePickupPoint
{
return $pickupPoint;
}
public function validate(Delivery $selectedDelivery, PaymentType $selectedPayment, string $orderTotalAmount, array $userDataBilling, array $userDataDelivery, ?stDeliveryTypePickupPoint $pickupPoint, bool $isWeekendDelivery, bool $isExpressDelivery, array &$errors): bool
{
if ($this->isPickupPoint())
{
if (empty($pickupPoint))
{
$errors[self::DELIVERY_ERROR] = self::PICKUP_POINT_IS_EMPTY;
}
else
{
$pickupPoint = $this->pickupPointUpdate($pickupPoint);
if (null === $pickupPoint)
{
$errors[self::DELIVERY_ERROR] = self::PICKUP_POINT_DOES_NOT_EXIST_ERROR_MSG;
}
elseif ($selectedPayment->getIsCod() && !$pickupPoint->getCod())
{
$errors[self::DELIVERY_ERROR] = self::PICKUP_POINT_HAS_NO_COD_SUPPORT_ERROR_MSG;
}
elseif ($isWeekendDelivery && !$pickupPoint->getWeekend())
{
$errors[self::DELIVERY_ERROR] = self::PICKUP_POINT_NO_WEEKEND_DELIVERY_ERROR_MSG;
}
}
}
return empty($errors);
}
public function isPickupPoint(): bool
{
return $this->configuration->getOption('pickup_point');
}
public function getApplicationName(): string
{
return $this->configuration->getApplicationName();
}
public function getCreatePackageActionUrl(Order $order): string
{
$urlParameters = 'action=create&order_id='.$order->getId();
if ($order->isAllegroOrder())
{
$urlParameters .= '&type=allegro';
}
if ($this->routing->hasRouteName($this->configuration->getBackendModule()))
{
return '@'.$this->configuration->getBackendModule().'?'.$urlParameters;
}
return '@'.$this->getApplicationName().'?'.$urlParameters;
}
/**
* Sprawdza czy dany typ dostawy obsługuje zamówienia z Allegro
*
* @param string $allegroDeliveryId Id dostawy z Allegro
* @return bool
*/
public function supportsAllegroDelivery(string $allegroDeliveryId): bool
{
return false;
}
abstract public function getTrackingUrl(string $number): string;
protected function getI18N(): sfI18N
{
return $this->context->getI18N();
}
}

View File

@@ -0,0 +1,176 @@
<?php
class stDeliveryTypeConfiguration implements stDeliveryTypeConfigurationInterface
{
const DEFAULT_OPTIONS = [
'pickup_point' => false,
'extends' => null,
];
protected $backendModule;
protected $frontendModule;
protected $applicationName;
protected $label;
protected $className;
protected $type;
protected $options;
protected static $registeredModules = [];
protected static $configurations = [];
public function __construct(string $type, string $className, string $label, array $options)
{
$applicationName = self::computeApplicationName($className);
$appPrefix = preg_replace('/Plugin$/', '', $applicationName);
$this->type = $type;
$this->className = $className;
$this->label = $label;
$this->backendModule = $appPrefix . 'Backend';
$this->frontendModule = $appPrefix . 'Frontend';
$this->applicationName = $applicationName;
$this->options = $options;
}
public function getOption(string $name)
{
if (!isset($this->options[$name]) && !array_key_exists($name, $this->options))
{
$available = implode('", "', array_keys($this->options));
throw new stDeliveryTypeConfigurationException(sprintf('Option "%s" does not exist (available: "%s")', $name, $available));
}
return $this->options[$name];
}
public function getApplicationName(): string
{
return $this->applicationName;
}
public function getFrontendModule(): string
{
return $this->frontendModule;
}
public function getBackendModule(): string
{
return $this->backendModule;
}
public function getClassName(): string
{
return $this->className;
}
public function getLabel(): string
{
return $this->label;
}
public function getType(): string
{
return $this->type;
}
/**
* Dodane nowy typ dostawy
*
* @param string $type Unikalna nazwa typu
* @param string $className Nazwa klasy obsługującej typ
* @param string $label Wyświetlana nazwa typu
* @return void
*/
public static function register(string $type, string $className, string $label, array $options = [])
{
$configuration = new static($type, $className, $label, $options);
$options = stConfigHelper::mergeOptions($options, self::DEFAULT_OPTIONS);
$types = self::getTypes();
$types[$type] = [
'class_name' => $configuration->getClassName(),
'label' => $configuration->getLabel(),
'options' => $options
];
if (!isset(self::$registeredModules[$configuration->getBackendModule()]))
{
stEventDispatcher::getInstance()->connect('stAdminGenerator.generate' . ucfirst($configuration->getBackendModule()), array('stDeliveryListener', 'generateDeliveryType'));
self::$registeredModules[$configuration->getBackendModule()] = true;
}
sfConfig::set('app_st_delivery_types', $types);
}
/**
* Sprawdza czy typ dostawy istnieje
*
* @param string $type Nazwa typu
* @return boolean
*/
public static function has($type)
{
$types = self::getTypes();
return isset($types[$type]);
}
/**
* Zwraca konfigurację dla danego typu
*
* @param string $type Nazwa typu
* @return stDeliveryTypeConfigurationInterface
*/
public static function get(string $type): stDeliveryTypeConfigurationInterface
{
if (!isset(self::$configurations[$type]))
{
$types = self::getTypes();
if (!self::has($type))
{
$available = array_keys($types);
throw new stDeliveryTypeConfigurationException(sprintf('Delivery type "%s" doest not exist (available: "%s")', $type, implode('", "', $available)));
}
self::$configurations[$type] = new static($type, $types[$type]['class_name'], $types[$type]['label'], $types[$type]['options']);
}
return self::$configurations[$type];
}
/**
* Zwraca dostępna listę typów dostaw
*
* @return array
*/
public static function getTypes()
{
return sfConfig::get('app_st_delivery_types', array());
}
public static function getTypesIntegrityHash(): string
{
$types = array_keys(self::getTypes());
return md5(implode(',', $types));
}
public static function checkTypesIntegrityHash(string $hash): bool
{
return $hash === self::getTypesIntegrityHash();
}
private static function computeApplicationName(string $className): string
{
$reflection = new ReflectionClass($className);
if (!preg_match('/\/plugins\/([^\/]+)\//', $reflection->getFileName(), $matches))
{
throw new stPaymentTypeConfigurationException(sprintf('The %s class must be added as part of a plugin', $className));
}
return $matches[1];
}
}

View File

@@ -0,0 +1,6 @@
<?php
class stDeliveryTypeConfigurationException extends Exception
{
}

View File

@@ -0,0 +1,54 @@
<?php
interface stDeliveryTypeConfigurationInterface
{
/**
* Nazwa aplikacji
*
* @return string
*/
public function getApplicationName(): string;
/**
* Nazwa modułu frontend
*
* @return string
*/
public function getFrontendModule(): string;
/**
* Nazwa modułu backend
*
* @return string
*/
public function getBackendModule(): string;
/**
* Nazwa klasy typu dostawy
*
* @return string
*/
public function getClassName(): string;
/**
* Etykieta typu dostawy (Nazwa wyświetlana po stronie panelu)
*
* @return string
*/
public function getLabel(): string;
/**
* Nazwa typu dostawy
*
* @return string
*/
public function getType(): string;
/**
* Zwraca wartość opcji
*
* @return string|int|bool|array|float|null
*/
public function getOption(string $name);
}

View File

@@ -0,0 +1,28 @@
<?php
class stDeliveryTypeConfigurationValidator extends sfValidator
{
public function execute(&$value, &$error)
{
if (null === $value || !stDeliveryTypeConfiguration::has($value))
{
return true;
}
$service = stDeliveryTypeService::get($value);
$i18n = $this->getContext()->getI18N();
if (!$service->checkConfiguration())
{
$error = $this->getContext()->getI18N()->__('Typ dostawy "%%service%%" wymaga poprawnej <a href="%%config_url%%" target="_blank">konfiguracji</a>', [
'%%service%%' => $i18n->__($service->getConfiguration()->getLabel(), null, $service->getConfiguration()->getBackendModule()),
'%%config_url%%' => stAdminGeneratorHelper::generateUrl($service->getConfiguration()->getBackendModule(), 'config'),
], 'stDeliveryBackend');
return false;
}
return true;
}
}

View File

@@ -0,0 +1,16 @@
<?php
class stDeliveryTypeFactory
{
/**
* Tworzy nową instancję typu dostawy
*
* @param string $type
* @return stDeliveryTypeAbstract
*/
public static function create($type)
{
$class = stDeliveryTypeConfiguration::get($type, stDeliveryTypeConfiguration::SERVICE_CLASS);
return new $class($type);
}
}

View File

@@ -0,0 +1,87 @@
<?php
interface stDeliveryTypeInterface
{
/**
* Zwraca konfigurację typu dostawy
*
* @return stDeliveryTypeConfigurationInterface
*/
public function getConfiguration(): stDeliveryTypeConfigurationInterface;
/**
* Zwraca url tworzenia paczki
*
* @param Order $order
* @return string
*/
public function getCreatePackageActionUrl(Order $order): string;
/**
* Sprawdza czy dany typ dostawy obsługuje zamówienia z Allegro
*
* @param string $allegroDeliveryId Id dostawy z Allegro
* @return bool
*/
public function supportsAllegroDelivery(string $allegroDeliveryId): bool;
/**
* Aktualizuje zapamiętany punkt odbioru
*
* @param stDeliveryTypePickupPoint $pickupPoint Zapamiętany punkt odbioru
* @return stDeliveryTypePickupPoint|null Aktualny punkt odbioru (Wartość null oznacza że punkt odbioru już nie istnieje lub jest tymczasowo niedostępny)
*/
public function pickupPointUpdate(stDeliveryTypePickupPoint $pickupPoint): ?stDeliveryTypePickupPoint;
/**
* Walidacja typu dostawy
*
* @param Delivery $selectedDelivery Wybrana dostawa
* @param PaymentType $selectedPayment Wybrana płatność
* @param string $orderTotalAmount Łączna kwota zamówienia
* @param array $userDataBilling Dane bilingowe
* @param array $userDataDelivery Dane dostawy
* @param stDeliveryTypePickupPoint|null $pickupPoint Punkt odbioru
* @param bool $isWeekendDelivery Dostawa w weekend?
* @param bool $isExpressDelivery Dostawa ekspresowa?
* @param array $errors Zwrócone błędy
* @return bool
*/
public function validate(Delivery $selectedDelivery, PaymentType $selectedPayment, string $orderTotalAmount, array $userDataBilling, array $userDataDelivery, ?stDeliveryTypePickupPoint $pickupPoint, bool $isWeekendDelivery, bool $isExpressDelivery, array &$errors): bool;
/**
* Zwraca url śledzenia paczki
*
* @param string $number
* @return string
*/
public function getTrackingUrl(string $number): string;
/**
* Czy typ dostawy jest punktem odbioru?
*
* @return boolean
*/
public function isPickupPoint(): bool;
/**
* Zwraca typ dostawy
*
* @return string
*/
public function getType(): string;
/**
* Zwraca nazwę typu dostawy
*
* @return string
*/
public function getLabel(): string;
/**
* Sprawdza czy typ dostawy jest poprawnie skonfigurowany przez użytkownika
*
* @return boolean
*/
public function checkConfiguration(): bool;
}

View File

@@ -0,0 +1,131 @@
<?php
class stDeliveryTypePickupPoint implements JsonSerializable
{
protected $id;
protected $name;
protected $address;
protected $postCode;
protected $city;
protected $countryCode;
protected $cod;
protected $weekend;
protected $customParamerers;
/**
* Zwraca punkt odbioru na podstawie formatu Json
*
* @param string $json
* @return stDeliveryTypePickupPoint
*/
public static function createFromJson(?string $json): ?stDeliveryTypePickupPoint
{
if (null === $json)
{
return null;
}
$data = json_decode($json, true);
return self::createFromArray($data);
}
public static function createFromArray(?array $data): ?stDeliveryTypePickupPoint
{
if (null === $data)
{
return null;
}
return new static($data['id'], $data['name'], $data['address'], $data['postCode'], $data['city'], $data['countryCode'], $data['cod'], $data['weekend'], isset($data['custom']) ? $data['custom'] : []);
}
public function __toString(): string
{
return $this->id;
}
public function __construct(string $id, string $name, string $address, string $postCode, string $city, string $countryCode, bool $cod, bool $weekend, array $customParamerers = [])
{
$this->id = $id;
$this->name = $name;
$this->address = $address;
$this->postCode = $postCode;
$this->city = $city;
$this->countryCode = strlen($countryCode) == 3 ? stCountries::convAlpha3ToAlpha2($countryCode) : $countryCode;
$this->cod = $cod;
$this->weekend = $weekend;
$this->customParamerers = $customParamerers;
}
public function jsonSerialize()
{
return [
'id' => $this->id,
'name' => $this->name,
'address' => $this->address,
'postCode' => $this->postCode,
'city' => $this->city,
'countryCode' => $this->countryCode,
'cod' => $this->cod,
'weekend' => $this->weekend,
'custom' => $this->customParamerers,
];
}
public function getId(): string
{
return $this->id;
}
public function getName(): string
{
return $this->name;
}
public function getAddress(): string
{
return $this->address;
}
public function getPostCode(): string
{
return $this->postCode;
}
public function getCity(): string
{
return $this->city;
}
public function getCountry(): Countries
{
return CountriesPeer::retrieveByIsoA2($this->countryCode);
}
public function getCod(): bool
{
return $this->cod;
}
public function getWeekend(): bool
{
return $this->weekend;
}
public function getCustomParameters(): array
{
return $this->customParamerers;
}
public function getCustomParameter(string $name, $default = null)
{
return isset($this->customParamerers[$name]) ? $this->customParamerers[$name] : $default;
}
public function setCod(bool $cod)
{
$this->cod = $cod;
}
}

View File

@@ -0,0 +1,24 @@
<?php
class stDeliveryTypeService
{
protected static $services = [];
/**
* Tworzy nową instancję typu dostawy
*
* @param string $type
* @return stDeliveryTypeInterface
*/
public static function get(string $type): stDeliveryTypeInterface
{
if (!isset(self::$services[$type]))
{
$configuration = stDeliveryTypeConfiguration::get($type);
$class = $configuration->getClassName();
self::$services[$type] = new $class(sfContext::getInstance(), $configuration);
}
return self::$services[$type];
}
}

View File

@@ -0,0 +1,16 @@
<?php
class stTimeValidator extends sfValidator
{
public function execute(&$value, &$error)
{
if (!preg_match('/^(0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$/', $value))
{
$error = $this->context->getI18N()->__('Musisz przekazać poprawną godzinę (np. 11:00)', null, 'stDeliveryBackend');
return false;
}
return true;
}
}