diff --git a/local/modules/MondialRelay/Config/config-data.json b/local/modules/MondialRelay/Config/config-data.json new file mode 100644 index 00000000..badcd50d --- /dev/null +++ b/local/modules/MondialRelay/Config/config-data.json @@ -0,0 +1,269 @@ +{ + "shippingZones": [ + { + "name": "Mondial Relay - Relay delivery Zone 1", + "delivery_time_in_days": 3, + "delivery_type": 1, + "countries": [ + "FRA", + "BEL", + "LUX", + "MCO" + ], + "prices": [ + { + "up_to": 0.5, + "price_euro": 4.55 + }, + { + "up_to": 1, + "price_euro": 5.25 + }, + { + "up_to": 2, + "price_euro": 5.95 + }, + { + "up_to": 3, + "price_euro": 6.80 + }, + { + "up_to": 5, + "price_euro": 8 + }, + { + "up_to": 7, + "price_euro": 10.50 + }, + { + "up_to": 10, + "price_euro": 12.75 + }, + { + "up_to": 15, + "price_euro": 15.35 + }, + { + "up_to": 30, + "price_euro": 19.10 + } + ] + }, + { + "name": "Mondial Relay - Relay delivery Zone 2", + "delivery_time_in_days": 5, + "delivery_type": 1, + "countries": [ + "ESP" + ], + "prices": [ + { + "up_to": 0.5, + "price_euro": 8.40 + }, + { + "up_to": 1, + "price_euro": 9 + }, + { + "up_to": 2, + "price_euro": 9.80 + }, + { + "up_to": 3, + "price_euro": 10.50 + }, + { + "up_to": 5, + "price_euro": 12.80 + }, + { + "up_to": 7, + "price_euro": 15.20 + }, + { + "up_to": 10, + "price_euro": 17.40 + }, + { + "up_to": 15, + "price_euro": 22.80 + }, + { + "up_to": 30, + "price_euro": 27.50 + } + ] + }, + { + "name": "Mondial Relay - Home delivery Zone 1", + "delivery_time_in_days": 3, + "delivery_type": 2, + "countries": [ + "DEU", + "BEL", + "LUX" + ], + "prices": [ + { + "up_to": 0.5, + "price_euro": 9.50 + }, + { + "up_to": 1, + "price_euro": 9.50 + }, + { + "up_to": 2, + "price_euro": 10.20 + }, + { + "up_to": 3, + "price_euro": 10.90 + }, + { + "up_to": 5, + "price_euro": 12.30 + }, + { + "up_to": 7, + "price_euro": 13.70 + }, + { + "up_to": 10, + "price_euro": 15.80 + }, + { + "up_to": 15, + "price_euro": 19.30 + }, + { + "up_to": 30, + "price_euro": 29.80 + } + ] + }, + { + "name": "Mondial Relay - Home delivery Zone 2", + "delivery_time_in_days": 5, + "delivery_type": 2, + "countries": [ + "GBR", + "ESP" + ], + "prices": [ + { + "up_to": 0.5, + "price_euro": 10.20 + }, + { + "up_to": 1, + "price_euro": 10.20 + }, + { + "up_to": 2, + "price_euro": 11.30 + }, + { + "up_to": 3, + "price_euro": 12.40 + }, + { + "up_to": 5, + "price_euro": 14.60 + }, + { + "up_to": 7, + "price_euro": 16.80 + }, + { + "up_to": 10, + "price_euro": 20.10 + }, + { + "up_to": 15, + "price_euro": 25.60 + }, + { + "up_to": 30, + "price_euro": 36.60 + } + ] + }, + { + "name": "Mondial Relay - Home delivery Zone 3", + "delivery_time_in_days": 6, + "delivery_type": 2, + "countries": [ + "ITA", + "PRT", + "AUT" + ], + "prices": [ + { + "up_to": 0.5, + "price_euro": 11.20 + }, + { + "up_to": 1, + "price_euro": 11.20 + }, + { + "up_to": 2, + "price_euro": 12.30 + }, + { + "up_to": 3, + "price_euro": 13.40 + }, + { + "up_to": 5, + "price_euro": 15.60 + }, + { + "up_to": 7, + "price_euro": 17.80 + }, + { + "up_to": 10, + "price_euro": 21.10 + }, + { + "up_to": 15, + "price_euro": 26.60 + }, + { + "up_to": 30, + "price_euro": 37.60 + } + ] + } + ], + "insurances": [ + { + "level": 1, + "value": 50, + "price_with_tax_euro": 2 + }, + { + "level": 2, + "value": 125, + "price_with_tax_euro": 3.50 + }, + { + "level": 3, + "value": 250, + "price_with_tax_euro": 5 + }, + { + "level": 4, + "value": 375, + "price_with_tax_euro": 6.50 + }, + { + "level": 5, + "value": 500, + "price_with_tax_euro": 8 + } + ] +} diff --git a/local/modules/MondialRelay/Config/config.xml b/local/modules/MondialRelay/Config/config.xml new file mode 100644 index 00000000..da38c0d4 --- /dev/null +++ b/local/modules/MondialRelay/Config/config.xml @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/local/modules/MondialRelay/Config/drop.sql b/local/modules/MondialRelay/Config/drop.sql new file mode 100644 index 00000000..1bc8e1d5 --- /dev/null +++ b/local/modules/MondialRelay/Config/drop.sql @@ -0,0 +1,8 @@ +SET FOREIGN_KEY_CHECKS = 0; + +DROP TABLE IF EXISTS `mondial_relay_pickup_address`; +DROP TABLE IF EXISTS `mondial_relay_delivery_price`; +DROP TABLE IF EXISTS `mondial_relay_delivery_insurance`; +DROP TABLE IF EXISTS `mondial_relay_zone_configuration`; + +SET FOREIGN_KEY_CHECKS = 1; diff --git a/local/modules/MondialRelay/Config/module.xml b/local/modules/MondialRelay/Config/module.xml new file mode 100644 index 00000000..21a86e95 --- /dev/null +++ b/local/modules/MondialRelay/Config/module.xml @@ -0,0 +1,26 @@ + + + MondialRelay\MondialRelay + + Mondial Relay delivery + + + Livraison avec Mondial Relay + + + en_US + fr_FR + + 1.0.7 + + Franck Allimant + CQFDev + thelia@cqfdev.fr + www.cqfdev.fr + + delivery + 2.3.0 + prod + diff --git a/local/modules/MondialRelay/Config/routing.xml b/local/modules/MondialRelay/Config/routing.xml new file mode 100644 index 00000000..6038551b --- /dev/null +++ b/local/modules/MondialRelay/Config/routing.xml @@ -0,0 +1,64 @@ + + + + + + + + + MondialRelay\Controller\BackOffice\ConfigurationController::saveAction + + + + + + + MondialRelay\Controller\BackOffice\AreaAttributesController::saveAction + \d+ + \d+ + + + + + + MondialRelay\Controller\BackOffice\PriceController::saveAction + \d+ + \d+ + + + + MondialRelay\Controller\BackOffice\PriceController::createAction + \d+ + \d+ + + + + MondialRelay\Controller\BackOffice\PriceController::deleteAction + \d+ + \d+ + + + + + + MondialRelay\Controller\BackOffice\InsuranceController::saveAction + + + + MondialRelay\Controller\BackOffice\InsuranceController::createAction + + + + MondialRelay\Controller\BackOffice\InsuranceController::deleteAction + \d+ + + + + + + MondialRelay\Controller\FrontOffice\MapManagement::getRelayMapAction + + + diff --git a/local/modules/MondialRelay/Config/schema.xml b/local/modules/MondialRelay/Config/schema.xml new file mode 100644 index 00000000..9fe7b73d --- /dev/null +++ b/local/modules/MondialRelay/Config/schema.xml @@ -0,0 +1,42 @@ + + + + + + + +
+ + + + + + + + + + +
+ + + + + + +
+ + + + + + + + + + +
+ + +
diff --git a/local/modules/MondialRelay/Config/thelia.sql b/local/modules/MondialRelay/Config/thelia.sql new file mode 100644 index 00000000..59ad01ba --- /dev/null +++ b/local/modules/MondialRelay/Config/thelia.sql @@ -0,0 +1,78 @@ + +# This is a fix for InnoDB in MySQL >= 4.1.x +# It "suspends judgement" for fkey relationships until are tables are set. +SET FOREIGN_KEY_CHECKS = 0; + +-- --------------------------------------------------------------------- +-- mondial_relay_pickup_address +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `mondial_relay_pickup_address`; + +CREATE TABLE `mondial_relay_pickup_address` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `json_relay_data` LONGTEXT NOT NULL, + `order_address_id` INTEGER NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB; + +-- --------------------------------------------------------------------- +-- mondial_relay_delivery_price +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `mondial_relay_delivery_price`; + +CREATE TABLE `mondial_relay_delivery_price` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `max_weight` DECIMAL(16,6) DEFAULT 0.000000 NOT NULL, + `price_with_tax` DECIMAL(16,6) DEFAULT 0.000000 NOT NULL, + `area_id` INTEGER NOT NULL, + PRIMARY KEY (`id`), + INDEX `fi_mondial_relay_delivery_price_area_id` (`area_id`), + CONSTRAINT `fk_mondial_relay_delivery_price_area_id` + FOREIGN KEY (`area_id`) + REFERENCES `area` (`id`) + ON UPDATE RESTRICT + ON DELETE CASCADE +) ENGINE=InnoDB; + +-- --------------------------------------------------------------------- +-- mondial_relay_delivery_insurance +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `mondial_relay_delivery_insurance`; + +CREATE TABLE `mondial_relay_delivery_insurance` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `level` INTEGER NOT NULL, + `max_value` DECIMAL(16,6) DEFAULT 0.000000 NOT NULL, + `price_with_tax` DECIMAL(16,6) DEFAULT 0.000000 NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB; + +-- --------------------------------------------------------------------- +-- mondial_relay_zone_configuration +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `mondial_relay_zone_configuration`; + +CREATE TABLE `mondial_relay_zone_configuration` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `delivery_time` INTEGER NOT NULL, + `delivery_type` INTEGER(1) NOT NULL, + `area_id` INTEGER NOT NULL, + PRIMARY KEY (`id`), + INDEX `fi_mondial_relay_zone_configuration_area_id` (`area_id`), + CONSTRAINT `fk_mondial_relay_zone_configuration_area_id` + FOREIGN KEY (`area_id`) + REFERENCES `area` (`id`) + ON UPDATE RESTRICT + ON DELETE CASCADE +) ENGINE=InnoDB; + +# This restores the fkey checks, after having unset them earlier +SET FOREIGN_KEY_CHECKS = 1; diff --git a/local/modules/MondialRelay/Controller/BackOffice/AreaAttributesController.php b/local/modules/MondialRelay/Controller/BackOffice/AreaAttributesController.php new file mode 100644 index 00000000..5f76b0fa --- /dev/null +++ b/local/modules/MondialRelay/Controller/BackOffice/AreaAttributesController.php @@ -0,0 +1,61 @@ + + */ +class AreaAttributesController extends BaseAdminController +{ + public function saveAction($areaId, $moduleId) + { + if (null !== $response = $this->checkAuth(AdminResources::MODULE, 'MondialRelay', AccessManager::UPDATE)) { + return $response; + } + + $form = $this->createForm('mondialrelay.area_attributes_update_form'); + + $errorMessage = false; + + try { + $viewForm = $this->validateForm($form); + + $data = $viewForm->getData(); + + if (null === $zoneConfig = MondialRelayZoneConfigurationQuery::create()->findOneByAreaId($areaId)) { + $zoneConfig = new MondialRelayZoneConfiguration(); + } + + $zoneConfig + ->setAreaId($areaId) + ->setDeliveryTime($data['delivery_time']) + ->setDeliveryType($data['delivery_type']) + ->save(); + + } catch (\Exception $ex) { + $errorMessage = $ex->getMessage(); + + Tlog::getInstance()->error("Failed to validate area attributes form: $errorMessage"); + } + + return $this->render('mondialrelay/ajax/prices', [ + 'module_id' => $moduleId, + 'error_message' => $errorMessage + ]); + } +} diff --git a/local/modules/MondialRelay/Controller/BackOffice/ConfigurationController.php b/local/modules/MondialRelay/Controller/BackOffice/ConfigurationController.php new file mode 100644 index 00000000..21c941d6 --- /dev/null +++ b/local/modules/MondialRelay/Controller/BackOffice/ConfigurationController.php @@ -0,0 +1,50 @@ + + */ +class ConfigurationController extends BaseAdminController +{ + public function saveAction() + { + if (null !== $response = $this->checkAuth(AdminResources::MODULE, 'MondialRelay', AccessManager::UPDATE)) { + return $response; + } + + $form = $this->createForm('mondialrelay.settings_form'); + + $errorMessage = false; + + try { + $viewForm = $this->validateForm($form); + + $data = $viewForm->getData(); + + foreach ($data as $name => $value) { + MondialRelay::setConfigValue($name, $value); + } + } catch (\Exception $ex) { + $errorMessage = $ex->getMessage(); + + Tlog::getInstance()->error("Failed to validate configuration form: $errorMessage"); + } + + return $this->render('mondialrelay/ajax/general', [ 'error_message' => $errorMessage ]); + } +} diff --git a/local/modules/MondialRelay/Controller/BackOffice/InsuranceController.php b/local/modules/MondialRelay/Controller/BackOffice/InsuranceController.php new file mode 100644 index 00000000..7447ace0 --- /dev/null +++ b/local/modules/MondialRelay/Controller/BackOffice/InsuranceController.php @@ -0,0 +1,102 @@ + + */ +class InsuranceController extends BaseAdminController +{ + public function saveAction() + { + if (null !== $response = $this->checkAuth(AdminResources::MODULE, 'MondialRelay', AccessManager::UPDATE)) { + return $response; + } + + $form = $this->createForm('mondialrelay.insurances_update_form'); + + $errorMessage = false; + + try { + $viewForm = $this->validateForm($form); + + $data = $viewForm->getData(); + + foreach ($data['max_value'] as $key => $value) { + if (null !== $insurance = MondialRelayDeliveryInsuranceQuery::create()->findPk($key)) { + $insurance + ->setMaxValue($value) + ->setPriceWithTax($data['price_with_tax'][$key]) + ->save(); + } + } + } catch (\Exception $ex) { + $errorMessage = $ex->getMessage(); + + Tlog::getInstance()->error("Failed to validate insurances form: $errorMessage"); + } + + return $this->render('mondialrelay/ajax/insurances', [ 'error_message' => $errorMessage ]); + } + + public function createAction() + { + if (null !== $response = $this->checkAuth(AdminResources::MODULE, 'MondialRelay', AccessManager::UPDATE)) { + return $response; + } + + $form = $this->createForm('mondialrelay.insurance_create_form'); + + $errorMessage = false; + + try { + $viewForm = $this->validateForm($form); + + $data = $viewForm->getData(); + + MondialRelayDeliveryInsuranceQuery::create()->filterByMaxValue($data['max_value'])->delete(); + + (new MondialRelayDeliveryInsurance()) + ->setPriceWithTax($data['price_with_tax']) + ->setMaxValue($data['max_value']) + ->save(); + } catch (\Exception $ex) { + $errorMessage = $ex->getMessage(); + + Tlog::getInstance()->error("Failed to validate insurances form: $errorMessage"); + } + + return $this->render('mondialrelay/ajax/insurances', [ 'error_message' => $errorMessage ]); + } + + /** + * @param $insuranceId + * @return mixed|\Thelia\Core\HttpFoundation\Response + * @throws \Propel\Runtime\Exception\PropelException + */ + public function deleteAction($insuranceId) + { + if (null !== $response = $this->checkAuth(AdminResources::MODULE, 'MondialRelay', AccessManager::DELETE)) { + return $response; + } + + MondialRelayDeliveryInsuranceQuery::create()->filterById($insuranceId)->delete(); + + return $this->render('mondialrelay/ajax/insurances'); + } +} diff --git a/local/modules/MondialRelay/Controller/BackOffice/PriceController.php b/local/modules/MondialRelay/Controller/BackOffice/PriceController.php new file mode 100644 index 00000000..807446c2 --- /dev/null +++ b/local/modules/MondialRelay/Controller/BackOffice/PriceController.php @@ -0,0 +1,111 @@ + + */ +class PriceController extends BaseAdminController +{ + public function saveAction($areaId, $moduleId) + { + if (null !== $response = $this->checkAuth(AdminResources::MODULE, 'MondialRelay', AccessManager::UPDATE)) { + return $response; + } + + $form = $this->createForm('mondialrelay.prices_update_form'); + + $errorMessage = false; + + try { + $viewForm = $this->validateForm($form); + + $data = $viewForm->getData(); + + MondialRelayDeliveryPriceQuery::create()->filterByAreaId($areaId)->delete(); + + foreach ($data['max_weight'] as $key => $value) { + (new MondialRelayDeliveryPrice()) + ->setAreaId($areaId) + ->setMaxWeight($value) + ->setPriceWithTax($data['price'][$key]) + ->save(); + } + + } catch (\Exception $ex) { + $errorMessage = $ex->getMessage(); + + Tlog::getInstance()->error("Failed to validate price form: $errorMessage"); + } + + return $this->render('mondialrelay/ajax/prices', [ + 'module_id' => $moduleId, + 'error_message' => $errorMessage + ]); + } + + public function createAction($areaId, $moduleId) + { + if (null !== $response = $this->checkAuth(AdminResources::MODULE, 'MondialRelay', AccessManager::UPDATE)) { + return $response; + } + + $form = $this->createForm('mondialrelay.price_form'); + + $errorMessage = false; + + try { + $viewForm = $this->validateForm($form); + + $data = $viewForm->getData(); + + MondialRelayDeliveryPriceQuery::create()->filterByMaxWeight($data['max_weight'])->delete(); + + (new MondialRelayDeliveryPrice()) + ->setAreaId($areaId) + ->setPriceWithTax($data['price']) + ->setMaxWeight($data['max_weight']) + ->save(); + } catch (\Exception $ex) { + $errorMessage = $ex->getMessage(); + + Tlog::getInstance()->error("Failed to validate price form: $errorMessage"); + } + + return $this->render('mondialrelay/ajax/prices', [ + 'module_id' => $moduleId, + 'error_message' => $errorMessage + ]); + } + + /** + * @param $insuranceId + * @return mixed|\Thelia\Core\HttpFoundation\Response + * @throws \Propel\Runtime\Exception\PropelException + */ + public function deleteAction($priceId, $moduleId) + { + if (null !== $response = $this->checkAuth(AdminResources::MODULE, 'MondialRelay', AccessManager::DELETE)) { + return $response; + } + + MondialRelayDeliveryPriceQuery::create()->filterById($priceId)->delete(); + + return $this->render('mondialrelay/ajax/prices', [ 'module_id' => $moduleId ]); + } +} diff --git a/local/modules/MondialRelay/Controller/FrontOffice/MapManagement.php b/local/modules/MondialRelay/Controller/FrontOffice/MapManagement.php new file mode 100644 index 00000000..00411c98 --- /dev/null +++ b/local/modules/MondialRelay/Controller/FrontOffice/MapManagement.php @@ -0,0 +1,44 @@ + + * Date: 12/03/2018 10:41 + */ + +namespace MondialRelay\Controller\FrontOffice; + +use MondialRelay\Event\FindRelayEvent; +use MondialRelay\Event\MondialRelayEvents; +use Thelia\Controller\Front\BaseFrontController; +use Thelia\Core\HttpFoundation\JsonResponse; + +require __DIR__ . "/../../vendor/autoload.php"; + +class MapManagement extends BaseFrontController +{ + public function getRelayMapAction() + { + $event = new FindRelayEvent( + intval($this->getRequest()->get('country_id', 0)), + $this->getRequest()->get('city', ''), + $this->getRequest()->get('zipcode', ''), + floatval($this->getRequest()->get('radius', 10)) + ); + + $this->getDispatcher()->dispatch(MondialRelayEvents::FIND_RELAYS, $event); + + + return new JsonResponse([ + 'points' => $event->getPoints(), + 'error' => $event->getError() + ]); + } +} diff --git a/local/modules/MondialRelay/Event/FindRelayEvent.php b/local/modules/MondialRelay/Event/FindRelayEvent.php new file mode 100644 index 00000000..31693538 --- /dev/null +++ b/local/modules/MondialRelay/Event/FindRelayEvent.php @@ -0,0 +1,151 @@ + + * Date: 28/04/2016 14:41 + */ +namespace MondialRelay\Event; + +use Thelia\Core\Event\ActionEvent; + +class FindRelayEvent extends ActionEvent +{ + /** @var int */ + protected $countryId; + + /** @var string */ + protected $city; + + /** @var string */ + protected $zipcode; + + /** @var float */ + protected $searchRadius; + + /** @var array */ + protected $points; + + /** @var string */ + protected $numPointRelais = ''; + + /** @var bool */ + protected $error = ''; + + /** + * FindRelayEvent constructor. + * @param int $countryId + * @param string $city + * @param string $zipcode + * @param float $searchRadius + */ + public function __construct($countryId, $city, $zipcode, $searchRadius) + { + $this->countryId = $countryId; + $this->city = $city; + $this->zipcode = $zipcode; + $this->searchRadius = $searchRadius; + } + + /** + * @return int + */ + public function getCountryId() + { + return $this->countryId; + } + + /** + * @return string + */ + public function getCity() + { + return $this->city; + } + + /** + * @return string + */ + public function getZipcode() + { + return $this->zipcode; + } + + /** + * @return float + */ + public function getSearchRadius() + { + return $this->searchRadius; + } + + /** + * @return array + */ + public function getPoints() + { + return $this->points; + } + + /** + * @param array $points + * @return $this + */ + public function setPoints($points) + { + $this->points = $points; + return $this; + } + + /** + * @return string + */ + public function getNumPointRelais() + { + return $this->numPointRelais; + } + + /** + * @param string $numPointRelais + * @return $this + */ + public function setNumPointRelais($numPointRelais) + { + $this->numPointRelais = $numPointRelais; + return $this; + } + + /** + * @return bool + */ + public function hasError() + { + return ! empty($this->error); + } + + /** + * @param string $error + * @return $this + */ + public function setError($error) + { + $this->error = $error; + return $this; + } + + /** + * @return string $error + */ + public function getError() + { + return $this->error; + } +} diff --git a/local/modules/MondialRelay/Event/MondialRelayEvents.php b/local/modules/MondialRelay/Event/MondialRelayEvents.php new file mode 100644 index 00000000..8dbb215d --- /dev/null +++ b/local/modules/MondialRelay/Event/MondialRelayEvents.php @@ -0,0 +1,21 @@ + + * Date: 12/03/2018 19:39 + */ + +namespace MondialRelay\Event; + +class MondialRelayEvents +{ + const FIND_RELAYS = "mondialrelay.event.find-relays"; +} diff --git a/local/modules/MondialRelay/EventListeners/DeliveryListener.php b/local/modules/MondialRelay/EventListeners/DeliveryListener.php new file mode 100644 index 00000000..a3e26ab6 --- /dev/null +++ b/local/modules/MondialRelay/EventListeners/DeliveryListener.php @@ -0,0 +1,432 @@ +requestStack = $requestStack; + } + + /** + * @return ApiClient + * @throws \SoapFault + */ + protected function getWebServiceClient() + { + return new ApiClient( + new \SoapClient( + MondialRelay::getConfigValue(MondialRelay::WEBSERVICE_URL) + ), + MondialRelay::getConfigValue(MondialRelay::CODE_ENSEIGNE), + MondialRelay::getConfigValue(MondialRelay::PRIVATE_KEY) + ); + } + + /** + * @param DeliveryPostageEvent $event + * @param $eventName + * @param EventDispatcherInterface $dispatcher + * @throws \Exception + * @throws \Propel\Runtime\Exception\PropelException + */ + public function processDeliveryPostageEvent(DeliveryPostageEvent $event, $eventName, EventDispatcherInterface $dispatcher) + { + $valid = false; + + /** @var Request $session */ + $request = $this->requestStack->getCurrentRequest(); + + /** @var Session $session */ + $session = $request->getSession(); + + // Get and store selected delivery type, if it is defined + switch($request->get('mondial-relay-selected-delivery-mode')) { + case 'pickup': + $selectedDeliveryType = MondialRelayZoneConfiguration::RELAY_DELIVERY_TYPE; + break; + case 'home': + $selectedDeliveryType = MondialRelayZoneConfiguration::HOME_DELIVERY_TYPE; + break; + default: + $selectedDeliveryType = $session->get(MondialRelay::SESSION_SELECTED_DELIVERY_TYPE); + } + + if (null !== $selectedDeliveryType) { + $session->set(MondialRelay::SESSION_SELECTED_DELIVERY_TYPE, $selectedDeliveryType); + } + + // Use the minimum weight if the cart is below this minimum. + $weight = max(MondialRelay::MIN_WEIGHT_KG, $session->getSessionCart($dispatcher)->getWeight()); + + if ($weight <= MondialRelay::MAX_WEIGHT_KG) { + $moduleModel = ModuleQuery::create()->findOneByCode(MondialRelay::getModuleCode()); + + // Find all allowed delivery types for the destination country + $countryHasRelay = $countryHasHome = false; + + $countryInAreaList = CountryAreaQuery::findByCountryAndState($event->getCountry(), $event->getState()); + + $price = PHP_INT_MAX; + + /** @var CountryArea $countryInArea */ + foreach ($countryInAreaList as $countryInArea) { + $areas = AreaDeliveryModuleQuery::create()->filterByAreaId($countryInArea->getAreaId()) + ->filterByModule($moduleModel) + ->find(); + + /** @var AreaDeliveryModule $area */ + foreach ($areas as $area) { + if (null !== $zoneConfig = MondialRelayZoneConfigurationQuery::create()->findOneByAreaId($area->getAreaId())) { + $zoneDeliveryType = $zoneConfig->getDeliveryType(); + + switch ($zoneDeliveryType) { + case MondialRelayZoneConfiguration::ALL_DELIVERY_TYPE: + $countryHasRelay = $countryHasHome = true; + break; + case MondialRelayZoneConfiguration::HOME_DELIVERY_TYPE: + $countryHasHome = true; + break; + case MondialRelayZoneConfiguration::RELAY_DELIVERY_TYPE: + $countryHasRelay = true; + break; + } + + // If the area delivery type matches the selected one, or if no zone is selected + if (null === $selectedDeliveryType || $zoneDeliveryType === $selectedDeliveryType) { + // Check if we have a price slice + if (null !== $deliveryPrice = MondialRelayDeliveryPriceQuery::create() + ->filterByAreaId($area->getAreaId()) + ->filterByMaxWeight($weight, Criteria::GREATER_EQUAL) + ->orderByMaxWeight(Criteria::ASC) + ->findOne()) { + $price = min($price, $deliveryPrice->getPriceWithTax()); + + $deliveryDelay = $zoneConfig->getDeliveryTime(); + } + } + } + } + } + + $relayAllowed = MondialRelay::getConfigValue(MondialRelay::ALLOW_RELAY_DELIVERY, true); + $homeAllowed = MondialRelay::getConfigValue(MondialRelay::ALLOW_HOME_DELIVERY, true); + + if (($countryHasHome && $homeAllowed) || ($countryHasRelay && $relayAllowed) && $price !== PHP_INT_MAX) { + // The module could be used ! + $valid = true; + + $deliveryDate = (new \DateTime())->add(new \DateInterval("P" . $deliveryDelay . "D")); + + $event + ->setPostage($price) + ->setDeliveryDate($deliveryDate); + } + } + + $event->setValidModule($valid); + + $event->stopPropagation(); + } + + protected function makeHoraire($str) + { + return substr($str, 0, 2) . ':' . substr($str, 2); + } + + /** + * @param FindRelayEvent $event + * @param $eventName + * @param EventDispatcherInterface $dispatcher + * @throws \Exception + */ + public function findRelays(FindRelayEvent $event, $eventName, EventDispatcherInterface $dispatcher) + { + $days = [ + 'monday' => Translator::getInstance()->trans("Monday"), + 'tuesday' => Translator::getInstance()->trans("Tuesday"), + 'wednesday' => Translator::getInstance()->trans("Wednesday"), + 'thursday' => Translator::getInstance()->trans("Thursday"), + 'friday' => Translator::getInstance()->trans("Friday"), + 'saturday' => Translator::getInstance()->trans("Saturday"), + 'sunday' => Translator::getInstance()->trans("Sunday") + ]; + + $points = []; + + if (null !== $country = CountryQuery::create()->findPk($event->getCountryId())) { + $apiClient = new ApiClient( + new \SoapClient(MondialRelay::getConfigValue(MondialRelay::WEBSERVICE_URL)), + MondialRelay::getConfigValue(MondialRelay::CODE_ENSEIGNE), + MondialRelay::getConfigValue(MondialRelay::PRIVATE_KEY) + ); + + $cartWeightInGrammes = 1000 * $this->requestStack + ->getCurrentRequest() + ->getSession() + ->getSessionCart($dispatcher) + ->getWeight(); + + $requestParams = [ + 'NumPointRelais' => $event->getNumPointRelais(), + 'Pays' => strtoupper($country->getIsoalpha2()), + 'Ville' => $event->getCity(), + 'CP' => $event->getZipcode(), + //'Latitude' => "", + //'Longitude' => "", + //'Taille' => "", + 'Poids' => $cartWeightInGrammes, + //'Action' => "", + //'DelaiEnvoi' => "0", + 'RayonRecherche' => $event->getSearchRadius() + ]; + + try { + $points = $apiClient->findDeliveryPoints($requestParams); + } catch (\Exception $ex) { + $points = []; + + $event->setError($ex->getMessage()); + } + } + + $normalizedPoints = []; + + /** @var Point $point */ + foreach ($points as $point) { + $normalizedPoint = [ + 'id' => $point->id(), + 'latitude' => $point->latitude(), + 'longitude' => $point->longitude(), + 'zipcode' => $point->cp(), + 'city' => $point->city(), + 'country' => $point->country(), + 'distance' => $point->distance(), + 'distance_km' => round($point->distance() / 1000, 1) + ]; + + $addresses = $point->address(); + + $nom = $addresses[0]; + if (! empty($adresses[1])) { + $nom .= '
' . $addresses[1]; + } + + $normalizedPoint["name"] = $nom; + + $address = $addresses[2]; + if (! empty($adresses[3])) { + $address .= '
' . $addresses[3]; + } + + $normalizedPoint["address"] = $address; + + + $horaires = []; + + /** @var BussinessHours $horaire */ + foreach ($point->business_hours() as $horaire) { + if ($horaire->openingTime1() != '0000' && $horaire->openingTime2() !== '0000') { + $data = [ 'day' => $days[$horaire->day()]]; + + $o1 = $horaire->openingTime1(); + $o2 = $horaire->openingTime2(); + + if (! empty($o1) && $o1 != '0000') { + $data['opening_time_1'] = $this->makeHoraire($horaire->openingTime1()); + $data['closing_time_1'] = $this->makeHoraire($horaire->closingTime1()); + } + + if (! empty($o2) && $o2 != '0000') { + $data['opening_time_2'] = $this->makeHoraire($horaire->openingTime2()); + $data['closing_time_2'] = $this->makeHoraire($horaire->closingTime2()); + } + + $horaires[] = $data; + } + } + + $normalizedPoint["openings"] = $horaires; + + $normalizedPoints[] = $normalizedPoint; + } + + $event->setPoints($normalizedPoints); + } + + /** + * Update the order delivery address with MondialRelay point data + * + * @param OrderEvent $event + * @throws \Propel\Runtime\Exception\PropelException + */ + public function updateOrderDeliveryAddress(OrderEvent $event) + { + /** @var Session $session */ + $session = $this->requestStack->getCurrentRequest()->getSession(); + + if (null !== $mrAddressId = $session->get(MondialRelay::SESSION_SELECTED_PICKUP_RELAY_ID)) { + if (null !== $mrRelayPickup = MondialRelayPickupAddressQuery::create()->findPk($mrAddressId)) { + if (false !== $relayData = json_decode($mrRelayPickup->getJsonRelayData(), true)) { + if (null !== $orderAddress = OrderAddressQuery::create()->findPK($event->getOrder()->getDeliveryOrderAddressId())) { + $orderAddress + ->setCompany($relayData['name']) + ->setFirstname( + Translator::getInstance()->trans( + "Pickup relay #%number", + [ '%number' => $relayData['id']], + MondialRelay::DOMAIN_NAME + ) + ) + ->setLastname('') + ->setAddress1($relayData['address']) + ->setAddress2('') + ->setAddress3('') + ->setZipcode($relayData['zipcode']) + ->setCity($relayData['city']) + ->setCountry(CountryQuery::create()->findOneByIsoalpha2($relayData['country'])) + ->save(); + + $mrRelayPickup + ->setOrderAddressId($orderAddress->getId()) + ->save(); + } + } + } + } + } + + /** + * @param OrderEvent $event + * @throws \Propel\Runtime\Exception\PropelException + */ + public function updateCurrentDeliveryAddress(OrderEvent $event, $eventName, EventDispatcherInterface $dispatcher) + { + /** @var Request $request */ + $request = $this->requestStack->getCurrentRequest(); + + /** @var Session $session */ + $session = $request->getSession(); + + // Reset stored pickup address, if any + if (null !== $mrAddressId = $session->remove(MondialRelay::SESSION_SELECTED_PICKUP_RELAY_ID)) { + // Do not delete, as the customer may have do a back, and restart another order + // MondialRelayPickupAddressQuery::create()->filterById($mrAddressId)->delete(); + } + + if ($event->getDeliveryModule() == MondialRelay::getModuleId()) { + // Check selected MondialRlay mode + $mode = $request->get('mondial-relay-selected-delivery-mode'); + + if ($mode == 'pickup') { + // Get the selected pickup relay + if (null !== $relayId = $request->get('mondialrelay_relay', null)) { + $countryId = $request->get('mondial_relay_country_id', 0); + + // Load pickup data for the selected point + $relayDataEvent = new FindRelayEvent($countryId, '', '', 0); + $relayDataEvent->setNumPointRelais($relayId); + + $dispatcher->dispatch(MondialRelayEvents::FIND_RELAYS, $relayDataEvent); + + // We're supposed to get only one point + $points = $relayDataEvent->getPoints(); + + if (isset($points[0])) { + // Create a new record to store the pickup data + $pickupAddress = new MondialRelayPickupAddress(); + $pickupAddress + ->setJsonRelayData(json_encode($points[0])) + ->save(); + + $session->set(MondialRelay::SESSION_SELECTED_PICKUP_RELAY_ID, $pickupAddress->getId()); + } + } else { + throw new TheliaProcessException("No Mondial Relay pickeup relay selected."); + } + } elseif ($mode !== 'home') { + throw new TheliaProcessException("Mondial Relay delivery mode was not selected."); + } + } + } + + /** + * Clear stored information once the order has been processed. + * + * @param OrderEvent $event + * @param $eventName + * @param EventDispatcherInterface $dispatcher + */ + public function clearDeliveryData(OrderEvent $event, $eventName, EventDispatcherInterface $dispatcher) + { + $session = $this->requestStack->getCurrentRequest()->getSession(); + + // Clear the session context + $session->remove(MondialRelay::SESSION_SELECTED_DELIVERY_TYPE); + $session->remove(MondialRelay::SESSION_SELECTED_PICKUP_RELAY_ID); + } + + public static function getSubscribedEvents() + { + return [ + TheliaEvents::getModuleEvent( + TheliaEvents::MODULE_DELIVERY_GET_POSTAGE, + MondialRelay::getModuleCode() + ) => [ "processDeliveryPostageEvent", 128 ], + TheliaEvents::ORDER_SET_DELIVERY_MODULE => ['updateCurrentDeliveryAddress', 64], + TheliaEvents::ORDER_BEFORE_PAYMENT => ['updateOrderDeliveryAddress', 256], + TheliaEvents::ORDER_CART_CLEAR => ['clearDeliveryData', 256], + + MondialRelayEvents::FIND_RELAYS => [ "findRelays" , 128] + ]; + } +} diff --git a/local/modules/MondialRelay/EventListeners/SendDeliveryEmail.php b/local/modules/MondialRelay/EventListeners/SendDeliveryEmail.php new file mode 100644 index 00000000..165f9314 --- /dev/null +++ b/local/modules/MondialRelay/EventListeners/SendDeliveryEmail.php @@ -0,0 +1,68 @@ +mailer = $mailer; + } + + /** + * @param OrderEvent $event + * @throws \Exception + * @throws \Propel\Runtime\Exception\PropelException + */ + public function updateStatus(OrderEvent $event) + { + $order = $event->getOrder(); + + $deliveryRef = $order->getDeliveryRef(); + + if ($order->isSent() + && + ! empty($deliveryRef) + && + $order->getDeliveryModuleId() == MondialRelay::getModuleId() + ) { + if (null !== $contactEmail = ConfigQuery::read('store_email')) { + $this->mailer->sendEmailToCustomer( + MondialRelay::TRACKING_MESSAGE_NAME, + $order->getCustomer(), + [ + 'order_id' => $order->getId(), + ] + ); + } + } + } + + public static function getSubscribedEvents() + { + return array( + TheliaEvents::ORDER_UPDATE_STATUS => array("updateStatus", 128) + ); + } +} diff --git a/local/modules/MondialRelay/Form/InsuranceCreateForm.php b/local/modules/MondialRelay/Form/InsuranceCreateForm.php new file mode 100644 index 00000000..9460cc94 --- /dev/null +++ b/local/modules/MondialRelay/Form/InsuranceCreateForm.php @@ -0,0 +1,42 @@ + + */ +class InsuranceCreateForm extends BaseForm +{ + protected function buildForm() + { + $this->formBuilder + ->add( + 'max_value', + 'number', + [ + "constraints" => [new GreaterThanOrEqual([ 'value' => 0 ])], + 'label' => $this->translator->trans('Cart value', [], MondialRelay::DOMAIN_NAME), + ] + )->add( + 'price_with_tax', + 'number', + [ + "constraints" => [new GreaterThanOrEqual([ 'value' => 0 ])], + 'label' => $this->translator->trans('Insurance price', [], MondialRelay::DOMAIN_NAME), + ] + ) + ; + } +} diff --git a/local/modules/MondialRelay/Form/InsurancesUpdateForm.php b/local/modules/MondialRelay/Form/InsurancesUpdateForm.php new file mode 100644 index 00000000..2f2c8d51 --- /dev/null +++ b/local/modules/MondialRelay/Form/InsurancesUpdateForm.php @@ -0,0 +1,50 @@ + + */ +class InsurancesUpdateForm extends BaseForm +{ + protected function buildForm() + { + $this->formBuilder + ->add( + 'max_value', + 'collection', + [ + "type" => 'number', + "constraints" => [new GreaterThanOrEqual([ 'value' => 0 ])], + 'label' => $this->translator->trans('Cart value', [], MondialRelay::DOMAIN_NAME), + 'label_attr' => [ ], + 'allow_add' => true, + 'allow_delete' => true, + ] + )->add( + 'price_with_tax', + 'collection', + [ + "type" => 'number', + "constraints" => [new GreaterThanOrEqual([ 'value' => 0 ])], + 'label' => $this->translator->trans('Insurance price', [], MondialRelay::DOMAIN_NAME), + 'label_attr' => [ ], + 'allow_add' => true, + 'allow_delete' => true, + ] + ) + ; + } +} diff --git a/local/modules/MondialRelay/Form/PriceAttributesUpdateForm.php b/local/modules/MondialRelay/Form/PriceAttributesUpdateForm.php new file mode 100644 index 00000000..21d85ded --- /dev/null +++ b/local/modules/MondialRelay/Form/PriceAttributesUpdateForm.php @@ -0,0 +1,47 @@ + + */ +class PriceAttributesUpdateForm extends BaseForm +{ + protected function buildForm() + { + $this->formBuilder + ->add( + 'delivery_time', + 'integer', + [ + "constraints" => [new GreaterThan([ 'value' => 0 ])], + 'label' => $this->translator->trans('Delivery delay', [], MondialRelay::DOMAIN_NAME), + ] + )->add( + 'delivery_type', + 'choice', + [ + "choices" => [ + MondialRelayZoneConfiguration::RELAY_DELIVERY_TYPE => $this->translator->trans('Relay delivery', [], MondialRelay::DOMAIN_NAME), + MondialRelayZoneConfiguration::HOME_DELIVERY_TYPE => $this->translator->trans('Home delivery', [], MondialRelay::DOMAIN_NAME), + MondialRelayZoneConfiguration::ALL_DELIVERY_TYPE => $this->translator->trans('Home and relay delivery', [], MondialRelay::DOMAIN_NAME) + ], + 'label' => $this->translator->trans('Delivery type', [], MondialRelay::DOMAIN_NAME), + ] + ) + ; + } +} diff --git a/local/modules/MondialRelay/Form/PriceCreateForm.php b/local/modules/MondialRelay/Form/PriceCreateForm.php new file mode 100644 index 00000000..cd9cd2d8 --- /dev/null +++ b/local/modules/MondialRelay/Form/PriceCreateForm.php @@ -0,0 +1,42 @@ + + */ +class PriceCreateForm extends BaseForm +{ + protected function buildForm() + { + $this->formBuilder + ->add( + 'max_weight', + 'number', + [ + "constraints" => [new GreaterThan([ 'value' => 0 ])], + 'label' => $this->translator->trans('Weight up to...', [], MondialRelay::DOMAIN_NAME), + ] + )->add( + 'price', + 'number', + [ + "constraints" => [new GreaterThan([ 'value' => 0 ])], + 'label' => $this->translator->trans('Price', [], MondialRelay::DOMAIN_NAME), + ] + ) + ; + } +} diff --git a/local/modules/MondialRelay/Form/PricesUpdateForm.php b/local/modules/MondialRelay/Form/PricesUpdateForm.php new file mode 100644 index 00000000..f92ede49 --- /dev/null +++ b/local/modules/MondialRelay/Form/PricesUpdateForm.php @@ -0,0 +1,48 @@ + + */ +class PricesUpdateForm extends BaseForm +{ + protected function buildForm() + { + $this->formBuilder + ->add( + 'max_weight', + 'collection', + [ + "type" => "number", + "constraints" => [new GreaterThan([ 'value' => 0 ])], + 'label' => $this->translator->trans('Weight up to...', [], MondialRelay::DOMAIN_NAME), + 'allow_add' => true, + 'allow_delete' => true, + ] + )->add( + 'price', + 'collection', + [ + "type" => "number", + "constraints" => [new GreaterThan([ 'value' => 0 ])], + 'label' => $this->translator->trans('Price', [], MondialRelay::DOMAIN_NAME), + 'allow_add' => true, + 'allow_delete' => true, + ] + ) + ; + } +} diff --git a/local/modules/MondialRelay/Form/SettingsForm.php b/local/modules/MondialRelay/Form/SettingsForm.php new file mode 100644 index 00000000..259aedca --- /dev/null +++ b/local/modules/MondialRelay/Form/SettingsForm.php @@ -0,0 +1,105 @@ + + */ +class SettingsForm extends BaseForm +{ + protected function buildForm() + { + $this->formBuilder + ->add( + MondialRelay::CODE_ENSEIGNE, + 'text', + [ + "constraints" => [new NotBlank()], + 'label' => $this->translator->trans('Mondial Relay store code', [], MondialRelay::DOMAIN_NAME), + 'label_attr' => [ + 'help' => $this->translator->trans('This is the store code, as provided by Mondial Relay.', [], MondialRelay::DOMAIN_NAME) + ] + + ] + )->add( + MondialRelay::PRIVATE_KEY, + 'text', + [ + "constraints" => [new NotBlank()], + 'label' => $this->translator->trans('Private key', [], MondialRelay::DOMAIN_NAME), + 'label_attr' => [ + 'help' => $this->translator->trans('Your private key, as provided by Mondial Relay.', [], MondialRelay::DOMAIN_NAME) + ] + + ] + )->add( + MondialRelay::ALLOW_HOME_DELIVERY, + 'checkbox', + [ + 'required' => false, + 'label' => $this->translator->trans('Allow home delivery', [], MondialRelay::DOMAIN_NAME), + 'label_attr' => [ + 'help' => $this->translator->trans('Check this box to allow delivery at customer address in supported countries.', [], MondialRelay::DOMAIN_NAME) + ] + + ] + )->add( + MondialRelay::ALLOW_RELAY_DELIVERY, + 'checkbox', + [ + 'required' => false, + 'label' => $this->translator->trans('Allow relay delivery', [], MondialRelay::DOMAIN_NAME), + 'label_attr' => [ + 'help' => $this->translator->trans('Check this box to allow delivery in relays in supported countries.', [], MondialRelay::DOMAIN_NAME) + ] + + ] + )->add( + MondialRelay::ALLOW_INSURANCE, + 'checkbox', + [ + 'required' => false, + 'label' => $this->translator->trans('Allow optional insurance', [], MondialRelay::DOMAIN_NAME), + 'label_attr' => [ + 'help' => $this->translator->trans('Check this box to allow an optionnal insurance selection depending on cart value.', [], MondialRelay::DOMAIN_NAME) + ] + + ] + )->add( + MondialRelay::WEBSERVICE_URL, + 'text', + [ + 'label' => $this->translator->trans('Mondial Relay Web service WSDL URL', [], MondialRelay::DOMAIN_NAME), + 'label_attr' => [ + 'help' => $this->translator->trans('This is the URL of the Mondial Relay web service WSDL.', [], MondialRelay::DOMAIN_NAME) + ] + ] + )->add( + MondialRelay::GOOGLE_MAPS_API_KEY, + 'text', + [ + 'label' => $this->translator->trans('Google Map API Key', [], MondialRelay::DOMAIN_NAME), + 'label_attr' => [ + 'help' => $this->translator->trans( + 'This key is required to display relays map. Click here to get one.', + [ "%get_key_url" => "https://developers.google.com/maps/documentation/javascript/get-api-key" ], + MondialRelay::DOMAIN_NAME + ) + ] + ] + ); + ; + } +} diff --git a/local/modules/MondialRelay/Hook/AdminHookManager.php b/local/modules/MondialRelay/Hook/AdminHookManager.php new file mode 100644 index 00000000..788b9bcc --- /dev/null +++ b/local/modules/MondialRelay/Hook/AdminHookManager.php @@ -0,0 +1,57 @@ + MondialRelay::getConfigValue(MondialRelay::CODE_ENSEIGNE), + 'private_key' => MondialRelay::getConfigValue(MondialRelay::PRIVATE_KEY), + 'allow_relay_delivery' => MondialRelay::getConfigValue(MondialRelay::ALLOW_RELAY_DELIVERY), + 'allow_home_delivery' => MondialRelay::getConfigValue(MondialRelay::ALLOW_HOME_DELIVERY), + 'allow_insurance' => MondialRelay::getConfigValue(MondialRelay::ALLOW_INSURANCE), + + 'module_id' => MondialRelay::getModuleId() + ]; + + $event->add( + $this->render('mondialrelay/module-configuration.html', $vars) + ); + } + + public function onMainTopMenuTools(HookRenderBlockEvent $event) + { + $event->add( + [ + 'id' => 'tools_mondial_relay', + 'class' => '', + 'url' => URL::getInstance()->absoluteUrl('/admin/module/MondialRelay'), + 'title' => $this->trans('Mondial Relay', [], MondialRelay::DOMAIN_NAME) + ] + ); + } + + public function onModuleConfigureJs(HookRenderEvent $event) + { + $event + ->add($this->render("mondialrelay/assets/js/mondialrelay.js.html")) + ->add($this->addJS("mondialrelay/assets/js/bootstrap-notify.min.js")) + ; + } +} diff --git a/local/modules/MondialRelay/Hook/EmailHookManager.php b/local/modules/MondialRelay/Hook/EmailHookManager.php new file mode 100644 index 00000000..f9f3a169 --- /dev/null +++ b/local/modules/MondialRelay/Hook/EmailHookManager.php @@ -0,0 +1,65 @@ +add( + $this->render( + 'mondialrelay/order-delivery-address.html', + [ + 'module_id' => $event->getArgument('module'), + 'order_id' => $event->getArgument('order'), + 'html_mode' => $htmlMode ? '1' : '0' + ] + ) + ); + } + + public function onDeliveryAddressText(HookRenderEvent $event) + { + $this->renderAddressTemplate($event, false); + } + + public function onDeliveryAddressHtml(HookRenderEvent $event) + { + $this->renderAddressTemplate($event, true); + } + + public function onAfterProductsText(HookRenderEvent $event) + { + $event->add( + $this->render( + 'mondialrelay/opening-hours-text.html', + [ + 'order_id' => $event->getArgument('order'), + ] + ) + ); + } + + public function onAfterProductsHtml(HookRenderEvent $event) + { + $event->add( + $this->render( + 'mondialrelay/opening-hours-html.html', + [ + 'order_id' => $event->getArgument('order'), + ] + ) + ); + } +} diff --git a/local/modules/MondialRelay/Hook/FrontHookManager.php b/local/modules/MondialRelay/Hook/FrontHookManager.php new file mode 100644 index 00000000..a034fbb1 --- /dev/null +++ b/local/modules/MondialRelay/Hook/FrontHookManager.php @@ -0,0 +1,53 @@ +getSession()->remove(MondialRelay::SESSION_SELECTED_DELIVERY_TYPE); + $this->getSession()->remove(MondialRelay::SESSION_SELECTED_PICKUP_RELAY_ID); + + // Get the address id from the request, as the hook don(t give it to us. + $addressId = $this->getRequest()->get('address_id', 0); + + $event->add( + $this->render( + 'mondialrelay/order-delivery-extra.html', + [ + 'module_id' => MondialRelay::getModuleId(), + 'address_id' => $addressId + ] + ) + ); + } + + public function onAccountOrderDeliveryAddress(HookRenderEvent $event) + { + $event->add( + $this->render( + 'mondialrelay/order-delivery-address.html', + [ + 'order_id' => $event->getArgument('order'), + 'module_id' => $event->getArgument('module') + ] + ) + ); + } +} + + diff --git a/local/modules/MondialRelay/Hook/PdfHookManager.php b/local/modules/MondialRelay/Hook/PdfHookManager.php new file mode 100644 index 00000000..6f368513 --- /dev/null +++ b/local/modules/MondialRelay/Hook/PdfHookManager.php @@ -0,0 +1,42 @@ +add( + $this->render( + 'mondialrelay/order-delivery-address.html', + [ + 'module_id' => $event->getArgument('module'), + 'order_id' => $event->getArgument('order'), + ] + ) + ); + } + public function onAfterDeliveryModule(HookRenderEvent $event) + { + $event->add( + $this->render( + 'mondialrelay/opening-hours.html', + [ + 'module_id' => $event->getArgument('module'), + 'order_id' => $event->getArgument('order'), + ] + ) + ); + } +} diff --git a/local/modules/MondialRelay/I18n/backOffice/default/en_US.php b/local/modules/MondialRelay/I18n/backOffice/default/en_US.php new file mode 100644 index 00000000..7b00e1b8 --- /dev/null +++ b/local/modules/MondialRelay/I18n/backOffice/default/en_US.php @@ -0,0 +1,30 @@ + 'Add a new insurance', + 'Add a new price' => 'Add a new price', + 'Add new insurance' => 'Add new insurance', + 'Add this price' => 'Add this price', + 'Area properties' => 'Area properties', + 'Cart value' => 'Cart value', + 'Cart weight up to...' => 'Cart weight up to...', + 'Configuration' => 'Configuration', + 'Delete this insurance' => 'Delete this insurance', + 'Delete this price' => 'Delete this price', + 'Delivery prices' => 'Delivery prices', + 'Development of this module is sponsored by you\'Nivers web and communication agency in Roanne.' => 'Development of this module is sponsored by you\'Nivers, web and communication agency in Roanne.', + 'Insurance price with tax' => 'Insurance price with tax', + 'Insurances' => 'Insurances', + 'Mondial Relay delivery configuration' => 'Mondial Relay delivery configuration', + 'Price with tax' => 'Price with tax', + 'Prices' => 'Prices', + 'Save' => 'Save', + 'Save changes' => 'Save changes', + 'Saving data, please wait...' => 'Saving data, please wait...', + 'Shipping zone "%name"' => 'Shipping zone "%name"', + 'Sorry, something goes wrong. Please try again.' => 'Sorry, something goes wrong. Please try again.', + 'There\'s no shipping zone defined for Mondial Relay. Please click here to configure module\'s shipping zones.' => 'There\'s no shipping zone defined for Mondial Relay. Please click here to configure module\'s shipping zones.', + 'Update finished.' => 'Update finished.', + 'days' => 'days', + 'kg' => 'kg', +); diff --git a/local/modules/MondialRelay/I18n/backOffice/default/fr_FR.php b/local/modules/MondialRelay/I18n/backOffice/default/fr_FR.php new file mode 100644 index 00000000..c3d6f922 --- /dev/null +++ b/local/modules/MondialRelay/I18n/backOffice/default/fr_FR.php @@ -0,0 +1,30 @@ + 'Ajouter une assurance', + 'Add a new price' => 'Ajouter un prix', + 'Add new insurance' => 'Ajouter une assurance', + 'Add this price' => 'Ajouter ce prix', + 'Area properties' => 'Propriétés de la zone', + 'Cart value' => 'Montant du panier', + 'Cart weight up to...' => 'Jusqu\'au poids...', + 'Configuration' => 'Configuration', + 'Delete this insurance' => 'Supprimer cette assurance', + 'Delete this price' => 'Supprimer ce prix', + 'Delivery prices' => 'Prix de livraison', + 'Development of this module is sponsored by you\'Nivers web and communication agency in Roanne.' => 'Le développement de ce module est financé par you\'Nivers, créateurs de site Internet à Roanne.', + 'Insurance price with tax' => 'Prix de l\'assurance TTC', + 'Insurances' => 'Assurances', + 'Mondial Relay delivery configuration' => 'Configuration des livraisons avec Mondial Relay', + 'Price with tax' => 'Prix TTC', + 'Prices' => 'Prix', + 'Save' => 'Enregistrer', + 'Save changes' => 'Enregistrer', + 'Saving data, please wait...' => 'Enregistrement en cours, merci de patienter...', + 'Shipping zone "%name"' => 'Zone de livraison "%name"', + 'Sorry, something goes wrong. Please try again.' => 'Quelque chose s\'est mal passé, merdi de ré-essayer.', + 'There\'s no shipping zone defined for Mondial Relay. Please click here to configure module\'s shipping zones.' => 'Il n\'y a pas de zone de livraison attaché à Mondial Relay. Cliquez ici pour configurer les zones de livraison du module', + 'Update finished.' => 'Enregistrement terminé.', + 'days' => 'jours', + 'kg' => 'kg', +); diff --git a/local/modules/MondialRelay/I18n/email/default/en_US.php b/local/modules/MondialRelay/I18n/email/default/en_US.php new file mode 100644 index 00000000..21a492c1 --- /dev/null +++ b/local/modules/MondialRelay/I18n/email/default/en_US.php @@ -0,0 +1,15 @@ + 'Dear %first %last', + 'Details about this order are available in your customer account.' => 'Details about this order are available in your customer account.', + 'Details about this order are available in your customer account: %account_url.' => 'Details about this order are available in your customer account: %account_url.', + 'Mondial Relay pickup location #%num' => 'Mondial Relay pickup location #%num', + 'Pickup relay opening hours:' => 'Pickup relay opening hours:', + 'See you soon at %store at the following address: %url' => 'See you soon at %store at the following address: %url', + 'See you soon at %store' => 'See you soon at %store', + 'The %store team.' => 'The %store team.', + 'Your %ref order has been shipped' => 'Your %ref order has been shipped', + 'Your order %order_ref has just been shipped from our store. The tracking number for this order is %tracking_ref. Please click here to track the delivery.' => 'Your order %order_ref has just been shipped from our store. The tracking number for this order is %tracking_ref. Please click here to track the delivery.', + 'Your order %order_ref has just been shipped from our store. The tracking number for this order is %tracking_ref. Tracking data is available at this address: https://www.mondialrelay.fr/suivi-de-colis' => 'Your order %order_ref has just been shipped from our store. The tracking number for this order is %tracking_ref. Tracking data is available at this address: https://www.mondialrelay.fr/suivi-de-colis', +); diff --git a/local/modules/MondialRelay/I18n/email/default/fr_FR.php b/local/modules/MondialRelay/I18n/email/default/fr_FR.php new file mode 100644 index 00000000..c3955ff7 --- /dev/null +++ b/local/modules/MondialRelay/I18n/email/default/fr_FR.php @@ -0,0 +1,15 @@ + 'Bonjour %first %last', + 'Details about this order are available in your customer account.' => 'Les détails de cette commande sont disponibles dans votre compte client.', + 'Details about this order are available in your customer account: %account_url.' => 'Les détails de cette commande sont disponibles dans votre compte client: %account_url.', + 'Mondial Relay pickup location #%num' => 'Point relais Mondial Relay No. %num', + 'Pickup relay opening hours:' => 'Horaires d\'ouverture du relais', + 'See you soon at %store at the following address: %url' => 'A bientôt sur %store en suivant ce lien: %url', + 'See you soon at %store' => 'A bientôt sur %store', + 'The %store team.' => 'L\'équipe %store.', + 'Your %ref order has been shipped' => 'Votre commande %ref a été expédiée.', + 'Your order %order_ref has just been shipped from our store. The tracking number for this order is %tracking_ref. Please click here to track the delivery.' => 'Votre commande %order_ref vient de quitter nos entrepôts. Le numéro de suivi est %tracking_ref. Merci de cliquer ici pour obtenir les informations de suivi.', + 'Your order %order_ref has just been shipped from our store. The tracking number for this order is %tracking_ref. Tracking data is available at this address: https://www.mondialrelay.fr/suivi-de-colis' => 'Votre commande %order_ref vient de quitter nos entrepôts. Le numéro de suivi est %tracking_ref. Pour obtenir des informations sur l\'avancement de votre commande, merci de suivre ce lien: https://www.mondialrelay.fr/suivi-de-colis', +); diff --git a/local/modules/MondialRelay/I18n/en_US.php b/local/modules/MondialRelay/I18n/en_US.php new file mode 100644 index 00000000..074bad18 --- /dev/null +++ b/local/modules/MondialRelay/I18n/en_US.php @@ -0,0 +1,38 @@ + 'Allow home delivery', + 'Allow optional insurance' => 'Allow optional insurance', + 'Allow relay delivery' => 'Allow relay delivery', + 'Cart value' => 'Cart value', + 'Check this box to allow an optionnal insurance selection depending on cart value.' => 'Check this box to allow an optionnal insurance selection depending on cart value.', + 'Check this box to allow delivery at customer address in supported countries.' => 'Check this box to allow delivery at customer address in supported countries.', + 'Check this box to allow delivery in relays in supported countries.' => 'Check this box to allow delivery in relays in supported countries.', + 'Delivery delay' => 'Delivery delay', + 'Delivery type' => 'Delivery type', + 'Friday' => 'Friday', + 'Google Map API Key' => 'Google Map API Key', + 'Home and relay delivery' => 'Home and relay delivery', + 'Home delivery' => 'Home delivery', + 'Insurance price' => 'Insurance price', + 'Monday' => 'Monday', + 'Mondial Relay' => 'Mondial Relay', + 'Mondial Relay Web service WSDL URL' => 'Mondial Relay Web service WSDL URL', + 'Mondial Relay store code' => 'Mondial Relay store code', + 'Mondial Relay tracking information' => 'Mondial Relay tracking information', + 'Pickup relay #%number' => 'Pickup relay #%number', + 'Price' => 'Price', + 'Private key' => 'Private key', + 'Relay delivery' => 'Relay delivery', + 'Saturday' => 'Saturday', + 'Sunday' => 'Sunday', + 'This is the URL of the Mondial Relay web service WSDL.' => 'This is the URL of the Mondial Relay web service WSDL.', + 'This is the store code, as provided by Mondial Relay.' => 'This is the store code, as provided by Mondial Relay.', + 'This key is required to display relays map. Click here to get one.' => 'This key is required to display relays map. Click here to get one.', + 'Thursday' => 'Thursday', + 'Tuesday' => 'Tuesday', + 'Wednesday' => 'Wednesday', + 'Weight up to...' => 'Weight up to...', + 'Your order has been shipped' => 'Your order has been shipped', + 'Your private key, as provided by Mondial Relay.' => 'Your private key, as provided by Mondial Relay.', +); diff --git a/local/modules/MondialRelay/I18n/fr_FR.php b/local/modules/MondialRelay/I18n/fr_FR.php new file mode 100644 index 00000000..15b66128 --- /dev/null +++ b/local/modules/MondialRelay/I18n/fr_FR.php @@ -0,0 +1,38 @@ + 'Autoriser la livraison à domicile', + 'Allow optional insurance' => 'Proposer une assurance optionnelle', + 'Allow relay delivery' => 'Autoriser la livraison en point relais', + 'Cart value' => 'Valeur du panier', + 'Check this box to allow an optionnal insurance selection depending on cart value.' => 'Cochez cette case pour proposer à vos client une assurance optionnelle, fonction du montant du panier', + 'Check this box to allow delivery at customer address in supported countries.' => 'Cochez cette case pour autoriser les livraison à domicile dans les pays ou Mondial Relay le propose', + 'Check this box to allow delivery in relays in supported countries.' => 'Cochez cette case pour autoriser les livraison en pojt relais dans les pays ou Mondial Relay le propose', + 'Delivery delay' => 'Délai de livraison', + 'Delivery type' => 'Type de livraison', + 'Friday' => 'Vendredi', + 'Google Map API Key' => 'Clef d\'API Google Maps', + 'Home and relay delivery' => 'Livraison en point relais ou à domicile', + 'Home delivery' => 'Livraison à mon domicile', + 'Insurance price' => 'Montant de l\'assurance', + 'Monday' => 'Lundi', + 'Mondial Relay' => 'Mondial Relay', + 'Mondial Relay Web service WSDL URL' => 'URL du WSDL du web service Mondial Relay', + 'Mondial Relay store code' => 'Code magasin Mondial Relay', + 'Mondial Relay tracking information' => 'Informations de suivi Mondial Relay', + 'Pickup relay #%number' => 'Point relais No. %number', + 'Price' => 'Prix', + 'Private key' => 'Clef privée', + 'Relay delivery' => 'Livraison en point relais', + 'Saturday' => 'Samedi', + 'Sunday' => 'Dimanche', + 'This is the URL of the Mondial Relay web service WSDL.' => 'Il s\'agit de l\'URL du descripteur du web service Mondial Relay, qui sera appelée par le module', + 'This is the store code, as provided by Mondial Relay.' => 'Il s\'agit du code magasin fourni par Mondial Relay', + 'This key is required to display relays map. Click here to get one.' => 'Cette clef est indispensable pour afficher la carte des points relais. Cliquez ici pour en obtenir une.', + 'Thursday' => 'Jeudi', + 'Tuesday' => 'Mardi', + 'Wednesday' => 'Mercredi', + 'Weight up to...' => 'Jusqu\'au poids...', + 'Your order has been shipped' => 'Votre commande a été expédiée', + 'Your private key, as provided by Mondial Relay.' => 'Votre clef privée, fournie par Mondial Relay', +); diff --git a/local/modules/MondialRelay/I18n/frontOffice/default/en_US.php b/local/modules/MondialRelay/I18n/frontOffice/default/en_US.php new file mode 100644 index 00000000..2e19908b --- /dev/null +++ b/local/modules/MondialRelay/I18n/frontOffice/default/en_US.php @@ -0,0 +1,23 @@ + 'City', + 'Current address can\'t be geolocated' => 'Current address can\'t be geolocated', + 'Expected delivery date: %delivery_date' => 'Expected delivery date: %delivery_date', + 'Find' => 'Find', + 'Find a pickup location around you' => 'Find a pickup location around you', + 'Loading...' => 'Loading...', + 'Mondial Relay home delivery' => 'Mondial Relay home delivery', + 'Mondial Relay pickup location' => 'Mondial Relay pickup location', + 'Mondial Relay pickup location #%num' => 'Mondial Relay pickup #%num', + 'No pickup locations were found for this address.' => 'No pickup locations were found for this address.', + 'Oops, something goes wrong, please try again.' => 'Oops, something goes wrong, please try again.', + 'Pickup location #%number' => 'Pickup location #%number', + 'Pickup location address' => 'Pickup location address', + 'Pickup location opening hours' => 'Pickup location opening hours', + 'Please select a pickup location.' => 'Please select a pickup location.', + 'Search radius' => 'Search radius', + 'Sorry, we failed to get pickup locations. Error is : __ERR__.' => 'Sorry, we failed to get pickup locations. Error is : __ERR__.', + 'Zip code' => 'Zip code', + 'km' => 'km', +); diff --git a/local/modules/MondialRelay/I18n/frontOffice/default/fr_FR.php b/local/modules/MondialRelay/I18n/frontOffice/default/fr_FR.php new file mode 100644 index 00000000..bea0ef5b --- /dev/null +++ b/local/modules/MondialRelay/I18n/frontOffice/default/fr_FR.php @@ -0,0 +1,23 @@ + 'Ville', + 'Current address can\'t be geolocated' => 'L\'adresse sélectionné ne peut être géolocalisée, merci de vérifier qu\'elle est correcte.', + 'Expected delivery date: %delivery_date' => 'Date de livraison estimée: %delivery_date', + 'Find' => 'Go', + 'Find a pickup location around you' => 'Trouver un point relais autour de vous', + 'Loading...' => 'Chargement...', + 'Mondial Relay home delivery' => 'Livraison Mondial Relay à mon domicile', + 'Mondial Relay pickup location' => 'Adresse du point relais Mondial Relay', + 'Mondial Relay pickup location #%num' => 'Point relais Mondial Relay No. %num', + 'No pickup locations were found for this address.' => 'Nous n\'avons pas trouvé de point relais autour de cette adresse.', + 'Oops, something goes wrong, please try again.' => 'Oups, quelque chose n\'a pas fonctionné correctement. Merci de recommencer.', + 'Pickup location #%number' => 'Point relais No. %number', + 'Pickup location address' => 'Adresse du point relais', + 'Pickup location opening hours' => 'Horaires d\'ouverture du relais', + 'Please select a pickup location.' => 'Merci de choisir un point relais.', + 'Search radius' => 'Rayon de recherche', + 'Sorry, we failed to get pickup locations. Error is : __ERR__.' => 'Impossible d\'obtenir les points relais. L\'erreur est : __ERR__.', + 'Zip code' => 'Code postal', + 'km' => 'km', +); diff --git a/local/modules/MondialRelay/I18n/pdf/default/en_US.php b/local/modules/MondialRelay/I18n/pdf/default/en_US.php new file mode 100644 index 00000000..9285719e --- /dev/null +++ b/local/modules/MondialRelay/I18n/pdf/default/en_US.php @@ -0,0 +1,6 @@ + 'Mondial Relay pickup location #%num', + 'Pickup relay opening hours:' => 'Pickup relay opening hours:', +); diff --git a/local/modules/MondialRelay/I18n/pdf/default/fr_FR.php b/local/modules/MondialRelay/I18n/pdf/default/fr_FR.php new file mode 100644 index 00000000..9f8033cd --- /dev/null +++ b/local/modules/MondialRelay/I18n/pdf/default/fr_FR.php @@ -0,0 +1,6 @@ + 'Point relais Mondial Relay No. %num', + 'Pickup relay opening hours:' => 'Horaires d\'ouverture du relais', +); diff --git a/local/modules/MondialRelay/LICENSE b/local/modules/MondialRelay/LICENSE new file mode 100644 index 00000000..65c5ca88 --- /dev/null +++ b/local/modules/MondialRelay/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/local/modules/MondialRelay/Loop/AreaAttributes.php b/local/modules/MondialRelay/Loop/AreaAttributes.php new file mode 100644 index 00000000..01a597b7 --- /dev/null +++ b/local/modules/MondialRelay/Loop/AreaAttributes.php @@ -0,0 +1,76 @@ +getAreaId()) { + $query->filterByAreaId($areaId, Criteria::IN); + } + + if (null !== $delivTypes = $this->getDeliveryType()) { + $query->filterByDeliveryType($delivTypes, Criteria::IN); + } + + return $query; + } + + public function parseResults(LoopResult $loopResult) + { + /** @var MondialRelayZoneConfiguration $item */ + foreach ($loopResult->getResultDataCollection() as $item) { + $loopResultRow = new LoopResultRow($item); + + $loopResultRow + ->set('ID', $item->getId()) + ->set('DELIVERY_TYPE', $item->getDeliveryType()) + ->set('DELIVERY_TIME', $item->getDeliveryTime()) + ->set('AREA_ID', $item->getAreaId()) + ; + + $loopResult->addRow($loopResultRow); + } + + return $loopResult; + } +} diff --git a/local/modules/MondialRelay/Loop/DeliveryPrice.php b/local/modules/MondialRelay/Loop/DeliveryPrice.php new file mode 100644 index 00000000..72b28e47 --- /dev/null +++ b/local/modules/MondialRelay/Loop/DeliveryPrice.php @@ -0,0 +1,209 @@ +findPk($this->getCountryId())) { + if (null !== $stateId = $this->getStateId()) { + $state = StateQuery::create()->findPk($this->$stateId()); + } else { + $state = null; + } + + $mode = $this->getMode(); + + switch ($mode) { + case 'home': + $deliveryType = MondialRelayZoneConfiguration::HOME_DELIVERY_TYPE; + + if (! MondialRelay::getConfigValue(MondialRelay::ALLOW_HOME_DELIVERY, true)) { + return []; + } + break; + + case 'relay': + $deliveryType = MondialRelayZoneConfiguration::RELAY_DELIVERY_TYPE; + + if (! MondialRelay::getConfigValue(MondialRelay::ALLOW_RELAY_DELIVERY, true)) { + return []; + } + break; + + case 'all': + $deliveryType = MondialRelayZoneConfiguration::ALL_DELIVERY_TYPE; + break; + } + + + // Find all areas which contains this country + $countryInAreaList = CountryAreaQuery::findByCountryAndState($country, $state); + + $areaIdList = []; + + $module = ModuleQuery::create()->findOneByCode(MondialRelay::getModuleCode()); + + /** @var CountryArea $countryInArea */ + foreach ($countryInAreaList as $countryInArea) { + // Check if module is attached to the area + if (AreaDeliveryModuleQuery::create() + ->filterByAreaId($countryInArea->getAreaId()) + ->filterByModule($module) + ->count() > 0) { + $areaIdList[] = $countryInArea->getAreaId(); + } + } + + // Find zones with the required delivery type + $zones = MondialRelayZoneConfigurationQuery::create() + ->filterByAreaId($areaIdList, Criteria::IN) + ->filterByDeliveryType($deliveryType) + ->find(); + + /** @var Cart $cart */ + $cart = $this->requestStack + ->getCurrentRequest() + ->getSession() + ->getSessionCart($this->dispatcher) + ; + + $cartWeight = $cart->getWeight(); + $cartValue = $cart->getTaxedAmount($country); + + /** @var MondialRelayZoneConfiguration $zone */ + foreach ($zones as $zone) { + $result = []; + + if (null !== $deliveryPrice = MondialRelayDeliveryPriceQuery::create() + ->filterByAreaId($zone->getAreaId()) + ->filterByMaxWeight($cartWeight, Criteria::GREATER_EQUAL) + ->orderByMaxWeight(Criteria::ASC) + ->findOne()) { + $deliveryDate = (new \DateTime())->add(new \DateInterval("P" . $zone->getDeliveryTime() . "D")); + + // We have a price + $result['PRICE'] = $deliveryPrice->getPriceWithTax(); + $result['MAX_WEIGHT'] = $deliveryPrice->getMaxWeight(); + $result['AREA_ID'] = $deliveryPrice->getAreaId(); + $result['DELIVERY_DELAY'] = $zone->getDeliveryTime(); + $result['DELIVERY_DATE'] = $deliveryDate; + switch ($zone->getDeliveryType()) { + case MondialRelayZoneConfiguration::HOME_DELIVERY_TYPE: + $result['ZONE_TYPE'] = 'home'; + break; + + case MondialRelayZoneConfiguration::RELAY_DELIVERY_TYPE: + $result['ZONE_TYPE'] = 'relay'; + break; + + default: + $result['ZONE_TYPE'] = '?'; + } + + $result['TYPE'] = $zone->getDeliveryType(); + + // Get insurance cost + if (null !== $insurance = MondialRelayDeliveryInsuranceQuery::create() + ->filterByMaxValue($cartValue, Criteria::GREATER_EQUAL) + ->orderByMaxValue(Criteria::ASC) + ->findOne() + ) { + $result['INSURANCE_AVAILABLE'] = true; + $result['INSURANCE_PRICE'] = $insurance->getPriceWithTax(); + $result['INSURANCE_REF_VALUE'] = $insurance->getMaxValue(); + } else { + $result['INSURANCE_AVAILABLE'] = false; + } + + $results[] = $result; + } + } + } + + return $results; + } + + public function parseResults(LoopResult $loopResult) + { + /** @var MondialRelayDeliveryPrice $item */ + foreach ($loopResult->getResultDataCollection() as $resultItem) { + $loopResultRow = new LoopResultRow($item); + + foreach ($resultItem as $name => $value) { + $loopResultRow->set($name, $value); + } + + $loopResult->addRow($loopResultRow); + } + + return $loopResult; + } +} diff --git a/local/modules/MondialRelay/Loop/Insurances.php b/local/modules/MondialRelay/Loop/Insurances.php new file mode 100644 index 00000000..49eafcc8 --- /dev/null +++ b/local/modules/MondialRelay/Loop/Insurances.php @@ -0,0 +1,64 @@ +orderByMaxValue(); + + return $query; + } + + public function parseResults(LoopResult $loopResult) + { + /** @var MondialRelayDeliveryInsurance $item */ + foreach ($loopResult->getResultDataCollection() as $item) { + $loopResultRow = new LoopResultRow($item); + + $loopResultRow + ->set('ID', $item->getId()) + ->set('MAX_VALUE', $item->getMaxValue()) + ->set('PRICE', $item->getPriceWithTax()) + ; + + $loopResult->addRow($loopResultRow); + } + + return $loopResult; + } +} diff --git a/local/modules/MondialRelay/Loop/PickupPoints.php b/local/modules/MondialRelay/Loop/PickupPoints.php new file mode 100644 index 00000000..0940d0fa --- /dev/null +++ b/local/modules/MondialRelay/Loop/PickupPoints.php @@ -0,0 +1,90 @@ +getCountryId(), + $this->getCity(), + $this->getZipcode(), + $this->getSearchRadius() + ); + + $this->dispatcher->dispatch(MondialRelayEvents::FIND_RELAYS, $event); + + return $event->getPoints(); + } + + public function parseResults(LoopResult $loopResult) + { + foreach ($loopResult->getResultDataCollection() as $item) { + $loopResultRow = new LoopResultRow($item); + + $loopResultRow + ->set("ID", $item['id']) + ->set("LATITUDE", $item['latitude']) + ->set("LONGITUDE", $item['longitude']) + ->set("ZIPCODE", $item['zipcode']) + ->set("CITY", $item['city']) + ->set("COUNTRY", $item['country']) + ->set("NAME", $item['name']) + ->set("ADDRESS", $item['address']) + ->set("DISTANCE", $item['distance']) + ->set("OPENINGS", $item['openings']) + ; + + $loopResult->addRow($loopResultRow); + } + + return $loopResult; + } +} diff --git a/local/modules/MondialRelay/Loop/Prices.php b/local/modules/MondialRelay/Loop/Prices.php new file mode 100644 index 00000000..c954a023 --- /dev/null +++ b/local/modules/MondialRelay/Loop/Prices.php @@ -0,0 +1,72 @@ +getAreaId()) { + $query->filterByAreaId($areaId, Criteria::IN); + } + + $query->orderByMaxWeight(); + + return $query; + } + + public function parseResults(LoopResult $loopResult) + { + /** @var MondialRelayDeliveryPrice $item */ + foreach ($loopResult->getResultDataCollection() as $item) { + $loopResultRow = new LoopResultRow($item); + + $loopResultRow + ->set('ID', $item->getId()) + ->set('MAX_WEIGHT', $item->getMaxWeight()) + ->set('PRICE', $item->getPriceWithTax()) + ->set('AREA_ID', $item->getAreaId()) + ; + + $loopResult->addRow($loopResultRow); + } + + return $loopResult; + } +} diff --git a/local/modules/MondialRelay/Loop/SelectedPickupPoint.php b/local/modules/MondialRelay/Loop/SelectedPickupPoint.php new file mode 100644 index 00000000..869089c1 --- /dev/null +++ b/local/modules/MondialRelay/Loop/SelectedPickupPoint.php @@ -0,0 +1,89 @@ +getCurrentRequest()->getSession()->get(MondialRelay::SESSION_SELECTED_PICKUP_RELAY_ID)) { + return MondialRelayPickupAddressQuery::create()->filterById($relayId); + } elseif (null !== $orderAddressId = $this->getOrderAddressId()) { + return MondialRelayPickupAddressQuery::create()->filterByOrderAddressId($orderAddressId); + } elseif (null !== $orderId = $this->getOrderId()) { + if (null !== $order = OrderQuery::create()->findPk($orderId)) { + return MondialRelayPickupAddressQuery::create() + ->filterByOrderAddressId($order->getDeliveryOrderAddressId()); + } + } + + return null; + } + + public function parseResults(LoopResult $loopResult) + { + /** @var MondialRelayPickupAddress $item */ + foreach ($loopResult->getResultDataCollection() as $item) { + $loopResultRow = new LoopResultRow($item); + + $relayData = json_decode($item->getJsonRelayData(), true); + + $loopResultRow + ->set("ID", $relayData['id']) + ->set("LATITUDE", $relayData['latitude']) + ->set("LONGITUDE", $relayData['longitude']) + ->set("ZIPCODE", $relayData['zipcode']) + ->set("CITY", $relayData['city']) + ->set("COUNTRY", $relayData['country']) + ->set("NAME", $relayData['name']) + ->set("ADDRESS", $relayData['address']) + ->set("DISTANCE", $relayData['distance']) + ->set("OPENINGS", $relayData['openings']) + ; + + $loopResult->addRow($loopResultRow); + } + + return $loopResult; + } +} diff --git a/local/modules/MondialRelay/Model/Base/MondialRelayDeliveryInsurance.php b/local/modules/MondialRelay/Model/Base/MondialRelayDeliveryInsurance.php new file mode 100644 index 00000000..18f4707d --- /dev/null +++ b/local/modules/MondialRelay/Model/Base/MondialRelayDeliveryInsurance.php @@ -0,0 +1,1251 @@ +max_value = '0.000000'; + $this->price_with_tax = '0.000000'; + } + + /** + * Initializes internal state of MondialRelay\Model\Base\MondialRelayDeliveryInsurance object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !!$this->modifiedColumns; + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return $this->modifiedColumns && isset($this->modifiedColumns[$col]); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return $this->modifiedColumns ? array_keys($this->modifiedColumns) : []; + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return boolean true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + if (isset($this->modifiedColumns[$col])) { + unset($this->modifiedColumns[$col]); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another MondialRelayDeliveryInsurance instance. If + * obj is an instance of MondialRelayDeliveryInsurance, delegates to + * equals(MondialRelayDeliveryInsurance). Otherwise, returns false. + * + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @param string $name The virtual column name + * @return boolean + */ + public function hasVirtualColumn($name) + { + return array_key_exists($name, $this->virtualColumns); + } + + /** + * Get the value of a virtual column in this object + * + * @param string $name The virtual column name + * @return mixed + * + * @throws PropelException + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return MondialRelayDeliveryInsurance The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return MondialRelayDeliveryInsurance The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [level] column value. + * + * @return int + */ + public function getLevel() + { + + return $this->level; + } + + /** + * Get the [max_value] column value. + * + * @return string + */ + public function getMaxValue() + { + + return $this->max_value; + } + + /** + * Get the [price_with_tax] column value. + * + * @return string + */ + public function getPriceWithTax() + { + + return $this->price_with_tax; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \MondialRelay\Model\MondialRelayDeliveryInsurance The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[MondialRelayDeliveryInsuranceTableMap::ID] = true; + } + + + return $this; + } // setId() + + /** + * Set the value of [level] column. + * + * @param int $v new value + * @return \MondialRelay\Model\MondialRelayDeliveryInsurance The current object (for fluent API support) + */ + public function setLevel($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->level !== $v) { + $this->level = $v; + $this->modifiedColumns[MondialRelayDeliveryInsuranceTableMap::LEVEL] = true; + } + + + return $this; + } // setLevel() + + /** + * Set the value of [max_value] column. + * + * @param string $v new value + * @return \MondialRelay\Model\MondialRelayDeliveryInsurance The current object (for fluent API support) + */ + public function setMaxValue($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->max_value !== $v) { + $this->max_value = $v; + $this->modifiedColumns[MondialRelayDeliveryInsuranceTableMap::MAX_VALUE] = true; + } + + + return $this; + } // setMaxValue() + + /** + * Set the value of [price_with_tax] column. + * + * @param string $v new value + * @return \MondialRelay\Model\MondialRelayDeliveryInsurance The current object (for fluent API support) + */ + public function setPriceWithTax($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->price_with_tax !== $v) { + $this->price_with_tax = $v; + $this->modifiedColumns[MondialRelayDeliveryInsuranceTableMap::PRICE_WITH_TAX] = true; + } + + + return $this; + } // setPriceWithTax() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + if ($this->max_value !== '0.000000') { + return false; + } + + if ($this->price_with_tax !== '0.000000') { + return false; + } + + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-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 array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : MondialRelayDeliveryInsuranceTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : MondialRelayDeliveryInsuranceTableMap::translateFieldName('Level', TableMap::TYPE_PHPNAME, $indexType)]; + $this->level = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : MondialRelayDeliveryInsuranceTableMap::translateFieldName('MaxValue', TableMap::TYPE_PHPNAME, $indexType)]; + $this->max_value = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : MondialRelayDeliveryInsuranceTableMap::translateFieldName('PriceWithTax', TableMap::TYPE_PHPNAME, $indexType)]; + $this->price_with_tax = (null !== $col) ? (string) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 4; // 4 = MondialRelayDeliveryInsuranceTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \MondialRelay\Model\MondialRelayDeliveryInsurance object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(MondialRelayDeliveryInsuranceTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildMondialRelayDeliveryInsuranceQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see MondialRelayDeliveryInsurance::setDeleted() + * @see MondialRelayDeliveryInsurance::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(MondialRelayDeliveryInsuranceTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildMondialRelayDeliveryInsuranceQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $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(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(MondialRelayDeliveryInsuranceTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + } else { + $ret = $ret && $this->preUpdate($con); + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + MondialRelayDeliveryInsuranceTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[MondialRelayDeliveryInsuranceTableMap::ID] = true; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . MondialRelayDeliveryInsuranceTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(MondialRelayDeliveryInsuranceTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(MondialRelayDeliveryInsuranceTableMap::LEVEL)) { + $modifiedColumns[':p' . $index++] = 'LEVEL'; + } + if ($this->isColumnModified(MondialRelayDeliveryInsuranceTableMap::MAX_VALUE)) { + $modifiedColumns[':p' . $index++] = 'MAX_VALUE'; + } + if ($this->isColumnModified(MondialRelayDeliveryInsuranceTableMap::PRICE_WITH_TAX)) { + $modifiedColumns[':p' . $index++] = 'PRICE_WITH_TAX'; + } + + $sql = sprintf( + 'INSERT INTO mondial_relay_delivery_insurance (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'LEVEL': + $stmt->bindValue($identifier, $this->level, PDO::PARAM_INT); + break; + case 'MAX_VALUE': + $stmt->bindValue($identifier, $this->max_value, PDO::PARAM_STR); + break; + case 'PRICE_WITH_TAX': + $stmt->bindValue($identifier, $this->price_with_tax, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = MondialRelayDeliveryInsuranceTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * 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->getLevel(); + break; + case 2: + return $this->getMaxValue(); + break; + case 3: + return $this->getPriceWithTax(); + 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array()) + { + if (isset($alreadyDumpedObjects['MondialRelayDeliveryInsurance'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['MondialRelayDeliveryInsurance'][$this->getPrimaryKey()] = true; + $keys = MondialRelayDeliveryInsuranceTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getLevel(), + $keys[2] => $this->getMaxValue(), + $keys[3] => $this->getPriceWithTax(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = MondialRelayDeliveryInsuranceTableMap::translateFieldName($name, $type, TableMap::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->setLevel($value); + break; + case 2: + $this->setMaxValue($value); + break; + case 3: + $this->setPriceWithTax($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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @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 = TableMap::TYPE_PHPNAME) + { + $keys = MondialRelayDeliveryInsuranceTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setLevel($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setMaxValue($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setPriceWithTax($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(MondialRelayDeliveryInsuranceTableMap::DATABASE_NAME); + + if ($this->isColumnModified(MondialRelayDeliveryInsuranceTableMap::ID)) $criteria->add(MondialRelayDeliveryInsuranceTableMap::ID, $this->id); + if ($this->isColumnModified(MondialRelayDeliveryInsuranceTableMap::LEVEL)) $criteria->add(MondialRelayDeliveryInsuranceTableMap::LEVEL, $this->level); + if ($this->isColumnModified(MondialRelayDeliveryInsuranceTableMap::MAX_VALUE)) $criteria->add(MondialRelayDeliveryInsuranceTableMap::MAX_VALUE, $this->max_value); + if ($this->isColumnModified(MondialRelayDeliveryInsuranceTableMap::PRICE_WITH_TAX)) $criteria->add(MondialRelayDeliveryInsuranceTableMap::PRICE_WITH_TAX, $this->price_with_tax); + + 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(MondialRelayDeliveryInsuranceTableMap::DATABASE_NAME); + $criteria->add(MondialRelayDeliveryInsuranceTableMap::ID, $this->id); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return int + */ + public function getPrimaryKey() + { + return $this->getId(); + } + + /** + * Generic method to set the primary key (id column). + * + * @param int $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setId($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return null === $this->getId(); + } + + /** + * 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 \MondialRelay\Model\MondialRelayDeliveryInsurance (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setLevel($this->getLevel()); + $copyObj->setMaxValue($this->getMaxValue()); + $copyObj->setPriceWithTax($this->getPriceWithTax()); + if ($makeNew) { + $copyObj->setNew(true); + $copyObj->setId(NULL); // this is a auto-increment 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 \MondialRelay\Model\MondialRelayDeliveryInsurance 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; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->level = null; + $this->max_value = null; + $this->price_with_tax = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(MondialRelayDeliveryInsuranceTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/local/modules/MondialRelay/Model/Base/MondialRelayDeliveryInsuranceQuery.php b/local/modules/MondialRelay/Model/Base/MondialRelayDeliveryInsuranceQuery.php new file mode 100644 index 00000000..192f7d36 --- /dev/null +++ b/local/modules/MondialRelay/Model/Base/MondialRelayDeliveryInsuranceQuery.php @@ -0,0 +1,479 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildMondialRelayDeliveryInsurance|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = MondialRelayDeliveryInsuranceTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(MondialRelayDeliveryInsuranceTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildMondialRelayDeliveryInsurance A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, LEVEL, MAX_VALUE, PRICE_WITH_TAX FROM mondial_relay_delivery_insurance WHERE ID = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildMondialRelayDeliveryInsurance(); + $obj->hydrate($row); + MondialRelayDeliveryInsuranceTableMap::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildMondialRelayDeliveryInsurance|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(12, 56, 832), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildMondialRelayDeliveryInsuranceQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(MondialRelayDeliveryInsuranceTableMap::ID, $key, Criteria::EQUAL); + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildMondialRelayDeliveryInsuranceQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(MondialRelayDeliveryInsuranceTableMap::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildMondialRelayDeliveryInsuranceQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(MondialRelayDeliveryInsuranceTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(MondialRelayDeliveryInsuranceTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(MondialRelayDeliveryInsuranceTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the level column + * + * Example usage: + * + * $query->filterByLevel(1234); // WHERE level = 1234 + * $query->filterByLevel(array(12, 34)); // WHERE level IN (12, 34) + * $query->filterByLevel(array('min' => 12)); // WHERE level > 12 + * + * + * @param mixed $level The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildMondialRelayDeliveryInsuranceQuery The current query, for fluid interface + */ + public function filterByLevel($level = null, $comparison = null) + { + if (is_array($level)) { + $useMinMax = false; + if (isset($level['min'])) { + $this->addUsingAlias(MondialRelayDeliveryInsuranceTableMap::LEVEL, $level['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($level['max'])) { + $this->addUsingAlias(MondialRelayDeliveryInsuranceTableMap::LEVEL, $level['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(MondialRelayDeliveryInsuranceTableMap::LEVEL, $level, $comparison); + } + + /** + * Filter the query on the max_value column + * + * Example usage: + * + * $query->filterByMaxValue(1234); // WHERE max_value = 1234 + * $query->filterByMaxValue(array(12, 34)); // WHERE max_value IN (12, 34) + * $query->filterByMaxValue(array('min' => 12)); // WHERE max_value > 12 + * + * + * @param mixed $maxValue The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildMondialRelayDeliveryInsuranceQuery The current query, for fluid interface + */ + public function filterByMaxValue($maxValue = null, $comparison = null) + { + if (is_array($maxValue)) { + $useMinMax = false; + if (isset($maxValue['min'])) { + $this->addUsingAlias(MondialRelayDeliveryInsuranceTableMap::MAX_VALUE, $maxValue['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($maxValue['max'])) { + $this->addUsingAlias(MondialRelayDeliveryInsuranceTableMap::MAX_VALUE, $maxValue['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(MondialRelayDeliveryInsuranceTableMap::MAX_VALUE, $maxValue, $comparison); + } + + /** + * Filter the query on the price_with_tax column + * + * Example usage: + * + * $query->filterByPriceWithTax(1234); // WHERE price_with_tax = 1234 + * $query->filterByPriceWithTax(array(12, 34)); // WHERE price_with_tax IN (12, 34) + * $query->filterByPriceWithTax(array('min' => 12)); // WHERE price_with_tax > 12 + * + * + * @param mixed $priceWithTax The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildMondialRelayDeliveryInsuranceQuery The current query, for fluid interface + */ + public function filterByPriceWithTax($priceWithTax = null, $comparison = null) + { + if (is_array($priceWithTax)) { + $useMinMax = false; + if (isset($priceWithTax['min'])) { + $this->addUsingAlias(MondialRelayDeliveryInsuranceTableMap::PRICE_WITH_TAX, $priceWithTax['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($priceWithTax['max'])) { + $this->addUsingAlias(MondialRelayDeliveryInsuranceTableMap::PRICE_WITH_TAX, $priceWithTax['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(MondialRelayDeliveryInsuranceTableMap::PRICE_WITH_TAX, $priceWithTax, $comparison); + } + + /** + * Exclude object from result + * + * @param ChildMondialRelayDeliveryInsurance $mondialRelayDeliveryInsurance Object to remove from the list of results + * + * @return ChildMondialRelayDeliveryInsuranceQuery The current query, for fluid interface + */ + public function prune($mondialRelayDeliveryInsurance = null) + { + if ($mondialRelayDeliveryInsurance) { + $this->addUsingAlias(MondialRelayDeliveryInsuranceTableMap::ID, $mondialRelayDeliveryInsurance->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Deletes all rows from the mondial_relay_delivery_insurance table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(MondialRelayDeliveryInsuranceTableMap::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->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + MondialRelayDeliveryInsuranceTableMap::clearInstancePool(); + MondialRelayDeliveryInsuranceTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildMondialRelayDeliveryInsurance or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildMondialRelayDeliveryInsurance object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(MondialRelayDeliveryInsuranceTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(MondialRelayDeliveryInsuranceTableMap::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->beginTransaction(); + + + MondialRelayDeliveryInsuranceTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + MondialRelayDeliveryInsuranceTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // MondialRelayDeliveryInsuranceQuery diff --git a/local/modules/MondialRelay/Model/Base/MondialRelayDeliveryPrice.php b/local/modules/MondialRelay/Model/Base/MondialRelayDeliveryPrice.php new file mode 100644 index 00000000..3065dc16 --- /dev/null +++ b/local/modules/MondialRelay/Model/Base/MondialRelayDeliveryPrice.php @@ -0,0 +1,1336 @@ +max_weight = '0.000000'; + $this->price_with_tax = '0.000000'; + } + + /** + * Initializes internal state of MondialRelay\Model\Base\MondialRelayDeliveryPrice object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !!$this->modifiedColumns; + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return $this->modifiedColumns && isset($this->modifiedColumns[$col]); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return $this->modifiedColumns ? array_keys($this->modifiedColumns) : []; + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return boolean true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + if (isset($this->modifiedColumns[$col])) { + unset($this->modifiedColumns[$col]); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another MondialRelayDeliveryPrice instance. If + * obj is an instance of MondialRelayDeliveryPrice, delegates to + * equals(MondialRelayDeliveryPrice). Otherwise, returns false. + * + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @param string $name The virtual column name + * @return boolean + */ + public function hasVirtualColumn($name) + { + return array_key_exists($name, $this->virtualColumns); + } + + /** + * Get the value of a virtual column in this object + * + * @param string $name The virtual column name + * @return mixed + * + * @throws PropelException + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return MondialRelayDeliveryPrice The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return MondialRelayDeliveryPrice The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [max_weight] column value. + * + * @return string + */ + public function getMaxWeight() + { + + return $this->max_weight; + } + + /** + * Get the [price_with_tax] column value. + * + * @return string + */ + public function getPriceWithTax() + { + + return $this->price_with_tax; + } + + /** + * Get the [area_id] column value. + * + * @return int + */ + public function getAreaId() + { + + return $this->area_id; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \MondialRelay\Model\MondialRelayDeliveryPrice The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[MondialRelayDeliveryPriceTableMap::ID] = true; + } + + + return $this; + } // setId() + + /** + * Set the value of [max_weight] column. + * + * @param string $v new value + * @return \MondialRelay\Model\MondialRelayDeliveryPrice The current object (for fluent API support) + */ + public function setMaxWeight($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->max_weight !== $v) { + $this->max_weight = $v; + $this->modifiedColumns[MondialRelayDeliveryPriceTableMap::MAX_WEIGHT] = true; + } + + + return $this; + } // setMaxWeight() + + /** + * Set the value of [price_with_tax] column. + * + * @param string $v new value + * @return \MondialRelay\Model\MondialRelayDeliveryPrice The current object (for fluent API support) + */ + public function setPriceWithTax($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->price_with_tax !== $v) { + $this->price_with_tax = $v; + $this->modifiedColumns[MondialRelayDeliveryPriceTableMap::PRICE_WITH_TAX] = true; + } + + + return $this; + } // setPriceWithTax() + + /** + * Set the value of [area_id] column. + * + * @param int $v new value + * @return \MondialRelay\Model\MondialRelayDeliveryPrice The current object (for fluent API support) + */ + public function setAreaId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->area_id !== $v) { + $this->area_id = $v; + $this->modifiedColumns[MondialRelayDeliveryPriceTableMap::AREA_ID] = true; + } + + if ($this->aArea !== null && $this->aArea->getId() !== $v) { + $this->aArea = null; + } + + + return $this; + } // setAreaId() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + if ($this->max_weight !== '0.000000') { + return false; + } + + if ($this->price_with_tax !== '0.000000') { + return false; + } + + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-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 array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : MondialRelayDeliveryPriceTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : MondialRelayDeliveryPriceTableMap::translateFieldName('MaxWeight', TableMap::TYPE_PHPNAME, $indexType)]; + $this->max_weight = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : MondialRelayDeliveryPriceTableMap::translateFieldName('PriceWithTax', TableMap::TYPE_PHPNAME, $indexType)]; + $this->price_with_tax = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : MondialRelayDeliveryPriceTableMap::translateFieldName('AreaId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->area_id = (null !== $col) ? (int) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 4; // 4 = MondialRelayDeliveryPriceTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \MondialRelay\Model\MondialRelayDeliveryPrice object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aArea !== null && $this->area_id !== $this->aArea->getId()) { + $this->aArea = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(MondialRelayDeliveryPriceTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildMondialRelayDeliveryPriceQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aArea = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see MondialRelayDeliveryPrice::setDeleted() + * @see MondialRelayDeliveryPrice::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(MondialRelayDeliveryPriceTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildMondialRelayDeliveryPriceQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $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(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(MondialRelayDeliveryPriceTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + } else { + $ret = $ret && $this->preUpdate($con); + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + MondialRelayDeliveryPriceTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aArea !== null) { + if ($this->aArea->isModified() || $this->aArea->isNew()) { + $affectedRows += $this->aArea->save($con); + } + $this->setArea($this->aArea); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[MondialRelayDeliveryPriceTableMap::ID] = true; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . MondialRelayDeliveryPriceTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(MondialRelayDeliveryPriceTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(MondialRelayDeliveryPriceTableMap::MAX_WEIGHT)) { + $modifiedColumns[':p' . $index++] = 'MAX_WEIGHT'; + } + if ($this->isColumnModified(MondialRelayDeliveryPriceTableMap::PRICE_WITH_TAX)) { + $modifiedColumns[':p' . $index++] = 'PRICE_WITH_TAX'; + } + if ($this->isColumnModified(MondialRelayDeliveryPriceTableMap::AREA_ID)) { + $modifiedColumns[':p' . $index++] = 'AREA_ID'; + } + + $sql = sprintf( + 'INSERT INTO mondial_relay_delivery_price (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'MAX_WEIGHT': + $stmt->bindValue($identifier, $this->max_weight, PDO::PARAM_STR); + break; + case 'PRICE_WITH_TAX': + $stmt->bindValue($identifier, $this->price_with_tax, PDO::PARAM_STR); + break; + case 'AREA_ID': + $stmt->bindValue($identifier, $this->area_id, PDO::PARAM_INT); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = MondialRelayDeliveryPriceTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * 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->getMaxWeight(); + break; + case 2: + return $this->getPriceWithTax(); + break; + case 3: + return $this->getAreaId(); + 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['MondialRelayDeliveryPrice'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['MondialRelayDeliveryPrice'][$this->getPrimaryKey()] = true; + $keys = MondialRelayDeliveryPriceTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getMaxWeight(), + $keys[2] => $this->getPriceWithTax(), + $keys[3] => $this->getAreaId(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aArea) { + $result['Area'] = $this->aArea->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = MondialRelayDeliveryPriceTableMap::translateFieldName($name, $type, TableMap::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->setMaxWeight($value); + break; + case 2: + $this->setPriceWithTax($value); + break; + case 3: + $this->setAreaId($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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @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 = TableMap::TYPE_PHPNAME) + { + $keys = MondialRelayDeliveryPriceTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setMaxWeight($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setPriceWithTax($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setAreaId($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(MondialRelayDeliveryPriceTableMap::DATABASE_NAME); + + if ($this->isColumnModified(MondialRelayDeliveryPriceTableMap::ID)) $criteria->add(MondialRelayDeliveryPriceTableMap::ID, $this->id); + if ($this->isColumnModified(MondialRelayDeliveryPriceTableMap::MAX_WEIGHT)) $criteria->add(MondialRelayDeliveryPriceTableMap::MAX_WEIGHT, $this->max_weight); + if ($this->isColumnModified(MondialRelayDeliveryPriceTableMap::PRICE_WITH_TAX)) $criteria->add(MondialRelayDeliveryPriceTableMap::PRICE_WITH_TAX, $this->price_with_tax); + if ($this->isColumnModified(MondialRelayDeliveryPriceTableMap::AREA_ID)) $criteria->add(MondialRelayDeliveryPriceTableMap::AREA_ID, $this->area_id); + + 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(MondialRelayDeliveryPriceTableMap::DATABASE_NAME); + $criteria->add(MondialRelayDeliveryPriceTableMap::ID, $this->id); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return int + */ + public function getPrimaryKey() + { + return $this->getId(); + } + + /** + * Generic method to set the primary key (id column). + * + * @param int $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setId($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return null === $this->getId(); + } + + /** + * 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 \MondialRelay\Model\MondialRelayDeliveryPrice (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setMaxWeight($this->getMaxWeight()); + $copyObj->setPriceWithTax($this->getPriceWithTax()); + $copyObj->setAreaId($this->getAreaId()); + if ($makeNew) { + $copyObj->setNew(true); + $copyObj->setId(NULL); // this is a auto-increment 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 \MondialRelay\Model\MondialRelayDeliveryPrice 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; + } + + /** + * Declares an association between this object and a ChildArea object. + * + * @param ChildArea $v + * @return \MondialRelay\Model\MondialRelayDeliveryPrice The current object (for fluent API support) + * @throws PropelException + */ + public function setArea(ChildArea $v = null) + { + if ($v === null) { + $this->setAreaId(NULL); + } else { + $this->setAreaId($v->getId()); + } + + $this->aArea = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildArea object, it will not be re-added. + if ($v !== null) { + $v->addMondialRelayDeliveryPrice($this); + } + + + return $this; + } + + + /** + * Get the associated ChildArea object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildArea The associated ChildArea object. + * @throws PropelException + */ + public function getArea(ConnectionInterface $con = null) + { + if ($this->aArea === null && ($this->area_id !== null)) { + $this->aArea = AreaQuery::create()->findPk($this->area_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aArea->addMondialRelayDeliveryPrices($this); + */ + } + + return $this->aArea; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->max_weight = null; + $this->price_with_tax = null; + $this->area_id = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aArea = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(MondialRelayDeliveryPriceTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/local/modules/MondialRelay/Model/Base/MondialRelayDeliveryPriceQuery.php b/local/modules/MondialRelay/Model/Base/MondialRelayDeliveryPriceQuery.php new file mode 100644 index 00000000..48b6c3dc --- /dev/null +++ b/local/modules/MondialRelay/Model/Base/MondialRelayDeliveryPriceQuery.php @@ -0,0 +1,564 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildMondialRelayDeliveryPrice|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = MondialRelayDeliveryPriceTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(MondialRelayDeliveryPriceTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildMondialRelayDeliveryPrice A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, MAX_WEIGHT, PRICE_WITH_TAX, AREA_ID FROM mondial_relay_delivery_price WHERE ID = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildMondialRelayDeliveryPrice(); + $obj->hydrate($row); + MondialRelayDeliveryPriceTableMap::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildMondialRelayDeliveryPrice|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(12, 56, 832), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildMondialRelayDeliveryPriceQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(MondialRelayDeliveryPriceTableMap::ID, $key, Criteria::EQUAL); + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildMondialRelayDeliveryPriceQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(MondialRelayDeliveryPriceTableMap::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildMondialRelayDeliveryPriceQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(MondialRelayDeliveryPriceTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(MondialRelayDeliveryPriceTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(MondialRelayDeliveryPriceTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the max_weight column + * + * Example usage: + * + * $query->filterByMaxWeight(1234); // WHERE max_weight = 1234 + * $query->filterByMaxWeight(array(12, 34)); // WHERE max_weight IN (12, 34) + * $query->filterByMaxWeight(array('min' => 12)); // WHERE max_weight > 12 + * + * + * @param mixed $maxWeight The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildMondialRelayDeliveryPriceQuery The current query, for fluid interface + */ + public function filterByMaxWeight($maxWeight = null, $comparison = null) + { + if (is_array($maxWeight)) { + $useMinMax = false; + if (isset($maxWeight['min'])) { + $this->addUsingAlias(MondialRelayDeliveryPriceTableMap::MAX_WEIGHT, $maxWeight['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($maxWeight['max'])) { + $this->addUsingAlias(MondialRelayDeliveryPriceTableMap::MAX_WEIGHT, $maxWeight['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(MondialRelayDeliveryPriceTableMap::MAX_WEIGHT, $maxWeight, $comparison); + } + + /** + * Filter the query on the price_with_tax column + * + * Example usage: + * + * $query->filterByPriceWithTax(1234); // WHERE price_with_tax = 1234 + * $query->filterByPriceWithTax(array(12, 34)); // WHERE price_with_tax IN (12, 34) + * $query->filterByPriceWithTax(array('min' => 12)); // WHERE price_with_tax > 12 + * + * + * @param mixed $priceWithTax The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildMondialRelayDeliveryPriceQuery The current query, for fluid interface + */ + public function filterByPriceWithTax($priceWithTax = null, $comparison = null) + { + if (is_array($priceWithTax)) { + $useMinMax = false; + if (isset($priceWithTax['min'])) { + $this->addUsingAlias(MondialRelayDeliveryPriceTableMap::PRICE_WITH_TAX, $priceWithTax['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($priceWithTax['max'])) { + $this->addUsingAlias(MondialRelayDeliveryPriceTableMap::PRICE_WITH_TAX, $priceWithTax['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(MondialRelayDeliveryPriceTableMap::PRICE_WITH_TAX, $priceWithTax, $comparison); + } + + /** + * Filter the query on the area_id column + * + * Example usage: + * + * $query->filterByAreaId(1234); // WHERE area_id = 1234 + * $query->filterByAreaId(array(12, 34)); // WHERE area_id IN (12, 34) + * $query->filterByAreaId(array('min' => 12)); // WHERE area_id > 12 + * + * + * @see filterByArea() + * + * @param mixed $areaId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildMondialRelayDeliveryPriceQuery The current query, for fluid interface + */ + public function filterByAreaId($areaId = null, $comparison = null) + { + if (is_array($areaId)) { + $useMinMax = false; + if (isset($areaId['min'])) { + $this->addUsingAlias(MondialRelayDeliveryPriceTableMap::AREA_ID, $areaId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($areaId['max'])) { + $this->addUsingAlias(MondialRelayDeliveryPriceTableMap::AREA_ID, $areaId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(MondialRelayDeliveryPriceTableMap::AREA_ID, $areaId, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\Area object + * + * @param \Thelia\Model\Area|ObjectCollection $area The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildMondialRelayDeliveryPriceQuery The current query, for fluid interface + */ + public function filterByArea($area, $comparison = null) + { + if ($area instanceof \Thelia\Model\Area) { + return $this + ->addUsingAlias(MondialRelayDeliveryPriceTableMap::AREA_ID, $area->getId(), $comparison); + } elseif ($area instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(MondialRelayDeliveryPriceTableMap::AREA_ID, $area->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByArea() only accepts arguments of type \Thelia\Model\Area or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Area relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildMondialRelayDeliveryPriceQuery The current query, for fluid interface + */ + public function joinArea($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Area'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Area'); + } + + return $this; + } + + /** + * Use the Area relation Area object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\AreaQuery A secondary query class using the current class as primary query + */ + public function useAreaQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinArea($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Area', '\Thelia\Model\AreaQuery'); + } + + /** + * Exclude object from result + * + * @param ChildMondialRelayDeliveryPrice $mondialRelayDeliveryPrice Object to remove from the list of results + * + * @return ChildMondialRelayDeliveryPriceQuery The current query, for fluid interface + */ + public function prune($mondialRelayDeliveryPrice = null) + { + if ($mondialRelayDeliveryPrice) { + $this->addUsingAlias(MondialRelayDeliveryPriceTableMap::ID, $mondialRelayDeliveryPrice->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Deletes all rows from the mondial_relay_delivery_price table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(MondialRelayDeliveryPriceTableMap::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->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + MondialRelayDeliveryPriceTableMap::clearInstancePool(); + MondialRelayDeliveryPriceTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildMondialRelayDeliveryPrice or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildMondialRelayDeliveryPrice object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(MondialRelayDeliveryPriceTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(MondialRelayDeliveryPriceTableMap::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->beginTransaction(); + + + MondialRelayDeliveryPriceTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + MondialRelayDeliveryPriceTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // MondialRelayDeliveryPriceQuery diff --git a/local/modules/MondialRelay/Model/Base/MondialRelayPickupAddress.php b/local/modules/MondialRelay/Model/Base/MondialRelayPickupAddress.php new file mode 100644 index 00000000..197cea4e --- /dev/null +++ b/local/modules/MondialRelay/Model/Base/MondialRelayPickupAddress.php @@ -0,0 +1,1168 @@ +modifiedColumns; + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return $this->modifiedColumns && isset($this->modifiedColumns[$col]); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return $this->modifiedColumns ? array_keys($this->modifiedColumns) : []; + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return boolean true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + if (isset($this->modifiedColumns[$col])) { + unset($this->modifiedColumns[$col]); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another MondialRelayPickupAddress instance. If + * obj is an instance of MondialRelayPickupAddress, delegates to + * equals(MondialRelayPickupAddress). Otherwise, returns false. + * + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @param string $name The virtual column name + * @return boolean + */ + public function hasVirtualColumn($name) + { + return array_key_exists($name, $this->virtualColumns); + } + + /** + * Get the value of a virtual column in this object + * + * @param string $name The virtual column name + * @return mixed + * + * @throws PropelException + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return MondialRelayPickupAddress The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return MondialRelayPickupAddress The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [json_relay_data] column value. + * + * @return string + */ + public function getJsonRelayData() + { + + return $this->json_relay_data; + } + + /** + * Get the [order_address_id] column value. + * + * @return int + */ + public function getOrderAddressId() + { + + return $this->order_address_id; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \MondialRelay\Model\MondialRelayPickupAddress The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[MondialRelayPickupAddressTableMap::ID] = true; + } + + + return $this; + } // setId() + + /** + * Set the value of [json_relay_data] column. + * + * @param string $v new value + * @return \MondialRelay\Model\MondialRelayPickupAddress The current object (for fluent API support) + */ + public function setJsonRelayData($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->json_relay_data !== $v) { + $this->json_relay_data = $v; + $this->modifiedColumns[MondialRelayPickupAddressTableMap::JSON_RELAY_DATA] = true; + } + + + return $this; + } // setJsonRelayData() + + /** + * Set the value of [order_address_id] column. + * + * @param int $v new value + * @return \MondialRelay\Model\MondialRelayPickupAddress The current object (for fluent API support) + */ + public function setOrderAddressId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->order_address_id !== $v) { + $this->order_address_id = $v; + $this->modifiedColumns[MondialRelayPickupAddressTableMap::ORDER_ADDRESS_ID] = true; + } + + + return $this; + } // setOrderAddressId() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-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 array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : MondialRelayPickupAddressTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : MondialRelayPickupAddressTableMap::translateFieldName('JsonRelayData', TableMap::TYPE_PHPNAME, $indexType)]; + $this->json_relay_data = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : MondialRelayPickupAddressTableMap::translateFieldName('OrderAddressId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->order_address_id = (null !== $col) ? (int) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 3; // 3 = MondialRelayPickupAddressTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \MondialRelay\Model\MondialRelayPickupAddress object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(MondialRelayPickupAddressTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildMondialRelayPickupAddressQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see MondialRelayPickupAddress::setDeleted() + * @see MondialRelayPickupAddress::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(MondialRelayPickupAddressTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildMondialRelayPickupAddressQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $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(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(MondialRelayPickupAddressTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + } else { + $ret = $ret && $this->preUpdate($con); + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + MondialRelayPickupAddressTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[MondialRelayPickupAddressTableMap::ID] = true; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . MondialRelayPickupAddressTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(MondialRelayPickupAddressTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(MondialRelayPickupAddressTableMap::JSON_RELAY_DATA)) { + $modifiedColumns[':p' . $index++] = 'JSON_RELAY_DATA'; + } + if ($this->isColumnModified(MondialRelayPickupAddressTableMap::ORDER_ADDRESS_ID)) { + $modifiedColumns[':p' . $index++] = 'ORDER_ADDRESS_ID'; + } + + $sql = sprintf( + 'INSERT INTO mondial_relay_pickup_address (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'JSON_RELAY_DATA': + $stmt->bindValue($identifier, $this->json_relay_data, PDO::PARAM_STR); + break; + case 'ORDER_ADDRESS_ID': + $stmt->bindValue($identifier, $this->order_address_id, PDO::PARAM_INT); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = MondialRelayPickupAddressTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * 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->getJsonRelayData(); + break; + case 2: + return $this->getOrderAddressId(); + 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array()) + { + if (isset($alreadyDumpedObjects['MondialRelayPickupAddress'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['MondialRelayPickupAddress'][$this->getPrimaryKey()] = true; + $keys = MondialRelayPickupAddressTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getJsonRelayData(), + $keys[2] => $this->getOrderAddressId(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = MondialRelayPickupAddressTableMap::translateFieldName($name, $type, TableMap::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->setJsonRelayData($value); + break; + case 2: + $this->setOrderAddressId($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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @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 = TableMap::TYPE_PHPNAME) + { + $keys = MondialRelayPickupAddressTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setJsonRelayData($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setOrderAddressId($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(MondialRelayPickupAddressTableMap::DATABASE_NAME); + + if ($this->isColumnModified(MondialRelayPickupAddressTableMap::ID)) $criteria->add(MondialRelayPickupAddressTableMap::ID, $this->id); + if ($this->isColumnModified(MondialRelayPickupAddressTableMap::JSON_RELAY_DATA)) $criteria->add(MondialRelayPickupAddressTableMap::JSON_RELAY_DATA, $this->json_relay_data); + if ($this->isColumnModified(MondialRelayPickupAddressTableMap::ORDER_ADDRESS_ID)) $criteria->add(MondialRelayPickupAddressTableMap::ORDER_ADDRESS_ID, $this->order_address_id); + + 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(MondialRelayPickupAddressTableMap::DATABASE_NAME); + $criteria->add(MondialRelayPickupAddressTableMap::ID, $this->id); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return int + */ + public function getPrimaryKey() + { + return $this->getId(); + } + + /** + * Generic method to set the primary key (id column). + * + * @param int $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setId($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return null === $this->getId(); + } + + /** + * 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 \MondialRelay\Model\MondialRelayPickupAddress (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setJsonRelayData($this->getJsonRelayData()); + $copyObj->setOrderAddressId($this->getOrderAddressId()); + if ($makeNew) { + $copyObj->setNew(true); + $copyObj->setId(NULL); // this is a auto-increment 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 \MondialRelay\Model\MondialRelayPickupAddress 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; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->json_relay_data = null; + $this->order_address_id = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(MondialRelayPickupAddressTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/local/modules/MondialRelay/Model/Base/MondialRelayPickupAddressQuery.php b/local/modules/MondialRelay/Model/Base/MondialRelayPickupAddressQuery.php new file mode 100644 index 00000000..7bbaff95 --- /dev/null +++ b/local/modules/MondialRelay/Model/Base/MondialRelayPickupAddressQuery.php @@ -0,0 +1,422 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildMondialRelayPickupAddress|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = MondialRelayPickupAddressTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(MondialRelayPickupAddressTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildMondialRelayPickupAddress A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, JSON_RELAY_DATA, ORDER_ADDRESS_ID FROM mondial_relay_pickup_address WHERE ID = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildMondialRelayPickupAddress(); + $obj->hydrate($row); + MondialRelayPickupAddressTableMap::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildMondialRelayPickupAddress|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(12, 56, 832), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildMondialRelayPickupAddressQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(MondialRelayPickupAddressTableMap::ID, $key, Criteria::EQUAL); + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildMondialRelayPickupAddressQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(MondialRelayPickupAddressTableMap::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildMondialRelayPickupAddressQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(MondialRelayPickupAddressTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(MondialRelayPickupAddressTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(MondialRelayPickupAddressTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the json_relay_data column + * + * Example usage: + * + * $query->filterByJsonRelayData('fooValue'); // WHERE json_relay_data = 'fooValue' + * $query->filterByJsonRelayData('%fooValue%'); // WHERE json_relay_data LIKE '%fooValue%' + * + * + * @param string $jsonRelayData The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildMondialRelayPickupAddressQuery The current query, for fluid interface + */ + public function filterByJsonRelayData($jsonRelayData = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($jsonRelayData)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $jsonRelayData)) { + $jsonRelayData = str_replace('*', '%', $jsonRelayData); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(MondialRelayPickupAddressTableMap::JSON_RELAY_DATA, $jsonRelayData, $comparison); + } + + /** + * Filter the query on the order_address_id column + * + * Example usage: + * + * $query->filterByOrderAddressId(1234); // WHERE order_address_id = 1234 + * $query->filterByOrderAddressId(array(12, 34)); // WHERE order_address_id IN (12, 34) + * $query->filterByOrderAddressId(array('min' => 12)); // WHERE order_address_id > 12 + * + * + * @param mixed $orderAddressId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildMondialRelayPickupAddressQuery The current query, for fluid interface + */ + public function filterByOrderAddressId($orderAddressId = null, $comparison = null) + { + if (is_array($orderAddressId)) { + $useMinMax = false; + if (isset($orderAddressId['min'])) { + $this->addUsingAlias(MondialRelayPickupAddressTableMap::ORDER_ADDRESS_ID, $orderAddressId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($orderAddressId['max'])) { + $this->addUsingAlias(MondialRelayPickupAddressTableMap::ORDER_ADDRESS_ID, $orderAddressId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(MondialRelayPickupAddressTableMap::ORDER_ADDRESS_ID, $orderAddressId, $comparison); + } + + /** + * Exclude object from result + * + * @param ChildMondialRelayPickupAddress $mondialRelayPickupAddress Object to remove from the list of results + * + * @return ChildMondialRelayPickupAddressQuery The current query, for fluid interface + */ + public function prune($mondialRelayPickupAddress = null) + { + if ($mondialRelayPickupAddress) { + $this->addUsingAlias(MondialRelayPickupAddressTableMap::ID, $mondialRelayPickupAddress->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Deletes all rows from the mondial_relay_pickup_address table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(MondialRelayPickupAddressTableMap::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->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + MondialRelayPickupAddressTableMap::clearInstancePool(); + MondialRelayPickupAddressTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildMondialRelayPickupAddress or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildMondialRelayPickupAddress object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(MondialRelayPickupAddressTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(MondialRelayPickupAddressTableMap::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->beginTransaction(); + + + MondialRelayPickupAddressTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + MondialRelayPickupAddressTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // MondialRelayPickupAddressQuery diff --git a/local/modules/MondialRelay/Model/Base/MondialRelayZoneConfiguration.php b/local/modules/MondialRelay/Model/Base/MondialRelayZoneConfiguration.php new file mode 100644 index 00000000..b0e14075 --- /dev/null +++ b/local/modules/MondialRelay/Model/Base/MondialRelayZoneConfiguration.php @@ -0,0 +1,1311 @@ +modifiedColumns; + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return $this->modifiedColumns && isset($this->modifiedColumns[$col]); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return $this->modifiedColumns ? array_keys($this->modifiedColumns) : []; + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return boolean true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + if (isset($this->modifiedColumns[$col])) { + unset($this->modifiedColumns[$col]); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another MondialRelayZoneConfiguration instance. If + * obj is an instance of MondialRelayZoneConfiguration, delegates to + * equals(MondialRelayZoneConfiguration). Otherwise, returns false. + * + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @param string $name The virtual column name + * @return boolean + */ + public function hasVirtualColumn($name) + { + return array_key_exists($name, $this->virtualColumns); + } + + /** + * Get the value of a virtual column in this object + * + * @param string $name The virtual column name + * @return mixed + * + * @throws PropelException + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return MondialRelayZoneConfiguration The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return MondialRelayZoneConfiguration The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [delivery_time] column value. + * + * @return int + */ + public function getDeliveryTime() + { + + return $this->delivery_time; + } + + /** + * Get the [delivery_type] column value. + * + * @return int + */ + public function getDeliveryType() + { + + return $this->delivery_type; + } + + /** + * Get the [area_id] column value. + * + * @return int + */ + public function getAreaId() + { + + return $this->area_id; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \MondialRelay\Model\MondialRelayZoneConfiguration The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[MondialRelayZoneConfigurationTableMap::ID] = true; + } + + + return $this; + } // setId() + + /** + * Set the value of [delivery_time] column. + * + * @param int $v new value + * @return \MondialRelay\Model\MondialRelayZoneConfiguration The current object (for fluent API support) + */ + public function setDeliveryTime($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->delivery_time !== $v) { + $this->delivery_time = $v; + $this->modifiedColumns[MondialRelayZoneConfigurationTableMap::DELIVERY_TIME] = true; + } + + + return $this; + } // setDeliveryTime() + + /** + * Set the value of [delivery_type] column. + * + * @param int $v new value + * @return \MondialRelay\Model\MondialRelayZoneConfiguration The current object (for fluent API support) + */ + public function setDeliveryType($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->delivery_type !== $v) { + $this->delivery_type = $v; + $this->modifiedColumns[MondialRelayZoneConfigurationTableMap::DELIVERY_TYPE] = true; + } + + + return $this; + } // setDeliveryType() + + /** + * Set the value of [area_id] column. + * + * @param int $v new value + * @return \MondialRelay\Model\MondialRelayZoneConfiguration The current object (for fluent API support) + */ + public function setAreaId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->area_id !== $v) { + $this->area_id = $v; + $this->modifiedColumns[MondialRelayZoneConfigurationTableMap::AREA_ID] = true; + } + + if ($this->aArea !== null && $this->aArea->getId() !== $v) { + $this->aArea = null; + } + + + return $this; + } // setAreaId() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-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 array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : MondialRelayZoneConfigurationTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : MondialRelayZoneConfigurationTableMap::translateFieldName('DeliveryTime', TableMap::TYPE_PHPNAME, $indexType)]; + $this->delivery_time = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : MondialRelayZoneConfigurationTableMap::translateFieldName('DeliveryType', TableMap::TYPE_PHPNAME, $indexType)]; + $this->delivery_type = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : MondialRelayZoneConfigurationTableMap::translateFieldName('AreaId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->area_id = (null !== $col) ? (int) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 4; // 4 = MondialRelayZoneConfigurationTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \MondialRelay\Model\MondialRelayZoneConfiguration object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aArea !== null && $this->area_id !== $this->aArea->getId()) { + $this->aArea = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(MondialRelayZoneConfigurationTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildMondialRelayZoneConfigurationQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aArea = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see MondialRelayZoneConfiguration::setDeleted() + * @see MondialRelayZoneConfiguration::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(MondialRelayZoneConfigurationTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildMondialRelayZoneConfigurationQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $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(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(MondialRelayZoneConfigurationTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + } else { + $ret = $ret && $this->preUpdate($con); + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + MondialRelayZoneConfigurationTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row 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 ConnectionInterface $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(ConnectionInterface $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 corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aArea !== null) { + if ($this->aArea->isModified() || $this->aArea->isNew()) { + $affectedRows += $this->aArea->save($con); + } + $this->setArea($this->aArea); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[MondialRelayZoneConfigurationTableMap::ID] = true; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . MondialRelayZoneConfigurationTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(MondialRelayZoneConfigurationTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(MondialRelayZoneConfigurationTableMap::DELIVERY_TIME)) { + $modifiedColumns[':p' . $index++] = 'DELIVERY_TIME'; + } + if ($this->isColumnModified(MondialRelayZoneConfigurationTableMap::DELIVERY_TYPE)) { + $modifiedColumns[':p' . $index++] = 'DELIVERY_TYPE'; + } + if ($this->isColumnModified(MondialRelayZoneConfigurationTableMap::AREA_ID)) { + $modifiedColumns[':p' . $index++] = 'AREA_ID'; + } + + $sql = sprintf( + 'INSERT INTO mondial_relay_zone_configuration (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'DELIVERY_TIME': + $stmt->bindValue($identifier, $this->delivery_time, PDO::PARAM_INT); + break; + case 'DELIVERY_TYPE': + $stmt->bindValue($identifier, $this->delivery_type, PDO::PARAM_INT); + break; + case 'AREA_ID': + $stmt->bindValue($identifier, $this->area_id, PDO::PARAM_INT); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * 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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = MondialRelayZoneConfigurationTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * 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->getDeliveryTime(); + break; + case 2: + return $this->getDeliveryType(); + break; + case 3: + return $this->getAreaId(); + 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 (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['MondialRelayZoneConfiguration'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['MondialRelayZoneConfiguration'][$this->getPrimaryKey()] = true; + $keys = MondialRelayZoneConfigurationTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getDeliveryTime(), + $keys[2] => $this->getDeliveryType(), + $keys[3] => $this->getAreaId(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aArea) { + $result['Area'] = $this->aArea->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = MondialRelayZoneConfigurationTableMap::translateFieldName($name, $type, TableMap::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->setDeliveryTime($value); + break; + case 2: + $this->setDeliveryType($value); + break; + case 3: + $this->setAreaId($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 TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @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 = TableMap::TYPE_PHPNAME) + { + $keys = MondialRelayZoneConfigurationTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setDeliveryTime($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setDeliveryType($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setAreaId($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(MondialRelayZoneConfigurationTableMap::DATABASE_NAME); + + if ($this->isColumnModified(MondialRelayZoneConfigurationTableMap::ID)) $criteria->add(MondialRelayZoneConfigurationTableMap::ID, $this->id); + if ($this->isColumnModified(MondialRelayZoneConfigurationTableMap::DELIVERY_TIME)) $criteria->add(MondialRelayZoneConfigurationTableMap::DELIVERY_TIME, $this->delivery_time); + if ($this->isColumnModified(MondialRelayZoneConfigurationTableMap::DELIVERY_TYPE)) $criteria->add(MondialRelayZoneConfigurationTableMap::DELIVERY_TYPE, $this->delivery_type); + if ($this->isColumnModified(MondialRelayZoneConfigurationTableMap::AREA_ID)) $criteria->add(MondialRelayZoneConfigurationTableMap::AREA_ID, $this->area_id); + + 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(MondialRelayZoneConfigurationTableMap::DATABASE_NAME); + $criteria->add(MondialRelayZoneConfigurationTableMap::ID, $this->id); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return int + */ + public function getPrimaryKey() + { + return $this->getId(); + } + + /** + * Generic method to set the primary key (id column). + * + * @param int $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setId($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return null === $this->getId(); + } + + /** + * 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 \MondialRelay\Model\MondialRelayZoneConfiguration (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setDeliveryTime($this->getDeliveryTime()); + $copyObj->setDeliveryType($this->getDeliveryType()); + $copyObj->setAreaId($this->getAreaId()); + if ($makeNew) { + $copyObj->setNew(true); + $copyObj->setId(NULL); // this is a auto-increment 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 \MondialRelay\Model\MondialRelayZoneConfiguration 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; + } + + /** + * Declares an association between this object and a ChildArea object. + * + * @param ChildArea $v + * @return \MondialRelay\Model\MondialRelayZoneConfiguration The current object (for fluent API support) + * @throws PropelException + */ + public function setArea(ChildArea $v = null) + { + if ($v === null) { + $this->setAreaId(NULL); + } else { + $this->setAreaId($v->getId()); + } + + $this->aArea = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildArea object, it will not be re-added. + if ($v !== null) { + $v->addMondialRelayZoneConfiguration($this); + } + + + return $this; + } + + + /** + * Get the associated ChildArea object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildArea The associated ChildArea object. + * @throws PropelException + */ + public function getArea(ConnectionInterface $con = null) + { + if ($this->aArea === null && ($this->area_id !== null)) { + $this->aArea = AreaQuery::create()->findPk($this->area_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aArea->addMondialRelayZoneConfigurations($this); + */ + } + + return $this->aArea; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->delivery_time = null; + $this->delivery_type = null; + $this->area_id = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aArea = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(MondialRelayZoneConfigurationTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/local/modules/MondialRelay/Model/Base/MondialRelayZoneConfigurationQuery.php b/local/modules/MondialRelay/Model/Base/MondialRelayZoneConfigurationQuery.php new file mode 100644 index 00000000..982569d6 --- /dev/null +++ b/local/modules/MondialRelay/Model/Base/MondialRelayZoneConfigurationQuery.php @@ -0,0 +1,564 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildMondialRelayZoneConfiguration|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = MondialRelayZoneConfigurationTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(MondialRelayZoneConfigurationTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildMondialRelayZoneConfiguration A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, DELIVERY_TIME, DELIVERY_TYPE, AREA_ID FROM mondial_relay_zone_configuration WHERE ID = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildMondialRelayZoneConfiguration(); + $obj->hydrate($row); + MondialRelayZoneConfigurationTableMap::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildMondialRelayZoneConfiguration|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(12, 56, 832), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildMondialRelayZoneConfigurationQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(MondialRelayZoneConfigurationTableMap::ID, $key, Criteria::EQUAL); + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildMondialRelayZoneConfigurationQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(MondialRelayZoneConfigurationTableMap::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildMondialRelayZoneConfigurationQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(MondialRelayZoneConfigurationTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(MondialRelayZoneConfigurationTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(MondialRelayZoneConfigurationTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the delivery_time column + * + * Example usage: + * + * $query->filterByDeliveryTime(1234); // WHERE delivery_time = 1234 + * $query->filterByDeliveryTime(array(12, 34)); // WHERE delivery_time IN (12, 34) + * $query->filterByDeliveryTime(array('min' => 12)); // WHERE delivery_time > 12 + * + * + * @param mixed $deliveryTime The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildMondialRelayZoneConfigurationQuery The current query, for fluid interface + */ + public function filterByDeliveryTime($deliveryTime = null, $comparison = null) + { + if (is_array($deliveryTime)) { + $useMinMax = false; + if (isset($deliveryTime['min'])) { + $this->addUsingAlias(MondialRelayZoneConfigurationTableMap::DELIVERY_TIME, $deliveryTime['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($deliveryTime['max'])) { + $this->addUsingAlias(MondialRelayZoneConfigurationTableMap::DELIVERY_TIME, $deliveryTime['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(MondialRelayZoneConfigurationTableMap::DELIVERY_TIME, $deliveryTime, $comparison); + } + + /** + * Filter the query on the delivery_type column + * + * Example usage: + * + * $query->filterByDeliveryType(1234); // WHERE delivery_type = 1234 + * $query->filterByDeliveryType(array(12, 34)); // WHERE delivery_type IN (12, 34) + * $query->filterByDeliveryType(array('min' => 12)); // WHERE delivery_type > 12 + * + * + * @param mixed $deliveryType The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildMondialRelayZoneConfigurationQuery The current query, for fluid interface + */ + public function filterByDeliveryType($deliveryType = null, $comparison = null) + { + if (is_array($deliveryType)) { + $useMinMax = false; + if (isset($deliveryType['min'])) { + $this->addUsingAlias(MondialRelayZoneConfigurationTableMap::DELIVERY_TYPE, $deliveryType['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($deliveryType['max'])) { + $this->addUsingAlias(MondialRelayZoneConfigurationTableMap::DELIVERY_TYPE, $deliveryType['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(MondialRelayZoneConfigurationTableMap::DELIVERY_TYPE, $deliveryType, $comparison); + } + + /** + * Filter the query on the area_id column + * + * Example usage: + * + * $query->filterByAreaId(1234); // WHERE area_id = 1234 + * $query->filterByAreaId(array(12, 34)); // WHERE area_id IN (12, 34) + * $query->filterByAreaId(array('min' => 12)); // WHERE area_id > 12 + * + * + * @see filterByArea() + * + * @param mixed $areaId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildMondialRelayZoneConfigurationQuery The current query, for fluid interface + */ + public function filterByAreaId($areaId = null, $comparison = null) + { + if (is_array($areaId)) { + $useMinMax = false; + if (isset($areaId['min'])) { + $this->addUsingAlias(MondialRelayZoneConfigurationTableMap::AREA_ID, $areaId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($areaId['max'])) { + $this->addUsingAlias(MondialRelayZoneConfigurationTableMap::AREA_ID, $areaId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(MondialRelayZoneConfigurationTableMap::AREA_ID, $areaId, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\Area object + * + * @param \Thelia\Model\Area|ObjectCollection $area The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildMondialRelayZoneConfigurationQuery The current query, for fluid interface + */ + public function filterByArea($area, $comparison = null) + { + if ($area instanceof \Thelia\Model\Area) { + return $this + ->addUsingAlias(MondialRelayZoneConfigurationTableMap::AREA_ID, $area->getId(), $comparison); + } elseif ($area instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(MondialRelayZoneConfigurationTableMap::AREA_ID, $area->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByArea() only accepts arguments of type \Thelia\Model\Area or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Area relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildMondialRelayZoneConfigurationQuery The current query, for fluid interface + */ + public function joinArea($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Area'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Area'); + } + + return $this; + } + + /** + * Use the Area relation Area object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\AreaQuery A secondary query class using the current class as primary query + */ + public function useAreaQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinArea($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Area', '\Thelia\Model\AreaQuery'); + } + + /** + * Exclude object from result + * + * @param ChildMondialRelayZoneConfiguration $mondialRelayZoneConfiguration Object to remove from the list of results + * + * @return ChildMondialRelayZoneConfigurationQuery The current query, for fluid interface + */ + public function prune($mondialRelayZoneConfiguration = null) + { + if ($mondialRelayZoneConfiguration) { + $this->addUsingAlias(MondialRelayZoneConfigurationTableMap::ID, $mondialRelayZoneConfiguration->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Deletes all rows from the mondial_relay_zone_configuration table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(MondialRelayZoneConfigurationTableMap::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->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + MondialRelayZoneConfigurationTableMap::clearInstancePool(); + MondialRelayZoneConfigurationTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildMondialRelayZoneConfiguration or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildMondialRelayZoneConfiguration object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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 function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(MondialRelayZoneConfigurationTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(MondialRelayZoneConfigurationTableMap::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->beginTransaction(); + + + MondialRelayZoneConfigurationTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + MondialRelayZoneConfigurationTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // MondialRelayZoneConfigurationQuery diff --git a/local/modules/MondialRelay/Model/Map/MondialRelayDeliveryInsuranceTableMap.php b/local/modules/MondialRelay/Model/Map/MondialRelayDeliveryInsuranceTableMap.php new file mode 100644 index 00000000..8271f1c8 --- /dev/null +++ b/local/modules/MondialRelay/Model/Map/MondialRelayDeliveryInsuranceTableMap.php @@ -0,0 +1,426 @@ + array('Id', 'Level', 'MaxValue', 'PriceWithTax', ), + self::TYPE_STUDLYPHPNAME => array('id', 'level', 'maxValue', 'priceWithTax', ), + self::TYPE_COLNAME => array(MondialRelayDeliveryInsuranceTableMap::ID, MondialRelayDeliveryInsuranceTableMap::LEVEL, MondialRelayDeliveryInsuranceTableMap::MAX_VALUE, MondialRelayDeliveryInsuranceTableMap::PRICE_WITH_TAX, ), + self::TYPE_RAW_COLNAME => array('ID', 'LEVEL', 'MAX_VALUE', 'PRICE_WITH_TAX', ), + self::TYPE_FIELDNAME => array('id', 'level', 'max_value', 'price_with_tax', ), + self::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::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Level' => 1, 'MaxValue' => 2, 'PriceWithTax' => 3, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'level' => 1, 'maxValue' => 2, 'priceWithTax' => 3, ), + self::TYPE_COLNAME => array(MondialRelayDeliveryInsuranceTableMap::ID => 0, MondialRelayDeliveryInsuranceTableMap::LEVEL => 1, MondialRelayDeliveryInsuranceTableMap::MAX_VALUE => 2, MondialRelayDeliveryInsuranceTableMap::PRICE_WITH_TAX => 3, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LEVEL' => 1, 'MAX_VALUE' => 2, 'PRICE_WITH_TAX' => 3, ), + self::TYPE_FIELDNAME => array('id' => 0, 'level' => 1, 'max_value' => 2, 'price_with_tax' => 3, ), + self::TYPE_NUM => array(0, 1, 2, 3, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('mondial_relay_delivery_insurance'); + $this->setPhpName('MondialRelayDeliveryInsurance'); + $this->setClassName('\\MondialRelay\\Model\\MondialRelayDeliveryInsurance'); + $this->setPackage('MondialRelay.Model'); + $this->setUseIdGenerator(true); + // columns + $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addColumn('LEVEL', 'Level', 'INTEGER', true, null, null); + $this->addColumn('MAX_VALUE', 'MaxValue', 'DECIMAL', true, 16, 0); + $this->addColumn('PRICE_WITH_TAX', 'PriceWithTax', 'DECIMAL', true, 16, 0); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + } // buildRelations() + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? MondialRelayDeliveryInsuranceTableMap::CLASS_DEFAULT : MondialRelayDeliveryInsuranceTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (MondialRelayDeliveryInsurance object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = MondialRelayDeliveryInsuranceTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = MondialRelayDeliveryInsuranceTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + MondialRelayDeliveryInsuranceTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = MondialRelayDeliveryInsuranceTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + MondialRelayDeliveryInsuranceTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = MondialRelayDeliveryInsuranceTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = MondialRelayDeliveryInsuranceTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + MondialRelayDeliveryInsuranceTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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 $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(MondialRelayDeliveryInsuranceTableMap::ID); + $criteria->addSelectColumn(MondialRelayDeliveryInsuranceTableMap::LEVEL); + $criteria->addSelectColumn(MondialRelayDeliveryInsuranceTableMap::MAX_VALUE); + $criteria->addSelectColumn(MondialRelayDeliveryInsuranceTableMap::PRICE_WITH_TAX); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.LEVEL'); + $criteria->addSelectColumn($alias . '.MAX_VALUE'); + $criteria->addSelectColumn($alias . '.PRICE_WITH_TAX'); + } + } + + /** + * Returns the TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(MondialRelayDeliveryInsuranceTableMap::DATABASE_NAME)->getTable(MondialRelayDeliveryInsuranceTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(MondialRelayDeliveryInsuranceTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(MondialRelayDeliveryInsuranceTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new MondialRelayDeliveryInsuranceTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a MondialRelayDeliveryInsurance or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or MondialRelayDeliveryInsurance object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(MondialRelayDeliveryInsuranceTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \MondialRelay\Model\MondialRelayDeliveryInsurance) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(MondialRelayDeliveryInsuranceTableMap::DATABASE_NAME); + $criteria->add(MondialRelayDeliveryInsuranceTableMap::ID, (array) $values, Criteria::IN); + } + + $query = MondialRelayDeliveryInsuranceQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { MondialRelayDeliveryInsuranceTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { MondialRelayDeliveryInsuranceTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the mondial_relay_delivery_insurance table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return MondialRelayDeliveryInsuranceQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a MondialRelayDeliveryInsurance or Criteria object. + * + * @param mixed $criteria Criteria or MondialRelayDeliveryInsurance object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(MondialRelayDeliveryInsuranceTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from MondialRelayDeliveryInsurance object + } + + if ($criteria->containsKey(MondialRelayDeliveryInsuranceTableMap::ID) && $criteria->keyContainsValue(MondialRelayDeliveryInsuranceTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.MondialRelayDeliveryInsuranceTableMap::ID.')'); + } + + + // Set the correct dbName + $query = MondialRelayDeliveryInsuranceQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // MondialRelayDeliveryInsuranceTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +MondialRelayDeliveryInsuranceTableMap::buildTableMap(); diff --git a/local/modules/MondialRelay/Model/Map/MondialRelayDeliveryPriceTableMap.php b/local/modules/MondialRelay/Model/Map/MondialRelayDeliveryPriceTableMap.php new file mode 100644 index 00000000..d2b4cb26 --- /dev/null +++ b/local/modules/MondialRelay/Model/Map/MondialRelayDeliveryPriceTableMap.php @@ -0,0 +1,427 @@ + array('Id', 'MaxWeight', 'PriceWithTax', 'AreaId', ), + self::TYPE_STUDLYPHPNAME => array('id', 'maxWeight', 'priceWithTax', 'areaId', ), + self::TYPE_COLNAME => array(MondialRelayDeliveryPriceTableMap::ID, MondialRelayDeliveryPriceTableMap::MAX_WEIGHT, MondialRelayDeliveryPriceTableMap::PRICE_WITH_TAX, MondialRelayDeliveryPriceTableMap::AREA_ID, ), + self::TYPE_RAW_COLNAME => array('ID', 'MAX_WEIGHT', 'PRICE_WITH_TAX', 'AREA_ID', ), + self::TYPE_FIELDNAME => array('id', 'max_weight', 'price_with_tax', 'area_id', ), + self::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::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'MaxWeight' => 1, 'PriceWithTax' => 2, 'AreaId' => 3, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'maxWeight' => 1, 'priceWithTax' => 2, 'areaId' => 3, ), + self::TYPE_COLNAME => array(MondialRelayDeliveryPriceTableMap::ID => 0, MondialRelayDeliveryPriceTableMap::MAX_WEIGHT => 1, MondialRelayDeliveryPriceTableMap::PRICE_WITH_TAX => 2, MondialRelayDeliveryPriceTableMap::AREA_ID => 3, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'MAX_WEIGHT' => 1, 'PRICE_WITH_TAX' => 2, 'AREA_ID' => 3, ), + self::TYPE_FIELDNAME => array('id' => 0, 'max_weight' => 1, 'price_with_tax' => 2, 'area_id' => 3, ), + self::TYPE_NUM => array(0, 1, 2, 3, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('mondial_relay_delivery_price'); + $this->setPhpName('MondialRelayDeliveryPrice'); + $this->setClassName('\\MondialRelay\\Model\\MondialRelayDeliveryPrice'); + $this->setPackage('MondialRelay.Model'); + $this->setUseIdGenerator(true); + // columns + $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addColumn('MAX_WEIGHT', 'MaxWeight', 'DECIMAL', true, 16, 0); + $this->addColumn('PRICE_WITH_TAX', 'PriceWithTax', 'DECIMAL', true, 16, 0); + $this->addForeignKey('AREA_ID', 'AreaId', 'INTEGER', 'area', 'ID', true, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('Area', '\\Thelia\\Model\\Area', RelationMap::MANY_TO_ONE, array('area_id' => 'id', ), 'CASCADE', 'RESTRICT'); + } // buildRelations() + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? MondialRelayDeliveryPriceTableMap::CLASS_DEFAULT : MondialRelayDeliveryPriceTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (MondialRelayDeliveryPrice object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = MondialRelayDeliveryPriceTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = MondialRelayDeliveryPriceTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + MondialRelayDeliveryPriceTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = MondialRelayDeliveryPriceTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + MondialRelayDeliveryPriceTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = MondialRelayDeliveryPriceTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = MondialRelayDeliveryPriceTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + MondialRelayDeliveryPriceTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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 $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(MondialRelayDeliveryPriceTableMap::ID); + $criteria->addSelectColumn(MondialRelayDeliveryPriceTableMap::MAX_WEIGHT); + $criteria->addSelectColumn(MondialRelayDeliveryPriceTableMap::PRICE_WITH_TAX); + $criteria->addSelectColumn(MondialRelayDeliveryPriceTableMap::AREA_ID); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.MAX_WEIGHT'); + $criteria->addSelectColumn($alias . '.PRICE_WITH_TAX'); + $criteria->addSelectColumn($alias . '.AREA_ID'); + } + } + + /** + * Returns the TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(MondialRelayDeliveryPriceTableMap::DATABASE_NAME)->getTable(MondialRelayDeliveryPriceTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(MondialRelayDeliveryPriceTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(MondialRelayDeliveryPriceTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new MondialRelayDeliveryPriceTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a MondialRelayDeliveryPrice or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or MondialRelayDeliveryPrice object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(MondialRelayDeliveryPriceTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \MondialRelay\Model\MondialRelayDeliveryPrice) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(MondialRelayDeliveryPriceTableMap::DATABASE_NAME); + $criteria->add(MondialRelayDeliveryPriceTableMap::ID, (array) $values, Criteria::IN); + } + + $query = MondialRelayDeliveryPriceQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { MondialRelayDeliveryPriceTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { MondialRelayDeliveryPriceTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the mondial_relay_delivery_price table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return MondialRelayDeliveryPriceQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a MondialRelayDeliveryPrice or Criteria object. + * + * @param mixed $criteria Criteria or MondialRelayDeliveryPrice object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(MondialRelayDeliveryPriceTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from MondialRelayDeliveryPrice object + } + + if ($criteria->containsKey(MondialRelayDeliveryPriceTableMap::ID) && $criteria->keyContainsValue(MondialRelayDeliveryPriceTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.MondialRelayDeliveryPriceTableMap::ID.')'); + } + + + // Set the correct dbName + $query = MondialRelayDeliveryPriceQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // MondialRelayDeliveryPriceTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +MondialRelayDeliveryPriceTableMap::buildTableMap(); diff --git a/local/modules/MondialRelay/Model/Map/MondialRelayPickupAddressTableMap.php b/local/modules/MondialRelay/Model/Map/MondialRelayPickupAddressTableMap.php new file mode 100644 index 00000000..9fce2b25 --- /dev/null +++ b/local/modules/MondialRelay/Model/Map/MondialRelayPickupAddressTableMap.php @@ -0,0 +1,418 @@ + array('Id', 'JsonRelayData', 'OrderAddressId', ), + self::TYPE_STUDLYPHPNAME => array('id', 'jsonRelayData', 'orderAddressId', ), + self::TYPE_COLNAME => array(MondialRelayPickupAddressTableMap::ID, MondialRelayPickupAddressTableMap::JSON_RELAY_DATA, MondialRelayPickupAddressTableMap::ORDER_ADDRESS_ID, ), + self::TYPE_RAW_COLNAME => array('ID', 'JSON_RELAY_DATA', 'ORDER_ADDRESS_ID', ), + self::TYPE_FIELDNAME => array('id', 'json_relay_data', 'order_address_id', ), + self::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::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'JsonRelayData' => 1, 'OrderAddressId' => 2, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'jsonRelayData' => 1, 'orderAddressId' => 2, ), + self::TYPE_COLNAME => array(MondialRelayPickupAddressTableMap::ID => 0, MondialRelayPickupAddressTableMap::JSON_RELAY_DATA => 1, MondialRelayPickupAddressTableMap::ORDER_ADDRESS_ID => 2, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'JSON_RELAY_DATA' => 1, 'ORDER_ADDRESS_ID' => 2, ), + self::TYPE_FIELDNAME => array('id' => 0, 'json_relay_data' => 1, 'order_address_id' => 2, ), + self::TYPE_NUM => array(0, 1, 2, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('mondial_relay_pickup_address'); + $this->setPhpName('MondialRelayPickupAddress'); + $this->setClassName('\\MondialRelay\\Model\\MondialRelayPickupAddress'); + $this->setPackage('MondialRelay.Model'); + $this->setUseIdGenerator(true); + // columns + $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addColumn('JSON_RELAY_DATA', 'JsonRelayData', 'CLOB', true, null, null); + $this->addColumn('ORDER_ADDRESS_ID', 'OrderAddressId', 'INTEGER', true, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + } // buildRelations() + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? MondialRelayPickupAddressTableMap::CLASS_DEFAULT : MondialRelayPickupAddressTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (MondialRelayPickupAddress object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = MondialRelayPickupAddressTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = MondialRelayPickupAddressTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + MondialRelayPickupAddressTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = MondialRelayPickupAddressTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + MondialRelayPickupAddressTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = MondialRelayPickupAddressTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = MondialRelayPickupAddressTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + MondialRelayPickupAddressTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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 $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(MondialRelayPickupAddressTableMap::ID); + $criteria->addSelectColumn(MondialRelayPickupAddressTableMap::JSON_RELAY_DATA); + $criteria->addSelectColumn(MondialRelayPickupAddressTableMap::ORDER_ADDRESS_ID); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.JSON_RELAY_DATA'); + $criteria->addSelectColumn($alias . '.ORDER_ADDRESS_ID'); + } + } + + /** + * Returns the TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(MondialRelayPickupAddressTableMap::DATABASE_NAME)->getTable(MondialRelayPickupAddressTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(MondialRelayPickupAddressTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(MondialRelayPickupAddressTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new MondialRelayPickupAddressTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a MondialRelayPickupAddress or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or MondialRelayPickupAddress object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(MondialRelayPickupAddressTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \MondialRelay\Model\MondialRelayPickupAddress) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(MondialRelayPickupAddressTableMap::DATABASE_NAME); + $criteria->add(MondialRelayPickupAddressTableMap::ID, (array) $values, Criteria::IN); + } + + $query = MondialRelayPickupAddressQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { MondialRelayPickupAddressTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { MondialRelayPickupAddressTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the mondial_relay_pickup_address table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return MondialRelayPickupAddressQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a MondialRelayPickupAddress or Criteria object. + * + * @param mixed $criteria Criteria or MondialRelayPickupAddress object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(MondialRelayPickupAddressTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from MondialRelayPickupAddress object + } + + if ($criteria->containsKey(MondialRelayPickupAddressTableMap::ID) && $criteria->keyContainsValue(MondialRelayPickupAddressTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.MondialRelayPickupAddressTableMap::ID.')'); + } + + + // Set the correct dbName + $query = MondialRelayPickupAddressQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // MondialRelayPickupAddressTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +MondialRelayPickupAddressTableMap::buildTableMap(); diff --git a/local/modules/MondialRelay/Model/Map/MondialRelayZoneConfigurationTableMap.php b/local/modules/MondialRelay/Model/Map/MondialRelayZoneConfigurationTableMap.php new file mode 100644 index 00000000..45374e38 --- /dev/null +++ b/local/modules/MondialRelay/Model/Map/MondialRelayZoneConfigurationTableMap.php @@ -0,0 +1,427 @@ + array('Id', 'DeliveryTime', 'DeliveryType', 'AreaId', ), + self::TYPE_STUDLYPHPNAME => array('id', 'deliveryTime', 'deliveryType', 'areaId', ), + self::TYPE_COLNAME => array(MondialRelayZoneConfigurationTableMap::ID, MondialRelayZoneConfigurationTableMap::DELIVERY_TIME, MondialRelayZoneConfigurationTableMap::DELIVERY_TYPE, MondialRelayZoneConfigurationTableMap::AREA_ID, ), + self::TYPE_RAW_COLNAME => array('ID', 'DELIVERY_TIME', 'DELIVERY_TYPE', 'AREA_ID', ), + self::TYPE_FIELDNAME => array('id', 'delivery_time', 'delivery_type', 'area_id', ), + self::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::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'DeliveryTime' => 1, 'DeliveryType' => 2, 'AreaId' => 3, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'deliveryTime' => 1, 'deliveryType' => 2, 'areaId' => 3, ), + self::TYPE_COLNAME => array(MondialRelayZoneConfigurationTableMap::ID => 0, MondialRelayZoneConfigurationTableMap::DELIVERY_TIME => 1, MondialRelayZoneConfigurationTableMap::DELIVERY_TYPE => 2, MondialRelayZoneConfigurationTableMap::AREA_ID => 3, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'DELIVERY_TIME' => 1, 'DELIVERY_TYPE' => 2, 'AREA_ID' => 3, ), + self::TYPE_FIELDNAME => array('id' => 0, 'delivery_time' => 1, 'delivery_type' => 2, 'area_id' => 3, ), + self::TYPE_NUM => array(0, 1, 2, 3, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('mondial_relay_zone_configuration'); + $this->setPhpName('MondialRelayZoneConfiguration'); + $this->setClassName('\\MondialRelay\\Model\\MondialRelayZoneConfiguration'); + $this->setPackage('MondialRelay.Model'); + $this->setUseIdGenerator(true); + // columns + $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addColumn('DELIVERY_TIME', 'DeliveryTime', 'INTEGER', true, null, null); + $this->addColumn('DELIVERY_TYPE', 'DeliveryType', 'INTEGER', true, 1, null); + $this->addForeignKey('AREA_ID', 'AreaId', 'INTEGER', 'area', 'ID', true, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('Area', '\\Thelia\\Model\\Area', RelationMap::MANY_TO_ONE, array('area_id' => 'id', ), 'CASCADE', 'RESTRICT'); + } // buildRelations() + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? MondialRelayZoneConfigurationTableMap::CLASS_DEFAULT : MondialRelayZoneConfigurationTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (MondialRelayZoneConfiguration object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = MondialRelayZoneConfigurationTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = MondialRelayZoneConfigurationTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + MondialRelayZoneConfigurationTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = MondialRelayZoneConfigurationTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + MondialRelayZoneConfigurationTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = MondialRelayZoneConfigurationTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = MondialRelayZoneConfigurationTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + MondialRelayZoneConfigurationTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * 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 $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(MondialRelayZoneConfigurationTableMap::ID); + $criteria->addSelectColumn(MondialRelayZoneConfigurationTableMap::DELIVERY_TIME); + $criteria->addSelectColumn(MondialRelayZoneConfigurationTableMap::DELIVERY_TYPE); + $criteria->addSelectColumn(MondialRelayZoneConfigurationTableMap::AREA_ID); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.DELIVERY_TIME'); + $criteria->addSelectColumn($alias . '.DELIVERY_TYPE'); + $criteria->addSelectColumn($alias . '.AREA_ID'); + } + } + + /** + * Returns the TableMap related to this object. + * 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::getServiceContainer()->getDatabaseMap(MondialRelayZoneConfigurationTableMap::DATABASE_NAME)->getTable(MondialRelayZoneConfigurationTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(MondialRelayZoneConfigurationTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(MondialRelayZoneConfigurationTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new MondialRelayZoneConfigurationTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a MondialRelayZoneConfiguration or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or MondialRelayZoneConfiguration object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $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, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(MondialRelayZoneConfigurationTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \MondialRelay\Model\MondialRelayZoneConfiguration) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(MondialRelayZoneConfigurationTableMap::DATABASE_NAME); + $criteria->add(MondialRelayZoneConfigurationTableMap::ID, (array) $values, Criteria::IN); + } + + $query = MondialRelayZoneConfigurationQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { MondialRelayZoneConfigurationTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { MondialRelayZoneConfigurationTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the mondial_relay_zone_configuration table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return MondialRelayZoneConfigurationQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a MondialRelayZoneConfiguration or Criteria object. + * + * @param mixed $criteria Criteria or MondialRelayZoneConfiguration object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface 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($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(MondialRelayZoneConfigurationTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from MondialRelayZoneConfiguration object + } + + if ($criteria->containsKey(MondialRelayZoneConfigurationTableMap::ID) && $criteria->keyContainsValue(MondialRelayZoneConfigurationTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.MondialRelayZoneConfigurationTableMap::ID.')'); + } + + + // Set the correct dbName + $query = MondialRelayZoneConfigurationQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // MondialRelayZoneConfigurationTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +MondialRelayZoneConfigurationTableMap::buildTableMap(); diff --git a/local/modules/MondialRelay/Model/MondialRelayDeliveryInsurance.php b/local/modules/MondialRelay/Model/MondialRelayDeliveryInsurance.php new file mode 100644 index 00000000..25d3f39a --- /dev/null +++ b/local/modules/MondialRelay/Model/MondialRelayDeliveryInsurance.php @@ -0,0 +1,10 @@ +findOne(); + } catch (\Exception $e) { + $database = new Database($con); + $database->insertSql(null, [ __DIR__ . '/Config/thelia.sql' ]); + + // Test Enseigne and private key + self::setConfigValue(self::CODE_ENSEIGNE, "BDTEST13"); + self::setConfigValue(self::PRIVATE_KEY, "PrivateK"); + self::setConfigValue(self::WEBSERVICE_URL, "https://api.mondialrelay.com/Web_Services.asmx?WSDL"); + self::setConfigValue(self::GOOGLE_MAPS_API_KEY, "get_your_own_api_key"); + self::setConfigValue(self::ALLOW_HOME_DELIVERY, true); + self::setConfigValue(self::ALLOW_RELAY_DELIVERY, true); + self::setConfigValue(self::ALLOW_INSURANCE, true); + + // Create mondial relay shipping zones for relay and home delivery + + $moduleId = self::getModuleId(); + + $rateFromEuro = Currency::getDefaultCurrency()->getRate(); + + $moduleConfiguration = json_decode(file_get_contents(__DIR__. '/Config/config-data.json')); + + if (false === $moduleConfiguration) { + throw new TheliaProcessException("Invalid JSON configuration for Mondial Relay module"); + } + + // Create all shipping zones, and associate Mondial relay module with them. + foreach ($moduleConfiguration->shippingZones as $shippingZone) { + AreaQuery::create()->filterByName($shippingZone->name)->delete(); + + $area = new Area(); + + $area + ->setName($shippingZone->name) + ->save(); + + foreach ($shippingZone->countries as $countryIsoCode) { + if (null !== $country = CountryQuery::create()->findOneByIsoalpha3($countryIsoCode)) { + (new CountryArea()) + ->setAreaId($area->getId()) + ->setCountryId($country->getId()) + ->save(); + } + } + + // Define zone attributes + (new MondialRelayZoneConfiguration()) + ->setAreaId($area->getId()) + ->setDeliveryType($shippingZone->delivery_type) + ->setDeliveryTime($shippingZone->delivery_time_in_days) + ->save(); + + // Attach this zone to our module + (new AreaDeliveryModule()) + ->setArea($area) + ->setDeliveryModuleId($moduleId) + ->save(); + + // Create base prices + foreach ($shippingZone->prices as $price) { + (new MondialRelayDeliveryPrice()) + ->setAreaId($area->getId()) + ->setMaxWeight($price->up_to) + ->setPriceWithTax($price->price_euro * $rateFromEuro) + ->save(); + } + } + + // Insurances + foreach ($moduleConfiguration->insurances as $insurance) { + (new MondialRelayDeliveryInsurance()) + ->setMaxValue($insurance->value) + ->setPriceWithTax($insurance->price_with_tax_euro) + ->setLevel($insurance->level) + ->save(); + } + + if (null === MessageQuery::create()->findOneByName(self::TRACKING_MESSAGE_NAME)) { + $message = new Message(); + $message + ->setName(self::TRACKING_MESSAGE_NAME) + ->setHtmlLayoutFileName('') + ->setHtmlTemplateFileName(self::TRACKING_MESSAGE_NAME.'.html') + ->setTextLayoutFileName('') + ->setTextTemplateFileName(self::TRACKING_MESSAGE_NAME.'.txt') + ; + + $languages = LangQuery::create()->find(); + + /** @var Lang $language */ + foreach ($languages as $language) { + $locale = $language->getLocale(); + $message->setLocale($locale); + + $message->setTitle( + Translator::getInstance()->trans('Mondial Relay tracking information', [], self::DOMAIN_NAME, $locale) + ); + + $message->setSubject( + Translator::getInstance()->trans('Your order has been shipped', [], self::DOMAIN_NAME, $locale) + ); + } + + $message->save(); + } + + /* Deploy the module's image */ + $module = $this->getModuleModel(); + if (ModuleImageQuery::create()->filterByModule($module)->count() == 0) { + $this->deployImageFolder($module, sprintf('%s/images', __DIR__), $con); + } + } + } + + /** + * @param ConnectionInterface|null $con + * @param bool $deleteModuleData + * @throws \Propel\Runtime\Exception\PropelException + */ + public function destroy(ConnectionInterface $con = null, $deleteModuleData = false) + { + if ($deleteModuleData) { + // Delete message + MessageQuery::create()->filterByName(self::TRACKING_MESSAGE_NAME)->delete($con); + + // Delete module config data + ModuleConfigQuery::create()->filterByModuleId(self::getModuleId())->delete($con); + + // Delete module tables. + if (null !== $con) { + $database = new Database($con); + $database->insertSql(null, [__DIR__ . '/Config/drop.sql']); + } + } + + parent::destroy($con, $deleteModuleData); + } +} diff --git a/local/modules/MondialRelay/Readme.md b/local/modules/MondialRelay/Readme.md new file mode 100644 index 00000000..8d25067b --- /dev/null +++ b/local/modules/MondialRelay/Readme.md @@ -0,0 +1,39 @@ +# Module de livraison Mondial Relay + +Ce module vous permet de proposer à vos clients une livraison avec le transporteur Mondial Relay, +en point relais ou directement à domicile, en fonction des options disponibles +dans le pays de destination. + +## Installation + +Ajoutez le module depuis la page Modules de votre back-office, ou directement sur votre serveur si vous préférez. Vous +pouvez aussi utiliser composer : + + composer require thelia/mondialrelay:~1.0 + +## Configuration + +Par défaut, le module utilise des identifiants de test. Rendez-vous dans la configuration du module pour indiquer vos +propres identifiants Mondial Relay, et configurer les divers aspects du module. + +Lors de son installation, le module crée cinq zones de livraison, qui correspondent aux zones proposées par +Mondial Relay [sur la page des tarifs](http://www.mondialrelay.fr/envoi-de-colis/premiere-visite/#Tarifs "sur cette page"). + +Chacun de ces zones de livraison peut proposer la livraison en point relais, la livraison à domicile, ou les deux. +Vous pouvez régler ceci dans l'onglet "Prix" de la configuration du module. + +Pour chaque zone, vous pouvez définir des prix par tranche de poids. Ces prix sont initialisés l'installation du module +avec les prix de mars 2018. + +## Intégration + +Le module utilise les hooks de Thelia, aucun travail d'intégration n'est nécessaire. + +Pour une livraison en point relais, les caractéristiques du relais (numéro, coordonnées, horaires d'ouverture) sont +communiquées à vos clients dans les e-mails, documents PDF et historique de commande. + +## Notifications par email + +Si vous avez saisi un numéro de suivi, une notification d'envoi est expédiée à vos clients lorsque la commande passe à + l'état "envoyé". Vous pouvez modifier le contenu de ce mail dans les fichiers + `templates/email/default/mondial-relay-tracking-message.html` et `templates/email/default/mondial-relay-tracking-message.txt` diff --git a/local/modules/MondialRelay/Solution-Web-Service-V5.4.pdf b/local/modules/MondialRelay/Solution-Web-Service-V5.4.pdf new file mode 100644 index 00000000..4c4ed390 Binary files /dev/null and b/local/modules/MondialRelay/Solution-Web-Service-V5.4.pdf differ diff --git a/local/modules/MondialRelay/composer.json b/local/modules/MondialRelay/composer.json new file mode 100644 index 00000000..aeac3166 --- /dev/null +++ b/local/modules/MondialRelay/composer.json @@ -0,0 +1,11 @@ +{ + "name": "thelia/mondial-relay-module", + "license": "LGPL-3.0-or-later", + "type": "thelia-module", + "require": { + "xaviborja/php-mondialrelay-api": "dev-master" + }, + "extra": { + "installer-name": "MondialRelay" + } +} diff --git a/local/modules/MondialRelay/composer.lock b/local/modules/MondialRelay/composer.lock new file mode 100644 index 00000000..f35aeffa --- /dev/null +++ b/local/modules/MondialRelay/composer.lock @@ -0,0 +1,59 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "content-hash": "9dba6910bb06325dfa941ec161c6c334", + "packages": [ + { + "name": "xaviborja/php-mondialrelay-api", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/xaviborja/php-mondialrelay-api.git", + "reference": "b57f7da5f3f2ce983c8bea3d8239b7fdbe7ebcbf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/xaviborja/php-mondialrelay-api/zipball/b57f7da5f3f2ce983c8bea3d8239b7fdbe7ebcbf", + "reference": "b57f7da5f3f2ce983c8bea3d8239b7fdbe7ebcbf", + "shasum": "" + }, + "require": { + "xaviborja/php-mondialrelay-api": "dev-master" + }, + "require-dev": { + "phpunit/phpunit": "^5.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "MondialRelay\\": "src/MondialRelay/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Xavier Borja", + "email": "xavibm86@gmail.com" + } + ], + "description": "A PHP library for dealing with Mondial Relay API (http://api.mondialrelay.com)", + "time": "2017-06-21T12:22:06+00:00" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": { + "xaviborja/php-mondialrelay-api": 20 + }, + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [] +} diff --git a/local/modules/MondialRelay/images/logo-mr.png b/local/modules/MondialRelay/images/logo-mr.png new file mode 100644 index 00000000..0b887e90 Binary files /dev/null and b/local/modules/MondialRelay/images/logo-mr.png differ diff --git a/local/modules/MondialRelay/templates/backOffice/default/mondialrelay/ajax/general.html b/local/modules/MondialRelay/templates/backOffice/default/mondialrelay/ajax/general.html new file mode 100644 index 00000000..6e83d898 --- /dev/null +++ b/local/modules/MondialRelay/templates/backOffice/default/mondialrelay/ajax/general.html @@ -0,0 +1,37 @@ +{form name="mondialrelay.settings_form"} + + {include file = "includes/inner-form-toolbar.html" + hide_flags = true + page_url = "{url path='/admin/module/MondialRelay'}" + close_url = "{url path='/admin/modules'}" + hide_save_and_close_button = true + } + + {form_hidden_fields form=$form} + + {if $form_error}
{$form_error_message}
{/if} + +
+
+ {render_form_field field="code_enseigne" value={module_config module="MondialRelay" key='code_enseigne' locale="en_US"}} + {render_form_field field="private_key" value={module_config module="MondialRelay" key='private_key' locale="en_US"}} + {render_form_field field="webservice_url" value={module_config module="MondialRelay" key='webservice_url' locale="en_US"}} + {render_form_field field="google_maps_api_key" value={module_config module="MondialRelay" key='google_maps_api_key' locale="en_US"}} +
+
+ {render_form_field field="allow_relay_delivery" value={module_config module="MondialRelay" key='allow_relay_delivery' locale="en_US"}} + {render_form_field field="allow_home_delivery" value={module_config module="MondialRelay" key='allow_home_delivery' locale="en_US"}} + {* + {render_form_field field="allow_insurance" value={module_config module="MondialRelay" key='allow_insurance' locale="en_US"}} + *} + +
+

+

{intl l='Development of this module is sponsored by you\'Nivers web and communication agency in Roanne.' d="mondialrelay.bo.default"}

+
+
+
+ +{/form} + +{include file="mondialrelay/includes/error-dialog.html"} diff --git a/local/modules/MondialRelay/templates/backOffice/default/mondialrelay/ajax/insurances.html b/local/modules/MondialRelay/templates/backOffice/default/mondialrelay/ajax/insurances.html new file mode 100644 index 00000000..1a4e2a7c --- /dev/null +++ b/local/modules/MondialRelay/templates/backOffice/default/mondialrelay/ajax/insurances.html @@ -0,0 +1,98 @@ +{form name="mondialrelay.insurances_update_form"} +
+ {form_hidden_fields form=$form} + + {if $form_error}
{$form_error_message}
{/if} + + + + + + + + + + + + {loop type="mondialrelay.insurances" name="insurances"} + + + + + + + + {/loop} + + + + + + +
{intl l='Cart value' d='mondialrelay.bo.default'}{intl l='Insurance price with tax' d='mondialrelay.bo.default'} 
+ {form_field field="max_value"} +
+ + {currency attr="symbol"} +
+ {/form_field} +
+ {form_field field="price_with_tax"} +
+ + {currency attr="symbol"} +
+ {/form_field} +
+ + + +
+ +
+
+{/form} + +{form name="mondialrelay.insurance_create_form"} +
+ {form_hidden_fields form=$form} + + {if $form_error}
{$form_error_message}
{/if} + + + + + + + + + + + + + + +
{intl l='Add a new insurance' d='mondialrelay.bo.default'}
+ {form_field field="max_value"} +
+ + {currency attr="symbol"} +
+ {/form_field} +
+ {form_field field="price_with_tax"} +
+ + {currency attr="symbol"} +
+ {/form_field} +
+ +
+
+{/form} + +{include file="mondialrelay/includes/error-dialog.html"} diff --git a/local/modules/MondialRelay/templates/backOffice/default/mondialrelay/ajax/prices.html b/local/modules/MondialRelay/templates/backOffice/default/mondialrelay/ajax/prices.html new file mode 100644 index 00000000..e6be0e28 --- /dev/null +++ b/local/modules/MondialRelay/templates/backOffice/default/mondialrelay/ajax/prices.html @@ -0,0 +1,158 @@ +{$module_id = {$smarty.request.module_id|default:$module_id|default:0}} + +{ifloop rel="module-areas"} +

 

+ + {loop type="area" name="module-areas" module_id=$module_id order='id'} +
+
+ {intl l="Shipping zone \"%name\"" name=$NAME d='mondialrelay.bo.default'} +
+ +
+
+
+
+
+ {intl l='Delivery prices' d='mondialrelay.bo.default'} +
+ +
+ {form name="mondialrelay.prices_update_form"} +
+ {form_hidden_fields form=$form} + + + + + + + + + + + + {loop type="mondialrelay.prices" name="prices" area_id=$ID} + + + + + + + + {/loop} + + + + + + + +
{intl l='Cart weight up to...' d='mondialrelay.bo.default'}{intl l='Price with tax' d='mondialrelay.bo.default'} 
+ {form_field field="max_weight" value_key=$ID} +
+ + {intl l='kg' d='mondialrelay.bo.default'} +
+ {/form_field} +
+ {form_field field="price" value_key=$ID} +
+ + {currency attr="symbol"} +
+ {/form_field} +
+ +
+ +
+
+ {/form} + + {form name="mondialrelay.price_form"} +
+ + {form_hidden_fields form=$form} + + + + + + + + + + + + + + +
{intl l='Add a new price' d='mondialrelay.bo.default'}
+ {form_field field="max_weight"} +
+ + {intl l='kg' d='mondialrelay.bo.default'} +
+ {/form_field} +
+ {form_field field="price"} +
+ + {currency attr="symbol"} +
+ {/form_field} +
+ +
+
+ {/form} +
+
+
+ +
+
+
+ {intl l='Area properties' d='mondialrelay.bo.default'} +
+ +
+ {form name="mondialrelay.area_attributes_update_form"} +
+ {form_hidden_fields form=$form} + + {loop type="mondialrelay.area-attributes" name="area-attributes" area_id=$ID} + {custom_render_form_field field="delivery_time"} +
+ + {intl l='days' d='mondialrelay.bo.default'} +
+ {/custom_render_form_field} + + {render_form_field field="delivery_type" value=$DELIVERY_TYPE} + + + {/loop} +
+ {/form} +
+
+
+ +
+
+
+ {/loop} +{/ifloop} + +{elseloop rel="module-areas"} +
+ {intl l='There\'s no shipping zone defined for Mondial Relay. Please click here to configure module\'s shipping zones.' url={url path='/admin/configuration/shipping_zones'} d='mondialrelay.bo.default'} +
+{/elseloop} + +{include file="mondialrelay/includes/error-dialog.html"} diff --git a/local/modules/MondialRelay/templates/backOffice/default/mondialrelay/assets/img/younivers.png b/local/modules/MondialRelay/templates/backOffice/default/mondialrelay/assets/img/younivers.png new file mode 100644 index 00000000..9322ffd6 Binary files /dev/null and b/local/modules/MondialRelay/templates/backOffice/default/mondialrelay/assets/img/younivers.png differ diff --git a/local/modules/MondialRelay/templates/backOffice/default/mondialrelay/assets/js/bootstrap-notify.min.js b/local/modules/MondialRelay/templates/backOffice/default/mondialrelay/assets/js/bootstrap-notify.min.js new file mode 100644 index 00000000..01e7f309 --- /dev/null +++ b/local/modules/MondialRelay/templates/backOffice/default/mondialrelay/assets/js/bootstrap-notify.min.js @@ -0,0 +1 @@ +!function(t){"function"==typeof define&&define.amd?define(["jquery"],t):t("object"==typeof exports?require("jquery"):jQuery)}(function(t){function s(s){var e=!1;return t('[data-notify="container"]').each(function(i,n){var a=t(n),o=a.find('[data-notify="title"]').text().trim(),r=a.find('[data-notify="message"]').html().trim(),l=o===t("
"+s.settings.content.title+"
").html().trim(),d=r===t("
"+s.settings.content.message+"
").html().trim(),g=a.hasClass("alert-"+s.settings.type);return l&&d&&g&&(e=!0),!e}),e}function e(e,n,a){var o={content:{message:"object"==typeof n?n.message:n,title:n.title?n.title:"",icon:n.icon?n.icon:"",url:n.url?n.url:"#",target:n.target?n.target:"-"}};a=t.extend(!0,{},o,a),this.settings=t.extend(!0,{},i,a),this._defaults=i,"-"===this.settings.content.target&&(this.settings.content.target=this.settings.url_target),this.animations={start:"webkitAnimationStart oanimationstart MSAnimationStart animationstart",end:"webkitAnimationEnd oanimationend MSAnimationEnd animationend"},"number"==typeof this.settings.offset&&(this.settings.offset={x:this.settings.offset,y:this.settings.offset}),(this.settings.allow_duplicates||!this.settings.allow_duplicates&&!s(this))&&this.init()}var i={element:"body",position:null,type:"info",allow_dismiss:!0,allow_duplicates:!0,newest_on_top:!1,showProgressbar:!1,placement:{from:"top",align:"right"},offset:20,spacing:10,z_index:1031,delay:5e3,timer:1e3,url_target:"_blank",mouse_over:null,animate:{enter:"animated fadeInDown",exit:"animated fadeOutUp"},onShow:null,onShown:null,onClose:null,onClosed:null,icon_type:"class",template:''};String.format=function(){for(var t=arguments[0],s=1;s .progress-bar').removeClass("progress-bar-"+t.settings.type),t.settings.type=i[n],this.$ele.addClass("alert-"+i[n]).find('[data-notify="progressbar"] > .progress-bar').addClass("progress-bar-"+i[n]);break;case"icon":var a=this.$ele.find('[data-notify="icon"]');"class"===t.settings.icon_type.toLowerCase()?a.removeClass(t.settings.content.icon).addClass(i[n]):(a.is("img")||a.find("img"),a.attr("src",i[n]));break;case"progress":var o=t.settings.delay-t.settings.delay*(i[n]/100);this.$ele.data("notify-delay",o),this.$ele.find('[data-notify="progressbar"] > div').attr("aria-valuenow",i[n]).css("width",i[n]+"%");break;case"url":this.$ele.find('[data-notify="url"]').attr("href",i[n]);break;case"target":this.$ele.find('[data-notify="url"]').attr("target",i[n]);break;default:this.$ele.find('[data-notify="'+n+'"]').html(i[n])}var r=this.$ele.outerHeight()+parseInt(t.settings.spacing)+parseInt(t.settings.offset.y);t.reposition(r)},close:function(){t.close()}}},buildNotify:function(){var s=this.settings.content;this.$ele=t(String.format(this.settings.template,this.settings.type,s.title,s.message,s.url,s.target)),this.$ele.attr("data-notify-position",this.settings.placement.from+"-"+this.settings.placement.align),this.settings.allow_dismiss||this.$ele.find('[data-notify="dismiss"]').css("display","none"),(this.settings.delay<=0&&!this.settings.showProgressbar||!this.settings.showProgressbar)&&this.$ele.find('[data-notify="progressbar"]').remove()},setIcon:function(){"class"===this.settings.icon_type.toLowerCase()?this.$ele.find('[data-notify="icon"]').addClass(this.settings.content.icon):this.$ele.find('[data-notify="icon"]').is("img")?this.$ele.find('[data-notify="icon"]').attr("src",this.settings.content.icon):this.$ele.find('[data-notify="icon"]').append('Notify Icon')},styleDismiss:function(){this.$ele.find('[data-notify="dismiss"]').css({position:"absolute",right:"10px",top:"5px",zIndex:this.settings.z_index+2})},styleURL:function(){this.$ele.find('[data-notify="url"]').css({backgroundImage:"url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)",height:"100%",left:0,position:"absolute",top:0,width:"100%",zIndex:this.settings.z_index+1})},placement:function(){var s=this,e=this.settings.offset.y,i={display:"inline-block",margin:"0px auto",position:this.settings.position?this.settings.position:"body"===this.settings.element?"fixed":"absolute",transition:"all .5s ease-in-out",zIndex:this.settings.z_index},n=!1,a=this.settings;switch(t('[data-notify-position="'+this.settings.placement.from+"-"+this.settings.placement.align+'"]:not([data-closing="true"])').each(function(){e=Math.max(e,parseInt(t(this).css(a.placement.from))+parseInt(t(this).outerHeight())+parseInt(a.spacing))}),this.settings.newest_on_top===!0&&(e=this.settings.offset.y),i[this.settings.placement.from]=e+"px",this.settings.placement.align){case"left":case"right":i[this.settings.placement.align]=this.settings.offset.x+"px";break;case"center":i.left=0,i.right=0}this.$ele.css(i).addClass(this.settings.animate.enter),t.each(Array("webkit-","moz-","o-","ms-",""),function(t,e){s.$ele[0].style[e+"AnimationIterationCount"]=1}),t(this.settings.element).append(this.$ele),this.settings.newest_on_top===!0&&(e=parseInt(e)+parseInt(this.settings.spacing)+this.$ele.outerHeight(),this.reposition(e)),t.isFunction(s.settings.onShow)&&s.settings.onShow.call(this.$ele),this.$ele.one(this.animations.start,function(){n=!0}).one(this.animations.end,function(){s.$ele.removeClass(s.settings.animate.enter),t.isFunction(s.settings.onShown)&&s.settings.onShown.call(this)}),setTimeout(function(){n||t.isFunction(s.settings.onShown)&&s.settings.onShown.call(this)},600)},bind:function(){var s=this;if(this.$ele.find('[data-notify="dismiss"]').on("click",function(){s.close()}),this.$ele.mouseover(function(){t(this).data("data-hover","true")}).mouseout(function(){t(this).data("data-hover","false")}),this.$ele.data("data-hover","false"),this.settings.delay>0){s.$ele.data("notify-delay",s.settings.delay);var e=setInterval(function(){var t=parseInt(s.$ele.data("notify-delay"))-s.settings.timer;if("false"===s.$ele.data("data-hover")&&"pause"===s.settings.mouse_over||"pause"!=s.settings.mouse_over){var i=(s.settings.delay-t)/s.settings.delay*100;s.$ele.data("notify-delay",t),s.$ele.find('[data-notify="progressbar"] > div').attr("aria-valuenow",i).css("width",i+"%")}t<=-s.settings.timer&&(clearInterval(e),s.close())},s.settings.timer)}},close:function(){var s=this,e=parseInt(this.$ele.css(this.settings.placement.from)),i=!1;this.$ele.attr("data-closing","true").addClass(this.settings.animate.exit),s.reposition(e),t.isFunction(s.settings.onClose)&&s.settings.onClose.call(this.$ele),this.$ele.one(this.animations.start,function(){i=!0}).one(this.animations.end,function(){t(this).remove(),t.isFunction(s.settings.onClosed)&&s.settings.onClosed.call(this)}),setTimeout(function(){i||(s.$ele.remove(),s.settings.onClosed&&s.settings.onClosed(s.$ele))},600)},reposition:function(s){var e=this,i='[data-notify-position="'+this.settings.placement.from+"-"+this.settings.placement.align+'"]:not([data-closing="true"])',n=this.$ele.nextAll(i);this.settings.newest_on_top===!0&&(n=this.$ele.prevAll(i)),n.each(function(){t(this).css(e.settings.placement.from,s),s=parseInt(s)+parseInt(e.settings.spacing)+t(this).outerHeight()})}}),t.notify=function(t,s){var i=new e(this,t,s);return i.notify},t.notifyDefaults=function(s){return i=t.extend(!0,{},i,s)},t.notifyClose=function(s){"warning"===s&&(s="danger"),"undefined"==typeof s||"all"===s?t("[data-notify]").find('[data-notify="dismiss"]').trigger("click"):"success"===s||"info"===s||"warning"===s||"danger"===s?t(".alert-"+s+"[data-notify]").find('[data-notify="dismiss"]').trigger("click"):s?t(s+"[data-notify]").find('[data-notify="dismiss"]').trigger("click"):t('[data-notify-position="'+s+'"]').find('[data-notify="dismiss"]').trigger("click")},t.notifyCloseExcept=function(s){"warning"===s&&(s="danger"),"success"===s||"info"===s||"warning"===s||"danger"===s?t("[data-notify]").not(".alert-"+s).find('[data-notify="dismiss"]').trigger("click"):t("[data-notify]").not(s).find('[data-notify="dismiss"]').trigger("click")}}); \ No newline at end of file diff --git a/local/modules/MondialRelay/templates/backOffice/default/mondialrelay/assets/js/mondialrelay.js.html b/local/modules/MondialRelay/templates/backOffice/default/mondialrelay/assets/js/mondialrelay.js.html new file mode 100644 index 00000000..4d1e625d --- /dev/null +++ b/local/modules/MondialRelay/templates/backOffice/default/mondialrelay/assets/js/mondialrelay.js.html @@ -0,0 +1,53 @@ + diff --git a/local/modules/MondialRelay/templates/backOffice/default/mondialrelay/includes/error-dialog.html b/local/modules/MondialRelay/templates/backOffice/default/mondialrelay/includes/error-dialog.html new file mode 100644 index 00000000..08b474a5 --- /dev/null +++ b/local/modules/MondialRelay/templates/backOffice/default/mondialrelay/includes/error-dialog.html @@ -0,0 +1,27 @@ +{if $error_message} + + + +{/if} diff --git a/local/modules/MondialRelay/templates/backOffice/default/mondialrelay/module-configuration.html b/local/modules/MondialRelay/templates/backOffice/default/mondialrelay/module-configuration.html new file mode 100644 index 00000000..d0731b13 --- /dev/null +++ b/local/modules/MondialRelay/templates/backOffice/default/mondialrelay/module-configuration.html @@ -0,0 +1,38 @@ +{$current_tab = {$smarty.get.tab|default:'general'}} +
+
+
+ {intl l="Mondial Relay delivery configuration" d='mondialrelay.bo.default'} +
+
+ + + +
+
+
+ {include file="mondialrelay/ajax/general.html"} +
+
+ +
+
+ {include file="mondialrelay/ajax/prices.html" module_id=$module_id} +
+
+ + {* +
+
+ {include file="mondialrelay/ajax/insurances.html"} +
+
+ *} +
+
diff --git a/local/modules/MondialRelay/templates/email/default/mondial-relay-tracking-message.html b/local/modules/MondialRelay/templates/email/default/mondial-relay-tracking-message.html new file mode 100644 index 00000000..19182d50 --- /dev/null +++ b/local/modules/MondialRelay/templates/email/default/mondial-relay-tracking-message.html @@ -0,0 +1,28 @@ +{extends file="email-layout.tpl"} + +{default_translation_domain domain='mondialrelay.email.default'} + +{* Do not provide a "Open in browser" link *} +{block name="browser"}{/block} +{* No pre-header *} +{block name="pre-header"}{/block} + +{* Subject *} +{block name="email-subject"}{intl l="Your %ref order has been shipped" ref=$REF}{/block} + +{* Title *} +{block name="email-title"}{intl l="Your %ref order has been shipped" ref=$REF}{/block} + +{* Content *} +{block name="email-content"} +{loop type="order" name="order" id=$order_id} + {loop type="customer" name="customer.order" current=false id=$CUSTOMER backend_context="1"} +

{intl l="Dear %first %last" last=$LASTNAME first=$FIRSTNAME},

+ {/loop} + +

{intl l="Your order %order_ref has just been shipped from our store. The tracking number for this order is %tracking_ref. Please click here to track the delivery." order_ref=$REF tracking_ref=$DELIVERY_REF}

+

{intl l="Details about this order are available in your customer account." account_url={url path="/account"}}

+

{intl l="See you soon at %store" url={navigate to='index'} store={config key="store_name"}}

+

{intl l="The %store team." store={config key="store_name"}}

+{/loop} +{/block} diff --git a/local/modules/MondialRelay/templates/email/default/mondial-relay-tracking-message.txt b/local/modules/MondialRelay/templates/email/default/mondial-relay-tracking-message.txt new file mode 100644 index 00000000..2ae098dc --- /dev/null +++ b/local/modules/MondialRelay/templates/email/default/mondial-relay-tracking-message.txt @@ -0,0 +1,11 @@ +{default_translation_domain domain='mondialrelay.email.default'} +{default_locale locale={$locale}} +{loop type="order" name="order" id=$order_id} +{loop type="customer" name="customer.order" current=false id=$CUSTOMER backend_context="1"} +{intl l="Dear %first %last" last=$LASTNAME first=$FIRSTNAME},
+{/loop} +{intl l="Your order %order_ref has just been shipped from our store. The tracking number for this order is %tracking_ref. Tracking data is available at this address: https://www.mondialrelay.fr/suivi-de-colis" order_ref=$REF tracking_ref=$DELIVERY_REF}
+{intl l="Details about this order are available in your customer account: %account_url." account_url={url path="/account"}}
+{intl l="See you soon at %store at the following address: %url" url={navigate to='index'} store={config key="store_name"}}
+{intl l="The %store team." store={config key="store_name"}} +{/loop} diff --git a/local/modules/MondialRelay/templates/email/default/mondialrelay/opening-hours-html.html b/local/modules/MondialRelay/templates/email/default/mondialrelay/opening-hours-html.html new file mode 100644 index 00000000..f5e5cd61 --- /dev/null +++ b/local/modules/MondialRelay/templates/email/default/mondialrelay/opening-hours-html.html @@ -0,0 +1,26 @@ +{strip} + {loop type="mondialrelay.selected-pickup-point" name="avec-pickup" order_id=$order_id} + {if count($OPENINGS) > 0} +
+

{intl l="Pickup relay opening hours:" d="mondialrelay.email.default"}

+ + {foreach $OPENINGS as $opening} + + + {if $opening.opening_time_1} + + {else} + + {/if} + {if $opening.opening_time_2} + + {else} + + {/if} + + {/foreach} +
{$opening.day}{$opening.opening_time_1} - {$opening.closing_time_1} {$opening.opening_time_2} - {$opening.closing_time_2} 
+
+ {/if} + {/loop} +{/strip} diff --git a/local/modules/MondialRelay/templates/email/default/mondialrelay/opening-hours-text.html b/local/modules/MondialRelay/templates/email/default/mondialrelay/opening-hours-text.html new file mode 100644 index 00000000..883169ed --- /dev/null +++ b/local/modules/MondialRelay/templates/email/default/mondialrelay/opening-hours-text.html @@ -0,0 +1,8 @@ +{strip} +{loop type="mondialrelay.selected-pickup-point" name="avec-pickup" order_id=$order_id} +{if count($OPENINGS) > 0}{foreach $OPENINGS as $opening} +{intl l="Pickup relay opening hours:" d="mondialrelay.email.default"} +{$opening.day}: {if $opening.opening_time_1}{$opening.opening_time_1} - {$opening.closing_time_1}{/if} {if $opening.opening_time_2}{$opening.opening_time_2} - {$opening.closing_time_2}{/if} +{/foreach}{/if} +{/loop} +{/strip} diff --git a/local/modules/MondialRelay/templates/email/default/mondialrelay/order-delivery-address.html b/local/modules/MondialRelay/templates/email/default/mondialrelay/order-delivery-address.html new file mode 100644 index 00000000..c5752c23 --- /dev/null +++ b/local/modules/MondialRelay/templates/email/default/mondialrelay/order-delivery-address.html @@ -0,0 +1,13 @@ +{strip} + {loop type="mondialrelay.selected-pickup-point" name="avec-pickup" order_id=$order_id} + {intl l="Mondial Relay pickup location #%num" num=$ID d="mondialrelay.email.default"}
+ {format_address + country_code=$COUNTRY + locality=$CITY + postal_code=$ZIPCODE + address_line1=$ADDRESS + organization=$NAME + html=$html_mode + } + {/loop} +{/strip} diff --git a/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/css/styles.css b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/css/styles.css new file mode 100644 index 00000000..bca5a3a0 --- /dev/null +++ b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/css/styles.css @@ -0,0 +1,66 @@ +.location-form { + margin-bottom: 20px; +} + +.location-form button { + padding: 6px 12px !important; +} + +#relay_info { + height: 450px; + overflow-y: scroll; + border: 1px solid #ccc; +} + +#relay_info table { + margin: 0; + width: 100%; +} + +#relay_info table.pickup-points > tbody > tr > td { + border-bottom: 1px solid #ccc; + margin: 0; + padding: 10px; + cursor: pointer; +} +#relay_info table.pickup-points > tbody > tr:hover { + background-color: #f5f5f5; +} + +#relay_info table.pickup-points > tbody > tr > td .name { + font-weight: bold; +} + +#relay_info table.pickup-points > tbody > tr > td .name .numero { + display: inline-block; + border-radius: 2px; + background-color:#e64b62; + color: #fff; + padding: 0 5px; + margin-right: 5px; +} + +#relay_info table.opening-hours { + width: 100%; +} + +#relay_info table.opening-hours tr td { + font-size: 90%; + padding: 3px; +} +#relay_info table.opening-hours tr:nth-child(even) { + background-color:#f5f5f5; +} + +#mondial-relay-pickup { + display: none; +} + +.pickup-home-separator { + margin-top: 20px; + border-top: 1px solid #eee; + padding-top: 30px; + margin-left: -30px; + margin-right: -30px; +} + diff --git a/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/maison.png b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/maison.png new file mode 100644 index 00000000..c1685e2e Binary files /dev/null and b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/maison.png differ diff --git a/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_1.png b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_1.png new file mode 100644 index 00000000..49ff5906 Binary files /dev/null and b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_1.png differ diff --git a/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_10.png b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_10.png new file mode 100644 index 00000000..7c15dacf Binary files /dev/null and b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_10.png differ diff --git a/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_11.png b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_11.png new file mode 100644 index 00000000..d6e84978 Binary files /dev/null and b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_11.png differ diff --git a/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_12.png b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_12.png new file mode 100644 index 00000000..db39e523 Binary files /dev/null and b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_12.png differ diff --git a/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_13.png b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_13.png new file mode 100644 index 00000000..8676efc9 Binary files /dev/null and b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_13.png differ diff --git a/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_14.png b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_14.png new file mode 100644 index 00000000..ef1b5363 Binary files /dev/null and b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_14.png differ diff --git a/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_15.png b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_15.png new file mode 100644 index 00000000..1e1af8ec Binary files /dev/null and b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_15.png differ diff --git a/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_16.png b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_16.png new file mode 100644 index 00000000..805dfbe5 Binary files /dev/null and b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_16.png differ diff --git a/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_17.png b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_17.png new file mode 100644 index 00000000..89991633 Binary files /dev/null and b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_17.png differ diff --git a/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_18.png b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_18.png new file mode 100644 index 00000000..8218fbf2 Binary files /dev/null and b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_18.png differ diff --git a/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_19.png b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_19.png new file mode 100644 index 00000000..f28b9949 Binary files /dev/null and b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_19.png differ diff --git a/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_2.png b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_2.png new file mode 100644 index 00000000..94e4c780 Binary files /dev/null and b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_2.png differ diff --git a/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_20.png b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_20.png new file mode 100644 index 00000000..78d897f2 Binary files /dev/null and b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_20.png differ diff --git a/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_21.png b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_21.png new file mode 100644 index 00000000..606c4a6f Binary files /dev/null and b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_21.png differ diff --git a/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_22.png b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_22.png new file mode 100644 index 00000000..8124f359 Binary files /dev/null and b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_22.png differ diff --git a/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_23.png b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_23.png new file mode 100644 index 00000000..1b0f4bfa Binary files /dev/null and b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_23.png differ diff --git a/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_24.png b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_24.png new file mode 100644 index 00000000..6a52d3df Binary files /dev/null and b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_24.png differ diff --git a/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_25.png b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_25.png new file mode 100644 index 00000000..06ca9a82 Binary files /dev/null and b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_25.png differ diff --git a/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_26.png b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_26.png new file mode 100644 index 00000000..27d09819 Binary files /dev/null and b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_26.png differ diff --git a/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_27.png b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_27.png new file mode 100644 index 00000000..72cb21f3 Binary files /dev/null and b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_27.png differ diff --git a/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_28.png b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_28.png new file mode 100644 index 00000000..abefd559 Binary files /dev/null and b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_28.png differ diff --git a/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_29.png b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_29.png new file mode 100644 index 00000000..26b16878 Binary files /dev/null and b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_29.png differ diff --git a/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_3.png b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_3.png new file mode 100644 index 00000000..d99878e0 Binary files /dev/null and b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_3.png differ diff --git a/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_30.png b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_30.png new file mode 100644 index 00000000..66ddc662 Binary files /dev/null and b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_30.png differ diff --git a/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_4.png b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_4.png new file mode 100644 index 00000000..f9bd4f6a Binary files /dev/null and b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_4.png differ diff --git a/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_5.png b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_5.png new file mode 100644 index 00000000..171756f1 Binary files /dev/null and b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_5.png differ diff --git a/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_6.png b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_6.png new file mode 100644 index 00000000..7611b81a Binary files /dev/null and b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_6.png differ diff --git a/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_7.png b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_7.png new file mode 100644 index 00000000..426ecef5 Binary files /dev/null and b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_7.png differ diff --git a/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_8.png b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_8.png new file mode 100644 index 00000000..8ddc2354 Binary files /dev/null and b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_8.png differ diff --git a/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_9.png b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_9.png new file mode 100644 index 00000000..b0273de2 Binary files /dev/null and b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/assets/img/pins/pointsrelais_pin_9.png differ diff --git a/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/delivery-address.html b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/delivery-address.html new file mode 100644 index 00000000..8d2d09c3 --- /dev/null +++ b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/delivery-address.html @@ -0,0 +1,18 @@ +{strip} + {loop type="module" name="is_mondial_relay" id={order attr="delivery_module"} code="MondialRelay"} + {loop type="mondialrelay.selected-pickup-point" name="avec-pickup"} +
+
{intl l="Pickup location address" d="mondialrelay.fo.default"}
+
+ {intl l="Pickup location #%number" number=$ID d="mondialrelay.fo.default"} + {$NAME} +
+ {$ADDRESS}
+ {$ZIPCODE} + {$CITY} - {$COUNTRY} +
+
+
+ {/loop} + {/loop} +{/strip} diff --git a/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/order-delivery-address.html b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/order-delivery-address.html new file mode 100644 index 00000000..d6679e9b --- /dev/null +++ b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/order-delivery-address.html @@ -0,0 +1,26 @@ +{strip} + {loop type="mondialrelay.selected-pickup-point" name="avec-pickup" order_id=$order_id} + {intl l="Mondial Relay pickup location #%num" num=$ID d="mondialrelay.fo.default"}
+ {format_address + country_code=$COUNTRY + locality=$CITY + postal_code=$ZIPCODE + address_line1=$ADDRESS + organization=$NAME + } + {if count($OPENINGS) > 0} +
+

{intl l="Pickup location opening hours" d='mondialrelay.fo.default'}

+ + {foreach $OPENINGS as $opening} + + + + + + {/foreach} +
{$opening.day}{if $opening.opening_time_1}{$opening.opening_time_1} - {$opening.closing_time_1}{else} {/if}{if $opening.opening_time_2}{$opening.opening_time_2} - {$opening.closing_time_2}{else} {/if}
+
+ {/if} + {/loop} +{/strip} diff --git a/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/order-delivery-extra.html b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/order-delivery-extra.html new file mode 100644 index 00000000..a0bd8069 --- /dev/null +++ b/local/modules/MondialRelay/templates/frontOffice/default/mondialrelay/order-delivery-extra.html @@ -0,0 +1,347 @@ + + + diff --git a/local/modules/MondialRelay/templates/pdf/default/mondialrelay/opening-hours.html b/local/modules/MondialRelay/templates/pdf/default/mondialrelay/opening-hours.html new file mode 100644 index 00000000..badc6e99 --- /dev/null +++ b/local/modules/MondialRelay/templates/pdf/default/mondialrelay/opening-hours.html @@ -0,0 +1,30 @@ +{strip} + {loop type="mondialrelay.selected-pickup-point" name="avec-pickup" order_id=$order_id} + {if count($OPENINGS) > 0} +
+

{intl l="Pickup relay opening hours:" d="mondialrelay.pdf.default"}

+ + + + + + {foreach $OPENINGS as $opening} + + + {if $opening.opening_time_1} + + {else} + + {/if} + {if $opening.opening_time_2} + + {else} + + {/if} + + {/foreach} +
{$opening.day}{$opening.opening_time_1} - {$opening.closing_time_1} {$opening.opening_time_2} - {$opening.closing_time_2} 
+
+ {/if} + {/loop} +{/strip} diff --git a/local/modules/MondialRelay/templates/pdf/default/mondialrelay/order-delivery-address.html b/local/modules/MondialRelay/templates/pdf/default/mondialrelay/order-delivery-address.html new file mode 100644 index 00000000..e88ff372 --- /dev/null +++ b/local/modules/MondialRelay/templates/pdf/default/mondialrelay/order-delivery-address.html @@ -0,0 +1,12 @@ +{strip} + {loop type="mondialrelay.selected-pickup-point" name="avec-pickup" order_id=$order_id} + {intl l="Mondial Relay pickup location #%num" num=$ID d="mondialrelay.pdf.default"}
+ {format_address + country_code=$COUNTRY + locality=$CITY + postal_code=$ZIPCODE + address_line1=$ADDRESS + organization=$NAME + } + {/loop} +{/strip} diff --git a/local/modules/MondialRelay/vendor/autoload.php b/local/modules/MondialRelay/vendor/autoload.php new file mode 100644 index 00000000..abc12a10 --- /dev/null +++ b/local/modules/MondialRelay/vendor/autoload.php @@ -0,0 +1,7 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Autoload; + +/** + * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. + * + * $loader = new \Composer\Autoload\ClassLoader(); + * + * // register classes with namespaces + * $loader->add('Symfony\Component', __DIR__.'/component'); + * $loader->add('Symfony', __DIR__.'/framework'); + * + * // activate the autoloader + * $loader->register(); + * + * // to enable searching the include path (eg. for PEAR packages) + * $loader->setUseIncludePath(true); + * + * In this example, if you try to use a class in the Symfony\Component + * namespace or one of its children (Symfony\Component\Console for instance), + * the autoloader will first look for the class under the component/ + * directory, and it will then fallback to the framework/ directory if not + * found before giving up. + * + * This class is loosely based on the Symfony UniversalClassLoader. + * + * @author Fabien Potencier + * @author Jordi Boggiano + * @see http://www.php-fig.org/psr/psr-0/ + * @see http://www.php-fig.org/psr/psr-4/ + */ +class ClassLoader +{ + // PSR-4 + private $prefixLengthsPsr4 = array(); + private $prefixDirsPsr4 = array(); + private $fallbackDirsPsr4 = array(); + + // PSR-0 + private $prefixesPsr0 = array(); + private $fallbackDirsPsr0 = array(); + + private $useIncludePath = false; + private $classMap = array(); + private $classMapAuthoritative = false; + private $missingClasses = array(); + private $apcuPrefix; + + public function getPrefixes() + { + if (!empty($this->prefixesPsr0)) { + return call_user_func_array('array_merge', $this->prefixesPsr0); + } + + return array(); + } + + public function getPrefixesPsr4() + { + return $this->prefixDirsPsr4; + } + + public function getFallbackDirs() + { + return $this->fallbackDirsPsr0; + } + + public function getFallbackDirsPsr4() + { + return $this->fallbackDirsPsr4; + } + + public function getClassMap() + { + return $this->classMap; + } + + /** + * @param array $classMap Class to filename map + */ + public function addClassMap(array $classMap) + { + if ($this->classMap) { + $this->classMap = array_merge($this->classMap, $classMap); + } else { + $this->classMap = $classMap; + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, either + * appending or prepending to the ones previously set for this prefix. + * + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories + */ + public function add($prefix, $paths, $prepend = false) + { + if (!$prefix) { + if ($prepend) { + $this->fallbackDirsPsr0 = array_merge( + (array) $paths, + $this->fallbackDirsPsr0 + ); + } else { + $this->fallbackDirsPsr0 = array_merge( + $this->fallbackDirsPsr0, + (array) $paths + ); + } + + return; + } + + $first = $prefix[0]; + if (!isset($this->prefixesPsr0[$first][$prefix])) { + $this->prefixesPsr0[$first][$prefix] = (array) $paths; + + return; + } + if ($prepend) { + $this->prefixesPsr0[$first][$prefix] = array_merge( + (array) $paths, + $this->prefixesPsr0[$first][$prefix] + ); + } else { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $this->prefixesPsr0[$first][$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, either + * appending or prepending to the ones previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories + * + * @throws \InvalidArgumentException + */ + public function addPsr4($prefix, $paths, $prepend = false) + { + if (!$prefix) { + // Register directories for the root namespace. + if ($prepend) { + $this->fallbackDirsPsr4 = array_merge( + (array) $paths, + $this->fallbackDirsPsr4 + ); + } else { + $this->fallbackDirsPsr4 = array_merge( + $this->fallbackDirsPsr4, + (array) $paths + ); + } + } elseif (!isset($this->prefixDirsPsr4[$prefix])) { + // Register directories for a new namespace. + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } elseif ($prepend) { + // Prepend directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + (array) $paths, + $this->prefixDirsPsr4[$prefix] + ); + } else { + // Append directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $this->prefixDirsPsr4[$prefix], + (array) $paths + ); + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, + * replacing any others previously set for this prefix. + * + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 base directories + */ + public function set($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr0 = (array) $paths; + } else { + $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, + * replacing any others previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-4 base directories + * + * @throws \InvalidArgumentException + */ + public function setPsr4($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr4 = (array) $paths; + } else { + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } + } + + /** + * Turns on searching the include path for class files. + * + * @param bool $useIncludePath + */ + public function setUseIncludePath($useIncludePath) + { + $this->useIncludePath = $useIncludePath; + } + + /** + * Can be used to check if the autoloader uses the include path to check + * for classes. + * + * @return bool + */ + public function getUseIncludePath() + { + return $this->useIncludePath; + } + + /** + * Turns off searching the prefix and fallback directories for classes + * that have not been registered with the class map. + * + * @param bool $classMapAuthoritative + */ + public function setClassMapAuthoritative($classMapAuthoritative) + { + $this->classMapAuthoritative = $classMapAuthoritative; + } + + /** + * Should class lookup fail if not found in the current class map? + * + * @return bool + */ + public function isClassMapAuthoritative() + { + return $this->classMapAuthoritative; + } + + /** + * APCu prefix to use to cache found/not-found classes, if the extension is enabled. + * + * @param string|null $apcuPrefix + */ + public function setApcuPrefix($apcuPrefix) + { + $this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null; + } + + /** + * The APCu prefix in use, or null if APCu caching is not enabled. + * + * @return string|null + */ + public function getApcuPrefix() + { + return $this->apcuPrefix; + } + + /** + * Registers this instance as an autoloader. + * + * @param bool $prepend Whether to prepend the autoloader or not + */ + public function register($prepend = false) + { + spl_autoload_register(array($this, 'loadClass'), true, $prepend); + } + + /** + * Unregisters this instance as an autoloader. + */ + public function unregister() + { + spl_autoload_unregister(array($this, 'loadClass')); + } + + /** + * Loads the given class or interface. + * + * @param string $class The name of the class + * @return bool|null True if loaded, null otherwise + */ + public function loadClass($class) + { + if ($file = $this->findFile($class)) { + includeFile($file); + + return true; + } + } + + /** + * Finds the path to the file where the class is defined. + * + * @param string $class The name of the class + * + * @return string|false The path if found, false otherwise + */ + public function findFile($class) + { + // class map lookup + if (isset($this->classMap[$class])) { + return $this->classMap[$class]; + } + if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { + return false; + } + if (null !== $this->apcuPrefix) { + $file = apcu_fetch($this->apcuPrefix.$class, $hit); + if ($hit) { + return $file; + } + } + + $file = $this->findFileWithExtension($class, '.php'); + + // Search for Hack files if we are running on HHVM + if (false === $file && defined('HHVM_VERSION')) { + $file = $this->findFileWithExtension($class, '.hh'); + } + + if (null !== $this->apcuPrefix) { + apcu_add($this->apcuPrefix.$class, $file); + } + + if (false === $file) { + // Remember that this class does not exist. + $this->missingClasses[$class] = true; + } + + return $file; + } + + private function findFileWithExtension($class, $ext) + { + // PSR-4 lookup + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; + + $first = $class[0]; + if (isset($this->prefixLengthsPsr4[$first])) { + $subPath = $class; + while (false !== $lastPos = strrpos($subPath, '\\')) { + $subPath = substr($subPath, 0, $lastPos); + $search = $subPath.'\\'; + if (isset($this->prefixDirsPsr4[$search])) { + $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); + foreach ($this->prefixDirsPsr4[$search] as $dir) { + if (file_exists($file = $dir . $pathEnd)) { + return $file; + } + } + } + } + } + + // PSR-4 fallback dirs + foreach ($this->fallbackDirsPsr4 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { + return $file; + } + } + + // PSR-0 lookup + if (false !== $pos = strrpos($class, '\\')) { + // namespaced class name + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); + } else { + // PEAR-like class name + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; + } + + if (isset($this->prefixesPsr0[$first])) { + foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { + if (0 === strpos($class, $prefix)) { + foreach ($dirs as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + } + } + } + + // PSR-0 fallback dirs + foreach ($this->fallbackDirsPsr0 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + + // PSR-0 include paths. + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { + return $file; + } + + return false; + } +} + +/** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + */ +function includeFile($file) +{ + include $file; +} diff --git a/local/modules/MondialRelay/vendor/composer/LICENSE b/local/modules/MondialRelay/vendor/composer/LICENSE new file mode 100644 index 00000000..f27399a0 --- /dev/null +++ b/local/modules/MondialRelay/vendor/composer/LICENSE @@ -0,0 +1,21 @@ + +Copyright (c) Nils Adermann, Jordi Boggiano + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/local/modules/MondialRelay/vendor/composer/autoload_classmap.php b/local/modules/MondialRelay/vendor/composer/autoload_classmap.php new file mode 100644 index 00000000..7a91153b --- /dev/null +++ b/local/modules/MondialRelay/vendor/composer/autoload_classmap.php @@ -0,0 +1,9 @@ + array($vendorDir . '/xaviborja/php-mondialrelay-api/src/MondialRelay'), +); diff --git a/local/modules/MondialRelay/vendor/composer/autoload_real.php b/local/modules/MondialRelay/vendor/composer/autoload_real.php new file mode 100644 index 00000000..c0faa38f --- /dev/null +++ b/local/modules/MondialRelay/vendor/composer/autoload_real.php @@ -0,0 +1,52 @@ += 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); + if ($useStaticLoader) { + require_once __DIR__ . '/autoload_static.php'; + + call_user_func(\Composer\Autoload\ComposerStaticInitc5f9e4166b08cdd2cfebefc863dd2000::getInitializer($loader)); + } else { + $map = require __DIR__ . '/autoload_namespaces.php'; + foreach ($map as $namespace => $path) { + $loader->set($namespace, $path); + } + + $map = require __DIR__ . '/autoload_psr4.php'; + foreach ($map as $namespace => $path) { + $loader->setPsr4($namespace, $path); + } + + $classMap = require __DIR__ . '/autoload_classmap.php'; + if ($classMap) { + $loader->addClassMap($classMap); + } + } + + $loader->register(true); + + return $loader; + } +} diff --git a/local/modules/MondialRelay/vendor/composer/autoload_static.php b/local/modules/MondialRelay/vendor/composer/autoload_static.php new file mode 100644 index 00000000..ba624e2a --- /dev/null +++ b/local/modules/MondialRelay/vendor/composer/autoload_static.php @@ -0,0 +1,31 @@ + + array ( + 'MondialRelay\\' => 13, + ), + ); + + public static $prefixDirsPsr4 = array ( + 'MondialRelay\\' => + array ( + 0 => __DIR__ . '/..' . '/xaviborja/php-mondialrelay-api/src/MondialRelay', + ), + ); + + public static function getInitializer(ClassLoader $loader) + { + return \Closure::bind(function () use ($loader) { + $loader->prefixLengthsPsr4 = ComposerStaticInitc5f9e4166b08cdd2cfebefc863dd2000::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInitc5f9e4166b08cdd2cfebefc863dd2000::$prefixDirsPsr4; + + }, null, ClassLoader::class); + } +} diff --git a/local/modules/MondialRelay/vendor/composer/installed.json b/local/modules/MondialRelay/vendor/composer/installed.json new file mode 100644 index 00000000..4805743d --- /dev/null +++ b/local/modules/MondialRelay/vendor/composer/installed.json @@ -0,0 +1,43 @@ +[ + { + "name": "xaviborja/php-mondialrelay-api", + "version": "dev-master", + "version_normalized": "9999999-dev", + "source": { + "type": "git", + "url": "https://github.com/xaviborja/php-mondialrelay-api.git", + "reference": "b57f7da5f3f2ce983c8bea3d8239b7fdbe7ebcbf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/xaviborja/php-mondialrelay-api/zipball/b57f7da5f3f2ce983c8bea3d8239b7fdbe7ebcbf", + "reference": "b57f7da5f3f2ce983c8bea3d8239b7fdbe7ebcbf", + "shasum": "" + }, + "require": { + "xaviborja/php-mondialrelay-api": "dev-master" + }, + "require-dev": { + "phpunit/phpunit": "^5.0" + }, + "time": "2017-06-21T12:22:06+00:00", + "type": "library", + "installation-source": "source", + "autoload": { + "psr-4": { + "MondialRelay\\": "src/MondialRelay/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Xavier Borja", + "email": "xavibm86@gmail.com" + } + ], + "description": "A PHP library for dealing with Mondial Relay API (http://api.mondialrelay.com)" + } +] diff --git a/local/modules/MondialRelay/vendor/xaviborja/php-mondialrelay-api/Readme.md b/local/modules/MondialRelay/vendor/xaviborja/php-mondialrelay-api/Readme.md new file mode 100644 index 00000000..5399f7c4 --- /dev/null +++ b/local/modules/MondialRelay/vendor/xaviborja/php-mondialrelay-api/Readme.md @@ -0,0 +1,5 @@ +PHP Library to Wrap Mondial Relay API + +## Installation + +composer require xaviborja/php-mondialrelay-api \ No newline at end of file diff --git a/local/modules/MondialRelay/vendor/xaviborja/php-mondialrelay-api/bin/phpunit b/local/modules/MondialRelay/vendor/xaviborja/php-mondialrelay-api/bin/phpunit new file mode 100644 index 00000000..4ba32564 --- /dev/null +++ b/local/modules/MondialRelay/vendor/xaviborja/php-mondialrelay-api/bin/phpunit @@ -0,0 +1 @@ +../vendor/phpunit/phpunit/phpunit \ No newline at end of file diff --git a/local/modules/MondialRelay/vendor/xaviborja/php-mondialrelay-api/composer.json b/local/modules/MondialRelay/vendor/xaviborja/php-mondialrelay-api/composer.json new file mode 100644 index 00000000..62cd3c2a --- /dev/null +++ b/local/modules/MondialRelay/vendor/xaviborja/php-mondialrelay-api/composer.json @@ -0,0 +1,26 @@ +{ + "name": "xaviborja/php-mondialrelay-api", + "description": "A PHP library for dealing with Mondial Relay API (http://api.mondialrelay.com)", + "license": "MIT", + "authors": [ + { + "name": "Xavier Borja", + "email": "xavibm86@gmail.com" + } + ], + "require-dev": { + "phpunit/phpunit": "^5.0" + }, + "autoload": { + "psr-4": {"MondialRelay\\": "src/MondialRelay/"} + }, + "autoload-dev": { + "psr-4": {"MondialRelay\\": "tests/MondialRelay/"} + }, + "config": { + "bin-dir": "bin" + }, + "require": { + "xaviborja/php-mondialrelay-api": "dev-master" + } +} diff --git a/local/modules/MondialRelay/vendor/xaviborja/php-mondialrelay-api/composer.lock b/local/modules/MondialRelay/vendor/xaviborja/php-mondialrelay-api/composer.lock new file mode 100644 index 00000000..8a888c40 --- /dev/null +++ b/local/modules/MondialRelay/vendor/xaviborja/php-mondialrelay-api/composer.lock @@ -0,0 +1,1334 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "hash": "8c06eaf6adaabe01bf46a48dc8762f8d", + "content-hash": "8f1695d3c1fcb4d11101af5575b9d8af", + "packages": [], + "packages-dev": [ + { + "name": "doctrine/instantiator", + "version": "1.0.5", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", + "shasum": "" + }, + "require": { + "php": ">=5.3,<8.0-DEV" + }, + "require-dev": { + "athletic/athletic": "~0.1.8", + "ext-pdo": "*", + "ext-phar": "*", + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "~2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://github.com/doctrine/instantiator", + "keywords": [ + "constructor", + "instantiate" + ], + "time": "2015-06-14 21:17:01" + }, + { + "name": "myclabs/deep-copy", + "version": "1.6.1", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "8e6e04167378abf1ddb4d3522d8755c5fd90d102" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/8e6e04167378abf1ddb4d3522d8755c5fd90d102", + "reference": "8e6e04167378abf1ddb4d3522d8755c5fd90d102", + "shasum": "" + }, + "require": { + "php": ">=5.4.0" + }, + "require-dev": { + "doctrine/collections": "1.*", + "phpunit/phpunit": "~4.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Create deep copies (clones) of your objects", + "homepage": "https://github.com/myclabs/DeepCopy", + "keywords": [ + "clone", + "copy", + "duplicate", + "object", + "object graph" + ], + "time": "2017-04-12 18:52:22" + }, + { + "name": "phpdocumentor/reflection-common", + "version": "1.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionCommon.git", + "reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/144c307535e82c8fdcaacbcfc1d6d8eeb896687c", + "reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c", + "shasum": "" + }, + "require": { + "php": ">=5.5" + }, + "require-dev": { + "phpunit/phpunit": "^4.6" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": [ + "src" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jaap van Otterdijk", + "email": "opensource@ijaap.nl" + } + ], + "description": "Common reflection classes used by phpdocumentor to reflect the code structure", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "FQSEN", + "phpDocumentor", + "phpdoc", + "reflection", + "static analysis" + ], + "time": "2015-12-27 11:43:31" + }, + { + "name": "phpdocumentor/reflection-docblock", + "version": "3.1.1", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/8331b5efe816ae05461b7ca1e721c01b46bafb3e", + "reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e", + "shasum": "" + }, + "require": { + "php": ">=5.5", + "phpdocumentor/reflection-common": "^1.0@dev", + "phpdocumentor/type-resolver": "^0.2.0", + "webmozart/assert": "^1.0" + }, + "require-dev": { + "mockery/mockery": "^0.9.4", + "phpunit/phpunit": "^4.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } + ], + "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", + "time": "2016-09-30 07:12:33" + }, + { + "name": "phpdocumentor/type-resolver", + "version": "0.2.1", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/TypeResolver.git", + "reference": "e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb", + "reference": "e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb", + "shasum": "" + }, + "require": { + "php": ">=5.5", + "phpdocumentor/reflection-common": "^1.0" + }, + "require-dev": { + "mockery/mockery": "^0.9.4", + "phpunit/phpunit": "^5.2||^4.8.24" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } + ], + "time": "2016-11-25 06:54:22" + }, + { + "name": "phpspec/prophecy", + "version": "v1.7.0", + "source": { + "type": "git", + "url": "https://github.com/phpspec/prophecy.git", + "reference": "93d39f1f7f9326d746203c7c056f300f7f126073" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/93d39f1f7f9326d746203c7c056f300f7f126073", + "reference": "93d39f1f7f9326d746203c7c056f300f7f126073", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.0.2", + "php": "^5.3|^7.0", + "phpdocumentor/reflection-docblock": "^2.0|^3.0.2", + "sebastian/comparator": "^1.1|^2.0", + "sebastian/recursion-context": "^1.0|^2.0|^3.0" + }, + "require-dev": { + "phpspec/phpspec": "^2.5|^3.2", + "phpunit/phpunit": "^4.8 || ^5.6.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.6.x-dev" + } + }, + "autoload": { + "psr-0": { + "Prophecy\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Konstantin Kudryashov", + "email": "ever.zet@gmail.com", + "homepage": "http://everzet.com" + }, + { + "name": "Marcello Duarte", + "email": "marcello.duarte@gmail.com" + } + ], + "description": "Highly opinionated mocking framework for PHP 5.3+", + "homepage": "https://github.com/phpspec/prophecy", + "keywords": [ + "Double", + "Dummy", + "fake", + "mock", + "spy", + "stub" + ], + "time": "2017-03-02 20:05:34" + }, + { + "name": "phpunit/php-code-coverage", + "version": "4.0.8", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "ef7b2f56815df854e66ceaee8ebe9393ae36a40d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ef7b2f56815df854e66ceaee8ebe9393ae36a40d", + "reference": "ef7b2f56815df854e66ceaee8ebe9393ae36a40d", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-xmlwriter": "*", + "php": "^5.6 || ^7.0", + "phpunit/php-file-iterator": "^1.3", + "phpunit/php-text-template": "^1.2", + "phpunit/php-token-stream": "^1.4.2 || ^2.0", + "sebastian/code-unit-reverse-lookup": "^1.0", + "sebastian/environment": "^1.3.2 || ^2.0", + "sebastian/version": "^1.0 || ^2.0" + }, + "require-dev": { + "ext-xdebug": "^2.1.4", + "phpunit/phpunit": "^5.7" + }, + "suggest": { + "ext-xdebug": "^2.5.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "time": "2017-04-02 07:44:40" + }, + { + "name": "phpunit/php-file-iterator", + "version": "1.4.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/3cc8f69b3028d0f96a9078e6295d86e9bf019be5", + "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "time": "2016-10-03 07:40:28" + }, + { + "name": "phpunit/php-text-template", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "time": "2015-06-21 13:50:34" + }, + { + "name": "phpunit/php-timer", + "version": "1.0.9", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", + "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", + "shasum": "" + }, + "require": { + "php": "^5.3.3 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "time": "2017-02-26 11:10:40" + }, + { + "name": "phpunit/php-token-stream", + "version": "1.4.11", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-token-stream.git", + "reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/e03f8f67534427a787e21a385a67ec3ca6978ea7", + "reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Wrapper around PHP's tokenizer extension.", + "homepage": "https://github.com/sebastianbergmann/php-token-stream/", + "keywords": [ + "tokenizer" + ], + "time": "2017-02-27 10:12:30" + }, + { + "name": "phpunit/phpunit", + "version": "5.7.19", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "69c4f49ff376af2692bad9cebd883d17ebaa98a1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/69c4f49ff376af2692bad9cebd883d17ebaa98a1", + "reference": "69c4f49ff376af2692bad9cebd883d17ebaa98a1", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-xml": "*", + "myclabs/deep-copy": "~1.3", + "php": "^5.6 || ^7.0", + "phpspec/prophecy": "^1.6.2", + "phpunit/php-code-coverage": "^4.0.4", + "phpunit/php-file-iterator": "~1.4", + "phpunit/php-text-template": "~1.2", + "phpunit/php-timer": "^1.0.6", + "phpunit/phpunit-mock-objects": "^3.2", + "sebastian/comparator": "^1.2.4", + "sebastian/diff": "~1.2", + "sebastian/environment": "^1.3.4 || ^2.0", + "sebastian/exporter": "~2.0", + "sebastian/global-state": "^1.1", + "sebastian/object-enumerator": "~2.0", + "sebastian/resource-operations": "~1.0", + "sebastian/version": "~1.0.3|~2.0", + "symfony/yaml": "~2.1|~3.0" + }, + "conflict": { + "phpdocumentor/reflection-docblock": "3.0.2" + }, + "require-dev": { + "ext-pdo": "*" + }, + "suggest": { + "ext-xdebug": "*", + "phpunit/php-invoker": "~1.1" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.7.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "time": "2017-04-03 02:22:27" + }, + { + "name": "phpunit/phpunit-mock-objects", + "version": "3.4.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", + "reference": "3ab72b65b39b491e0c011e2e09bb2206c2aa8e24" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/3ab72b65b39b491e0c011e2e09bb2206c2aa8e24", + "reference": "3ab72b65b39b491e0c011e2e09bb2206c2aa8e24", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.0.2", + "php": "^5.6 || ^7.0", + "phpunit/php-text-template": "^1.2", + "sebastian/exporter": "^1.2 || ^2.0" + }, + "conflict": { + "phpunit/phpunit": "<5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.4" + }, + "suggest": { + "ext-soap": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Mock Object library for PHPUnit", + "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", + "keywords": [ + "mock", + "xunit" + ], + "time": "2016-12-08 20:27:08" + }, + { + "name": "sebastian/code-unit-reverse-lookup", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", + "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", + "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.7 || ^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Looks up which function or method a line of code belongs to", + "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "time": "2017-03-04 06:30:41" + }, + { + "name": "sebastian/comparator", + "version": "1.2.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", + "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/diff": "~1.2", + "sebastian/exporter": "~1.2 || ~2.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "http://www.github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "time": "2017-01-29 09:50:25" + }, + { + "name": "sebastian/diff", + "version": "1.4.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "13edfd8706462032c2f52b4b862974dd46b71c9e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/13edfd8706462032c2f52b4b862974dd46b71c9e", + "reference": "13edfd8706462032c2f52b4b862974dd46b71c9e", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Diff implementation", + "homepage": "https://github.com/sebastianbergmann/diff", + "keywords": [ + "diff" + ], + "time": "2015-12-08 07:14:41" + }, + { + "name": "sebastian/environment", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/5795ffe5dc5b02460c3e34222fee8cbe245d8fac", + "reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "time": "2016-11-26 07:53:53" + }, + { + "name": "sebastian/exporter", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4", + "reference": "ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/recursion-context": "~2.0" + }, + "require-dev": { + "ext-mbstring": "*", + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "http://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "time": "2016-11-19 08:54:04" + }, + { + "name": "sebastian/global-state", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bc37d50fea7d017d3d340f230811c9f1d7280af4", + "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "suggest": { + "ext-uopz": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Snapshotting of global state", + "homepage": "http://www.github.com/sebastianbergmann/global-state", + "keywords": [ + "global state" + ], + "time": "2015-10-12 03:26:01" + }, + { + "name": "sebastian/object-enumerator", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-enumerator.git", + "reference": "1311872ac850040a79c3c058bea3e22d0f09cbb7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/1311872ac850040a79c3c058bea3e22d0f09cbb7", + "reference": "1311872ac850040a79c3c058bea3e22d0f09cbb7", + "shasum": "" + }, + "require": { + "php": ">=5.6", + "sebastian/recursion-context": "~2.0" + }, + "require-dev": { + "phpunit/phpunit": "~5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Traverses array structures and object graphs to enumerate all referenced objects", + "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "time": "2017-02-18 15:18:39" + }, + { + "name": "sebastian/recursion-context", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "2c3ba150cbec723aa057506e73a8d33bdb286c9a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/2c3ba150cbec723aa057506e73a8d33bdb286c9a", + "reference": "2c3ba150cbec723aa057506e73a8d33bdb286c9a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "time": "2016-11-19 07:33:16" + }, + { + "name": "sebastian/resource-operations", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/resource-operations.git", + "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", + "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", + "shasum": "" + }, + "require": { + "php": ">=5.6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides a list of PHP built-in functions that operate on resources", + "homepage": "https://www.github.com/sebastianbergmann/resource-operations", + "time": "2015-07-28 20:34:47" + }, + { + "name": "sebastian/version", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019", + "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "time": "2016-10-03 07:35:21" + }, + { + "name": "symfony/yaml", + "version": "v3.2.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/yaml.git", + "reference": "62b4cdb99d52cb1ff253c465eb1532a80cebb621" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/yaml/zipball/62b4cdb99d52cb1ff253c465eb1532a80cebb621", + "reference": "62b4cdb99d52cb1ff253c465eb1532a80cebb621", + "shasum": "" + }, + "require": { + "php": ">=5.5.9" + }, + "require-dev": { + "symfony/console": "~2.8|~3.0" + }, + "suggest": { + "symfony/console": "For validating YAML files using the lint command" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.2-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Yaml\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Yaml Component", + "homepage": "https://symfony.com", + "time": "2017-03-20 09:45:15" + }, + { + "name": "webmozart/assert", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/webmozart/assert.git", + "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozart/assert/zipball/2db61e59ff05fe5126d152bd0655c9ea113e550f", + "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f", + "shasum": "" + }, + "require": { + "php": "^5.3.3 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.6", + "sebastian/version": "^1.0.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "autoload": { + "psr-4": { + "Webmozart\\Assert\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Assertions to validate method input/output with nice error messages.", + "keywords": [ + "assert", + "check", + "validate" + ], + "time": "2016-11-23 20:04:58" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": { + "xaviborja/php-mondialrelay-api": 20 + }, + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [] +} diff --git a/local/modules/MondialRelay/vendor/xaviborja/php-mondialrelay-api/phpunit.xml.dist b/local/modules/MondialRelay/vendor/xaviborja/php-mondialrelay-api/phpunit.xml.dist new file mode 100644 index 00000000..44cdcf7c --- /dev/null +++ b/local/modules/MondialRelay/vendor/xaviborja/php-mondialrelay-api/phpunit.xml.dist @@ -0,0 +1,24 @@ + + + + + + + ./tests/ + + + + + + ./src/ + + + \ No newline at end of file diff --git a/local/modules/MondialRelay/vendor/xaviborja/php-mondialrelay-api/src/MondialRelay/ApiClient.php b/local/modules/MondialRelay/vendor/xaviborja/php-mondialrelay-api/src/MondialRelay/ApiClient.php new file mode 100644 index 00000000..adcf2091 --- /dev/null +++ b/local/modules/MondialRelay/vendor/xaviborja/php-mondialrelay-api/src/MondialRelay/ApiClient.php @@ -0,0 +1,132 @@ +websiteId = $websiteId; + $this->websiteKey = $websiteKey; + $this->client = $soapClient; + } + + public function findDeliveryPoints(array $request) + { + try { + $request = $this->decorateRequest($request); + $result = $this->client->WSI4_PointRelais_Recherche($request); + + $pointFactory = new PointFactory(); + $this->checkResponse('WSI4_PointRelais_Recherche', $result); + $delivery_points = []; + if (!property_exists($result->WSI4_PointRelais_RechercheResult, 'PointsRelais')) { + return $delivery_points; + } + if (!property_exists($result->WSI4_PointRelais_RechercheResult->PointsRelais, 'PointRelais_Details')) { + return $delivery_points; + } + if (is_object($result->WSI4_PointRelais_RechercheResult->PointsRelais->PointRelais_Details)) { + $delivery_points[] = $pointFactory->create($result->WSI4_PointRelais_RechercheResult->PointsRelais->PointRelais_Details); + return $delivery_points; + } + foreach ($result->WSI4_PointRelais_RechercheResult->PointsRelais->PointRelais_Details as $destination_point) { + $delivery_points[] = $pointFactory->create($destination_point); + } + return $delivery_points; + } catch (\SoapFault $e) { + throw new \Exception(); + } + + } + + public function findDeliveryPoint($id, $country) + { + try { + return $this->findDeliveryPoints(array( + 'NumPointRelais' => $id, + 'Pays' => $country + )); + + } catch (\SoapFault $e) { + throw new \Exception(); + } + } + + private function decorateRequest($request) + { + $key = $this->websiteId; + foreach ($request as $parameter => $value) { + $key .= $value; + } + $key .= $this->websiteKey; + $request['Enseigne'] = $this->websiteId; + $request['Security'] = strtoupper(md5($key)); + return $request; + } + + private function checkResponse($method, $result) + { + $method = $method . "Result"; + if ($result->{$method}->STAT != 0) { + $request = $this->decorateRequest([ + 'STAT_ID' => $result->{$method}->STAT, + 'Langue' => 'FR', + ]); + $error_response = $this->client->WSI2_STAT_Label($request); + throw new \InvalidArgumentException($error_response->WSI2_STAT_LabelResult); + } + } + + public function createExpedition(array $request) + { + try { + + $request = $this->decorateRequest($request); + $result = $this->client->WSI2_CreationExpedition($request); + $this->checkResponse('WSI2_CreationExpedition', $result); + + return (new ExpeditionFactory())->create($result->WSI2_CreationExpeditionResult->STAT, + $result->WSI2_CreationExpeditionResult->ExpeditionNum, + $result->WSI2_CreationExpeditionResult->TRI_AgenceCode, + $result->WSI2_CreationExpeditionResult->TRI_Groupe, + $result->WSI2_CreationExpeditionResult->TRI_Navette, + $result->WSI2_CreationExpeditionResult->TRI_Agence, + $result->WSI2_CreationExpeditionResult->TRI_TourneeCode, + $result->WSI2_CreationExpeditionResult->TRI_LivraisonMode, + $result->WSI2_CreationExpeditionResult->CodesBarres->string); + + } catch (\SoapFault $e) { + throw new \Exception(); + } + } + + public function generateTickets(array $request) + { + + try { + + $request = $this->decorateRequest($request); + $result = $this->client->WSI3_GetEtiquettes($request); + $this->checkResponse('WSI3_GetEtiquettes', $result); + + return (new TicketFactory())->create($result->WSI3_GetEtiquettesResult->STAT, + $result->WSI3_GetEtiquettesResult->URL_PDF_A4, + $result->WSI3_GetEtiquettesResult->URL_PDF_A5, + $result->WSI3_GetEtiquettesResult->URL_PDF_10x15); + + } catch (\SoapFault $e) { + throw new \Exception(); + } + } + +} diff --git a/local/modules/MondialRelay/vendor/xaviborja/php-mondialrelay-api/src/MondialRelay/BussinessHours/BussinessHours.php b/local/modules/MondialRelay/vendor/xaviborja/php-mondialrelay-api/src/MondialRelay/BussinessHours/BussinessHours.php new file mode 100644 index 00000000..2da171c7 --- /dev/null +++ b/local/modules/MondialRelay/vendor/xaviborja/php-mondialrelay-api/src/MondialRelay/BussinessHours/BussinessHours.php @@ -0,0 +1,51 @@ +day = $day; + $this->openingTime1 = $openingTime1; + $this->closingTime1 = $closingTime1; + $this->openingTime2 = $openingTime2; + $this->closingTime2 = $closingTime2; + } + + public function day() + { + return $this->day; + } + + public function openingTime1() + { + return $this->openingTime1; + } + + public function closingTime1() + { + return $this->closingTime1; + } + + public function openingTime2() + { + return $this->openingTime2; + } + + public function closingTime2() + { + return $this->closingTime2; + } + + + +} \ No newline at end of file diff --git a/local/modules/MondialRelay/vendor/xaviborja/php-mondialrelay-api/src/MondialRelay/BussinessHours/BussinessHoursFactory.php b/local/modules/MondialRelay/vendor/xaviborja/php-mondialrelay-api/src/MondialRelay/BussinessHours/BussinessHoursFactory.php new file mode 100644 index 00000000..94e81ccc --- /dev/null +++ b/local/modules/MondialRelay/vendor/xaviborja/php-mondialrelay-api/src/MondialRelay/BussinessHours/BussinessHoursFactory.php @@ -0,0 +1,39 @@ + 'Horaires_Lundi', + 'tuesday' => 'Horaires_Mardi', + 'wednesday' => 'Horaires_Mercredi', + 'thursday' => 'Horaires_Jeudi', + 'friday' => 'Horaires_Vendredi', + 'saturday' => 'Horaires_Samedi', + 'sunday' => 'Horaires_Dimanche' + ]; + + public function create($response) + { + $bussines_hours = []; + foreach (self::$property_days_name as $day => $property) { + $bussines_hours[] = new BussinessHours( + $day, + $response->$property->string[0], + $response->$property->string[1], + $response->$property->string[2], + $response->$property->string[3] + ); + } + return $bussines_hours; + + } +} \ No newline at end of file diff --git a/local/modules/MondialRelay/vendor/xaviborja/php-mondialrelay-api/src/MondialRelay/Expedition/Expedition.php b/local/modules/MondialRelay/vendor/xaviborja/php-mondialrelay-api/src/MondialRelay/Expedition/Expedition.php new file mode 100644 index 00000000..42d83146 --- /dev/null +++ b/local/modules/MondialRelay/vendor/xaviborja/php-mondialrelay-api/src/MondialRelay/Expedition/Expedition.php @@ -0,0 +1,124 @@ +stat = $stat; + $this->expeditionNum = $expeditionNum; + $this->triAgenceCode = $triAgenceCode; + $this->triGroupe = $triGroupe; + $this->triNavette = $triNavette; + $this->triAgence = $triAgence; + $this->triTourneeCode = $triTourneeCode; + $this->triLivraisonMode = $triLivraisonMode; + $this->codesBarres = $codesBarres; + } + + /** + * @return mixed + */ + public function stat() + { + return $this->stat; + } + + /** + * @return mixed + */ + public function expeditionNum() + { + return $this->expeditionNum; + } + + /** + * @return mixed + */ + public function triAgenceCode() + { + return $this->triAgenceCode; + } + + /** + * @return mixed + */ + public function triGroupe() + { + return $this->triGroupe; + } + + /** + * @return mixed + */ + public function triNavette() + { + return $this->triNavette; + } + + /** + * @return mixed + */ + public function triAgence() + { + return $this->triAgence; + } + + /** + * @return mixed + */ + public function triTourneeCode() + { + return $this->triTourneeCode; + } + + /** + * @return mixed + */ + public function triLivraisonMode() + { + return $this->triLivraisonMode; + } + + /** + * @return mixed + */ + public function codesBarres() + { + return $this->codesBarres; + } + +} \ No newline at end of file diff --git a/local/modules/MondialRelay/vendor/xaviborja/php-mondialrelay-api/src/MondialRelay/Expedition/ExpeditionFactory.php b/local/modules/MondialRelay/vendor/xaviborja/php-mondialrelay-api/src/MondialRelay/Expedition/ExpeditionFactory.php new file mode 100644 index 00000000..62e6f4ea --- /dev/null +++ b/local/modules/MondialRelay/vendor/xaviborja/php-mondialrelay-api/src/MondialRelay/Expedition/ExpeditionFactory.php @@ -0,0 +1,34 @@ +id = $id; + $this->latitude = $latitude; + $this->longitude = $longitude; + $this->cp = $cp; + $this->address = $address; + $this->city = $city; + $this->country = $country; + $this->location = $location; + $this->activityType = $activityType; + $this->information = $information; + $this->distance = $distance; + $this->business_hours = $business_hours; + } + + + public function id() + { + return $this->id; + } + + public function address() + { + return $this->address; + } + + public function latitude() + { + return $this->latitude; + } + + public function longitude() + { + return $this->longitude; + } + + public function cp() + { + return $this->cp; + } + + public function city() + { + return $this->city; + } + + public function country() + { + return $this->country; + } + + public function location() + { + return $this->location; + } + + public function activityType() + { + return $this->activityType; + } + + public function information() + { + return $this->information; + } + + public function distance() + { + return $this->distance; + } + + public function business_hours() + { + return $this->business_hours; + } + + +} diff --git a/local/modules/MondialRelay/vendor/xaviborja/php-mondialrelay-api/src/MondialRelay/Point/PointFactory.php b/local/modules/MondialRelay/vendor/xaviborja/php-mondialrelay-api/src/MondialRelay/Point/PointFactory.php new file mode 100644 index 00000000..fb3491ee --- /dev/null +++ b/local/modules/MondialRelay/vendor/xaviborja/php-mondialrelay-api/src/MondialRelay/Point/PointFactory.php @@ -0,0 +1,51 @@ +$var)) { + return $response->$var; + } else { + return ''; + } + } + + public function create($response) + { + $bussines_hours = (new BussinessHoursFactory())->create($response); + return new Point( + $response->Num, + str_replace(",", ".", $response->Latitude), + str_replace(",", ".", $response->Longitude), + $response->CP, + [ + trim($this->safeGet($response, 'LgAdr1')), + trim($this->safeGet($response, 'LgAdr2')), + trim($this->safeGet($response, 'LgAdr3')), + trim($this->safeGet($response, 'LgAdr4')), + ], + $response->Ville, + $response->Pays, + [ + $this->safeGet($response, 'Localisation1'), + $this->safeGet($response, 'Localisation2'), + ], + $response->TypeActivite, + $response->Information, + $response->Distance, + $bussines_hours + ); + + } +} diff --git a/local/modules/MondialRelay/vendor/xaviborja/php-mondialrelay-api/src/MondialRelay/Ticket/Ticket.php b/local/modules/MondialRelay/vendor/xaviborja/php-mondialrelay-api/src/MondialRelay/Ticket/Ticket.php new file mode 100644 index 00000000..83a1b0e8 --- /dev/null +++ b/local/modules/MondialRelay/vendor/xaviborja/php-mondialrelay-api/src/MondialRelay/Ticket/Ticket.php @@ -0,0 +1,63 @@ +stat = $stat; + $this->urlPDFA4 = $urlPDFA4; + $this->urlPDFA5 = $urlPDFA5; + $this->url10x15 = $url10x15; + } + + /** + * @return mixed + */ + public function getStat() + { + return $this->stat; + } + + /** + * @return mixed + */ + public function getUrlPDFA4() + { + return $this->urlPDFA4; + } + + /** + * @return mixed + */ + public function getUrlPDFA5() + { + return $this->urlPDFA5; + } + + /** + * @return mixed + */ + public function getUrl10x15() + { + return $this->url10x15; + } + +} \ No newline at end of file diff --git a/local/modules/MondialRelay/vendor/xaviborja/php-mondialrelay-api/src/MondialRelay/Ticket/TicketFactory.php b/local/modules/MondialRelay/vendor/xaviborja/php-mondialrelay-api/src/MondialRelay/Ticket/TicketFactory.php new file mode 100644 index 00000000..e1965682 --- /dev/null +++ b/local/modules/MondialRelay/vendor/xaviborja/php-mondialrelay-api/src/MondialRelay/Ticket/TicketFactory.php @@ -0,0 +1,13 @@ +client = new ApiClient(new \SoapClient("http://api.mondialrelay.com/Web_Services.asmx?WSDL"), + self::WEBSITEID, self::WEBSITEKEY); + } + + /** + * @test + * @expectedException \InvalidArgumentException + */ + public function itShouldReturnAnExceptionInvalidParametersAreSent() + { + $this->client->findDeliveryPoints([]); + } + + /** + * @test + */ + public function itShouldReturnAnEmptyStringIfNoPointsAreFound() + { + $points = $this->client->findDeliveryPoints(array( + 'Pays' => "ES", + 'Ville' => "", + 'CP' => '12345', + 'Latitude' => "", + 'Longitude' => "", + 'Taille' => "", + 'Poids' => "", + 'Action' => "", + 'DelaiEnvoi' => "0", + 'RayonRecherche' => "0" + )); + $this->assertEmpty($points); + } + + /** + * @test + */ + public function itShouldReturnAnArrayOfPointsIfParametersMatch() + { + $points = $this->client->findDeliveryPoints(array( + 'Pays' => "ES", + 'Ville' => "", + 'CP' => '08915', + 'Latitude' => "", + 'Longitude' => "", + 'Taille' => "", + 'Poids' => "", + 'Action' => "", + 'DelaiEnvoi' => "0", + 'RayonRecherche' => "20" + )); + foreach ($points as $point) { + $this->assertInstanceOf(Point::class, $point); + } + } + + /** + * @test + */ + public function itShouldReturnAValidPoint() + { + $point = $this->client->findDeliveryPoint('077712', 'ES'); + $this->assertInstanceOf(Point::class, $point); + } + + /** + * @test + */ + public function itShouldReturnAValidExpedition() + { + $expedition = $this->client->createExpedition(array( + 'ModeCol' => 'CCC', /*^(CCC|CDR|CDS|REL)$*/ + 'ModeLiv' => '24R', /*^(LCC|LD1|LDS|24R|24L|24X|ESP|DRI)$*/ + 'NDossier' => '55415', + 'NClient' => '147014', + 'Expe_Langage' => 'ES', + 'Expe_Ad1' => 'Albert', + 'Expe_Ad2' => '', + 'Expe_Ad3' => 'Calle Falsa', + 'Expe_Ad4' => '123', + 'Expe_Ville' => 'Granollers', + 'Expe_CP' => '08402', + 'Expe_Pays' => 'ES', + 'Expe_Tel1' => '+34666234566', + 'Expe_Tel2' => '', + 'Expe_Mail' => 'pepe@test.com', + 'Dest_Langage' => 'ES', + 'Dest_Ad1' => 'Client1', + 'Dest_Ad2' => 'LLIBRERIA CASABELLA', + 'Dest_Ad3' => 'AV PUIG I CADAFALCH', + 'Dest_Ad4' => '10', + 'Dest_Ville' => 'Granollers', + 'Dest_CP' => '08402', + 'Dest_Pays' => 'ES', + 'Dest_Tel1' => '', + 'Dest_Mail' => 'test@test.com', + 'Poids' => '123', + 'Longueur' => '1', + 'Taille' => 'XL', + 'NbColis' => '1', + 'CRT_Valeur' => '1780', + 'CRT_Devise' => 'EUR', + 'Exp_Valeur' => '1780', + 'Exp_Devise' => 'EUR', + 'COL_Rel_Pays' => 'ES', + 'COL_Rel' => '0000', + 'LIV_Rel_Pays' => 'ES', + 'LIV_Rel' => '053589', + 'TAvisage' => 'N', + 'TReprise' => 'N', + 'Montage' => '0', + 'TRDV' => 'N', + 'Instructions' => '0', + 'Assurance' => '' + )); + $this->assertInstanceOf(Expedition::class, $expedition); + } + + /** + * @test + */ + public function itShouldReturnAValidTicket() + { + $ticket = $this->client->generateTickets(array( + 'Expeditions' => '12345678', /*^[0-9]{8}(;[0-9]{8})*$*/ + 'Langue' => 'ES' /*^[A-Z]{2}$*/ + )); + + $this->assertInstanceOf(Ticket::class, $ticket); + } + + + /** + * @test + */ + public function itShouldReturnAnArrayOfValidTickets() + { + $tickets = $this->client->generateTickets(array( + 'Expeditions' => '12345678;87654321', /*^[0-9]{8}(;[0-9]{8})*$*/ + 'Langue' => 'ES' /*^[A-Z]{2}$*/ + )); + + foreach ($tickets as $ticket) { + $this->assertInstanceOf(Ticket::class, $ticket); + } + } + + /** + * @test + * @expectedException \InvalidArgumentException + */ + public function itShouldReturnAnExceptionInvalidParametersOfTicketsAreSent() + { + $this->client->generateTickets([]); + } + + /** + * @test + * @expectedException \InvalidArgumentException + */ + public function itShouldReturnAnExceptionInvalidParametersOfExpeditionsAreSent() + { + $this->client->createExpedition([]); + } + +}