first commit
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Subclass for representing a row from the 'st_paczkomaty_dispatch_order' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stPaczkomatyPlugin.lib.model
|
||||
*/
|
||||
class PaczkomatyDispatchOrder extends BasePaczkomatyDispatchOrder
|
||||
{
|
||||
public function __toString()
|
||||
{
|
||||
return null !== $this->getDispatchOrderExternalId() ? $this->getDispatchOrderExternalId() : '';
|
||||
}
|
||||
|
||||
public function getParcels()
|
||||
{
|
||||
|
||||
$trackingNumbers = [];
|
||||
|
||||
foreach ($this->getPaczkomatyPacks() as $pack)
|
||||
{
|
||||
$trackingNumbers[] = $pack->getTrackingNumber();
|
||||
}
|
||||
|
||||
return implode(', ', $trackingNumbers);
|
||||
}
|
||||
|
||||
public function getStatusLabel()
|
||||
{
|
||||
return stInPostApi::getInstance()->getDispatchOrderStatusTitleByName($this->status);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Subclass for performing query and update operations on the 'st_paczkomaty_dispatch_order' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stPaczkomatyPlugin.lib.model
|
||||
*/
|
||||
class PaczkomatyDispatchOrderPeer extends BasePaczkomatyDispatchOrderPeer
|
||||
{
|
||||
public static function doSelectWithShipX(Criteria $c, $con = null)
|
||||
{
|
||||
/**
|
||||
* @var PaczkomatyDispatchOrder[]
|
||||
*/
|
||||
$results = [];
|
||||
$ids = [];
|
||||
|
||||
foreach (parent::doSelect($c, $con) as $index => $result)
|
||||
{
|
||||
$ids[] = $result->getDispatchOrderId();
|
||||
$results[empty($result->getDispatchOrderId()) ? $index : $result->getDispatchOrderId()] = $result;
|
||||
}
|
||||
|
||||
$api = stInPostApi::getInstance();
|
||||
$response = $api->getDispatchOrders($ids);
|
||||
|
||||
foreach ($response->items as $item)
|
||||
{
|
||||
if (isset($results[$item->id]))
|
||||
{
|
||||
$results[$item->id]->setStatus($item->status);
|
||||
$results[$item->id]->save();
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
}
|
||||
351
plugins/stPaczkomatyPlugin/lib/model/PaczkomatyPack.php
Normal file
351
plugins/stPaczkomatyPlugin/lib/model/PaczkomatyPack.php
Normal file
@@ -0,0 +1,351 @@
|
||||
<?php
|
||||
|
||||
class PaczkomatyPack extends BasePaczkomatyPack
|
||||
{
|
||||
|
||||
protected $allegroTransaction = null;
|
||||
|
||||
protected $sendingMethod = null;
|
||||
|
||||
protected $dropoffPoint = null;
|
||||
|
||||
protected $endOfWeekCollection = false;
|
||||
|
||||
public function isAdminGeneratorPlainField(): bool
|
||||
{
|
||||
return !$this->isNew() && !in_array($this->getStatus(), array('created', 'offers_prepared', 'offer_selected'));
|
||||
}
|
||||
|
||||
public function isAdminGeneratorActionVisible(string $name): bool
|
||||
{
|
||||
if ($name == 'download_label' && empty($this->getTrackingNumber()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($name == 'dispatch_order' && (!stDeliveryTypeConfiguration::has('inpostk') || $this->getSendingMethod() != 'dispatch_order' || null !== $this->getDispatchOrderId() || empty($this->getTrackingNumber())))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($name == '_delete' && !empty($this->getStatus()) && !in_array($this->getStatus(), ['created', 'offers_prepared', 'offer_selected']))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getServiceType(): string
|
||||
{
|
||||
return $this->getOrder()->getOrderDelivery()->getDeliveryTypeService()->getLabel();
|
||||
}
|
||||
|
||||
public function getOrderNumber()
|
||||
{
|
||||
return $this->getOrder() ? $this->getOrder()->getNumber() : null;
|
||||
}
|
||||
|
||||
public function setOrder($order)
|
||||
{
|
||||
if ($this->isNew() && null === $this->aOrder)
|
||||
{
|
||||
parent::setOrder($order);
|
||||
|
||||
$userData = $order->getOrderUserDataDelivery();
|
||||
$this->setCustomerEmail($order->getOptClientEmail());
|
||||
$this->setCustomerPhone($userData->getPhone());
|
||||
$this->setCustomerPickupPoint($order->getOrderDelivery()->getPickupPoint());
|
||||
$this->setEndOfWeekCollection($order->getOrderDelivery()->getIsWeekendDelivery());
|
||||
|
||||
if ($this->hasCourierService())
|
||||
{
|
||||
$address = $userData->getAddress();
|
||||
|
||||
if (!empty($userData->getAddressMore()))
|
||||
{
|
||||
$address .= ' ' . $userData->getAddressMore();
|
||||
}
|
||||
|
||||
$addressParser = new stAddressParser($address);
|
||||
|
||||
$this->setCustomerCompanyName($userData->getCompany());
|
||||
$this->setCustomerName($userData->getFullName());
|
||||
$this->setCustomerStreet($addressParser->getStreet());
|
||||
$this->setCustomerBuildingNumber($addressParser->getBuilding(true));
|
||||
$this->setCustomerCity($userData->getTown());
|
||||
$this->setCustomerCountryCode($userData->getCountries()->getIsoA2());
|
||||
$this->setCustomerPostCode($userData->getCode());
|
||||
$this->setCustomerPhone($userData->getPhone());
|
||||
}
|
||||
|
||||
if ($order->getOrderDelivery()->getDelivery())
|
||||
{
|
||||
$this->setPackType($order->getOrderDelivery()->getDelivery()->getPaczkomatySize());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getService()
|
||||
{
|
||||
$service = parent::getService();
|
||||
|
||||
if (null === $service)
|
||||
{
|
||||
$orderDelivery = $this->getOrder()->getOrderDelivery();
|
||||
|
||||
if ($this->getOrder()->isAllegroOrder())
|
||||
{
|
||||
$service = stInPostApi::getAllegroDeliveryToServiceMapping($orderDelivery->getOptAllegroDeliveryMethodId());
|
||||
}
|
||||
else
|
||||
{
|
||||
$service = $orderDelivery->getDeliveryTypeService()->getConfiguration()->getType() == 'inpostp' ? 'inpost_locker_standard' : 'inpost_courier_standard';
|
||||
}
|
||||
|
||||
$this->setService($service);
|
||||
}
|
||||
|
||||
return $service;
|
||||
}
|
||||
|
||||
public function hasCourierService()
|
||||
{
|
||||
return in_array($this->getService(), stInPostApi::COURIER_SERVICES);
|
||||
}
|
||||
|
||||
public function setCustomerPhone($v)
|
||||
{
|
||||
$v = str_replace(array('+48', ' ', '-'), '', $v);
|
||||
return parent::setCustomerPhone($v);
|
||||
}
|
||||
|
||||
public function setCustomerPickupPoint($v)
|
||||
{
|
||||
$this->setCustomerPaczkomat($v);
|
||||
}
|
||||
|
||||
public function getCustomerPickupPoint()
|
||||
{
|
||||
return $this->getCustomerPaczkomat();
|
||||
}
|
||||
|
||||
public function setDropOffPoint($v)
|
||||
{
|
||||
$this->dropoffPoint = $v;
|
||||
}
|
||||
|
||||
public function getDropOffPoint()
|
||||
{
|
||||
return $this->dropoffPoint;
|
||||
}
|
||||
|
||||
public function setEndOfWeekCollection($v)
|
||||
{
|
||||
$this->endOfWeekCollection = $v;
|
||||
}
|
||||
|
||||
public function getEndOfWeekCollection()
|
||||
{
|
||||
return $this->endOfWeekCollection;
|
||||
}
|
||||
|
||||
public function setTrackingNumber($v)
|
||||
{
|
||||
$this->setCode($v);
|
||||
}
|
||||
|
||||
public function getTrackingNumber()
|
||||
{
|
||||
return $this->getCode();
|
||||
}
|
||||
|
||||
public function getStatusLabel()
|
||||
{
|
||||
if (!$this->isAdminGeneratorPlainField())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$status = null;
|
||||
$api = stInPostApi::getInstance();
|
||||
|
||||
if ($this->status)
|
||||
{
|
||||
try
|
||||
{
|
||||
$status = $api->getStatusTitleByName($this->status);
|
||||
}
|
||||
catch (stInPostApiException $e)
|
||||
{
|
||||
$status = null;
|
||||
}
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwraca predefiniowany formiar paczki
|
||||
*
|
||||
* @return string Zwraca 'small', 'medium' or 'large'
|
||||
*/
|
||||
public function getParcelTemplate()
|
||||
{
|
||||
$templates = array(
|
||||
'A' => 'small',
|
||||
'B' => 'medium',
|
||||
'C' => 'large',
|
||||
);
|
||||
|
||||
return $templates[$this->getPackType()];
|
||||
}
|
||||
|
||||
public function setParcelTemplate($template)
|
||||
{
|
||||
$types = array(
|
||||
'small' => 'A',
|
||||
'medium' => 'B',
|
||||
'large' => 'C',
|
||||
);
|
||||
|
||||
$this->setPackType($types[$template]);
|
||||
}
|
||||
|
||||
public function delete($con = null)
|
||||
{
|
||||
$ret = parent::delete($con);
|
||||
|
||||
$delivery = $this->getOrder()->getOrderDelivery();
|
||||
$delivery->setNumber(null);
|
||||
$delivery->save();
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function save($con = null)
|
||||
{
|
||||
$orderNumberModified = $this->isColumnModified(PaczkomatyPackPeer::CODE);
|
||||
$pickupPointModified = $this->isColumnModified(PaczkomatyPackPeer::CUSTOMER_PACZKOMAT);
|
||||
|
||||
$ret = parent::save($con);
|
||||
|
||||
if ($orderNumberModified)
|
||||
{
|
||||
$orderDelivery = $this->getOrder()->getOrderDelivery();
|
||||
|
||||
if ($orderDelivery)
|
||||
{
|
||||
$orderDelivery->setNumber($this->getTrackingNumber());
|
||||
$orderDelivery->save();
|
||||
}
|
||||
}
|
||||
|
||||
if ($pickupPointModified)
|
||||
{
|
||||
$orderUserDataDelivery = $this->getOrder()->getOrderUserDataDelivery();
|
||||
|
||||
if ($orderUserDataDelivery)
|
||||
{
|
||||
$pickupPoint = stInPostApi::getInstance()->getPoint($this->getCustomerPickupPoint());
|
||||
|
||||
$address = $pickupPoint->address_details->street . ' ' . $pickupPoint->address_details->building_number;
|
||||
|
||||
if ($pickupPoint->address_details->flat_number)
|
||||
{
|
||||
$address .= '/' . $pickupPoint->address_details->flat_number;
|
||||
}
|
||||
|
||||
$orderUserDataDelivery->setCompany('Paczkomat - ' . $pickupPoint->name);
|
||||
$orderUserDataDelivery->setFullName(null);
|
||||
$orderUserDataDelivery->setAddress($address);
|
||||
$orderUserDataDelivery->setCode($pickupPoint->address_details->post_code);
|
||||
$orderUserDataDelivery->setAddressMore(null);
|
||||
$orderUserDataDelivery->setTown($pickupPoint->address_details->city);
|
||||
$orderUserDataDelivery->save();
|
||||
}
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function getCashOnDelivery($fetchFromOrder = false)
|
||||
{
|
||||
$amount = parent::getCashOnDelivery();
|
||||
|
||||
if (null === $amount && $fetchFromOrder)
|
||||
{
|
||||
$amount = stPrice::round($this->getOrder()->getUnpaidAmount());
|
||||
|
||||
if ($this->getOrder()->getOrderCurrency() != 'PLN')
|
||||
{
|
||||
$amount = $this->getOrder()->getOrderCurrency()->exchange($amount, true);
|
||||
}
|
||||
}
|
||||
|
||||
return $amount;
|
||||
}
|
||||
|
||||
public function hasAllegroTransactionId()
|
||||
{
|
||||
return $this->getOrder()->isAllegroOrder();
|
||||
}
|
||||
|
||||
public function hasAllegroInsurance()
|
||||
{
|
||||
return $this->hasAllegroTransactionId() && ($this->getOrder()->getOptTotalAmount() - $this->getOrder()->getOrderDelivery()->getCost(true) <= 5000);
|
||||
}
|
||||
|
||||
public function getAllegroTransactionId()
|
||||
{
|
||||
if (null === $this->allegroTransaction)
|
||||
{
|
||||
if ($this->getOrder()->getOptAllegroCheckoutFormId() && !is_numeric($this->getOrder()->getOrderPayment()->getTransactionId()))
|
||||
{
|
||||
$api = stAllegroApi::getInstance();
|
||||
$this->allegroTransaction = $api->getPaymentMapping($this->getOrder()->getOrderPayment()->getTransactionId());
|
||||
}
|
||||
else
|
||||
{
|
||||
$order = $this->getOrder();
|
||||
|
||||
$c = new Criteria();
|
||||
$c->add(AllegroAuctionHasOrderPeer::ORDER_ID, $order->getId());
|
||||
$allegroTransaction = AllegroAuctionHasOrderPeer::doSelectOne($c);
|
||||
|
||||
$this->allegroTransaction = $allegroTransaction ? $allegroTransaction->getTransId() : null;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->allegroTransaction;
|
||||
}
|
||||
|
||||
public function getInsurance($fetchFromOrder = false)
|
||||
{
|
||||
$amount = parent::getInsurance();
|
||||
|
||||
if (!$amount && $fetchFromOrder)
|
||||
{
|
||||
$amount = $this->getOrder()->getTotalAmount(true, true);
|
||||
|
||||
if ($this->getOrder()->getOrderCurrency() != 'PLN')
|
||||
{
|
||||
$amount = $this->getOrder()->getOrderCurrency()->exchange($amount, true);
|
||||
}
|
||||
}
|
||||
|
||||
return $amount;
|
||||
}
|
||||
|
||||
public function hasCashOnDelivery()
|
||||
{
|
||||
if ($this->getHasCashOnDelivery())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
$payment = $this->getOrder()->getOrderPayment();
|
||||
|
||||
return $payment && $payment->getPaymentType()->getIsCod();
|
||||
}
|
||||
}
|
||||
63
plugins/stPaczkomatyPlugin/lib/model/PaczkomatyPackPeer.php
Normal file
63
plugins/stPaczkomatyPlugin/lib/model/PaczkomatyPackPeer.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
class PaczkomatyPackPeer extends BasePaczkomatyPackPeer {
|
||||
|
||||
public static function retrieveByCode($code, $con = null) {
|
||||
$c = new Criteria();
|
||||
$c->add(PaczkomatyPackPeer::CODE, $code);
|
||||
return PaczkomatyPackPeer::doSelectOne($c, $con);
|
||||
}
|
||||
|
||||
public static function retrieveByOrder(Order $order)
|
||||
{
|
||||
$c = new Criteria();
|
||||
$c->add(self::ORDER_ID, $order->getId());
|
||||
$c->addDescendingOrderByColumn(self::ID);
|
||||
return self::doSelectOne($c);
|
||||
}
|
||||
|
||||
public static function retrieveByPKsOrder(array $pks)
|
||||
{
|
||||
$c = new Criteria();
|
||||
$c->add(self::ID, $pks, Criteria::IN);
|
||||
$c->addOrderByField(self::ID, $pks);
|
||||
|
||||
return self::doSelect($c);
|
||||
}
|
||||
|
||||
public static function doSelectWithShipX(Criteria $c, $con = null)
|
||||
{
|
||||
/**
|
||||
* @var PaczkomatyPack[]
|
||||
*/
|
||||
$results = [];
|
||||
$ids = [];
|
||||
|
||||
foreach (self::doSelectJoinAll($c) as $result)
|
||||
{
|
||||
$results[$result->getInpostShipmentId()] = $result;
|
||||
$ids[] = $result->getInpostShipmentId();
|
||||
}
|
||||
|
||||
$api = stInPostApi::getInstance();
|
||||
$response = $api->getShipmentsById($ids);
|
||||
|
||||
foreach ($response->items as $item)
|
||||
{
|
||||
if (isset($results[$item->id]))
|
||||
{
|
||||
$pack = $results[$item->id];
|
||||
$pack->setStatus($item->status);
|
||||
|
||||
if (empty($pack->getTrackingNumber()) && !empty($item->tracking_number))
|
||||
{
|
||||
$pack->setTrackingNumber($item->tracking_number);
|
||||
}
|
||||
|
||||
$pack->save();
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* This class adds structure of 'st_paczkomaty_dispatch_order' 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.stPaczkomatyPlugin.lib.model.map
|
||||
*/
|
||||
class PaczkomatyDispatchOrderMapBuilder {
|
||||
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'plugins.stPaczkomatyPlugin.lib.model.map.PaczkomatyDispatchOrderMapBuilder';
|
||||
|
||||
/**
|
||||
* 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_paczkomaty_dispatch_order');
|
||||
$tMap->setPhpName('PaczkomatyDispatchOrder');
|
||||
|
||||
$tMap->setUseIdGenerator(true);
|
||||
|
||||
$tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null);
|
||||
|
||||
$tMap->addColumn('DISPATCH_ORDER_ID', 'DispatchOrderId', 'string', CreoleTypes::BIGINT, false, null);
|
||||
|
||||
$tMap->addColumn('DISPATCH_ORDER_EXTERNAL_ID', 'DispatchOrderExternalId', 'string', CreoleTypes::BIGINT, false, null);
|
||||
|
||||
$tMap->addColumn('CREATED_AT', 'CreatedAt', 'int', CreoleTypes::TIMESTAMP, false, null);
|
||||
|
||||
$tMap->addColumn('STATUS', 'Status', 'string', CreoleTypes::VARCHAR, false, 16);
|
||||
|
||||
} // doBuild()
|
||||
|
||||
} // PaczkomatyDispatchOrderMapBuilder
|
||||
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* This class adds structure of 'st_paczkomaty_pack' 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.stPaczkomatyPlugin.lib.model.map
|
||||
*/
|
||||
class PaczkomatyPackMapBuilder {
|
||||
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'plugins.stPaczkomatyPlugin.lib.model.map.PaczkomatyPackMapBuilder';
|
||||
|
||||
/**
|
||||
* 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_paczkomaty_pack');
|
||||
$tMap->setPhpName('PaczkomatyPack');
|
||||
|
||||
$tMap->setUseIdGenerator(true);
|
||||
|
||||
$tMap->addColumn('CREATED_AT', 'CreatedAt', 'int', CreoleTypes::TIMESTAMP, false, null);
|
||||
|
||||
$tMap->addColumn('UPDATED_AT', 'UpdatedAt', 'int', CreoleTypes::TIMESTAMP, false, null);
|
||||
|
||||
$tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null);
|
||||
|
||||
$tMap->addColumn('CUSTOMER_EMAIL', 'CustomerEmail', 'string', CreoleTypes::VARCHAR, false, 255);
|
||||
|
||||
$tMap->addColumn('CUSTOMER_PHONE', 'CustomerPhone', 'string', CreoleTypes::VARCHAR, false, 24);
|
||||
|
||||
$tMap->addColumn('CUSTOMER_NAME', 'CustomerName', 'string', CreoleTypes::VARCHAR, false, 255);
|
||||
|
||||
$tMap->addColumn('CUSTOMER_COMPANY_NAME', 'CustomerCompanyName', 'string', CreoleTypes::VARCHAR, false, 255);
|
||||
|
||||
$tMap->addColumn('CUSTOMER_STREET', 'CustomerStreet', 'string', CreoleTypes::VARCHAR, false, 255);
|
||||
|
||||
$tMap->addColumn('CUSTOMER_BUILDING_NUMBER', 'CustomerBuildingNumber', 'string', CreoleTypes::VARCHAR, false, 24);
|
||||
|
||||
$tMap->addColumn('CUSTOMER_CITY', 'CustomerCity', 'string', CreoleTypes::VARCHAR, false, 255);
|
||||
|
||||
$tMap->addColumn('CUSTOMER_POST_CODE', 'CustomerPostCode', 'string', CreoleTypes::VARCHAR, false, 16);
|
||||
|
||||
$tMap->addColumn('CUSTOMER_COUNTRY_CODE', 'CustomerCountryCode', 'string', CreoleTypes::CHAR, false, 2);
|
||||
|
||||
$tMap->addColumn('CUSTOMER_PACZKOMAT', 'CustomerPaczkomat', 'string', CreoleTypes::VARCHAR, false, 48);
|
||||
|
||||
$tMap->addColumn('SENDING_METHOD', 'SendingMethod', 'string', CreoleTypes::VARCHAR, false, 48);
|
||||
|
||||
$tMap->addColumn('SENDER_PACZKOMAT', 'SenderPaczkomat', 'string', CreoleTypes::VARCHAR, false, 24);
|
||||
|
||||
$tMap->addColumn('USE_SENDER_PACZKOMAT', 'UseSenderPaczkomat', 'boolean', CreoleTypes::BOOLEAN, false, null);
|
||||
|
||||
$tMap->addColumn('PACK_TYPE', 'PackType', 'string', CreoleTypes::CHAR, false, 1);
|
||||
|
||||
$tMap->addColumn('INPOST_SHIPMENT_ID', 'InpostShipmentId', 'int', CreoleTypes::INTEGER, false, null);
|
||||
|
||||
$tMap->addColumn('INSURANCE', 'Insurance', 'double', CreoleTypes::DECIMAL, false, 10);
|
||||
|
||||
$tMap->addColumn('CASH_ON_DELIVERY', 'CashOnDelivery', 'double', CreoleTypes::DECIMAL, false, 10);
|
||||
|
||||
$tMap->addColumn('DESCRIPTION', 'Description', 'string', CreoleTypes::VARCHAR, false, 255);
|
||||
|
||||
$tMap->addColumn('PARCELS', 'Parcels', 'array', CreoleTypes::VARCHAR, false, 8192);
|
||||
|
||||
$tMap->addColumn('SERVICE', 'Service', 'string', CreoleTypes::VARCHAR, false, 48);
|
||||
|
||||
$tMap->addColumn('CODE', 'Code', 'string', CreoleTypes::VARCHAR, false, 255);
|
||||
|
||||
$tMap->addColumn('HAS_CASH_ON_DELIVERY', 'HasCashOnDelivery', 'boolean', CreoleTypes::BOOLEAN, false, null);
|
||||
|
||||
$tMap->addColumn('STATUS', 'Status', 'string', CreoleTypes::VARCHAR, false, 255);
|
||||
|
||||
$tMap->addForeignKey('ORDER_ID', 'OrderId', 'int', CreoleTypes::INTEGER, 'st_order', 'ID', false, null);
|
||||
|
||||
$tMap->addForeignKey('DISPATCH_ORDER_ID', 'DispatchOrderId', 'int', CreoleTypes::INTEGER, 'st_paczkomaty_dispatch_order', 'ID', false, null);
|
||||
|
||||
} // doBuild()
|
||||
|
||||
} // PaczkomatyPackMapBuilder
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,691 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Base static class for performing query and update operations on the 'st_paczkomaty_dispatch_order' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package plugins.stPaczkomatyPlugin.lib.model.om
|
||||
*/
|
||||
abstract class BasePaczkomatyDispatchOrderPeer {
|
||||
|
||||
/** the default database name for this class */
|
||||
const DATABASE_NAME = 'propel';
|
||||
|
||||
/** the table name for this class */
|
||||
const TABLE_NAME = 'st_paczkomaty_dispatch_order';
|
||||
|
||||
/** A class that can be returned by this peer. */
|
||||
const CLASS_DEFAULT = 'plugins.stPaczkomatyPlugin.lib.model.PaczkomatyDispatchOrder';
|
||||
|
||||
/** 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_paczkomaty_dispatch_order.ID';
|
||||
|
||||
/** the column name for the DISPATCH_ORDER_ID field */
|
||||
const DISPATCH_ORDER_ID = 'st_paczkomaty_dispatch_order.DISPATCH_ORDER_ID';
|
||||
|
||||
/** the column name for the DISPATCH_ORDER_EXTERNAL_ID field */
|
||||
const DISPATCH_ORDER_EXTERNAL_ID = 'st_paczkomaty_dispatch_order.DISPATCH_ORDER_EXTERNAL_ID';
|
||||
|
||||
/** the column name for the CREATED_AT field */
|
||||
const CREATED_AT = 'st_paczkomaty_dispatch_order.CREATED_AT';
|
||||
|
||||
/** the column name for the STATUS field */
|
||||
const STATUS = 'st_paczkomaty_dispatch_order.STATUS';
|
||||
|
||||
/** 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', 'DispatchOrderId', 'DispatchOrderExternalId', 'CreatedAt', 'Status', ),
|
||||
BasePeer::TYPE_COLNAME => array (PaczkomatyDispatchOrderPeer::ID, PaczkomatyDispatchOrderPeer::DISPATCH_ORDER_ID, PaczkomatyDispatchOrderPeer::DISPATCH_ORDER_EXTERNAL_ID, PaczkomatyDispatchOrderPeer::CREATED_AT, PaczkomatyDispatchOrderPeer::STATUS, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id', 'dispatch_order_id', 'dispatch_order_external_id', 'created_at', 'status', ),
|
||||
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, 'DispatchOrderId' => 1, 'DispatchOrderExternalId' => 2, 'CreatedAt' => 3, 'Status' => 4, ),
|
||||
BasePeer::TYPE_COLNAME => array (PaczkomatyDispatchOrderPeer::ID => 0, PaczkomatyDispatchOrderPeer::DISPATCH_ORDER_ID => 1, PaczkomatyDispatchOrderPeer::DISPATCH_ORDER_EXTERNAL_ID => 2, PaczkomatyDispatchOrderPeer::CREATED_AT => 3, PaczkomatyDispatchOrderPeer::STATUS => 4, ),
|
||||
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'dispatch_order_id' => 1, 'dispatch_order_external_id' => 2, 'created_at' => 3, 'status' => 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.stPaczkomatyPlugin.lib.model.map.PaczkomatyDispatchOrderMapBuilder');
|
||||
}
|
||||
/**
|
||||
* 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 = PaczkomatyDispatchOrderPeer::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. PaczkomatyDispatchOrderPeer::COLUMN_NAME).
|
||||
* @return string
|
||||
*/
|
||||
public static function alias($alias, $column)
|
||||
{
|
||||
return str_replace(PaczkomatyDispatchOrderPeer::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(PaczkomatyDispatchOrderPeer::ID);
|
||||
|
||||
$criteria->addSelectColumn(PaczkomatyDispatchOrderPeer::DISPATCH_ORDER_ID);
|
||||
|
||||
$criteria->addSelectColumn(PaczkomatyDispatchOrderPeer::DISPATCH_ORDER_EXTERNAL_ID);
|
||||
|
||||
$criteria->addSelectColumn(PaczkomatyDispatchOrderPeer::CREATED_AT);
|
||||
|
||||
$criteria->addSelectColumn(PaczkomatyDispatchOrderPeer::STATUS);
|
||||
|
||||
|
||||
if (stEventDispatcher::getInstance()->getListeners('PaczkomatyDispatchOrderPeer.postAddSelectColumns')) {
|
||||
stEventDispatcher::getInstance()->notify(new sfEvent($criteria, 'PaczkomatyDispatchOrderPeer.postAddSelectColumns'));
|
||||
}
|
||||
}
|
||||
|
||||
const COUNT = 'COUNT(st_paczkomaty_dispatch_order.ID)';
|
||||
const COUNT_DISTINCT = 'COUNT(DISTINCT st_paczkomaty_dispatch_order.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(PaczkomatyDispatchOrderPeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(PaczkomatyDispatchOrderPeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$rs = PaczkomatyDispatchOrderPeer::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 PaczkomatyDispatchOrder
|
||||
* @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 = PaczkomatyDispatchOrderPeer::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 PaczkomatyDispatchOrder[]
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelect(Criteria $criteria, $con = null)
|
||||
{
|
||||
return PaczkomatyDispatchOrderPeer::populateObjects(PaczkomatyDispatchOrderPeer::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;
|
||||
PaczkomatyDispatchOrderPeer::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 = PaczkomatyDispatchOrderPeer::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 PaczkomatyDispatchOrderPeer::CLASS_DEFAULT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform an INSERT on the database, given a PaczkomatyDispatchOrder or Criteria object.
|
||||
*
|
||||
* @param mixed $values Criteria or PaczkomatyDispatchOrder 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('BasePaczkomatyDispatchOrderPeer:doInsert:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, 'BasePaczkomatyDispatchOrderPeer', $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 PaczkomatyDispatchOrder object
|
||||
}
|
||||
|
||||
$criteria->remove(PaczkomatyDispatchOrderPeer::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('BasePaczkomatyDispatchOrderPeer:doInsert:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, 'BasePaczkomatyDispatchOrderPeer', $values, $con, $pk);
|
||||
}
|
||||
|
||||
return $pk;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform an UPDATE on the database, given a PaczkomatyDispatchOrder or Criteria object.
|
||||
*
|
||||
* @param mixed $values Criteria or PaczkomatyDispatchOrder 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('BasePaczkomatyDispatchOrderPeer:doUpdate:pre') as $callable)
|
||||
{
|
||||
$ret = call_user_func($callable, 'BasePaczkomatyDispatchOrderPeer', $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(PaczkomatyDispatchOrderPeer::ID);
|
||||
$selectCriteria->add(PaczkomatyDispatchOrderPeer::ID, $criteria->remove(PaczkomatyDispatchOrderPeer::ID), $comparison);
|
||||
|
||||
} else { // $values is PaczkomatyDispatchOrder 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('BasePaczkomatyDispatchOrderPeer:doUpdate:post') as $callable)
|
||||
{
|
||||
call_user_func($callable, 'BasePaczkomatyDispatchOrderPeer', $values, $con, $ret);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to DELETE all rows from the st_paczkomaty_dispatch_order 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();
|
||||
PaczkomatyDispatchOrderPeer::doOnDeleteSetNull(new Criteria(), $con);
|
||||
$affectedRows += BasePeer::doDeleteAll(PaczkomatyDispatchOrderPeer::TABLE_NAME, $con);
|
||||
$con->commit();
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform a DELETE on the database, given a PaczkomatyDispatchOrder or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or PaczkomatyDispatchOrder 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(PaczkomatyDispatchOrderPeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
} elseif ($values instanceof PaczkomatyDispatchOrder) {
|
||||
|
||||
$criteria = $values->buildPkeyCriteria();
|
||||
} else {
|
||||
// it must be the primary key
|
||||
$criteria = new Criteria(self::DATABASE_NAME);
|
||||
$criteria->add(PaczkomatyDispatchOrderPeer::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();
|
||||
PaczkomatyDispatchOrderPeer::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 = PaczkomatyDispatchOrderPeer::doSelect($criteria, $con);
|
||||
foreach($objects as $obj) {
|
||||
|
||||
// set fkey col in related PaczkomatyPack rows to NULL
|
||||
$selectCriteria = new Criteria(PaczkomatyDispatchOrderPeer::DATABASE_NAME);
|
||||
$updateValues = new Criteria(PaczkomatyDispatchOrderPeer::DATABASE_NAME);
|
||||
$selectCriteria->add(PaczkomatyPackPeer::DISPATCH_ORDER_ID, $obj->getId());
|
||||
$updateValues->add(PaczkomatyPackPeer::DISPATCH_ORDER_ID, null);
|
||||
|
||||
BasePeer::doUpdate($selectCriteria, $updateValues, $con); // use BasePeer because generated Peer doUpdate() methods only update using pkey
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates all modified columns of given PaczkomatyDispatchOrder 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 PaczkomatyDispatchOrder $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(PaczkomatyDispatchOrder $obj, $cols = null)
|
||||
{
|
||||
$columns = array();
|
||||
|
||||
if ($cols) {
|
||||
$dbMap = Propel::getDatabaseMap(PaczkomatyDispatchOrderPeer::DATABASE_NAME);
|
||||
$tableMap = $dbMap->getTable(PaczkomatyDispatchOrderPeer::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(PaczkomatyDispatchOrderPeer::DATABASE_NAME, PaczkomatyDispatchOrderPeer::TABLE_NAME, $columns);
|
||||
if ($res !== true) {
|
||||
$request = sfContext::getInstance()->getRequest();
|
||||
foreach ($res as $failed) {
|
||||
$col = PaczkomatyDispatchOrderPeer::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 PaczkomatyDispatchOrder
|
||||
*/
|
||||
public static function retrieveByPK($pk, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$criteria = new Criteria(PaczkomatyDispatchOrderPeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(PaczkomatyDispatchOrderPeer::ID, $pk);
|
||||
|
||||
|
||||
$v = PaczkomatyDispatchOrderPeer::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 PaczkomatyDispatchOrder[]
|
||||
*/
|
||||
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(PaczkomatyDispatchOrderPeer::ID, $pks, Criteria::IN);
|
||||
$objs = PaczkomatyDispatchOrderPeer::doSelect($criteria, $con);
|
||||
}
|
||||
return $objs;
|
||||
}
|
||||
|
||||
} // BasePaczkomatyDispatchOrderPeer
|
||||
|
||||
// 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 {
|
||||
BasePaczkomatyDispatchOrderPeer::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.stPaczkomatyPlugin.lib.model.map.PaczkomatyDispatchOrderMapBuilder');
|
||||
}
|
||||
2179
plugins/stPaczkomatyPlugin/lib/model/om/BasePaczkomatyPack.php
Normal file
2179
plugins/stPaczkomatyPlugin/lib/model/om/BasePaczkomatyPack.php
Normal file
File diff suppressed because it is too large
Load Diff
1312
plugins/stPaczkomatyPlugin/lib/model/om/BasePaczkomatyPackPeer.php
Normal file
1312
plugins/stPaczkomatyPlugin/lib/model/om/BasePaczkomatyPackPeer.php
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user