From 154fff5134d7bded98f4967e2abb313802c4221b Mon Sep 17 00:00:00 2001 From: TheCoreDev Date: Mon, 25 Jan 2021 18:44:19 +0100 Subject: [PATCH] D'autres fichiers en conf --- local/modules/.gitkeep | 0 local/modules/HookTest/Config/config.xml | 55 + local/modules/HookTest/Config/module.xml | 18 + local/modules/HookTest/Hook/FrontHook.php | 170 ++ local/modules/HookTest/HookTest.php | 21 + local/modules/HookTest/I18n/en_US.php | 8 + local/modules/HookTest/I18n/fr_FR.php | 7 + .../I18n/frontOffice/default/en_US.php | 5 + .../I18n/frontOffice/default/fr_FR.php | 4 + local/modules/HookTest/composer.json | 10 + .../frontOffice/default/assets/css/print.css | 1 + .../frontOffice/default/assets/css/style1.css | 1 + .../frontOffice/default/assets/css/style2.css | 1 + .../frontOffice/default/assets/css/style3.css | 1 + .../frontOffice/default/assets/css/styles.css | 1 + .../frontOffice/default/assets/js/script.js | 1 + .../templates/frontOffice/default/dump.txt | 2 + .../default/main-navbar-secondary.html | 71 + .../frontOffice/default/override-assets.html | 13 + .../frontOffice/default/override1.html | 1 + .../frontOffice/default/override2.html | 1 + .../frontOffice/default/override3.html | 1 + .../templates/frontOffice/default/render.html | 2 + .../hooktest/assets/css/style2.css | 1 + .../frontOffice/hooktest/override2.html | 1 + .../PaymentCondition/Config/config.xml | 49 + .../PaymentCondition/Config/module.xml | 41 + .../PaymentCondition/Config/routing.xml | 35 + .../PaymentCondition/Config/schema.xml | 71 + .../modules/PaymentCondition/Config/sqldb.map | 2 + .../PaymentCondition/Config/thelia.sql | 125 ++ .../Controller/AdminController.php | 17 + .../Controller/AreaConditionController.php | 62 + .../CustomerFamilyConditionController.php | 78 + .../DeliveryConditionController.php | 62 + .../EventListeners/PaymentLoopExtend.php | 185 +++ .../Hook/CustomerEditHook.php | 31 + .../I18n/backOffice/default/fr_FR.php | 12 + local/modules/PaymentCondition/I18n/en_US.php | 4 + local/modules/PaymentCondition/I18n/fr_FR.php | 4 + .../Model/Base/PaymentAreaCondition.php | 1388 +++++++++++++++++ .../Model/Base/PaymentAreaConditionQuery.php | 646 ++++++++ .../Base/PaymentCustomerFamilyCondition.php | 1311 ++++++++++++++++ .../PaymentCustomerFamilyConditionQuery.php | 564 +++++++ .../Model/Base/PaymentDeliveryCondition.php | 1386 ++++++++++++++++ .../Base/PaymentDeliveryConditionQuery.php | 645 ++++++++ .../Map/PaymentAreaConditionTableMap.php | 428 +++++ ...PaymentCustomerFamilyConditionTableMap.php | 427 +++++ .../Map/PaymentDeliveryConditionTableMap.php | 428 +++++ .../Model/PaymentAreaCondition.php | 10 + .../Model/PaymentAreaConditionQuery.php | 21 + .../Model/PaymentCustomerCondition.php | 20 + .../Model/PaymentCustomerConditionQuery.php | 20 + .../Model/PaymentCustomerFamilyCondition.php | 10 + .../PaymentCustomerFamilyConditionQuery.php | 21 + .../Model/PaymentCustomerModuleCondition.php | 20 + .../PaymentCustomerModuleConditionQuery.php | 20 + .../Model/PaymentDeliveryCondition.php | 10 + .../Model/PaymentDeliveryConditionQuery.php | 21 + .../PaymentCondition/PaymentCondition.php | 34 + local/modules/PaymentCondition/Readme.md | 19 + local/modules/PaymentCondition/composer.json | 11 + .../payment-condition/configuration.html | 62 + .../payment-condition/customer_edit_hook.html | 25 + .../payment-condition/customer_family.html | 59 + .../default/payment-condition/delivery.html | 57 + .../payment-condition/shipping_area.html | 57 + templates/.gitkeep | 0 templates/frontOffice/hooktest/composer.json | 10 + .../hooktest/includes/single-product.html | 110 ++ templates/frontOffice/hooktest/index.html | 24 + templates/frontOffice/hooktest/layout.tpl | 110 ++ .../modules/HookTest/assets/css/style3.css | 1 + .../hooktest/modules/HookTest/override3.html | 1 + 74 files changed, 9151 insertions(+) create mode 100644 local/modules/.gitkeep create mode 100644 local/modules/HookTest/Config/config.xml create mode 100644 local/modules/HookTest/Config/module.xml create mode 100644 local/modules/HookTest/Hook/FrontHook.php create mode 100644 local/modules/HookTest/HookTest.php create mode 100644 local/modules/HookTest/I18n/en_US.php create mode 100644 local/modules/HookTest/I18n/fr_FR.php create mode 100644 local/modules/HookTest/I18n/frontOffice/default/en_US.php create mode 100644 local/modules/HookTest/I18n/frontOffice/default/fr_FR.php create mode 100644 local/modules/HookTest/composer.json create mode 100644 local/modules/HookTest/templates/frontOffice/default/assets/css/print.css create mode 100644 local/modules/HookTest/templates/frontOffice/default/assets/css/style1.css create mode 100644 local/modules/HookTest/templates/frontOffice/default/assets/css/style2.css create mode 100644 local/modules/HookTest/templates/frontOffice/default/assets/css/style3.css create mode 100644 local/modules/HookTest/templates/frontOffice/default/assets/css/styles.css create mode 100644 local/modules/HookTest/templates/frontOffice/default/assets/js/script.js create mode 100644 local/modules/HookTest/templates/frontOffice/default/dump.txt create mode 100644 local/modules/HookTest/templates/frontOffice/default/main-navbar-secondary.html create mode 100644 local/modules/HookTest/templates/frontOffice/default/override-assets.html create mode 100644 local/modules/HookTest/templates/frontOffice/default/override1.html create mode 100644 local/modules/HookTest/templates/frontOffice/default/override2.html create mode 100644 local/modules/HookTest/templates/frontOffice/default/override3.html create mode 100644 local/modules/HookTest/templates/frontOffice/default/render.html create mode 100644 local/modules/HookTest/templates/frontOffice/hooktest/assets/css/style2.css create mode 100644 local/modules/HookTest/templates/frontOffice/hooktest/override2.html create mode 100644 local/modules/PaymentCondition/Config/config.xml create mode 100644 local/modules/PaymentCondition/Config/module.xml create mode 100644 local/modules/PaymentCondition/Config/routing.xml create mode 100644 local/modules/PaymentCondition/Config/schema.xml create mode 100644 local/modules/PaymentCondition/Config/sqldb.map create mode 100644 local/modules/PaymentCondition/Config/thelia.sql create mode 100644 local/modules/PaymentCondition/Controller/AdminController.php create mode 100644 local/modules/PaymentCondition/Controller/AreaConditionController.php create mode 100644 local/modules/PaymentCondition/Controller/CustomerFamilyConditionController.php create mode 100644 local/modules/PaymentCondition/Controller/DeliveryConditionController.php create mode 100644 local/modules/PaymentCondition/EventListeners/PaymentLoopExtend.php create mode 100644 local/modules/PaymentCondition/Hook/CustomerEditHook.php create mode 100644 local/modules/PaymentCondition/I18n/backOffice/default/fr_FR.php create mode 100644 local/modules/PaymentCondition/I18n/en_US.php create mode 100644 local/modules/PaymentCondition/I18n/fr_FR.php create mode 100644 local/modules/PaymentCondition/Model/Base/PaymentAreaCondition.php create mode 100644 local/modules/PaymentCondition/Model/Base/PaymentAreaConditionQuery.php create mode 100644 local/modules/PaymentCondition/Model/Base/PaymentCustomerFamilyCondition.php create mode 100644 local/modules/PaymentCondition/Model/Base/PaymentCustomerFamilyConditionQuery.php create mode 100644 local/modules/PaymentCondition/Model/Base/PaymentDeliveryCondition.php create mode 100644 local/modules/PaymentCondition/Model/Base/PaymentDeliveryConditionQuery.php create mode 100644 local/modules/PaymentCondition/Model/Map/PaymentAreaConditionTableMap.php create mode 100644 local/modules/PaymentCondition/Model/Map/PaymentCustomerFamilyConditionTableMap.php create mode 100644 local/modules/PaymentCondition/Model/Map/PaymentDeliveryConditionTableMap.php create mode 100644 local/modules/PaymentCondition/Model/PaymentAreaCondition.php create mode 100644 local/modules/PaymentCondition/Model/PaymentAreaConditionQuery.php create mode 100644 local/modules/PaymentCondition/Model/PaymentCustomerCondition.php create mode 100644 local/modules/PaymentCondition/Model/PaymentCustomerConditionQuery.php create mode 100644 local/modules/PaymentCondition/Model/PaymentCustomerFamilyCondition.php create mode 100644 local/modules/PaymentCondition/Model/PaymentCustomerFamilyConditionQuery.php create mode 100644 local/modules/PaymentCondition/Model/PaymentCustomerModuleCondition.php create mode 100644 local/modules/PaymentCondition/Model/PaymentCustomerModuleConditionQuery.php create mode 100644 local/modules/PaymentCondition/Model/PaymentDeliveryCondition.php create mode 100644 local/modules/PaymentCondition/Model/PaymentDeliveryConditionQuery.php create mode 100644 local/modules/PaymentCondition/PaymentCondition.php create mode 100644 local/modules/PaymentCondition/Readme.md create mode 100644 local/modules/PaymentCondition/composer.json create mode 100644 local/modules/PaymentCondition/templates/backOffice/default/payment-condition/configuration.html create mode 100644 local/modules/PaymentCondition/templates/backOffice/default/payment-condition/customer_edit_hook.html create mode 100644 local/modules/PaymentCondition/templates/backOffice/default/payment-condition/customer_family.html create mode 100644 local/modules/PaymentCondition/templates/backOffice/default/payment-condition/delivery.html create mode 100644 local/modules/PaymentCondition/templates/backOffice/default/payment-condition/shipping_area.html create mode 100644 templates/.gitkeep create mode 100644 templates/frontOffice/hooktest/composer.json create mode 100644 templates/frontOffice/hooktest/includes/single-product.html create mode 100644 templates/frontOffice/hooktest/index.html create mode 100644 templates/frontOffice/hooktest/layout.tpl create mode 100644 templates/frontOffice/hooktest/modules/HookTest/assets/css/style3.css create mode 100644 templates/frontOffice/hooktest/modules/HookTest/override3.html diff --git a/local/modules/.gitkeep b/local/modules/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/local/modules/HookTest/Config/config.xml b/local/modules/HookTest/Config/config.xml new file mode 100644 index 00000000..6b26bd61 --- /dev/null +++ b/local/modules/HookTest/Config/config.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/local/modules/HookTest/Config/module.xml b/local/modules/HookTest/Config/module.xml new file mode 100644 index 00000000..9cd16c76 --- /dev/null +++ b/local/modules/HookTest/Config/module.xml @@ -0,0 +1,18 @@ + + + HookTest\HookTest + + Hook module tester + + + Hook module tester + + 0.1 + + Julien Chanséaume + jchanseaume@openstudio.fr + + classic + 2.0.0 + other + diff --git a/local/modules/HookTest/Hook/FrontHook.php b/local/modules/HookTest/Hook/FrontHook.php new file mode 100644 index 00000000..ea805a63 --- /dev/null +++ b/local/modules/HookTest/Hook/FrontHook.php @@ -0,0 +1,170 @@ + + */ +class FrontHook extends BaseHook { + + protected $ldelim = "::"; + protected $rdelim = "::"; + + + public function onMainHeadTop(HookRenderEvent $event) + { + $event->add($this->mark("main.head-top test0")); + } + + public function onMainHeadTopTest1(HookRenderEvent $event) + { + $event->add($this->mark("main.head-top test1")); + } + + public function onMainHeadTopTest2(HookRenderEvent $event) + { + $event->add($this->mark("main.head-top test2")); + } + + public function onMainHeadTopTest3(HookRenderEvent $event) + { + $event->add($this->mark("main.head-top test3")); + } + + + // == Hook Function ===================================================== + + public function onMainBodyTop(HookRenderEvent $event){ + $event->add($this->mark("main.body-top 1-1")); + $event->add($this->mark("main.body-top 1-2")); + } + + public function onMainBodyTop2(HookRenderEvent $event) + { + $event->add($this->mark("main.body-top 2")); + } + + + // == ifhook / elsehook ================================================ + + public function onMainNavbarSecondary(HookRenderEvent $event){ + $event->add($this->mark("main.navbar-secondary 1")); + } + + /** + * empty string should be considered as empty :) and should activate the elsehook + * + * @param HookRenderEvent $event + */ + public function onMainNavbarPrimary(HookRenderEvent $event) + { + $event->add(""); + $event->add(" "); + } + + public function onProductAdditional(HookRenderEvent $event) + { + // nothing added + } + + + // == hookblock / forhook ============================================== + + public function onMainFooterBody(HookRenderBlockEvent $event) + { + $event->addFragment(new Fragment(array( + "id" => "id1", + "class" => "class1", + "content" => "content1" + ))); + $event->add(array( + "id" => "id2", + "class" => "class2", + "content" => "content2" + )); + } + + // == global objects =================================================== + + public function onMainContentTop(HookRenderEvent $event) + { + $event->add($this->mark("main.content-top")); + $event->add($this->mark("view : " . $this->getView())); + $event->add($this->mark("request : " . $this->getRequest())); + $event->add($this->mark("session : " . $this->getSession()->getId())); + $event->add($this->mark("cart : " . ($this->getCart() === null ? "null" : "not null"))); + $event->add($this->mark("order : " . ($this->getOrder() === null ? "null" : "not null"))); + $event->add($this->mark("currency : " . $this->getCurrency()->getId())); + $event->add($this->mark("customer : " . $this->getCustomer())); + $event->add($this->mark("lang : " . $this->getLang()->getId())); + } + + public function onMainContentTopRender(HookRenderEvent $event) + { + $event->add($this->render("render.html")); + } + + public function onMainContentTopDump(HookRenderEvent $event) + { + $event->add($this->dump("dump.txt")); + } + + public function onMainContentTopAddCSS(HookRenderEvent $event) + { + $event->add($this->mark($this->addCSS("assets/css/styles.css"))); + $event->add($this->mark($this->addCSS("assets/css/print.css", array("media" => "print")))); + } + + public function onMainContentTopAddJS(HookRenderEvent $event) + { + $event->add($this->mark($this->addJS("assets/js/script.js"))); + } + + public function onMainContentTopTrans(HookRenderEvent $event) + { + $event->add($this->mark($this->trans("Hodor Hodor", array(), "hooktest"))); + $event->add($this->mark($this->trans("Hello World", array(), "hooktest"))); + $event->add($this->mark($this->trans("Hello %name%", array("%name%" => "Hodor")))); + $event->add($this->mark($this->trans("Hi %name%", array("%name%" => "Hodor"), "hooktest", 'fr_FR'))); + } + + // == template overriding ==================================================== + + public function onMainContentTopOverriding(HookRenderEvent $event) + { + $event->add($this->render("override1.html")); + // redefined in template hooktest in the module + $event->add($this->render("override2.html")); + // redefined in template hooktest + $event->add($this->render("override3.html")); + + $event->add($this->render("override-assets.html")); + + } + + + + protected function mark($message, $endofline="\n") + { + return sprintf("%s %s %s%s", $this->ldelim, $message, $this->rdelim, $endofline); + } + +} \ No newline at end of file diff --git a/local/modules/HookTest/HookTest.php b/local/modules/HookTest/HookTest.php new file mode 100644 index 00000000..1a95a557 --- /dev/null +++ b/local/modules/HookTest/HookTest.php @@ -0,0 +1,21 @@ + 'Hodor en_US Hodor', + 'Hello World' => 'Hello en_US World', + 'Hello %name%' => 'Hello en_US %name%', + 'Hi %name%' => 'Hi en_US %name%', +); diff --git a/local/modules/HookTest/I18n/fr_FR.php b/local/modules/HookTest/I18n/fr_FR.php new file mode 100644 index 00000000..78016ce0 --- /dev/null +++ b/local/modules/HookTest/I18n/fr_FR.php @@ -0,0 +1,7 @@ + 'Hodor fr_FR Hodor', + 'Hello World' => 'Bonjour fr_FR monde', + 'Hello %name%' => 'Bonjour fr_FR %name%', + 'Hi %name%' => 'Salut fr_FR %name%', +); diff --git a/local/modules/HookTest/I18n/frontOffice/default/en_US.php b/local/modules/HookTest/I18n/frontOffice/default/en_US.php new file mode 100644 index 00000000..afca37ed --- /dev/null +++ b/local/modules/HookTest/I18n/frontOffice/default/en_US.php @@ -0,0 +1,5 @@ + + {ifloop rel="cartloop"} + + {/ifloop} + {elseloop rel="cartloop"} + + {/elseloop} + \ No newline at end of file diff --git a/local/modules/HookTest/templates/frontOffice/default/override-assets.html b/local/modules/HookTest/templates/frontOffice/default/override-assets.html new file mode 100644 index 00000000..3702db3c --- /dev/null +++ b/local/modules/HookTest/templates/frontOffice/default/override-assets.html @@ -0,0 +1,13 @@ + + +{stylesheets file="assets/css/style1.css" source="HookTest"} +asset file 1 : {$asset_url} +{/stylesheets} +{stylesheets file="assets/css/style2.css" source="HookTest"} +asset file 2 : {$asset_url} +{/stylesheets} +{stylesheets file="assets/css/style3.css" source="HookTest"} +asset file 3 : {$asset_url} +{/stylesheets} + + \ No newline at end of file diff --git a/local/modules/HookTest/templates/frontOffice/default/override1.html b/local/modules/HookTest/templates/frontOffice/default/override1.html new file mode 100644 index 00000000..31b1e3e4 --- /dev/null +++ b/local/modules/HookTest/templates/frontOffice/default/override1.html @@ -0,0 +1 @@ +:: file override1 from module/default :: diff --git a/local/modules/HookTest/templates/frontOffice/default/override2.html b/local/modules/HookTest/templates/frontOffice/default/override2.html new file mode 100644 index 00000000..d3744dba --- /dev/null +++ b/local/modules/HookTest/templates/frontOffice/default/override2.html @@ -0,0 +1 @@ +:: file override2 from module/default :: diff --git a/local/modules/HookTest/templates/frontOffice/default/override3.html b/local/modules/HookTest/templates/frontOffice/default/override3.html new file mode 100644 index 00000000..e178cc79 --- /dev/null +++ b/local/modules/HookTest/templates/frontOffice/default/override3.html @@ -0,0 +1 @@ +:: file override3 from module/default :: diff --git a/local/modules/HookTest/templates/frontOffice/default/render.html b/local/modules/HookTest/templates/frontOffice/default/render.html new file mode 100644 index 00000000..217a5f63 --- /dev/null +++ b/local/modules/HookTest/templates/frontOffice/default/render.html @@ -0,0 +1,2 @@ + +:: function render :: diff --git a/local/modules/HookTest/templates/frontOffice/hooktest/assets/css/style2.css b/local/modules/HookTest/templates/frontOffice/hooktest/assets/css/style2.css new file mode 100644 index 00000000..348fd427 --- /dev/null +++ b/local/modules/HookTest/templates/frontOffice/hooktest/assets/css/style2.css @@ -0,0 +1 @@ +/* style2 in module/hooktest */ \ No newline at end of file diff --git a/local/modules/HookTest/templates/frontOffice/hooktest/override2.html b/local/modules/HookTest/templates/frontOffice/hooktest/override2.html new file mode 100644 index 00000000..108fb477 --- /dev/null +++ b/local/modules/HookTest/templates/frontOffice/hooktest/override2.html @@ -0,0 +1 @@ +:: file override2 from module/hooktest :: diff --git a/local/modules/PaymentCondition/Config/config.xml b/local/modules/PaymentCondition/Config/config.xml new file mode 100644 index 00000000..310bf486 --- /dev/null +++ b/local/modules/PaymentCondition/Config/config.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/local/modules/PaymentCondition/Config/module.xml b/local/modules/PaymentCondition/Config/module.xml new file mode 100644 index 00000000..224b8465 --- /dev/null +++ b/local/modules/PaymentCondition/Config/module.xml @@ -0,0 +1,41 @@ + + + PaymentCondition\PaymentCondition + + Allow to manage condition for display payment module + + + + Permet de génerer des conditions d'affichages pour les modules de paiements + + + + + en_US + fr_FR + + 1.0.0 + + + Vincent Lopes-Vicente + vlopes@openstudio.fr + + + classic + + 2.3.0 + other + diff --git a/local/modules/PaymentCondition/Config/routing.xml b/local/modules/PaymentCondition/Config/routing.xml new file mode 100644 index 00000000..6c730d04 --- /dev/null +++ b/local/modules/PaymentCondition/Config/routing.xml @@ -0,0 +1,35 @@ + + + + + + PaymentCondition\Controller\AdminController::viewAction + + + + PaymentCondition\Controller\DeliveryConditionController::viewAction + + + + PaymentCondition\Controller\DeliveryConditionController::saveAction + + + + PaymentCondition\Controller\CustomerFamilyConditionController::viewAction + + + + PaymentCondition\Controller\CustomerFamilyConditionController::saveAction + + + + PaymentCondition\Controller\AreaConditionController::viewAction + + + + PaymentCondition\Controller\AreaConditionController::saveAction + + + diff --git a/local/modules/PaymentCondition/Config/schema.xml b/local/modules/PaymentCondition/Config/schema.xml new file mode 100644 index 00000000..dd013fde --- /dev/null +++ b/local/modules/PaymentCondition/Config/schema.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + +
+ + + + + + + + + + + + + + +
+ + + + + + + + +
+ + + + + + + + + + + + + +
+ + +
diff --git a/local/modules/PaymentCondition/Config/sqldb.map b/local/modules/PaymentCondition/Config/sqldb.map new file mode 100644 index 00000000..63a93baa --- /dev/null +++ b/local/modules/PaymentCondition/Config/sqldb.map @@ -0,0 +1,2 @@ +# Sqlfile -> Database map +thelia.sql=thelia diff --git a/local/modules/PaymentCondition/Config/thelia.sql b/local/modules/PaymentCondition/Config/thelia.sql new file mode 100644 index 00000000..7fd45a0e --- /dev/null +++ b/local/modules/PaymentCondition/Config/thelia.sql @@ -0,0 +1,125 @@ + +# 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; + +-- --------------------------------------------------------------------- +-- payment_delivery_condition +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `payment_delivery_condition`; + +CREATE TABLE `payment_delivery_condition` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `payment_module_id` INTEGER NOT NULL, + `delivery_module_id` INTEGER NOT NULL, + `is_valid` TINYINT, + PRIMARY KEY (`id`), + INDEX `fi_payment_delivery_condition_payment_module_id` (`payment_module_id`), + INDEX `fi_payment_delivery_condition_delivery_module_id` (`delivery_module_id`), + CONSTRAINT `fk_payment_delivery_condition_payment_module_id` + FOREIGN KEY (`payment_module_id`) + REFERENCES `module` (`id`) + ON UPDATE RESTRICT + ON DELETE CASCADE, + CONSTRAINT `fk_payment_delivery_condition_delivery_module_id` + FOREIGN KEY (`delivery_module_id`) + REFERENCES `module` (`id`) + ON UPDATE RESTRICT + ON DELETE CASCADE +) ENGINE=InnoDB; + +-- --------------------------------------------------------------------- +-- payment_customer_family_condition +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `payment_customer_family_condition`; + +CREATE TABLE `payment_customer_family_condition` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `payment_module_id` INTEGER NOT NULL, + `customer_family_id` INTEGER NOT NULL, + `is_valid` TINYINT, + PRIMARY KEY (`id`), + INDEX `fi_payment_customer_family_condition_payment_module_id` (`payment_module_id`), + CONSTRAINT `fk_payment_customer_family_condition_payment_module_id` + FOREIGN KEY (`payment_module_id`) + REFERENCES `module` (`id`) + ON UPDATE RESTRICT + ON DELETE CASCADE +) ENGINE=InnoDB; + +-- --------------------------------------------------------------------- +-- payment_area_condition +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `payment_area_condition`; + +CREATE TABLE `payment_area_condition` +( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `payment_module_id` INTEGER NOT NULL, + `area_id` INTEGER NOT NULL, + `is_valid` TINYINT, + PRIMARY KEY (`id`), + INDEX `fi_payment_area_condition_payment_module_id` (`payment_module_id`), + INDEX `fi_payment_area_condition_area_id` (`area_id`), + CONSTRAINT `fk_payment_area_condition_payment_module_id` + FOREIGN KEY (`payment_module_id`) + REFERENCES `module` (`id`) + ON UPDATE RESTRICT + ON DELETE CASCADE, + CONSTRAINT `fk_payment_area_condition_area_id` + FOREIGN KEY (`area_id`) + REFERENCES `area` (`id`) + ON UPDATE RESTRICT + ON DELETE CASCADE +) ENGINE=InnoDB; + +-- --------------------------------------------------------------------- +-- payment_customer_condition +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `payment_customer_condition`; + +CREATE TABLE `payment_customer_condition` +( + `customer_id` INTEGER NOT NULL, + `module_restriction_active` TINYINT, + PRIMARY KEY (`customer_id`), + CONSTRAINT `fk_payment_customer_condition_customer_id` + FOREIGN KEY (`customer_id`) + REFERENCES `customer` (`id`) + ON UPDATE RESTRICT + ON DELETE CASCADE +) ENGINE=InnoDB; + +-- --------------------------------------------------------------------- +-- payment_customer_module_condition +-- --------------------------------------------------------------------- + +DROP TABLE IF EXISTS `payment_customer_module_condition`; + +CREATE TABLE `payment_customer_module_condition` +( + `payment_module_id` INTEGER NOT NULL, + `customer_id` INTEGER NOT NULL, + `is_valid` TINYINT, + PRIMARY KEY (`payment_module_id`,`customer_id`), + INDEX `fi_payment_customer_module_condition_customer_id` (`customer_id`), + CONSTRAINT `fk_payment_customer_module_condition_customer_id` + FOREIGN KEY (`customer_id`) + REFERENCES `customer` (`id`) + ON UPDATE RESTRICT + ON DELETE CASCADE, + CONSTRAINT `fk_payment_customer_module_condition_payment_module_id` + FOREIGN KEY (`payment_module_id`) + REFERENCES `module` (`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/PaymentCondition/Controller/AdminController.php b/local/modules/PaymentCondition/Controller/AdminController.php new file mode 100644 index 00000000..30f306f0 --- /dev/null +++ b/local/modules/PaymentCondition/Controller/AdminController.php @@ -0,0 +1,17 @@ +render('payment-condition/configuration'); + } +} diff --git a/local/modules/PaymentCondition/Controller/AreaConditionController.php b/local/modules/PaymentCondition/Controller/AreaConditionController.php new file mode 100644 index 00000000..28e68cc0 --- /dev/null +++ b/local/modules/PaymentCondition/Controller/AreaConditionController.php @@ -0,0 +1,62 @@ +findByCategory('payment'); + + $shippingAreas = AreaQuery::create()->find(); + + $paymentAreaConditions = PaymentAreaConditionQuery::create() + ->find(); + + if (null !== $paymentAreaConditions) { + /** @var PaymentAreaCondition $paymentAreaCondition */ + foreach ($paymentAreaConditions as $paymentAreaCondition) { + $areaPaymentConditionArray[$paymentAreaCondition->getPaymentModuleId()][$paymentAreaCondition->getAreaId()] = $paymentAreaCondition->getIsValid(); + } + } + + return $this->render('payment-condition/shipping_area', [ + 'paymentModules' => $paymentModules, + 'shippingAreas' => $shippingAreas, + "areaPaymentCondition" => $areaPaymentConditionArray + ]); + } + + public function saveAction() + { + $request = $this->getRequest(); + + try { + $paymentId = $request->request->get("paymentId"); + $areaId = $request->request->get("areaId"); + $isValid = $request->request->get("isValid") == "true" ? 1 : 0; + + $paymentArea = PaymentAreaConditionQuery::create() + ->filterByPaymentModuleId($paymentId) + ->filterByAreaId($areaId) + ->findOneOrCreate(); + + $paymentArea->setIsValid($isValid) + ->save(); + + } catch (\Exception $e) { + return JsonResponse::create($e->getMessage(), 500); + } + return JsonResponse::create("Success"); + } +} diff --git a/local/modules/PaymentCondition/Controller/CustomerFamilyConditionController.php b/local/modules/PaymentCondition/Controller/CustomerFamilyConditionController.php new file mode 100644 index 00000000..5f07b49b --- /dev/null +++ b/local/modules/PaymentCondition/Controller/CustomerFamilyConditionController.php @@ -0,0 +1,78 @@ +findByCategory('payment'); + + $customerFamilies = CustomerFamilyQuery::create() + ->find(); + + /** @var Module $paymentModule */ + foreach ($paymentModules as $paymentModule) { + $moduleCodes[$paymentModule->getId()] = $paymentModule->getCode(); + + /** @var CustomerFamily $customerFamily */ + foreach ($customerFamilies as $customerFamily) { + $customerFamilyPaymentsModules[$customerFamily->getId()][$paymentModule->getId()] = 0; + $familyCodes[$customerFamily->getId()] = $customerFamily->getCode(); + } + } + + $customerFamilyPayments = PaymentCustomerFamilyConditionQuery::create() + ->find(); + + if (null !== $customerFamilyPayments) { + /** @var PaymentCustomerFamilyCondition $customerFamilyPayment */ + foreach ($customerFamilyPayments as $customerFamilyPayment) { + $customerFamilyPaymentsModules[$customerFamilyPayment->getCustomerFamilyId()][$customerFamilyPayment->getPaymentModuleId()] = $customerFamilyPayment->getIsValid(); + } + } + + return $this->render('payment-condition/customer_family', [ + "module_codes" => $moduleCodes, + "family_codes" => $familyCodes, + "paymentFamilyCondition" =>$customerFamilyPaymentsModules + ]); + } + + public function saveAction() + { + $request = $this->getRequest(); + + try { + $moduleId = $request->request->get("moduleId"); + $customerFamilyId = $request->request->get("customerFamilyId"); + $isValid = $request->request->get("isValid") == "true" ? 1 : 0; + + $paymentCustomerFamily = PaymentCustomerFamilyConditionQuery::create() + ->filterByPaymentModuleId($moduleId) + ->filterByCustomerFamilyId($customerFamilyId) + ->findOneOrCreate(); + + $paymentCustomerFamily->setIsValid($isValid) + ->save(); + + } catch (\Exception $e) { + return JsonResponse::create($e->getMessage(), 500); + } + return JsonResponse::create("Success"); + } +} diff --git a/local/modules/PaymentCondition/Controller/DeliveryConditionController.php b/local/modules/PaymentCondition/Controller/DeliveryConditionController.php new file mode 100644 index 00000000..2c9efa60 --- /dev/null +++ b/local/modules/PaymentCondition/Controller/DeliveryConditionController.php @@ -0,0 +1,62 @@ +findByCategory('payment'); + + $deliveryModules = ModuleQuery::create() + ->findByCategory('delivery'); + + $paymentDeliveryConditions = PaymentDeliveryConditionQuery::create() + ->find(); + + if (null !== $paymentDeliveryConditions) { + /** @var PaymentDeliveryCondition $paymentDeliveryCondition */ + foreach ($paymentDeliveryConditions as $paymentDeliveryCondition) { + $paymentDeliveryConditionArray[$paymentDeliveryCondition->getPaymentModuleId()][$paymentDeliveryCondition->getDeliveryModuleId()] = $paymentDeliveryCondition->getIsValid(); + } + } + + return $this->render('payment-condition/delivery', [ + 'paymentModules' => $paymentModules, + 'deliveryModules' => $deliveryModules, + "paymentDeliveryCondition" => $paymentDeliveryConditionArray + ]); + } + + public function saveAction() + { + $request = $this->getRequest(); + + try { + $paymentId = $request->request->get("paymentId"); + $deliveryId = $request->request->get("deliveryId"); + $isValid = $request->request->get("isValid") == "true" ? 1 : 0; + + $paymentDelivery = PaymentDeliveryConditionQuery::create() + ->filterByPaymentModuleId($paymentId) + ->filterByDeliveryModuleId($deliveryId) + ->findOneOrCreate(); + + $paymentDelivery->setIsValid($isValid) + ->save(); + + } catch (\Exception $e) { + return JsonResponse::create($e->getMessage(), 500); + } + return JsonResponse::create("Success"); + } +} diff --git a/local/modules/PaymentCondition/EventListeners/PaymentLoopExtend.php b/local/modules/PaymentCondition/EventListeners/PaymentLoopExtend.php new file mode 100644 index 00000000..66400f89 --- /dev/null +++ b/local/modules/PaymentCondition/EventListeners/PaymentLoopExtend.php @@ -0,0 +1,185 @@ +request = $requestStack->getCurrentRequest(); + } + + public function paymentDeliveryCondition(LoopExtendsBuildModelCriteriaEvent $event) + { + /** @var Order $order */ + $order = $this->request->getSession()->get('thelia.order'); + + if (null === $order) { + return; + } + + $deliveryModuleId = $order->getDeliveryModuleId(); + + if (null === $deliveryModuleId) { + return; + } + + $join = new Join(); + $join->addExplicitCondition( + ModuleTableMap::TABLE_NAME, + 'ID', + null, + PaymentDeliveryConditionTableMap::TABLE_NAME, + 'PAYMENT_MODULE_ID', + null + ); + + $join->setJoinType(Criteria::JOIN); + $event->getModelCriteria()->addJoinObject($join, 'payment_delivery_condition_join') + ->addJoinCondition('payment_delivery_condition_join', PaymentDeliveryConditionTableMap::DELIVERY_MODULE_ID . ' = ' . $deliveryModuleId) + ->addJoinCondition('payment_delivery_condition_join', PaymentDeliveryConditionTableMap::IS_VALID . ' = 1'); + } + + public function paymentCustomerFamilyCondition(LoopExtendsBuildModelCriteriaEvent $event) + { + /** @var Session $session */ + $session = $this->request->getSession(); + + $customer = $session->getCustomerUser(); + + if (null === $customer) { + return null; + } + + $customerCustomerFamily = CustomerCustomerFamilyQuery::create() + ->findOneByCustomerId($customer->getId()); + + if (null === $customerCustomerFamily) { + return null; + } + + $join = new Join(); + $join->addExplicitCondition( + ModuleTableMap::TABLE_NAME, + 'ID', + null, + PaymentCustomerFamilyConditionTableMap::TABLE_NAME, + 'PAYMENT_MODULE_ID', + null + ); + + $join->setJoinType(Criteria::JOIN); + $event->getModelCriteria()->addJoinObject($join, 'payment_customer_family_condition_join') + ->addJoinCondition('payment_customer_family_condition_join', PaymentCustomerFamilyConditionTableMap::CUSTOMER_FAMILY_ID.' = '.$customerCustomerFamily->getCustomerFamilyId()) + ->addJoinCondition('payment_customer_family_condition_join', PaymentCustomerFamilyConditionTableMap::IS_VALID . ' = 1'); + } + + public function paymentAreaCondition(LoopExtendsBuildModelCriteriaEvent $event) + { + /** @var Order $order */ + $order = $this->request->getSession()->get('thelia.order'); + + if (null === $order) { + return; + } + + $chosenDeliveryAddressId = $order->getChoosenDeliveryAddress(); + + if (null === $chosenDeliveryAddressId) { + return; + } + + $chosenDeliveryAddress = AddressQuery::create()->findOneById($chosenDeliveryAddressId); + + if (null === $chosenDeliveryAddress) { + return; + } + + $chosenCountryId = $chosenDeliveryAddress->getCountryId(); + + $query = ModuleTableMap::ID . ' IN (SELECT '.PaymentAreaConditionTableMap::PAYMENT_MODULE_ID.' FROM '.PaymentAreaConditionTableMap::TABLE_NAME + .' WHERE '.PaymentAreaConditionTableMap::IS_VALID.' = 1 AND area_id IN' + .' (SELECT '.CountryAreaTableMap::AREA_ID.' FROM '.CountryAreaTableMap::TABLE_NAME.' WHERE '.CountryAreaTableMap::COUNTRY_ID.' = '.$chosenCountryId.')' + .')'; + + $event->getModelCriteria()->add(ModuleTableMap::ID, $query, Criteria::CUSTOM); + } + + public function paymentCustomerCondition(LoopExtendsBuildModelCriteriaEvent $event) + { + $criteria = $event->getModelCriteria(); + $customer = $this->request->getSession()->getCustomerUser(); + + if (null === $customer) { + return; + } + + $paymentCustomerCondition = PaymentCustomerConditionQuery::create() + ->findOneByCustomerId($customer->getId()); + + if (null === $paymentCustomerCondition || false == $paymentCustomerCondition->getModuleRestrictionActive()) { + return; + } + + // Join customer module condition to know if the payment module is valid + $paymentModuleConditionJoin = new Join(); + $paymentModuleConditionJoin->addExplicitCondition( + ModuleTableMap::TABLE_NAME, + 'ID', + null, + PaymentCustomerModuleConditionTableMap::TABLE_NAME, + 'PAYMENT_MODULE_ID', + null + ); + + $paymentModuleConditionJoin->setJoinType(Criteria::JOIN); + $criteria->addJoinObject($paymentModuleConditionJoin, 'payment_customer_module_condition_join') + ->addJoinCondition('payment_customer_module_condition_join', PaymentCustomerModuleConditionTableMap::COL_CUSTOMER_ID.' = '.$customer->getId()) + ->addJoinCondition('payment_customer_module_condition_join', PaymentCustomerModuleConditionTableMap::COL_IS_VALID.' = 1'); + } + + public static function getSubscribedEvents() + { + $events = []; + + $events[TheliaEvents::getLoopExtendsEvent(TheliaEvents::LOOP_EXTENDS_BUILD_MODEL_CRITERIA, 'payment')][] = ['paymentDeliveryCondition', '64']; + $events[TheliaEvents::getLoopExtendsEvent(TheliaEvents::LOOP_EXTENDS_BUILD_MODEL_CRITERIA, 'payment')][] = ['paymentAreaCondition', '62']; + + $customFamilyModuleIsActive = ModuleQuery::create() + ->filterByCode('CustomerFamily') + ->filterByActivate(1) + ->findOne(); + + if (null !== $customFamilyModuleIsActive) { + $events[TheliaEvents::getLoopExtendsEvent(TheliaEvents::LOOP_EXTENDS_BUILD_MODEL_CRITERIA, 'payment')][] = ['paymentCustomerFamilyCondition', '63']; + + } + + $events[TheliaEvents::getLoopExtendsEvent(TheliaEvents::LOOP_EXTENDS_BUILD_MODEL_CRITERIA, 'payment')][] = ['paymentCustomerCondition', '60']; + + return $events; + } +} diff --git a/local/modules/PaymentCondition/Hook/CustomerEditHook.php b/local/modules/PaymentCondition/Hook/CustomerEditHook.php new file mode 100644 index 00000000..025d23f0 --- /dev/null +++ b/local/modules/PaymentCondition/Hook/CustomerEditHook.php @@ -0,0 +1,31 @@ +getArgument('customer_id'); + + $paymentCustomerCondition = PaymentCustomerConditionQuery::create() + ->findOneByCustomerId($customerId); + + $paymentCustomerModuleConditions = PaymentCustomerModuleConditionQuery::create() + ->findByCustomerId($customerId); + + $allowedModules = []; + foreach ($paymentCustomerModuleConditions as $paymentCustomerModuleCondition) { + if ($paymentCustomerModuleCondition->getIsValid()) { + $allowedModules[] = $paymentCustomerModuleCondition->getModule(); + } + } + + $event->add($this->render('payment-condition/customer_edit_hook.html', compact('paymentCustomerCondition', 'allowedModules'))); + } +} diff --git a/local/modules/PaymentCondition/I18n/backOffice/default/fr_FR.php b/local/modules/PaymentCondition/I18n/backOffice/default/fr_FR.php new file mode 100644 index 00000000..a3a5a00f --- /dev/null +++ b/local/modules/PaymentCondition/I18n/backOffice/default/fr_FR.php @@ -0,0 +1,12 @@ + 'Paiements autorisés :', + 'Condition by chosen delivery module' => 'Condition par module de livraison', + 'Condition by chosen shipping area' => 'Condition par zone de livraison', + 'Condition by customer family' => 'Condition par famille de client', + 'Install and activate \'CustomerFamily\' module to get configuration options.' => 'Installez et activez le module \'CustomerFamily\' pour configurer cette partie', + 'Payment condition module configuration' => 'Configuration des conditions de paiement', + 'Payment conditions for this customer' => 'Conditions de paiement pour ce client', + 'Payment restrictions is not activated for this customer' => 'Pas de restriction de paiement pour ce client', +); diff --git a/local/modules/PaymentCondition/I18n/en_US.php b/local/modules/PaymentCondition/I18n/en_US.php new file mode 100644 index 00000000..0b4fa142 --- /dev/null +++ b/local/modules/PaymentCondition/I18n/en_US.php @@ -0,0 +1,4 @@ + 'The displayed english string', +); diff --git a/local/modules/PaymentCondition/I18n/fr_FR.php b/local/modules/PaymentCondition/I18n/fr_FR.php new file mode 100644 index 00000000..37086245 --- /dev/null +++ b/local/modules/PaymentCondition/I18n/fr_FR.php @@ -0,0 +1,4 @@ + 'La traduction française de la chaine', +); diff --git a/local/modules/PaymentCondition/Model/Base/PaymentAreaCondition.php b/local/modules/PaymentCondition/Model/Base/PaymentAreaCondition.php new file mode 100644 index 00000000..3941f110 --- /dev/null +++ b/local/modules/PaymentCondition/Model/Base/PaymentAreaCondition.php @@ -0,0 +1,1388 @@ +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 PaymentAreaCondition instance. If + * obj is an instance of PaymentAreaCondition, delegates to + * equals(PaymentAreaCondition). 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 PaymentAreaCondition 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 PaymentAreaCondition 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 [payment_module_id] column value. + * + * @return int + */ + public function getPaymentModuleId() + { + + return $this->payment_module_id; + } + + /** + * Get the [area_id] column value. + * + * @return int + */ + public function getAreaId() + { + + return $this->area_id; + } + + /** + * Get the [is_valid] column value. + * + * @return int + */ + public function getIsValid() + { + + return $this->is_valid; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \PaymentCondition\Model\PaymentAreaCondition 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[PaymentAreaConditionTableMap::ID] = true; + } + + + return $this; + } // setId() + + /** + * Set the value of [payment_module_id] column. + * + * @param int $v new value + * @return \PaymentCondition\Model\PaymentAreaCondition The current object (for fluent API support) + */ + public function setPaymentModuleId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->payment_module_id !== $v) { + $this->payment_module_id = $v; + $this->modifiedColumns[PaymentAreaConditionTableMap::PAYMENT_MODULE_ID] = true; + } + + if ($this->aModule !== null && $this->aModule->getId() !== $v) { + $this->aModule = null; + } + + + return $this; + } // setPaymentModuleId() + + /** + * Set the value of [area_id] column. + * + * @param int $v new value + * @return \PaymentCondition\Model\PaymentAreaCondition 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[PaymentAreaConditionTableMap::AREA_ID] = true; + } + + if ($this->aArea !== null && $this->aArea->getId() !== $v) { + $this->aArea = null; + } + + + return $this; + } // setAreaId() + + /** + * Set the value of [is_valid] column. + * + * @param int $v new value + * @return \PaymentCondition\Model\PaymentAreaCondition The current object (for fluent API support) + */ + public function setIsValid($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->is_valid !== $v) { + $this->is_valid = $v; + $this->modifiedColumns[PaymentAreaConditionTableMap::IS_VALID] = true; + } + + + return $this; + } // setIsValid() + + /** + * 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 : PaymentAreaConditionTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : PaymentAreaConditionTableMap::translateFieldName('PaymentModuleId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->payment_module_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : PaymentAreaConditionTableMap::translateFieldName('AreaId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->area_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : PaymentAreaConditionTableMap::translateFieldName('IsValid', TableMap::TYPE_PHPNAME, $indexType)]; + $this->is_valid = (null !== $col) ? (int) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 4; // 4 = PaymentAreaConditionTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \PaymentCondition\Model\PaymentAreaCondition 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->aModule !== null && $this->payment_module_id !== $this->aModule->getId()) { + $this->aModule = null; + } + 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(PaymentAreaConditionTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildPaymentAreaConditionQuery::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->aModule = null; + $this->aArea = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see PaymentAreaCondition::setDeleted() + * @see PaymentAreaCondition::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(PaymentAreaConditionTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildPaymentAreaConditionQuery::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(PaymentAreaConditionTableMap::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); + PaymentAreaConditionTableMap::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->aModule !== null) { + if ($this->aModule->isModified() || $this->aModule->isNew()) { + $affectedRows += $this->aModule->save($con); + } + $this->setModule($this->aModule); + } + + 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[PaymentAreaConditionTableMap::ID] = true; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . PaymentAreaConditionTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(PaymentAreaConditionTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(PaymentAreaConditionTableMap::PAYMENT_MODULE_ID)) { + $modifiedColumns[':p' . $index++] = 'PAYMENT_MODULE_ID'; + } + if ($this->isColumnModified(PaymentAreaConditionTableMap::AREA_ID)) { + $modifiedColumns[':p' . $index++] = 'AREA_ID'; + } + if ($this->isColumnModified(PaymentAreaConditionTableMap::IS_VALID)) { + $modifiedColumns[':p' . $index++] = 'IS_VALID'; + } + + $sql = sprintf( + 'INSERT INTO payment_area_condition (%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 'PAYMENT_MODULE_ID': + $stmt->bindValue($identifier, $this->payment_module_id, PDO::PARAM_INT); + break; + case 'AREA_ID': + $stmt->bindValue($identifier, $this->area_id, PDO::PARAM_INT); + break; + case 'IS_VALID': + $stmt->bindValue($identifier, $this->is_valid, 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 = PaymentAreaConditionTableMap::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->getPaymentModuleId(); + break; + case 2: + return $this->getAreaId(); + break; + case 3: + return $this->getIsValid(); + 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['PaymentAreaCondition'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['PaymentAreaCondition'][$this->getPrimaryKey()] = true; + $keys = PaymentAreaConditionTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getPaymentModuleId(), + $keys[2] => $this->getAreaId(), + $keys[3] => $this->getIsValid(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aModule) { + $result['Module'] = $this->aModule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + 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 = PaymentAreaConditionTableMap::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->setPaymentModuleId($value); + break; + case 2: + $this->setAreaId($value); + break; + case 3: + $this->setIsValid($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 = PaymentAreaConditionTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setPaymentModuleId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setAreaId($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setIsValid($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(PaymentAreaConditionTableMap::DATABASE_NAME); + + if ($this->isColumnModified(PaymentAreaConditionTableMap::ID)) $criteria->add(PaymentAreaConditionTableMap::ID, $this->id); + if ($this->isColumnModified(PaymentAreaConditionTableMap::PAYMENT_MODULE_ID)) $criteria->add(PaymentAreaConditionTableMap::PAYMENT_MODULE_ID, $this->payment_module_id); + if ($this->isColumnModified(PaymentAreaConditionTableMap::AREA_ID)) $criteria->add(PaymentAreaConditionTableMap::AREA_ID, $this->area_id); + if ($this->isColumnModified(PaymentAreaConditionTableMap::IS_VALID)) $criteria->add(PaymentAreaConditionTableMap::IS_VALID, $this->is_valid); + + 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(PaymentAreaConditionTableMap::DATABASE_NAME); + $criteria->add(PaymentAreaConditionTableMap::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 \PaymentCondition\Model\PaymentAreaCondition (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->setPaymentModuleId($this->getPaymentModuleId()); + $copyObj->setAreaId($this->getAreaId()); + $copyObj->setIsValid($this->getIsValid()); + 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 \PaymentCondition\Model\PaymentAreaCondition 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 ChildModule object. + * + * @param ChildModule $v + * @return \PaymentCondition\Model\PaymentAreaCondition The current object (for fluent API support) + * @throws PropelException + */ + public function setModule(ChildModule $v = null) + { + if ($v === null) { + $this->setPaymentModuleId(NULL); + } else { + $this->setPaymentModuleId($v->getId()); + } + + $this->aModule = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildModule object, it will not be re-added. + if ($v !== null) { + $v->addPaymentAreaCondition($this); + } + + + return $this; + } + + + /** + * Get the associated ChildModule object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildModule The associated ChildModule object. + * @throws PropelException + */ + public function getModule(ConnectionInterface $con = null) + { + if ($this->aModule === null && ($this->payment_module_id !== null)) { + $this->aModule = ModuleQuery::create()->findPk($this->payment_module_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->aModule->addPaymentAreaConditions($this); + */ + } + + return $this->aModule; + } + + /** + * Declares an association between this object and a ChildArea object. + * + * @param ChildArea $v + * @return \PaymentCondition\Model\PaymentAreaCondition 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->addPaymentAreaCondition($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->addPaymentAreaConditions($this); + */ + } + + return $this->aArea; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->payment_module_id = null; + $this->area_id = null; + $this->is_valid = 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->aModule = null; + $this->aArea = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(PaymentAreaConditionTableMap::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/PaymentCondition/Model/Base/PaymentAreaConditionQuery.php b/local/modules/PaymentCondition/Model/Base/PaymentAreaConditionQuery.php new file mode 100644 index 00000000..50f5b8b9 --- /dev/null +++ b/local/modules/PaymentCondition/Model/Base/PaymentAreaConditionQuery.php @@ -0,0 +1,646 @@ +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 ChildPaymentAreaCondition|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = PaymentAreaConditionTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(PaymentAreaConditionTableMap::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 ChildPaymentAreaCondition A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, PAYMENT_MODULE_ID, AREA_ID, IS_VALID FROM payment_area_condition 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 ChildPaymentAreaCondition(); + $obj->hydrate($row); + PaymentAreaConditionTableMap::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 ChildPaymentAreaCondition|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 ChildPaymentAreaConditionQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(PaymentAreaConditionTableMap::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 ChildPaymentAreaConditionQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(PaymentAreaConditionTableMap::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 ChildPaymentAreaConditionQuery 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(PaymentAreaConditionTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(PaymentAreaConditionTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(PaymentAreaConditionTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the payment_module_id column + * + * Example usage: + * + * $query->filterByPaymentModuleId(1234); // WHERE payment_module_id = 1234 + * $query->filterByPaymentModuleId(array(12, 34)); // WHERE payment_module_id IN (12, 34) + * $query->filterByPaymentModuleId(array('min' => 12)); // WHERE payment_module_id > 12 + * + * + * @see filterByModule() + * + * @param mixed $paymentModuleId 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 ChildPaymentAreaConditionQuery The current query, for fluid interface + */ + public function filterByPaymentModuleId($paymentModuleId = null, $comparison = null) + { + if (is_array($paymentModuleId)) { + $useMinMax = false; + if (isset($paymentModuleId['min'])) { + $this->addUsingAlias(PaymentAreaConditionTableMap::PAYMENT_MODULE_ID, $paymentModuleId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($paymentModuleId['max'])) { + $this->addUsingAlias(PaymentAreaConditionTableMap::PAYMENT_MODULE_ID, $paymentModuleId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(PaymentAreaConditionTableMap::PAYMENT_MODULE_ID, $paymentModuleId, $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 ChildPaymentAreaConditionQuery 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(PaymentAreaConditionTableMap::AREA_ID, $areaId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($areaId['max'])) { + $this->addUsingAlias(PaymentAreaConditionTableMap::AREA_ID, $areaId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(PaymentAreaConditionTableMap::AREA_ID, $areaId, $comparison); + } + + /** + * Filter the query on the is_valid column + * + * Example usage: + * + * $query->filterByIsValid(1234); // WHERE is_valid = 1234 + * $query->filterByIsValid(array(12, 34)); // WHERE is_valid IN (12, 34) + * $query->filterByIsValid(array('min' => 12)); // WHERE is_valid > 12 + * + * + * @param mixed $isValid 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 ChildPaymentAreaConditionQuery The current query, for fluid interface + */ + public function filterByIsValid($isValid = null, $comparison = null) + { + if (is_array($isValid)) { + $useMinMax = false; + if (isset($isValid['min'])) { + $this->addUsingAlias(PaymentAreaConditionTableMap::IS_VALID, $isValid['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($isValid['max'])) { + $this->addUsingAlias(PaymentAreaConditionTableMap::IS_VALID, $isValid['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(PaymentAreaConditionTableMap::IS_VALID, $isValid, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\Module object + * + * @param \Thelia\Model\Module|ObjectCollection $module The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildPaymentAreaConditionQuery The current query, for fluid interface + */ + public function filterByModule($module, $comparison = null) + { + if ($module instanceof \Thelia\Model\Module) { + return $this + ->addUsingAlias(PaymentAreaConditionTableMap::PAYMENT_MODULE_ID, $module->getId(), $comparison); + } elseif ($module instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(PaymentAreaConditionTableMap::PAYMENT_MODULE_ID, $module->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByModule() only accepts arguments of type \Thelia\Model\Module or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Module relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildPaymentAreaConditionQuery The current query, for fluid interface + */ + public function joinModule($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Module'); + + // 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, 'Module'); + } + + return $this; + } + + /** + * Use the Module relation Module 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\ModuleQuery A secondary query class using the current class as primary query + */ + public function useModuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinModule($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Module', '\Thelia\Model\ModuleQuery'); + } + + /** + * 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 ChildPaymentAreaConditionQuery The current query, for fluid interface + */ + public function filterByArea($area, $comparison = null) + { + if ($area instanceof \Thelia\Model\Area) { + return $this + ->addUsingAlias(PaymentAreaConditionTableMap::AREA_ID, $area->getId(), $comparison); + } elseif ($area instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(PaymentAreaConditionTableMap::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 ChildPaymentAreaConditionQuery 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 ChildPaymentAreaCondition $paymentAreaCondition Object to remove from the list of results + * + * @return ChildPaymentAreaConditionQuery The current query, for fluid interface + */ + public function prune($paymentAreaCondition = null) + { + if ($paymentAreaCondition) { + $this->addUsingAlias(PaymentAreaConditionTableMap::ID, $paymentAreaCondition->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Deletes all rows from the payment_area_condition 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(PaymentAreaConditionTableMap::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). + PaymentAreaConditionTableMap::clearInstancePool(); + PaymentAreaConditionTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildPaymentAreaCondition or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildPaymentAreaCondition 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(PaymentAreaConditionTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(PaymentAreaConditionTableMap::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(); + + + PaymentAreaConditionTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + PaymentAreaConditionTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // PaymentAreaConditionQuery diff --git a/local/modules/PaymentCondition/Model/Base/PaymentCustomerFamilyCondition.php b/local/modules/PaymentCondition/Model/Base/PaymentCustomerFamilyCondition.php new file mode 100644 index 00000000..370d4894 --- /dev/null +++ b/local/modules/PaymentCondition/Model/Base/PaymentCustomerFamilyCondition.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 PaymentCustomerFamilyCondition instance. If + * obj is an instance of PaymentCustomerFamilyCondition, delegates to + * equals(PaymentCustomerFamilyCondition). 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 PaymentCustomerFamilyCondition 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 PaymentCustomerFamilyCondition 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 [payment_module_id] column value. + * + * @return int + */ + public function getPaymentModuleId() + { + + return $this->payment_module_id; + } + + /** + * Get the [customer_family_id] column value. + * + * @return int + */ + public function getCustomerFamilyId() + { + + return $this->customer_family_id; + } + + /** + * Get the [is_valid] column value. + * + * @return int + */ + public function getIsValid() + { + + return $this->is_valid; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \PaymentCondition\Model\PaymentCustomerFamilyCondition 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[PaymentCustomerFamilyConditionTableMap::ID] = true; + } + + + return $this; + } // setId() + + /** + * Set the value of [payment_module_id] column. + * + * @param int $v new value + * @return \PaymentCondition\Model\PaymentCustomerFamilyCondition The current object (for fluent API support) + */ + public function setPaymentModuleId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->payment_module_id !== $v) { + $this->payment_module_id = $v; + $this->modifiedColumns[PaymentCustomerFamilyConditionTableMap::PAYMENT_MODULE_ID] = true; + } + + if ($this->aModule !== null && $this->aModule->getId() !== $v) { + $this->aModule = null; + } + + + return $this; + } // setPaymentModuleId() + + /** + * Set the value of [customer_family_id] column. + * + * @param int $v new value + * @return \PaymentCondition\Model\PaymentCustomerFamilyCondition The current object (for fluent API support) + */ + public function setCustomerFamilyId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->customer_family_id !== $v) { + $this->customer_family_id = $v; + $this->modifiedColumns[PaymentCustomerFamilyConditionTableMap::CUSTOMER_FAMILY_ID] = true; + } + + + return $this; + } // setCustomerFamilyId() + + /** + * Set the value of [is_valid] column. + * + * @param int $v new value + * @return \PaymentCondition\Model\PaymentCustomerFamilyCondition The current object (for fluent API support) + */ + public function setIsValid($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->is_valid !== $v) { + $this->is_valid = $v; + $this->modifiedColumns[PaymentCustomerFamilyConditionTableMap::IS_VALID] = true; + } + + + return $this; + } // setIsValid() + + /** + * 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 : PaymentCustomerFamilyConditionTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : PaymentCustomerFamilyConditionTableMap::translateFieldName('PaymentModuleId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->payment_module_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : PaymentCustomerFamilyConditionTableMap::translateFieldName('CustomerFamilyId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->customer_family_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : PaymentCustomerFamilyConditionTableMap::translateFieldName('IsValid', TableMap::TYPE_PHPNAME, $indexType)]; + $this->is_valid = (null !== $col) ? (int) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 4; // 4 = PaymentCustomerFamilyConditionTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \PaymentCondition\Model\PaymentCustomerFamilyCondition 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->aModule !== null && $this->payment_module_id !== $this->aModule->getId()) { + $this->aModule = 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(PaymentCustomerFamilyConditionTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildPaymentCustomerFamilyConditionQuery::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->aModule = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see PaymentCustomerFamilyCondition::setDeleted() + * @see PaymentCustomerFamilyCondition::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(PaymentCustomerFamilyConditionTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildPaymentCustomerFamilyConditionQuery::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(PaymentCustomerFamilyConditionTableMap::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); + PaymentCustomerFamilyConditionTableMap::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->aModule !== null) { + if ($this->aModule->isModified() || $this->aModule->isNew()) { + $affectedRows += $this->aModule->save($con); + } + $this->setModule($this->aModule); + } + + 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[PaymentCustomerFamilyConditionTableMap::ID] = true; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . PaymentCustomerFamilyConditionTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(PaymentCustomerFamilyConditionTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(PaymentCustomerFamilyConditionTableMap::PAYMENT_MODULE_ID)) { + $modifiedColumns[':p' . $index++] = 'PAYMENT_MODULE_ID'; + } + if ($this->isColumnModified(PaymentCustomerFamilyConditionTableMap::CUSTOMER_FAMILY_ID)) { + $modifiedColumns[':p' . $index++] = 'CUSTOMER_FAMILY_ID'; + } + if ($this->isColumnModified(PaymentCustomerFamilyConditionTableMap::IS_VALID)) { + $modifiedColumns[':p' . $index++] = 'IS_VALID'; + } + + $sql = sprintf( + 'INSERT INTO payment_customer_family_condition (%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 'PAYMENT_MODULE_ID': + $stmt->bindValue($identifier, $this->payment_module_id, PDO::PARAM_INT); + break; + case 'CUSTOMER_FAMILY_ID': + $stmt->bindValue($identifier, $this->customer_family_id, PDO::PARAM_INT); + break; + case 'IS_VALID': + $stmt->bindValue($identifier, $this->is_valid, 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 = PaymentCustomerFamilyConditionTableMap::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->getPaymentModuleId(); + break; + case 2: + return $this->getCustomerFamilyId(); + break; + case 3: + return $this->getIsValid(); + 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['PaymentCustomerFamilyCondition'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['PaymentCustomerFamilyCondition'][$this->getPrimaryKey()] = true; + $keys = PaymentCustomerFamilyConditionTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getPaymentModuleId(), + $keys[2] => $this->getCustomerFamilyId(), + $keys[3] => $this->getIsValid(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aModule) { + $result['Module'] = $this->aModule->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 = PaymentCustomerFamilyConditionTableMap::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->setPaymentModuleId($value); + break; + case 2: + $this->setCustomerFamilyId($value); + break; + case 3: + $this->setIsValid($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 = PaymentCustomerFamilyConditionTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setPaymentModuleId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setCustomerFamilyId($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setIsValid($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(PaymentCustomerFamilyConditionTableMap::DATABASE_NAME); + + if ($this->isColumnModified(PaymentCustomerFamilyConditionTableMap::ID)) $criteria->add(PaymentCustomerFamilyConditionTableMap::ID, $this->id); + if ($this->isColumnModified(PaymentCustomerFamilyConditionTableMap::PAYMENT_MODULE_ID)) $criteria->add(PaymentCustomerFamilyConditionTableMap::PAYMENT_MODULE_ID, $this->payment_module_id); + if ($this->isColumnModified(PaymentCustomerFamilyConditionTableMap::CUSTOMER_FAMILY_ID)) $criteria->add(PaymentCustomerFamilyConditionTableMap::CUSTOMER_FAMILY_ID, $this->customer_family_id); + if ($this->isColumnModified(PaymentCustomerFamilyConditionTableMap::IS_VALID)) $criteria->add(PaymentCustomerFamilyConditionTableMap::IS_VALID, $this->is_valid); + + 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(PaymentCustomerFamilyConditionTableMap::DATABASE_NAME); + $criteria->add(PaymentCustomerFamilyConditionTableMap::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 \PaymentCondition\Model\PaymentCustomerFamilyCondition (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->setPaymentModuleId($this->getPaymentModuleId()); + $copyObj->setCustomerFamilyId($this->getCustomerFamilyId()); + $copyObj->setIsValid($this->getIsValid()); + 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 \PaymentCondition\Model\PaymentCustomerFamilyCondition 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 ChildModule object. + * + * @param ChildModule $v + * @return \PaymentCondition\Model\PaymentCustomerFamilyCondition The current object (for fluent API support) + * @throws PropelException + */ + public function setModule(ChildModule $v = null) + { + if ($v === null) { + $this->setPaymentModuleId(NULL); + } else { + $this->setPaymentModuleId($v->getId()); + } + + $this->aModule = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildModule object, it will not be re-added. + if ($v !== null) { + $v->addPaymentCustomerFamilyCondition($this); + } + + + return $this; + } + + + /** + * Get the associated ChildModule object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildModule The associated ChildModule object. + * @throws PropelException + */ + public function getModule(ConnectionInterface $con = null) + { + if ($this->aModule === null && ($this->payment_module_id !== null)) { + $this->aModule = ModuleQuery::create()->findPk($this->payment_module_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->aModule->addPaymentCustomerFamilyConditions($this); + */ + } + + return $this->aModule; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->payment_module_id = null; + $this->customer_family_id = null; + $this->is_valid = 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->aModule = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(PaymentCustomerFamilyConditionTableMap::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/PaymentCondition/Model/Base/PaymentCustomerFamilyConditionQuery.php b/local/modules/PaymentCondition/Model/Base/PaymentCustomerFamilyConditionQuery.php new file mode 100644 index 00000000..d708dcc6 --- /dev/null +++ b/local/modules/PaymentCondition/Model/Base/PaymentCustomerFamilyConditionQuery.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 ChildPaymentCustomerFamilyCondition|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = PaymentCustomerFamilyConditionTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(PaymentCustomerFamilyConditionTableMap::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 ChildPaymentCustomerFamilyCondition A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, PAYMENT_MODULE_ID, CUSTOMER_FAMILY_ID, IS_VALID FROM payment_customer_family_condition 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 ChildPaymentCustomerFamilyCondition(); + $obj->hydrate($row); + PaymentCustomerFamilyConditionTableMap::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 ChildPaymentCustomerFamilyCondition|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 ChildPaymentCustomerFamilyConditionQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(PaymentCustomerFamilyConditionTableMap::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 ChildPaymentCustomerFamilyConditionQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(PaymentCustomerFamilyConditionTableMap::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 ChildPaymentCustomerFamilyConditionQuery 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(PaymentCustomerFamilyConditionTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(PaymentCustomerFamilyConditionTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(PaymentCustomerFamilyConditionTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the payment_module_id column + * + * Example usage: + * + * $query->filterByPaymentModuleId(1234); // WHERE payment_module_id = 1234 + * $query->filterByPaymentModuleId(array(12, 34)); // WHERE payment_module_id IN (12, 34) + * $query->filterByPaymentModuleId(array('min' => 12)); // WHERE payment_module_id > 12 + * + * + * @see filterByModule() + * + * @param mixed $paymentModuleId 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 ChildPaymentCustomerFamilyConditionQuery The current query, for fluid interface + */ + public function filterByPaymentModuleId($paymentModuleId = null, $comparison = null) + { + if (is_array($paymentModuleId)) { + $useMinMax = false; + if (isset($paymentModuleId['min'])) { + $this->addUsingAlias(PaymentCustomerFamilyConditionTableMap::PAYMENT_MODULE_ID, $paymentModuleId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($paymentModuleId['max'])) { + $this->addUsingAlias(PaymentCustomerFamilyConditionTableMap::PAYMENT_MODULE_ID, $paymentModuleId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(PaymentCustomerFamilyConditionTableMap::PAYMENT_MODULE_ID, $paymentModuleId, $comparison); + } + + /** + * Filter the query on the customer_family_id column + * + * Example usage: + * + * $query->filterByCustomerFamilyId(1234); // WHERE customer_family_id = 1234 + * $query->filterByCustomerFamilyId(array(12, 34)); // WHERE customer_family_id IN (12, 34) + * $query->filterByCustomerFamilyId(array('min' => 12)); // WHERE customer_family_id > 12 + * + * + * @param mixed $customerFamilyId 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 ChildPaymentCustomerFamilyConditionQuery The current query, for fluid interface + */ + public function filterByCustomerFamilyId($customerFamilyId = null, $comparison = null) + { + if (is_array($customerFamilyId)) { + $useMinMax = false; + if (isset($customerFamilyId['min'])) { + $this->addUsingAlias(PaymentCustomerFamilyConditionTableMap::CUSTOMER_FAMILY_ID, $customerFamilyId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($customerFamilyId['max'])) { + $this->addUsingAlias(PaymentCustomerFamilyConditionTableMap::CUSTOMER_FAMILY_ID, $customerFamilyId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(PaymentCustomerFamilyConditionTableMap::CUSTOMER_FAMILY_ID, $customerFamilyId, $comparison); + } + + /** + * Filter the query on the is_valid column + * + * Example usage: + * + * $query->filterByIsValid(1234); // WHERE is_valid = 1234 + * $query->filterByIsValid(array(12, 34)); // WHERE is_valid IN (12, 34) + * $query->filterByIsValid(array('min' => 12)); // WHERE is_valid > 12 + * + * + * @param mixed $isValid 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 ChildPaymentCustomerFamilyConditionQuery The current query, for fluid interface + */ + public function filterByIsValid($isValid = null, $comparison = null) + { + if (is_array($isValid)) { + $useMinMax = false; + if (isset($isValid['min'])) { + $this->addUsingAlias(PaymentCustomerFamilyConditionTableMap::IS_VALID, $isValid['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($isValid['max'])) { + $this->addUsingAlias(PaymentCustomerFamilyConditionTableMap::IS_VALID, $isValid['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(PaymentCustomerFamilyConditionTableMap::IS_VALID, $isValid, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\Module object + * + * @param \Thelia\Model\Module|ObjectCollection $module The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildPaymentCustomerFamilyConditionQuery The current query, for fluid interface + */ + public function filterByModule($module, $comparison = null) + { + if ($module instanceof \Thelia\Model\Module) { + return $this + ->addUsingAlias(PaymentCustomerFamilyConditionTableMap::PAYMENT_MODULE_ID, $module->getId(), $comparison); + } elseif ($module instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(PaymentCustomerFamilyConditionTableMap::PAYMENT_MODULE_ID, $module->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByModule() only accepts arguments of type \Thelia\Model\Module or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Module relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildPaymentCustomerFamilyConditionQuery The current query, for fluid interface + */ + public function joinModule($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Module'); + + // 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, 'Module'); + } + + return $this; + } + + /** + * Use the Module relation Module 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\ModuleQuery A secondary query class using the current class as primary query + */ + public function useModuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinModule($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Module', '\Thelia\Model\ModuleQuery'); + } + + /** + * Exclude object from result + * + * @param ChildPaymentCustomerFamilyCondition $paymentCustomerFamilyCondition Object to remove from the list of results + * + * @return ChildPaymentCustomerFamilyConditionQuery The current query, for fluid interface + */ + public function prune($paymentCustomerFamilyCondition = null) + { + if ($paymentCustomerFamilyCondition) { + $this->addUsingAlias(PaymentCustomerFamilyConditionTableMap::ID, $paymentCustomerFamilyCondition->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Deletes all rows from the payment_customer_family_condition 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(PaymentCustomerFamilyConditionTableMap::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). + PaymentCustomerFamilyConditionTableMap::clearInstancePool(); + PaymentCustomerFamilyConditionTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildPaymentCustomerFamilyCondition or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildPaymentCustomerFamilyCondition 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(PaymentCustomerFamilyConditionTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(PaymentCustomerFamilyConditionTableMap::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(); + + + PaymentCustomerFamilyConditionTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + PaymentCustomerFamilyConditionTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // PaymentCustomerFamilyConditionQuery diff --git a/local/modules/PaymentCondition/Model/Base/PaymentDeliveryCondition.php b/local/modules/PaymentCondition/Model/Base/PaymentDeliveryCondition.php new file mode 100644 index 00000000..a706067a --- /dev/null +++ b/local/modules/PaymentCondition/Model/Base/PaymentDeliveryCondition.php @@ -0,0 +1,1386 @@ +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 PaymentDeliveryCondition instance. If + * obj is an instance of PaymentDeliveryCondition, delegates to + * equals(PaymentDeliveryCondition). 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 PaymentDeliveryCondition 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 PaymentDeliveryCondition 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 [payment_module_id] column value. + * + * @return int + */ + public function getPaymentModuleId() + { + + return $this->payment_module_id; + } + + /** + * Get the [delivery_module_id] column value. + * + * @return int + */ + public function getDeliveryModuleId() + { + + return $this->delivery_module_id; + } + + /** + * Get the [is_valid] column value. + * + * @return int + */ + public function getIsValid() + { + + return $this->is_valid; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \PaymentCondition\Model\PaymentDeliveryCondition 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[PaymentDeliveryConditionTableMap::ID] = true; + } + + + return $this; + } // setId() + + /** + * Set the value of [payment_module_id] column. + * + * @param int $v new value + * @return \PaymentCondition\Model\PaymentDeliveryCondition The current object (for fluent API support) + */ + public function setPaymentModuleId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->payment_module_id !== $v) { + $this->payment_module_id = $v; + $this->modifiedColumns[PaymentDeliveryConditionTableMap::PAYMENT_MODULE_ID] = true; + } + + if ($this->aModuleRelatedByPaymentModuleId !== null && $this->aModuleRelatedByPaymentModuleId->getId() !== $v) { + $this->aModuleRelatedByPaymentModuleId = null; + } + + + return $this; + } // setPaymentModuleId() + + /** + * Set the value of [delivery_module_id] column. + * + * @param int $v new value + * @return \PaymentCondition\Model\PaymentDeliveryCondition The current object (for fluent API support) + */ + public function setDeliveryModuleId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->delivery_module_id !== $v) { + $this->delivery_module_id = $v; + $this->modifiedColumns[PaymentDeliveryConditionTableMap::DELIVERY_MODULE_ID] = true; + } + + if ($this->aModuleRelatedByDeliveryModuleId !== null && $this->aModuleRelatedByDeliveryModuleId->getId() !== $v) { + $this->aModuleRelatedByDeliveryModuleId = null; + } + + + return $this; + } // setDeliveryModuleId() + + /** + * Set the value of [is_valid] column. + * + * @param int $v new value + * @return \PaymentCondition\Model\PaymentDeliveryCondition The current object (for fluent API support) + */ + public function setIsValid($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->is_valid !== $v) { + $this->is_valid = $v; + $this->modifiedColumns[PaymentDeliveryConditionTableMap::IS_VALID] = true; + } + + + return $this; + } // setIsValid() + + /** + * 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 : PaymentDeliveryConditionTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : PaymentDeliveryConditionTableMap::translateFieldName('PaymentModuleId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->payment_module_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : PaymentDeliveryConditionTableMap::translateFieldName('DeliveryModuleId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->delivery_module_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : PaymentDeliveryConditionTableMap::translateFieldName('IsValid', TableMap::TYPE_PHPNAME, $indexType)]; + $this->is_valid = (null !== $col) ? (int) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 4; // 4 = PaymentDeliveryConditionTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \PaymentCondition\Model\PaymentDeliveryCondition 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->aModuleRelatedByPaymentModuleId !== null && $this->payment_module_id !== $this->aModuleRelatedByPaymentModuleId->getId()) { + $this->aModuleRelatedByPaymentModuleId = null; + } + if ($this->aModuleRelatedByDeliveryModuleId !== null && $this->delivery_module_id !== $this->aModuleRelatedByDeliveryModuleId->getId()) { + $this->aModuleRelatedByDeliveryModuleId = 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(PaymentDeliveryConditionTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildPaymentDeliveryConditionQuery::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->aModuleRelatedByPaymentModuleId = null; + $this->aModuleRelatedByDeliveryModuleId = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see PaymentDeliveryCondition::setDeleted() + * @see PaymentDeliveryCondition::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(PaymentDeliveryConditionTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildPaymentDeliveryConditionQuery::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(PaymentDeliveryConditionTableMap::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); + PaymentDeliveryConditionTableMap::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->aModuleRelatedByPaymentModuleId !== null) { + if ($this->aModuleRelatedByPaymentModuleId->isModified() || $this->aModuleRelatedByPaymentModuleId->isNew()) { + $affectedRows += $this->aModuleRelatedByPaymentModuleId->save($con); + } + $this->setModuleRelatedByPaymentModuleId($this->aModuleRelatedByPaymentModuleId); + } + + if ($this->aModuleRelatedByDeliveryModuleId !== null) { + if ($this->aModuleRelatedByDeliveryModuleId->isModified() || $this->aModuleRelatedByDeliveryModuleId->isNew()) { + $affectedRows += $this->aModuleRelatedByDeliveryModuleId->save($con); + } + $this->setModuleRelatedByDeliveryModuleId($this->aModuleRelatedByDeliveryModuleId); + } + + 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[PaymentDeliveryConditionTableMap::ID] = true; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . PaymentDeliveryConditionTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(PaymentDeliveryConditionTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(PaymentDeliveryConditionTableMap::PAYMENT_MODULE_ID)) { + $modifiedColumns[':p' . $index++] = 'PAYMENT_MODULE_ID'; + } + if ($this->isColumnModified(PaymentDeliveryConditionTableMap::DELIVERY_MODULE_ID)) { + $modifiedColumns[':p' . $index++] = 'DELIVERY_MODULE_ID'; + } + if ($this->isColumnModified(PaymentDeliveryConditionTableMap::IS_VALID)) { + $modifiedColumns[':p' . $index++] = 'IS_VALID'; + } + + $sql = sprintf( + 'INSERT INTO payment_delivery_condition (%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 'PAYMENT_MODULE_ID': + $stmt->bindValue($identifier, $this->payment_module_id, PDO::PARAM_INT); + break; + case 'DELIVERY_MODULE_ID': + $stmt->bindValue($identifier, $this->delivery_module_id, PDO::PARAM_INT); + break; + case 'IS_VALID': + $stmt->bindValue($identifier, $this->is_valid, 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 = PaymentDeliveryConditionTableMap::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->getPaymentModuleId(); + break; + case 2: + return $this->getDeliveryModuleId(); + break; + case 3: + return $this->getIsValid(); + 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['PaymentDeliveryCondition'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['PaymentDeliveryCondition'][$this->getPrimaryKey()] = true; + $keys = PaymentDeliveryConditionTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getPaymentModuleId(), + $keys[2] => $this->getDeliveryModuleId(), + $keys[3] => $this->getIsValid(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aModuleRelatedByPaymentModuleId) { + $result['ModuleRelatedByPaymentModuleId'] = $this->aModuleRelatedByPaymentModuleId->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->aModuleRelatedByDeliveryModuleId) { + $result['ModuleRelatedByDeliveryModuleId'] = $this->aModuleRelatedByDeliveryModuleId->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 = PaymentDeliveryConditionTableMap::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->setPaymentModuleId($value); + break; + case 2: + $this->setDeliveryModuleId($value); + break; + case 3: + $this->setIsValid($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 = PaymentDeliveryConditionTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setPaymentModuleId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setDeliveryModuleId($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setIsValid($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(PaymentDeliveryConditionTableMap::DATABASE_NAME); + + if ($this->isColumnModified(PaymentDeliveryConditionTableMap::ID)) $criteria->add(PaymentDeliveryConditionTableMap::ID, $this->id); + if ($this->isColumnModified(PaymentDeliveryConditionTableMap::PAYMENT_MODULE_ID)) $criteria->add(PaymentDeliveryConditionTableMap::PAYMENT_MODULE_ID, $this->payment_module_id); + if ($this->isColumnModified(PaymentDeliveryConditionTableMap::DELIVERY_MODULE_ID)) $criteria->add(PaymentDeliveryConditionTableMap::DELIVERY_MODULE_ID, $this->delivery_module_id); + if ($this->isColumnModified(PaymentDeliveryConditionTableMap::IS_VALID)) $criteria->add(PaymentDeliveryConditionTableMap::IS_VALID, $this->is_valid); + + 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(PaymentDeliveryConditionTableMap::DATABASE_NAME); + $criteria->add(PaymentDeliveryConditionTableMap::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 \PaymentCondition\Model\PaymentDeliveryCondition (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->setPaymentModuleId($this->getPaymentModuleId()); + $copyObj->setDeliveryModuleId($this->getDeliveryModuleId()); + $copyObj->setIsValid($this->getIsValid()); + 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 \PaymentCondition\Model\PaymentDeliveryCondition 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 ChildModule object. + * + * @param ChildModule $v + * @return \PaymentCondition\Model\PaymentDeliveryCondition The current object (for fluent API support) + * @throws PropelException + */ + public function setModuleRelatedByPaymentModuleId(ChildModule $v = null) + { + if ($v === null) { + $this->setPaymentModuleId(NULL); + } else { + $this->setPaymentModuleId($v->getId()); + } + + $this->aModuleRelatedByPaymentModuleId = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildModule object, it will not be re-added. + if ($v !== null) { + $v->addPaymentDeliveryConditionRelatedByPaymentModuleId($this); + } + + + return $this; + } + + + /** + * Get the associated ChildModule object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildModule The associated ChildModule object. + * @throws PropelException + */ + public function getModuleRelatedByPaymentModuleId(ConnectionInterface $con = null) + { + if ($this->aModuleRelatedByPaymentModuleId === null && ($this->payment_module_id !== null)) { + $this->aModuleRelatedByPaymentModuleId = ModuleQuery::create()->findPk($this->payment_module_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->aModuleRelatedByPaymentModuleId->addPaymentDeliveryConditionsRelatedByPaymentModuleId($this); + */ + } + + return $this->aModuleRelatedByPaymentModuleId; + } + + /** + * Declares an association between this object and a ChildModule object. + * + * @param ChildModule $v + * @return \PaymentCondition\Model\PaymentDeliveryCondition The current object (for fluent API support) + * @throws PropelException + */ + public function setModuleRelatedByDeliveryModuleId(ChildModule $v = null) + { + if ($v === null) { + $this->setDeliveryModuleId(NULL); + } else { + $this->setDeliveryModuleId($v->getId()); + } + + $this->aModuleRelatedByDeliveryModuleId = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildModule object, it will not be re-added. + if ($v !== null) { + $v->addPaymentDeliveryConditionRelatedByDeliveryModuleId($this); + } + + + return $this; + } + + + /** + * Get the associated ChildModule object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildModule The associated ChildModule object. + * @throws PropelException + */ + public function getModuleRelatedByDeliveryModuleId(ConnectionInterface $con = null) + { + if ($this->aModuleRelatedByDeliveryModuleId === null && ($this->delivery_module_id !== null)) { + $this->aModuleRelatedByDeliveryModuleId = ModuleQuery::create()->findPk($this->delivery_module_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->aModuleRelatedByDeliveryModuleId->addPaymentDeliveryConditionsRelatedByDeliveryModuleId($this); + */ + } + + return $this->aModuleRelatedByDeliveryModuleId; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->payment_module_id = null; + $this->delivery_module_id = null; + $this->is_valid = 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->aModuleRelatedByPaymentModuleId = null; + $this->aModuleRelatedByDeliveryModuleId = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(PaymentDeliveryConditionTableMap::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/PaymentCondition/Model/Base/PaymentDeliveryConditionQuery.php b/local/modules/PaymentCondition/Model/Base/PaymentDeliveryConditionQuery.php new file mode 100644 index 00000000..a024d269 --- /dev/null +++ b/local/modules/PaymentCondition/Model/Base/PaymentDeliveryConditionQuery.php @@ -0,0 +1,645 @@ +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 ChildPaymentDeliveryCondition|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = PaymentDeliveryConditionTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(PaymentDeliveryConditionTableMap::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 ChildPaymentDeliveryCondition A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, PAYMENT_MODULE_ID, DELIVERY_MODULE_ID, IS_VALID FROM payment_delivery_condition 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 ChildPaymentDeliveryCondition(); + $obj->hydrate($row); + PaymentDeliveryConditionTableMap::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 ChildPaymentDeliveryCondition|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 ChildPaymentDeliveryConditionQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(PaymentDeliveryConditionTableMap::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 ChildPaymentDeliveryConditionQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(PaymentDeliveryConditionTableMap::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 ChildPaymentDeliveryConditionQuery 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(PaymentDeliveryConditionTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(PaymentDeliveryConditionTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(PaymentDeliveryConditionTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the payment_module_id column + * + * Example usage: + * + * $query->filterByPaymentModuleId(1234); // WHERE payment_module_id = 1234 + * $query->filterByPaymentModuleId(array(12, 34)); // WHERE payment_module_id IN (12, 34) + * $query->filterByPaymentModuleId(array('min' => 12)); // WHERE payment_module_id > 12 + * + * + * @see filterByModuleRelatedByPaymentModuleId() + * + * @param mixed $paymentModuleId 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 ChildPaymentDeliveryConditionQuery The current query, for fluid interface + */ + public function filterByPaymentModuleId($paymentModuleId = null, $comparison = null) + { + if (is_array($paymentModuleId)) { + $useMinMax = false; + if (isset($paymentModuleId['min'])) { + $this->addUsingAlias(PaymentDeliveryConditionTableMap::PAYMENT_MODULE_ID, $paymentModuleId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($paymentModuleId['max'])) { + $this->addUsingAlias(PaymentDeliveryConditionTableMap::PAYMENT_MODULE_ID, $paymentModuleId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(PaymentDeliveryConditionTableMap::PAYMENT_MODULE_ID, $paymentModuleId, $comparison); + } + + /** + * Filter the query on the delivery_module_id column + * + * Example usage: + * + * $query->filterByDeliveryModuleId(1234); // WHERE delivery_module_id = 1234 + * $query->filterByDeliveryModuleId(array(12, 34)); // WHERE delivery_module_id IN (12, 34) + * $query->filterByDeliveryModuleId(array('min' => 12)); // WHERE delivery_module_id > 12 + * + * + * @see filterByModuleRelatedByDeliveryModuleId() + * + * @param mixed $deliveryModuleId 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 ChildPaymentDeliveryConditionQuery The current query, for fluid interface + */ + public function filterByDeliveryModuleId($deliveryModuleId = null, $comparison = null) + { + if (is_array($deliveryModuleId)) { + $useMinMax = false; + if (isset($deliveryModuleId['min'])) { + $this->addUsingAlias(PaymentDeliveryConditionTableMap::DELIVERY_MODULE_ID, $deliveryModuleId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($deliveryModuleId['max'])) { + $this->addUsingAlias(PaymentDeliveryConditionTableMap::DELIVERY_MODULE_ID, $deliveryModuleId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(PaymentDeliveryConditionTableMap::DELIVERY_MODULE_ID, $deliveryModuleId, $comparison); + } + + /** + * Filter the query on the is_valid column + * + * Example usage: + * + * $query->filterByIsValid(1234); // WHERE is_valid = 1234 + * $query->filterByIsValid(array(12, 34)); // WHERE is_valid IN (12, 34) + * $query->filterByIsValid(array('min' => 12)); // WHERE is_valid > 12 + * + * + * @param mixed $isValid 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 ChildPaymentDeliveryConditionQuery The current query, for fluid interface + */ + public function filterByIsValid($isValid = null, $comparison = null) + { + if (is_array($isValid)) { + $useMinMax = false; + if (isset($isValid['min'])) { + $this->addUsingAlias(PaymentDeliveryConditionTableMap::IS_VALID, $isValid['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($isValid['max'])) { + $this->addUsingAlias(PaymentDeliveryConditionTableMap::IS_VALID, $isValid['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(PaymentDeliveryConditionTableMap::IS_VALID, $isValid, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\Module object + * + * @param \Thelia\Model\Module|ObjectCollection $module The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildPaymentDeliveryConditionQuery The current query, for fluid interface + */ + public function filterByModuleRelatedByPaymentModuleId($module, $comparison = null) + { + if ($module instanceof \Thelia\Model\Module) { + return $this + ->addUsingAlias(PaymentDeliveryConditionTableMap::PAYMENT_MODULE_ID, $module->getId(), $comparison); + } elseif ($module instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(PaymentDeliveryConditionTableMap::PAYMENT_MODULE_ID, $module->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByModuleRelatedByPaymentModuleId() only accepts arguments of type \Thelia\Model\Module or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the ModuleRelatedByPaymentModuleId relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildPaymentDeliveryConditionQuery The current query, for fluid interface + */ + public function joinModuleRelatedByPaymentModuleId($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('ModuleRelatedByPaymentModuleId'); + + // 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, 'ModuleRelatedByPaymentModuleId'); + } + + return $this; + } + + /** + * Use the ModuleRelatedByPaymentModuleId relation Module 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\ModuleQuery A secondary query class using the current class as primary query + */ + public function useModuleRelatedByPaymentModuleIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinModuleRelatedByPaymentModuleId($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ModuleRelatedByPaymentModuleId', '\Thelia\Model\ModuleQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\Module object + * + * @param \Thelia\Model\Module|ObjectCollection $module The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildPaymentDeliveryConditionQuery The current query, for fluid interface + */ + public function filterByModuleRelatedByDeliveryModuleId($module, $comparison = null) + { + if ($module instanceof \Thelia\Model\Module) { + return $this + ->addUsingAlias(PaymentDeliveryConditionTableMap::DELIVERY_MODULE_ID, $module->getId(), $comparison); + } elseif ($module instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(PaymentDeliveryConditionTableMap::DELIVERY_MODULE_ID, $module->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByModuleRelatedByDeliveryModuleId() only accepts arguments of type \Thelia\Model\Module or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the ModuleRelatedByDeliveryModuleId relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildPaymentDeliveryConditionQuery The current query, for fluid interface + */ + public function joinModuleRelatedByDeliveryModuleId($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('ModuleRelatedByDeliveryModuleId'); + + // 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, 'ModuleRelatedByDeliveryModuleId'); + } + + return $this; + } + + /** + * Use the ModuleRelatedByDeliveryModuleId relation Module 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\ModuleQuery A secondary query class using the current class as primary query + */ + public function useModuleRelatedByDeliveryModuleIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinModuleRelatedByDeliveryModuleId($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ModuleRelatedByDeliveryModuleId', '\Thelia\Model\ModuleQuery'); + } + + /** + * Exclude object from result + * + * @param ChildPaymentDeliveryCondition $paymentDeliveryCondition Object to remove from the list of results + * + * @return ChildPaymentDeliveryConditionQuery The current query, for fluid interface + */ + public function prune($paymentDeliveryCondition = null) + { + if ($paymentDeliveryCondition) { + $this->addUsingAlias(PaymentDeliveryConditionTableMap::ID, $paymentDeliveryCondition->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Deletes all rows from the payment_delivery_condition 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(PaymentDeliveryConditionTableMap::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). + PaymentDeliveryConditionTableMap::clearInstancePool(); + PaymentDeliveryConditionTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildPaymentDeliveryCondition or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildPaymentDeliveryCondition 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(PaymentDeliveryConditionTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(PaymentDeliveryConditionTableMap::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(); + + + PaymentDeliveryConditionTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + PaymentDeliveryConditionTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // PaymentDeliveryConditionQuery diff --git a/local/modules/PaymentCondition/Model/Map/PaymentAreaConditionTableMap.php b/local/modules/PaymentCondition/Model/Map/PaymentAreaConditionTableMap.php new file mode 100644 index 00000000..1533f7c6 --- /dev/null +++ b/local/modules/PaymentCondition/Model/Map/PaymentAreaConditionTableMap.php @@ -0,0 +1,428 @@ + array('Id', 'PaymentModuleId', 'AreaId', 'IsValid', ), + self::TYPE_STUDLYPHPNAME => array('id', 'paymentModuleId', 'areaId', 'isValid', ), + self::TYPE_COLNAME => array(PaymentAreaConditionTableMap::ID, PaymentAreaConditionTableMap::PAYMENT_MODULE_ID, PaymentAreaConditionTableMap::AREA_ID, PaymentAreaConditionTableMap::IS_VALID, ), + self::TYPE_RAW_COLNAME => array('ID', 'PAYMENT_MODULE_ID', 'AREA_ID', 'IS_VALID', ), + self::TYPE_FIELDNAME => array('id', 'payment_module_id', 'area_id', 'is_valid', ), + 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, 'PaymentModuleId' => 1, 'AreaId' => 2, 'IsValid' => 3, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'paymentModuleId' => 1, 'areaId' => 2, 'isValid' => 3, ), + self::TYPE_COLNAME => array(PaymentAreaConditionTableMap::ID => 0, PaymentAreaConditionTableMap::PAYMENT_MODULE_ID => 1, PaymentAreaConditionTableMap::AREA_ID => 2, PaymentAreaConditionTableMap::IS_VALID => 3, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'PAYMENT_MODULE_ID' => 1, 'AREA_ID' => 2, 'IS_VALID' => 3, ), + self::TYPE_FIELDNAME => array('id' => 0, 'payment_module_id' => 1, 'area_id' => 2, 'is_valid' => 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('payment_area_condition'); + $this->setPhpName('PaymentAreaCondition'); + $this->setClassName('\\PaymentCondition\\Model\\PaymentAreaCondition'); + $this->setPackage('PaymentCondition.Model'); + $this->setUseIdGenerator(true); + // columns + $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('PAYMENT_MODULE_ID', 'PaymentModuleId', 'INTEGER', 'module', 'ID', true, null, null); + $this->addForeignKey('AREA_ID', 'AreaId', 'INTEGER', 'area', 'ID', true, null, null); + $this->addColumn('IS_VALID', 'IsValid', 'TINYINT', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('Module', '\\Thelia\\Model\\Module', RelationMap::MANY_TO_ONE, array('payment_module_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $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 ? PaymentAreaConditionTableMap::CLASS_DEFAULT : PaymentAreaConditionTableMap::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 (PaymentAreaCondition object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = PaymentAreaConditionTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = PaymentAreaConditionTableMap::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 + PaymentAreaConditionTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = PaymentAreaConditionTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + PaymentAreaConditionTableMap::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 = PaymentAreaConditionTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = PaymentAreaConditionTableMap::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; + PaymentAreaConditionTableMap::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(PaymentAreaConditionTableMap::ID); + $criteria->addSelectColumn(PaymentAreaConditionTableMap::PAYMENT_MODULE_ID); + $criteria->addSelectColumn(PaymentAreaConditionTableMap::AREA_ID); + $criteria->addSelectColumn(PaymentAreaConditionTableMap::IS_VALID); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.PAYMENT_MODULE_ID'); + $criteria->addSelectColumn($alias . '.AREA_ID'); + $criteria->addSelectColumn($alias . '.IS_VALID'); + } + } + + /** + * 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(PaymentAreaConditionTableMap::DATABASE_NAME)->getTable(PaymentAreaConditionTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(PaymentAreaConditionTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(PaymentAreaConditionTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new PaymentAreaConditionTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a PaymentAreaCondition or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or PaymentAreaCondition 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(PaymentAreaConditionTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \PaymentCondition\Model\PaymentAreaCondition) { // 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(PaymentAreaConditionTableMap::DATABASE_NAME); + $criteria->add(PaymentAreaConditionTableMap::ID, (array) $values, Criteria::IN); + } + + $query = PaymentAreaConditionQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { PaymentAreaConditionTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { PaymentAreaConditionTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the payment_area_condition 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 PaymentAreaConditionQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a PaymentAreaCondition or Criteria object. + * + * @param mixed $criteria Criteria or PaymentAreaCondition 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(PaymentAreaConditionTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from PaymentAreaCondition object + } + + if ($criteria->containsKey(PaymentAreaConditionTableMap::ID) && $criteria->keyContainsValue(PaymentAreaConditionTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.PaymentAreaConditionTableMap::ID.')'); + } + + + // Set the correct dbName + $query = PaymentAreaConditionQuery::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; + } + +} // PaymentAreaConditionTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +PaymentAreaConditionTableMap::buildTableMap(); diff --git a/local/modules/PaymentCondition/Model/Map/PaymentCustomerFamilyConditionTableMap.php b/local/modules/PaymentCondition/Model/Map/PaymentCustomerFamilyConditionTableMap.php new file mode 100644 index 00000000..6f1b6a45 --- /dev/null +++ b/local/modules/PaymentCondition/Model/Map/PaymentCustomerFamilyConditionTableMap.php @@ -0,0 +1,427 @@ + array('Id', 'PaymentModuleId', 'CustomerFamilyId', 'IsValid', ), + self::TYPE_STUDLYPHPNAME => array('id', 'paymentModuleId', 'customerFamilyId', 'isValid', ), + self::TYPE_COLNAME => array(PaymentCustomerFamilyConditionTableMap::ID, PaymentCustomerFamilyConditionTableMap::PAYMENT_MODULE_ID, PaymentCustomerFamilyConditionTableMap::CUSTOMER_FAMILY_ID, PaymentCustomerFamilyConditionTableMap::IS_VALID, ), + self::TYPE_RAW_COLNAME => array('ID', 'PAYMENT_MODULE_ID', 'CUSTOMER_FAMILY_ID', 'IS_VALID', ), + self::TYPE_FIELDNAME => array('id', 'payment_module_id', 'customer_family_id', 'is_valid', ), + 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, 'PaymentModuleId' => 1, 'CustomerFamilyId' => 2, 'IsValid' => 3, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'paymentModuleId' => 1, 'customerFamilyId' => 2, 'isValid' => 3, ), + self::TYPE_COLNAME => array(PaymentCustomerFamilyConditionTableMap::ID => 0, PaymentCustomerFamilyConditionTableMap::PAYMENT_MODULE_ID => 1, PaymentCustomerFamilyConditionTableMap::CUSTOMER_FAMILY_ID => 2, PaymentCustomerFamilyConditionTableMap::IS_VALID => 3, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'PAYMENT_MODULE_ID' => 1, 'CUSTOMER_FAMILY_ID' => 2, 'IS_VALID' => 3, ), + self::TYPE_FIELDNAME => array('id' => 0, 'payment_module_id' => 1, 'customer_family_id' => 2, 'is_valid' => 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('payment_customer_family_condition'); + $this->setPhpName('PaymentCustomerFamilyCondition'); + $this->setClassName('\\PaymentCondition\\Model\\PaymentCustomerFamilyCondition'); + $this->setPackage('PaymentCondition.Model'); + $this->setUseIdGenerator(true); + // columns + $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('PAYMENT_MODULE_ID', 'PaymentModuleId', 'INTEGER', 'module', 'ID', true, null, null); + $this->addColumn('CUSTOMER_FAMILY_ID', 'CustomerFamilyId', 'INTEGER', true, null, null); + $this->addColumn('IS_VALID', 'IsValid', 'TINYINT', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('Module', '\\Thelia\\Model\\Module', RelationMap::MANY_TO_ONE, array('payment_module_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 ? PaymentCustomerFamilyConditionTableMap::CLASS_DEFAULT : PaymentCustomerFamilyConditionTableMap::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 (PaymentCustomerFamilyCondition object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = PaymentCustomerFamilyConditionTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = PaymentCustomerFamilyConditionTableMap::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 + PaymentCustomerFamilyConditionTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = PaymentCustomerFamilyConditionTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + PaymentCustomerFamilyConditionTableMap::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 = PaymentCustomerFamilyConditionTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = PaymentCustomerFamilyConditionTableMap::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; + PaymentCustomerFamilyConditionTableMap::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(PaymentCustomerFamilyConditionTableMap::ID); + $criteria->addSelectColumn(PaymentCustomerFamilyConditionTableMap::PAYMENT_MODULE_ID); + $criteria->addSelectColumn(PaymentCustomerFamilyConditionTableMap::CUSTOMER_FAMILY_ID); + $criteria->addSelectColumn(PaymentCustomerFamilyConditionTableMap::IS_VALID); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.PAYMENT_MODULE_ID'); + $criteria->addSelectColumn($alias . '.CUSTOMER_FAMILY_ID'); + $criteria->addSelectColumn($alias . '.IS_VALID'); + } + } + + /** + * 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(PaymentCustomerFamilyConditionTableMap::DATABASE_NAME)->getTable(PaymentCustomerFamilyConditionTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(PaymentCustomerFamilyConditionTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(PaymentCustomerFamilyConditionTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new PaymentCustomerFamilyConditionTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a PaymentCustomerFamilyCondition or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or PaymentCustomerFamilyCondition 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(PaymentCustomerFamilyConditionTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \PaymentCondition\Model\PaymentCustomerFamilyCondition) { // 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(PaymentCustomerFamilyConditionTableMap::DATABASE_NAME); + $criteria->add(PaymentCustomerFamilyConditionTableMap::ID, (array) $values, Criteria::IN); + } + + $query = PaymentCustomerFamilyConditionQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { PaymentCustomerFamilyConditionTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { PaymentCustomerFamilyConditionTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the payment_customer_family_condition 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 PaymentCustomerFamilyConditionQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a PaymentCustomerFamilyCondition or Criteria object. + * + * @param mixed $criteria Criteria or PaymentCustomerFamilyCondition 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(PaymentCustomerFamilyConditionTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from PaymentCustomerFamilyCondition object + } + + if ($criteria->containsKey(PaymentCustomerFamilyConditionTableMap::ID) && $criteria->keyContainsValue(PaymentCustomerFamilyConditionTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.PaymentCustomerFamilyConditionTableMap::ID.')'); + } + + + // Set the correct dbName + $query = PaymentCustomerFamilyConditionQuery::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; + } + +} // PaymentCustomerFamilyConditionTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +PaymentCustomerFamilyConditionTableMap::buildTableMap(); diff --git a/local/modules/PaymentCondition/Model/Map/PaymentDeliveryConditionTableMap.php b/local/modules/PaymentCondition/Model/Map/PaymentDeliveryConditionTableMap.php new file mode 100644 index 00000000..37113723 --- /dev/null +++ b/local/modules/PaymentCondition/Model/Map/PaymentDeliveryConditionTableMap.php @@ -0,0 +1,428 @@ + array('Id', 'PaymentModuleId', 'DeliveryModuleId', 'IsValid', ), + self::TYPE_STUDLYPHPNAME => array('id', 'paymentModuleId', 'deliveryModuleId', 'isValid', ), + self::TYPE_COLNAME => array(PaymentDeliveryConditionTableMap::ID, PaymentDeliveryConditionTableMap::PAYMENT_MODULE_ID, PaymentDeliveryConditionTableMap::DELIVERY_MODULE_ID, PaymentDeliveryConditionTableMap::IS_VALID, ), + self::TYPE_RAW_COLNAME => array('ID', 'PAYMENT_MODULE_ID', 'DELIVERY_MODULE_ID', 'IS_VALID', ), + self::TYPE_FIELDNAME => array('id', 'payment_module_id', 'delivery_module_id', 'is_valid', ), + 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, 'PaymentModuleId' => 1, 'DeliveryModuleId' => 2, 'IsValid' => 3, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'paymentModuleId' => 1, 'deliveryModuleId' => 2, 'isValid' => 3, ), + self::TYPE_COLNAME => array(PaymentDeliveryConditionTableMap::ID => 0, PaymentDeliveryConditionTableMap::PAYMENT_MODULE_ID => 1, PaymentDeliveryConditionTableMap::DELIVERY_MODULE_ID => 2, PaymentDeliveryConditionTableMap::IS_VALID => 3, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'PAYMENT_MODULE_ID' => 1, 'DELIVERY_MODULE_ID' => 2, 'IS_VALID' => 3, ), + self::TYPE_FIELDNAME => array('id' => 0, 'payment_module_id' => 1, 'delivery_module_id' => 2, 'is_valid' => 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('payment_delivery_condition'); + $this->setPhpName('PaymentDeliveryCondition'); + $this->setClassName('\\PaymentCondition\\Model\\PaymentDeliveryCondition'); + $this->setPackage('PaymentCondition.Model'); + $this->setUseIdGenerator(true); + // columns + $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('PAYMENT_MODULE_ID', 'PaymentModuleId', 'INTEGER', 'module', 'ID', true, null, null); + $this->addForeignKey('DELIVERY_MODULE_ID', 'DeliveryModuleId', 'INTEGER', 'module', 'ID', true, null, null); + $this->addColumn('IS_VALID', 'IsValid', 'TINYINT', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('ModuleRelatedByPaymentModuleId', '\\Thelia\\Model\\Module', RelationMap::MANY_TO_ONE, array('payment_module_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('ModuleRelatedByDeliveryModuleId', '\\Thelia\\Model\\Module', RelationMap::MANY_TO_ONE, array('delivery_module_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 ? PaymentDeliveryConditionTableMap::CLASS_DEFAULT : PaymentDeliveryConditionTableMap::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 (PaymentDeliveryCondition object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = PaymentDeliveryConditionTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = PaymentDeliveryConditionTableMap::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 + PaymentDeliveryConditionTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = PaymentDeliveryConditionTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + PaymentDeliveryConditionTableMap::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 = PaymentDeliveryConditionTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = PaymentDeliveryConditionTableMap::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; + PaymentDeliveryConditionTableMap::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(PaymentDeliveryConditionTableMap::ID); + $criteria->addSelectColumn(PaymentDeliveryConditionTableMap::PAYMENT_MODULE_ID); + $criteria->addSelectColumn(PaymentDeliveryConditionTableMap::DELIVERY_MODULE_ID); + $criteria->addSelectColumn(PaymentDeliveryConditionTableMap::IS_VALID); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.PAYMENT_MODULE_ID'); + $criteria->addSelectColumn($alias . '.DELIVERY_MODULE_ID'); + $criteria->addSelectColumn($alias . '.IS_VALID'); + } + } + + /** + * 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(PaymentDeliveryConditionTableMap::DATABASE_NAME)->getTable(PaymentDeliveryConditionTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(PaymentDeliveryConditionTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(PaymentDeliveryConditionTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new PaymentDeliveryConditionTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a PaymentDeliveryCondition or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or PaymentDeliveryCondition 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(PaymentDeliveryConditionTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \PaymentCondition\Model\PaymentDeliveryCondition) { // 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(PaymentDeliveryConditionTableMap::DATABASE_NAME); + $criteria->add(PaymentDeliveryConditionTableMap::ID, (array) $values, Criteria::IN); + } + + $query = PaymentDeliveryConditionQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { PaymentDeliveryConditionTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { PaymentDeliveryConditionTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the payment_delivery_condition 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 PaymentDeliveryConditionQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a PaymentDeliveryCondition or Criteria object. + * + * @param mixed $criteria Criteria or PaymentDeliveryCondition 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(PaymentDeliveryConditionTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from PaymentDeliveryCondition object + } + + if ($criteria->containsKey(PaymentDeliveryConditionTableMap::ID) && $criteria->keyContainsValue(PaymentDeliveryConditionTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.PaymentDeliveryConditionTableMap::ID.')'); + } + + + // Set the correct dbName + $query = PaymentDeliveryConditionQuery::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; + } + +} // PaymentDeliveryConditionTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +PaymentDeliveryConditionTableMap::buildTableMap(); diff --git a/local/modules/PaymentCondition/Model/PaymentAreaCondition.php b/local/modules/PaymentCondition/Model/PaymentAreaCondition.php new file mode 100644 index 00000000..afcae11b --- /dev/null +++ b/local/modules/PaymentCondition/Model/PaymentAreaCondition.php @@ -0,0 +1,10 @@ +insertSql(null, [__DIR__ . "/Config/thelia.sql"]); + self::setConfigValue('is_initialized', true); + } + } +} diff --git a/local/modules/PaymentCondition/Readme.md b/local/modules/PaymentCondition/Readme.md new file mode 100644 index 00000000..1fc01c52 --- /dev/null +++ b/local/modules/PaymentCondition/Readme.md @@ -0,0 +1,19 @@ +# Payment Condition + +Allow to restrict payment modules by customer, delivery module, customer family or shipping area + +## Installation + +### Composer + +Add it in your main thelia composer.json file + +``` +composer require thelia/payment-condition-module:~1.0 +``` + +## Usage + +Go to module configuration where you can configure the payment restrictions. +This module change the payment loop result so if you use this loop to display your payment method you will have nothing else to do. + diff --git a/local/modules/PaymentCondition/composer.json b/local/modules/PaymentCondition/composer.json new file mode 100644 index 00000000..6d7eb45a --- /dev/null +++ b/local/modules/PaymentCondition/composer.json @@ -0,0 +1,11 @@ +{ + "name": "thelia/payment-condition-module", + "license": "LGPL-3.0+", + "type": "thelia-module", + "require": { + "thelia/installer": "~1.1" + }, + "extra": { + "installer-name": "PaymentCondition" + } +} \ No newline at end of file diff --git a/local/modules/PaymentCondition/templates/backOffice/default/payment-condition/configuration.html b/local/modules/PaymentCondition/templates/backOffice/default/payment-condition/configuration.html new file mode 100644 index 00000000..39be1904 --- /dev/null +++ b/local/modules/PaymentCondition/templates/backOffice/default/payment-condition/configuration.html @@ -0,0 +1,62 @@ +{extends file="admin-layout.tpl"} + +{block name="after-bootstrap-css"} + +{/block} + +{block name="no-return-functions"} + {$admin_current_location = 'module'} +{/block} + +{block name="page-title"}{intl l='Payment condition module configuration' d='paymentcondition.bo.default'}{/block} + +{block name="check-resource"}admin.module{/block} +{block name="check-access"}view{/block} +{block name="check-module"}paymentcondition{/block} + +{block name="main-content"} +
+
+ +
+ + {loop name="customer_family_enabled" type="module" code="CustomerFamily" active="1"} +
+ +
+ {/loop} + {elseloop rel="customer_family_enabled"} +
+ {intl l="Install and activate 'CustomerFamily' module to get configuration options." d='paymentcondition.bo.default'} +
+ {/elseloop} + +
+ +
+
+{/block} + +{block name="javascript-initialization"} + {javascripts file='assets/js/bootstrap-switch/bootstrap-switch.js'} + + {/javascripts} + + +{/block} \ No newline at end of file diff --git a/local/modules/PaymentCondition/templates/backOffice/default/payment-condition/customer_edit_hook.html b/local/modules/PaymentCondition/templates/backOffice/default/payment-condition/customer_edit_hook.html new file mode 100644 index 00000000..0eeb7755 --- /dev/null +++ b/local/modules/PaymentCondition/templates/backOffice/default/payment-condition/customer_edit_hook.html @@ -0,0 +1,25 @@ +
+
+
+
{intl l="Payment conditions for this customer" d="paymentcondition.bo.default"}
+
+
+ {if null === $paymentCustomerCondition || 0 === $paymentCustomerCondition->getModuleRestrictionActive()} +
+ {intl l="Payment restrictions is not activated for this customer" d="paymentcondition.bo.default"} +
+ {else} +

+ {intl l="Allowed payments :" d="paymentcondition.bo.default"} +

+
    + {foreach from=$allowedModules item=allowedModule} +
  • {$allowedModule->getTitle()} ({$allowedModule->getCode()})
  • + {/foreach} +
+ {/if} +
+
+
+
+
\ No newline at end of file diff --git a/local/modules/PaymentCondition/templates/backOffice/default/payment-condition/customer_family.html b/local/modules/PaymentCondition/templates/backOffice/default/payment-condition/customer_family.html new file mode 100644 index 00000000..01baf4d0 --- /dev/null +++ b/local/modules/PaymentCondition/templates/backOffice/default/payment-condition/customer_family.html @@ -0,0 +1,59 @@ +
+

{intl l="Condition by customer family"}

+
+ + + + {$i=0} + {foreach from=$module_codes item=code} + {$i = $i + 1} + + {/foreach} + + {foreach from=$paymentFamilyCondition key=family_id item=item} + + + + {foreach from=$item key=payment_id item=is_valid} + + {/foreach} + + {/foreach} +
{$code}
{$family_codes[$family_id]} +
+ +
+
+
+
+ + diff --git a/local/modules/PaymentCondition/templates/backOffice/default/payment-condition/delivery.html b/local/modules/PaymentCondition/templates/backOffice/default/payment-condition/delivery.html new file mode 100644 index 00000000..06d970c5 --- /dev/null +++ b/local/modules/PaymentCondition/templates/backOffice/default/payment-condition/delivery.html @@ -0,0 +1,57 @@ + +
+

{intl l="Condition by chosen delivery module"}

+
+ + + + {foreach from=$paymentModules item=paymentModule} + + {/foreach} + + {foreach from=$deliveryModules item=deliveryModule} + + + {foreach from=$paymentModules item=paymentModule} + + {/foreach} + + {/foreach} +
{$paymentModule->getCode()}
{$deliveryModule->getCode()} +
+ getId()][$deliveryModule->getId()]}checked{/if}/> +
+
+
+
+ + + diff --git a/local/modules/PaymentCondition/templates/backOffice/default/payment-condition/shipping_area.html b/local/modules/PaymentCondition/templates/backOffice/default/payment-condition/shipping_area.html new file mode 100644 index 00000000..78851ef8 --- /dev/null +++ b/local/modules/PaymentCondition/templates/backOffice/default/payment-condition/shipping_area.html @@ -0,0 +1,57 @@ + +
+

{intl l="Condition by chosen shipping area"}

+
+ + + + {foreach from=$paymentModules item=paymentModule} + + {/foreach} + + {foreach from=$shippingAreas item=shippingArea} + + + {foreach from=$paymentModules item=paymentModule} + + {/foreach} + + {/foreach} +
{$paymentModule->getCode()}
{$shippingArea->getName()} +
+ getId()][$shippingArea->getId()]}checked{/if}/> +
+
+
+
+ + + diff --git a/templates/.gitkeep b/templates/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/templates/frontOffice/hooktest/composer.json b/templates/frontOffice/hooktest/composer.json new file mode 100644 index 00000000..4ee9e18e --- /dev/null +++ b/templates/frontOffice/hooktest/composer.json @@ -0,0 +1,10 @@ +{ + "name": "thelia/hooktest-template", + "type": "thelia-frontoffice-template", + "require": { + "thelia/installer": "~1.1" + }, + "extra": { + "installer-name": "hooktest" + } +} diff --git a/templates/frontOffice/hooktest/includes/single-product.html b/templates/frontOffice/hooktest/includes/single-product.html new file mode 100644 index 00000000..cd7aebd3 --- /dev/null +++ b/templates/frontOffice/hooktest/includes/single-product.html @@ -0,0 +1,110 @@ +
  • + {if $PSE_COUNT > 1} + {assign var="hasSubmit" value = false} + {else} + {assign var="hasSubmit" value = true} + {/if} + {assign var="productTitle" value="{$TITLE}"} + {if not $product_id} + {assign var="product_id" value=$ID} + {/if} +
    + + {hook name="singleproduct.top" product="{$product_id}"} + + + +
    +

    {$productTitle}

    + {if $hasDescription} +
    +

    {$DESCRIPTION nofilter}

    +
    + {/if} +
    + + {* Stock *} + {assign var="current_stock_content" value = "in_stock"} + {assign var="current_stock_href" value = "http://schema.org/InStock"} + {if {config key="check-available-stock"} != 0} + {if $QUANTITY == 0} + {assign var="current_stock_content" value = "out_stock"} + {assign var="current_stock_href" value = "http://schema.org/OutOfStock"} + {/if} + {/if} + +
    +
    + + {* List of condition : NewCondition, DamagedCondition, UsedCondition, RefurbishedCondition *} + + {* List of currency : The currency used to describe the product price, in three-letter ISO format. *} + + + {if $IS_PROMO } + {intl l="Special Price:"} {format_number number=$TAXED_PROMO_PRICE} {currency attr="symbol"} + {intl l="Regular Price:"} {format_number number=$TAXED_PRICE} {currency attr="symbol"} + {else} + {format_number number=$BEST_TAXED_PRICE} {currency attr="symbol"} + {/if} +
    + + {if $hasBtn == true} + {if $hasSubmit == true} + {form name="thelia.cart.add" } +
    + {form_hidden_fields form=$form} + + + + {if $form_error}
    {$form_error_message}
    {/if} + + {form_field form=$form field='product_sale_elements_id'} + + {/form_field} + {form_field form=$form field="product"} + + {/form_field} + +
    + {form_field form=$form field='quantity'} +
    + + + {if $error } + {$message} + {elseif $value != "" && !$error} + + {/if} +
    + {/form_field} +
    +
    + +
    +
    +
    +
    + {/form} + {else} +
    + +
    + {/if} + {/if} +
    + + {hook name="singleproduct.bottom" product="{$product_id}"} + +
    +
  • diff --git a/templates/frontOffice/hooktest/index.html b/templates/frontOffice/hooktest/index.html new file mode 100644 index 00000000..034bb83e --- /dev/null +++ b/templates/frontOffice/hooktest/index.html @@ -0,0 +1,24 @@ +{extends file="layout.tpl"} + +{block name="main-content"} + + {ifhook rel="home.body"} + {hook name="home.body"} + {/ifhook} + {elsehook rel="home.body"} + ::NO home.body:: + {/elsehook} + +{/block} + +{block name="stylesheet"} +{hook name="home.stylesheet"} +{/block} + +{block name="after-javascript-include"} +{hook name="home.after-javascript-include"} +{/block} + +{block name="javascript-initialization"} +{hook name="home.javascript-initialization"} +{/block} diff --git a/templates/frontOffice/hooktest/layout.tpl b/templates/frontOffice/hooktest/layout.tpl new file mode 100644 index 00000000..51134518 --- /dev/null +++ b/templates/frontOffice/hooktest/layout.tpl @@ -0,0 +1,110 @@ + + + + +{* Declare assets directory, relative to template base directory *} +{declare_assets directory='assets'} + +{* Set the default translation domain, that will be used by {intl} when the 'd' parameter is not set *} +{default_translation_domain domain='fo.default'} + +{hook name="main.head-top"} + +{hook name="main.stylesheet"} + +{hook name="main.body-top"} + +{hook name="main.header-top"} + +{hook name="main.navbar-secondary"} +{ifhook rel="main.navbar-secondary"} + ::main.navbar-secondary ifhook:: +{/ifhook} +{elsehook rel="main.navbar-secondary"} + ::main.navbar-secondary elsehook:: +{/elsehook} + +{hook name="main.navbar-primary"} +{ifhook rel="main.navbar-primary"} + ::main.navbar-primary ifhook:: +{/ifhook} +{elsehook rel="main.navbar-primary"} + ::main.navbar-primary elsehook:: +{/elsehook} + +{hook name="main.header-bottom"} + +{hook name="main.content-top"} + + +{block name="main-content"}{/block} + + +{hook name="main.content-bottom"} + +{ifhook rel="main.footer-top"} + {hook name="main.footer-top"} +{/ifhook} +{elsehook rel="main.footer-top"} + ::NO main.footer-top:: +{/elsehook} + +{ifhook rel="product.additional"} +{hookblock name="product.additional"} +{forhook rel="product.additional"} + ::product.additional ifhook:: +{/forhook} +{/hookblock} +{/ifhook} +{elsehook rel="product.additional"} + ::product.additional elsehook:: +{/elsehook} + + + +{ifhook rel="main.footer-body"} + ::main.footer-body ifhook:: + {hookblock name="main.footer-body"} + {forhook rel="main.footer-body"} + ::main.footer-body {$id} {$class} {$content}:: + {/forhook} + {/hookblock} +{/ifhook} +{elsehook rel="main.footer-body"} + ::main.footer-body elsehook:: +{/elsehook} + +{ifhook rel="main.footer-bottom"} + {hook name="main.footer-bottom"} +{/ifhook} +{elsehook rel="main.footer-bottom"} + ::NO main.footer-bottom:: +{/elsehook} + +{hook name="main.after-javascript-include"} + +{block name="after-javascript-include"}{/block} + +{hook name="main.javascript-initialization"} + +{block name="javascript-initialization"}{/block} + +{hook name="main.body-bottom"} diff --git a/templates/frontOffice/hooktest/modules/HookTest/assets/css/style3.css b/templates/frontOffice/hooktest/modules/HookTest/assets/css/style3.css new file mode 100644 index 00000000..ed6ae71a --- /dev/null +++ b/templates/frontOffice/hooktest/modules/HookTest/assets/css/style3.css @@ -0,0 +1 @@ +/* style3 in template/hooktest */ \ No newline at end of file diff --git a/templates/frontOffice/hooktest/modules/HookTest/override3.html b/templates/frontOffice/hooktest/modules/HookTest/override3.html new file mode 100644 index 00000000..a880c846 --- /dev/null +++ b/templates/frontOffice/hooktest/modules/HookTest/override3.html @@ -0,0 +1 @@ +:: file override3 from template/hooktest ::