From 9338cdb472d3bcdd48ea2f0d833463a034096b28 Mon Sep 17 00:00:00 2001 From: gmorel Date: Mon, 16 Sep 2013 22:05:33 +0200 Subject: [PATCH 01/98] Merge branch 'master' of https://github.com/thelia/thelia into coupon # By Manuel Raynaud (19) and others # Via Manuel Raynaud (5) and others * 'master' of https://github.com/thelia/thelia: (37 commits) add PropelDataCollector to debugbar, still missing some informations remove unused class integrate debugbar module remove htmlpurifier modify insert.sql including debugBar module add new event and new tag Started category modification Factorized modal dialogs javascript Factorized creation and confirmation modal dialogs create controller adding delivery module in session create Delivery loop Working : Continuing categories administration... Working : create base loop for delivery and payment entities remove htmlpurifier dependency country id can be an argument for calculate method Working : Working : fix typo ... Conflicts: composer.lock core/lib/Thelia/Controller/Admin/CategoryController.php templates/admin/default/assets/less/thelia/variables.less --- local/modules/Colissimo/Colissimo.php | 0 local/modules/Colissimo/Config/config.xml | 0 local/modules/Colissimo/Config/plugin.xml | 0 local/modules/Colissimo/Config/schema.xml | 0 local/modules/DebugBar/Config/config.xml | 0 local/modules/DebugBar/Config/plugin.xml | 0 local/modules/DebugBar/Config/schema.xml | 0 local/modules/DebugBar/DataCollector/PropelCollector.php | 0 local/modules/DebugBar/DebugBar.php | 0 local/modules/DebugBar/Listeners/DebugBarListeners.php | 0 local/modules/DebugBar/Smarty/Plugin/DebugBar.php | 0 11 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 local/modules/Colissimo/Colissimo.php mode change 100644 => 100755 local/modules/Colissimo/Config/config.xml mode change 100644 => 100755 local/modules/Colissimo/Config/plugin.xml mode change 100644 => 100755 local/modules/Colissimo/Config/schema.xml mode change 100644 => 100755 local/modules/DebugBar/Config/config.xml mode change 100644 => 100755 local/modules/DebugBar/Config/plugin.xml mode change 100644 => 100755 local/modules/DebugBar/Config/schema.xml mode change 100644 => 100755 local/modules/DebugBar/DataCollector/PropelCollector.php mode change 100644 => 100755 local/modules/DebugBar/DebugBar.php mode change 100644 => 100755 local/modules/DebugBar/Listeners/DebugBarListeners.php mode change 100644 => 100755 local/modules/DebugBar/Smarty/Plugin/DebugBar.php diff --git a/local/modules/Colissimo/Colissimo.php b/local/modules/Colissimo/Colissimo.php old mode 100644 new mode 100755 diff --git a/local/modules/Colissimo/Config/config.xml b/local/modules/Colissimo/Config/config.xml old mode 100644 new mode 100755 diff --git a/local/modules/Colissimo/Config/plugin.xml b/local/modules/Colissimo/Config/plugin.xml old mode 100644 new mode 100755 diff --git a/local/modules/Colissimo/Config/schema.xml b/local/modules/Colissimo/Config/schema.xml old mode 100644 new mode 100755 diff --git a/local/modules/DebugBar/Config/config.xml b/local/modules/DebugBar/Config/config.xml old mode 100644 new mode 100755 diff --git a/local/modules/DebugBar/Config/plugin.xml b/local/modules/DebugBar/Config/plugin.xml old mode 100644 new mode 100755 diff --git a/local/modules/DebugBar/Config/schema.xml b/local/modules/DebugBar/Config/schema.xml old mode 100644 new mode 100755 diff --git a/local/modules/DebugBar/DataCollector/PropelCollector.php b/local/modules/DebugBar/DataCollector/PropelCollector.php old mode 100644 new mode 100755 diff --git a/local/modules/DebugBar/DebugBar.php b/local/modules/DebugBar/DebugBar.php old mode 100644 new mode 100755 diff --git a/local/modules/DebugBar/Listeners/DebugBarListeners.php b/local/modules/DebugBar/Listeners/DebugBarListeners.php old mode 100644 new mode 100755 diff --git a/local/modules/DebugBar/Smarty/Plugin/DebugBar.php b/local/modules/DebugBar/Smarty/Plugin/DebugBar.php old mode 100644 new mode 100755 From 6f1c77a57ede3ccc358710d2b752fbee540b2965 Mon Sep 17 00:00:00 2001 From: gmorel Date: Mon, 16 Sep 2013 22:41:17 +0200 Subject: [PATCH 02/98] WIP : Coupon functional tests --- .../functionnal/casperjs/exe/00_parameters.js | 5 - .../casperjs/exe/31_coupons_rule.js | 618 +++++++++--------- 2 files changed, 309 insertions(+), 314 deletions(-) diff --git a/tests/functionnal/casperjs/exe/00_parameters.js b/tests/functionnal/casperjs/exe/00_parameters.js index df5470229..29bf20a25 100644 --- a/tests/functionnal/casperjs/exe/00_parameters.js +++ b/tests/functionnal/casperjs/exe/00_parameters.js @@ -7,11 +7,6 @@ var thelia2_login_coupon_create_url = thelia2_base_url + 'admin/coupon/create/'; var thelia2_login_coupon_read_url = thelia2_base_url + 'admin/coupon/read/1'; var thelia2_login_coupon_update_url = thelia2_base_url + 'admin/coupon/update/1'; - - -//var findMyId = /([0-9]+)$/; -//var currentId; - casper.test.comment('Variables are set'); casper.test.done(0); diff --git a/tests/functionnal/casperjs/exe/31_coupons_rule.js b/tests/functionnal/casperjs/exe/31_coupons_rule.js index 66706aada..4b9ada4ba 100644 --- a/tests/functionnal/casperjs/exe/31_coupons_rule.js +++ b/tests/functionnal/casperjs/exe/31_coupons_rule.js @@ -1,312 +1,312 @@ -//// -////var casper = require('casper').create({ -//// viewportSize:{ -//// width:1024, height:768 -//// }, -//// pageSettings:{ -//// userAgent:'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.79 Safari/535.11' -//// }, -//// verbose:true -////}); // -//casper.test.comment('Testing coupons rules'); -// -////UPDATE COUPON RULE -//casper.start(thelia2_login_coupon_update_url, function() { -// this.test.assertHttpStatus(200); -// this.test.comment('Now on : ' + this.getCurrentUrl()); -// this.capture('tests/functionnal/casperjs/screenshot/coupons/init.png'); -// this.test.comment('COUPON RULE - EDIT'); -// this.test.assertTitle('Update coupon - Thelia Back Office', 'Web page title OK'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','1) 1st default rule found'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','1) 2nd default rule found'); -// -// // Create rule -// this.evaluate(function() { -// $('#category-rule').val('thelia.constraint.rule.available_for_x_articles').change(); -// return true; +//var casper = require('casper').create({ +// viewportSize:{ +// width:1024, height:768 +// }, +// pageSettings:{ +// userAgent:'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.79 Safari/535.11' +// }, +// verbose:true +//}); + +casper.test.comment('Testing coupons rules'); + +//UPDATE COUPON RULE +casper.start(thelia2_login_coupon_update_url, function() { + this.test.assertHttpStatus(200); + this.test.comment('Now on : ' + this.getCurrentUrl()); + this.capture('tests/functionnal/casperjs/screenshot/coupons/init.png'); + this.test.comment('COUPON RULE - EDIT'); + this.test.assertTitle('Update coupon - Thelia Back Office', 'Web page title OK'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','1) 1st default rule found'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','1) 2nd default rule found'); + + // Create rule + this.evaluate(function() { + $('#category-rule').val('thelia.constraint.rule.available_for_x_articles').change(); + return true; + }); + this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-selected.png'); +}); + +casper.wait(1000, function() { + this.echo("\nWaiting...."); +}); + +// Test Rule updating +casper.then(function(){ + this.evaluate(function() { + $('#quantity-operator').val('>=').change(); + return true; + }); + this.sendKeys('input#quantity-value', '4'); + this.click('#constraint-save-btn'); +}); + +casper.wait(1000, function() { + this.echo("\nWaiting...."); +}); + +casper.then(function(){ + this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-added.png'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','2) 1st default rule found'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','2) 2nd default rule found'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', ' If cart products quantity is superior or equal to 4','2) 3rd rule found'); + + // Click on Edit button + this.click('tbody#constraint-list tr:nth-child(3) .constraint-update-btn'); +}); + +casper.wait(2000, function() { + this.echo("\nWaiting...."); +}); + +casper.then(function(){ + this.evaluate(function() { + $('#quantity-operator').val('==').change(); + return true; + }); + + // Removing old value +// casper.evaluate(function triggerKeyDownEvent() { +// var e = $.Event("keydown"); +// e.which = 8; +// e.keyCode = 8; +// $("#quantity-value").trigger(e); // }); -// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-selected.png'); -//}); -// -//casper.wait(1000, function() { -// this.echo("\nWaiting...."); -//}); -// -//// Test Rule updating -//casper.then(function(){ -// this.evaluate(function() { -// $('#quantity-operator').val('>=').change(); -// return true; + this.evaluate(function() { + $("#quantity-value").val('').change(); + return true; + }); + + // Adding new value + this.sendKeys('#quantity-value', '5'); + this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-being-edited.png'); + this.click('#constraint-save-btn'); +}); + +casper.wait(2000, function() { + this.echo("\nWaiting...."); +}); +// Check if updated rule has been saved and list refreshed +casper.then(function(){ + this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-edited.png'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','3) 1st default rule found'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','3) 2nd default rule found'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', 'If cart products quantity is equal to 5','3) 3rd rule updated found'); +}); + +// Check if updated rule has been well saved +casper.thenOpen(thelia2_login_coupon_update_url, function() { + this.test.assertHttpStatus(200); + this.test.comment('Now on : ' + this.getCurrentUrl()); + this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-edited-refreshed.png'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','4) 1st default rule found'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','4) 2nd default rule found'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', 'If cart products quantity is equal to 5','4) 3rd rule updated found'); + + // Click on Delete button + this.click('tbody#constraint-list tr:nth-child(2) .constraint-delete-btn'); +}); + +casper.wait(2000, function() { + this.echo("\nWaiting...."); +}); + +casper.then(function(){ + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','5) 1st default rule found'); + this.test.assertSelectorDoesntHaveText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','5) 2nd default rule found'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart products quantity is equal to 5','5) 3rd rule updated found'); +}); + +// Check if updated rule has been well saved +casper.thenOpen(thelia2_login_coupon_update_url, function() { + this.test.assertHttpStatus(200); + this.test.comment('Now on : ' + this.getCurrentUrl()); + this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-deleted-refreshed.png'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','6) 1st default rule found'); + this.test.assertSelectorDoesntHaveText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','6) 2nd default rule found'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart products quantity is equal to 5','6) 3rd rule updated found'); +}); + +// Test creating rule that won't be edited +casper.then(function(){ +// Create rule + this.evaluate(function() { + $('#category-rule').val('thelia.constraint.rule.available_for_total_amount').change(); + return true; + }); + this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-selected2.png'); +}); + +casper.wait(2000, function() { + this.echo("\nWaiting...."); +}); + +// Test Rule creation +casper.then(function(){ + this.evaluate(function() { + $('#price-operator').val('<=').change(); + return true; + }); + // Removing old value +// casper.evaluate(function triggerKeyDownEvent() { +// var e = $.Event("keydown"); +// e.which = 8; +// e.keyCode = 8; +// $("input#price-value").trigger(e); // }); -// this.sendKeys('input#quantity-value', '4'); -// this.click('#constraint-save-btn'); -//}); -// -//casper.wait(1000, function() { -// this.echo("\nWaiting...."); -//}); -// -//casper.then(function(){ -// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-added.png'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','2) 1st default rule found'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','2) 2nd default rule found'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', ' If cart products quantity is superior or equal to 4','2) 3rd rule found'); -// -// // Click on Edit button -// this.click('tbody#constraint-list tr:nth-child(3) .constraint-update-btn'); -//}); -// -//casper.wait(2000, function() { -// this.echo("\nWaiting...."); -//}); -// -//casper.then(function(){ -// this.evaluate(function() { -// $('#quantity-operator').val('==').change(); -// return true; -// }); -// -// // Removing old value -//// casper.evaluate(function triggerKeyDownEvent() { -//// var e = $.Event("keydown"); -//// e.which = 8; -//// e.keyCode = 8; -//// $("#quantity-value").trigger(e); -//// }); -// this.evaluate(function() { -// $("#quantity-value").val('').change(); -// return true; -// }); -// -// // Adding new value -// this.sendKeys('#quantity-value', '5'); -// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-being-edited.png'); -// this.click('#constraint-save-btn'); -//}); -// -//casper.wait(2000, function() { -// this.echo("\nWaiting...."); -//}); -//// Check if updated rule has been saved and list refreshed -//casper.then(function(){ -// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-edited.png'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','3) 1st default rule found'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','3) 2nd default rule found'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', 'If cart products quantity is equal to 5','3) 3rd rule updated found'); -//}); -// -//// Check if updated rule has been well saved -//casper.thenOpen(thelia2_login_coupon_update_url, function() { -// this.test.assertHttpStatus(200); -// this.test.comment('Now on : ' + this.getCurrentUrl()); -// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-edited-refreshed.png'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','4) 1st default rule found'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','4) 2nd default rule found'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', 'If cart products quantity is equal to 5','4) 3rd rule updated found'); -// -// // Click on Delete button -// this.click('tbody#constraint-list tr:nth-child(2) .constraint-delete-btn'); -//}); -// -//casper.wait(2000, function() { -// this.echo("\nWaiting...."); -//}); -// -//casper.then(function(){ -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','5) 1st default rule found'); -// this.test.assertSelectorDoesntHaveText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','5) 2nd default rule found'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart products quantity is equal to 5','5) 3rd rule updated found'); -//}); -// -//// Check if updated rule has been well saved -//casper.thenOpen(thelia2_login_coupon_update_url, function() { -// this.test.assertHttpStatus(200); -// this.test.comment('Now on : ' + this.getCurrentUrl()); -// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-deleted-refreshed.png'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','6) 1st default rule found'); -// this.test.assertSelectorDoesntHaveText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','6) 2nd default rule found'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart products quantity is equal to 5','6) 3rd rule updated found'); -//}); -// -//// Test creating rule that won't be edited -//casper.then(function(){ -//// Create rule -// this.evaluate(function() { -// $('#category-rule').val('thelia.constraint.rule.available_for_total_amount').change(); -// return true; -// }); -// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-selected2.png'); -//}); -// -//casper.wait(2000, function() { -// this.echo("\nWaiting...."); -//}); -// -//// Test Rule creation -//casper.then(function(){ -// this.evaluate(function() { -// $('#price-operator').val('<=').change(); -// return true; -// }); -// // Removing old value -//// casper.evaluate(function triggerKeyDownEvent() { -//// var e = $.Event("keydown"); -//// e.which = 8; -//// e.keyCode = 8; -//// $("input#price-value").trigger(e); -//// }); -// this.evaluate(function() { -// $("input#price-value").val('').change(); -// return true; -// }); -// -// // Changing 400 to 401 -// this.sendKeys('input#price-value', '401'); -// this.evaluate(function() { -// $('#currency-value').val('GBP').change(); -// return true; -// }); -// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-saved-edited-before-click-save.png'); -// this.click('#constraint-save-btn'); -//}); -// -//casper.wait(2000, function() { -// this.echo("\nWaiting...."); -//}); -// -//casper.then(function(){ -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','7) 1st default rule found'); -// this.test.assertSelectorDoesntHaveText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','7) 2nd default rule found'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart products quantity is equal to 5','7) 3rd rule updated found'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', 'If cart total amount is inferior or equal to 401 GBP','7) 4rd rule created found'); -//}); -// -//// Check if created rule has been well saved -//casper.thenOpen(thelia2_login_coupon_update_url, function() { -// this.test.assertHttpStatus(200); -// this.test.comment('Now on : ' + this.getCurrentUrl()); -// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-added-refreshed.png'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','8) 1st default rule found'); -// this.test.assertSelectorDoesntHaveText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','8) 2nd default rule found'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart products quantity is equal to 5','8) 3rd rule updated found'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', 'If cart total amount is inferior or equal to 401 GBP','8) 4rd rule created found'); -//}); -// -//// Testing deleting all rules -//casper.then(function(){ -//// Click on Delete button -// this.click('tbody#constraint-list tr:nth-child(1) .constraint-delete-btn'); -//}); -//casper.wait(1000, function() { -// this.echo("\nWaiting...."); -//}); -//casper.then(function(){ -//// Click on Delete button -// this.click('tbody#constraint-list tr:nth-child(1) .constraint-delete-btn'); -//}); -//casper.wait(1000, function() { -// this.echo("\nWaiting...."); -//}); -//casper.then(function(){ -//// Click on Delete button -// this.click('tbody#constraint-list tr:nth-child(1) .constraint-delete-btn'); -//}); -//casper.wait(1000, function() { -// this.echo("\nWaiting...."); -//}); -//casper.then(function(){ -// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted.png'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'No conditions','9) 1st default rule found'); -// test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)'); -//}); -// -//// Check if created rule has been well saved -//casper.thenOpen(thelia2_login_coupon_update_url, function() { -// this.test.assertHttpStatus(200); -// this.test.comment('Now on : ' + this.getCurrentUrl()); -// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted-refreshed.png'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'No conditions','10) 1st default rule found'); -// test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)'); -//}); -// -// -//// Test add no condition rule -//casper.then(function(){ -// this.evaluate(function() { -// $('#category-rule').val('thelia.constraint.rule.available_for_x_articles').change(); -// return true; -// }); -//}); -// -//casper.wait(1000, function() { -// this.echo("\nWaiting...."); -//}); -// -//// Test Rule updating -//casper.then(function(){ -// this.evaluate(function() { -// $('#quantity-operator').val('>').change(); -// return true; -// }); -// this.sendKeys('input#quantity-value', '4'); -// this.click('#constraint-save-btn'); -//}); -// -//casper.wait(1000, function() { -// this.echo("\nWaiting...."); -//}); -// -//casper.then(function(){ -// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted.png'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart products quantity is superior to 4', '11) 1st default rule found'); -// test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)'); -//}); -// -//// Check if created rule has been well saved -//casper.thenOpen(thelia2_login_coupon_update_url, function() { -// this.test.assertHttpStatus(200); -// this.test.comment('Now on : ' + this.getCurrentUrl()); -// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted-refreshed.png'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart products quantity is superior to 4','12) 1st default rule found'); -// test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)'); -//}); -// -//casper.then(function(){ -// this.evaluate(function() { -// $('#category-rule').val('thelia.constraint.rule.available_for_everyone').change(); -// return true; -// }); -//}); -// -//casper.wait(1000, function() { -// this.echo("\nWaiting...."); -//}); -// -//// Test Rule updating -//casper.then(function(){ -// this.click('#constraint-save-btn'); -//}); -// -//casper.wait(1000, function() { -// this.echo("\nWaiting...."); -//}); -//casper.then(function(){ -// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted.png'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'No conditions','13) 1st default rule found'); -// test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)'); -//}); -// -//// Check if created rule has been well saved -//casper.thenOpen(thelia2_login_coupon_update_url, function() { -// this.test.assertHttpStatus(200); -// this.test.comment('Now on : ' + this.getCurrentUrl()); -// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted-refreshed.png'); -// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'No conditions','14) 1st default rule found'); -// test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)'); -//}); -// -////RUN -//casper.run(function() { -// this.test.done(); -//}); \ No newline at end of file + this.evaluate(function() { + $("input#price-value").val('').change(); + return true; + }); + + // Changing 400 to 401 + this.sendKeys('input#price-value', '401'); + this.evaluate(function() { + $('#currency-value').val('GBP').change(); + return true; + }); + this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-saved-edited-before-click-save.png'); + this.click('#constraint-save-btn'); +}); + +casper.wait(2000, function() { + this.echo("\nWaiting...."); +}); + +casper.then(function(){ + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','7) 1st default rule found'); + this.test.assertSelectorDoesntHaveText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','7) 2nd default rule found'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart products quantity is equal to 5','7) 3rd rule updated found'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', 'If cart total amount is inferior or equal to 401 GBP','7) 4rd rule created found'); +}); + +// Check if created rule has been well saved +casper.thenOpen(thelia2_login_coupon_update_url, function() { + this.test.assertHttpStatus(200); + this.test.comment('Now on : ' + this.getCurrentUrl()); + this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-added-refreshed.png'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','8) 1st default rule found'); + this.test.assertSelectorDoesntHaveText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','8) 2nd default rule found'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart products quantity is equal to 5','8) 3rd rule updated found'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', 'If cart total amount is inferior or equal to 401 GBP','8) 4rd rule created found'); +}); + +// Testing deleting all rules +casper.then(function(){ +// Click on Delete button + this.click('tbody#constraint-list tr:nth-child(1) .constraint-delete-btn'); +}); +casper.wait(1000, function() { + this.echo("\nWaiting...."); +}); +casper.then(function(){ +// Click on Delete button + this.click('tbody#constraint-list tr:nth-child(1) .constraint-delete-btn'); +}); +casper.wait(1000, function() { + this.echo("\nWaiting...."); +}); +casper.then(function(){ +// Click on Delete button + this.click('tbody#constraint-list tr:nth-child(1) .constraint-delete-btn'); +}); +casper.wait(1000, function() { + this.echo("\nWaiting...."); +}); +casper.then(function(){ + this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted.png'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'No conditions','9) 1st default rule found'); + test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)'); +}); + +// Check if created rule has been well saved +casper.thenOpen(thelia2_login_coupon_update_url, function() { + this.test.assertHttpStatus(200); + this.test.comment('Now on : ' + this.getCurrentUrl()); + this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted-refreshed.png'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'No conditions','10) 1st default rule found'); + test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)'); +}); + + +// Test add no condition rule +casper.then(function(){ + this.evaluate(function() { + $('#category-rule').val('thelia.constraint.rule.available_for_x_articles').change(); + return true; + }); +}); + +casper.wait(1000, function() { + this.echo("\nWaiting...."); +}); + +// Test Rule updating +casper.then(function(){ + this.evaluate(function() { + $('#quantity-operator').val('>').change(); + return true; + }); + this.sendKeys('input#quantity-value', '4'); + this.click('#constraint-save-btn'); +}); + +casper.wait(1000, function() { + this.echo("\nWaiting...."); +}); + +casper.then(function(){ + this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted.png'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart products quantity is superior to 4', '11) 1st default rule found'); + test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)'); +}); + +// Check if created rule has been well saved +casper.thenOpen(thelia2_login_coupon_update_url, function() { + this.test.assertHttpStatus(200); + this.test.comment('Now on : ' + this.getCurrentUrl()); + this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted-refreshed.png'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart products quantity is superior to 4','12) 1st default rule found'); + test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)'); +}); + +casper.then(function(){ + this.evaluate(function() { + $('#category-rule').val('thelia.constraint.rule.available_for_everyone').change(); + return true; + }); +}); + +casper.wait(1000, function() { + this.echo("\nWaiting...."); +}); + +// Test Rule updating +casper.then(function(){ + this.click('#constraint-save-btn'); +}); + +casper.wait(1000, function() { + this.echo("\nWaiting...."); +}); +casper.then(function(){ + this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted.png'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'No conditions','13) 1st default rule found'); + test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)'); +}); + +// Check if created rule has been well saved +casper.thenOpen(thelia2_login_coupon_update_url, function() { + this.test.assertHttpStatus(200); + this.test.comment('Now on : ' + this.getCurrentUrl()); + this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted-refreshed.png'); + this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'No conditions','14) 1st default rule found'); + test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)'); +}); + +//RUN +casper.run(function() { + this.test.done(); +}); \ No newline at end of file From 73c0a96979501b5c9a3f44e4dd69e6aed824954f Mon Sep 17 00:00:00 2001 From: gmorel Date: Mon, 16 Sep 2013 23:05:46 +0200 Subject: [PATCH 03/98] WIP : Coupon : unit tests on Operator --- .../Tests/Constraint/Rule/OperatorsTest.php | 62 +++++++++++++++++-- 1 file changed, 56 insertions(+), 6 deletions(-) diff --git a/core/lib/Thelia/Tests/Constraint/Rule/OperatorsTest.php b/core/lib/Thelia/Tests/Constraint/Rule/OperatorsTest.php index 0b29baa62..d5a340d2b 100644 --- a/core/lib/Thelia/Tests/Constraint/Rule/OperatorsTest.php +++ b/core/lib/Thelia/Tests/Constraint/Rule/OperatorsTest.php @@ -23,7 +23,6 @@ namespace Thelia\Coupon; -use Thelia\Constraint\Validator\QuantityParam; use Thelia\Constraint\Rule\Operators; /** @@ -48,14 +47,58 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase { } - public function testSomething() +// public function testSomething() +// { +// // Stop here and mark this test as incomplete. +// $this->markTestIncomplete( +// 'This test has not been implemented yet.' +// ); +// } + + public function testOperatorI18n() { - // Stop here and mark this test as incomplete. - $this->markTestIncomplete( - 'This test has not been implemented yet.' - ); + $stubTranslator = $this->getMockBuilder('\Symfony\Component\Translation\Translator') + ->disableOriginalConstructor() + ->getMock(); + + $stubTranslator->expects($this->any()) + ->method('trans') + ->will($this->returnCallback((array($this, 'callbackI18n')))); + + $actual = Operators::getI18n($stubTranslator, Operators::INFERIOR); + $expected = 'inferior to'; + $this->assertEquals($expected, $actual); + + $actual = Operators::getI18n($stubTranslator, Operators::INFERIOR_OR_EQUAL); + $expected = 'inferior or equal to'; + $this->assertEquals($expected, $actual); + + $actual = Operators::getI18n($stubTranslator, Operators::EQUAL); + $expected = 'equal to'; + $this->assertEquals($expected, $actual); + + $actual = Operators::getI18n($stubTranslator, Operators::SUPERIOR_OR_EQUAL); + $expected = 'superior or equal to'; + $this->assertEquals($expected, $actual); + + $actual = Operators::getI18n($stubTranslator, Operators::SUPERIOR); + $expected = 'superior to'; + $this->assertEquals($expected, $actual); + + $actual = Operators::getI18n($stubTranslator, Operators::DIFFERENT); + $expected = 'different from'; + $this->assertEquals($expected, $actual); + + $actual = Operators::getI18n($stubTranslator, Operators::IN); + $expected = 'in'; + $this->assertEquals($expected, $actual); + + $actual = Operators::getI18n($stubTranslator, Operators::OUT); + $expected = 'not in'; + $this->assertEquals($expected, $actual); } + // /** // * // * @covers Thelia\Coupon\Rule\Operator::isValidAccordingToOperator @@ -424,4 +467,11 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase { } + function callbackI18n() { + $args = func_get_args(); + + return $args[0]; + } } + + From ad48823b4819fdfe0a7a615fce8fabd38b9a991a Mon Sep 17 00:00:00 2001 From: gmorel Date: Mon, 16 Sep 2013 23:51:47 +0200 Subject: [PATCH 04/98] WIP : Coupon : unit tests on Rules --- ...=> AvailableForTotalAmountManagerTest.php} | 259 +++++++++++------- ...p => AvailableForXArticlesManagerTest.php} | 122 +++++---- .../Tests/Constraint/Rule/OperatorsTest.php | 4 + 3 files changed, 236 insertions(+), 149 deletions(-) rename core/lib/Thelia/Tests/Constraint/Rule/{AvailableForTotalAmountTest.php => AvailableForTotalAmountManagerTest.php} (78%) rename core/lib/Thelia/Tests/Constraint/Rule/{AvailableForXArticlesTest.php => AvailableForXArticlesManagerTest.php} (89%) diff --git a/core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountTest.php b/core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountManagerTest.php similarity index 78% rename from core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountTest.php rename to core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountManagerTest.php index c3f7249df..4ad790a5b 100644 --- a/core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountTest.php +++ b/core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountManagerTest.php @@ -26,19 +26,20 @@ namespace Thelia\Coupon; use Thelia\Constraint\ConstraintValidator; use Thelia\Constraint\Rule\AvailableForTotalAmountManager; use Thelia\Constraint\Rule\Operators; +use Thelia\Exception\InvalidRuleValueException; /** * Created by JetBrains PhpStorm. * Date: 8/19/13 * Time: 3:24 PM * - * Unit Test AvailableForTotalAmount Class + * Unit Test AvailableForTotalAmountManager Class * * @package Constraint * @author Guillaume MOREL * */ -class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase +class AvailableForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase { /** @var CouponAdapterInterface $stubTheliaAdapter */ protected $stubTheliaAdapter = null; @@ -49,108 +50,168 @@ class AvailableForTotalAmountTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { -// /** @var CouponAdapterInterface $stubTheliaAdapter */ -// $this->stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); + } -// /** -// * Generate valid CouponBaseAdapter -// * -// * @param float $cartTotalPrice Total amount of the current Cart -// * -// * @return CouponAdapterInterface -// */ -// protected function generateValidCouponBaseAdapterMock($cartTotalPrice = 421.23) -// { -// /** @var CouponAdapterInterface $stubTheliaAdapter */ -// $stubTheliaAdapter = $this->getMock( -// 'Thelia\Coupon\CouponBaseAdapter', -// array('getCartTotalPrice'), -// array() -// ); -// $stubTheliaAdapter->expects($this->any()) -// ->method('getCartTotalPrice') -// ->will($this->returnValue($cartTotalPrice)); -// -// return $stubTheliaAdapter; -// } + /** + * Check if validity test on BackOffice inputs are working + * + * @covers Thelia\Coupon\Rule\AvailableForTotalAmountManager::setValidators + * @expectedException \Thelia\Exception\InvalidRuleOperatorException + * + */ + public function testInValidBackOfficeInputOperator() + { + $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') + ->disableOriginalConstructor() + ->getMock(); -// /** -// * Check if validity test on BackOffice inputs are working -// * -// * @covers Thelia\Coupon\Rule\AvailableForTotalAmount::checkBackOfficeInput -// * -// */ -// public function testValidBackOfficeInput() -// { -// $adapter = new CouponBaseAdapter(); -// -// $validators = array( -// AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( -// Operators::SUPERIOR, -// new PriceParam( -// $adapter, 421.23, 'EUR' -// ) -// ) -// ); -// $rule = new AvailableForTotalAmount($adapter, $validators); -// -// $expected = true; -// $actual = $rule->checkBackOfficeInput(); -// $this->assertEquals($expected, $actual); -// } + $stubAdapter->expects($this->any()) + ->method('getCartTotalPrice') + ->will($this->returnValue(399)); + $stubAdapter->expects($this->any()) + ->method('getCheckoutCurrency') + ->will($this->returnValue('EUR')); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); -// /** -// * Check if validity test on BackOffice inputs are working -// * -// * @covers Thelia\Coupon\Rule\AvailableForTotalAmount::checkBackOfficeInput -// * @expectedException \Thelia\Exception\InvalidRuleOperatorException -// * -// */ -// public function testInValidBackOfficeInputOperator() -// { -// $adapter = new CouponBaseAdapter(); -// -// $validators = array( -// AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( -// 'X', -// new PriceParam( -// $adapter, 421.23, 'EUR' -// ) -// ) -// ); -// -// $rule = new AvailableForTotalAmount($adapter, $validators); -// -// $expected = false; -// $actual = $rule->checkBackOfficeInput(); -// $this->assertEquals($expected, $actual); -// } + $rule1 = new AvailableForTotalAmountManager($stubAdapter); + $operators = array( + AvailableForTotalAmountManager::INPUT1 => Operators::IN, + AvailableForTotalAmountManager::INPUT2 => Operators::EQUAL + ); + $values = array( + AvailableForTotalAmountManager::INPUT1 => '400', + AvailableForTotalAmountManager::INPUT2 => 'EUR'); + $rule1->setValidatorsFromForm($operators, $values); -// /** -// * Check if validity test on BackOffice inputs are working -// * -// * @covers Thelia\Coupon\Rule\AvailableForTotalAmount::checkBackOfficeInput -// * @expectedException \ErrorException -// * -// */ -// public function testInValidBackOfficeInputValue() -// { -// $adapter = $this->generateValidCouponBaseAdapterMock(); -// -// $validators = array( -// AvailableForTotalAmount::PARAM1_PRICE => new RuleValidator( -// Operators::SUPERIOR, -// 421 -// ) -// ); -// -// $rule = new AvailableForTotalAmount($adapter, $validators); -// -// $expected = false; -// $actual = $rule->checkBackOfficeInput(); -// $this->assertEquals($expected, $actual); -// } + $isValid = $rule1->isMatching(); + + $expected = true; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + /** + * Check if validity test on BackOffice inputs are working + * + * @covers Thelia\Coupon\Rule\AvailableForTotalAmountManager::setValidators + * @expectedException \Thelia\Exception\InvalidRuleOperatorException + * + */ + public function testInValidBackOfficeInputOperator2() + { + $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') + ->disableOriginalConstructor() + ->getMock(); + + $stubAdapter->expects($this->any()) + ->method('getCartTotalPrice') + ->will($this->returnValue(399)); + $stubAdapter->expects($this->any()) + ->method('getCheckoutCurrency') + ->will($this->returnValue('EUR')); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); + + $rule1 = new AvailableForTotalAmountManager($stubAdapter); + $operators = array( + AvailableForTotalAmountManager::INPUT1 => Operators::SUPERIOR, + AvailableForTotalAmountManager::INPUT2 => Operators::INFERIOR + ); + $values = array( + AvailableForTotalAmountManager::INPUT1 => '400', + AvailableForTotalAmountManager::INPUT2 => 'EUR'); + $rule1->setValidatorsFromForm($operators, $values); + + $isValid = $rule1->isMatching(); + + $expected = true; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + /** + * Check if validity test on BackOffice inputs are working + * + * @covers Thelia\Coupon\Rule\AvailableForTotalAmountManager::setValidators + * @expectedException \Thelia\Exception\InvalidRuleValueException + * + */ + public function testInValidBackOfficeInputValue() + { + $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') + ->disableOriginalConstructor() + ->getMock(); + + $stubAdapter->expects($this->any()) + ->method('getCartTotalPrice') + ->will($this->returnValue(399)); + $stubAdapter->expects($this->any()) + ->method('getCheckoutCurrency') + ->will($this->returnValue('EUR')); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); + + $rule1 = new AvailableForTotalAmountManager($stubAdapter); + $operators = array( + AvailableForTotalAmountManager::INPUT1 => Operators::SUPERIOR, + AvailableForTotalAmountManager::INPUT2 => Operators::EQUAL + ); + $values = array( + AvailableForTotalAmountManager::INPUT1 => 'X', + AvailableForTotalAmountManager::INPUT2 => 'EUR'); + $rule1->setValidatorsFromForm($operators, $values); + + $isValid = $rule1->isMatching(); + + $expected = true; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + /** + * Check if validity test on BackOffice inputs are working + * + * @covers Thelia\Coupon\Rule\AvailableForTotalAmountManager::setValidators + * @expectedException \Thelia\Exception\InvalidRuleValueException + * + */ + public function testInValidBackOfficeInputValue2() + { + $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') + ->disableOriginalConstructor() + ->getMock(); + + $stubAdapter->expects($this->any()) + ->method('getCartTotalPrice') + ->will($this->returnValue(399)); + $stubAdapter->expects($this->any()) + ->method('getCheckoutCurrency') + ->will($this->returnValue('EUR')); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); + + $rule1 = new AvailableForTotalAmountManager($stubAdapter); + $operators = array( + AvailableForTotalAmountManager::INPUT1 => Operators::SUPERIOR, + AvailableForTotalAmountManager::INPUT2 => Operators::EQUAL + ); + $values = array( + AvailableForTotalAmountManager::INPUT1 => 400, + AvailableForTotalAmountManager::INPUT2 => 'FLA'); + $rule1->setValidatorsFromForm($operators, $values); + + $isValid = $rule1->isMatching(); + + $expected = true; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } /** * Check if test inferior operator is working diff --git a/core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesTest.php b/core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesManagerTest.php similarity index 89% rename from core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesTest.php rename to core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesManagerTest.php index 4ecbcb8ac..12deb34b8 100644 --- a/core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesTest.php +++ b/core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesManagerTest.php @@ -33,13 +33,13 @@ use Thelia\Constraint\Rule\SerializableRule; * Date: 8/19/13 * Time: 3:24 PM * - * Unit Test AvailableForXArticles Class + * Unit Test AvailableForXArticlesManager Class * * @package Constraint * @author Guillaume MOREL * */ -class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase +class AvailableForXArticlesManagerTest extends \PHPUnit_Framework_TestCase { // /** @var CouponAdapterInterface $stubTheliaAdapter */ @@ -51,30 +51,8 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { -// /** @var CouponAdapterInterface $stubTheliaAdapter */ -// $this->stubTheliaAdapter = $this->generateValidCouponBaseAdapterMock(); - } -// /** -// * Generate valid CouponBaseAdapter -// * -// * @param int $nbArticlesInCart Total articles in the current Cart -// * -// * @return CouponAdapterInterface -// */ -// protected function generateValidCouponBaseAdapterMock($nbArticlesInCart = 4) -// { -// /** @var CouponAdapterInterface $stubTheliaAdapter */ -// $stubTheliaAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') -// ->disableOriginalConstructor() -// ->setMethods(array('getNbArticlesInCart')) -// ->getMock(); -// $stubTheliaAdapter->expects($this->any()) -// ->method('getNbArticlesInCart') -// ->will($this->returnValue($nbArticlesInCart)); -// -// return $stubTheliaAdapter; -// } + } // /** // * Check if validity test on BackOffice inputs are working @@ -100,31 +78,75 @@ class AvailableForXArticlesTest extends \PHPUnit_Framework_TestCase // $this->assertEquals($expected, $actual); // } -// /** -// * Check if validity test on BackOffice inputs are working -// * -// * @covers Thelia\Coupon\Rule\AvailableForXArticles::checkBackOfficeInput -// * @expectedException \Thelia\Exception\InvalidRuleValueException -// */ -// public function testInValidBackOfficeInputFloat() -// { -// $adapter = $this->stubTheliaAdapter; -// -// $validators = array( -// AvailableForXArticles::PARAM1_QUANTITY => new RuleValidator( -// Operators::SUPERIOR, -// new QuantityParam( -// $adapter, -// 4.5 -// ) -// ) -// ); -// $rule = new AvailableForXArticles($adapter, $validators); -// -// $expected = false; -// $actual = $rule->checkBackOfficeInput(); -// $this->assertEquals($expected, $actual); -// } + /** + * Check if validity test on BackOffice inputs are working + * + * @covers Thelia\Coupon\Rule\AvailableForXArticles::checkBackOfficeInput + * @expectedException \Thelia\Exception\InvalidRuleOperatorException + */ + public function testInValidBackOfficeInputOperator() + { + $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') + ->disableOriginalConstructor() + ->getMock(); + + $stubAdapter->expects($this->any()) + ->method('getNbArticlesInCart') + ->will($this->returnValue(4)); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); + + $rule1 = new AvailableForXArticlesManager($stubAdapter); + $operators = array( + AvailableForXArticlesManager::INPUT1 => Operators::IN + ); + $values = array( + AvailableForXArticlesManager::INPUT1 => 5 + ); + $rule1->setValidatorsFromForm($operators, $values); + + $isValid = $rule1->isMatching(); + + $expected = true; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } + + /** + * Check if validity test on BackOffice inputs are working + * + * @covers Thelia\Coupon\Rule\AvailableForXArticles::checkBackOfficeInput + * @expectedException \Thelia\Exception\InvalidRuleValueException + */ + public function testInValidBackOfficeInputValue() + { + $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') + ->disableOriginalConstructor() + ->getMock(); + + $stubAdapter->expects($this->any()) + ->method('getNbArticlesInCart') + ->will($this->returnValue(4)); + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); + + $rule1 = new AvailableForXArticlesManager($stubAdapter); + $operators = array( + AvailableForXArticlesManager::INPUT1 => Operators::SUPERIOR + ); + $values = array( + AvailableForXArticlesManager::INPUT1 => 'X' + ); + $rule1->setValidatorsFromForm($operators, $values); + + $isValid = $rule1->isMatching(); + + $expected = true; + $actual =$isValid; + $this->assertEquals($expected, $actual); + } // /** // * Check if validity test on BackOffice inputs are working diff --git a/core/lib/Thelia/Tests/Constraint/Rule/OperatorsTest.php b/core/lib/Thelia/Tests/Constraint/Rule/OperatorsTest.php index d5a340d2b..6cdcb3430 100644 --- a/core/lib/Thelia/Tests/Constraint/Rule/OperatorsTest.php +++ b/core/lib/Thelia/Tests/Constraint/Rule/OperatorsTest.php @@ -96,6 +96,10 @@ class OperatorsTest extends \PHPUnit_Framework_TestCase $actual = Operators::getI18n($stubTranslator, Operators::OUT); $expected = 'not in'; $this->assertEquals($expected, $actual); + + $actual = Operators::getI18n($stubTranslator, 'unexpected operator'); + $expected = 'unexpected operator'; + $this->assertEquals($expected, $actual); } From a7ef4300aa16ba189a9d383ed1d2f2ba5f8c374b Mon Sep 17 00:00:00 2001 From: gmorel Date: Mon, 16 Sep 2013 23:56:31 +0200 Subject: [PATCH 05/98] WIP : Coupon : unit tests on Rules --- .../Rule/AvailableForTotalAmountManager.php | 12 +-- .../Rule/AvailableForXArticlesManager.php | 9 ++- core/lib/Thelia/Constraint/Rule/Operators.php | 56 ------------- .../Rule/AvailableForXArticlesManagerTest.php | 80 +------------------ 4 files changed, 13 insertions(+), 144 deletions(-) diff --git a/core/lib/Thelia/Constraint/Rule/AvailableForTotalAmountManager.php b/core/lib/Thelia/Constraint/Rule/AvailableForTotalAmountManager.php index 30bc86ad6..d8a4755f6 100644 --- a/core/lib/Thelia/Constraint/Rule/AvailableForTotalAmountManager.php +++ b/core/lib/Thelia/Constraint/Rule/AvailableForTotalAmountManager.php @@ -111,8 +111,8 @@ class AvailableForTotalAmountManager extends CouponRuleAbstract $this->availableOperators[self::INPUT1] ); if (!$isOperator1Legit) { - throw new \InvalidArgumentException( - 'Operator for price field is not legit' + throw new InvalidRuleOperatorException( + get_class(), 'price' ); } @@ -121,15 +121,15 @@ class AvailableForTotalAmountManager extends CouponRuleAbstract $this->availableOperators[self::INPUT2] ); if (!$isOperator1Legit) { - throw new \InvalidArgumentException( - 'Operator for currency field is not legit' + throw new InvalidRuleOperatorException( + get_class(), 'price' ); } $floatType = new FloatType(); if (!$floatType->isValid($priceValue) || $priceValue <= 0) { - throw new \InvalidArgumentException( - 'Value for price field is not legit' + throw new InvalidRuleValueException( + get_class(), 'price' ); } diff --git a/core/lib/Thelia/Constraint/Rule/AvailableForXArticlesManager.php b/core/lib/Thelia/Constraint/Rule/AvailableForXArticlesManager.php index 572d39b1d..f73d5e2be 100644 --- a/core/lib/Thelia/Constraint/Rule/AvailableForXArticlesManager.php +++ b/core/lib/Thelia/Constraint/Rule/AvailableForXArticlesManager.php @@ -30,6 +30,7 @@ use Thelia\Constraint\Validator\QuantityParam; use Thelia\Constraint\Validator\RuleValidator; use Thelia\Coupon\CouponAdapterInterface; use Thelia\Exception\InvalidRuleException; +use Thelia\Exception\InvalidRuleOperatorException; use Thelia\Exception\InvalidRuleValueException; use Thelia\Type\FloatType; @@ -98,14 +99,14 @@ class AvailableForXArticlesManager extends CouponRuleAbstract $this->availableOperators[self::INPUT1] ); if (!$isOperator1Legit) { - throw new \InvalidArgumentException( - 'Operator for quantity field is not legit' + throw new InvalidRuleOperatorException( + get_class(), 'quantity' ); } if ((int) $quantityValue <= 0) { - throw new \InvalidArgumentException( - 'Value for quantity field is not legit' + throw new InvalidRuleValueException( + get_class(), 'quantity' ); } diff --git a/core/lib/Thelia/Constraint/Rule/Operators.php b/core/lib/Thelia/Constraint/Rule/Operators.php index 2ed5c2909..a6c457c75 100644 --- a/core/lib/Thelia/Constraint/Rule/Operators.php +++ b/core/lib/Thelia/Constraint/Rule/Operators.php @@ -56,62 +56,6 @@ abstract class Operators /** Param1 is not in Param2 */ CONST OUT = 'out'; -// /** -// * Check if a parameter is valid against a ComparableInterface from its operator -// * -// * @param mixed $a Parameter to validate -// * @param string $operator Operator to validate against -// * @param ComparableInterface $b Comparable to validate against -// * -// * @return bool -// */ -// public static function isValid($a, $operator, ComparableInterface $b) -// { -// $ret = false; -// -// try { -// $comparison = $b->compareTo($a); -// } catch (\Exception $e) { -// return false; -// } -// -// switch ($operator) { -// case self::INFERIOR: -// if ($comparison == 1) { -// return true; -// } -// break; -// case self::INFERIOR_OR_EQUAL: -// if ($comparison == 1 || $comparison == 0) { -// return true; -// } -// break; -// case self::EQUAL: -// if ($comparison == 0) { -// return true; -// } -// break; -// case self::SUPERIOR_OR_EQUAL: -// if ($comparison == -1 || $comparison == 0) { -// return true; -// } -// break; -// case self::SUPERIOR: -// if ($comparison == -1) { -// return true; -// } -// break; -// case self::DIFFERENT: -// if ($comparison != 0) { -// return true; -// } -// break; -// default: -// } -// -// return $ret; -// } - /** * Get operator translation * diff --git a/core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesManagerTest.php b/core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesManagerTest.php index 12deb34b8..4937826b6 100644 --- a/core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesManagerTest.php +++ b/core/lib/Thelia/Tests/Constraint/Rule/AvailableForXArticlesManagerTest.php @@ -54,34 +54,10 @@ class AvailableForXArticlesManagerTest extends \PHPUnit_Framework_TestCase } -// /** -// * Check if validity test on BackOffice inputs are working -// * -// * @covers Thelia\Coupon\Rule\AvailableForXArticles::checkBackOfficeInput -// * -// */ -// public function testValidBackOfficeInput() -// { -// $translator = $this->getMockBuilder('\Thelia\Core\Translation\Translator') -// ->disableOriginalConstructor() -// ->getMock(); -// -// $rule = new AvailableForXArticles($translator); -// $operators = array(AvailableForXArticles::PARAM1_QUANTITY => Operators::SUPERIOR); -// $values = array( -// AvailableForXArticles::PARAM1_QUANTITY => 4 -// ); -// $rule->populateFromForm($operators, $values); -// -// $expected = true; -// $actual = $rule->checkBackOfficeInput(); -// $this->assertEquals($expected, $actual); -// } - /** * Check if validity test on BackOffice inputs are working * - * @covers Thelia\Coupon\Rule\AvailableForXArticles::checkBackOfficeInput + * @covers Thelia\Coupon\Rule\AvailableForXArticlesManager::setValidators * @expectedException \Thelia\Exception\InvalidRuleOperatorException */ public function testInValidBackOfficeInputOperator() @@ -116,7 +92,7 @@ class AvailableForXArticlesManagerTest extends \PHPUnit_Framework_TestCase /** * Check if validity test on BackOffice inputs are working * - * @covers Thelia\Coupon\Rule\AvailableForXArticles::checkBackOfficeInput + * @covers Thelia\Coupon\Rule\AvailableForXArticlesManager::setValidators * @expectedException \Thelia\Exception\InvalidRuleValueException */ public function testInValidBackOfficeInputValue() @@ -148,58 +124,6 @@ class AvailableForXArticlesManagerTest extends \PHPUnit_Framework_TestCase $this->assertEquals($expected, $actual); } -// /** -// * Check if validity test on BackOffice inputs are working -// * -// * @covers Thelia\Coupon\Rule\AvailableForXArticles::checkBackOfficeInput -// * @expectedException \Thelia\Exception\InvalidRuleValueException -// */ -// public function testInValidBackOfficeInputNegative() -// { -// $adapter = $this->stubTheliaAdapter; -// -// $validators = array( -// AvailableForXArticles::PARAM1_QUANTITY => new RuleValidator( -// Operators::SUPERIOR, -// new QuantityParam( -// $adapter, -// -1 -// ) -// ) -// ); -// $rule = new AvailableForXArticles($adapter, $validators); -// -// $expected = false; -// $actual = $rule->checkBackOfficeInput(); -// $this->assertEquals($expected, $actual); -// } - -// /** -// * Check if validity test on BackOffice inputs are working -// * -// * @covers Thelia\Coupon\Rule\AvailableForXArticles::checkBackOfficeInput -// * @expectedException \Thelia\Exception\InvalidRuleValueException -// */ -// public function testInValidBackOfficeInputString() -// { -// $adapter = $this->stubTheliaAdapter; -// -// $validators = array( -// AvailableForXArticles::PARAM1_QUANTITY => new RuleValidator( -// Operators::SUPERIOR, -// new QuantityParam( -// $adapter, -// 'bad' -// ) -// ) -// ); -// $rule = new AvailableForXArticles($adapter, $validators); -// -// $expected = false; -// $actual = $rule->checkBackOfficeInput(); -// $this->assertEquals($expected, $actual); -// } - /** * Check if test inferior operator is working * From 3b249dc21c65bea8836a275d867b1d00d516cb4e Mon Sep 17 00:00:00 2001 From: gmorel Date: Tue, 17 Sep 2013 11:41:09 +0200 Subject: [PATCH 06/98] Working : Coupon : Unit testing --- .../Rule/AvailableForTotalAmountManager.php | 11 +- .../Constraint/Rule/CouponRuleAbstract.php | 51 +++ .../Controller/Admin/CouponController.php | 2 + .../Thelia/Coupon/CouponAdapterInterface.php | 7 + core/lib/Thelia/Coupon/CouponBaseAdapter.php | 15 + .../AvailableForTotalAmountManagerTest.php | 290 ++++-------------- 6 files changed, 135 insertions(+), 241 deletions(-) diff --git a/core/lib/Thelia/Constraint/Rule/AvailableForTotalAmountManager.php b/core/lib/Thelia/Constraint/Rule/AvailableForTotalAmountManager.php index d8a4755f6..c4087e734 100644 --- a/core/lib/Thelia/Constraint/Rule/AvailableForTotalAmountManager.php +++ b/core/lib/Thelia/Constraint/Rule/AvailableForTotalAmountManager.php @@ -126,14 +126,11 @@ class AvailableForTotalAmountManager extends CouponRuleAbstract ); } - $floatType = new FloatType(); - if (!$floatType->isValid($priceValue) || $priceValue <= 0) { - throw new InvalidRuleValueException( - get_class(), 'price' - ); - } + $this->isPriceValid($priceValue); + + + $this->IsCurrencyValid($currencyValue); - // @todo check currency is legit or not $this->operators = array( self::INPUT1 => $priceOperator, diff --git a/core/lib/Thelia/Constraint/Rule/CouponRuleAbstract.php b/core/lib/Thelia/Constraint/Rule/CouponRuleAbstract.php index 0986daa50..ffd1eb0f3 100644 --- a/core/lib/Thelia/Constraint/Rule/CouponRuleAbstract.php +++ b/core/lib/Thelia/Constraint/Rule/CouponRuleAbstract.php @@ -31,6 +31,9 @@ use Thelia\Constraint\Validator\ComparableInterface; use Thelia\Constraint\Validator\RuleValidator; use Thelia\Exception\InvalidRuleException; use Thelia\Exception\InvalidRuleOperatorException; +use Thelia\Exception\InvalidRuleValueException; +use Thelia\Model\Currency; +use Thelia\Type\FloatType; /** * Created by JetBrains PhpStorm. @@ -268,4 +271,52 @@ abstract class CouponRuleAbstract implements CouponRuleInterface return $serializableRule; } + + /** + * Check if currency if valid or not + * + * @param string $currencyValue Currency EUR|USD|.. + * + * @return bool + * @throws \Thelia\Exception\InvalidRuleValueException + */ + protected function IsCurrencyValid($currencyValue) + { + $availableCurrencies = $this->adapter->getAvailableCurrencies(); + /** @var Currency $currency */ + $currencyFound = false; + foreach ($availableCurrencies as $key => $currency) { + if ($currencyValue == $currency->getCode()) { + $currencyFound = true; + } + } + if (!$currencyFound) { + throw new InvalidRuleValueException( + get_class(), 'currency' + ); + } + + return true; + } + + /** + * Check if price is valid + * + * @param float $priceValue Price value to check + * + * @return bool + * @throws \Thelia\Exception\InvalidRuleValueException + */ + protected function isPriceValid($priceValue) + { + $floatType = new FloatType(); + if (!$floatType->isValid($priceValue) || $priceValue <= 0) { + throw new InvalidRuleValueException( + get_class(), 'price' + ); + } + + return true; + } + } \ No newline at end of file diff --git a/core/lib/Thelia/Controller/Admin/CouponController.php b/core/lib/Thelia/Controller/Admin/CouponController.php index 6803addfd..f50c58307 100755 --- a/core/lib/Thelia/Controller/Admin/CouponController.php +++ b/core/lib/Thelia/Controller/Admin/CouponController.php @@ -49,7 +49,9 @@ use Thelia\Form\Exception\FormValidationException; use Thelia\Log\Tlog; use Thelia\Model\Coupon; use Thelia\Model\CouponQuery; +use Thelia\Model\CurrencyQuery; use Thelia\Model\Lang; +use Thelia\Model\LangQuery; use Thelia\Tools\I18n; /** diff --git a/core/lib/Thelia/Coupon/CouponAdapterInterface.php b/core/lib/Thelia/Coupon/CouponAdapterInterface.php index b2c168186..413fc3df6 100644 --- a/core/lib/Thelia/Coupon/CouponAdapterInterface.php +++ b/core/lib/Thelia/Coupon/CouponAdapterInterface.php @@ -169,4 +169,11 @@ interface CouponAdapterInterface */ public function getConstraintValidator(); + /** + * Return all available currencies + * + * @return array of Currency + */ + public function getAvailableCurrencies(); + } \ No newline at end of file diff --git a/core/lib/Thelia/Coupon/CouponBaseAdapter.php b/core/lib/Thelia/Coupon/CouponBaseAdapter.php index f9fae8651..cb5162090 100644 --- a/core/lib/Thelia/Coupon/CouponBaseAdapter.php +++ b/core/lib/Thelia/Coupon/CouponBaseAdapter.php @@ -35,6 +35,8 @@ use Thelia\Model\Coupon; use Thelia\Model\CouponQuery; use Thelia\Cart\CartTrait; use Thelia\Model\Currency; +use Thelia\Model\CurrencyQuery; +use Thelia\Model\LangQuery; /** * Created by JetBrains PhpStorm. @@ -266,4 +268,17 @@ class CouponBaseAdapter implements CouponAdapterInterface { return $this->container->get('thelia.constraint.validator'); } + + + /** + * Return all available currencies + * + * @return array of Currency + */ + public function getAvailableCurrencies() + { + $currencies = CurrencyQuery::create(); + + return $currencies->find(); + } } diff --git a/core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountManagerTest.php b/core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountManagerTest.php index 4ad790a5b..a883a0712 100644 --- a/core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountManagerTest.php +++ b/core/lib/Thelia/Tests/Constraint/Rule/AvailableForTotalAmountManagerTest.php @@ -27,6 +27,7 @@ use Thelia\Constraint\ConstraintValidator; use Thelia\Constraint\Rule\AvailableForTotalAmountManager; use Thelia\Constraint\Rule\Operators; use Thelia\Exception\InvalidRuleValueException; +use Thelia\Model\Currency; /** * Created by JetBrains PhpStorm. @@ -44,6 +45,43 @@ class AvailableForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase /** @var CouponAdapterInterface $stubTheliaAdapter */ protected $stubTheliaAdapter = null; + /** + * Generate adapter stub + * + * @param int $cartTotalPrice Cart total price + * @param string $checkoutCurrency Checkout currency + * + * @return \PHPUnit_Framework_MockObject_MockObject + */ + public function generateAdapterStub($cartTotalPrice = 400, $checkoutCurrency = 'EUR') + { + $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') + ->disableOriginalConstructor() + ->getMock(); + + $stubAdapter->expects($this->any()) + ->method('getCartTotalPrice') + ->will($this->returnValue($cartTotalPrice)); + + $stubAdapter->expects($this->any()) + ->method('getCheckoutCurrency') + ->will($this->returnValue($checkoutCurrency)); + + $stubAdapter->expects($this->any()) + ->method('getConstraintValidator') + ->will($this->returnValue(new ConstraintValidator())); + + $currency1 = new Currency(); + $currency1->setCode('EUR'); + $currency2 = new Currency(); + $currency2->setCode('USD'); + $stubAdapter->expects($this->any()) + ->method('getAvailableCurrencies') + ->will($this->returnValue(array($currency1, $currency2))); + + return $stubAdapter; + } + /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. @@ -62,19 +100,7 @@ class AvailableForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase */ public function testInValidBackOfficeInputOperator() { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(399)); - $stubAdapter->expects($this->any()) - ->method('getCheckoutCurrency') - ->will($this->returnValue('EUR')); - $stubAdapter->expects($this->any()) - ->method('getConstraintValidator') - ->will($this->returnValue(new ConstraintValidator())); + $stubAdapter = $this->generateAdapterStub(399, 'EUR'); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -102,19 +128,7 @@ class AvailableForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase */ public function testInValidBackOfficeInputOperator2() { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(399)); - $stubAdapter->expects($this->any()) - ->method('getCheckoutCurrency') - ->will($this->returnValue('EUR')); - $stubAdapter->expects($this->any()) - ->method('getConstraintValidator') - ->will($this->returnValue(new ConstraintValidator())); + $stubAdapter = $this->generateAdapterStub(399, 'EUR'); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -142,19 +156,7 @@ class AvailableForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase */ public function testInValidBackOfficeInputValue() { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(399)); - $stubAdapter->expects($this->any()) - ->method('getCheckoutCurrency') - ->will($this->returnValue('EUR')); - $stubAdapter->expects($this->any()) - ->method('getConstraintValidator') - ->will($this->returnValue(new ConstraintValidator())); + $stubAdapter = $this->generateAdapterStub(399, 'EUR'); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -182,19 +184,7 @@ class AvailableForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase */ public function testInValidBackOfficeInputValue2() { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(399)); - $stubAdapter->expects($this->any()) - ->method('getCheckoutCurrency') - ->will($this->returnValue('EUR')); - $stubAdapter->expects($this->any()) - ->method('getConstraintValidator') - ->will($this->returnValue(new ConstraintValidator())); + $stubAdapter = $this->generateAdapterStub(399, 'EUR'); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -221,19 +211,7 @@ class AvailableForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase */ public function testMatchingRuleInferior() { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(399)); - $stubAdapter->expects($this->any()) - ->method('getCheckoutCurrency') - ->will($this->returnValue('EUR')); - $stubAdapter->expects($this->any()) - ->method('getConstraintValidator') - ->will($this->returnValue(new ConstraintValidator())); + $stubAdapter = $this->generateAdapterStub(399, 'EUR'); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -260,19 +238,7 @@ class AvailableForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase */ public function testNotMatchingRuleInferior() { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(400)); - $stubAdapter->expects($this->any()) - ->method('getCheckoutCurrency') - ->will($this->returnValue('EUR')); - $stubAdapter->expects($this->any()) - ->method('getConstraintValidator') - ->will($this->returnValue(new ConstraintValidator())); + $stubAdapter = $this->generateAdapterStub(400, 'EUR'); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -299,19 +265,7 @@ class AvailableForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase */ public function testMatchingRuleInferiorEquals() { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(400)); - $stubAdapter->expects($this->any()) - ->method('getCheckoutCurrency') - ->will($this->returnValue('EUR')); - $stubAdapter->expects($this->any()) - ->method('getConstraintValidator') - ->will($this->returnValue(new ConstraintValidator())); + $stubAdapter = $this->generateAdapterStub(400, 'EUR'); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -338,19 +292,7 @@ class AvailableForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase */ public function testMatchingRuleInferiorEquals2() { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(399)); - $stubAdapter->expects($this->any()) - ->method('getCheckoutCurrency') - ->will($this->returnValue('EUR')); - $stubAdapter->expects($this->any()) - ->method('getConstraintValidator') - ->will($this->returnValue(new ConstraintValidator())); + $stubAdapter = $this->generateAdapterStub(399, 'EUR'); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -377,19 +319,7 @@ class AvailableForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase */ public function testNotMatchingRuleInferiorEquals() { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(401)); - $stubAdapter->expects($this->any()) - ->method('getCheckoutCurrency') - ->will($this->returnValue('EUR')); - $stubAdapter->expects($this->any()) - ->method('getConstraintValidator') - ->will($this->returnValue(new ConstraintValidator())); + $stubAdapter = $this->generateAdapterStub(401, 'EUR'); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -416,19 +346,7 @@ class AvailableForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase */ public function testMatchingRuleEqual() { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(400)); - $stubAdapter->expects($this->any()) - ->method('getCheckoutCurrency') - ->will($this->returnValue('EUR')); - $stubAdapter->expects($this->any()) - ->method('getConstraintValidator') - ->will($this->returnValue(new ConstraintValidator())); + $stubAdapter = $this->generateAdapterStub(400, 'EUR'); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -455,19 +373,7 @@ class AvailableForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase */ public function testNotMatchingRuleEqual() { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(399)); - $stubAdapter->expects($this->any()) - ->method('getCheckoutCurrency') - ->will($this->returnValue('EUR')); - $stubAdapter->expects($this->any()) - ->method('getConstraintValidator') - ->will($this->returnValue(new ConstraintValidator())); + $stubAdapter = $this->generateAdapterStub(399, 'EUR'); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -494,19 +400,7 @@ class AvailableForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase */ public function testMatchingRuleSuperiorEquals() { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(401)); - $stubAdapter->expects($this->any()) - ->method('getCheckoutCurrency') - ->will($this->returnValue('EUR')); - $stubAdapter->expects($this->any()) - ->method('getConstraintValidator') - ->will($this->returnValue(new ConstraintValidator())); + $stubAdapter = $this->generateAdapterStub(401, 'EUR'); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -533,19 +427,7 @@ class AvailableForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase */ public function testMatchingRuleSuperiorEquals2() { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(400)); - $stubAdapter->expects($this->any()) - ->method('getCheckoutCurrency') - ->will($this->returnValue('EUR')); - $stubAdapter->expects($this->any()) - ->method('getConstraintValidator') - ->will($this->returnValue(new ConstraintValidator())); + $stubAdapter = $this->generateAdapterStub(400, 'EUR'); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -572,19 +454,7 @@ class AvailableForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase */ public function testNotMatchingRuleSuperiorEquals() { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(399.00)); - $stubAdapter->expects($this->any()) - ->method('getCheckoutCurrency') - ->will($this->returnValue('EUR')); - $stubAdapter->expects($this->any()) - ->method('getConstraintValidator') - ->will($this->returnValue(new ConstraintValidator())); + $stubAdapter = $this->generateAdapterStub(399, 'EUR'); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -611,19 +481,7 @@ class AvailableForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase */ public function testMatchingRuleSuperior() { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(401)); - $stubAdapter->expects($this->any()) - ->method('getCheckoutCurrency') - ->will($this->returnValue('EUR')); - $stubAdapter->expects($this->any()) - ->method('getConstraintValidator') - ->will($this->returnValue(new ConstraintValidator())); + $stubAdapter = $this->generateAdapterStub(401, 'EUR'); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -650,19 +508,7 @@ class AvailableForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase */ public function testNotMatchingRuleSuperior() { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(399.00)); - $stubAdapter->expects($this->any()) - ->method('getCheckoutCurrency') - ->will($this->returnValue('EUR')); - $stubAdapter->expects($this->any()) - ->method('getConstraintValidator') - ->will($this->returnValue(new ConstraintValidator())); + $stubAdapter = $this->generateAdapterStub(399, 'EUR'); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -689,19 +535,7 @@ class AvailableForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase */ public function testMatchingRuleCurrency() { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(400.00)); - $stubAdapter->expects($this->any()) - ->method('getCheckoutCurrency') - ->will($this->returnValue('EUR')); - $stubAdapter->expects($this->any()) - ->method('getConstraintValidator') - ->will($this->returnValue(new ConstraintValidator())); + $stubAdapter = $this->generateAdapterStub(400, 'EUR'); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( @@ -728,19 +562,7 @@ class AvailableForTotalAmountManagerTest extends \PHPUnit_Framework_TestCase */ public function testNotMatchingRuleCurrency() { - $stubAdapter = $this->getMockBuilder('\Thelia\Coupon\CouponBaseAdapter') - ->disableOriginalConstructor() - ->getMock(); - - $stubAdapter->expects($this->any()) - ->method('getCartTotalPrice') - ->will($this->returnValue(400.00)); - $stubAdapter->expects($this->any()) - ->method('getCheckoutCurrency') - ->will($this->returnValue('EUR')); - $stubAdapter->expects($this->any()) - ->method('getConstraintValidator') - ->will($this->returnValue(new ConstraintValidator())); + $stubAdapter = $this->generateAdapterStub(400.00, 'EUR'); $rule1 = new AvailableForTotalAmountManager($stubAdapter); $operators = array( From 5326ab1341549c1020ff4235abda6e03386d703a Mon Sep 17 00:00:00 2001 From: gmorel Date: Tue, 17 Sep 2013 22:54:49 +0200 Subject: [PATCH 07/98] Working : Coupon : fixture add old coupon --- install/faker.php | 57 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 43 insertions(+), 14 deletions(-) diff --git a/install/faker.php b/install/faker.php index 66303f05a..25112d904 100755 --- a/install/faker.php +++ b/install/faker.php @@ -1,5 +1,6 @@ setIsUsed(1); $coupon1->setIsEnabled(1); $date = new \DateTime(); - $coupon1->setExpirationDate($date->setTimestamp(strtotime("today + 2 months"))); + $coupon1->setExpirationDate($date->setTimestamp(strtotime("today + 3 months"))); $rule1 = new AvailableForTotalAmountManager($adapter); $operators = array( @@ -588,27 +589,18 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $rules = new CouponRuleCollection(); $rules->add($rule1); $rules->add($rule2); - /** @var ConstraintFactory $constraintFactory */ $constraintFactory = $container->get('thelia.constraint.factory'); $serializedRules = $constraintFactory->serializeCouponRuleCollection($rules); $coupon1->setSerializedRules($serializedRules); - $coupon1->setMaxUsage(40); $coupon1->setIsCumulative(1); $coupon1->setIsRemovingPostage(0); $coupon1->setIsAvailableOnSpecialOffers(1); - $coupon1->save(); - - - - - - // Coupons $coupon2 = new Thelia\Model\Coupon(); $coupon2->setCode('SPRINGBREAK'); @@ -628,7 +620,7 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $coupon2->setIsUsed(1); $coupon2->setIsEnabled(1); $date = new \DateTime(); - $coupon2->setExpirationDate($date->setTimestamp(strtotime("today + 2 months"))); + $coupon2->setExpirationDate($date->setTimestamp(strtotime("today + 1 months"))); $rule1 = new AvailableForXArticlesManager($adapter); $operators = array( @@ -638,7 +630,6 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua AvailableForXArticlesManager::INPUT1 => 4, ); $rule1->setValidatorsFromForm($operators, $values); - $rules = new CouponRuleCollection(); $rules->add($rule1); @@ -647,11 +638,49 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $serializedRules = $constraintFactory->serializeCouponRuleCollection($rules); $coupon2->setSerializedRules($serializedRules); - $coupon2->setMaxUsage(-1); $coupon2->setIsCumulative(0); $coupon2->setIsRemovingPostage(1); $coupon2->setIsAvailableOnSpecialOffers(1); - $coupon2->save(); + + + // Coupons + $coupon3 = new Thelia\Model\Coupon(); + $coupon3->setCode('OLD'); + $coupon3->setType('thelia.coupon.type.remove_x_percent'); + $coupon3->setTitle('Old coupon'); + $coupon3->setShortDescription('Coupon for Springbreak removing 10% if you have more than 4 articles in your cart'); + $coupon3->setDescription('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras at luctus tellus. Integer turpis mauris, aliquet vitae risus tristique, pellentesque vestibulum urna. Vestibulum sodales laoreet lectus dictum suscipit. Praesent vulputate, sem id varius condimentum, quam magna tempor elit, quis venenatis ligula nulla eget libero. Cras egestas euismod tellus, id pharetra leo suscipit quis. Donec lacinia ac lacus et ultricies. Nunc in porttitor neque. Proin at quam congue, consectetur orci sed, congue nulla. Nulla eleifend nunc ligula, nec pharetra elit tempus quis. Vivamus vel mauris sed est dictum blandit. Maecenas blandit dapibus velit ut sollicitudin. In in euismod mauris, consequat viverra magna. Cras velit velit, sollicitudin commodo tortor gravida, tempus varius nulla. + +Donec rhoncus leo mauris, id porttitor ante luctus tempus. Curabitur quis augue feugiat, ullamcorper mauris ac, interdum mi. Quisque aliquam lorem vitae felis lobortis, id interdum turpis mattis. Vestibulum diam massa, ornare congue blandit quis, facilisis at nisl. In tortor metus, venenatis non arcu nec, sollicitudin ornare nisl. Nunc erat risus, varius nec urna at, iaculis lacinia elit. Aenean ut felis tempus, tincidunt odio non, sagittis nisl. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec vitae hendrerit elit. Nunc sit amet gravida risus, euismod lobortis massa. Nam a erat mauris. Nam a malesuada lorem. Nulla id accumsan dolor, sed rhoncus tellus. Quisque dictum felis sed leo auctor, at volutpat lectus viverra. Morbi rutrum, est ac aliquam imperdiet, nibh sem sagittis justo, ac mattis magna lacus eu nulla. + +Duis interdum lectus nulla, nec pellentesque sapien condimentum at. Suspendisse potenti. Sed eu purus tellus. Nunc quis rhoncus metus. Fusce vitae tellus enim. Interdum et malesuada fames ac ante ipsum primis in faucibus. Etiam tempor porttitor erat vitae iaculis. Sed est elit, consequat non ornare vitae, vehicula eget lectus. Etiam consequat sapien mauris, eget consectetur magna imperdiet eget. Nunc sollicitudin luctus velit, in commodo nulla adipiscing fermentum. Fusce nisi sapien, posuere vitae metus sit amet, facilisis sollicitudin dui. Fusce ultricies auctor enim sit amet iaculis. Morbi at vestibulum enim, eget adipiscing eros. + +Praesent ligula lorem, faucibus ut metus quis, fermentum iaculis erat. Pellentesque elit erat, lacinia sed semper ac, sagittis vel elit. Nam eu convallis est. Curabitur rhoncus odio vitae consectetur pellentesque. Nam vitae arcu nec ante scelerisque dignissim vel nec neque. Suspendisse augue nulla, mollis eget dui et, tempor facilisis erat. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi ac diam ipsum. Donec convallis dui ultricies velit auctor, non lobortis nulla ultrices. Morbi vitae dignissim ante, sit amet lobortis tortor. Nunc dapibus condimentum augue, in molestie neque congue non. + +Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesuada tortor vel erat volutpat tincidunt. In vehicula diam est, a convallis eros scelerisque ut. Donec aliquet venenatis iaculis. Ut a arcu gravida, placerat dui eu, iaculis nisl. Quisque adipiscing orci sit amet dui dignissim lacinia. Sed vulputate lorem non dolor adipiscing ornare. Morbi ornare id nisl id aliquam. Ut fringilla elit ante, nec lacinia enim fermentum sit amet. Aenean rutrum lorem eu convallis pharetra. Cras malesuada varius metus, vitae gravida velit. Nam a varius ipsum, ac commodo dolor. Phasellus nec elementum elit. Etiam vel adipiscing leo.'); + $coupon3->setAmount(10.00); + $coupon3->setIsUsed(1); + $coupon3->setIsEnabled(0); + $date = new \DateTime(); + $coupon3->setExpirationDate($date->setTimestamp(strtotime("today + 2 months"))); + + $rule1 = new AvailableForEveryoneManager($adapter); + $operators = array(); + $values = array(); + $rule1->setValidatorsFromForm($operators, $values); + $rules = new CouponRuleCollection(); + $rules->add($rule1); + + /** @var ConstraintFactory $constraintFactory */ + $constraintFactory = $container->get('thelia.constraint.factory'); + + $serializedRules = $constraintFactory->serializeCouponRuleCollection($rules); + $coupon3->setSerializedRules($serializedRules); + $coupon3->setMaxUsage(-1); + $coupon3->setIsCumulative(0); + $coupon3->setIsRemovingPostage(1); + $coupon3->setIsAvailableOnSpecialOffers(1); + $coupon3->save(); } From ce72a2007476b368f900cd18e986890d6426f453 Mon Sep 17 00:00:00 2001 From: gmorel Date: Tue, 17 Sep 2013 23:09:55 +0200 Subject: [PATCH 08/98] Working : Coupon : fix loop --- core/lib/Thelia/Core/Template/Loop/Coupon.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/lib/Thelia/Core/Template/Loop/Coupon.php b/core/lib/Thelia/Core/Template/Loop/Coupon.php index 4e8ca3e71..dff5e782b 100755 --- a/core/lib/Thelia/Core/Template/Loop/Coupon.php +++ b/core/lib/Thelia/Core/Template/Loop/Coupon.php @@ -88,8 +88,8 @@ class Coupon extends BaseI18nLoop $search->filterById($id, Criteria::IN); } - if ($isEnabled != BooleanOrBothType::ANY) { - $search->filterByIsEnabled($isEnabled ? 1 : 0); + if (isset($isEnabled)) { + $search->filterByIsEnabled($isEnabled ? true : false); } // Perform search From 542a1423298431263c72d3d0f6a835b13971c247 Mon Sep 17 00:00:00 2001 From: gmorel Date: Tue, 17 Sep 2013 23:19:09 +0200 Subject: [PATCH 09/98] Working : Coupon : fix loop, fix read display --- core/lib/Thelia/Core/Template/Loop/Coupon.php | 2 +- install/faker.php | 8 ++++---- templates/admin/default/coupon-read.html | 6 +++++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/core/lib/Thelia/Core/Template/Loop/Coupon.php b/core/lib/Thelia/Core/Template/Loop/Coupon.php index dff5e782b..063ffa397 100755 --- a/core/lib/Thelia/Core/Template/Loop/Coupon.php +++ b/core/lib/Thelia/Core/Template/Loop/Coupon.php @@ -63,7 +63,7 @@ class Coupon extends BaseI18nLoop { return new ArgumentCollection( Argument::createIntListTypeArgument('id'), - Argument::createBooleanOrBothTypeArgument('is_enabled', 1) + Argument::createBooleanOrBothTypeArgument('is_enabled') ); } diff --git a/install/faker.php b/install/faker.php index 94c507d02..9a1d3d480 100755 --- a/install/faker.php +++ b/install/faker.php @@ -742,7 +742,7 @@ Praesent ligula lorem, faucibus ut metus quis, fermentum iaculis erat. Pellentes Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesuada tortor vel erat volutpat tincidunt. In vehicula diam est, a convallis eros scelerisque ut. Donec aliquet venenatis iaculis. Ut a arcu gravida, placerat dui eu, iaculis nisl. Quisque adipiscing orci sit amet dui dignissim lacinia. Sed vulputate lorem non dolor adipiscing ornare. Morbi ornare id nisl id aliquam. Ut fringilla elit ante, nec lacinia enim fermentum sit amet. Aenean rutrum lorem eu convallis pharetra. Cras malesuada varius metus, vitae gravida velit. Nam a varius ipsum, ac commodo dolor. Phasellus nec elementum elit. Etiam vel adipiscing leo.'); $coupon3->setAmount(10.00); - $coupon3->setIsUsed(1); + $coupon3->setIsUsed(0); $coupon3->setIsEnabled(0); $date = new \DateTime(); $coupon3->setExpirationDate($date->setTimestamp(strtotime("today + 2 months"))); @@ -760,8 +760,8 @@ Sed facilisis pellentesque nisl, eu tincidunt erat scelerisque a. Nullam malesua $serializedRules = $constraintFactory->serializeCouponRuleCollection($rules); $coupon3->setSerializedRules($serializedRules); $coupon3->setMaxUsage(-1); - $coupon3->setIsCumulative(0); - $coupon3->setIsRemovingPostage(1); - $coupon3->setIsAvailableOnSpecialOffers(1); + $coupon3->setIsCumulative(1); + $coupon3->setIsRemovingPostage(0); + $coupon3->setIsAvailableOnSpecialOffers(0); $coupon3->save(); } diff --git a/templates/admin/default/coupon-read.html b/templates/admin/default/coupon-read.html index 4ae5e5c68..859163fc8 100755 --- a/templates/admin/default/coupon-read.html +++ b/templates/admin/default/coupon-read.html @@ -63,7 +63,11 @@ {intl l='Usage left'} - {if $USAGE_LEFT} + {if $USAGE_LEFT == -1} + + {intl l='Unlimited'} + + {elseif $USAGE_LEFT} {$USAGE_LEFT} From be665cba56d7ed3da0caf3d8d65e1ffea79625ef Mon Sep 17 00:00:00 2001 From: gmorel Date: Tue, 17 Sep 2013 23:25:38 +0200 Subject: [PATCH 10/98] Working : Coupon : fix loop, fix read display --- templates/admin/default/coupon-list.html | 36 ++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/templates/admin/default/coupon-list.html b/templates/admin/default/coupon-list.html index 2eafde586..a17d01e96 100755 --- a/templates/admin/default/coupon-list.html +++ b/templates/admin/default/coupon-list.html @@ -41,7 +41,23 @@ {block name="coupon-code"}{$CODE}{/block} {block name="coupon-title"}{$TITLE}{/block} {block name="coupon-expiration-date"}{$EXPIRATION_DATE}{/block} - {block name="coupon-usage-left"}{$USAGE_LEFT}{/block} + + {block name="coupon-usage-left"} + {if $USAGE_LEFT == -1} + + {intl l='Unlimited'} + + {elseif $USAGE_LEFT} + + {$USAGE_LEFT} + + {else} + + 0 + + {/if} + {/block} + {block name="coupon-action"} @@ -77,7 +93,23 @@ {block name="coupon-code"}{$CODE}{/block} {block name="coupon-title"}{$TITLE}{/block} {block name="coupon-expiration-date"}{$EXPIRATION_DATE}{/block} - {block name="coupon-usage-left"}{$USAGE_LEFT}{/block} + + {block name="coupon-usage-left"} + {if $USAGE_LEFT == -1} + + {intl l='Unlimited'} + + {elseif $USAGE_LEFT} + + {$USAGE_LEFT} + + {else} + + 0 + + {/if} + {/block} + {block name="coupon-action"} From b545e1c012f1d3ef609612021b34c812ca5d36a3 Mon Sep 17 00:00:00 2001 From: gmorel Date: Tue, 17 Sep 2013 23:29:25 +0200 Subject: [PATCH 11/98] Working : Coupon : fix loop, fix read display --- core/lib/Thelia/Core/Template/Loop/Coupon.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/core/lib/Thelia/Core/Template/Loop/Coupon.php b/core/lib/Thelia/Core/Template/Loop/Coupon.php index 063ffa397..9b720ef13 100755 --- a/core/lib/Thelia/Core/Template/Loop/Coupon.php +++ b/core/lib/Thelia/Core/Template/Loop/Coupon.php @@ -31,13 +31,11 @@ use Thelia\Core\HttpFoundation\Request; use Thelia\Core\Template\Element\BaseI18nLoop; use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResultRow; - -use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; - +use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Coupon\Type\CouponInterface; -use Thelia\Model\CouponQuery; use Thelia\Model\Coupon as MCoupon; +use Thelia\Model\CouponQuery; use Thelia\Type; use Thelia\Type\BooleanOrBothType; From 8e308d21e99dc44a247213c74b69400400125d4c Mon Sep 17 00:00:00 2001 From: gmorel Date: Thu, 19 Sep 2013 23:25:01 +0200 Subject: [PATCH 12/98] Working : Coupon : fix update effect (becomes type), update max usage --- .../Thelia/Config/Resources/routing/admin.xml | 19 ++++++++++++------- .../Controller/Admin/CouponController.php | 7 ++++--- .../Coupon/CouponCreateOrUpdateEvent.php | 12 ++++++------ core/lib/Thelia/Form/CouponCreationForm.php | 2 +- core/lib/Thelia/Model/Coupon.php | 6 +++--- .../Thelia/Tests/Coupon/RuleOrganizerTest.php | 3 ++- templates/admin/default/assets/js/coupon.js | 17 ++++++++++++----- templates/admin/default/coupon/form.html | 18 ++++++++++-------- 8 files changed, 50 insertions(+), 34 deletions(-) diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index af7c950af..15e450c01 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -160,26 +160,31 @@ - + Thelia\Controller\Admin\CouponController::browseAction - + Thelia\Controller\Admin\CouponController::createAction - + Thelia\Controller\Admin\CouponController::updateAction + \d+ - + Thelia\Controller\Admin\CouponController::readAction + \d+ - + Thelia\Controller\Admin\CouponController::getRuleInputAction + .* - + Thelia\Controller\Admin\CouponController::updateRulesAction + \d+ - + Thelia\Controller\Admin\CouponController::consumeAction + .* diff --git a/core/lib/Thelia/Controller/Admin/CouponController.php b/core/lib/Thelia/Controller/Admin/CouponController.php index f50c58307..f7804de8e 100755 --- a/core/lib/Thelia/Controller/Admin/CouponController.php +++ b/core/lib/Thelia/Controller/Admin/CouponController.php @@ -201,7 +201,7 @@ class CouponController extends BaseAdminController $lang = $this->getSession()->getLang(); $eventToDispatch = TheliaEvents::COUPON_UPDATE; - // Create + // Update if ($this->getRequest()->isMethod('POST')) { $this->validateCreateOrUpdateForm( $i18n, @@ -210,7 +210,7 @@ class CouponController extends BaseAdminController 'updated', 'update' ); - } else { // Update + } else { // Display // Prepare the data that will hydrate the form /** @var ConstraintFactory $constraintFactory */ @@ -495,11 +495,12 @@ class CouponController extends BaseAdminController // Get the form field values $data = $form->getData(); + $couponEvent = new CouponCreateOrUpdateEvent( $data['code'], $data['title'], $data['amount'], - $data['effect'], + $data['type'], $data['shortDescription'], $data['description'], $data['isEnabled'], diff --git a/core/lib/Thelia/Core/Event/Coupon/CouponCreateOrUpdateEvent.php b/core/lib/Thelia/Core/Event/Coupon/CouponCreateOrUpdateEvent.php index 2e004b818..e8f54fffb 100644 --- a/core/lib/Thelia/Core/Event/Coupon/CouponCreateOrUpdateEvent.php +++ b/core/lib/Thelia/Core/Event/Coupon/CouponCreateOrUpdateEvent.php @@ -90,7 +90,7 @@ class CouponCreateOrUpdateEvent extends ActionEvent * @param string $code Coupon Code * @param string $title Coupon title * @param float $amount Amount removed from the Total Checkout - * @param string $effect Coupon effect + * @param string $type Coupon type * @param string $shortDescription Coupon short description * @param string $description Coupon description * @param boolean $isEnabled Enable/Disable @@ -106,7 +106,7 @@ class CouponCreateOrUpdateEvent extends ActionEvent $code, $title, $amount, - $effect, + $type, $shortDescription, $description, $isEnabled, @@ -130,7 +130,7 @@ class CouponCreateOrUpdateEvent extends ActionEvent $this->rules = $rules; $this->shortDescription = $shortDescription; $this->title = $title; - $this->effect = $effect; + $this->type = $type; $this->locale = $locale; } @@ -264,13 +264,13 @@ class CouponCreateOrUpdateEvent extends ActionEvent } /** - * Get Coupon effect + * Get Coupon type (effect) * * @return string */ - public function getEffect() + public function getType() { - return $this->effect; + return $this->type; } /** diff --git a/core/lib/Thelia/Form/CouponCreationForm.php b/core/lib/Thelia/Form/CouponCreationForm.php index 1625ab685..f3ee0df63 100755 --- a/core/lib/Thelia/Form/CouponCreationForm.php +++ b/core/lib/Thelia/Form/CouponCreationForm.php @@ -87,7 +87,7 @@ class CouponCreationForm extends BaseForm ) ) ->add( - 'effect', + 'type', 'text', array( 'constraints' => array( diff --git a/core/lib/Thelia/Model/Coupon.php b/core/lib/Thelia/Model/Coupon.php index 032de412a..e40fd9078 100755 --- a/core/lib/Thelia/Model/Coupon.php +++ b/core/lib/Thelia/Model/Coupon.php @@ -54,7 +54,7 @@ class Coupon extends BaseCoupon * @param string $code Coupon Code * @param string $title Coupon title * @param float $amount Amount removed from the Total Checkout - * @param string $effect Coupon effect + * @param string $type Coupon type * @param bool $isRemovingPostage Is removing Postage * @param string $shortDescription Coupon short description * @param string $description Coupon description @@ -67,13 +67,13 @@ class Coupon extends BaseCoupon * * @throws \Exception */ - function createOrUpdate($code, $title, $amount, $effect, $isRemovingPostage, $shortDescription, $description, $isEnabled, $expirationDate, $isAvailableOnSpecialOffers, $isCumulative, $maxUsage, $locale = null) + function createOrUpdate($code, $title, $amount, $type, $isRemovingPostage, $shortDescription, $description, $isEnabled, $expirationDate, $isAvailableOnSpecialOffers, $isCumulative, $maxUsage, $locale = null) { $this->setCode($code) ->setTitle($title) ->setShortDescription($shortDescription) ->setDescription($description) - ->setType($effect) + ->setType($type) ->setAmount($amount) ->setIsRemovingPostage($isRemovingPostage) ->setIsEnabled($isEnabled) diff --git a/core/lib/Thelia/Tests/Coupon/RuleOrganizerTest.php b/core/lib/Thelia/Tests/Coupon/RuleOrganizerTest.php index 3300cb19b..d13184a8c 100644 --- a/core/lib/Thelia/Tests/Coupon/RuleOrganizerTest.php +++ b/core/lib/Thelia/Tests/Coupon/RuleOrganizerTest.php @@ -23,6 +23,7 @@ namespace Thelia\Coupon; +use Thelia\Coupon\RuleOrganizer; /** * Created by JetBrains PhpStorm. * Date: 8/19/13 @@ -47,7 +48,7 @@ class RuleOrganizerTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { - $this->object = new RuleOrganizer; + $this->object = new RuleOrganizer(); } /** diff --git a/templates/admin/default/assets/js/coupon.js b/templates/admin/default/assets/js/coupon.js index 41e0c1430..dae26d4b4 100644 --- a/templates/admin/default/assets/js/coupon.js +++ b/templates/admin/default/assets/js/coupon.js @@ -138,17 +138,24 @@ $(function($){ // Set max usage to unlimited or not couponManager.onUsageUnlimitedChange = function() { - if (!$('#max-usage').parent().hasClass('has-error')) { - $('#max-usage').hide().attr('value', '-1'); + var isUnlimited = $('#is-unlimited'); + if ($('#max-usage').val() == -1) { + isUnlimited.prop('checked', true); + $('#max-usage').hide(); $('#max-usage-label').hide(); + } else { + $isUnlimited.prop('checked', false); + $('#max-usage').show(); + $('#max-usage-label').show(); } - $('#is-unlimited').change(function(){ + + isUnlimited.change(function(){ var $this = $(this); if ($this.is(':checked')) { - $('#max-usage').hide().attr('value', '-1'); + $('#max-usage').hide().val('-1'); $('#max-usage-label').hide(); } else { - $('#max-usage').show().val('').attr('value', ''); + $('#max-usage').show().val(''); $('#max-usage-label').show(); } }); diff --git a/templates/admin/default/coupon/form.html b/templates/admin/default/coupon/form.html index a4ec8b14a..68c74bee2 100644 --- a/templates/admin/default/coupon/form.html +++ b/templates/admin/default/coupon/form.html @@ -88,11 +88,11 @@
- + {if $error}{$message}{/if}
{/form_field} @@ -101,17 +101,19 @@
- {form_field form=$form field='effect'} + {form_field form=$form field='type'}
- - + {foreach from=$availableCoupons item=availableCoupon} - + {/foreach} {if $error}{$message}{/if} - {$availableCoupons.0.toolTip} + {$availableCoupons.0.toolTip}
{/form_field}
From d0f20cca1d5b3d9a4e49a86a7df0145d39cceaa9 Mon Sep 17 00:00:00 2001 From: gmorel Date: Mon, 23 Sep 2013 23:04:00 +0200 Subject: [PATCH 13/98] Working : coupon creation : add default rule (thelia.constraint.rule.available_for_everyone) --- core/lib/Thelia/Action/Coupon.php | 16 ++- core/lib/Thelia/Action/Image.php | 2 +- .../Controller/Admin/CouponController.php | 41 ++------ .../Coupon/CouponCreateOrUpdateEvent.php | 63 +++--------- core/lib/Thelia/Model/Coupon.php | 8 +- templates/admin/default/admin-layout.tpl | 2 +- templates/admin/default/assets/js/coupon.js | 99 ++++++++++--------- templates/admin/default/coupon-create.html | 2 +- templates/admin/default/coupon-list.html | 42 +++++++- templates/admin/default/coupon-read.html | 8 +- templates/admin/default/coupon-update.html | 18 ++-- templates/admin/default/coupon/form.html | 9 +- 12 files changed, 154 insertions(+), 156 deletions(-) diff --git a/core/lib/Thelia/Action/Coupon.php b/core/lib/Thelia/Action/Coupon.php index 036502c68..c1affe633 100755 --- a/core/lib/Thelia/Action/Coupon.php +++ b/core/lib/Thelia/Action/Coupon.php @@ -32,6 +32,7 @@ use Thelia\Core\Event\TheliaEvents; use Thelia\Core\HttpFoundation\Request; use Thelia\Coupon\CouponFactory; use Thelia\Coupon\CouponManager; +use Thelia\Coupon\CouponRuleCollection; use Thelia\Coupon\Type\CouponInterface; use Thelia\Model\Coupon as CouponModel; @@ -137,11 +138,21 @@ class Coupon extends BaseAction implements EventSubscriberInterface { $coupon->setDispatcher($this->getDispatcher()); + // Set default rule if none found + $noConditionRule = $this->container->get('thelia.constraint.rule.available_for_everyone'); + $constraintFactory = $this->container->get('thelia.constraint.factory'); + $couponRuleCollection = new CouponRuleCollection(); + $couponRuleCollection->add($noConditionRule); + $defaultSerializedRule = $constraintFactory->serializeCouponRuleCollection( + $couponRuleCollection + ); + + $coupon->createOrUpdate( $event->getCode(), $event->getTitle(), $event->getAmount(), - $event->getEffect(), + $event->getType(), $event->isRemovingPostage(), $event->getShortDescription(), $event->getDescription(), @@ -150,9 +161,12 @@ class Coupon extends BaseAction implements EventSubscriberInterface $event->isAvailableOnSpecialOffers(), $event->isCumulative(), $event->getMaxUsage(), + $defaultSerializedRule, $event->getLocale() ); + + $event->setCoupon($coupon); } diff --git a/core/lib/Thelia/Action/Image.php b/core/lib/Thelia/Action/Image.php index 4660f93b8..ba5ee153f 100755 --- a/core/lib/Thelia/Action/Image.php +++ b/core/lib/Thelia/Action/Image.php @@ -229,7 +229,7 @@ class Image extends BaseCachedFile implements EventSubscriberInterface // Compute the image URL $processed_image_url = $this->getCacheFileURL($subdir, basename($cacheFilePath)); - // compute the full resulution image path in cache + // compute the full resolution image path in cache $original_image_url = $this->getCacheFileURL($subdir, basename($originalImagePathInCache)); // Update the event with file path and file URL diff --git a/core/lib/Thelia/Controller/Admin/CouponController.php b/core/lib/Thelia/Controller/Admin/CouponController.php index f7804de8e..1c7b1c603 100755 --- a/core/lib/Thelia/Controller/Admin/CouponController.php +++ b/core/lib/Thelia/Controller/Admin/CouponController.php @@ -78,13 +78,13 @@ class CouponController extends BaseAdminController $args['urlReadCoupon'] = $this->getRoute( 'admin.coupon.read', - array('couponId' => 'couponId'), + array('couponId' => 0), Router::ABSOLUTE_URL ); $args['urlEditCoupon'] = $this->getRoute( 'admin.coupon.update', - array('couponId' => 'couponId'), + array('couponId' => 0), Router::ABSOLUTE_URL ); @@ -164,7 +164,7 @@ class CouponController extends BaseAdminController $args['dateFormat'] = $this->getSession()->getLang()->getDateFormat(); $args['availableCoupons'] = $this->getAvailableCoupons(); - $args['formAction'] = 'admin/coupon/create/'; + $args['formAction'] = 'admin/coupon/create'; return $this->render( 'coupon-create', @@ -223,7 +223,7 @@ class CouponController extends BaseAdminController 'code' => $coupon->getCode(), 'title' => $coupon->getTitle(), 'amount' => $coupon->getAmount(), - 'effect' => $coupon->getType(), + 'type' => $coupon->getType(), 'shortDescription' => $coupon->getShortDescription(), 'description' => $coupon->getDescription(), 'isEnabled' => ($coupon->getIsEnabled() == 1), @@ -271,7 +271,7 @@ class CouponController extends BaseAdminController Router::ABSOLUTE_URL ); - $args['formAction'] = 'admin/coupon/update/' . $couponId; + $args['formAction'] = 'admin/coupon/update' . $couponId; return $this->render('coupon-update', $args); } @@ -347,20 +347,7 @@ class CouponController extends BaseAdminController ); $couponEvent = new CouponCreateOrUpdateEvent( - $coupon->getCode(), - $coupon->getTitle(), - $coupon->getAmount(), - $coupon->getType(), - $coupon->getShortDescription(), - $coupon->getDescription(), - $coupon->getIsEnabled(), - $coupon->getExpirationDate(), - $coupon->getIsAvailableOnSpecialOffers(), - $coupon->getIsCumulative(), - $coupon->getIsRemovingPostage(), - $coupon->getMaxUsage(), - $rules, - $coupon->getLocale() + $coupon->getCode(), $coupon->getTitle(), $coupon->getAmount(), $coupon->getType(), $coupon->getShortDescription(), $coupon->getDescription(), $coupon->getIsEnabled(), $coupon->getExpirationDate(), $coupon->getIsAvailableOnSpecialOffers(), $coupon->getIsCumulative(), $coupon->getIsRemovingPostage(), $coupon->getMaxUsage(), $coupon->getLocale() ); $couponEvent->setCoupon($coupon); @@ -497,20 +484,7 @@ class CouponController extends BaseAdminController $data = $form->getData(); $couponEvent = new CouponCreateOrUpdateEvent( - $data['code'], - $data['title'], - $data['amount'], - $data['type'], - $data['shortDescription'], - $data['description'], - $data['isEnabled'], - \DateTime::createFromFormat('Y-m-d', $data['expirationDate']), - $data['isAvailableOnSpecialOffers'], - $data['isCumulative'], - $data['isRemovingPostage'], - $data['maxUsage'], - new CouponRuleCollection(array()), - $data['locale'] + $data['code'], $data['title'], $data['amount'], $data['type'], $data['shortDescription'], $data['description'], $data['isEnabled'], \DateTime::createFromFormat('Y-m-d', $data['expirationDate']), $data['isAvailableOnSpecialOffers'], $data['isCumulative'], $data['isRemovingPostage'], $data['maxUsage'], $data['locale'] ); // Dispatch Event to the Action @@ -538,7 +512,6 @@ class CouponController extends BaseAdminController } catch (FormValidationException $e) { // Invalid data entered $message = 'Please check your input:'; - $this->logError($action, $message, $e); } catch (\Exception $e) { // Any other error diff --git a/core/lib/Thelia/Core/Event/Coupon/CouponCreateOrUpdateEvent.php b/core/lib/Thelia/Core/Event/Coupon/CouponCreateOrUpdateEvent.php index e8f54fffb..4b85065dc 100644 --- a/core/lib/Thelia/Core/Event/Coupon/CouponCreateOrUpdateEvent.php +++ b/core/lib/Thelia/Core/Event/Coupon/CouponCreateOrUpdateEvent.php @@ -78,8 +78,8 @@ class CouponCreateOrUpdateEvent extends ActionEvent /** @var Coupon Coupon model */ protected $coupon = null; - /** @var string Coupon effect */ - protected $effect; + /** @var string Coupon type */ + protected $type; /** @var string Language code ISO (ex: fr_FR) */ protected $locale = null; @@ -87,36 +87,22 @@ class CouponCreateOrUpdateEvent extends ActionEvent /** * Constructor * - * @param string $code Coupon Code - * @param string $title Coupon title - * @param float $amount Amount removed from the Total Checkout - * @param string $type Coupon type - * @param string $shortDescription Coupon short description - * @param string $description Coupon description - * @param boolean $isEnabled Enable/Disable - * @param \DateTime $expirationDate Coupon expiration date - * @param boolean $isAvailableOnSpecialOffers Is available on special offers - * @param boolean $isCumulative Is cumulative - * @param boolean $isRemovingPostage Is removing Postage - * @param int $maxUsage Coupon quantity - * @param CouponRuleCollection $rules CouponRuleInterface to add - * @param string $locale Coupon Language code ISO (ex: fr_FR) + * @param string $code Coupon Code + * @param string $title Coupon title + * @param float $amount Amount removed from the Total Checkout + * @param string $type Coupon type + * @param string $shortDescription Coupon short description + * @param string $description Coupon description + * @param boolean $isEnabled Enable/Disable + * @param \DateTime $expirationDate Coupon expiration date + * @param boolean $isAvailableOnSpecialOffers Is available on special offers + * @param boolean $isCumulative Is cumulative + * @param boolean $isRemovingPostage Is removing Postage + * @param int $maxUsage Coupon quantity + * @param string $locale Coupon Language code ISO (ex: fr_FR) */ public function __construct( - $code, - $title, - $amount, - $type, - $shortDescription, - $description, - $isEnabled, - \DateTime $expirationDate, - $isAvailableOnSpecialOffers, - $isCumulative, - $isRemovingPostage, - $maxUsage, - $rules, - $locale + $code, $title, $amount, $type, $shortDescription, $description, $isEnabled, \DateTime $expirationDate, $isAvailableOnSpecialOffers, $isCumulative, $isRemovingPostage, $maxUsage, $locale ) { $this->amount = $amount; $this->code = $code; @@ -127,7 +113,6 @@ class CouponCreateOrUpdateEvent extends ActionEvent $this->isEnabled = $isEnabled; $this->isRemovingPostage = $isRemovingPostage; $this->maxUsage = $maxUsage; - $this->rules = $rules; $this->shortDescription = $shortDescription; $this->title = $title; $this->type = $type; @@ -206,22 +191,6 @@ class CouponCreateOrUpdateEvent extends ActionEvent return $this->amount; } - /** - * Return condition to validate the Coupon or not - * - * @return CouponRuleCollection - */ - public function getRules() - { - if ($this->rules === null || !is_object($this->rules)) { - $rules = $this->rules; - } else { - $rules = clone $this->rules; - } - - return $rules; - } - /** * Return Coupon expiration date * diff --git a/core/lib/Thelia/Model/Coupon.php b/core/lib/Thelia/Model/Coupon.php index e40fd9078..d25c48354 100755 --- a/core/lib/Thelia/Model/Coupon.php +++ b/core/lib/Thelia/Model/Coupon.php @@ -63,11 +63,12 @@ class Coupon extends BaseCoupon * @param boolean $isAvailableOnSpecialOffers Is available on special offers * @param boolean $isCumulative Is cumulative * @param int $maxUsage Coupon quantity + * @param string $defaultSerializedRule Serialized default rule added if none found * @param string $locale Coupon Language code ISO (ex: fr_FR) * * @throws \Exception */ - function createOrUpdate($code, $title, $amount, $type, $isRemovingPostage, $shortDescription, $description, $isEnabled, $expirationDate, $isAvailableOnSpecialOffers, $isCumulative, $maxUsage, $locale = null) + function createOrUpdate($code, $title, $amount, $type, $isRemovingPostage, $shortDescription, $description, $isEnabled, $expirationDate, $isAvailableOnSpecialOffers, $isCumulative, $maxUsage, $defaultSerializedRule, $locale = null) { $this->setCode($code) ->setTitle($title) @@ -82,6 +83,11 @@ class Coupon extends BaseCoupon ->setIsCumulative($isCumulative) ->setMaxUsage($maxUsage); + // If no rule given, set default rule + if (null === $this->getSerializedRules()) { + $this->setSerializedRules($defaultSerializedRule); + } + // Set object language (i18n) if (!is_null($locale)) { $this->setLocale($locale); diff --git a/templates/admin/default/admin-layout.tpl b/templates/admin/default/admin-layout.tpl index 553466def..2dbf87a46 100644 --- a/templates/admin/default/admin-layout.tpl +++ b/templates/admin/default/admin-layout.tpl @@ -147,7 +147,7 @@ {loop name="menu-auth-coupon" type="auth" roles="ADMIN" permissions="admin.coupon.view"}
  • - {intl l="Coupons"} + {intl l="Coupons"}
  • {/loop} diff --git a/templates/admin/default/assets/js/coupon.js b/templates/admin/default/assets/js/coupon.js index dae26d4b4..089db5ef2 100644 --- a/templates/admin/default/assets/js/coupon.js +++ b/templates/admin/default/assets/js/coupon.js @@ -1,5 +1,17 @@ $(function($){ + // Manage how coupon and rules are saved + $.couponManager = {}; + // Rule to be saved + $.couponManager.ruleToSave = {}; + $.couponManager.ruleToSave.serviceId = false; + $.couponManager.ruleToSave.operators = {}; + $.couponManager.ruleToSave.values = {}; + // Rules payload to save + $.couponManager.rulesToSave = []; + // Rule being updated id + $.couponManager.ruleToUpdateId = false; + // Clean array from deleteValue (undefined) keys Array.prototype.clean = function(deleteValue) { for (var i = 0; i < this.length; i++) { @@ -12,109 +24,109 @@ $(function($){ }; // Remove 1 Rule then Save Rules AJAX - couponManager.removeRuleAjax = function(id) { + $.couponManager.removeRuleAjax = function(id) { // Delete rule in temporary array - delete couponManager.rulesToSave[id]; - couponManager.rulesToSave.clean(undefined); + delete $.couponManager.rulesToSave[id]; + $.couponManager.rulesToSave.clean(undefined); // Save - couponManager.saveRuleAjax(); + $.couponManager.saveRuleAjax(); }; // Add 1 Rule / or update the temporary Rules array then Save Rules via AJAX - couponManager.createOrUpdateRuleAjax = function() { - var id = couponManager.ruleToUpdateId; + $.couponManager.createOrUpdateRuleAjax = function() { + var id = $.couponManager.ruleToUpdateId; // If create if(!id) { - couponManager.rulesToSave.push(couponManager.ruleToSave); + $.couponManager.rulesToSave.push($.couponManager.ruleToSave); } else { // else update - couponManager.rulesToSave[id] = couponManager.ruleToSave; + $.couponManager.rulesToSave[id] = $.couponManager.ruleToSave; // reset edit mode to off - couponManager.ruleToUpdateId = false; + $.couponManager.ruleToUpdateId = false; } // Save - couponManager.saveRuleAjax(); + $.couponManager.saveRuleAjax(); }; // Set rule inputs to allow editing - couponManager.updateRuleSelectAjax = function(id) { - couponManager.ruleToUpdateId = id; - couponManager.ruleToSave = couponManager.rulesToSave[id]; + $.couponManager.updateRuleSelectAjax = function(id) { + $.couponManager.ruleToUpdateId = id; + $.couponManager.ruleToSave = $.couponManager.rulesToSave[id]; // Set the rule selector $("#category-rule option").filter(function() { - return $(this).val() == couponManager.ruleToSave.serviceId; + return $(this).val() == $.couponManager.ruleToSave.serviceId; }).prop('selected', true); // Force rule input refresh - couponManager.loadRuleInputs(couponManager.ruleToSave.serviceId, function() { - couponManager.fillInRuleInputs(); + $.couponManager.loadRuleInputs($.couponManager.ruleToSave.serviceId, function() { + $.couponManager.fillInRuleInputs(); }); }; // Fill in rule inputs - couponManager.fillInRuleInputs = function() { + $.couponManager.fillInRuleInputs = function() { var operatorId = null; var valueId = null; var idName = null; - var id = couponManager.ruleToUpdateId; + var id = $.couponManager.ruleToUpdateId; if(id) { - couponManager.ruleToSave = couponManager.rulesToSave[id]; + $.couponManager.ruleToSave = $.couponManager.rulesToSave[id]; } - for (idName in couponManager.ruleToSave.operators) { + for (idName in $.couponManager.ruleToSave.operators) { // Setting idName operator select operatorId = idName + '-operator'; - $('#' + operatorId).val(couponManager.ruleToSave.operators[idName]); + $('#' + operatorId).val($.couponManager.ruleToSave.operators[idName]); // Setting idName value input valueId = idName + '-value'; - $('#' + valueId).val(couponManager.ruleToSave.values[idName]); + $('#' + valueId).val($.couponManager.ruleToSave.values[idName]); } }; // Save rules on click - couponManager.onClickSaveRule = function() { + $.couponManager.onClickSaveRule = function() { $('#constraint-save-btn').on('click', function () { if($('#category-rule').val() == 'thelia.constraint.rule.available_for_everyone') { // @todo translate + modal var r= confirm("Do you really want to set this coupon available to everyone ?"); if (r == true) { - couponManager.createOrUpdateRuleAjax(); + $.couponManager.createOrUpdateRuleAjax(); } } }); }; - couponManager.onClickSaveRule(); + $.couponManager.onClickSaveRule(); // Remove rule on click - couponManager.onClickDeleteRule = function() { + $.couponManager.onClickDeleteRule = function() { $('.constraint-delete-btn').on('click', function (e) { e.preventDefault(); var $this = $(this); - couponManager.removeRuleAjax($this.attr('data-int')); + $.couponManager.removeRuleAjax($this.attr('data-int')); }); }; - couponManager.onClickDeleteRule(); + $.couponManager.onClickDeleteRule(); // Update rule on click - couponManager.onClickUpdateRule = function() { + $.couponManager.onClickUpdateRule = function() { $('.constraint-update-btn').on('click', function (e) { e.preventDefault(); var $this = $(this); - couponManager.updateRuleSelectAjax($this.attr('data-int')); + $.couponManager.updateRuleSelectAjax($this.attr('data-int')); // Hide row being updated $this.parent().parent().remove(); }); }; - couponManager.onClickUpdateRule(); + $.couponManager.onClickUpdateRule(); // Reload effect inputs when changing effect - couponManager.onEffectChange = function() { + $.couponManager.onEffectChange = function() { var optionSelected = $("option:selected", this); $('#effectToolTip').html(optionSelected.attr("data-description")); $('#effect').on('change', function () { @@ -122,22 +134,22 @@ $(function($){ $('#effectToolTip').html(optionSelected.attr("data-description")); }); }; - couponManager.onEffectChange(); + $.couponManager.onEffectChange(); // Reload rule inputs when changing effect - couponManager.onRuleChange = function() { + $.couponManager.onRuleChange = function() { $('#category-rule').on('change', function () { - couponManager.loadRuleInputs($(this).val(), function() {}); + $.couponManager.loadRuleInputs($(this).val(), function() {}); }); }; - couponManager.onRuleChange(); + $.couponManager.onRuleChange(); // Fill in ready to be saved rule array // var onInputsChange = function() // In AJAX response // Set max usage to unlimited or not - couponManager.onUsageUnlimitedChange = function() { + $.couponManager.onUsageUnlimitedChange = function() { var isUnlimited = $('#is-unlimited'); if ($('#max-usage').val() == -1) { isUnlimited.prop('checked', true); @@ -160,20 +172,9 @@ $(function($){ } }); }; - couponManager.onUsageUnlimitedChange(); + $.couponManager.onUsageUnlimitedChange(); }); -// Rule to save -var couponManager = {}; -// Rule to be saved -couponManager.ruleToSave = {}; -couponManager.ruleToSave.serviceId = false; -couponManager.ruleToSave.operators = {}; -couponManager.ruleToSave.values = {}; -// Rules payload to save -couponManager.rulesToSave = []; -// Rule being updated id -couponManager.ruleToUpdateId = false; diff --git a/templates/admin/default/coupon-create.html b/templates/admin/default/coupon-create.html index f8a0411e1..4b23ca118 100755 --- a/templates/admin/default/coupon-create.html +++ b/templates/admin/default/coupon-create.html @@ -8,7 +8,7 @@ diff --git a/templates/admin/default/coupon-list.html b/templates/admin/default/coupon-list.html index 3abc9268d..07e7420db 100755 --- a/templates/admin/default/coupon-list.html +++ b/templates/admin/default/coupon-list.html @@ -8,7 +8,7 @@ @@ -39,13 +39,29 @@ {loop type="coupon" name="list_coupon" is_enabled="1" backend_context="true"} - {block name="coupon-code"}{$CODE}{/block} + {block name="coupon-code"}{$CODE}{/block} {block name="coupon-title"}{$TITLE}{/block} {block name="coupon-expiration-date"}{$EXPIRATION_DATE}{/block} - {block name="coupon-usage-left"}{$USAGE_LEFT}{/block} + + {block name="coupon-usage-left"} + {if $USAGE_LEFT == -1} + + {intl l="Unlimited"} + + {elseif $USAGE_LEFT} + + {$USAGE_LEFT} + + {else} + + 0 + + {/if} + {/block} + {block name="coupon-action"} - + {intl l='Edit'} {/block} @@ -80,7 +96,23 @@ {block name="coupon-code"}{$CODE}{/block} {block name="coupon-title"}{$TITLE}{/block} {block name="coupon-expiration-date"}{$EXPIRATION_DATE}{/block} - {block name="coupon-usage-left"}{$USAGE_LEFT}{/block} + + {block name="coupon-usage-left"} + {if $USAGE_LEFT == -1} + + {intl l="Unlimited"} + + {elseif $USAGE_LEFT} + + {$USAGE_LEFT} + + {else} + + 0 + + {/if} + {/block} + {block name="coupon-action"} diff --git a/templates/admin/default/coupon-read.html b/templates/admin/default/coupon-read.html index 8f14dd44f..aa0bfc5a1 100755 --- a/templates/admin/default/coupon-read.html +++ b/templates/admin/default/coupon-read.html @@ -8,7 +8,7 @@ @@ -64,7 +64,11 @@ {intl l='Usage left'} - {if $USAGE_LEFT} + {if $USAGE_LEFT == -1} + + {intl l="Unlimited"} + + {elseif $USAGE_LEFT} {$USAGE_LEFT} diff --git a/templates/admin/default/coupon-update.html b/templates/admin/default/coupon-update.html index 0902dae4c..8ef58f271 100755 --- a/templates/admin/default/coupon-update.html +++ b/templates/admin/default/coupon-update.html @@ -8,7 +8,7 @@ @@ -48,7 +48,7 @@ miniBrowser(0, '/test_to_remove/datas_coupon_edit.json'); // Init Rules - couponManager.initRules = function() { + $.couponManager.initRules = function() { var rules = []; {foreach from=$rulesObject key=k item=rule} // Init rule @@ -70,13 +70,13 @@ }; // Save Rules AJAX - couponManager.saveRuleAjax = function() { + $.couponManager.saveRuleAjax = function() { $('#constraint-add-operators-values').html('
    '); var $url = '{$urlAjaxUpdateRules}'; $.ajax({ type: "POST", url: $url, - data: {literal}{{/literal}rules:JSON.stringify(couponManager.rulesToSave){literal}}{/literal}, + data: {literal}{{/literal}rules:JSON.stringify($.couponManager.rulesToSave){literal}}{/literal}, statusCode: { 404: function() { $('#constraint-add-operators-values').html( @@ -92,13 +92,13 @@ return $(this).val() == 'thelia.constraint.rule.available_for_everyone'; }).prop('selected', true); - couponManager.onClickUpdateRule(); - couponManager.onClickDeleteRule(); + $.couponManager.onClickUpdateRule(); + $.couponManager.onClickDeleteRule(); }); }; // Reload rule inputs - couponManager.loadRuleInputs = function(ruleId, callBack) { + $.couponManager.loadRuleInputs = function(ruleId, callBack) { $('#constraint-add-operators-values').html('
    '); var url = "{$urlAjaxGetRuleInput}"; url = url.replace('ruleId', ruleId) @@ -113,7 +113,7 @@ } }).done(function(data) { $('#constraint-add-operators-values').html(data); - couponManager.ruleToSave.serviceId = ruleId; + $.couponManager.ruleToSave.serviceId = ruleId; if (ruleId == -1) { // Placeholder can't be saved $('#constraint-save-btn').hide(); @@ -125,7 +125,7 @@ }; // Rules which will be saved - couponManager.rulesToSave = couponManager.initRules(); + $.couponManager.rulesToSave = $.couponManager.initRules(); $('#constraint-save-btn').hide(); diff --git a/templates/admin/default/coupon/form.html b/templates/admin/default/coupon/form.html index 68c74bee2..299c6598b 100644 --- a/templates/admin/default/coupon/form.html +++ b/templates/admin/default/coupon/form.html @@ -11,7 +11,7 @@ {/form_field} {form_field form=$form field='success_url'} - + {/form_field}
    @@ -104,10 +104,10 @@ {form_field form=$form field='type'}
    - + {foreach from=$availableCoupons item=availableCoupon} - {/foreach} @@ -285,4 +285,3 @@ {/if} - From fbd91c1925a445c62d6e427570fad880dc885470 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Tue, 24 Sep 2013 09:15:41 +0200 Subject: [PATCH 14/98] add admin templates --- templates/admin/default/order-edit.html | 519 ++++++++++++------------ templates/admin/default/orders.html | 178 ++++---- 2 files changed, 354 insertions(+), 343 deletions(-) diff --git a/templates/admin/default/order-edit.html b/templates/admin/default/order-edit.html index 603176fe6..793414afb 100644 --- a/templates/admin/default/order-edit.html +++ b/templates/admin/default/order-edit.html @@ -30,71 +30,75 @@
    - - - - - - - - - - +
    +
    - {intl l='Information about order 01201303540354'} -
    {intl l="Designation"}{intl l="Price"}{intl l="Quantity"}{intl l="Total"}
    + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - -
    + {intl l='Information about order 01201303540354'} +
    {intl l="Designation"}{intl l="Price"}{intl l="Quantity"}{intl l="Total"}
    T-Shirt F T120.00 €360.00 €
    T-Shirt F T120.00 €360.00 €
    T-Shirt F T120.00 €360.00 €
    Total180.00 €
    + + + T-Shirt F T1 + 20.00 € + 3 + 60.00 € + + + T-Shirt F T1 + 20.00 € + 3 + 60.00 € + + + T-Shirt F T1 + 20.00 € + 3 + 60.00 € + + + + + Total + 180.00 € + + + +
    - - - - - - - - - - +
    +
    - {intl l='Information about the bill'} -
    {intl l="Bill n°"}{intl l="Compagny"}{intl l="Firstname & Lastname"}{intl l="Date & Hour"}
    + + + + + + + + + - - - - - - - - -
    + {intl l='Information about the bill'} +
    {intl l="Bill n°"}{intl l="Compagny"}{intl l="Firstname & Lastname"}{intl l="Date & Hour"}
    0001TheliaDupont Jean11/01/2013 14:11:00
    + + + 0001 + Thelia + Dupont Jean + 11/01/2013 14:11:00 + + + +
    @@ -116,214 +120,219 @@
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - {intl l='Information about the settlement'} -
    {intl l="Type of payment"}Unknown
    {intl l="Transaction reference"}141100
    {intl l="Total order before discount"}60 €
    {intl l="Discount"}10%
    {intl l="Coupon code"}
    {intl l="Total with discount"}50 €
    {intl l="Freight"}6 €
    {intl l="Total"}56 €
    - +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + {intl l='Information about the settlement'} +
    {intl l="Type of payment"}Unknown
    {intl l="Transaction reference"}141100
    {intl l="Total order before discount"}60 €
    {intl l="Discount"}10%
    {intl l="Coupon code"}
    {intl l="Total with discount"}50 €
    {intl l="Freight"}6 €
    {intl l="Total"}56 €
    +
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - {intl l='Billing address'} - - - -
    {intl l="Title"}Mr
    {intl l="Compagny"}Thelia
    {intl l="Firstname"}Espeche
    {intl l="Lastname"}Michaël
    {intl l="Street address"}5, rue Rochon
    {intl l="Additional address"}Lorem ipsum dolor sit amet
    {intl l="Additional address"}Lorem ipsum dolor sit
    {intl l="Zip code"}63000
    {intl l="City"}Clermont-Fd
    {intl l="Country"}France
    {intl l="Phone"}01 02 03 04 05
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + {intl l='Billing address'} + + + +
    {intl l="Title"}Mr
    {intl l="Compagny"}Thelia
    {intl l="Firstname"}Espeche
    {intl l="Lastname"}Michaël
    {intl l="Street address"}5, rue Rochon
    {intl l="Additional address"}Lorem ipsum dolor sit amet
    {intl l="Additional address"}Lorem ipsum dolor sit
    {intl l="Zip code"}63000
    {intl l="City"}Clermont-Fd
    {intl l="Country"}France
    {intl l="Phone"}01 02 03 04 05
    +
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - {intl l='Delivery address'} - - - -
    {intl l="Title"}Mr
    {intl l="Compagny"}Thelia
    {intl l="Firstname"}Espeche
    {intl l="Lastname"}Michaël
    {intl l="Street address"}5, rue Rochon
    {intl l="Additional address"}Lorem ipsum dolor sit amet
    {intl l="Additional address"}Lorem ipsum dolor sit
    {intl l="Zip code"}63000
    {intl l="City"}Clermont-Fd
    {intl l="Country"}France
    {intl l="Phone"}01 02 03 04 05
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + {intl l='Delivery address'} + + + +
    {intl l="Title"}Mr
    {intl l="Compagny"}Thelia
    {intl l="Firstname"}Espeche
    {intl l="Lastname"}Michaël
    {intl l="Street address"}5, rue Rochon
    {intl l="Additional address"}Lorem ipsum dolor sit amet
    {intl l="Additional address"}Lorem ipsum dolor sit
    {intl l="Zip code"}63000
    {intl l="City"}Clermont-Fd
    {intl l="Country"}France
    {intl l="Phone"}01 02 03 04 05
    +
    - - - - - - - - - - - - - - - - - - - - - - -
    - {intl l='Further information'} -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    -
    - -
    - -
    -
    -
    {intl l='Bill'} {intl l='Download bill to pdf'}
    {intl l='Delivery'} {intl l='Download delivery to pdf'}
    +
    + + + + + + + + + + + + + + + + + + + + + +
    + {intl l='Further information'} +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    +
    + +
    + +
    +
    +
    {intl l='Bill'} {intl l='Download bill to pdf'}
    {intl l='Delivery'} {intl l='Download delivery to pdf'}
    +
    diff --git a/templates/admin/default/orders.html b/templates/admin/default/orders.html index 4f9c6ecf8..02bbea458 100644 --- a/templates/admin/default/orders.html +++ b/templates/admin/default/orders.html @@ -19,114 +19,116 @@
    - - - - - - - - - - +
    +
    - {intl l='Orders'} - {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.orders.create"} - - - - {/loop} -
    {intl l="Order n°"}{intl l="Date & Hour"}{intl l="Compagny"}{intl l="Name"}{intl l="Amount"}{intl l="Status"}
    + + + + + + + + + - {module_include location='orders_table_header'} + {module_include location='orders_table_header'} - - - + + + - - + + - - - - - - + + + + + + - {module_include location='orders_table_row'} + {module_include location='orders_table_row'} - - - + {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.orders.delete"} + + {/loop} + + + + - - - - - - + + + + + + - {module_include location='orders_table_row'} + {module_include location='orders_table_row'} - - - + {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.orders.delete"} + + {/loop} + + + + - - - - - - + + + + + + - {module_include location='orders_table_row'} + {module_include location='orders_table_row'} - - + {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.orders.delete"} + + {/loop} + + + - + - -
    + {intl l='Orders'} + {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.orders.create"} + + + + {/loop} +
    {intl l="Order n°"}{intl l="Date & Hour"}{intl l="Compagny"}{intl l="Name"}{intl l="Amount"}{intl l="Status"}{intl l="Actions"}
    {intl l="Actions"}
    0123045012304511/09/2013 10:24:31TheliaDupont251 €Paid0123045012304511/09/2013 10:24:31TheliaDupont251 €Paid -
    +
    +
    - {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.orders.edit"} - - {/loop} + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.orders.edit"} + + {/loop} - {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.orders.delete"} - - {/loop} -
    -
    0123045012304511/09/2013 10:24:31TheliaDupont251 €Canceled0123045012304511/09/2013 10:24:31TheliaDupont251 €Canceled -
    +
    +
    - {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.orders.edit"} - - {/loop} + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.orders.edit"} + + {/loop} - {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.orders.delete"} - - {/loop} -
    -
    0123045012304511/09/2013 10:24:31TheliaDupont251 €Current0123045012304511/09/2013 10:24:31TheliaDupont251 €Current -
    +
    +
    - {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.orders.edit"} - - {/loop} + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.orders.edit"} + + {/loop} - {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.orders.delete"} - - {/loop} -
    -
    + + +
    From 93e7a4dc90b899d86015dfc8971410feeb478505 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Tue, 24 Sep 2013 09:44:59 +0200 Subject: [PATCH 15/98] order admin integration --- core/lib/Thelia/Config/Resources/config.xml | 1 + core/lib/Thelia/Core/Template/Loop/Order.php | 26 ++- .../Core/Template/Loop/OrderAddress.php | 155 ++++++++++++++++++ templates/admin/default/orders.html | 60 ++----- 4 files changed, 190 insertions(+), 52 deletions(-) create mode 100755 core/lib/Thelia/Core/Template/Loop/OrderAddress.php diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index 809c62a33..0421f4ef6 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -23,6 +23,7 @@ + diff --git a/core/lib/Thelia/Core/Template/Loop/Order.php b/core/lib/Thelia/Core/Template/Loop/Order.php index 41d49c4f8..25e12fec8 100755 --- a/core/lib/Thelia/Core/Template/Loop/Order.php +++ b/core/lib/Thelia/Core/Template/Loop/Order.php @@ -53,11 +53,18 @@ class Order extends BaseLoop 'customer', new TypeCollection( new Type\IntType(), - new Type\EnumType(array('current')) + new Type\EnumType(array('current', '*')) ), 'current' ), - Argument::createIntListTypeArgument('status') + Argument::createIntListTypeArgument('status'), + new Argument( + 'order', + new TypeCollection( + new Type\EnumListType(array('create-date', 'create-date-reverse')) + ), + 'create-date-reverse' + ) ); } @@ -85,7 +92,7 @@ class Order extends BaseLoop } else { $search->filterByCustomerId($currentCustomer->getId(), Criteria::EQUAL); } - } else { + } elseif ($customer !== '*') { $search->filterByCustomerId($customer, Criteria::EQUAL); } @@ -95,6 +102,19 @@ class Order extends BaseLoop $search->filterByStatusId($status, Criteria::IN); } + $orderers = $this->getOrder(); + + foreach ($orderers as $orderer) { + switch ($orderer) { + case "create-date": + $search->orderByCreatedAt(Criteria::ASC); + break; + case "create-date-reverse": + $search->orderByCreatedAt(Criteria::DESC); + break; + } + } + $orders = $this->search($search, $pagination); $loopResult = new LoopResult($orders); diff --git a/core/lib/Thelia/Core/Template/Loop/OrderAddress.php b/core/lib/Thelia/Core/Template/Loop/OrderAddress.php new file mode 100755 index 000000000..cb0cbd5b5 --- /dev/null +++ b/core/lib/Thelia/Core/Template/Loop/OrderAddress.php @@ -0,0 +1,155 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Template\Loop; + +use Propel\Runtime\ActiveQuery\Criteria; +use Thelia\Core\Template\Element\BaseLoop; +use Thelia\Core\Template\Element\LoopResult; +use Thelia\Core\Template\Element\LoopResultRow; + +use Thelia\Core\Template\Loop\Argument\ArgumentCollection; +use Thelia\Core\Template\Loop\Argument\Argument; + +use Thelia\Model\AddressQuery; +use Thelia\Type\TypeCollection; +use Thelia\Type; + +/** + * + * OrderAddress loop + * + * + * Class OrderAddress + * @package Thelia\Core\Template\Loop + * @author Etienne Roudeix + */ +class OrderAddress extends BaseLoop +{ + public $timestampable = true; + + /** + * @return ArgumentCollection + */ + protected function getArgDefinitions() + { + return new ArgumentCollection( + new Argument( + 'id', + new TypeCollection( + new Type\IntListType(), + new Type\EnumType(array('*', 'any')) + ) + ), + new Argument( + 'customer', + new TypeCollection( + new Type\IntType(), + new Type\EnumType(array('current')) + ), + 'current' + ), + Argument::createBooleanOrBothTypeArgument('default'), + new Argument( + 'exclude', + new TypeCollection( + new Type\IntListType(), + new Type\EnumType(array('none')) + ) + ) + ); + } + + /** + * @param $pagination + * + * @return \Thelia\Core\Template\Element\LoopResult + */ + public function exec(&$pagination) + { + $search = OrderAddressQuery::create(); + + $id = $this->getId(); + + if (null !== $id && !in_array($id, array('*', 'any'))) { + $search->filterById($id, Criteria::IN); + } + + $customer = $this->getCustomer(); + + if ($customer === 'current') { + $currentCustomer = $this->securityContext->getCustomerUser(); + if ($currentCustomer === null) { + return new LoopResult(); + } else { + $search->filterByCustomerId($currentCustomer->getId(), Criteria::EQUAL); + } + } else { + $search->filterByCustomerId($customer, Criteria::EQUAL); + } + + $default = $this->getDefault(); + + if ($default === true) { + $search->filterByIsDefault(1, Criteria::EQUAL); + } else if($default === false) { + $search->filterByIsDefault(0, Criteria::EQUAL); + } + + $exclude = $this->getExclude(); + + if (null !== $exclude && 'none' !== $exclude) { + $search->filterById($exclude, Criteria::NOT_IN); + } + + $addresses = $this->search($search, $pagination); + + $loopResult = new LoopResult($addresses); + + foreach ($addresses as $address) { + $loopResultRow = new LoopResultRow($loopResult, $address, $this->versionable, $this->timestampable, $this->countable); + $loopResultRow + ->set("ID", $address->getId()) + ->set("LABEL", $address->getLabel()) + ->set("CUSTOMER", $address->getCustomerId()) + ->set("TITLE", $address->getTitleId()) + ->set("COMPANY", $address->getCompany()) + ->set("FIRSTNAME", $address->getFirstname()) + ->set("LASTNAME", $address->getLastname()) + ->set("ADDRESS1", $address->getAddress1()) + ->set("ADDRESS2", $address->getAddress2()) + ->set("ADDRESS3", $address->getAddress3()) + ->set("ZIPCODE", $address->getZipcode()) + ->set("CITY", $address->getCity()) + ->set("COUNTRY", $address->getCountryId()) + ->set("PHONE", $address->getPhone()) + ->set("CELLPHONE", $address->getCellphone()) + ->set("DEFAULT", $address->getIsDefault()) + ; + + $loopResult->addRow($loopResultRow); + } + + return $loopResult; + } +} diff --git a/templates/admin/default/orders.html b/templates/admin/default/orders.html index 02bbea458..2cb8517ea 100644 --- a/templates/admin/default/orders.html +++ b/templates/admin/default/orders.html @@ -45,10 +45,18 @@ + {loop type="order" name="order-list" customer="*"} + + {loop type="customer" name="order-customer"} + {/loop} + + {loop type="order_address" name="order-invoice-address"} + {/loop} + - 01230450123045 - 11/09/2013 10:24:31 + {$REF} + {format_date date=$CREATE_DATE} Thelia Dupont 251 € @@ -69,54 +77,8 @@
    - - 01230450123045 - 11/09/2013 10:24:31 - Thelia - Dupont - 251 € - Canceled - - {module_include location='orders_table_row'} - - -
    - - {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.orders.edit"} - - {/loop} - - {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.orders.delete"} - - {/loop} -
    - - - - - 01230450123045 - 11/09/2013 10:24:31 - Thelia - Dupont - 251 € - Current - - {module_include location='orders_table_row'} - - -
    - - {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.orders.edit"} - - {/loop} - - {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.orders.delete"} - - {/loop} -
    - - + {/loop} + {ifloop rel='the-order'} -
    -
    - - - - - - - - - - + {loop type="order" name="the-order" id=$order_id customer="*"} - - - - - - - - -
    - {intl l='Information about the bill'} -
    {intl l="Bill n°"}{intl l="Compagny"}{intl l="Firstname & Lastname"}{intl l="Date & Hour"}
    0001TheliaDupont Jean11/01/2013 14:11:00
    -
    -
    + {loop type="currency" name="order-currency" id=$CURRENCY} + {assign "orderCurrency" $SYMBOL} + {/loop} -
    -

    - {intl l='Information about the carriage'} - - {intl l='Download pdf bill'} - -

    + -
    -
    {intl l="Mode of transportation"}
    -
    Colissimo
    -
    -
    -
    {intl l="Description"}
    -
    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ut, error, necessitatibus ipsam dolores ad quisquam provident sed repudiandae ullam quasi quae perferendis numquam voluptates doloribus laborum possimus dicta similique in?
    -
    -
    +
    +
    +
    + + + + + + + + + + -
    -
    -
    + {intl l='Cart'} +
    {intl l="Product"}{intl l="Price"}{intl l="Quantity"}{intl l="Total"}
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - {intl l='Information about the settlement'} -
    {intl l="Type of payment"}Unknown
    {intl l="Transaction reference"}141100
    {intl l="Total order before discount"}60 €
    {intl l="Discount"}10%
    {intl l="Coupon code"}
    {intl l="Total with discount"}50 €
    {intl l="Freight"}6 €
    {intl l="Total"}56 €
    -
    -
    + + + T-Shirt F T1 + 20.00 € + 3 + 60.00 € + + + T-Shirt F T1 + 20.00 € + 3 + 60.00 € + + + T-Shirt F T1 + 20.00 € + 3 + 60.00 € + + + + + Total + 180.00 € + + + +
    -
    - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - {intl l='Billing address'} - - - -
    {intl l="Title"}Mr
    {intl l="Compagny"}Thelia
    {intl l="Firstname"}Espeche
    {intl l="Lastname"}Michaël
    {intl l="Street address"}5, rue Rochon
    {intl l="Additional address"}Lorem ipsum dolor sit amet
    {intl l="Additional address"}Lorem ipsum dolor sit
    {intl l="Zip code"}63000
    {intl l="City"}Clermont-Fd
    {intl l="Country"}France
    {intl l="Phone"}01 02 03 04 05
    -
    -
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + {intl l='Payment information'} +
    {intl l="Payment module"}{loop name="payment-module" type="module" id=$PAYMENT_MODULE}{$TITLE}{/loop}
    {intl l="Transaction reference"}{$TRANSACTION_REF}
    {intl l="Total without discount"}@TODO
    {intl l="Discount"}@TODO
    {intl l="Coupon code"}@TODO
    {intl l="Total including discount"}{$orderCurrency} {$TOTAL_TAXED_AMOUNT-$POSTAGE}
    {intl l="Postage"}{$orderCurrency} {$POSTAGE}
    {intl l="Total"}{$orderCurrency} {$TOTAL_TAXED_AMOUNT}
    +
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - {intl l='Delivery address'} - - - -
    {intl l="Title"}Mr
    {intl l="Compagny"}Thelia
    {intl l="Firstname"}Espeche
    {intl l="Lastname"}Michaël
    {intl l="Street address"}5, rue Rochon
    {intl l="Additional address"}Lorem ipsum dolor sit amet
    {intl l="Additional address"}Lorem ipsum dolor sit
    {intl l="Zip code"}63000
    {intl l="City"}Clermont-Fd
    {intl l="Country"}France
    {intl l="Phone"}01 02 03 04 05
    -
    -
    - -
    - -
    -
    - - - - - - - - - - - - - - - - - - - - - -
    - {intl l='Further information'} -
    -
    -
    -
    - -
    -
    -
    -
    -
    -
    -
    - -
    - -
    -
    -
    {intl l='Bill'} {intl l='Download bill to pdf'}
    {intl l='Delivery'} {intl l='Download delivery to pdf'}
    -
    -
    + - +
    + +

    + {intl l='Delivery module'} +

    + + {loop name="payment-module" type="module" id=$DELIVERY_MODULE} + +
    +
    {intl l="Name"}
    +
    {$TITLE}
    +
    +
    +
    {intl l="Description"}
    +
    {$DESCRIPTION}
    +
    + + {/loop} + +
    +
    + + + + + + + + + + + + + {loop type="order_address" name="order-invoice-address" id=$INVOICE_ADDRESS} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {/loop} + +
    + {intl l='Invoice informations'} + +
    {intl l="Invoice reference"}{$INVOICE_REF}
    {intl l="Invoice date"}{format_date date=$INVOICE_DATE output="date"}
    {intl l="Title"}{loop type="title" name="order-invoice-address-title" id=$TITLE}{$LONG}{/loop}
    {intl l="Compagny"}{$COMPANY}
    {intl l="Firstname"}{$FIRSTNAME}
    {intl l="Lastname"}{$LASTNAME}
    {intl l="Street address"}{$ADDRESS1}
    {intl l="Additional address"}{$ADDRESS2}
    {intl l="Additional address"}{$ADDRESS3}
    {intl l="Zip code"}{$ZIPCODE}
    {intl l="City"}{$CITY}
    {intl l="Country"}{loop type="country" name="order-invoice-address-country" id=$COUNTRY}{$TITLE}{/loop}
    {intl l="Phone"}{$PHONE}
    +
    +
    + +
    +
    + + + + {loop type="order_address" name="order-delivery-address" id=$DELIVERY_ADDRESS} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {/loop} + +
    + {intl l='Delivery address'} + +
    {intl l="Title"}{loop type="title" name="order-delivery-address-title" id=$TITLE}{$LONG}{/loop}
    {intl l="Compagny"}{$COMPANY}
    {intl l="Firstname"}{$FIRSTNAME}
    {intl l="Lastname"}{$LASTNAME}
    {intl l="Street address"}{$ADDRESS1}
    {intl l="Additional address"}{$ADDRESS2}
    {intl l="Additional address"}{$ADDRESS3}
    {intl l="Zip code"}{$ZIPCODE}
    {intl l="City"}{$CITY}
    {intl l="Country"}{loop type="country" name="order-delivery-address-country" id=$COUNTRY}{$TITLE}{/loop}
    {intl l="Phone"}{$PHONE}
    +
    +
    + + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    + {intl l='Further information'} +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    +
    + +
    + +
    +
    +
    {intl l='Bill'} {intl l='Download bill to pdf'}
    {intl l='Delivery'} {intl l='Download delivery to pdf'}
    +
    +
    + + + {/loop} + + {/ifloop} + {elseloop rel="the-order"} + + DOES NOT EXISTS + + {/elseloop} diff --git a/templates/admin/default/orders.html b/templates/admin/default/orders.html index 2cb8517ea..c0b420275 100644 --- a/templates/admin/default/orders.html +++ b/templates/admin/default/orders.html @@ -45,22 +45,47 @@ + {loop type="order" name="order-list" customer="*"} - {loop type="customer" name="order-customer"} + {loop type="order_address" name="order-invoice-address" id=$INVOICE_ADDRESS} + {assign "orderInvoiceFirstName" $FIRSTNAME} + {assign "orderInvoiceLastName" $LASTNAME} + {assign "orderInvoiceCompany" $COMPANY} {/loop} - {loop type="order_address" name="order-invoice-address"} + {loop type="order-status" name="order-status" id=$STATUS} + {assign "orderStatus" $TITLE} + {if $CODE == 'not_paid'} + {assign "orderStatusLabel" "warning"} + {else} + {if $CODE == 'paid'} + {assign "orderStatusLabel" "success"} + {else} + {if $CODE == 'processing'} + {assign "orderStatusLabel" "Primary"} + {else} + {if $CODE == 'sent'} + {assign "orderStatusLabel" "info"} + {else} + {if $CODE == 'canceled'} + {assign "orderStatusLabel" "danger"} + {else} + {/if} + {/if} + {/if} + {/if} + {/if} {/loop} - {$REF} + 01230450123045 {format_date date=$CREATE_DATE} - Thelia - Dupont - 251 € - Paid + {$orderInvoiceCompany} + {$orderInvoiceFirstName|ucwords} {$orderInvoiceLastName|upper} + {$TOTAL_TAXED_AMOUNT} + {$orderStatus} {module_include location='orders_table_row'} From 7bd511c420f29a795c74a9cc0b8e4b1ac373530c Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Tue, 24 Sep 2013 17:04:32 +0200 Subject: [PATCH 17/98] order admin --- core/lib/Thelia/Action/Order.php | 5 +- core/lib/Thelia/Config/Resources/config.xml | 2 + .../Core/Template/Loop/OrderProduct.php | 125 ++++++++++++++++ .../Loop/OrderProductAttributeCombination.php | 119 ++++++++++++++++ core/lib/Thelia/Model/Attribute.php | 2 +- core/lib/Thelia/Model/Base/Attribute.php | 76 ++-------- core/lib/Thelia/Model/Base/AttributeQuery.php | 47 +----- .../Thelia/Model/Base/AttributeTemplate.php | 134 ++++++++++++++++-- .../Model/Base/AttributeTemplateQuery.php | 80 ++++++++++- core/lib/Thelia/Model/Base/Feature.php | 76 ++-------- core/lib/Thelia/Model/Base/FeatureProduct.php | 48 +++---- .../Thelia/Model/Base/FeatureProductQuery.php | 28 ++-- core/lib/Thelia/Model/Base/FeatureQuery.php | 47 +----- .../lib/Thelia/Model/Base/FeatureTemplate.php | 76 ++++++++-- .../Model/Base/FeatureTemplateQuery.php | 47 +++++- .../Base/OrderProductAttributeCombination.php | 48 +++---- .../OrderProductAttributeCombinationQuery.php | 28 ++-- .../lib/Thelia/Model/Base/OrderProductTax.php | 76 ++++++++-- .../Model/Base/OrderProductTaxQuery.php | 47 +++++- .../Thelia/Model/Base/ProductSaleElements.php | 96 +++++++++++-- .../Model/Base/ProductSaleElementsQuery.php | 33 ++++- core/lib/Thelia/Model/Feature.php | 2 +- .../Thelia/Model/Map/AttributeTableMap.php | 36 ++--- .../Model/Map/AttributeTemplateTableMap.php | 44 ++++-- .../Model/Map/FeatureProductTableMap.php | 30 ++-- core/lib/Thelia/Model/Map/FeatureTableMap.php | 36 ++--- .../Model/Map/FeatureTemplateTableMap.php | 36 +++-- ...derProductAttributeCombinationTableMap.php | 30 ++-- .../Model/Map/OrderProductTaxTableMap.php | 36 +++-- .../Model/Map/ProductSaleElementsTableMap.php | 40 +++--- core/lib/Thelia/Model/Order.php | 12 +- core/lib/Thelia/Model/TaxRule.php | 9 +- core/lib/Thelia/Tests/Action/OrderTest.php | 5 +- install/faker.php | 6 +- install/thelia.sql | 17 ++- local/config/schema.xml | 19 +-- templates/admin/default/admin-layout.tpl | 7 + .../default/assets/less/thelia/tables.less | 17 ++- templates/admin/default/order-edit.html | 126 ++++++++++------ templates/admin/default/orders.html | 4 +- 40 files changed, 1197 insertions(+), 555 deletions(-) create mode 100755 core/lib/Thelia/Core/Template/Loop/OrderProduct.php create mode 100755 core/lib/Thelia/Core/Template/Loop/OrderProductAttributeCombination.php diff --git a/core/lib/Thelia/Action/Order.php b/core/lib/Thelia/Action/Order.php index f93733da3..3bc33fc99 100755 --- a/core/lib/Thelia/Action/Order.php +++ b/core/lib/Thelia/Action/Order.php @@ -200,7 +200,8 @@ class Order extends BaseAction implements EventSubscriberInterface $taxDetail = $product->getTaxRule()->getTaxDetail( $taxCountry, - $cartItem->getPromo() == 1 ? $cartItem->getPromoPrice() : $cartItem->getPrice(), + $cartItem->getPrice(), + $cartItem->getPromoPrice(), $this->getSession()->getLang()->getLocale() ); @@ -242,7 +243,7 @@ class Order extends BaseAction implements EventSubscriberInterface ->setAttributeTitle($attribute->getTitle()) ->setAttributeChapo($attribute->getChapo()) ->setAttributeDescription($attribute->getDescription()) - ->setAttributePostscriptumn($attribute->getPostscriptum()) + ->setAttributePostscriptum($attribute->getPostscriptum()) ->setAttributeAvTitle($attributeAv->getTitle()) ->setAttributeAvChapo($attributeAv->getChapo()) ->setAttributeAvDescription($attributeAv->getDescription()) diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index 0421f4ef6..a05ace847 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -24,6 +24,8 @@ + + diff --git a/core/lib/Thelia/Core/Template/Loop/OrderProduct.php b/core/lib/Thelia/Core/Template/Loop/OrderProduct.php new file mode 100755 index 000000000..7e14d91f5 --- /dev/null +++ b/core/lib/Thelia/Core/Template/Loop/OrderProduct.php @@ -0,0 +1,125 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Template\Loop; + +use Propel\Runtime\ActiveQuery\Criteria; +use Thelia\Core\Template\Element\BaseLoop; +use Thelia\Core\Template\Element\LoopResult; +use Thelia\Core\Template\Element\LoopResultRow; + +use Thelia\Core\Template\Loop\Argument\ArgumentCollection; +use Thelia\Core\Template\Loop\Argument\Argument; + +use Thelia\Exception\TaxEngineException; +use Thelia\Model\Base\OrderProductQuery; +use Thelia\Model\CountryQuery; +use Thelia\Model\CurrencyQuery; +use Thelia\Model\Map\OrderProductTableMap; +use Thelia\Type\TypeCollection; +use Thelia\Type; + +/** + * + * OrderProduct loop + * + * Class OrderProduct + * @package Thelia\Core\Template\Loop + * @author Etienne Roudeix + */ +class OrderProduct extends BaseLoop +{ + public $timestampable = true; + + /** + * @return ArgumentCollection + */ + protected function getArgDefinitions() + { + return new ArgumentCollection( + Argument::createIntTypeArgument('order', null, true) + ); + } + + /** + * @param $pagination + * + * @return \Thelia\Core\Template\Element\LoopResult + * @throws \InvalidArgumentException + */ + public function exec(&$pagination) + { + $search = OrderProductQuery::create(); + + $search->joinOrderProductTax('opt', Criteria::LEFT_JOIN) + ->withColumn('SUM(`opt`.AMOUNT)', 'TOTAL_TAX') + ->withColumn('SUM(`opt`.PROMO_AMOUNT)', 'TOTAL_PROMO_TAX') + ->groupById(); + + + $order = $this->getOrder(); + + $search->filterByOrderId($order, Criteria::EQUAL); + + $search->orderById(Criteria::ASC); + + $products = $this->search($search, $pagination); + + $loopResult = new LoopResult($products); + + foreach ($products as $product) { + $loopResultRow = new LoopResultRow($loopResult, $product, $this->versionable, $this->timestampable, $this->countable); + + $price = $product->getPrice(); + $taxedPrice = $price + round($product->getVirtualColumn('TOTAL_TAX'), 2); + $promoPrice = $product->getPromoPrice(); + $taxedPromoPrice = $promoPrice + round($product->getVirtualColumn('TOTAL_PROMO_TAX'), 2); + + $loopResultRow->set("ID", $product->getId()) + ->set("REF", $product->getProductRef()) + ->set("PRODUCT_SALE_ELEMENTS_REF", $product->getProductSaleElementsRef()) + ->set("WAS_NEW", $product->getWasNew() === 1 ? 1 : 0) + ->set("WAS_IN_PROMO", $product->getWasInPromo() === 1 ? 1 : 0) + ->set("WEIGHT", $product->getWeight()) + ->set("TITLE", $product->getTitle()) + ->set("CHAPO", $product->getChapo()) + ->set("DESCRIPTION", $product->getDescription()) + ->set("POSTSCRIPTUM", $product->getPostscriptum()) + ->set("QUANTITY", $product->getQuantity()) + ->set("PRICE", $price) + ->set("PRICE_TAX", $taxedPrice - $price) + ->set("TAXED_PRICE", $taxedPrice) + ->set("PROMO_PRICE", $promoPrice) + ->set("PROMO_PRICE_TAX", $taxedPromoPrice - $promoPrice) + ->set("TAXED_PROMO_PRICE", $taxedPromoPrice) + ->set("TAX_RULE_TITLE", $product->getTaxRuleTitle()) + ->set("TAX_RULE_DESCRIPTION", $product->getTaxRuledescription()) + ->set("PARENT", $product->getParent()) + ; + + $loopResult->addRow($loopResultRow); + } + + return $loopResult; + } +} diff --git a/core/lib/Thelia/Core/Template/Loop/OrderProductAttributeCombination.php b/core/lib/Thelia/Core/Template/Loop/OrderProductAttributeCombination.php new file mode 100755 index 000000000..0e483ef81 --- /dev/null +++ b/core/lib/Thelia/Core/Template/Loop/OrderProductAttributeCombination.php @@ -0,0 +1,119 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Template\Loop; + +use Propel\Runtime\ActiveQuery\Criteria; +use Thelia\Core\Template\Element\BaseI18nLoop; +use Thelia\Core\Template\Element\LoopResult; +use Thelia\Core\Template\Element\LoopResultRow; + +use Thelia\Core\Template\Loop\Argument\ArgumentCollection; +use Thelia\Core\Template\Loop\Argument\Argument; + +use Thelia\Model\Base\OrderProductAttributeCombinationQuery; +use Thelia\Model\Map\AttributeAvTableMap; +use Thelia\Model\Map\AttributeTableMap; +use Thelia\Type\TypeCollection; +use Thelia\Type; + +/** + * + * OrderProductOrderProductAttributeCombination loop + * + * Class OrderProductAttributeCombination + * @package Thelia\Core\Template\Loop + * @author Etienne Roudeix + */ +class OrderProductAttributeCombination extends BaseI18nLoop +{ + public $timestampable = true; + + /** + * @return ArgumentCollection + */ + protected function getArgDefinitions() + { + return new ArgumentCollection( + Argument::createIntTypeArgument('order_product', null, true), + new Argument( + 'order', + new TypeCollection( + new Type\EnumListType(array('alpha', 'alpha_reverse')) + ), + 'alpha' + ) + ); + } + + /** + * @param $pagination + * + * @return \Thelia\Core\Template\Element\LoopResult + */ + public function exec(&$pagination) + { + $search = OrderProductAttributeCombinationQuery::create(); + + $orderProduct = $this->getOrder_product(); + + $search->filterByOrderProductId($orderProduct, Criteria::EQUAL); + + $orders = $this->getOrder(); + + foreach ($orders as $order) { + switch ($order) { + case "alpha": + $search->orderByAttributeTitle(Criteria::ASC); + break; + case "alpha_reverse": + $search->orderByAttributeTitle(Criteria::DESC); + break; + } + } + + $attributeCombinations = $this->search($search, $pagination); + + $loopResult = new LoopResult($attributeCombinations); + + foreach ($attributeCombinations as $attributeCombination) { + $loopResultRow = new LoopResultRow($loopResult, $attributeCombination, $this->versionable, $this->timestampable, $this->countable); + + $loopResultRow + ->set("LOCALE",$locale) + ->set("ATTRIBUTE_TITLE", $attributeCombination->getAttributeTitle()) + ->set("ATTRIBUTE_CHAPO", $attributeCombination->getAttributeChapo()) + ->set("ATTRIBUTE_DESCRIPTION", $attributeCombination->getAttributeDescription()) + ->set("ATTRIBUTE_POSTSCRIPTUM", $attributeCombination->getAttributePostscriptum()) + ->set("ATTRIBUTE_AVAILABILITY_TITLE", $attributeCombination->getAttributeAvTitle()) + ->set("ATTRIBUTE_AVAILABILITY_CHAPO", $attributeCombination->getAttributeAvChapo()) + ->set("ATTRIBUTE_AVAILABILITY_DESCRIPTION", $attributeCombination->getAttributeAvDescription()) + ->set("ATTRIBUTE_AVAILABILITY_POSTSCRIPTUM", $attributeCombination->getAttributeAvPostscriptum()) + ; + + $loopResult->addRow($loopResultRow); + } + + return $loopResult; + } +} diff --git a/core/lib/Thelia/Model/Attribute.php b/core/lib/Thelia/Model/Attribute.php index b4101da8c..85197b802 100755 --- a/core/lib/Thelia/Model/Attribute.php +++ b/core/lib/Thelia/Model/Attribute.php @@ -20,7 +20,7 @@ class Attribute extends BaseAttribute { $this->dispatchEvent(TheliaEvents::BEFORE_CREATEATTRIBUTE, new AttributeEvent($this)); // Set the current position for the new object - $this->setPosition($this->getNextPosition()); + //$this->setPosition($this->getNextPosition()); return true; } diff --git a/core/lib/Thelia/Model/Base/Attribute.php b/core/lib/Thelia/Model/Base/Attribute.php index 64e765fdd..51ddaac83 100644 --- a/core/lib/Thelia/Model/Base/Attribute.php +++ b/core/lib/Thelia/Model/Base/Attribute.php @@ -71,12 +71,6 @@ abstract class Attribute implements ActiveRecordInterface */ protected $id; - /** - * The value for the position field. - * @var int - */ - protected $position; - /** * The value for the created_at field. * @var string @@ -435,17 +429,6 @@ abstract class Attribute implements ActiveRecordInterface return $this->id; } - /** - * Get the [position] column value. - * - * @return int - */ - public function getPosition() - { - - return $this->position; - } - /** * Get the [optionally formatted] temporal [created_at] column value. * @@ -507,27 +490,6 @@ abstract class Attribute implements ActiveRecordInterface return $this; } // setId() - /** - * Set the value of [position] column. - * - * @param int $v new value - * @return \Thelia\Model\Attribute The current object (for fluent API support) - */ - public function setPosition($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->position !== $v) { - $this->position = $v; - $this->modifiedColumns[] = AttributeTableMap::POSITION; - } - - - return $this; - } // setPosition() - /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. * @@ -610,16 +572,13 @@ abstract class Attribute implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : AttributeTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; $this->id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AttributeTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; - $this->position = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AttributeTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AttributeTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AttributeTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AttributeTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -632,7 +591,7 @@ abstract class Attribute implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 4; // 4 = AttributeTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 3; // 3 = AttributeTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\Attribute object", 0, $e); @@ -959,9 +918,6 @@ abstract class Attribute implements ActiveRecordInterface if ($this->isColumnModified(AttributeTableMap::ID)) { $modifiedColumns[':p' . $index++] = 'ID'; } - if ($this->isColumnModified(AttributeTableMap::POSITION)) { - $modifiedColumns[':p' . $index++] = 'POSITION'; - } if ($this->isColumnModified(AttributeTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } @@ -982,9 +938,6 @@ abstract class Attribute implements ActiveRecordInterface case 'ID': $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); break; - case 'POSITION': - $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); - break; case 'CREATED_AT': $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; @@ -1057,12 +1010,9 @@ abstract class Attribute implements ActiveRecordInterface return $this->getId(); break; case 1: - return $this->getPosition(); - break; - case 2: return $this->getCreatedAt(); break; - case 3: + case 2: return $this->getUpdatedAt(); break; default: @@ -1095,9 +1045,8 @@ abstract class Attribute implements ActiveRecordInterface $keys = AttributeTableMap::getFieldNames($keyType); $result = array( $keys[0] => $this->getId(), - $keys[1] => $this->getPosition(), - $keys[2] => $this->getCreatedAt(), - $keys[3] => $this->getUpdatedAt(), + $keys[1] => $this->getCreatedAt(), + $keys[2] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -1156,12 +1105,9 @@ abstract class Attribute implements ActiveRecordInterface $this->setId($value); break; case 1: - $this->setPosition($value); - break; - case 2: $this->setCreatedAt($value); break; - case 3: + case 2: $this->setUpdatedAt($value); break; } // switch() @@ -1189,9 +1135,8 @@ abstract class Attribute implements ActiveRecordInterface $keys = AttributeTableMap::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setPosition($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]); + if (array_key_exists($keys[1], $arr)) $this->setCreatedAt($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setUpdatedAt($arr[$keys[2]]); } /** @@ -1204,7 +1149,6 @@ abstract class Attribute implements ActiveRecordInterface $criteria = new Criteria(AttributeTableMap::DATABASE_NAME); if ($this->isColumnModified(AttributeTableMap::ID)) $criteria->add(AttributeTableMap::ID, $this->id); - if ($this->isColumnModified(AttributeTableMap::POSITION)) $criteria->add(AttributeTableMap::POSITION, $this->position); if ($this->isColumnModified(AttributeTableMap::CREATED_AT)) $criteria->add(AttributeTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(AttributeTableMap::UPDATED_AT)) $criteria->add(AttributeTableMap::UPDATED_AT, $this->updated_at); @@ -1270,7 +1214,6 @@ abstract class Attribute implements ActiveRecordInterface */ public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { - $copyObj->setPosition($this->getPosition()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); @@ -2504,7 +2447,6 @@ abstract class Attribute implements ActiveRecordInterface public function clear() { $this->id = null; - $this->position = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; diff --git a/core/lib/Thelia/Model/Base/AttributeQuery.php b/core/lib/Thelia/Model/Base/AttributeQuery.php index b496289f8..4a7fd6b20 100644 --- a/core/lib/Thelia/Model/Base/AttributeQuery.php +++ b/core/lib/Thelia/Model/Base/AttributeQuery.php @@ -23,12 +23,10 @@ use Thelia\Model\Map\AttributeTableMap; * * * @method ChildAttributeQuery orderById($order = Criteria::ASC) Order by the id column - * @method ChildAttributeQuery orderByPosition($order = Criteria::ASC) Order by the position column * @method ChildAttributeQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildAttributeQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * * @method ChildAttributeQuery groupById() Group by the id column - * @method ChildAttributeQuery groupByPosition() Group by the position column * @method ChildAttributeQuery groupByCreatedAt() Group by the created_at column * @method ChildAttributeQuery groupByUpdatedAt() Group by the updated_at column * @@ -56,12 +54,10 @@ use Thelia\Model\Map\AttributeTableMap; * @method ChildAttribute findOneOrCreate(ConnectionInterface $con = null) Return the first ChildAttribute matching the query, or a new ChildAttribute object populated from the query conditions when no match is found * * @method ChildAttribute findOneById(int $id) Return the first ChildAttribute filtered by the id column - * @method ChildAttribute findOneByPosition(int $position) Return the first ChildAttribute filtered by the position column * @method ChildAttribute findOneByCreatedAt(string $created_at) Return the first ChildAttribute filtered by the created_at column * @method ChildAttribute findOneByUpdatedAt(string $updated_at) Return the first ChildAttribute filtered by the updated_at column * * @method array findById(int $id) Return ChildAttribute objects filtered by the id column - * @method array findByPosition(int $position) Return ChildAttribute objects filtered by the position column * @method array findByCreatedAt(string $created_at) Return ChildAttribute objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildAttribute objects filtered by the updated_at column * @@ -152,7 +148,7 @@ abstract class AttributeQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, POSITION, CREATED_AT, UPDATED_AT FROM attribute WHERE ID = :p0'; + $sql = 'SELECT ID, CREATED_AT, UPDATED_AT FROM attribute WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -282,47 +278,6 @@ abstract class AttributeQuery extends ModelCriteria return $this->addUsingAlias(AttributeTableMap::ID, $id, $comparison); } - /** - * Filter the query on the position column - * - * Example usage: - * - * $query->filterByPosition(1234); // WHERE position = 1234 - * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) - * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 - * - * - * @param mixed $position 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 ChildAttributeQuery The current query, for fluid interface - */ - public function filterByPosition($position = null, $comparison = null) - { - if (is_array($position)) { - $useMinMax = false; - if (isset($position['min'])) { - $this->addUsingAlias(AttributeTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($position['max'])) { - $this->addUsingAlias(AttributeTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AttributeTableMap::POSITION, $position, $comparison); - } - /** * Filter the query on the created_at column * diff --git a/core/lib/Thelia/Model/Base/AttributeTemplate.php b/core/lib/Thelia/Model/Base/AttributeTemplate.php index cedc85431..0014e1a8d 100644 --- a/core/lib/Thelia/Model/Base/AttributeTemplate.php +++ b/core/lib/Thelia/Model/Base/AttributeTemplate.php @@ -76,6 +76,18 @@ abstract class AttributeTemplate implements ActiveRecordInterface */ protected $template_id; + /** + * The value for the position field. + * @var int + */ + protected $position; + + /** + * The value for the attribute_templatecol field. + * @var string + */ + protected $attribute_templatecol; + /** * The value for the created_at field. * @var string @@ -393,6 +405,28 @@ abstract class AttributeTemplate implements ActiveRecordInterface return $this->template_id; } + /** + * Get the [position] column value. + * + * @return int + */ + public function getPosition() + { + + return $this->position; + } + + /** + * Get the [attribute_templatecol] column value. + * + * @return string + */ + public function getAttributeTemplatecol() + { + + return $this->attribute_templatecol; + } + /** * Get the [optionally formatted] temporal [created_at] column value. * @@ -504,6 +538,48 @@ abstract class AttributeTemplate implements ActiveRecordInterface return $this; } // setTemplateId() + /** + * Set the value of [position] column. + * + * @param int $v new value + * @return \Thelia\Model\AttributeTemplate The current object (for fluent API support) + */ + public function setPosition($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->position !== $v) { + $this->position = $v; + $this->modifiedColumns[] = AttributeTemplateTableMap::POSITION; + } + + + return $this; + } // setPosition() + + /** + * Set the value of [attribute_templatecol] column. + * + * @param string $v new value + * @return \Thelia\Model\AttributeTemplate The current object (for fluent API support) + */ + public function setAttributeTemplatecol($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->attribute_templatecol !== $v) { + $this->attribute_templatecol = $v; + $this->modifiedColumns[] = AttributeTemplateTableMap::ATTRIBUTE_TEMPLATECOL; + } + + + return $this; + } // setAttributeTemplatecol() + /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. * @@ -592,13 +668,19 @@ abstract class AttributeTemplate implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AttributeTemplateTableMap::translateFieldName('TemplateId', TableMap::TYPE_PHPNAME, $indexType)]; $this->template_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AttributeTemplateTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AttributeTemplateTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $this->position = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : AttributeTemplateTableMap::translateFieldName('AttributeTemplatecol', TableMap::TYPE_PHPNAME, $indexType)]; + $this->attribute_templatecol = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : AttributeTemplateTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : AttributeTemplateTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : AttributeTemplateTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -611,7 +693,7 @@ abstract class AttributeTemplate implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 5; // 5 = AttributeTemplateTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 7; // 7 = AttributeTemplateTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\AttributeTemplate object", 0, $e); @@ -867,6 +949,12 @@ abstract class AttributeTemplate implements ActiveRecordInterface if ($this->isColumnModified(AttributeTemplateTableMap::TEMPLATE_ID)) { $modifiedColumns[':p' . $index++] = 'TEMPLATE_ID'; } + if ($this->isColumnModified(AttributeTemplateTableMap::POSITION)) { + $modifiedColumns[':p' . $index++] = 'POSITION'; + } + if ($this->isColumnModified(AttributeTemplateTableMap::ATTRIBUTE_TEMPLATECOL)) { + $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_TEMPLATECOL'; + } if ($this->isColumnModified(AttributeTemplateTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } @@ -893,6 +981,12 @@ abstract class AttributeTemplate implements ActiveRecordInterface case 'TEMPLATE_ID': $stmt->bindValue($identifier, $this->template_id, PDO::PARAM_INT); break; + case 'POSITION': + $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); + break; + case 'ATTRIBUTE_TEMPLATECOL': + $stmt->bindValue($identifier, $this->attribute_templatecol, PDO::PARAM_STR); + break; case 'CREATED_AT': $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; @@ -971,9 +1065,15 @@ abstract class AttributeTemplate implements ActiveRecordInterface return $this->getTemplateId(); break; case 3: - return $this->getCreatedAt(); + return $this->getPosition(); break; case 4: + return $this->getAttributeTemplatecol(); + break; + case 5: + return $this->getCreatedAt(); + break; + case 6: return $this->getUpdatedAt(); break; default: @@ -1008,8 +1108,10 @@ abstract class AttributeTemplate implements ActiveRecordInterface $keys[0] => $this->getId(), $keys[1] => $this->getAttributeId(), $keys[2] => $this->getTemplateId(), - $keys[3] => $this->getCreatedAt(), - $keys[4] => $this->getUpdatedAt(), + $keys[3] => $this->getPosition(), + $keys[4] => $this->getAttributeTemplatecol(), + $keys[5] => $this->getCreatedAt(), + $keys[6] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -1068,9 +1170,15 @@ abstract class AttributeTemplate implements ActiveRecordInterface $this->setTemplateId($value); break; case 3: - $this->setCreatedAt($value); + $this->setPosition($value); break; case 4: + $this->setAttributeTemplatecol($value); + break; + case 5: + $this->setCreatedAt($value); + break; + case 6: $this->setUpdatedAt($value); break; } // switch() @@ -1100,8 +1208,10 @@ abstract class AttributeTemplate implements ActiveRecordInterface if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setAttributeId($arr[$keys[1]]); if (array_key_exists($keys[2], $arr)) $this->setTemplateId($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]); + if (array_key_exists($keys[3], $arr)) $this->setPosition($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setAttributeTemplatecol($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]); } /** @@ -1116,6 +1226,8 @@ abstract class AttributeTemplate implements ActiveRecordInterface if ($this->isColumnModified(AttributeTemplateTableMap::ID)) $criteria->add(AttributeTemplateTableMap::ID, $this->id); if ($this->isColumnModified(AttributeTemplateTableMap::ATTRIBUTE_ID)) $criteria->add(AttributeTemplateTableMap::ATTRIBUTE_ID, $this->attribute_id); if ($this->isColumnModified(AttributeTemplateTableMap::TEMPLATE_ID)) $criteria->add(AttributeTemplateTableMap::TEMPLATE_ID, $this->template_id); + if ($this->isColumnModified(AttributeTemplateTableMap::POSITION)) $criteria->add(AttributeTemplateTableMap::POSITION, $this->position); + if ($this->isColumnModified(AttributeTemplateTableMap::ATTRIBUTE_TEMPLATECOL)) $criteria->add(AttributeTemplateTableMap::ATTRIBUTE_TEMPLATECOL, $this->attribute_templatecol); if ($this->isColumnModified(AttributeTemplateTableMap::CREATED_AT)) $criteria->add(AttributeTemplateTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(AttributeTemplateTableMap::UPDATED_AT)) $criteria->add(AttributeTemplateTableMap::UPDATED_AT, $this->updated_at); @@ -1183,6 +1295,8 @@ abstract class AttributeTemplate implements ActiveRecordInterface { $copyObj->setAttributeId($this->getAttributeId()); $copyObj->setTemplateId($this->getTemplateId()); + $copyObj->setPosition($this->getPosition()); + $copyObj->setAttributeTemplatecol($this->getAttributeTemplatecol()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); if ($makeNew) { @@ -1323,6 +1437,8 @@ abstract class AttributeTemplate implements ActiveRecordInterface $this->id = null; $this->attribute_id = null; $this->template_id = null; + $this->position = null; + $this->attribute_templatecol = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; diff --git a/core/lib/Thelia/Model/Base/AttributeTemplateQuery.php b/core/lib/Thelia/Model/Base/AttributeTemplateQuery.php index bd895360b..5e53ba738 100644 --- a/core/lib/Thelia/Model/Base/AttributeTemplateQuery.php +++ b/core/lib/Thelia/Model/Base/AttributeTemplateQuery.php @@ -24,12 +24,16 @@ use Thelia\Model\Map\AttributeTemplateTableMap; * @method ChildAttributeTemplateQuery orderById($order = Criteria::ASC) Order by the id column * @method ChildAttributeTemplateQuery orderByAttributeId($order = Criteria::ASC) Order by the attribute_id column * @method ChildAttributeTemplateQuery orderByTemplateId($order = Criteria::ASC) Order by the template_id column + * @method ChildAttributeTemplateQuery orderByPosition($order = Criteria::ASC) Order by the position column + * @method ChildAttributeTemplateQuery orderByAttributeTemplatecol($order = Criteria::ASC) Order by the attribute_templatecol column * @method ChildAttributeTemplateQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildAttributeTemplateQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * * @method ChildAttributeTemplateQuery groupById() Group by the id column * @method ChildAttributeTemplateQuery groupByAttributeId() Group by the attribute_id column * @method ChildAttributeTemplateQuery groupByTemplateId() Group by the template_id column + * @method ChildAttributeTemplateQuery groupByPosition() Group by the position column + * @method ChildAttributeTemplateQuery groupByAttributeTemplatecol() Group by the attribute_templatecol column * @method ChildAttributeTemplateQuery groupByCreatedAt() Group by the created_at column * @method ChildAttributeTemplateQuery groupByUpdatedAt() Group by the updated_at column * @@ -51,12 +55,16 @@ use Thelia\Model\Map\AttributeTemplateTableMap; * @method ChildAttributeTemplate findOneById(int $id) Return the first ChildAttributeTemplate filtered by the id column * @method ChildAttributeTemplate findOneByAttributeId(int $attribute_id) Return the first ChildAttributeTemplate filtered by the attribute_id column * @method ChildAttributeTemplate findOneByTemplateId(int $template_id) Return the first ChildAttributeTemplate filtered by the template_id column + * @method ChildAttributeTemplate findOneByPosition(int $position) Return the first ChildAttributeTemplate filtered by the position column + * @method ChildAttributeTemplate findOneByAttributeTemplatecol(string $attribute_templatecol) Return the first ChildAttributeTemplate filtered by the attribute_templatecol column * @method ChildAttributeTemplate findOneByCreatedAt(string $created_at) Return the first ChildAttributeTemplate filtered by the created_at column * @method ChildAttributeTemplate findOneByUpdatedAt(string $updated_at) Return the first ChildAttributeTemplate filtered by the updated_at column * * @method array findById(int $id) Return ChildAttributeTemplate objects filtered by the id column * @method array findByAttributeId(int $attribute_id) Return ChildAttributeTemplate objects filtered by the attribute_id column * @method array findByTemplateId(int $template_id) Return ChildAttributeTemplate objects filtered by the template_id column + * @method array findByPosition(int $position) Return ChildAttributeTemplate objects filtered by the position column + * @method array findByAttributeTemplatecol(string $attribute_templatecol) Return ChildAttributeTemplate objects filtered by the attribute_templatecol column * @method array findByCreatedAt(string $created_at) Return ChildAttributeTemplate objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildAttributeTemplate objects filtered by the updated_at column * @@ -147,7 +155,7 @@ abstract class AttributeTemplateQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, ATTRIBUTE_ID, TEMPLATE_ID, CREATED_AT, UPDATED_AT FROM attribute_template WHERE ID = :p0'; + $sql = 'SELECT ID, ATTRIBUTE_ID, TEMPLATE_ID, POSITION, ATTRIBUTE_TEMPLATECOL, CREATED_AT, UPDATED_AT FROM attribute_template WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -363,6 +371,76 @@ abstract class AttributeTemplateQuery extends ModelCriteria return $this->addUsingAlias(AttributeTemplateTableMap::TEMPLATE_ID, $templateId, $comparison); } + /** + * Filter the query on the position column + * + * Example usage: + * + * $query->filterByPosition(1234); // WHERE position = 1234 + * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) + * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 + * + * + * @param mixed $position 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 ChildAttributeTemplateQuery The current query, for fluid interface + */ + public function filterByPosition($position = null, $comparison = null) + { + if (is_array($position)) { + $useMinMax = false; + if (isset($position['min'])) { + $this->addUsingAlias(AttributeTemplateTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($position['max'])) { + $this->addUsingAlias(AttributeTemplateTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(AttributeTemplateTableMap::POSITION, $position, $comparison); + } + + /** + * Filter the query on the attribute_templatecol column + * + * Example usage: + * + * $query->filterByAttributeTemplatecol('fooValue'); // WHERE attribute_templatecol = 'fooValue' + * $query->filterByAttributeTemplatecol('%fooValue%'); // WHERE attribute_templatecol LIKE '%fooValue%' + * + * + * @param string $attributeTemplatecol The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildAttributeTemplateQuery The current query, for fluid interface + */ + public function filterByAttributeTemplatecol($attributeTemplatecol = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($attributeTemplatecol)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $attributeTemplatecol)) { + $attributeTemplatecol = str_replace('*', '%', $attributeTemplatecol); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(AttributeTemplateTableMap::ATTRIBUTE_TEMPLATECOL, $attributeTemplatecol, $comparison); + } + /** * Filter the query on the created_at column * diff --git a/core/lib/Thelia/Model/Base/Feature.php b/core/lib/Thelia/Model/Base/Feature.php index c9b6c5ed4..f771674e1 100644 --- a/core/lib/Thelia/Model/Base/Feature.php +++ b/core/lib/Thelia/Model/Base/Feature.php @@ -78,12 +78,6 @@ abstract class Feature implements ActiveRecordInterface */ protected $visible; - /** - * The value for the position field. - * @var int - */ - protected $position; - /** * The value for the created_at field. * @var string @@ -466,17 +460,6 @@ abstract class Feature implements ActiveRecordInterface return $this->visible; } - /** - * Get the [position] column value. - * - * @return int - */ - public function getPosition() - { - - return $this->position; - } - /** * Get the [optionally formatted] temporal [created_at] column value. * @@ -559,27 +542,6 @@ abstract class Feature implements ActiveRecordInterface return $this; } // setVisible() - /** - * Set the value of [position] column. - * - * @param int $v new value - * @return \Thelia\Model\Feature The current object (for fluent API support) - */ - public function setPosition($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->position !== $v) { - $this->position = $v; - $this->modifiedColumns[] = FeatureTableMap::POSITION; - } - - - return $this; - } // setPosition() - /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. * @@ -669,16 +631,13 @@ abstract class Feature implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : FeatureTableMap::translateFieldName('Visible', TableMap::TYPE_PHPNAME, $indexType)]; $this->visible = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : FeatureTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; - $this->position = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : FeatureTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : FeatureTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : FeatureTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : FeatureTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -691,7 +650,7 @@ abstract class Feature implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 5; // 5 = FeatureTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 4; // 4 = FeatureTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\Feature object", 0, $e); @@ -1021,9 +980,6 @@ abstract class Feature implements ActiveRecordInterface if ($this->isColumnModified(FeatureTableMap::VISIBLE)) { $modifiedColumns[':p' . $index++] = 'VISIBLE'; } - if ($this->isColumnModified(FeatureTableMap::POSITION)) { - $modifiedColumns[':p' . $index++] = 'POSITION'; - } if ($this->isColumnModified(FeatureTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } @@ -1047,9 +1003,6 @@ abstract class Feature implements ActiveRecordInterface case 'VISIBLE': $stmt->bindValue($identifier, $this->visible, PDO::PARAM_INT); break; - case 'POSITION': - $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); - break; case 'CREATED_AT': $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; @@ -1125,12 +1078,9 @@ abstract class Feature implements ActiveRecordInterface return $this->getVisible(); break; case 2: - return $this->getPosition(); - break; - case 3: return $this->getCreatedAt(); break; - case 4: + case 3: return $this->getUpdatedAt(); break; default: @@ -1164,9 +1114,8 @@ abstract class Feature implements ActiveRecordInterface $result = array( $keys[0] => $this->getId(), $keys[1] => $this->getVisible(), - $keys[2] => $this->getPosition(), - $keys[3] => $this->getCreatedAt(), - $keys[4] => $this->getUpdatedAt(), + $keys[2] => $this->getCreatedAt(), + $keys[3] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -1228,12 +1177,9 @@ abstract class Feature implements ActiveRecordInterface $this->setVisible($value); break; case 2: - $this->setPosition($value); - break; - case 3: $this->setCreatedAt($value); break; - case 4: + case 3: $this->setUpdatedAt($value); break; } // switch() @@ -1262,9 +1208,8 @@ abstract class Feature implements ActiveRecordInterface if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setVisible($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setPosition($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]); + if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]); } /** @@ -1278,7 +1223,6 @@ abstract class Feature implements ActiveRecordInterface if ($this->isColumnModified(FeatureTableMap::ID)) $criteria->add(FeatureTableMap::ID, $this->id); if ($this->isColumnModified(FeatureTableMap::VISIBLE)) $criteria->add(FeatureTableMap::VISIBLE, $this->visible); - if ($this->isColumnModified(FeatureTableMap::POSITION)) $criteria->add(FeatureTableMap::POSITION, $this->position); if ($this->isColumnModified(FeatureTableMap::CREATED_AT)) $criteria->add(FeatureTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(FeatureTableMap::UPDATED_AT)) $criteria->add(FeatureTableMap::UPDATED_AT, $this->updated_at); @@ -1345,7 +1289,6 @@ abstract class Feature implements ActiveRecordInterface public function copyInto($copyObj, $deepCopy = false, $makeNew = true) { $copyObj->setVisible($this->getVisible()); - $copyObj->setPosition($this->getPosition()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); @@ -2577,7 +2520,6 @@ abstract class Feature implements ActiveRecordInterface { $this->id = null; $this->visible = null; - $this->position = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; diff --git a/core/lib/Thelia/Model/Base/FeatureProduct.php b/core/lib/Thelia/Model/Base/FeatureProduct.php index 4af200d51..039967cee 100644 --- a/core/lib/Thelia/Model/Base/FeatureProduct.php +++ b/core/lib/Thelia/Model/Base/FeatureProduct.php @@ -85,10 +85,10 @@ abstract class FeatureProduct implements ActiveRecordInterface protected $feature_av_id; /** - * The value for the by_default field. + * The value for the free_text_value field. * @var string */ - protected $by_default; + protected $free_text_value; /** * The value for the position field. @@ -430,14 +430,14 @@ abstract class FeatureProduct implements ActiveRecordInterface } /** - * Get the [by_default] column value. + * Get the [free_text_value] column value. * * @return string */ - public function getByDefault() + public function getFreeTextValue() { - return $this->by_default; + return $this->free_text_value; } /** @@ -588,25 +588,25 @@ abstract class FeatureProduct implements ActiveRecordInterface } // setFeatureAvId() /** - * Set the value of [by_default] column. + * Set the value of [free_text_value] column. * * @param string $v new value * @return \Thelia\Model\FeatureProduct The current object (for fluent API support) */ - public function setByDefault($v) + public function setFreeTextValue($v) { if ($v !== null) { $v = (string) $v; } - if ($this->by_default !== $v) { - $this->by_default = $v; - $this->modifiedColumns[] = FeatureProductTableMap::BY_DEFAULT; + if ($this->free_text_value !== $v) { + $this->free_text_value = $v; + $this->modifiedColumns[] = FeatureProductTableMap::FREE_TEXT_VALUE; } return $this; - } // setByDefault() + } // setFreeTextValue() /** * Set the value of [position] column. @@ -720,8 +720,8 @@ abstract class FeatureProduct implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : FeatureProductTableMap::translateFieldName('FeatureAvId', TableMap::TYPE_PHPNAME, $indexType)]; $this->feature_av_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : FeatureProductTableMap::translateFieldName('ByDefault', TableMap::TYPE_PHPNAME, $indexType)]; - $this->by_default = (null !== $col) ? (string) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : FeatureProductTableMap::translateFieldName('FreeTextValue', TableMap::TYPE_PHPNAME, $indexType)]; + $this->free_text_value = (null !== $col) ? (string) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : FeatureProductTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; $this->position = (null !== $col) ? (int) $col : null; @@ -1015,8 +1015,8 @@ abstract class FeatureProduct implements ActiveRecordInterface if ($this->isColumnModified(FeatureProductTableMap::FEATURE_AV_ID)) { $modifiedColumns[':p' . $index++] = 'FEATURE_AV_ID'; } - if ($this->isColumnModified(FeatureProductTableMap::BY_DEFAULT)) { - $modifiedColumns[':p' . $index++] = 'BY_DEFAULT'; + if ($this->isColumnModified(FeatureProductTableMap::FREE_TEXT_VALUE)) { + $modifiedColumns[':p' . $index++] = 'FREE_TEXT_VALUE'; } if ($this->isColumnModified(FeatureProductTableMap::POSITION)) { $modifiedColumns[':p' . $index++] = 'POSITION'; @@ -1050,8 +1050,8 @@ abstract class FeatureProduct implements ActiveRecordInterface case 'FEATURE_AV_ID': $stmt->bindValue($identifier, $this->feature_av_id, PDO::PARAM_INT); break; - case 'BY_DEFAULT': - $stmt->bindValue($identifier, $this->by_default, PDO::PARAM_STR); + case 'FREE_TEXT_VALUE': + $stmt->bindValue($identifier, $this->free_text_value, PDO::PARAM_STR); break; case 'POSITION': $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); @@ -1137,7 +1137,7 @@ abstract class FeatureProduct implements ActiveRecordInterface return $this->getFeatureAvId(); break; case 4: - return $this->getByDefault(); + return $this->getFreeTextValue(); break; case 5: return $this->getPosition(); @@ -1181,7 +1181,7 @@ abstract class FeatureProduct implements ActiveRecordInterface $keys[1] => $this->getProductId(), $keys[2] => $this->getFeatureId(), $keys[3] => $this->getFeatureAvId(), - $keys[4] => $this->getByDefault(), + $keys[4] => $this->getFreeTextValue(), $keys[5] => $this->getPosition(), $keys[6] => $this->getCreatedAt(), $keys[7] => $this->getUpdatedAt(), @@ -1249,7 +1249,7 @@ abstract class FeatureProduct implements ActiveRecordInterface $this->setFeatureAvId($value); break; case 4: - $this->setByDefault($value); + $this->setFreeTextValue($value); break; case 5: $this->setPosition($value); @@ -1288,7 +1288,7 @@ abstract class FeatureProduct implements ActiveRecordInterface if (array_key_exists($keys[1], $arr)) $this->setProductId($arr[$keys[1]]); if (array_key_exists($keys[2], $arr)) $this->setFeatureId($arr[$keys[2]]); if (array_key_exists($keys[3], $arr)) $this->setFeatureAvId($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setByDefault($arr[$keys[4]]); + if (array_key_exists($keys[4], $arr)) $this->setFreeTextValue($arr[$keys[4]]); if (array_key_exists($keys[5], $arr)) $this->setPosition($arr[$keys[5]]); if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]); if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]); @@ -1307,7 +1307,7 @@ abstract class FeatureProduct implements ActiveRecordInterface if ($this->isColumnModified(FeatureProductTableMap::PRODUCT_ID)) $criteria->add(FeatureProductTableMap::PRODUCT_ID, $this->product_id); if ($this->isColumnModified(FeatureProductTableMap::FEATURE_ID)) $criteria->add(FeatureProductTableMap::FEATURE_ID, $this->feature_id); if ($this->isColumnModified(FeatureProductTableMap::FEATURE_AV_ID)) $criteria->add(FeatureProductTableMap::FEATURE_AV_ID, $this->feature_av_id); - if ($this->isColumnModified(FeatureProductTableMap::BY_DEFAULT)) $criteria->add(FeatureProductTableMap::BY_DEFAULT, $this->by_default); + if ($this->isColumnModified(FeatureProductTableMap::FREE_TEXT_VALUE)) $criteria->add(FeatureProductTableMap::FREE_TEXT_VALUE, $this->free_text_value); if ($this->isColumnModified(FeatureProductTableMap::POSITION)) $criteria->add(FeatureProductTableMap::POSITION, $this->position); if ($this->isColumnModified(FeatureProductTableMap::CREATED_AT)) $criteria->add(FeatureProductTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(FeatureProductTableMap::UPDATED_AT)) $criteria->add(FeatureProductTableMap::UPDATED_AT, $this->updated_at); @@ -1377,7 +1377,7 @@ abstract class FeatureProduct implements ActiveRecordInterface $copyObj->setProductId($this->getProductId()); $copyObj->setFeatureId($this->getFeatureId()); $copyObj->setFeatureAvId($this->getFeatureAvId()); - $copyObj->setByDefault($this->getByDefault()); + $copyObj->setFreeTextValue($this->getFreeTextValue()); $copyObj->setPosition($this->getPosition()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); @@ -1571,7 +1571,7 @@ abstract class FeatureProduct implements ActiveRecordInterface $this->product_id = null; $this->feature_id = null; $this->feature_av_id = null; - $this->by_default = null; + $this->free_text_value = null; $this->position = null; $this->created_at = null; $this->updated_at = null; diff --git a/core/lib/Thelia/Model/Base/FeatureProductQuery.php b/core/lib/Thelia/Model/Base/FeatureProductQuery.php index c6a8f2a73..eb2ee7ec1 100644 --- a/core/lib/Thelia/Model/Base/FeatureProductQuery.php +++ b/core/lib/Thelia/Model/Base/FeatureProductQuery.php @@ -25,7 +25,7 @@ use Thelia\Model\Map\FeatureProductTableMap; * @method ChildFeatureProductQuery orderByProductId($order = Criteria::ASC) Order by the product_id column * @method ChildFeatureProductQuery orderByFeatureId($order = Criteria::ASC) Order by the feature_id column * @method ChildFeatureProductQuery orderByFeatureAvId($order = Criteria::ASC) Order by the feature_av_id column - * @method ChildFeatureProductQuery orderByByDefault($order = Criteria::ASC) Order by the by_default column + * @method ChildFeatureProductQuery orderByFreeTextValue($order = Criteria::ASC) Order by the free_text_value column * @method ChildFeatureProductQuery orderByPosition($order = Criteria::ASC) Order by the position column * @method ChildFeatureProductQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildFeatureProductQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column @@ -34,7 +34,7 @@ use Thelia\Model\Map\FeatureProductTableMap; * @method ChildFeatureProductQuery groupByProductId() Group by the product_id column * @method ChildFeatureProductQuery groupByFeatureId() Group by the feature_id column * @method ChildFeatureProductQuery groupByFeatureAvId() Group by the feature_av_id column - * @method ChildFeatureProductQuery groupByByDefault() Group by the by_default column + * @method ChildFeatureProductQuery groupByFreeTextValue() Group by the free_text_value column * @method ChildFeatureProductQuery groupByPosition() Group by the position column * @method ChildFeatureProductQuery groupByCreatedAt() Group by the created_at column * @method ChildFeatureProductQuery groupByUpdatedAt() Group by the updated_at column @@ -62,7 +62,7 @@ use Thelia\Model\Map\FeatureProductTableMap; * @method ChildFeatureProduct findOneByProductId(int $product_id) Return the first ChildFeatureProduct filtered by the product_id column * @method ChildFeatureProduct findOneByFeatureId(int $feature_id) Return the first ChildFeatureProduct filtered by the feature_id column * @method ChildFeatureProduct findOneByFeatureAvId(int $feature_av_id) Return the first ChildFeatureProduct filtered by the feature_av_id column - * @method ChildFeatureProduct findOneByByDefault(string $by_default) Return the first ChildFeatureProduct filtered by the by_default column + * @method ChildFeatureProduct findOneByFreeTextValue(string $free_text_value) Return the first ChildFeatureProduct filtered by the free_text_value column * @method ChildFeatureProduct findOneByPosition(int $position) Return the first ChildFeatureProduct filtered by the position column * @method ChildFeatureProduct findOneByCreatedAt(string $created_at) Return the first ChildFeatureProduct filtered by the created_at column * @method ChildFeatureProduct findOneByUpdatedAt(string $updated_at) Return the first ChildFeatureProduct filtered by the updated_at column @@ -71,7 +71,7 @@ use Thelia\Model\Map\FeatureProductTableMap; * @method array findByProductId(int $product_id) Return ChildFeatureProduct objects filtered by the product_id column * @method array findByFeatureId(int $feature_id) Return ChildFeatureProduct objects filtered by the feature_id column * @method array findByFeatureAvId(int $feature_av_id) Return ChildFeatureProduct objects filtered by the feature_av_id column - * @method array findByByDefault(string $by_default) Return ChildFeatureProduct objects filtered by the by_default column + * @method array findByFreeTextValue(string $free_text_value) Return ChildFeatureProduct objects filtered by the free_text_value column * @method array findByPosition(int $position) Return ChildFeatureProduct objects filtered by the position column * @method array findByCreatedAt(string $created_at) Return ChildFeatureProduct objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildFeatureProduct objects filtered by the updated_at column @@ -163,7 +163,7 @@ abstract class FeatureProductQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, PRODUCT_ID, FEATURE_ID, FEATURE_AV_ID, BY_DEFAULT, POSITION, CREATED_AT, UPDATED_AT FROM feature_product WHERE ID = :p0'; + $sql = 'SELECT ID, PRODUCT_ID, FEATURE_ID, FEATURE_AV_ID, FREE_TEXT_VALUE, POSITION, CREATED_AT, UPDATED_AT FROM feature_product WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -423,32 +423,32 @@ abstract class FeatureProductQuery extends ModelCriteria } /** - * Filter the query on the by_default column + * Filter the query on the free_text_value column * * Example usage: * - * $query->filterByByDefault('fooValue'); // WHERE by_default = 'fooValue' - * $query->filterByByDefault('%fooValue%'); // WHERE by_default LIKE '%fooValue%' + * $query->filterByFreeTextValue('fooValue'); // WHERE free_text_value = 'fooValue' + * $query->filterByFreeTextValue('%fooValue%'); // WHERE free_text_value LIKE '%fooValue%' * * - * @param string $byDefault The value to use as filter. + * @param string $freeTextValue The value to use as filter. * Accepts wildcards (* and % trigger a LIKE) * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildFeatureProductQuery The current query, for fluid interface */ - public function filterByByDefault($byDefault = null, $comparison = null) + public function filterByFreeTextValue($freeTextValue = null, $comparison = null) { if (null === $comparison) { - if (is_array($byDefault)) { + if (is_array($freeTextValue)) { $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $byDefault)) { - $byDefault = str_replace('*', '%', $byDefault); + } elseif (preg_match('/[\%\*]/', $freeTextValue)) { + $freeTextValue = str_replace('*', '%', $freeTextValue); $comparison = Criteria::LIKE; } } - return $this->addUsingAlias(FeatureProductTableMap::BY_DEFAULT, $byDefault, $comparison); + return $this->addUsingAlias(FeatureProductTableMap::FREE_TEXT_VALUE, $freeTextValue, $comparison); } /** diff --git a/core/lib/Thelia/Model/Base/FeatureQuery.php b/core/lib/Thelia/Model/Base/FeatureQuery.php index 097646c87..93004f3e6 100644 --- a/core/lib/Thelia/Model/Base/FeatureQuery.php +++ b/core/lib/Thelia/Model/Base/FeatureQuery.php @@ -24,13 +24,11 @@ use Thelia\Model\Map\FeatureTableMap; * * @method ChildFeatureQuery orderById($order = Criteria::ASC) Order by the id column * @method ChildFeatureQuery orderByVisible($order = Criteria::ASC) Order by the visible column - * @method ChildFeatureQuery orderByPosition($order = Criteria::ASC) Order by the position column * @method ChildFeatureQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildFeatureQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * * @method ChildFeatureQuery groupById() Group by the id column * @method ChildFeatureQuery groupByVisible() Group by the visible column - * @method ChildFeatureQuery groupByPosition() Group by the position column * @method ChildFeatureQuery groupByCreatedAt() Group by the created_at column * @method ChildFeatureQuery groupByUpdatedAt() Group by the updated_at column * @@ -59,13 +57,11 @@ use Thelia\Model\Map\FeatureTableMap; * * @method ChildFeature findOneById(int $id) Return the first ChildFeature filtered by the id column * @method ChildFeature findOneByVisible(int $visible) Return the first ChildFeature filtered by the visible column - * @method ChildFeature findOneByPosition(int $position) Return the first ChildFeature filtered by the position column * @method ChildFeature findOneByCreatedAt(string $created_at) Return the first ChildFeature filtered by the created_at column * @method ChildFeature findOneByUpdatedAt(string $updated_at) Return the first ChildFeature filtered by the updated_at column * * @method array findById(int $id) Return ChildFeature objects filtered by the id column * @method array findByVisible(int $visible) Return ChildFeature objects filtered by the visible column - * @method array findByPosition(int $position) Return ChildFeature objects filtered by the position column * @method array findByCreatedAt(string $created_at) Return ChildFeature objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildFeature objects filtered by the updated_at column * @@ -156,7 +152,7 @@ abstract class FeatureQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, VISIBLE, POSITION, CREATED_AT, UPDATED_AT FROM feature WHERE ID = :p0'; + $sql = 'SELECT ID, VISIBLE, CREATED_AT, UPDATED_AT FROM feature WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -327,47 +323,6 @@ abstract class FeatureQuery extends ModelCriteria return $this->addUsingAlias(FeatureTableMap::VISIBLE, $visible, $comparison); } - /** - * Filter the query on the position column - * - * Example usage: - * - * $query->filterByPosition(1234); // WHERE position = 1234 - * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) - * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 - * - * - * @param mixed $position 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 ChildFeatureQuery The current query, for fluid interface - */ - public function filterByPosition($position = null, $comparison = null) - { - if (is_array($position)) { - $useMinMax = false; - if (isset($position['min'])) { - $this->addUsingAlias(FeatureTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($position['max'])) { - $this->addUsingAlias(FeatureTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(FeatureTableMap::POSITION, $position, $comparison); - } - /** * Filter the query on the created_at column * diff --git a/core/lib/Thelia/Model/Base/FeatureTemplate.php b/core/lib/Thelia/Model/Base/FeatureTemplate.php index bbccd9251..b8ba55629 100644 --- a/core/lib/Thelia/Model/Base/FeatureTemplate.php +++ b/core/lib/Thelia/Model/Base/FeatureTemplate.php @@ -76,6 +76,12 @@ abstract class FeatureTemplate implements ActiveRecordInterface */ protected $template_id; + /** + * The value for the position field. + * @var int + */ + protected $position; + /** * The value for the created_at field. * @var string @@ -393,6 +399,17 @@ abstract class FeatureTemplate implements ActiveRecordInterface return $this->template_id; } + /** + * Get the [position] column value. + * + * @return int + */ + public function getPosition() + { + + return $this->position; + } + /** * Get the [optionally formatted] temporal [created_at] column value. * @@ -504,6 +521,27 @@ abstract class FeatureTemplate implements ActiveRecordInterface return $this; } // setTemplateId() + /** + * Set the value of [position] column. + * + * @param int $v new value + * @return \Thelia\Model\FeatureTemplate The current object (for fluent API support) + */ + public function setPosition($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->position !== $v) { + $this->position = $v; + $this->modifiedColumns[] = FeatureTemplateTableMap::POSITION; + } + + + return $this; + } // setPosition() + /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. * @@ -592,13 +630,16 @@ abstract class FeatureTemplate implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : FeatureTemplateTableMap::translateFieldName('TemplateId', TableMap::TYPE_PHPNAME, $indexType)]; $this->template_id = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : FeatureTemplateTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : FeatureTemplateTableMap::translateFieldName('Position', TableMap::TYPE_PHPNAME, $indexType)]; + $this->position = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : FeatureTemplateTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : FeatureTemplateTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : FeatureTemplateTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -611,7 +652,7 @@ abstract class FeatureTemplate implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 5; // 5 = FeatureTemplateTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 6; // 6 = FeatureTemplateTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\FeatureTemplate object", 0, $e); @@ -867,6 +908,9 @@ abstract class FeatureTemplate implements ActiveRecordInterface if ($this->isColumnModified(FeatureTemplateTableMap::TEMPLATE_ID)) { $modifiedColumns[':p' . $index++] = 'TEMPLATE_ID'; } + if ($this->isColumnModified(FeatureTemplateTableMap::POSITION)) { + $modifiedColumns[':p' . $index++] = 'POSITION'; + } if ($this->isColumnModified(FeatureTemplateTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } @@ -893,6 +937,9 @@ abstract class FeatureTemplate implements ActiveRecordInterface case 'TEMPLATE_ID': $stmt->bindValue($identifier, $this->template_id, PDO::PARAM_INT); break; + case 'POSITION': + $stmt->bindValue($identifier, $this->position, PDO::PARAM_INT); + break; case 'CREATED_AT': $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; @@ -971,9 +1018,12 @@ abstract class FeatureTemplate implements ActiveRecordInterface return $this->getTemplateId(); break; case 3: - return $this->getCreatedAt(); + return $this->getPosition(); break; case 4: + return $this->getCreatedAt(); + break; + case 5: return $this->getUpdatedAt(); break; default: @@ -1008,8 +1058,9 @@ abstract class FeatureTemplate implements ActiveRecordInterface $keys[0] => $this->getId(), $keys[1] => $this->getFeatureId(), $keys[2] => $this->getTemplateId(), - $keys[3] => $this->getCreatedAt(), - $keys[4] => $this->getUpdatedAt(), + $keys[3] => $this->getPosition(), + $keys[4] => $this->getCreatedAt(), + $keys[5] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -1068,9 +1119,12 @@ abstract class FeatureTemplate implements ActiveRecordInterface $this->setTemplateId($value); break; case 3: - $this->setCreatedAt($value); + $this->setPosition($value); break; case 4: + $this->setCreatedAt($value); + break; + case 5: $this->setUpdatedAt($value); break; } // switch() @@ -1100,8 +1154,9 @@ abstract class FeatureTemplate implements ActiveRecordInterface if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setFeatureId($arr[$keys[1]]); if (array_key_exists($keys[2], $arr)) $this->setTemplateId($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]); + if (array_key_exists($keys[3], $arr)) $this->setPosition($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]); } /** @@ -1116,6 +1171,7 @@ abstract class FeatureTemplate implements ActiveRecordInterface if ($this->isColumnModified(FeatureTemplateTableMap::ID)) $criteria->add(FeatureTemplateTableMap::ID, $this->id); if ($this->isColumnModified(FeatureTemplateTableMap::FEATURE_ID)) $criteria->add(FeatureTemplateTableMap::FEATURE_ID, $this->feature_id); if ($this->isColumnModified(FeatureTemplateTableMap::TEMPLATE_ID)) $criteria->add(FeatureTemplateTableMap::TEMPLATE_ID, $this->template_id); + if ($this->isColumnModified(FeatureTemplateTableMap::POSITION)) $criteria->add(FeatureTemplateTableMap::POSITION, $this->position); if ($this->isColumnModified(FeatureTemplateTableMap::CREATED_AT)) $criteria->add(FeatureTemplateTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(FeatureTemplateTableMap::UPDATED_AT)) $criteria->add(FeatureTemplateTableMap::UPDATED_AT, $this->updated_at); @@ -1183,6 +1239,7 @@ abstract class FeatureTemplate implements ActiveRecordInterface { $copyObj->setFeatureId($this->getFeatureId()); $copyObj->setTemplateId($this->getTemplateId()); + $copyObj->setPosition($this->getPosition()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); if ($makeNew) { @@ -1323,6 +1380,7 @@ abstract class FeatureTemplate implements ActiveRecordInterface $this->id = null; $this->feature_id = null; $this->template_id = null; + $this->position = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; diff --git a/core/lib/Thelia/Model/Base/FeatureTemplateQuery.php b/core/lib/Thelia/Model/Base/FeatureTemplateQuery.php index c99c1305f..cccad15ae 100644 --- a/core/lib/Thelia/Model/Base/FeatureTemplateQuery.php +++ b/core/lib/Thelia/Model/Base/FeatureTemplateQuery.php @@ -24,12 +24,14 @@ use Thelia\Model\Map\FeatureTemplateTableMap; * @method ChildFeatureTemplateQuery orderById($order = Criteria::ASC) Order by the id column * @method ChildFeatureTemplateQuery orderByFeatureId($order = Criteria::ASC) Order by the feature_id column * @method ChildFeatureTemplateQuery orderByTemplateId($order = Criteria::ASC) Order by the template_id column + * @method ChildFeatureTemplateQuery orderByPosition($order = Criteria::ASC) Order by the position column * @method ChildFeatureTemplateQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildFeatureTemplateQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * * @method ChildFeatureTemplateQuery groupById() Group by the id column * @method ChildFeatureTemplateQuery groupByFeatureId() Group by the feature_id column * @method ChildFeatureTemplateQuery groupByTemplateId() Group by the template_id column + * @method ChildFeatureTemplateQuery groupByPosition() Group by the position column * @method ChildFeatureTemplateQuery groupByCreatedAt() Group by the created_at column * @method ChildFeatureTemplateQuery groupByUpdatedAt() Group by the updated_at column * @@ -51,12 +53,14 @@ use Thelia\Model\Map\FeatureTemplateTableMap; * @method ChildFeatureTemplate findOneById(int $id) Return the first ChildFeatureTemplate filtered by the id column * @method ChildFeatureTemplate findOneByFeatureId(int $feature_id) Return the first ChildFeatureTemplate filtered by the feature_id column * @method ChildFeatureTemplate findOneByTemplateId(int $template_id) Return the first ChildFeatureTemplate filtered by the template_id column + * @method ChildFeatureTemplate findOneByPosition(int $position) Return the first ChildFeatureTemplate filtered by the position column * @method ChildFeatureTemplate findOneByCreatedAt(string $created_at) Return the first ChildFeatureTemplate filtered by the created_at column * @method ChildFeatureTemplate findOneByUpdatedAt(string $updated_at) Return the first ChildFeatureTemplate filtered by the updated_at column * * @method array findById(int $id) Return ChildFeatureTemplate objects filtered by the id column * @method array findByFeatureId(int $feature_id) Return ChildFeatureTemplate objects filtered by the feature_id column * @method array findByTemplateId(int $template_id) Return ChildFeatureTemplate objects filtered by the template_id column + * @method array findByPosition(int $position) Return ChildFeatureTemplate objects filtered by the position column * @method array findByCreatedAt(string $created_at) Return ChildFeatureTemplate objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildFeatureTemplate objects filtered by the updated_at column * @@ -147,7 +151,7 @@ abstract class FeatureTemplateQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, FEATURE_ID, TEMPLATE_ID, CREATED_AT, UPDATED_AT FROM feature_template WHERE ID = :p0'; + $sql = 'SELECT ID, FEATURE_ID, TEMPLATE_ID, POSITION, CREATED_AT, UPDATED_AT FROM feature_template WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -363,6 +367,47 @@ abstract class FeatureTemplateQuery extends ModelCriteria return $this->addUsingAlias(FeatureTemplateTableMap::TEMPLATE_ID, $templateId, $comparison); } + /** + * Filter the query on the position column + * + * Example usage: + * + * $query->filterByPosition(1234); // WHERE position = 1234 + * $query->filterByPosition(array(12, 34)); // WHERE position IN (12, 34) + * $query->filterByPosition(array('min' => 12)); // WHERE position > 12 + * + * + * @param mixed $position 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 ChildFeatureTemplateQuery The current query, for fluid interface + */ + public function filterByPosition($position = null, $comparison = null) + { + if (is_array($position)) { + $useMinMax = false; + if (isset($position['min'])) { + $this->addUsingAlias(FeatureTemplateTableMap::POSITION, $position['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($position['max'])) { + $this->addUsingAlias(FeatureTemplateTableMap::POSITION, $position['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(FeatureTemplateTableMap::POSITION, $position, $comparison); + } + /** * Filter the query on the created_at column * diff --git a/core/lib/Thelia/Model/Base/OrderProductAttributeCombination.php b/core/lib/Thelia/Model/Base/OrderProductAttributeCombination.php index e02bc9cc5..971f127b6 100644 --- a/core/lib/Thelia/Model/Base/OrderProductAttributeCombination.php +++ b/core/lib/Thelia/Model/Base/OrderProductAttributeCombination.php @@ -87,10 +87,10 @@ abstract class OrderProductAttributeCombination implements ActiveRecordInterface protected $attribute_description; /** - * The value for the attribute_postscriptumn field. + * The value for the attribute_postscriptum field. * @var string */ - protected $attribute_postscriptumn; + protected $attribute_postscriptum; /** * The value for the attribute_av_title field. @@ -451,14 +451,14 @@ abstract class OrderProductAttributeCombination implements ActiveRecordInterface } /** - * Get the [attribute_postscriptumn] column value. + * Get the [attribute_postscriptum] column value. * * @return string */ - public function getAttributePostscriptumn() + public function getAttributePostscriptum() { - return $this->attribute_postscriptumn; + return $this->attribute_postscriptum; } /** @@ -655,25 +655,25 @@ abstract class OrderProductAttributeCombination implements ActiveRecordInterface } // setAttributeDescription() /** - * Set the value of [attribute_postscriptumn] column. + * Set the value of [attribute_postscriptum] column. * * @param string $v new value * @return \Thelia\Model\OrderProductAttributeCombination The current object (for fluent API support) */ - public function setAttributePostscriptumn($v) + public function setAttributePostscriptum($v) { if ($v !== null) { $v = (string) $v; } - if ($this->attribute_postscriptumn !== $v) { - $this->attribute_postscriptumn = $v; - $this->modifiedColumns[] = OrderProductAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUMN; + if ($this->attribute_postscriptum !== $v) { + $this->attribute_postscriptum = $v; + $this->modifiedColumns[] = OrderProductAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUM; } return $this; - } // setAttributePostscriptumn() + } // setAttributePostscriptum() /** * Set the value of [attribute_av_title] column. @@ -853,8 +853,8 @@ abstract class OrderProductAttributeCombination implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : OrderProductAttributeCombinationTableMap::translateFieldName('AttributeDescription', TableMap::TYPE_PHPNAME, $indexType)]; $this->attribute_description = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : OrderProductAttributeCombinationTableMap::translateFieldName('AttributePostscriptumn', TableMap::TYPE_PHPNAME, $indexType)]; - $this->attribute_postscriptumn = (null !== $col) ? (string) $col : null; + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : OrderProductAttributeCombinationTableMap::translateFieldName('AttributePostscriptum', TableMap::TYPE_PHPNAME, $indexType)]; + $this->attribute_postscriptum = (null !== $col) ? (string) $col : null; $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : OrderProductAttributeCombinationTableMap::translateFieldName('AttributeAvTitle', TableMap::TYPE_PHPNAME, $indexType)]; $this->attribute_av_title = (null !== $col) ? (string) $col : null; @@ -1138,8 +1138,8 @@ abstract class OrderProductAttributeCombination implements ActiveRecordInterface if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_DESCRIPTION)) { $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_DESCRIPTION'; } - if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUMN)) { - $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_POSTSCRIPTUMN'; + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUM)) { + $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_POSTSCRIPTUM'; } if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_TITLE)) { $modifiedColumns[':p' . $index++] = 'ATTRIBUTE_AV_TITLE'; @@ -1185,8 +1185,8 @@ abstract class OrderProductAttributeCombination implements ActiveRecordInterface case 'ATTRIBUTE_DESCRIPTION': $stmt->bindValue($identifier, $this->attribute_description, PDO::PARAM_STR); break; - case 'ATTRIBUTE_POSTSCRIPTUMN': - $stmt->bindValue($identifier, $this->attribute_postscriptumn, PDO::PARAM_STR); + case 'ATTRIBUTE_POSTSCRIPTUM': + $stmt->bindValue($identifier, $this->attribute_postscriptum, PDO::PARAM_STR); break; case 'ATTRIBUTE_AV_TITLE': $stmt->bindValue($identifier, $this->attribute_av_title, PDO::PARAM_STR); @@ -1284,7 +1284,7 @@ abstract class OrderProductAttributeCombination implements ActiveRecordInterface return $this->getAttributeDescription(); break; case 5: - return $this->getAttributePostscriptumn(); + return $this->getAttributePostscriptum(); break; case 6: return $this->getAttributeAvTitle(); @@ -1338,7 +1338,7 @@ abstract class OrderProductAttributeCombination implements ActiveRecordInterface $keys[2] => $this->getAttributeTitle(), $keys[3] => $this->getAttributeChapo(), $keys[4] => $this->getAttributeDescription(), - $keys[5] => $this->getAttributePostscriptumn(), + $keys[5] => $this->getAttributePostscriptum(), $keys[6] => $this->getAttributeAvTitle(), $keys[7] => $this->getAttributeAvChapo(), $keys[8] => $this->getAttributeAvDescription(), @@ -1406,7 +1406,7 @@ abstract class OrderProductAttributeCombination implements ActiveRecordInterface $this->setAttributeDescription($value); break; case 5: - $this->setAttributePostscriptumn($value); + $this->setAttributePostscriptum($value); break; case 6: $this->setAttributeAvTitle($value); @@ -1455,7 +1455,7 @@ abstract class OrderProductAttributeCombination implements ActiveRecordInterface if (array_key_exists($keys[2], $arr)) $this->setAttributeTitle($arr[$keys[2]]); if (array_key_exists($keys[3], $arr)) $this->setAttributeChapo($arr[$keys[3]]); if (array_key_exists($keys[4], $arr)) $this->setAttributeDescription($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setAttributePostscriptumn($arr[$keys[5]]); + if (array_key_exists($keys[5], $arr)) $this->setAttributePostscriptum($arr[$keys[5]]); if (array_key_exists($keys[6], $arr)) $this->setAttributeAvTitle($arr[$keys[6]]); if (array_key_exists($keys[7], $arr)) $this->setAttributeAvChapo($arr[$keys[7]]); if (array_key_exists($keys[8], $arr)) $this->setAttributeAvDescription($arr[$keys[8]]); @@ -1478,7 +1478,7 @@ abstract class OrderProductAttributeCombination implements ActiveRecordInterface if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_TITLE)) $criteria->add(OrderProductAttributeCombinationTableMap::ATTRIBUTE_TITLE, $this->attribute_title); if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_CHAPO)) $criteria->add(OrderProductAttributeCombinationTableMap::ATTRIBUTE_CHAPO, $this->attribute_chapo); if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_DESCRIPTION)) $criteria->add(OrderProductAttributeCombinationTableMap::ATTRIBUTE_DESCRIPTION, $this->attribute_description); - if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUMN)) $criteria->add(OrderProductAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUMN, $this->attribute_postscriptumn); + if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUM)) $criteria->add(OrderProductAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUM, $this->attribute_postscriptum); if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_TITLE)) $criteria->add(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_TITLE, $this->attribute_av_title); if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_CHAPO)) $criteria->add(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_CHAPO, $this->attribute_av_chapo); if ($this->isColumnModified(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_DESCRIPTION)) $criteria->add(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_DESCRIPTION, $this->attribute_av_description); @@ -1552,7 +1552,7 @@ abstract class OrderProductAttributeCombination implements ActiveRecordInterface $copyObj->setAttributeTitle($this->getAttributeTitle()); $copyObj->setAttributeChapo($this->getAttributeChapo()); $copyObj->setAttributeDescription($this->getAttributeDescription()); - $copyObj->setAttributePostscriptumn($this->getAttributePostscriptumn()); + $copyObj->setAttributePostscriptum($this->getAttributePostscriptum()); $copyObj->setAttributeAvTitle($this->getAttributeAvTitle()); $copyObj->setAttributeAvChapo($this->getAttributeAvChapo()); $copyObj->setAttributeAvDescription($this->getAttributeAvDescription()); @@ -1648,7 +1648,7 @@ abstract class OrderProductAttributeCombination implements ActiveRecordInterface $this->attribute_title = null; $this->attribute_chapo = null; $this->attribute_description = null; - $this->attribute_postscriptumn = null; + $this->attribute_postscriptum = null; $this->attribute_av_title = null; $this->attribute_av_chapo = null; $this->attribute_av_description = null; diff --git a/core/lib/Thelia/Model/Base/OrderProductAttributeCombinationQuery.php b/core/lib/Thelia/Model/Base/OrderProductAttributeCombinationQuery.php index 9e8298aa5..886b75c5f 100644 --- a/core/lib/Thelia/Model/Base/OrderProductAttributeCombinationQuery.php +++ b/core/lib/Thelia/Model/Base/OrderProductAttributeCombinationQuery.php @@ -26,7 +26,7 @@ use Thelia\Model\Map\OrderProductAttributeCombinationTableMap; * @method ChildOrderProductAttributeCombinationQuery orderByAttributeTitle($order = Criteria::ASC) Order by the attribute_title column * @method ChildOrderProductAttributeCombinationQuery orderByAttributeChapo($order = Criteria::ASC) Order by the attribute_chapo column * @method ChildOrderProductAttributeCombinationQuery orderByAttributeDescription($order = Criteria::ASC) Order by the attribute_description column - * @method ChildOrderProductAttributeCombinationQuery orderByAttributePostscriptumn($order = Criteria::ASC) Order by the attribute_postscriptumn column + * @method ChildOrderProductAttributeCombinationQuery orderByAttributePostscriptum($order = Criteria::ASC) Order by the attribute_postscriptum column * @method ChildOrderProductAttributeCombinationQuery orderByAttributeAvTitle($order = Criteria::ASC) Order by the attribute_av_title column * @method ChildOrderProductAttributeCombinationQuery orderByAttributeAvChapo($order = Criteria::ASC) Order by the attribute_av_chapo column * @method ChildOrderProductAttributeCombinationQuery orderByAttributeAvDescription($order = Criteria::ASC) Order by the attribute_av_description column @@ -39,7 +39,7 @@ use Thelia\Model\Map\OrderProductAttributeCombinationTableMap; * @method ChildOrderProductAttributeCombinationQuery groupByAttributeTitle() Group by the attribute_title column * @method ChildOrderProductAttributeCombinationQuery groupByAttributeChapo() Group by the attribute_chapo column * @method ChildOrderProductAttributeCombinationQuery groupByAttributeDescription() Group by the attribute_description column - * @method ChildOrderProductAttributeCombinationQuery groupByAttributePostscriptumn() Group by the attribute_postscriptumn column + * @method ChildOrderProductAttributeCombinationQuery groupByAttributePostscriptum() Group by the attribute_postscriptum column * @method ChildOrderProductAttributeCombinationQuery groupByAttributeAvTitle() Group by the attribute_av_title column * @method ChildOrderProductAttributeCombinationQuery groupByAttributeAvChapo() Group by the attribute_av_chapo column * @method ChildOrderProductAttributeCombinationQuery groupByAttributeAvDescription() Group by the attribute_av_description column @@ -63,7 +63,7 @@ use Thelia\Model\Map\OrderProductAttributeCombinationTableMap; * @method ChildOrderProductAttributeCombination findOneByAttributeTitle(string $attribute_title) Return the first ChildOrderProductAttributeCombination filtered by the attribute_title column * @method ChildOrderProductAttributeCombination findOneByAttributeChapo(string $attribute_chapo) Return the first ChildOrderProductAttributeCombination filtered by the attribute_chapo column * @method ChildOrderProductAttributeCombination findOneByAttributeDescription(string $attribute_description) Return the first ChildOrderProductAttributeCombination filtered by the attribute_description column - * @method ChildOrderProductAttributeCombination findOneByAttributePostscriptumn(string $attribute_postscriptumn) Return the first ChildOrderProductAttributeCombination filtered by the attribute_postscriptumn column + * @method ChildOrderProductAttributeCombination findOneByAttributePostscriptum(string $attribute_postscriptum) Return the first ChildOrderProductAttributeCombination filtered by the attribute_postscriptum column * @method ChildOrderProductAttributeCombination findOneByAttributeAvTitle(string $attribute_av_title) Return the first ChildOrderProductAttributeCombination filtered by the attribute_av_title column * @method ChildOrderProductAttributeCombination findOneByAttributeAvChapo(string $attribute_av_chapo) Return the first ChildOrderProductAttributeCombination filtered by the attribute_av_chapo column * @method ChildOrderProductAttributeCombination findOneByAttributeAvDescription(string $attribute_av_description) Return the first ChildOrderProductAttributeCombination filtered by the attribute_av_description column @@ -76,7 +76,7 @@ use Thelia\Model\Map\OrderProductAttributeCombinationTableMap; * @method array findByAttributeTitle(string $attribute_title) Return ChildOrderProductAttributeCombination objects filtered by the attribute_title column * @method array findByAttributeChapo(string $attribute_chapo) Return ChildOrderProductAttributeCombination objects filtered by the attribute_chapo column * @method array findByAttributeDescription(string $attribute_description) Return ChildOrderProductAttributeCombination objects filtered by the attribute_description column - * @method array findByAttributePostscriptumn(string $attribute_postscriptumn) Return ChildOrderProductAttributeCombination objects filtered by the attribute_postscriptumn column + * @method array findByAttributePostscriptum(string $attribute_postscriptum) Return ChildOrderProductAttributeCombination objects filtered by the attribute_postscriptum column * @method array findByAttributeAvTitle(string $attribute_av_title) Return ChildOrderProductAttributeCombination objects filtered by the attribute_av_title column * @method array findByAttributeAvChapo(string $attribute_av_chapo) Return ChildOrderProductAttributeCombination objects filtered by the attribute_av_chapo column * @method array findByAttributeAvDescription(string $attribute_av_description) Return ChildOrderProductAttributeCombination objects filtered by the attribute_av_description column @@ -171,7 +171,7 @@ abstract class OrderProductAttributeCombinationQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, ORDER_PRODUCT_ID, ATTRIBUTE_TITLE, ATTRIBUTE_CHAPO, ATTRIBUTE_DESCRIPTION, ATTRIBUTE_POSTSCRIPTUMN, ATTRIBUTE_AV_TITLE, ATTRIBUTE_AV_CHAPO, ATTRIBUTE_AV_DESCRIPTION, ATTRIBUTE_AV_POSTSCRIPTUM, CREATED_AT, UPDATED_AT FROM order_product_attribute_combination WHERE ID = :p0'; + $sql = 'SELECT ID, ORDER_PRODUCT_ID, ATTRIBUTE_TITLE, ATTRIBUTE_CHAPO, ATTRIBUTE_DESCRIPTION, ATTRIBUTE_POSTSCRIPTUM, ATTRIBUTE_AV_TITLE, ATTRIBUTE_AV_CHAPO, ATTRIBUTE_AV_DESCRIPTION, ATTRIBUTE_AV_POSTSCRIPTUM, CREATED_AT, UPDATED_AT FROM order_product_attribute_combination WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -432,32 +432,32 @@ abstract class OrderProductAttributeCombinationQuery extends ModelCriteria } /** - * Filter the query on the attribute_postscriptumn column + * Filter the query on the attribute_postscriptum column * * Example usage: * - * $query->filterByAttributePostscriptumn('fooValue'); // WHERE attribute_postscriptumn = 'fooValue' - * $query->filterByAttributePostscriptumn('%fooValue%'); // WHERE attribute_postscriptumn LIKE '%fooValue%' + * $query->filterByAttributePostscriptum('fooValue'); // WHERE attribute_postscriptum = 'fooValue' + * $query->filterByAttributePostscriptum('%fooValue%'); // WHERE attribute_postscriptum LIKE '%fooValue%' * * - * @param string $attributePostscriptumn The value to use as filter. + * @param string $attributePostscriptum The value to use as filter. * Accepts wildcards (* and % trigger a LIKE) * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildOrderProductAttributeCombinationQuery The current query, for fluid interface */ - public function filterByAttributePostscriptumn($attributePostscriptumn = null, $comparison = null) + public function filterByAttributePostscriptum($attributePostscriptum = null, $comparison = null) { if (null === $comparison) { - if (is_array($attributePostscriptumn)) { + if (is_array($attributePostscriptum)) { $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $attributePostscriptumn)) { - $attributePostscriptumn = str_replace('*', '%', $attributePostscriptumn); + } elseif (preg_match('/[\%\*]/', $attributePostscriptum)) { + $attributePostscriptum = str_replace('*', '%', $attributePostscriptum); $comparison = Criteria::LIKE; } } - return $this->addUsingAlias(OrderProductAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUMN, $attributePostscriptumn, $comparison); + return $this->addUsingAlias(OrderProductAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUM, $attributePostscriptum, $comparison); } /** diff --git a/core/lib/Thelia/Model/Base/OrderProductTax.php b/core/lib/Thelia/Model/Base/OrderProductTax.php index 544755ff4..6d0807ccf 100644 --- a/core/lib/Thelia/Model/Base/OrderProductTax.php +++ b/core/lib/Thelia/Model/Base/OrderProductTax.php @@ -86,6 +86,12 @@ abstract class OrderProductTax implements ActiveRecordInterface */ protected $amount; + /** + * The value for the promo_amount field. + * @var double + */ + protected $promo_amount; + /** * The value for the created_at field. * @var string @@ -420,6 +426,17 @@ abstract class OrderProductTax implements ActiveRecordInterface return $this->amount; } + /** + * Get the [promo_amount] column value. + * + * @return double + */ + public function getPromoAmount() + { + + return $this->promo_amount; + } + /** * Get the [optionally formatted] temporal [created_at] column value. * @@ -569,6 +586,27 @@ abstract class OrderProductTax implements ActiveRecordInterface return $this; } // setAmount() + /** + * Set the value of [promo_amount] column. + * + * @param double $v new value + * @return \Thelia\Model\OrderProductTax The current object (for fluent API support) + */ + public function setPromoAmount($v) + { + if ($v !== null) { + $v = (double) $v; + } + + if ($this->promo_amount !== $v) { + $this->promo_amount = $v; + $this->modifiedColumns[] = OrderProductTaxTableMap::PROMO_AMOUNT; + } + + + return $this; + } // setPromoAmount() + /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. * @@ -663,13 +701,16 @@ abstract class OrderProductTax implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : OrderProductTaxTableMap::translateFieldName('Amount', TableMap::TYPE_PHPNAME, $indexType)]; $this->amount = (null !== $col) ? (double) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : OrderProductTaxTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : OrderProductTaxTableMap::translateFieldName('PromoAmount', TableMap::TYPE_PHPNAME, $indexType)]; + $this->promo_amount = (null !== $col) ? (double) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : OrderProductTaxTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : OrderProductTaxTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : OrderProductTaxTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -682,7 +723,7 @@ abstract class OrderProductTax implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 7; // 7 = OrderProductTaxTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 8; // 8 = OrderProductTaxTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\OrderProductTax object", 0, $e); @@ -933,6 +974,9 @@ abstract class OrderProductTax implements ActiveRecordInterface if ($this->isColumnModified(OrderProductTaxTableMap::AMOUNT)) { $modifiedColumns[':p' . $index++] = 'AMOUNT'; } + if ($this->isColumnModified(OrderProductTaxTableMap::PROMO_AMOUNT)) { + $modifiedColumns[':p' . $index++] = 'PROMO_AMOUNT'; + } if ($this->isColumnModified(OrderProductTaxTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } @@ -965,6 +1009,9 @@ abstract class OrderProductTax implements ActiveRecordInterface case 'AMOUNT': $stmt->bindValue($identifier, $this->amount, PDO::PARAM_STR); break; + case 'PROMO_AMOUNT': + $stmt->bindValue($identifier, $this->promo_amount, PDO::PARAM_STR); + break; case 'CREATED_AT': $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; @@ -1049,9 +1096,12 @@ abstract class OrderProductTax implements ActiveRecordInterface return $this->getAmount(); break; case 5: - return $this->getCreatedAt(); + return $this->getPromoAmount(); break; case 6: + return $this->getCreatedAt(); + break; + case 7: return $this->getUpdatedAt(); break; default: @@ -1088,8 +1138,9 @@ abstract class OrderProductTax implements ActiveRecordInterface $keys[2] => $this->getTitle(), $keys[3] => $this->getDescription(), $keys[4] => $this->getAmount(), - $keys[5] => $this->getCreatedAt(), - $keys[6] => $this->getUpdatedAt(), + $keys[5] => $this->getPromoAmount(), + $keys[6] => $this->getCreatedAt(), + $keys[7] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -1151,9 +1202,12 @@ abstract class OrderProductTax implements ActiveRecordInterface $this->setAmount($value); break; case 5: - $this->setCreatedAt($value); + $this->setPromoAmount($value); break; case 6: + $this->setCreatedAt($value); + break; + case 7: $this->setUpdatedAt($value); break; } // switch() @@ -1185,8 +1239,9 @@ abstract class OrderProductTax implements ActiveRecordInterface if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]); if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]); if (array_key_exists($keys[4], $arr)) $this->setAmount($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]); + if (array_key_exists($keys[5], $arr)) $this->setPromoAmount($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setCreatedAt($arr[$keys[6]]); + if (array_key_exists($keys[7], $arr)) $this->setUpdatedAt($arr[$keys[7]]); } /** @@ -1203,6 +1258,7 @@ abstract class OrderProductTax implements ActiveRecordInterface if ($this->isColumnModified(OrderProductTaxTableMap::TITLE)) $criteria->add(OrderProductTaxTableMap::TITLE, $this->title); if ($this->isColumnModified(OrderProductTaxTableMap::DESCRIPTION)) $criteria->add(OrderProductTaxTableMap::DESCRIPTION, $this->description); if ($this->isColumnModified(OrderProductTaxTableMap::AMOUNT)) $criteria->add(OrderProductTaxTableMap::AMOUNT, $this->amount); + if ($this->isColumnModified(OrderProductTaxTableMap::PROMO_AMOUNT)) $criteria->add(OrderProductTaxTableMap::PROMO_AMOUNT, $this->promo_amount); if ($this->isColumnModified(OrderProductTaxTableMap::CREATED_AT)) $criteria->add(OrderProductTaxTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(OrderProductTaxTableMap::UPDATED_AT)) $criteria->add(OrderProductTaxTableMap::UPDATED_AT, $this->updated_at); @@ -1272,6 +1328,7 @@ abstract class OrderProductTax implements ActiveRecordInterface $copyObj->setTitle($this->getTitle()); $copyObj->setDescription($this->getDescription()); $copyObj->setAmount($this->getAmount()); + $copyObj->setPromoAmount($this->getPromoAmount()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); if ($makeNew) { @@ -1363,6 +1420,7 @@ abstract class OrderProductTax implements ActiveRecordInterface $this->title = null; $this->description = null; $this->amount = null; + $this->promo_amount = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; diff --git a/core/lib/Thelia/Model/Base/OrderProductTaxQuery.php b/core/lib/Thelia/Model/Base/OrderProductTaxQuery.php index d37c2c501..d0153d0cd 100644 --- a/core/lib/Thelia/Model/Base/OrderProductTaxQuery.php +++ b/core/lib/Thelia/Model/Base/OrderProductTaxQuery.php @@ -26,6 +26,7 @@ use Thelia\Model\Map\OrderProductTaxTableMap; * @method ChildOrderProductTaxQuery orderByTitle($order = Criteria::ASC) Order by the title column * @method ChildOrderProductTaxQuery orderByDescription($order = Criteria::ASC) Order by the description column * @method ChildOrderProductTaxQuery orderByAmount($order = Criteria::ASC) Order by the amount column + * @method ChildOrderProductTaxQuery orderByPromoAmount($order = Criteria::ASC) Order by the promo_amount column * @method ChildOrderProductTaxQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildOrderProductTaxQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * @@ -34,6 +35,7 @@ use Thelia\Model\Map\OrderProductTaxTableMap; * @method ChildOrderProductTaxQuery groupByTitle() Group by the title column * @method ChildOrderProductTaxQuery groupByDescription() Group by the description column * @method ChildOrderProductTaxQuery groupByAmount() Group by the amount column + * @method ChildOrderProductTaxQuery groupByPromoAmount() Group by the promo_amount column * @method ChildOrderProductTaxQuery groupByCreatedAt() Group by the created_at column * @method ChildOrderProductTaxQuery groupByUpdatedAt() Group by the updated_at column * @@ -53,6 +55,7 @@ use Thelia\Model\Map\OrderProductTaxTableMap; * @method ChildOrderProductTax findOneByTitle(string $title) Return the first ChildOrderProductTax filtered by the title column * @method ChildOrderProductTax findOneByDescription(string $description) Return the first ChildOrderProductTax filtered by the description column * @method ChildOrderProductTax findOneByAmount(double $amount) Return the first ChildOrderProductTax filtered by the amount column + * @method ChildOrderProductTax findOneByPromoAmount(double $promo_amount) Return the first ChildOrderProductTax filtered by the promo_amount column * @method ChildOrderProductTax findOneByCreatedAt(string $created_at) Return the first ChildOrderProductTax filtered by the created_at column * @method ChildOrderProductTax findOneByUpdatedAt(string $updated_at) Return the first ChildOrderProductTax filtered by the updated_at column * @@ -61,6 +64,7 @@ use Thelia\Model\Map\OrderProductTaxTableMap; * @method array findByTitle(string $title) Return ChildOrderProductTax objects filtered by the title column * @method array findByDescription(string $description) Return ChildOrderProductTax objects filtered by the description column * @method array findByAmount(double $amount) Return ChildOrderProductTax objects filtered by the amount column + * @method array findByPromoAmount(double $promo_amount) Return ChildOrderProductTax objects filtered by the promo_amount column * @method array findByCreatedAt(string $created_at) Return ChildOrderProductTax objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildOrderProductTax objects filtered by the updated_at column * @@ -151,7 +155,7 @@ abstract class OrderProductTaxQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, ORDER_PRODUCT_ID, TITLE, DESCRIPTION, AMOUNT, CREATED_AT, UPDATED_AT FROM order_product_tax WHERE ID = :p0'; + $sql = 'SELECT ID, ORDER_PRODUCT_ID, TITLE, DESCRIPTION, AMOUNT, PROMO_AMOUNT, CREATED_AT, UPDATED_AT FROM order_product_tax WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -423,6 +427,47 @@ abstract class OrderProductTaxQuery extends ModelCriteria return $this->addUsingAlias(OrderProductTaxTableMap::AMOUNT, $amount, $comparison); } + /** + * Filter the query on the promo_amount column + * + * Example usage: + * + * $query->filterByPromoAmount(1234); // WHERE promo_amount = 1234 + * $query->filterByPromoAmount(array(12, 34)); // WHERE promo_amount IN (12, 34) + * $query->filterByPromoAmount(array('min' => 12)); // WHERE promo_amount > 12 + * + * + * @param mixed $promoAmount 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 ChildOrderProductTaxQuery The current query, for fluid interface + */ + public function filterByPromoAmount($promoAmount = null, $comparison = null) + { + if (is_array($promoAmount)) { + $useMinMax = false; + if (isset($promoAmount['min'])) { + $this->addUsingAlias(OrderProductTaxTableMap::PROMO_AMOUNT, $promoAmount['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($promoAmount['max'])) { + $this->addUsingAlias(OrderProductTaxTableMap::PROMO_AMOUNT, $promoAmount['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(OrderProductTaxTableMap::PROMO_AMOUNT, $promoAmount, $comparison); + } + /** * Filter the query on the created_at column * diff --git a/core/lib/Thelia/Model/Base/ProductSaleElements.php b/core/lib/Thelia/Model/Base/ProductSaleElements.php index fa887dc8a..eb6aa2b1a 100644 --- a/core/lib/Thelia/Model/Base/ProductSaleElements.php +++ b/core/lib/Thelia/Model/Base/ProductSaleElements.php @@ -103,10 +103,18 @@ abstract class ProductSaleElements implements ActiveRecordInterface /** * The value for the weight field. + * Note: this column has a database default value of: 0 * @var double */ protected $weight; + /** + * The value for the is_default field. + * Note: this column has a database default value of: false + * @var boolean + */ + protected $is_default; + /** * The value for the created_at field. * @var string @@ -178,6 +186,8 @@ abstract class ProductSaleElements implements ActiveRecordInterface { $this->promo = 0; $this->newness = 0; + $this->weight = 0; + $this->is_default = false; } /** @@ -513,6 +523,17 @@ abstract class ProductSaleElements implements ActiveRecordInterface return $this->weight; } + /** + * Get the [is_default] column value. + * + * @return boolean + */ + public function getIsDefault() + { + + return $this->is_default; + } + /** * Get the [optionally formatted] temporal [created_at] column value. * @@ -704,6 +725,35 @@ abstract class ProductSaleElements implements ActiveRecordInterface return $this; } // setWeight() + /** + * Sets the value of the [is_default] column. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * + * @param boolean|integer|string $v The new value + * @return \Thelia\Model\ProductSaleElements The current object (for fluent API support) + */ + public function setIsDefault($v) + { + if ($v !== null) { + if (is_string($v)) { + $v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } else { + $v = (boolean) $v; + } + } + + if ($this->is_default !== $v) { + $this->is_default = $v; + $this->modifiedColumns[] = ProductSaleElementsTableMap::IS_DEFAULT; + } + + + return $this; + } // setIsDefault() + /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. * @@ -764,6 +814,14 @@ abstract class ProductSaleElements implements ActiveRecordInterface return false; } + if ($this->weight !== 0) { + return false; + } + + if ($this->is_default !== false) { + return false; + } + // otherwise, everything was equal, so return TRUE return true; } // hasOnlyDefaultValues() @@ -812,13 +870,16 @@ abstract class ProductSaleElements implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ProductSaleElementsTableMap::translateFieldName('Weight', TableMap::TYPE_PHPNAME, $indexType)]; $this->weight = (null !== $col) ? (double) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : ProductSaleElementsTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : ProductSaleElementsTableMap::translateFieldName('IsDefault', TableMap::TYPE_PHPNAME, $indexType)]; + $this->is_default = (null !== $col) ? (boolean) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : ProductSaleElementsTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : ProductSaleElementsTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : ProductSaleElementsTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -831,7 +892,7 @@ abstract class ProductSaleElements implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 9; // 9 = ProductSaleElementsTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 10; // 10 = ProductSaleElementsTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\ProductSaleElements object", 0, $e); @@ -1145,6 +1206,9 @@ abstract class ProductSaleElements implements ActiveRecordInterface if ($this->isColumnModified(ProductSaleElementsTableMap::WEIGHT)) { $modifiedColumns[':p' . $index++] = 'WEIGHT'; } + if ($this->isColumnModified(ProductSaleElementsTableMap::IS_DEFAULT)) { + $modifiedColumns[':p' . $index++] = 'IS_DEFAULT'; + } if ($this->isColumnModified(ProductSaleElementsTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } @@ -1183,6 +1247,9 @@ abstract class ProductSaleElements implements ActiveRecordInterface case 'WEIGHT': $stmt->bindValue($identifier, $this->weight, PDO::PARAM_STR); break; + case 'IS_DEFAULT': + $stmt->bindValue($identifier, (int) $this->is_default, PDO::PARAM_INT); + break; case 'CREATED_AT': $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; @@ -1273,9 +1340,12 @@ abstract class ProductSaleElements implements ActiveRecordInterface return $this->getWeight(); break; case 7: - return $this->getCreatedAt(); + return $this->getIsDefault(); break; case 8: + return $this->getCreatedAt(); + break; + case 9: return $this->getUpdatedAt(); break; default: @@ -1314,8 +1384,9 @@ abstract class ProductSaleElements implements ActiveRecordInterface $keys[4] => $this->getPromo(), $keys[5] => $this->getNewness(), $keys[6] => $this->getWeight(), - $keys[7] => $this->getCreatedAt(), - $keys[8] => $this->getUpdatedAt(), + $keys[7] => $this->getIsDefault(), + $keys[8] => $this->getCreatedAt(), + $keys[9] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; foreach($virtualColumns as $key => $virtualColumn) @@ -1392,9 +1463,12 @@ abstract class ProductSaleElements implements ActiveRecordInterface $this->setWeight($value); break; case 7: - $this->setCreatedAt($value); + $this->setIsDefault($value); break; case 8: + $this->setCreatedAt($value); + break; + case 9: $this->setUpdatedAt($value); break; } // switch() @@ -1428,8 +1502,9 @@ abstract class ProductSaleElements implements ActiveRecordInterface if (array_key_exists($keys[4], $arr)) $this->setPromo($arr[$keys[4]]); if (array_key_exists($keys[5], $arr)) $this->setNewness($arr[$keys[5]]); if (array_key_exists($keys[6], $arr)) $this->setWeight($arr[$keys[6]]); - if (array_key_exists($keys[7], $arr)) $this->setCreatedAt($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setUpdatedAt($arr[$keys[8]]); + if (array_key_exists($keys[7], $arr)) $this->setIsDefault($arr[$keys[7]]); + if (array_key_exists($keys[8], $arr)) $this->setCreatedAt($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setUpdatedAt($arr[$keys[9]]); } /** @@ -1448,6 +1523,7 @@ abstract class ProductSaleElements implements ActiveRecordInterface if ($this->isColumnModified(ProductSaleElementsTableMap::PROMO)) $criteria->add(ProductSaleElementsTableMap::PROMO, $this->promo); if ($this->isColumnModified(ProductSaleElementsTableMap::NEWNESS)) $criteria->add(ProductSaleElementsTableMap::NEWNESS, $this->newness); if ($this->isColumnModified(ProductSaleElementsTableMap::WEIGHT)) $criteria->add(ProductSaleElementsTableMap::WEIGHT, $this->weight); + if ($this->isColumnModified(ProductSaleElementsTableMap::IS_DEFAULT)) $criteria->add(ProductSaleElementsTableMap::IS_DEFAULT, $this->is_default); if ($this->isColumnModified(ProductSaleElementsTableMap::CREATED_AT)) $criteria->add(ProductSaleElementsTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(ProductSaleElementsTableMap::UPDATED_AT)) $criteria->add(ProductSaleElementsTableMap::UPDATED_AT, $this->updated_at); @@ -1519,6 +1595,7 @@ abstract class ProductSaleElements implements ActiveRecordInterface $copyObj->setPromo($this->getPromo()); $copyObj->setNewness($this->getNewness()); $copyObj->setWeight($this->getWeight()); + $copyObj->setIsDefault($this->getIsDefault()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); @@ -2445,6 +2522,7 @@ abstract class ProductSaleElements implements ActiveRecordInterface $this->promo = null; $this->newness = null; $this->weight = null; + $this->is_default = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; diff --git a/core/lib/Thelia/Model/Base/ProductSaleElementsQuery.php b/core/lib/Thelia/Model/Base/ProductSaleElementsQuery.php index 6e9068002..c8201ed0b 100644 --- a/core/lib/Thelia/Model/Base/ProductSaleElementsQuery.php +++ b/core/lib/Thelia/Model/Base/ProductSaleElementsQuery.php @@ -28,6 +28,7 @@ use Thelia\Model\Map\ProductSaleElementsTableMap; * @method ChildProductSaleElementsQuery orderByPromo($order = Criteria::ASC) Order by the promo column * @method ChildProductSaleElementsQuery orderByNewness($order = Criteria::ASC) Order by the newness column * @method ChildProductSaleElementsQuery orderByWeight($order = Criteria::ASC) Order by the weight column + * @method ChildProductSaleElementsQuery orderByIsDefault($order = Criteria::ASC) Order by the is_default column * @method ChildProductSaleElementsQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildProductSaleElementsQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * @@ -38,6 +39,7 @@ use Thelia\Model\Map\ProductSaleElementsTableMap; * @method ChildProductSaleElementsQuery groupByPromo() Group by the promo column * @method ChildProductSaleElementsQuery groupByNewness() Group by the newness column * @method ChildProductSaleElementsQuery groupByWeight() Group by the weight column + * @method ChildProductSaleElementsQuery groupByIsDefault() Group by the is_default column * @method ChildProductSaleElementsQuery groupByCreatedAt() Group by the created_at column * @method ChildProductSaleElementsQuery groupByUpdatedAt() Group by the updated_at column * @@ -71,6 +73,7 @@ use Thelia\Model\Map\ProductSaleElementsTableMap; * @method ChildProductSaleElements findOneByPromo(int $promo) Return the first ChildProductSaleElements filtered by the promo column * @method ChildProductSaleElements findOneByNewness(int $newness) Return the first ChildProductSaleElements filtered by the newness column * @method ChildProductSaleElements findOneByWeight(double $weight) Return the first ChildProductSaleElements filtered by the weight column + * @method ChildProductSaleElements findOneByIsDefault(boolean $is_default) Return the first ChildProductSaleElements filtered by the is_default column * @method ChildProductSaleElements findOneByCreatedAt(string $created_at) Return the first ChildProductSaleElements filtered by the created_at column * @method ChildProductSaleElements findOneByUpdatedAt(string $updated_at) Return the first ChildProductSaleElements filtered by the updated_at column * @@ -81,6 +84,7 @@ use Thelia\Model\Map\ProductSaleElementsTableMap; * @method array findByPromo(int $promo) Return ChildProductSaleElements objects filtered by the promo column * @method array findByNewness(int $newness) Return ChildProductSaleElements objects filtered by the newness column * @method array findByWeight(double $weight) Return ChildProductSaleElements objects filtered by the weight column + * @method array findByIsDefault(boolean $is_default) Return ChildProductSaleElements objects filtered by the is_default column * @method array findByCreatedAt(string $created_at) Return ChildProductSaleElements objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildProductSaleElements objects filtered by the updated_at column * @@ -171,7 +175,7 @@ abstract class ProductSaleElementsQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, PRODUCT_ID, REF, QUANTITY, PROMO, NEWNESS, WEIGHT, CREATED_AT, UPDATED_AT FROM product_sale_elements WHERE ID = :p0'; + $sql = 'SELECT ID, PRODUCT_ID, REF, QUANTITY, PROMO, NEWNESS, WEIGHT, IS_DEFAULT, CREATED_AT, UPDATED_AT FROM product_sale_elements WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -537,6 +541,33 @@ abstract class ProductSaleElementsQuery extends ModelCriteria return $this->addUsingAlias(ProductSaleElementsTableMap::WEIGHT, $weight, $comparison); } + /** + * Filter the query on the is_default column + * + * Example usage: + * + * $query->filterByIsDefault(true); // WHERE is_default = true + * $query->filterByIsDefault('yes'); // WHERE is_default = true + * + * + * @param boolean|string $isDefault The value to use as filter. + * Non-boolean arguments are converted using the following rules: + * * 1, '1', 'true', 'on', and 'yes' are converted to boolean true + * * 0, '0', 'false', 'off', and 'no' are converted to boolean false + * Check on string values is case insensitive (so 'FaLsE' is seen as 'false'). + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductSaleElementsQuery The current query, for fluid interface + */ + public function filterByIsDefault($isDefault = null, $comparison = null) + { + if (is_string($isDefault)) { + $is_default = in_array(strtolower($isDefault), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true; + } + + return $this->addUsingAlias(ProductSaleElementsTableMap::IS_DEFAULT, $isDefault, $comparison); + } + /** * Filter the query on the created_at column * diff --git a/core/lib/Thelia/Model/Feature.php b/core/lib/Thelia/Model/Feature.php index cf0284d2b..ffc5ae90f 100755 --- a/core/lib/Thelia/Model/Feature.php +++ b/core/lib/Thelia/Model/Feature.php @@ -20,7 +20,7 @@ class Feature extends BaseFeature { $this->dispatchEvent(TheliaEvents::BEFORE_CREATEFEATURE, new FeatureEvent($this)); // Set the current position for the new object - $this->setPosition($this->getNextPosition()); + //$this->setPosition($this->getNextPosition()); return true; } diff --git a/core/lib/Thelia/Model/Map/AttributeTableMap.php b/core/lib/Thelia/Model/Map/AttributeTableMap.php index 245dc08d3..50ea799ca 100644 --- a/core/lib/Thelia/Model/Map/AttributeTableMap.php +++ b/core/lib/Thelia/Model/Map/AttributeTableMap.php @@ -57,7 +57,7 @@ class AttributeTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 4; + const NUM_COLUMNS = 3; /** * The number of lazy-loaded columns @@ -67,18 +67,13 @@ class AttributeTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 4; + const NUM_HYDRATE_COLUMNS = 3; /** * the column name for the ID field */ const ID = 'attribute.ID'; - /** - * the column name for the POSITION field - */ - const POSITION = 'attribute.POSITION'; - /** * the column name for the CREATED_AT field */ @@ -110,12 +105,12 @@ class AttributeTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'Position', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'position', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(AttributeTableMap::ID, AttributeTableMap::POSITION, AttributeTableMap::CREATED_AT, AttributeTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'position', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, ) + self::TYPE_PHPNAME => array('Id', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(AttributeTableMap::ID, AttributeTableMap::CREATED_AT, AttributeTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, ) ); /** @@ -125,12 +120,12 @@ class AttributeTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'Position' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'position' => 1, 'createdAt' => 2, 'updatedAt' => 3, ), - self::TYPE_COLNAME => array(AttributeTableMap::ID => 0, AttributeTableMap::POSITION => 1, AttributeTableMap::CREATED_AT => 2, AttributeTableMap::UPDATED_AT => 3, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'POSITION' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ), - self::TYPE_FIELDNAME => array('id' => 0, 'position' => 1, 'created_at' => 2, 'updated_at' => 3, ), - self::TYPE_NUM => array(0, 1, 2, 3, ) + self::TYPE_PHPNAME => array('Id' => 0, 'CreatedAt' => 1, 'UpdatedAt' => 2, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'createdAt' => 1, 'updatedAt' => 2, ), + self::TYPE_COLNAME => array(AttributeTableMap::ID => 0, AttributeTableMap::CREATED_AT => 1, AttributeTableMap::UPDATED_AT => 2, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'CREATED_AT' => 1, 'UPDATED_AT' => 2, ), + self::TYPE_FIELDNAME => array('id' => 0, 'created_at' => 1, 'updated_at' => 2, ), + self::TYPE_NUM => array(0, 1, 2, ) ); /** @@ -150,7 +145,6 @@ class AttributeTableMap extends TableMap $this->setUseIdGenerator(true); // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -332,12 +326,10 @@ class AttributeTableMap extends TableMap { if (null === $alias) { $criteria->addSelectColumn(AttributeTableMap::ID); - $criteria->addSelectColumn(AttributeTableMap::POSITION); $criteria->addSelectColumn(AttributeTableMap::CREATED_AT); $criteria->addSelectColumn(AttributeTableMap::UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.POSITION'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } diff --git a/core/lib/Thelia/Model/Map/AttributeTemplateTableMap.php b/core/lib/Thelia/Model/Map/AttributeTemplateTableMap.php index 04d3a9a4a..c0df89d8f 100644 --- a/core/lib/Thelia/Model/Map/AttributeTemplateTableMap.php +++ b/core/lib/Thelia/Model/Map/AttributeTemplateTableMap.php @@ -57,7 +57,7 @@ class AttributeTemplateTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 5; + const NUM_COLUMNS = 7; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class AttributeTemplateTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 5; + const NUM_HYDRATE_COLUMNS = 7; /** * the column name for the ID field @@ -84,6 +84,16 @@ class AttributeTemplateTableMap extends TableMap */ const TEMPLATE_ID = 'attribute_template.TEMPLATE_ID'; + /** + * the column name for the POSITION field + */ + const POSITION = 'attribute_template.POSITION'; + + /** + * the column name for the ATTRIBUTE_TEMPLATECOL field + */ + const ATTRIBUTE_TEMPLATECOL = 'attribute_template.ATTRIBUTE_TEMPLATECOL'; + /** * the column name for the CREATED_AT field */ @@ -106,12 +116,12 @@ class AttributeTemplateTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'AttributeId', 'TemplateId', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'attributeId', 'templateId', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(AttributeTemplateTableMap::ID, AttributeTemplateTableMap::ATTRIBUTE_ID, AttributeTemplateTableMap::TEMPLATE_ID, AttributeTemplateTableMap::CREATED_AT, AttributeTemplateTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'ATTRIBUTE_ID', 'TEMPLATE_ID', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'attribute_id', 'template_id', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, ) + self::TYPE_PHPNAME => array('Id', 'AttributeId', 'TemplateId', 'Position', 'AttributeTemplatecol', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'attributeId', 'templateId', 'position', 'attributeTemplatecol', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(AttributeTemplateTableMap::ID, AttributeTemplateTableMap::ATTRIBUTE_ID, AttributeTemplateTableMap::TEMPLATE_ID, AttributeTemplateTableMap::POSITION, AttributeTemplateTableMap::ATTRIBUTE_TEMPLATECOL, AttributeTemplateTableMap::CREATED_AT, AttributeTemplateTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'ATTRIBUTE_ID', 'TEMPLATE_ID', 'POSITION', 'ATTRIBUTE_TEMPLATECOL', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'attribute_id', 'template_id', 'position', 'attribute_templatecol', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) ); /** @@ -121,12 +131,12 @@ class AttributeTemplateTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'AttributeId' => 1, 'TemplateId' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'attributeId' => 1, 'templateId' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), - self::TYPE_COLNAME => array(AttributeTemplateTableMap::ID => 0, AttributeTemplateTableMap::ATTRIBUTE_ID => 1, AttributeTemplateTableMap::TEMPLATE_ID => 2, AttributeTemplateTableMap::CREATED_AT => 3, AttributeTemplateTableMap::UPDATED_AT => 4, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'ATTRIBUTE_ID' => 1, 'TEMPLATE_ID' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), - self::TYPE_FIELDNAME => array('id' => 0, 'attribute_id' => 1, 'template_id' => 2, 'created_at' => 3, 'updated_at' => 4, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, ) + self::TYPE_PHPNAME => array('Id' => 0, 'AttributeId' => 1, 'TemplateId' => 2, 'Position' => 3, 'AttributeTemplatecol' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'attributeId' => 1, 'templateId' => 2, 'position' => 3, 'attributeTemplatecol' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), + self::TYPE_COLNAME => array(AttributeTemplateTableMap::ID => 0, AttributeTemplateTableMap::ATTRIBUTE_ID => 1, AttributeTemplateTableMap::TEMPLATE_ID => 2, AttributeTemplateTableMap::POSITION => 3, AttributeTemplateTableMap::ATTRIBUTE_TEMPLATECOL => 4, AttributeTemplateTableMap::CREATED_AT => 5, AttributeTemplateTableMap::UPDATED_AT => 6, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'ATTRIBUTE_ID' => 1, 'TEMPLATE_ID' => 2, 'POSITION' => 3, 'ATTRIBUTE_TEMPLATECOL' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), + self::TYPE_FIELDNAME => array('id' => 0, 'attribute_id' => 1, 'template_id' => 2, 'position' => 3, 'attribute_templatecol' => 4, 'created_at' => 5, 'updated_at' => 6, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) ); /** @@ -149,6 +159,8 @@ class AttributeTemplateTableMap extends TableMap $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addForeignKey('ATTRIBUTE_ID', 'AttributeId', 'INTEGER', 'attribute', 'ID', true, null, null); $this->addForeignKey('TEMPLATE_ID', 'TemplateId', 'INTEGER', 'template', 'ID', true, null, null); + $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null); + $this->addColumn('ATTRIBUTE_TEMPLATECOL', 'AttributeTemplatecol', 'VARCHAR', false, 45, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -316,12 +328,16 @@ class AttributeTemplateTableMap extends TableMap $criteria->addSelectColumn(AttributeTemplateTableMap::ID); $criteria->addSelectColumn(AttributeTemplateTableMap::ATTRIBUTE_ID); $criteria->addSelectColumn(AttributeTemplateTableMap::TEMPLATE_ID); + $criteria->addSelectColumn(AttributeTemplateTableMap::POSITION); + $criteria->addSelectColumn(AttributeTemplateTableMap::ATTRIBUTE_TEMPLATECOL); $criteria->addSelectColumn(AttributeTemplateTableMap::CREATED_AT); $criteria->addSelectColumn(AttributeTemplateTableMap::UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.ATTRIBUTE_ID'); $criteria->addSelectColumn($alias . '.TEMPLATE_ID'); + $criteria->addSelectColumn($alias . '.POSITION'); + $criteria->addSelectColumn($alias . '.ATTRIBUTE_TEMPLATECOL'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } diff --git a/core/lib/Thelia/Model/Map/FeatureProductTableMap.php b/core/lib/Thelia/Model/Map/FeatureProductTableMap.php index f0263b47c..9db4ec441 100644 --- a/core/lib/Thelia/Model/Map/FeatureProductTableMap.php +++ b/core/lib/Thelia/Model/Map/FeatureProductTableMap.php @@ -90,9 +90,9 @@ class FeatureProductTableMap extends TableMap const FEATURE_AV_ID = 'feature_product.FEATURE_AV_ID'; /** - * the column name for the BY_DEFAULT field + * the column name for the FREE_TEXT_VALUE field */ - const BY_DEFAULT = 'feature_product.BY_DEFAULT'; + const FREE_TEXT_VALUE = 'feature_product.FREE_TEXT_VALUE'; /** * the column name for the POSITION field @@ -121,11 +121,11 @@ class FeatureProductTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'ProductId', 'FeatureId', 'FeatureAvId', 'ByDefault', 'Position', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'productId', 'featureId', 'featureAvId', 'byDefault', 'position', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(FeatureProductTableMap::ID, FeatureProductTableMap::PRODUCT_ID, FeatureProductTableMap::FEATURE_ID, FeatureProductTableMap::FEATURE_AV_ID, FeatureProductTableMap::BY_DEFAULT, FeatureProductTableMap::POSITION, FeatureProductTableMap::CREATED_AT, FeatureProductTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'PRODUCT_ID', 'FEATURE_ID', 'FEATURE_AV_ID', 'BY_DEFAULT', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'product_id', 'feature_id', 'feature_av_id', 'by_default', 'position', 'created_at', 'updated_at', ), + self::TYPE_PHPNAME => array('Id', 'ProductId', 'FeatureId', 'FeatureAvId', 'FreeTextValue', 'Position', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'productId', 'featureId', 'featureAvId', 'freeTextValue', 'position', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(FeatureProductTableMap::ID, FeatureProductTableMap::PRODUCT_ID, FeatureProductTableMap::FEATURE_ID, FeatureProductTableMap::FEATURE_AV_ID, FeatureProductTableMap::FREE_TEXT_VALUE, FeatureProductTableMap::POSITION, FeatureProductTableMap::CREATED_AT, FeatureProductTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'PRODUCT_ID', 'FEATURE_ID', 'FEATURE_AV_ID', 'FREE_TEXT_VALUE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'product_id', 'feature_id', 'feature_av_id', 'free_text_value', 'position', 'created_at', 'updated_at', ), self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, ) ); @@ -136,11 +136,11 @@ class FeatureProductTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'ProductId' => 1, 'FeatureId' => 2, 'FeatureAvId' => 3, 'ByDefault' => 4, 'Position' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'productId' => 1, 'featureId' => 2, 'featureAvId' => 3, 'byDefault' => 4, 'position' => 5, 'createdAt' => 6, 'updatedAt' => 7, ), - self::TYPE_COLNAME => array(FeatureProductTableMap::ID => 0, FeatureProductTableMap::PRODUCT_ID => 1, FeatureProductTableMap::FEATURE_ID => 2, FeatureProductTableMap::FEATURE_AV_ID => 3, FeatureProductTableMap::BY_DEFAULT => 4, FeatureProductTableMap::POSITION => 5, FeatureProductTableMap::CREATED_AT => 6, FeatureProductTableMap::UPDATED_AT => 7, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'PRODUCT_ID' => 1, 'FEATURE_ID' => 2, 'FEATURE_AV_ID' => 3, 'BY_DEFAULT' => 4, 'POSITION' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ), - self::TYPE_FIELDNAME => array('id' => 0, 'product_id' => 1, 'feature_id' => 2, 'feature_av_id' => 3, 'by_default' => 4, 'position' => 5, 'created_at' => 6, 'updated_at' => 7, ), + self::TYPE_PHPNAME => array('Id' => 0, 'ProductId' => 1, 'FeatureId' => 2, 'FeatureAvId' => 3, 'FreeTextValue' => 4, 'Position' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'productId' => 1, 'featureId' => 2, 'featureAvId' => 3, 'freeTextValue' => 4, 'position' => 5, 'createdAt' => 6, 'updatedAt' => 7, ), + self::TYPE_COLNAME => array(FeatureProductTableMap::ID => 0, FeatureProductTableMap::PRODUCT_ID => 1, FeatureProductTableMap::FEATURE_ID => 2, FeatureProductTableMap::FEATURE_AV_ID => 3, FeatureProductTableMap::FREE_TEXT_VALUE => 4, FeatureProductTableMap::POSITION => 5, FeatureProductTableMap::CREATED_AT => 6, FeatureProductTableMap::UPDATED_AT => 7, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'PRODUCT_ID' => 1, 'FEATURE_ID' => 2, 'FEATURE_AV_ID' => 3, 'FREE_TEXT_VALUE' => 4, 'POSITION' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ), + self::TYPE_FIELDNAME => array('id' => 0, 'product_id' => 1, 'feature_id' => 2, 'feature_av_id' => 3, 'free_text_value' => 4, 'position' => 5, 'created_at' => 6, 'updated_at' => 7, ), self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, ) ); @@ -164,7 +164,7 @@ class FeatureProductTableMap extends TableMap $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', true, null, null); $this->addForeignKey('FEATURE_ID', 'FeatureId', 'INTEGER', 'feature', 'ID', true, null, null); $this->addForeignKey('FEATURE_AV_ID', 'FeatureAvId', 'INTEGER', 'feature_av', 'ID', false, null, null); - $this->addColumn('BY_DEFAULT', 'ByDefault', 'VARCHAR', false, 255, null); + $this->addColumn('FREE_TEXT_VALUE', 'FreeTextValue', 'LONGVARCHAR', false, null, null); $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); @@ -335,7 +335,7 @@ class FeatureProductTableMap extends TableMap $criteria->addSelectColumn(FeatureProductTableMap::PRODUCT_ID); $criteria->addSelectColumn(FeatureProductTableMap::FEATURE_ID); $criteria->addSelectColumn(FeatureProductTableMap::FEATURE_AV_ID); - $criteria->addSelectColumn(FeatureProductTableMap::BY_DEFAULT); + $criteria->addSelectColumn(FeatureProductTableMap::FREE_TEXT_VALUE); $criteria->addSelectColumn(FeatureProductTableMap::POSITION); $criteria->addSelectColumn(FeatureProductTableMap::CREATED_AT); $criteria->addSelectColumn(FeatureProductTableMap::UPDATED_AT); @@ -344,7 +344,7 @@ class FeatureProductTableMap extends TableMap $criteria->addSelectColumn($alias . '.PRODUCT_ID'); $criteria->addSelectColumn($alias . '.FEATURE_ID'); $criteria->addSelectColumn($alias . '.FEATURE_AV_ID'); - $criteria->addSelectColumn($alias . '.BY_DEFAULT'); + $criteria->addSelectColumn($alias . '.FREE_TEXT_VALUE'); $criteria->addSelectColumn($alias . '.POSITION'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); diff --git a/core/lib/Thelia/Model/Map/FeatureTableMap.php b/core/lib/Thelia/Model/Map/FeatureTableMap.php index 067a242a3..7aa4c1d5a 100644 --- a/core/lib/Thelia/Model/Map/FeatureTableMap.php +++ b/core/lib/Thelia/Model/Map/FeatureTableMap.php @@ -57,7 +57,7 @@ class FeatureTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 5; + const NUM_COLUMNS = 4; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class FeatureTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 5; + const NUM_HYDRATE_COLUMNS = 4; /** * the column name for the ID field @@ -79,11 +79,6 @@ class FeatureTableMap extends TableMap */ const VISIBLE = 'feature.VISIBLE'; - /** - * the column name for the POSITION field - */ - const POSITION = 'feature.POSITION'; - /** * the column name for the CREATED_AT field */ @@ -115,12 +110,12 @@ class FeatureTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'Visible', 'Position', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'visible', 'position', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(FeatureTableMap::ID, FeatureTableMap::VISIBLE, FeatureTableMap::POSITION, FeatureTableMap::CREATED_AT, FeatureTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'VISIBLE', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'visible', 'position', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, ) + self::TYPE_PHPNAME => array('Id', 'Visible', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'visible', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(FeatureTableMap::ID, FeatureTableMap::VISIBLE, FeatureTableMap::CREATED_AT, FeatureTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'VISIBLE', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'visible', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, ) ); /** @@ -130,12 +125,12 @@ class FeatureTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'Visible' => 1, 'Position' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'visible' => 1, 'position' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), - self::TYPE_COLNAME => array(FeatureTableMap::ID => 0, FeatureTableMap::VISIBLE => 1, FeatureTableMap::POSITION => 2, FeatureTableMap::CREATED_AT => 3, FeatureTableMap::UPDATED_AT => 4, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'VISIBLE' => 1, 'POSITION' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), - self::TYPE_FIELDNAME => array('id' => 0, 'visible' => 1, 'position' => 2, 'created_at' => 3, 'updated_at' => 4, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, ) + self::TYPE_PHPNAME => array('Id' => 0, 'Visible' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'visible' => 1, 'createdAt' => 2, 'updatedAt' => 3, ), + self::TYPE_COLNAME => array(FeatureTableMap::ID => 0, FeatureTableMap::VISIBLE => 1, FeatureTableMap::CREATED_AT => 2, FeatureTableMap::UPDATED_AT => 3, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'VISIBLE' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ), + self::TYPE_FIELDNAME => array('id' => 0, 'visible' => 1, 'created_at' => 2, 'updated_at' => 3, ), + self::TYPE_NUM => array(0, 1, 2, 3, ) ); /** @@ -156,7 +151,6 @@ class FeatureTableMap extends TableMap // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addColumn('VISIBLE', 'Visible', 'INTEGER', false, null, 0); - $this->addColumn('POSITION', 'Position', 'INTEGER', true, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -339,13 +333,11 @@ class FeatureTableMap extends TableMap if (null === $alias) { $criteria->addSelectColumn(FeatureTableMap::ID); $criteria->addSelectColumn(FeatureTableMap::VISIBLE); - $criteria->addSelectColumn(FeatureTableMap::POSITION); $criteria->addSelectColumn(FeatureTableMap::CREATED_AT); $criteria->addSelectColumn(FeatureTableMap::UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.VISIBLE'); - $criteria->addSelectColumn($alias . '.POSITION'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } diff --git a/core/lib/Thelia/Model/Map/FeatureTemplateTableMap.php b/core/lib/Thelia/Model/Map/FeatureTemplateTableMap.php index abb1a98b7..68f3b9a24 100644 --- a/core/lib/Thelia/Model/Map/FeatureTemplateTableMap.php +++ b/core/lib/Thelia/Model/Map/FeatureTemplateTableMap.php @@ -57,7 +57,7 @@ class FeatureTemplateTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 5; + const NUM_COLUMNS = 6; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class FeatureTemplateTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 5; + const NUM_HYDRATE_COLUMNS = 6; /** * the column name for the ID field @@ -84,6 +84,11 @@ class FeatureTemplateTableMap extends TableMap */ const TEMPLATE_ID = 'feature_template.TEMPLATE_ID'; + /** + * the column name for the POSITION field + */ + const POSITION = 'feature_template.POSITION'; + /** * the column name for the CREATED_AT field */ @@ -106,12 +111,12 @@ class FeatureTemplateTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'FeatureId', 'TemplateId', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'featureId', 'templateId', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(FeatureTemplateTableMap::ID, FeatureTemplateTableMap::FEATURE_ID, FeatureTemplateTableMap::TEMPLATE_ID, FeatureTemplateTableMap::CREATED_AT, FeatureTemplateTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'FEATURE_ID', 'TEMPLATE_ID', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'feature_id', 'template_id', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, ) + self::TYPE_PHPNAME => array('Id', 'FeatureId', 'TemplateId', 'Position', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'featureId', 'templateId', 'position', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(FeatureTemplateTableMap::ID, FeatureTemplateTableMap::FEATURE_ID, FeatureTemplateTableMap::TEMPLATE_ID, FeatureTemplateTableMap::POSITION, FeatureTemplateTableMap::CREATED_AT, FeatureTemplateTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'FEATURE_ID', 'TEMPLATE_ID', 'POSITION', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'feature_id', 'template_id', 'position', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) ); /** @@ -121,12 +126,12 @@ class FeatureTemplateTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'FeatureId' => 1, 'TemplateId' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'featureId' => 1, 'templateId' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), - self::TYPE_COLNAME => array(FeatureTemplateTableMap::ID => 0, FeatureTemplateTableMap::FEATURE_ID => 1, FeatureTemplateTableMap::TEMPLATE_ID => 2, FeatureTemplateTableMap::CREATED_AT => 3, FeatureTemplateTableMap::UPDATED_AT => 4, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'FEATURE_ID' => 1, 'TEMPLATE_ID' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), - self::TYPE_FIELDNAME => array('id' => 0, 'feature_id' => 1, 'template_id' => 2, 'created_at' => 3, 'updated_at' => 4, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, ) + self::TYPE_PHPNAME => array('Id' => 0, 'FeatureId' => 1, 'TemplateId' => 2, 'Position' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'featureId' => 1, 'templateId' => 2, 'position' => 3, 'createdAt' => 4, 'updatedAt' => 5, ), + self::TYPE_COLNAME => array(FeatureTemplateTableMap::ID => 0, FeatureTemplateTableMap::FEATURE_ID => 1, FeatureTemplateTableMap::TEMPLATE_ID => 2, FeatureTemplateTableMap::POSITION => 3, FeatureTemplateTableMap::CREATED_AT => 4, FeatureTemplateTableMap::UPDATED_AT => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'FEATURE_ID' => 1, 'TEMPLATE_ID' => 2, 'POSITION' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'feature_id' => 1, 'template_id' => 2, 'position' => 3, 'created_at' => 4, 'updated_at' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) ); /** @@ -149,6 +154,7 @@ class FeatureTemplateTableMap extends TableMap $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addForeignKey('FEATURE_ID', 'FeatureId', 'INTEGER', 'feature', 'ID', true, null, null); $this->addForeignKey('TEMPLATE_ID', 'TemplateId', 'INTEGER', 'template', 'ID', true, null, null); + $this->addColumn('POSITION', 'Position', 'INTEGER', false, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -316,12 +322,14 @@ class FeatureTemplateTableMap extends TableMap $criteria->addSelectColumn(FeatureTemplateTableMap::ID); $criteria->addSelectColumn(FeatureTemplateTableMap::FEATURE_ID); $criteria->addSelectColumn(FeatureTemplateTableMap::TEMPLATE_ID); + $criteria->addSelectColumn(FeatureTemplateTableMap::POSITION); $criteria->addSelectColumn(FeatureTemplateTableMap::CREATED_AT); $criteria->addSelectColumn(FeatureTemplateTableMap::UPDATED_AT); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.FEATURE_ID'); $criteria->addSelectColumn($alias . '.TEMPLATE_ID'); + $criteria->addSelectColumn($alias . '.POSITION'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } diff --git a/core/lib/Thelia/Model/Map/OrderProductAttributeCombinationTableMap.php b/core/lib/Thelia/Model/Map/OrderProductAttributeCombinationTableMap.php index 582bd2305..3c3aee2f9 100644 --- a/core/lib/Thelia/Model/Map/OrderProductAttributeCombinationTableMap.php +++ b/core/lib/Thelia/Model/Map/OrderProductAttributeCombinationTableMap.php @@ -95,9 +95,9 @@ class OrderProductAttributeCombinationTableMap extends TableMap const ATTRIBUTE_DESCRIPTION = 'order_product_attribute_combination.ATTRIBUTE_DESCRIPTION'; /** - * the column name for the ATTRIBUTE_POSTSCRIPTUMN field + * the column name for the ATTRIBUTE_POSTSCRIPTUM field */ - const ATTRIBUTE_POSTSCRIPTUMN = 'order_product_attribute_combination.ATTRIBUTE_POSTSCRIPTUMN'; + const ATTRIBUTE_POSTSCRIPTUM = 'order_product_attribute_combination.ATTRIBUTE_POSTSCRIPTUM'; /** * the column name for the ATTRIBUTE_AV_TITLE field @@ -141,11 +141,11 @@ class OrderProductAttributeCombinationTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'OrderProductId', 'AttributeTitle', 'AttributeChapo', 'AttributeDescription', 'AttributePostscriptumn', 'AttributeAvTitle', 'AttributeAvChapo', 'AttributeAvDescription', 'AttributeAvPostscriptum', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'orderProductId', 'attributeTitle', 'attributeChapo', 'attributeDescription', 'attributePostscriptumn', 'attributeAvTitle', 'attributeAvChapo', 'attributeAvDescription', 'attributeAvPostscriptum', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(OrderProductAttributeCombinationTableMap::ID, OrderProductAttributeCombinationTableMap::ORDER_PRODUCT_ID, OrderProductAttributeCombinationTableMap::ATTRIBUTE_TITLE, OrderProductAttributeCombinationTableMap::ATTRIBUTE_CHAPO, OrderProductAttributeCombinationTableMap::ATTRIBUTE_DESCRIPTION, OrderProductAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUMN, OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_TITLE, OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_CHAPO, OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_DESCRIPTION, OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_POSTSCRIPTUM, OrderProductAttributeCombinationTableMap::CREATED_AT, OrderProductAttributeCombinationTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'ORDER_PRODUCT_ID', 'ATTRIBUTE_TITLE', 'ATTRIBUTE_CHAPO', 'ATTRIBUTE_DESCRIPTION', 'ATTRIBUTE_POSTSCRIPTUMN', 'ATTRIBUTE_AV_TITLE', 'ATTRIBUTE_AV_CHAPO', 'ATTRIBUTE_AV_DESCRIPTION', 'ATTRIBUTE_AV_POSTSCRIPTUM', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'order_product_id', 'attribute_title', 'attribute_chapo', 'attribute_description', 'attribute_postscriptumn', 'attribute_av_title', 'attribute_av_chapo', 'attribute_av_description', 'attribute_av_postscriptum', 'created_at', 'updated_at', ), + self::TYPE_PHPNAME => array('Id', 'OrderProductId', 'AttributeTitle', 'AttributeChapo', 'AttributeDescription', 'AttributePostscriptum', 'AttributeAvTitle', 'AttributeAvChapo', 'AttributeAvDescription', 'AttributeAvPostscriptum', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'orderProductId', 'attributeTitle', 'attributeChapo', 'attributeDescription', 'attributePostscriptum', 'attributeAvTitle', 'attributeAvChapo', 'attributeAvDescription', 'attributeAvPostscriptum', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(OrderProductAttributeCombinationTableMap::ID, OrderProductAttributeCombinationTableMap::ORDER_PRODUCT_ID, OrderProductAttributeCombinationTableMap::ATTRIBUTE_TITLE, OrderProductAttributeCombinationTableMap::ATTRIBUTE_CHAPO, OrderProductAttributeCombinationTableMap::ATTRIBUTE_DESCRIPTION, OrderProductAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUM, OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_TITLE, OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_CHAPO, OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_DESCRIPTION, OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_POSTSCRIPTUM, OrderProductAttributeCombinationTableMap::CREATED_AT, OrderProductAttributeCombinationTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'ORDER_PRODUCT_ID', 'ATTRIBUTE_TITLE', 'ATTRIBUTE_CHAPO', 'ATTRIBUTE_DESCRIPTION', 'ATTRIBUTE_POSTSCRIPTUM', 'ATTRIBUTE_AV_TITLE', 'ATTRIBUTE_AV_CHAPO', 'ATTRIBUTE_AV_DESCRIPTION', 'ATTRIBUTE_AV_POSTSCRIPTUM', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'order_product_id', 'attribute_title', 'attribute_chapo', 'attribute_description', 'attribute_postscriptum', 'attribute_av_title', 'attribute_av_chapo', 'attribute_av_description', 'attribute_av_postscriptum', 'created_at', 'updated_at', ), self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ) ); @@ -156,11 +156,11 @@ class OrderProductAttributeCombinationTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'OrderProductId' => 1, 'AttributeTitle' => 2, 'AttributeChapo' => 3, 'AttributeDescription' => 4, 'AttributePostscriptumn' => 5, 'AttributeAvTitle' => 6, 'AttributeAvChapo' => 7, 'AttributeAvDescription' => 8, 'AttributeAvPostscriptum' => 9, 'CreatedAt' => 10, 'UpdatedAt' => 11, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'orderProductId' => 1, 'attributeTitle' => 2, 'attributeChapo' => 3, 'attributeDescription' => 4, 'attributePostscriptumn' => 5, 'attributeAvTitle' => 6, 'attributeAvChapo' => 7, 'attributeAvDescription' => 8, 'attributeAvPostscriptum' => 9, 'createdAt' => 10, 'updatedAt' => 11, ), - self::TYPE_COLNAME => array(OrderProductAttributeCombinationTableMap::ID => 0, OrderProductAttributeCombinationTableMap::ORDER_PRODUCT_ID => 1, OrderProductAttributeCombinationTableMap::ATTRIBUTE_TITLE => 2, OrderProductAttributeCombinationTableMap::ATTRIBUTE_CHAPO => 3, OrderProductAttributeCombinationTableMap::ATTRIBUTE_DESCRIPTION => 4, OrderProductAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUMN => 5, OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_TITLE => 6, OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_CHAPO => 7, OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_DESCRIPTION => 8, OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_POSTSCRIPTUM => 9, OrderProductAttributeCombinationTableMap::CREATED_AT => 10, OrderProductAttributeCombinationTableMap::UPDATED_AT => 11, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'ORDER_PRODUCT_ID' => 1, 'ATTRIBUTE_TITLE' => 2, 'ATTRIBUTE_CHAPO' => 3, 'ATTRIBUTE_DESCRIPTION' => 4, 'ATTRIBUTE_POSTSCRIPTUMN' => 5, 'ATTRIBUTE_AV_TITLE' => 6, 'ATTRIBUTE_AV_CHAPO' => 7, 'ATTRIBUTE_AV_DESCRIPTION' => 8, 'ATTRIBUTE_AV_POSTSCRIPTUM' => 9, 'CREATED_AT' => 10, 'UPDATED_AT' => 11, ), - self::TYPE_FIELDNAME => array('id' => 0, 'order_product_id' => 1, 'attribute_title' => 2, 'attribute_chapo' => 3, 'attribute_description' => 4, 'attribute_postscriptumn' => 5, 'attribute_av_title' => 6, 'attribute_av_chapo' => 7, 'attribute_av_description' => 8, 'attribute_av_postscriptum' => 9, 'created_at' => 10, 'updated_at' => 11, ), + self::TYPE_PHPNAME => array('Id' => 0, 'OrderProductId' => 1, 'AttributeTitle' => 2, 'AttributeChapo' => 3, 'AttributeDescription' => 4, 'AttributePostscriptum' => 5, 'AttributeAvTitle' => 6, 'AttributeAvChapo' => 7, 'AttributeAvDescription' => 8, 'AttributeAvPostscriptum' => 9, 'CreatedAt' => 10, 'UpdatedAt' => 11, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'orderProductId' => 1, 'attributeTitle' => 2, 'attributeChapo' => 3, 'attributeDescription' => 4, 'attributePostscriptum' => 5, 'attributeAvTitle' => 6, 'attributeAvChapo' => 7, 'attributeAvDescription' => 8, 'attributeAvPostscriptum' => 9, 'createdAt' => 10, 'updatedAt' => 11, ), + self::TYPE_COLNAME => array(OrderProductAttributeCombinationTableMap::ID => 0, OrderProductAttributeCombinationTableMap::ORDER_PRODUCT_ID => 1, OrderProductAttributeCombinationTableMap::ATTRIBUTE_TITLE => 2, OrderProductAttributeCombinationTableMap::ATTRIBUTE_CHAPO => 3, OrderProductAttributeCombinationTableMap::ATTRIBUTE_DESCRIPTION => 4, OrderProductAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUM => 5, OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_TITLE => 6, OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_CHAPO => 7, OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_DESCRIPTION => 8, OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_POSTSCRIPTUM => 9, OrderProductAttributeCombinationTableMap::CREATED_AT => 10, OrderProductAttributeCombinationTableMap::UPDATED_AT => 11, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'ORDER_PRODUCT_ID' => 1, 'ATTRIBUTE_TITLE' => 2, 'ATTRIBUTE_CHAPO' => 3, 'ATTRIBUTE_DESCRIPTION' => 4, 'ATTRIBUTE_POSTSCRIPTUM' => 5, 'ATTRIBUTE_AV_TITLE' => 6, 'ATTRIBUTE_AV_CHAPO' => 7, 'ATTRIBUTE_AV_DESCRIPTION' => 8, 'ATTRIBUTE_AV_POSTSCRIPTUM' => 9, 'CREATED_AT' => 10, 'UPDATED_AT' => 11, ), + self::TYPE_FIELDNAME => array('id' => 0, 'order_product_id' => 1, 'attribute_title' => 2, 'attribute_chapo' => 3, 'attribute_description' => 4, 'attribute_postscriptum' => 5, 'attribute_av_title' => 6, 'attribute_av_chapo' => 7, 'attribute_av_description' => 8, 'attribute_av_postscriptum' => 9, 'created_at' => 10, 'updated_at' => 11, ), self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ) ); @@ -185,7 +185,7 @@ class OrderProductAttributeCombinationTableMap extends TableMap $this->addColumn('ATTRIBUTE_TITLE', 'AttributeTitle', 'VARCHAR', true, 255, null); $this->addColumn('ATTRIBUTE_CHAPO', 'AttributeChapo', 'LONGVARCHAR', false, null, null); $this->addColumn('ATTRIBUTE_DESCRIPTION', 'AttributeDescription', 'CLOB', false, null, null); - $this->addColumn('ATTRIBUTE_POSTSCRIPTUMN', 'AttributePostscriptumn', 'LONGVARCHAR', false, null, null); + $this->addColumn('ATTRIBUTE_POSTSCRIPTUM', 'AttributePostscriptum', 'LONGVARCHAR', false, null, null); $this->addColumn('ATTRIBUTE_AV_TITLE', 'AttributeAvTitle', 'VARCHAR', true, 255, null); $this->addColumn('ATTRIBUTE_AV_CHAPO', 'AttributeAvChapo', 'LONGVARCHAR', false, null, null); $this->addColumn('ATTRIBUTE_AV_DESCRIPTION', 'AttributeAvDescription', 'CLOB', false, null, null); @@ -358,7 +358,7 @@ class OrderProductAttributeCombinationTableMap extends TableMap $criteria->addSelectColumn(OrderProductAttributeCombinationTableMap::ATTRIBUTE_TITLE); $criteria->addSelectColumn(OrderProductAttributeCombinationTableMap::ATTRIBUTE_CHAPO); $criteria->addSelectColumn(OrderProductAttributeCombinationTableMap::ATTRIBUTE_DESCRIPTION); - $criteria->addSelectColumn(OrderProductAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUMN); + $criteria->addSelectColumn(OrderProductAttributeCombinationTableMap::ATTRIBUTE_POSTSCRIPTUM); $criteria->addSelectColumn(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_TITLE); $criteria->addSelectColumn(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_CHAPO); $criteria->addSelectColumn(OrderProductAttributeCombinationTableMap::ATTRIBUTE_AV_DESCRIPTION); @@ -371,7 +371,7 @@ class OrderProductAttributeCombinationTableMap extends TableMap $criteria->addSelectColumn($alias . '.ATTRIBUTE_TITLE'); $criteria->addSelectColumn($alias . '.ATTRIBUTE_CHAPO'); $criteria->addSelectColumn($alias . '.ATTRIBUTE_DESCRIPTION'); - $criteria->addSelectColumn($alias . '.ATTRIBUTE_POSTSCRIPTUMN'); + $criteria->addSelectColumn($alias . '.ATTRIBUTE_POSTSCRIPTUM'); $criteria->addSelectColumn($alias . '.ATTRIBUTE_AV_TITLE'); $criteria->addSelectColumn($alias . '.ATTRIBUTE_AV_CHAPO'); $criteria->addSelectColumn($alias . '.ATTRIBUTE_AV_DESCRIPTION'); diff --git a/core/lib/Thelia/Model/Map/OrderProductTaxTableMap.php b/core/lib/Thelia/Model/Map/OrderProductTaxTableMap.php index 2e8460a6a..98994c6e4 100644 --- a/core/lib/Thelia/Model/Map/OrderProductTaxTableMap.php +++ b/core/lib/Thelia/Model/Map/OrderProductTaxTableMap.php @@ -57,7 +57,7 @@ class OrderProductTaxTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 7; + const NUM_COLUMNS = 8; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class OrderProductTaxTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 7; + const NUM_HYDRATE_COLUMNS = 8; /** * the column name for the ID field @@ -94,6 +94,11 @@ class OrderProductTaxTableMap extends TableMap */ const AMOUNT = 'order_product_tax.AMOUNT'; + /** + * the column name for the PROMO_AMOUNT field + */ + const PROMO_AMOUNT = 'order_product_tax.PROMO_AMOUNT'; + /** * the column name for the CREATED_AT field */ @@ -116,12 +121,12 @@ class OrderProductTaxTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'OrderProductId', 'Title', 'Description', 'Amount', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'orderProductId', 'title', 'description', 'amount', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(OrderProductTaxTableMap::ID, OrderProductTaxTableMap::ORDER_PRODUCT_ID, OrderProductTaxTableMap::TITLE, OrderProductTaxTableMap::DESCRIPTION, OrderProductTaxTableMap::AMOUNT, OrderProductTaxTableMap::CREATED_AT, OrderProductTaxTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'ORDER_PRODUCT_ID', 'TITLE', 'DESCRIPTION', 'AMOUNT', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'order_product_id', 'title', 'description', 'amount', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) + self::TYPE_PHPNAME => array('Id', 'OrderProductId', 'Title', 'Description', 'Amount', 'PromoAmount', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'orderProductId', 'title', 'description', 'amount', 'promoAmount', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(OrderProductTaxTableMap::ID, OrderProductTaxTableMap::ORDER_PRODUCT_ID, OrderProductTaxTableMap::TITLE, OrderProductTaxTableMap::DESCRIPTION, OrderProductTaxTableMap::AMOUNT, OrderProductTaxTableMap::PROMO_AMOUNT, OrderProductTaxTableMap::CREATED_AT, OrderProductTaxTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'ORDER_PRODUCT_ID', 'TITLE', 'DESCRIPTION', 'AMOUNT', 'PROMO_AMOUNT', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'order_product_id', 'title', 'description', 'amount', 'promo_amount', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, ) ); /** @@ -131,12 +136,12 @@ class OrderProductTaxTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'OrderProductId' => 1, 'Title' => 2, 'Description' => 3, 'Amount' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'orderProductId' => 1, 'title' => 2, 'description' => 3, 'amount' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), - self::TYPE_COLNAME => array(OrderProductTaxTableMap::ID => 0, OrderProductTaxTableMap::ORDER_PRODUCT_ID => 1, OrderProductTaxTableMap::TITLE => 2, OrderProductTaxTableMap::DESCRIPTION => 3, OrderProductTaxTableMap::AMOUNT => 4, OrderProductTaxTableMap::CREATED_AT => 5, OrderProductTaxTableMap::UPDATED_AT => 6, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'ORDER_PRODUCT_ID' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'AMOUNT' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), - self::TYPE_FIELDNAME => array('id' => 0, 'order_product_id' => 1, 'title' => 2, 'description' => 3, 'amount' => 4, 'created_at' => 5, 'updated_at' => 6, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) + self::TYPE_PHPNAME => array('Id' => 0, 'OrderProductId' => 1, 'Title' => 2, 'Description' => 3, 'Amount' => 4, 'PromoAmount' => 5, 'CreatedAt' => 6, 'UpdatedAt' => 7, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'orderProductId' => 1, 'title' => 2, 'description' => 3, 'amount' => 4, 'promoAmount' => 5, 'createdAt' => 6, 'updatedAt' => 7, ), + self::TYPE_COLNAME => array(OrderProductTaxTableMap::ID => 0, OrderProductTaxTableMap::ORDER_PRODUCT_ID => 1, OrderProductTaxTableMap::TITLE => 2, OrderProductTaxTableMap::DESCRIPTION => 3, OrderProductTaxTableMap::AMOUNT => 4, OrderProductTaxTableMap::PROMO_AMOUNT => 5, OrderProductTaxTableMap::CREATED_AT => 6, OrderProductTaxTableMap::UPDATED_AT => 7, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'ORDER_PRODUCT_ID' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'AMOUNT' => 4, 'PROMO_AMOUNT' => 5, 'CREATED_AT' => 6, 'UPDATED_AT' => 7, ), + self::TYPE_FIELDNAME => array('id' => 0, 'order_product_id' => 1, 'title' => 2, 'description' => 3, 'amount' => 4, 'promo_amount' => 5, 'created_at' => 6, 'updated_at' => 7, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, ) ); /** @@ -160,6 +165,7 @@ class OrderProductTaxTableMap extends TableMap $this->addColumn('TITLE', 'Title', 'VARCHAR', true, 255, null); $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); $this->addColumn('AMOUNT', 'Amount', 'FLOAT', true, null, null); + $this->addColumn('PROMO_AMOUNT', 'PromoAmount', 'FLOAT', false, null, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -328,6 +334,7 @@ class OrderProductTaxTableMap extends TableMap $criteria->addSelectColumn(OrderProductTaxTableMap::TITLE); $criteria->addSelectColumn(OrderProductTaxTableMap::DESCRIPTION); $criteria->addSelectColumn(OrderProductTaxTableMap::AMOUNT); + $criteria->addSelectColumn(OrderProductTaxTableMap::PROMO_AMOUNT); $criteria->addSelectColumn(OrderProductTaxTableMap::CREATED_AT); $criteria->addSelectColumn(OrderProductTaxTableMap::UPDATED_AT); } else { @@ -336,6 +343,7 @@ class OrderProductTaxTableMap extends TableMap $criteria->addSelectColumn($alias . '.TITLE'); $criteria->addSelectColumn($alias . '.DESCRIPTION'); $criteria->addSelectColumn($alias . '.AMOUNT'); + $criteria->addSelectColumn($alias . '.PROMO_AMOUNT'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } diff --git a/core/lib/Thelia/Model/Map/ProductSaleElementsTableMap.php b/core/lib/Thelia/Model/Map/ProductSaleElementsTableMap.php index fc23ae569..1e894ef24 100644 --- a/core/lib/Thelia/Model/Map/ProductSaleElementsTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductSaleElementsTableMap.php @@ -57,7 +57,7 @@ class ProductSaleElementsTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 9; + const NUM_COLUMNS = 10; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class ProductSaleElementsTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 9; + const NUM_HYDRATE_COLUMNS = 10; /** * the column name for the ID field @@ -104,6 +104,11 @@ class ProductSaleElementsTableMap extends TableMap */ const WEIGHT = 'product_sale_elements.WEIGHT'; + /** + * the column name for the IS_DEFAULT field + */ + const IS_DEFAULT = 'product_sale_elements.IS_DEFAULT'; + /** * the column name for the CREATED_AT field */ @@ -126,12 +131,12 @@ class ProductSaleElementsTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'ProductId', 'Ref', 'Quantity', 'Promo', 'Newness', 'Weight', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'productId', 'ref', 'quantity', 'promo', 'newness', 'weight', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(ProductSaleElementsTableMap::ID, ProductSaleElementsTableMap::PRODUCT_ID, ProductSaleElementsTableMap::REF, ProductSaleElementsTableMap::QUANTITY, ProductSaleElementsTableMap::PROMO, ProductSaleElementsTableMap::NEWNESS, ProductSaleElementsTableMap::WEIGHT, ProductSaleElementsTableMap::CREATED_AT, ProductSaleElementsTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'PRODUCT_ID', 'REF', 'QUANTITY', 'PROMO', 'NEWNESS', 'WEIGHT', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'product_id', 'ref', 'quantity', 'promo', 'newness', 'weight', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) + self::TYPE_PHPNAME => array('Id', 'ProductId', 'Ref', 'Quantity', 'Promo', 'Newness', 'Weight', 'IsDefault', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'productId', 'ref', 'quantity', 'promo', 'newness', 'weight', 'isDefault', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(ProductSaleElementsTableMap::ID, ProductSaleElementsTableMap::PRODUCT_ID, ProductSaleElementsTableMap::REF, ProductSaleElementsTableMap::QUANTITY, ProductSaleElementsTableMap::PROMO, ProductSaleElementsTableMap::NEWNESS, ProductSaleElementsTableMap::WEIGHT, ProductSaleElementsTableMap::IS_DEFAULT, ProductSaleElementsTableMap::CREATED_AT, ProductSaleElementsTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'PRODUCT_ID', 'REF', 'QUANTITY', 'PROMO', 'NEWNESS', 'WEIGHT', 'IS_DEFAULT', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'product_id', 'ref', 'quantity', 'promo', 'newness', 'weight', 'is_default', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) ); /** @@ -141,12 +146,12 @@ class ProductSaleElementsTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'ProductId' => 1, 'Ref' => 2, 'Quantity' => 3, 'Promo' => 4, 'Newness' => 5, 'Weight' => 6, 'CreatedAt' => 7, 'UpdatedAt' => 8, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'productId' => 1, 'ref' => 2, 'quantity' => 3, 'promo' => 4, 'newness' => 5, 'weight' => 6, 'createdAt' => 7, 'updatedAt' => 8, ), - self::TYPE_COLNAME => array(ProductSaleElementsTableMap::ID => 0, ProductSaleElementsTableMap::PRODUCT_ID => 1, ProductSaleElementsTableMap::REF => 2, ProductSaleElementsTableMap::QUANTITY => 3, ProductSaleElementsTableMap::PROMO => 4, ProductSaleElementsTableMap::NEWNESS => 5, ProductSaleElementsTableMap::WEIGHT => 6, ProductSaleElementsTableMap::CREATED_AT => 7, ProductSaleElementsTableMap::UPDATED_AT => 8, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'PRODUCT_ID' => 1, 'REF' => 2, 'QUANTITY' => 3, 'PROMO' => 4, 'NEWNESS' => 5, 'WEIGHT' => 6, 'CREATED_AT' => 7, 'UPDATED_AT' => 8, ), - self::TYPE_FIELDNAME => array('id' => 0, 'product_id' => 1, 'ref' => 2, 'quantity' => 3, 'promo' => 4, 'newness' => 5, 'weight' => 6, 'created_at' => 7, 'updated_at' => 8, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, ) + self::TYPE_PHPNAME => array('Id' => 0, 'ProductId' => 1, 'Ref' => 2, 'Quantity' => 3, 'Promo' => 4, 'Newness' => 5, 'Weight' => 6, 'IsDefault' => 7, 'CreatedAt' => 8, 'UpdatedAt' => 9, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'productId' => 1, 'ref' => 2, 'quantity' => 3, 'promo' => 4, 'newness' => 5, 'weight' => 6, 'isDefault' => 7, 'createdAt' => 8, 'updatedAt' => 9, ), + self::TYPE_COLNAME => array(ProductSaleElementsTableMap::ID => 0, ProductSaleElementsTableMap::PRODUCT_ID => 1, ProductSaleElementsTableMap::REF => 2, ProductSaleElementsTableMap::QUANTITY => 3, ProductSaleElementsTableMap::PROMO => 4, ProductSaleElementsTableMap::NEWNESS => 5, ProductSaleElementsTableMap::WEIGHT => 6, ProductSaleElementsTableMap::IS_DEFAULT => 7, ProductSaleElementsTableMap::CREATED_AT => 8, ProductSaleElementsTableMap::UPDATED_AT => 9, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'PRODUCT_ID' => 1, 'REF' => 2, 'QUANTITY' => 3, 'PROMO' => 4, 'NEWNESS' => 5, 'WEIGHT' => 6, 'IS_DEFAULT' => 7, 'CREATED_AT' => 8, 'UPDATED_AT' => 9, ), + self::TYPE_FIELDNAME => array('id' => 0, 'product_id' => 1, 'ref' => 2, 'quantity' => 3, 'promo' => 4, 'newness' => 5, 'weight' => 6, 'is_default' => 7, 'created_at' => 8, 'updated_at' => 9, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) ); /** @@ -167,11 +172,12 @@ class ProductSaleElementsTableMap extends TableMap // columns $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addForeignKey('PRODUCT_ID', 'ProductId', 'INTEGER', 'product', 'ID', true, null, null); - $this->addColumn('REF', 'Ref', 'VARCHAR', true, 45, null); + $this->addColumn('REF', 'Ref', 'VARCHAR', true, 255, null); $this->addColumn('QUANTITY', 'Quantity', 'FLOAT', true, null, null); $this->addColumn('PROMO', 'Promo', 'TINYINT', false, null, 0); $this->addColumn('NEWNESS', 'Newness', 'TINYINT', false, null, 0); - $this->addColumn('WEIGHT', 'Weight', 'FLOAT', false, null, null); + $this->addColumn('WEIGHT', 'Weight', 'FLOAT', false, null, 0); + $this->addColumn('IS_DEFAULT', 'IsDefault', 'BOOLEAN', false, 1, false); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -355,6 +361,7 @@ class ProductSaleElementsTableMap extends TableMap $criteria->addSelectColumn(ProductSaleElementsTableMap::PROMO); $criteria->addSelectColumn(ProductSaleElementsTableMap::NEWNESS); $criteria->addSelectColumn(ProductSaleElementsTableMap::WEIGHT); + $criteria->addSelectColumn(ProductSaleElementsTableMap::IS_DEFAULT); $criteria->addSelectColumn(ProductSaleElementsTableMap::CREATED_AT); $criteria->addSelectColumn(ProductSaleElementsTableMap::UPDATED_AT); } else { @@ -365,6 +372,7 @@ class ProductSaleElementsTableMap extends TableMap $criteria->addSelectColumn($alias . '.PROMO'); $criteria->addSelectColumn($alias . '.NEWNESS'); $criteria->addSelectColumn($alias . '.WEIGHT'); + $criteria->addSelectColumn($alias . '.IS_DEFAULT'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } diff --git a/core/lib/Thelia/Model/Order.php b/core/lib/Thelia/Model/Order.php index fd5164513..f0102a962 100755 --- a/core/lib/Thelia/Model/Order.php +++ b/core/lib/Thelia/Model/Order.php @@ -62,9 +62,15 @@ class Order extends BaseOrder /* browse all products */ $orderProductIds = array(); foreach($this->getOrderProducts() as $orderProduct) { - $taxAmount = OrderProductTaxQuery::create() - ->withColumn('SUM(' . OrderProductTaxTableMap::AMOUNT . ')', 'total_tax') - ->filterByOrderProductId($orderProduct->getId(), Criteria::EQUAL) + $taxAmountQuery = OrderProductTaxQuery::create(); + + if($orderProduct->getWasInPromo() == 1) { + $taxAmountQuery->withColumn('SUM(' . OrderProductTaxTableMap::PROMO_AMOUNT . ')', 'total_tax'); + } else { + $taxAmountQuery->withColumn('SUM(' . OrderProductTaxTableMap::AMOUNT . ')', 'total_tax'); + } + + $taxAmount = $taxAmountQuery->filterByOrderProductId($orderProduct->getId(), Criteria::EQUAL) ->findOne(); $amount += ($orderProduct->getWasInPromo() == 1 ? $orderProduct->getPromoPrice() : $orderProduct->getPrice()) * $orderProduct->getQuantity(); $tax += round($taxAmount->getVirtualColumn('total_tax'), 2) * $orderProduct->getQuantity(); diff --git a/core/lib/Thelia/Model/TaxRule.php b/core/lib/Thelia/Model/TaxRule.php index 024fd8923..e66e013d0 100755 --- a/core/lib/Thelia/Model/TaxRule.php +++ b/core/lib/Thelia/Model/TaxRule.php @@ -11,16 +11,23 @@ class TaxRule extends BaseTaxRule /** * @param Country $country * @param $untaxedAmount + * @param $untaxedPromoAmount * @param null $askedLocale * * @return OrderProductTaxCollection */ - public function getTaxDetail(Country $country, $untaxedAmount, $askedLocale = null) + public function getTaxDetail(Country $country, $untaxedAmount, $untaxedPromoAmount, $askedLocale = null) { $taxCalculator = new Calculator(); $taxCollection = new OrderProductTaxCollection(); $taxCalculator->loadTaxRule($this, $country)->getTaxedPrice($untaxedAmount, $taxCollection, $askedLocale); + $promoTaxCollection = new OrderProductTaxCollection(); + $taxCalculator->loadTaxRule($this, $country)->getTaxedPrice($untaxedPromoAmount, $promoTaxCollection, $askedLocale); + + foreach($taxCollection as $index => $tax) { + $tax->setPromoAmount($promoTaxCollection->getKey($index)->getAmount()); + } return $taxCollection; } diff --git a/core/lib/Thelia/Tests/Action/OrderTest.php b/core/lib/Thelia/Tests/Action/OrderTest.php index 3802b362f..18288fae2 100644 --- a/core/lib/Thelia/Tests/Action/OrderTest.php +++ b/core/lib/Thelia/Tests/Action/OrderTest.php @@ -159,7 +159,7 @@ class OrderTest extends \PHPUnit_Framework_TestCase ->setCart($cart) ->setProduct($pse->getProduct()) ->setProductSaleElements($pse) - ->setQuantity($i) + ->setQuantity($i+1) ->setPrice($pse->getPrice()) ->setPromoPrice($pse->getPromoPrice()) ->setPromo($pse->getPromo()) @@ -343,9 +343,10 @@ class OrderTest extends \PHPUnit_Framework_TestCase /* check tax */ $orderProductTaxList = $orderProduct->getOrderProductTaxes(); - foreach($cartItem->getProduct()->getTaxRule()->getTaxDetail($validDeliveryAddress->getCountry(), $cartItem->getPromo() == 1 ? $cartItem->getPromoPrice() : $cartItem->getPrice()) as $index => $tax) { + foreach($cartItem->getProduct()->getTaxRule()->getTaxDetail($validDeliveryAddress->getCountry(), $cartItem->getPrice(), $cartItem->getPromoPrice()) as $index => $tax) { $orderProductTax = $orderProductTaxList[$index]; $this->assertEquals($tax->getAmount(), $orderProductTax->getAmount()); + $this->assertEquals($tax->getPromoAmount(), $orderProductTax->getPromoAmount()); } } diff --git a/install/faker.php b/install/faker.php index 60232e2ea..22ee3c7b2 100755 --- a/install/faker.php +++ b/install/faker.php @@ -225,7 +225,7 @@ try { for($i=0; $i<4; $i++) { $feature = new Thelia\Model\Feature(); $feature->setVisible(1); - $feature->setPosition($i); + //$feature->setPosition($i); setI18n($faker, $feature); $feature->save(); @@ -249,7 +249,7 @@ try { $attributeList = array(); for($i=0; $i<4; $i++) { $attribute = new Thelia\Model\Attribute(); - $attribute->setPosition($i); + //$attribute->setPosition($i); setI18n($faker, $attribute); $attribute->save(); @@ -460,7 +460,7 @@ try { $featureAvId[array_rand($featureAvId, 1)] ); } else { //no av - $featureProduct->setByDefault($faker->text(10)); + $featureProduct->setFreeTextValue($faker->text(10)); } $featureProduct->save(); diff --git a/install/thelia.sql b/install/thelia.sql index d8d8e46b3..84fe21b95 100755 --- a/install/thelia.sql +++ b/install/thelia.sql @@ -51,7 +51,7 @@ CREATE TABLE `product` REFERENCES `tax_rule` (`id`) ON UPDATE RESTRICT ON DELETE SET NULL, - CONSTRAINT `fk_product_template1` + CONSTRAINT `fk_product_template` FOREIGN KEY (`template_id`) REFERENCES `template` (`id`) ) ENGINE=InnoDB; @@ -186,7 +186,6 @@ CREATE TABLE `feature` ( `id` INTEGER NOT NULL AUTO_INCREMENT, `visible` INTEGER DEFAULT 0, - `position` INTEGER NOT NULL, `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`) @@ -226,7 +225,7 @@ CREATE TABLE `feature_product` `product_id` INTEGER NOT NULL, `feature_id` INTEGER NOT NULL, `feature_av_id` INTEGER, - `by_default` VARCHAR(255), + `free_text_value` TEXT, `position` INTEGER, `created_at` DATETIME, `updated_at` DATETIME, @@ -262,6 +261,7 @@ CREATE TABLE `feature_template` `id` INTEGER NOT NULL AUTO_INCREMENT, `feature_id` INTEGER NOT NULL, `template_id` INTEGER NOT NULL, + `position` INTEGER, `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`), @@ -286,7 +286,6 @@ DROP TABLE IF EXISTS `attribute`; CREATE TABLE `attribute` ( `id` INTEGER NOT NULL AUTO_INCREMENT, - `position` INTEGER, `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`) @@ -358,11 +357,12 @@ CREATE TABLE `product_sale_elements` ( `id` INTEGER NOT NULL AUTO_INCREMENT, `product_id` INTEGER NOT NULL, - `ref` VARCHAR(45) NOT NULL, + `ref` VARCHAR(255) NOT NULL, `quantity` FLOAT NOT NULL, `promo` TINYINT DEFAULT 0, `newness` TINYINT DEFAULT 0, - `weight` FLOAT, + `weight` FLOAT DEFAULT 0, + `is_default` TINYINT(1) DEFAULT 0, `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`), @@ -386,6 +386,8 @@ CREATE TABLE `attribute_template` `id` INTEGER NOT NULL AUTO_INCREMENT, `attribute_id` INTEGER NOT NULL, `template_id` INTEGER NOT NULL, + `position` INTEGER, + `attribute_templatecol` VARCHAR(45), `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`), @@ -815,7 +817,7 @@ CREATE TABLE `order_product_attribute_combination` `attribute_title` VARCHAR(255) NOT NULL, `attribute_chapo` TEXT, `attribute_description` LONGTEXT, - `attribute_postscriptumn` TEXT, + `attribute_postscriptum` TEXT, `attribute_av_title` VARCHAR(255) NOT NULL, `attribute_av_chapo` TEXT, `attribute_av_description` LONGTEXT, @@ -1586,6 +1588,7 @@ CREATE TABLE `order_product_tax` `title` VARCHAR(255) NOT NULL, `description` LONGTEXT, `amount` FLOAT NOT NULL, + `promo_amount` FLOAT, `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`), diff --git a/local/config/schema.xml b/local/config/schema.xml index 429a52e3f..e1879ff32 100755 --- a/local/config/schema.xml +++ b/local/config/schema.xml @@ -32,7 +32,7 @@ - + @@ -55,7 +55,7 @@ - + @@ -145,7 +145,6 @@
    - @@ -179,7 +178,7 @@ - + @@ -205,6 +204,7 @@ + @@ -221,7 +221,6 @@
    - @@ -277,11 +276,12 @@
    - + - + + @@ -297,6 +297,8 @@ + + @@ -639,7 +641,7 @@ - + @@ -1243,6 +1245,7 @@ + diff --git a/templates/admin/default/admin-layout.tpl b/templates/admin/default/admin-layout.tpl index c8fe855b7..a223bfdb4 100644 --- a/templates/admin/default/admin-layout.tpl +++ b/templates/admin/default/admin-layout.tpl @@ -4,6 +4,13 @@ {check_auth roles="ADMIN" permissions="{block name="check-permissions"}{/block}" login_tpl="/admin/login"} {/block} +{* -- Define some stuff for Smarty ----------------------------------------- *} +{assign 'order-not-paid' 'warning'} +{assign 'order-paid' 'success'} +{assign 'order-processing' 'primary'} +{assign 'order-sent' 'info'} +{assign 'order-canceled' 'danger'} + diff --git a/templates/admin/default/assets/less/thelia/tables.less b/templates/admin/default/assets/less/thelia/tables.less index e542786ec..1f6212447 100755 --- a/templates/admin/default/assets/less/thelia/tables.less +++ b/templates/admin/default/assets/less/thelia/tables.less @@ -13,6 +13,19 @@ } } } + + tbody { + tr.active, tr { + td.td-unstyled { + background-color: white; + border-top: none; + border-right: 1px solid @table-border-color; + } + td.last { + border-bottom: 1px solid @table-border-color; + } + } + } } @@ -55,10 +68,6 @@ tfoot{ } } - // td, th { - // text-align: center; - // } - td.object-title, th.object-title { text-align: left; } diff --git a/templates/admin/default/order-edit.html b/templates/admin/default/order-edit.html index 7e27370e5..76e23e92a 100644 --- a/templates/admin/default/order-edit.html +++ b/templates/admin/default/order-edit.html @@ -27,10 +27,16 @@ {assign "orderCurrency" $SYMBOL} {/loop} - - - - - + + + + + + + {loop type="order_product" name="order-products" order=$ID} + {if $WAS_IN_PROMO == 1} + {assign "realPrice" $PROMO_PRICE} + {assign "realTax" $PROMO_PRICE_TAX} + {assign "realTaxedPrice" $TAXED_PROMO_PRICE} + {else} + {assign "realPrice" $PRICE} + {assign "realTax" $PRICE_TAX} + {assign "realTaxedPrice" $TAXED_PRICE} + {/if} - - - - + + + + + + + + {/loop} + + + + + + - - - - + + + + + + + + - - - - + + + + + + + + + + + + + - - - - - -
    {intl l="Product"}{intl l="Price"}{intl l="Quantity"}{intl l="Total"}{intl l="Product"}{intl l="Unit. price"}{intl l="Tax"}{intl l="Unit taxed price"}{intl l="Quantity"}{intl l="Taxed total"}
    T-Shirt F T120.00 €360.00 € + {$TITLE} + {ifloop rel="combinations"} +
    + {loop type="order_product_attribute_combination" name="combinations" order_product=$ID} +
    {$ATTRIBUTE_TITLE}
    +
    {$ATTRIBUTE_AVAILABILITY_TITLE}
    + {/loop} +
    + {/ifloop} +
    {$orderCurrency} {$realPrice}{$orderCurrency} {$realTax}{$orderCurrency} {$realTaxedPrice}{$QUANTITY}{$orderCurrency} {$realTaxedPrice * $QUANTITY}
    {intl l="Total without discount"}{$orderCurrency} {$TOTAL_TAXED_AMOUNT-$POSTAGE}
    T-Shirt F T120.00 €360.00 €{intl l="Discount"}{$orderCurrency} 0
    {intl l="Coupon code"}{$orderCurrency} 0
    T-Shirt F T120.00 €360.00 €{intl l="Total including discount"}{$orderCurrency} {$TOTAL_TAXED_AMOUNT-$POSTAGE}
    {intl l="Postage"}{$orderCurrency} {$POSTAGE}
    {intl l="Total"}{$orderCurrency} {$TOTAL_TAXED_AMOUNT}
    Total180.00 €
    @@ -92,30 +137,6 @@ {intl l="Transaction reference"} {$TRANSACTION_REF} - - {intl l="Total without discount"} - @TODO - - - {intl l="Discount"} - @TODO - - - {intl l="Coupon code"} - @TODO - - - {intl l="Total including discount"} - {$orderCurrency} {$TOTAL_TAXED_AMOUNT-$POSTAGE} - - - {intl l="Postage"} - {$orderCurrency} {$POSTAGE} - - - {intl l="Total"} - {$orderCurrency} {$TOTAL_TAXED_AMOUNT} - @@ -466,4 +487,15 @@ {/form} +{/block} + +{block name="javascript-initialization"} + + {javascripts file='assets/js/bootstrap-select/bootstrap-select.js'} + + {/javascripts} + {javascripts file='assets/js/main.js'} + + {/javascripts} + {/block} \ No newline at end of file diff --git a/templates/admin/default/orders.html b/templates/admin/default/orders.html index c0b420275..c7cded835 100644 --- a/templates/admin/default/orders.html +++ b/templates/admin/default/orders.html @@ -63,7 +63,7 @@ {assign "orderStatusLabel" "success"} {else} {if $CODE == 'processing'} - {assign "orderStatusLabel" "Primary"} + {assign "orderStatusLabel" "primary"} {else} {if $CODE == 'sent'} {assign "orderStatusLabel" "info"} @@ -85,7 +85,7 @@ {$orderInvoiceCompany} {$orderInvoiceFirstName|ucwords} {$orderInvoiceLastName|upper} {$TOTAL_TAXED_AMOUNT} - {$orderStatus} + {$orderStatus} {module_include location='orders_table_row'} From 033bebdd3046953e04c9a13927455e054c0544f0 Mon Sep 17 00:00:00 2001 From: gmorel Date: Tue, 24 Sep 2013 22:46:54 +0200 Subject: [PATCH 18/98] Working : coupon creation : Fix js --- .../admin/default/coupon/rule-input-ajax.html | 20 +++++++++---------- templates/admin/default/coupon/rules.html | 8 +++++--- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/templates/admin/default/coupon/rule-input-ajax.html b/templates/admin/default/coupon/rule-input-ajax.html index 9911ded32..50ff64a08 100644 --- a/templates/admin/default/coupon/rule-input-ajax.html +++ b/templates/admin/default/coupon/rule-input-ajax.html @@ -73,32 +73,32 @@ // Init Rules to set // Update only if no rule are already set - if(!couponManager.ruleToSave){ - couponManager.ruleToSave['serviceId'] = '{$ruleId}'; - couponManager.ruleToSave['operators'] = {literal}{}{/literal}; - couponManager.ruleToSave['values'] = {literal}{}{/literal}; + if(!$.couponManager.ruleToSave){ + $.couponManager.ruleToSave['serviceId'] = '{$ruleId}'; + $.couponManager.ruleToSave['operators'] = {literal}{}{/literal}; + $.couponManager.ruleToSave['values'] = {literal}{}{/literal}; } else { } {foreach from=$inputs.inputs key=name item=input} - couponManager.ruleToSave['operators']['{$name nofilter}'] = '{foreach from=$inputs.inputs[$name].availableOperators key=keyOperator item=valueOperator name=operators}{if $smarty.foreach.operators.first}{$keyOperator nofilter}{/if}{/foreach}'; - couponManager.ruleToSave['values']['{$name nofilter}'] = '{if count($inputs.inputs[$name].availableValues) != 0}{foreach from=$inputs.inputs[$name].availableValues key=keyValue item=valueValue name=values}{if $smarty.foreach.values.first}{$keyValue nofilter}{/if}{/foreach}{else}to set{/if}'; + $.couponManager.ruleToSave['operators']['{$name nofilter}'] = '{foreach from=$inputs.inputs[$name].availableOperators key=keyOperator item=valueOperator name=operators}{if $smarty.foreach.operators.first}{$keyOperator nofilter}{/if}{/foreach}'; + $.couponManager.ruleToSave['values']['{$name nofilter}'] = '{if count($inputs.inputs[$name].availableValues) != 0}{foreach from=$inputs.inputs[$name].availableValues key=keyValue item=valueValue name=values}{if $smarty.foreach.values.first}{$keyValue nofilter}{/if}{/foreach}{else}to set{/if}'; {/foreach} // Fill in ready to be saved rule array - couponManager.onInputsChange = function() {literal}{{/literal} + $.couponManager.onInputsChange = function() {literal}{{/literal} {foreach from=$inputs.inputs key=name item=input} // Operator selector $('#{$name}-operator').change(function (e) { var $this = $(this); - couponManager.ruleToSave['operators']['{$name nofilter}'] = $this.val(); + $.couponManager.ruleToSave['operators']['{$name nofilter}'] = $this.val(); }); // Value input $('#{$name}-value').change(function (e) { var $this = $(this); - couponManager.ruleToSave['values']['{$name nofilter}'] = $this.val(); + $.couponManager.ruleToSave['values']['{$name nofilter}'] = $this.val(); }); {/foreach} {literal}}{/literal} - couponManager.onInputsChange(); + $.couponManager.onInputsChange(); \ No newline at end of file diff --git a/templates/admin/default/coupon/rules.html b/templates/admin/default/coupon/rules.html index 199ee44c3..c5a09aa97 100644 --- a/templates/admin/default/coupon/rules.html +++ b/templates/admin/default/coupon/rules.html @@ -10,9 +10,11 @@ {intl l='Edit'} - - {intl l='Delete'} - + {if $rules|count != 1} + + {intl l='Delete'} + + {/if} {/foreach} From cb389f126c409d99163452c15c7437d42dacfd18 Mon Sep 17 00:00:00 2001 From: gmorel Date: Wed, 25 Sep 2013 12:58:12 +0200 Subject: [PATCH 19/98] WIP : Refactor contraint/rule becomes conditions (more generic) --- .../Thelia/Condition/ConditionEvaluator.php | 144 +++++++++++++++ .../lib/Thelia/Condition/ConditionFactory.php | 169 +++++++++++++++++ .../ConditionManagerAbstract.php} | 63 +++---- .../ConditionManagerInterface.php} | 28 ++- .../MatchForEveryoneManager.php} | 19 +- .../MatchForTotalAmountManager.php} | 42 ++--- .../MatchForXArticlesManager.php} | 42 ++--- .../Rule => Condition}/Operators.php | 23 ++- .../SerializableCondition.php} | 32 ++-- .../Thelia/Constraint/ConstraintFactory.php | 174 ------------------ 10 files changed, 423 insertions(+), 313 deletions(-) create mode 100644 core/lib/Thelia/Condition/ConditionEvaluator.php create mode 100644 core/lib/Thelia/Condition/ConditionFactory.php rename core/lib/Thelia/{Constraint/Rule/CouponRuleAbstract.php => Condition/ConditionManagerAbstract.php} (82%) rename core/lib/Thelia/{Constraint/Rule/CouponRuleInterface.php => Condition/ConditionManagerInterface.php} (86%) rename core/lib/Thelia/{Constraint/Rule/AvailableForEveryoneManager.php => Condition/Implementation/MatchForEveryoneManager.php} (87%) rename core/lib/Thelia/{Constraint/Rule/AvailableForTotalAmountManager.php => Condition/Implementation/MatchForTotalAmountManager.php} (88%) rename core/lib/Thelia/{Constraint/Rule/AvailableForXArticlesManager.php => Condition/Implementation/MatchForXArticlesManager.php} (86%) rename core/lib/Thelia/{Constraint/Rule => Condition}/Operators.php (91%) rename core/lib/Thelia/{Constraint/Rule/SerializableRule.php => Condition/SerializableCondition.php} (79%) delete mode 100644 core/lib/Thelia/Constraint/ConstraintFactory.php diff --git a/core/lib/Thelia/Condition/ConditionEvaluator.php b/core/lib/Thelia/Condition/ConditionEvaluator.php new file mode 100644 index 000000000..327c80a3d --- /dev/null +++ b/core/lib/Thelia/Condition/ConditionEvaluator.php @@ -0,0 +1,144 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Condition; + +use Symfony\Component\DependencyInjection\ContainerInterface; +use Thelia\Condition\Operators; +use Thelia\Coupon\ConditionCollection; + + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Validate Conditions + * + * @package Condition + * @author Guillaume MOREL + * + */ +class ConditionEvaluator +{ + /** + * Check if an Event matches SerializableCondition + * + * @param ConditionCollection $conditions Conditions to check against the Event + * + * @return bool + */ + public function isMatching(ConditionCollection $conditions) + { + $isMatching = true; + /** @var ConditionManagerInterface $condition */ + foreach ($conditions->getConditions() as $condition) { + if (!$condition->isMatching()) { + $isMatching = false; + } + } + + return $isMatching; + + } + + /** + * Do variable comparison + * + * @param mixed $v1 Variable 1 + * @param string $o Operator ex : Operators::DIFFERENT + * @param mixed $v2 Variable 2 + * + * @throws \Exception + * @return bool + */ + public function variableOpComparison($v1, $o, $v2) + { + if ($o == Operators::DIFFERENT) { + return ($v1 != $v2); + } + + switch ($o) { + case Operators::SUPERIOR : + // > + if ($v1 > $v2) { + return true; + } else { + continue; + } + break; + case Operators::SUPERIOR_OR_EQUAL : + // >= + if ($v1 >= $v2) { + return true; + } else { + continue; + } + break; + case Operators::INFERIOR : + // < + if ($v1 < $v2) { + return true; + } else { + continue; + } + break; + case Operators::INFERIOR_OR_EQUAL : + // <= + if ($v1 <= $v2) { + return true; + } else { + continue; + } + break; + case Operators::EQUAL : + // == + if ($v1 == $v2) { + return true; + } else { + continue; + } + break; + case Operators::IN: + // in + if (in_array($v1, $v2)) { + return true; + } else { + continue; + } + break; + case Operators::OUT: + // not in + if (!in_array($v1, $v2)) { + return true; + } else { + continue; + } + break; + default: + throw new \Exception('Unrecognized operator ' . $o); + } + + return false; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Condition/ConditionFactory.php b/core/lib/Thelia/Condition/ConditionFactory.php new file mode 100644 index 000000000..8e8c37b1d --- /dev/null +++ b/core/lib/Thelia/Condition/ConditionFactory.php @@ -0,0 +1,169 @@ +. */ +/* */ +/**********************************************************************************/ + +namespace Thelia\Condition; + +use Symfony\Component\DependencyInjection\ContainerInterface; +use Thelia\Coupon\AdapterInterface; +use Thelia\Coupon\ConditionCollection; + + +/** + * Created by JetBrains PhpStorm. + * Date: 8/19/13 + * Time: 3:24 PM + * + * Manage how Condition could interact with the current application state (Thelia) + * + * @package Constraint + * @author Guillaume MOREL + * + */ +class ConditionFactory +{ + /** @var ContainerInterface Service Container */ + protected $container = null; + + /** @var AdapterInterface Provide necessary value from Thelia */ + protected $adapter; + + /** @var array ConditionCollection to process*/ + protected $conditions = null; + + /** + * Constructor + * + * @param ContainerInterface $container Service container + */ + public function __construct(ContainerInterface $container) + { + $this->container = $container; + $this->adapter = $container->get('thelia.adapter'); + } + + /** + * Serialize a collection of conditions + * + * @param ConditionCollection $collection A collection of conditions + * + * @return string A ready to be stored Condition collection + */ + public function serializeCouponRuleCollection(ConditionCollection $collection) + { + if ($collection->isEmpty()) { + /** @var ConditionManagerInterface $conditionNone */ + $conditionNone = $this->container->get( + 'thelia.constraint.rule.available_for_everyone' + ); + $collection->add($conditionNone); + } + $serializableConditions = array(); + $conditions = $collection->getConditions(); + if ($conditions !== null) { + /** @var $condition ConditionManagerInterface */ + foreach ($conditions as $condition) { + // Remove all rule if the "no condition" condition is found +// if ($condition->getServiceId() == 'thelia.constraint.rule.available_for_everyone') { +// return base64_encode(json_encode(array($condition->getSerializableRule()))); +// } + $serializableConditions[] = $condition->getSerializableCondition(); + } + } + + return base64_encode(json_encode($serializableConditions)); + } + + /** + * Unserialize a collection of conditions + * + * @param string $serializedConditions Serialized Conditions + * + * @return ConditionCollection Conditions ready to be processed + */ + public function unserializeCouponRuleCollection($serializedConditions) + { + $unserializedConditions = json_decode(base64_decode($serializedConditions)); + + $collection = new ConditionCollection(); + + if (!empty($unserializedConditions) && !empty($unserializedConditions)) { + /** @var SerializableCondition $condition */ + foreach ($unserializedConditions as $condition) { + if ($this->container->has($condition->conditionServiceId)) { + /** @var ConditionManagerInterface $conditionManager */ + $conditionManager = $this->build( + $condition->conditionServiceId, + (array) $condition->operators, + (array) $condition->values + ); + $collection->add(clone $conditionManager); + } + } + } + + return $collection; + } + + + /** + * Build a Condition from form + * + * @param string $conditionServiceId Condition class name + * @param array $operators Condition Operator (<, >, = ) + * @param array $values Values setting this Condition + * + * @throws \InvalidArgumentException + * @return ConditionManagerInterface Ready to use Condition or false + */ + public function build($conditionServiceId, array $operators, array $values) + { + if (!$this->container->has($conditionServiceId)) { + return false; + } + + /** @var ConditionManagerInterface $condition */ + $condition = $this->container->get($conditionServiceId); + $condition->setValidatorsFromForm($operators, $values); + + return $condition; + } + + /** + * Get Condition inputs from serviceId + * + * @param string $conditionServiceId ConditionManager class name + * + * @return array Ready to be drawn rule inputs + */ + public function getInputs($conditionServiceId) + { + if (!$this->container->has($conditionServiceId)) { + return false; + } + + /** @var ConditionManagerInterface $condition */ + $condition = $this->container->get($conditionServiceId); + + return $condition->getValidators(); + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Constraint/Rule/CouponRuleAbstract.php b/core/lib/Thelia/Condition/ConditionManagerAbstract.php similarity index 82% rename from core/lib/Thelia/Constraint/Rule/CouponRuleAbstract.php rename to core/lib/Thelia/Condition/ConditionManagerAbstract.php index ffd1eb0f3..16ef2c044 100644 --- a/core/lib/Thelia/Constraint/Rule/CouponRuleAbstract.php +++ b/core/lib/Thelia/Condition/ConditionManagerAbstract.php @@ -21,17 +21,12 @@ /* */ /**********************************************************************************/ -namespace Thelia\Constraint\Rule; +namespace Thelia\Condition; use Symfony\Component\Intl\Exception\NotImplementedException; -use Thelia\Constraint\ConstraintValidator; use Thelia\Core\Translation\Translator; -use Thelia\Coupon\CouponAdapterInterface; -use Thelia\Constraint\Validator\ComparableInterface; -use Thelia\Constraint\Validator\RuleValidator; -use Thelia\Exception\InvalidRuleException; -use Thelia\Exception\InvalidRuleOperatorException; -use Thelia\Exception\InvalidRuleValueException; +use Thelia\Coupon\AdapterInterface; +use Thelia\Exception\InvalidConditionValueException; use Thelia\Model\Currency; use Thelia\Type\FloatType; @@ -46,7 +41,7 @@ use Thelia\Type\FloatType; * @author Guillaume MOREL * */ -abstract class CouponRuleAbstract implements CouponRuleInterface +abstract class ConditionManagerAbstract implements ConditionManagerInterface { // /** Operator key in $validators */ // CONST OPERATOR = 'operator'; @@ -65,7 +60,7 @@ abstract class CouponRuleAbstract implements CouponRuleInterface // /** @var array Parameters to be validated */ // protected $paramsToValidate = array(); - /** @var CouponAdapterInterface Provide necessary value from Thelia */ + /** @var AdapterInterface Provide necessary value from Thelia */ protected $adapter = null; /** @var Translator Service Translator */ @@ -77,19 +72,19 @@ abstract class CouponRuleAbstract implements CouponRuleInterface /** @var array Values set by Admin in BackOffice */ protected $values = array(); - /** @var ConstraintValidator Constaints validator */ - protected $constraintValidator = null; + /** @var ConditionEvaluator Conditions validator */ + protected $conditionValidator = null; /** * Constructor * - * @param CouponAdapterInterface $adapter Service adapter + * @param AdapterInterface $adapter Service adapter */ - function __construct(CouponAdapterInterface $adapter) + public function __construct(AdapterInterface $adapter) { $this->adapter = $adapter; $this->translator = $adapter->getTranslator(); - $this->constraintValidator = $adapter->getConstraintValidator(); + $this->conditionValidator = $adapter->getConditionValidator(); } // /** @@ -108,7 +103,7 @@ abstract class CouponRuleAbstract implements CouponRuleInterface // throw new InvalidRuleException(get_class()); // } // if (!in_array($validator->getOperator(), $this->availableOperators)) { -// throw new InvalidRuleOperatorException( +// throw new InvalidConditionOperatorException( // get_class(), // $validator->getOperator() // ); @@ -149,7 +144,7 @@ abstract class CouponRuleAbstract implements CouponRuleInterface // } /** - * Return all available Operators for this Rule + * Return all available Operators for this Condition * * @return array Operators::CONST */ @@ -161,7 +156,7 @@ abstract class CouponRuleAbstract implements CouponRuleInterface // /** // * Check if Operators set for this Rule in the BackOffice are legit // * -// * @throws InvalidRuleOperatorException if Operator is not allowed +// * @throws InvalidConditionOperatorException if Operator is not allowed // * @return bool // */ // protected function checkBackOfficeInputsOperators() @@ -172,7 +167,7 @@ abstract class CouponRuleAbstract implements CouponRuleInterface // if (!isset($operator) // ||!in_array($operator, $this->availableOperators) // ) { -// throw new InvalidRuleOperatorException(get_class(), $key); +// throw new InvalidConditionOperatorException(get_class(), $key); // } // } // return true; @@ -233,7 +228,7 @@ abstract class CouponRuleAbstract implements CouponRuleInterface } /** - * Get Rule Service id + * Get ConditionManager Service id * * @return string */ @@ -243,7 +238,7 @@ abstract class CouponRuleAbstract implements CouponRuleInterface } /** - * Validate if Operator given is available for this Coupon + * Validate if Operator given is available for this Condition * * @param string $operator Operator to validate ex < * @param array $availableOperators Available operators @@ -256,19 +251,19 @@ abstract class CouponRuleAbstract implements CouponRuleInterface } /** - * Return a serializable Rule + * Return a serializable Condition * - * @return SerializableRule + * @return SerializableCondition */ - public function getSerializableRule() + public function getSerializableCondition() { - $serializableRule = new SerializableRule(); - $serializableRule->ruleServiceId = $this->serviceId; - $serializableRule->operators = $this->operators; + $serializableCondition = new SerializableCondition(); + $serializableCondition->conditionServiceId = $this->serviceId; + $serializableCondition->operators = $this->operators; - $serializableRule->values = $this->values; + $serializableCondition->values = $this->values; - return $serializableRule; + return $serializableCondition; } @@ -278,20 +273,20 @@ abstract class CouponRuleAbstract implements CouponRuleInterface * @param string $currencyValue Currency EUR|USD|.. * * @return bool - * @throws \Thelia\Exception\InvalidRuleValueException + * @throws \Thelia\Exception\InvalidConditionValueException */ protected function IsCurrencyValid($currencyValue) { $availableCurrencies = $this->adapter->getAvailableCurrencies(); /** @var Currency $currency */ $currencyFound = false; - foreach ($availableCurrencies as $key => $currency) { + foreach ($availableCurrencies as $currency) { if ($currencyValue == $currency->getCode()) { $currencyFound = true; } } if (!$currencyFound) { - throw new InvalidRuleValueException( + throw new InvalidConditionValueException( get_class(), 'currency' ); } @@ -305,13 +300,13 @@ abstract class CouponRuleAbstract implements CouponRuleInterface * @param float $priceValue Price value to check * * @return bool - * @throws \Thelia\Exception\InvalidRuleValueException + * @throws \Thelia\Exception\InvalidConditionValueException */ protected function isPriceValid($priceValue) { $floatType = new FloatType(); if (!$floatType->isValid($priceValue) || $priceValue <= 0) { - throw new InvalidRuleValueException( + throw new InvalidConditionValueException( get_class(), 'price' ); } diff --git a/core/lib/Thelia/Constraint/Rule/CouponRuleInterface.php b/core/lib/Thelia/Condition/ConditionManagerInterface.php similarity index 86% rename from core/lib/Thelia/Constraint/Rule/CouponRuleInterface.php rename to core/lib/Thelia/Condition/ConditionManagerInterface.php index ac9579094..37f75479f 100644 --- a/core/lib/Thelia/Constraint/Rule/CouponRuleInterface.php +++ b/core/lib/Thelia/Condition/ConditionManagerInterface.php @@ -21,30 +21,30 @@ /* */ /**********************************************************************************/ -namespace Thelia\Constraint\Rule; +namespace Thelia\Condition; use Thelia\Core\Translation\Translator; -use Thelia\Coupon\CouponAdapterInterface; +use Thelia\Coupon\AdapterInterface; /** * Created by JetBrains PhpStorm. * Date: 8/19/13 * Time: 3:24 PM * - * Represents a condition of whether the Rule is applied or not + * Manage how the application checks its state in order to check if it matches the implemented condition * - * @package Constraint + * @package Condition * @author Guillaume MOREL * */ -interface CouponRuleInterface +interface ConditionManagerInterface { /** * Constructor * - * @param CouponAdapterInterface $adapter Service adapter + * @param AdapterInterface $adapter Service adapter */ - function __construct(CouponAdapterInterface $adapter); + function __construct(AdapterInterface $adapter); /** * Get Rule Service id @@ -86,14 +86,14 @@ interface CouponRuleInterface // public function isMatching(); /** - * Test if Customer meets conditions + * Test if the current application state matches conditions * * @return bool */ public function isMatching(); /** - * Return all available Operators for this Rule + * Return all available Operators for this condition * * @return array Operators::CONST */ @@ -133,14 +133,10 @@ interface CouponRuleInterface /** - * Return a serializable Rule + * Return a serializable Condition * - * @return SerializableRule + * @return SerializableCondition */ - public function getSerializableRule(); - - - - + public function getSerializableCondition(); } diff --git a/core/lib/Thelia/Constraint/Rule/AvailableForEveryoneManager.php b/core/lib/Thelia/Condition/Implementation/MatchForEveryoneManager.php similarity index 87% rename from core/lib/Thelia/Constraint/Rule/AvailableForEveryoneManager.php rename to core/lib/Thelia/Condition/Implementation/MatchForEveryoneManager.php index 15e0e3ab7..57a7814b9 100644 --- a/core/lib/Thelia/Constraint/Rule/AvailableForEveryoneManager.php +++ b/core/lib/Thelia/Condition/Implementation/MatchForEveryoneManager.php @@ -21,17 +21,10 @@ /* */ /**********************************************************************************/ -namespace Thelia\Constraint\Rule; +namespace Thelia\Condition\Implementation; use InvalidArgumentException; -use Symfony\Component\Translation\Translator; -use Thelia\Constraint\ConstraintValidator; -use Thelia\Constraint\Validator\QuantityParam; -use Thelia\Constraint\Validator\RuleValidator; -use Thelia\Coupon\CouponAdapterInterface; -use Thelia\Exception\InvalidRuleException; -use Thelia\Exception\InvalidRuleValueException; -use Thelia\Type\FloatType; +use Thelia\Condition\ConditionManagerAbstract; /** * Created by JetBrains PhpStorm. @@ -40,11 +33,11 @@ use Thelia\Type\FloatType; * * Allow every one, perform no check * - * @package Constraint + * @package Condition * @author Guillaume MOREL * */ -class AvailableForEveryoneManager extends CouponRuleAbstract +class MatchForEveryoneManager extends ConditionManagerAbstract { /** @var string Service Id from Resources/config.xml */ protected $serviceId = 'thelia.constraint.rule.available_for_everyone'; @@ -102,7 +95,7 @@ class AvailableForEveryoneManager extends CouponRuleAbstract return $this->translator->trans( 'Everybody can use it (no condition)', array(), - 'constraint' + 'condition' ); } @@ -116,7 +109,7 @@ class AvailableForEveryoneManager extends CouponRuleAbstract $toolTip = $this->translator->trans( 'Will return always true', array(), - 'constraint' + 'condition' ); return $toolTip; diff --git a/core/lib/Thelia/Constraint/Rule/AvailableForTotalAmountManager.php b/core/lib/Thelia/Condition/Implementation/MatchForTotalAmountManager.php similarity index 88% rename from core/lib/Thelia/Constraint/Rule/AvailableForTotalAmountManager.php rename to core/lib/Thelia/Condition/Implementation/MatchForTotalAmountManager.php index c4087e734..87524cdc9 100644 --- a/core/lib/Thelia/Constraint/Rule/AvailableForTotalAmountManager.php +++ b/core/lib/Thelia/Condition/Implementation/MatchForTotalAmountManager.php @@ -21,38 +21,33 @@ /* */ /**********************************************************************************/ -namespace Thelia\Constraint\Rule; +namespace Thelia\Condition\Implementation; use Symfony\Component\Intl\Exception\NotImplementedException; -use Symfony\Component\Translation\Translator; -use Thelia\Coupon\CouponAdapterInterface; -use Thelia\Constraint\Validator\PriceParam; -use Thelia\Constraint\Validator\RuleValidator; -use Thelia\Exception\InvalidRuleException; -use Thelia\Exception\InvalidRuleOperatorException; -use Thelia\Exception\InvalidRuleValueException; +use Thelia\Condition\ConditionManagerAbstract; +use Thelia\Condition\Operators; +use Thelia\Exception\InvalidConditionOperatorException; use Thelia\Model\Currency; use Thelia\Model\CurrencyQuery; -use Thelia\Type\FloatType; /** * Created by JetBrains PhpStorm. * Date: 8/19/13 * Time: 3:24 PM * - * Rule AvailableForTotalAmount + * Condition AvailableForTotalAmount * Check if a Checkout total amount match criteria * - * @package Constraint + * @package Condition * @author Guillaume MOREL * */ -class AvailableForTotalAmountManager extends CouponRuleAbstract +class MatchForTotalAmountManager extends ConditionManagerAbstract { - /** Rule 1st parameter : price */ + /** Condition 1st parameter : price */ CONST INPUT1 = 'price'; - /** Rule 1st parameter : currency */ + /** Condition 1st parameter : currency */ CONST INPUT2 = 'currency'; /** @var string Service Id from Resources/config.xml */ @@ -101,7 +96,7 @@ class AvailableForTotalAmountManager extends CouponRuleAbstract * @param string $currencyOperator Currency Operator ex = * @param string $currencyValue Currency set to meet condition * - * @throws \InvalidArgumentException + * @throws \Thelia\Exception\InvalidConditionOperatorException * @return $this */ protected function setValidators($priceOperator, $priceValue, $currencyOperator, $currencyValue) @@ -111,7 +106,7 @@ class AvailableForTotalAmountManager extends CouponRuleAbstract $this->availableOperators[self::INPUT1] ); if (!$isOperator1Legit) { - throw new InvalidRuleOperatorException( + throw new InvalidConditionOperatorException( get_class(), 'price' ); } @@ -121,7 +116,7 @@ class AvailableForTotalAmountManager extends CouponRuleAbstract $this->availableOperators[self::INPUT2] ); if (!$isOperator1Legit) { - throw new InvalidRuleOperatorException( + throw new InvalidConditionOperatorException( get_class(), 'price' ); } @@ -164,12 +159,12 @@ class AvailableForTotalAmountManager extends CouponRuleAbstract return false; } - $constraint1 = $this->constraintValidator->variableOpComparison( + $constraint1 = $this->conditionValidator->variableOpComparison( $this->adapter->getCartTotalPrice(), $this->operators[self::INPUT1], $this->values[self::INPUT1] ); - $constraint2 = $this->constraintValidator->variableOpComparison( + $constraint2 = $this->conditionValidator->variableOpComparison( $this->adapter->getCheckoutCurrency(), $this->operators[self::INPUT2], $this->values[self::INPUT2] @@ -177,6 +172,7 @@ class AvailableForTotalAmountManager extends CouponRuleAbstract if ($constraint1 && $constraint2) { return true; } + return false; } @@ -190,7 +186,7 @@ class AvailableForTotalAmountManager extends CouponRuleAbstract return $this->translator->trans( 'Cart total amount', array(), - 'constraint' + 'condition' ); } @@ -212,7 +208,7 @@ class AvailableForTotalAmountManager extends CouponRuleAbstract '%amount%' => $this->values[self::INPUT1], '%currency%' => $this->values[self::INPUT2] ), - 'constraint' + 'condition' ); return $toolTip; @@ -235,12 +231,12 @@ class AvailableForTotalAmountManager extends CouponRuleAbstract $name1 = $this->translator->trans( 'Price', array(), - 'constraint' + 'condition' ); $name2 = $this->translator->trans( 'Currency', array(), - 'constraint' + 'condition' ); return array( diff --git a/core/lib/Thelia/Constraint/Rule/AvailableForXArticlesManager.php b/core/lib/Thelia/Condition/Implementation/MatchForXArticlesManager.php similarity index 86% rename from core/lib/Thelia/Constraint/Rule/AvailableForXArticlesManager.php rename to core/lib/Thelia/Condition/Implementation/MatchForXArticlesManager.php index f73d5e2be..a8e874a46 100644 --- a/core/lib/Thelia/Constraint/Rule/AvailableForXArticlesManager.php +++ b/core/lib/Thelia/Condition/Implementation/MatchForXArticlesManager.php @@ -21,18 +21,13 @@ /* */ /**********************************************************************************/ -namespace Thelia\Constraint\Rule; +namespace Thelia\Condition\Implementation; use InvalidArgumentException; -use Symfony\Component\Translation\Translator; -use Thelia\Constraint\ConstraintValidator; -use Thelia\Constraint\Validator\QuantityParam; -use Thelia\Constraint\Validator\RuleValidator; -use Thelia\Coupon\CouponAdapterInterface; -use Thelia\Exception\InvalidRuleException; -use Thelia\Exception\InvalidRuleOperatorException; -use Thelia\Exception\InvalidRuleValueException; -use Thelia\Type\FloatType; +use Thelia\Condition\ConditionManagerAbstract; +use Thelia\Condition\Operators; +use Thelia\Exception\InvalidConditionOperatorException; +use Thelia\Exception\InvalidConditionValueException; /** * Created by JetBrains PhpStorm. @@ -41,13 +36,13 @@ use Thelia\Type\FloatType; * * Check a Checkout against its Product number * - * @package Constraint + * @package Condition * @author Guillaume MOREL * */ -class AvailableForXArticlesManager extends CouponRuleAbstract +class MatchForXArticlesManager extends ConditionManagerAbstract { - /** Rule 1st parameter : quantity */ + /** Condition 1st parameter : quantity */ CONST INPUT1 = 'quantity'; /** @var string Service Id from Resources/config.xml */ @@ -89,7 +84,8 @@ class AvailableForXArticlesManager extends CouponRuleAbstract * @param string $quantityOperator Quantity Operator ex < * @param int $quantityValue Quantity set to meet condition * - * @throws \InvalidArgumentException + * @throws \Thelia\Exception\InvalidConditionValueException + * @throws \Thelia\Exception\InvalidConditionOperatorException * @return $this */ protected function setValidators($quantityOperator, $quantityValue) @@ -99,13 +95,13 @@ class AvailableForXArticlesManager extends CouponRuleAbstract $this->availableOperators[self::INPUT1] ); if (!$isOperator1Legit) { - throw new InvalidRuleOperatorException( + throw new InvalidConditionOperatorException( get_class(), 'quantity' ); } if ((int) $quantityValue <= 0) { - throw new InvalidRuleValueException( + throw new InvalidConditionValueException( get_class(), 'quantity' ); } @@ -127,15 +123,16 @@ class AvailableForXArticlesManager extends CouponRuleAbstract */ public function isMatching() { - $constraint1 = $this->constraintValidator->variableOpComparison( + $condition1 = $this->conditionValidator->variableOpComparison( $this->adapter->getNbArticlesInCart(), $this->operators[self::INPUT1], $this->values[self::INPUT1] ); - if ($constraint1) { + if ($condition1) { return true; } + return false; } @@ -149,7 +146,7 @@ class AvailableForXArticlesManager extends CouponRuleAbstract return $this->translator->trans( 'Number of articles in cart', array(), - 'constraint' + 'condition' ); } @@ -170,7 +167,7 @@ class AvailableForXArticlesManager extends CouponRuleAbstract '%operator%' => $i18nOperator, '%quantity%' => $this->values[self::INPUT1] ), - 'constraint' + 'condition' ); return $toolTip; @@ -186,7 +183,7 @@ class AvailableForXArticlesManager extends CouponRuleAbstract $name1 = $this->translator->trans( 'Quantity', array(), - 'constraint' + 'condition' ); return array( @@ -200,5 +197,4 @@ class AvailableForXArticlesManager extends CouponRuleAbstract ) ); } - -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Constraint/Rule/Operators.php b/core/lib/Thelia/Condition/Operators.php similarity index 91% rename from core/lib/Thelia/Constraint/Rule/Operators.php rename to core/lib/Thelia/Condition/Operators.php index a6c457c75..57be8e0bf 100644 --- a/core/lib/Thelia/Constraint/Rule/Operators.php +++ b/core/lib/Thelia/Condition/Operators.php @@ -21,17 +21,16 @@ /* */ /**********************************************************************************/ -namespace Thelia\Constraint\Rule; +namespace Thelia\Condition; -use Symfony\Component\Translation\Translator; -use Thelia\Constraint\Validator\ComparableInterface; +use Thelia\Core\Translation\Translator; /** * Created by JetBrains PhpStorm. * Date: 8/19/13 * Time: 3:24 PM * - * Represent available Operations in rule checking + * Represent available Operations in condition checking * * @package Constraint * @author Guillaume MOREL @@ -72,56 +71,56 @@ abstract class Operators $ret = $translator->trans( 'inferior to', array(), - 'constraint' + 'condition' ); break; case self::INFERIOR_OR_EQUAL: $ret = $translator->trans( 'inferior or equal to', array(), - 'constraint' + 'condition' ); break; case self::EQUAL: $ret = $translator->trans( 'equal to', array(), - 'constraint' + 'condition' ); break; case self::SUPERIOR_OR_EQUAL: $ret = $translator->trans( 'superior or equal to', array(), - 'constraint' + 'condition' ); break; case self::SUPERIOR: $ret = $translator->trans( 'superior to', array(), - 'constraint' + 'condition' ); break; case self::DIFFERENT: $ret = $translator->trans( 'different from', array(), - 'constraint' + 'condition' ); break; case self::IN: $ret = $translator->trans( 'in', array(), - 'constraint' + 'condition' ); break; case self::OUT: $ret = $translator->trans( 'not in', array(), - 'constraint' + 'condition' ); break; default: diff --git a/core/lib/Thelia/Constraint/Rule/SerializableRule.php b/core/lib/Thelia/Condition/SerializableCondition.php similarity index 79% rename from core/lib/Thelia/Constraint/Rule/SerializableRule.php rename to core/lib/Thelia/Condition/SerializableCondition.php index 011c3e261..9dbec171c 100644 --- a/core/lib/Thelia/Constraint/Rule/SerializableRule.php +++ b/core/lib/Thelia/Condition/SerializableCondition.php @@ -21,32 +21,32 @@ /* */ /**********************************************************************************/ -namespace Thelia\Constraint\Rule; +namespace Thelia\Condition; /** * Created by JetBrains PhpStorm. * Date: 8/19/13 * Time: 3:24 PM * - * A rule set by an admin ready to be serialized and stored in DataBase + * A condition set by an admin ready to be serialized and stored in DataBase * - * @package Constraint + * @package Condition * @author Guillaume MOREL * */ -class SerializableRule +class SerializableCondition { - /** @var string Rule Service id */ - public $ruleServiceId = null; + /** @var string Condition Service id */ + public $conditionServiceId = null; - /** @var array Operators set by Admin for this Rule */ + /** @var array Operators set by Admin for this Condition */ public $operators = array(); - /** @var array Values set by Admin for this Rule */ + /** @var array Values set by Admin for this Condition */ public $values = array(); /** - * Get Operators set by Admin for this Rule + * Get Operators set by Admin for this Condition * * @return array */ @@ -56,17 +56,17 @@ class SerializableRule } /** - * Get Rule Service id + * Get Condition Service id * * @return string */ - public function getRuleServiceId() + public function getConditionServiceId() { - return $this->ruleServiceId; + return $this->conditionServiceId; } /** - * Get Values set by Admin for this Rule + * Get Values set by Admin for this Condition * * @return array */ @@ -74,8 +74,4 @@ class SerializableRule { return $this->values; } - - - - -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Constraint/ConstraintFactory.php b/core/lib/Thelia/Constraint/ConstraintFactory.php deleted file mode 100644 index e13d1d2aa..000000000 --- a/core/lib/Thelia/Constraint/ConstraintFactory.php +++ /dev/null @@ -1,174 +0,0 @@ -. */ -/* */ -/**********************************************************************************/ - -namespace Thelia\Constraint; - -use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\Serializer\Encoder\JsonEncoder; -use Thelia\Constraint\Rule\AvailableForEveryoneManager; -use Thelia\Constraint\Rule\AvailableForTotalAmountManager; -use Thelia\Constraint\Rule\CouponRuleInterface; -use Thelia\Constraint\Rule\SerializableRule; -use Thelia\Coupon\CouponAdapterInterface; -use Thelia\Coupon\CouponRuleCollection; - - -/** - * Created by JetBrains PhpStorm. - * Date: 8/19/13 - * Time: 3:24 PM - * - * Manage how Constraint could interact - * - * @package Constraint - * @author Guillaume MOREL - * - */ -class ConstraintFactory -{ - /** @var ContainerInterface Service Container */ - protected $container = null; - - /** @var CouponAdapterInterface Provide necessary value from Thelia*/ - protected $adapter; - - /** @var array CouponRuleCollection to process*/ - protected $rules = null; - - /** - * Constructor - * - * @param ContainerInterface $container Service container - */ - function __construct(ContainerInterface $container) - { - $this->container = $container; - $this->adapter = $container->get('thelia.adapter'); - } - - /** - * Serialize a collection of rules - * - * @param CouponRuleCollection $collection A collection of rules - * - * @return string A ready to be stored Rule collection - */ - public function serializeCouponRuleCollection(CouponRuleCollection $collection) - { - if ($collection->isEmpty()) { - /** @var CouponRuleInterface $ruleNoCondition */ - $ruleNoCondition = $this->container->get( - 'thelia.constraint.rule.available_for_everyone' - ); - $collection->add($ruleNoCondition); - } - $serializableRules = array(); - $rules = $collection->getRules(); - if ($rules !== null) { - /** @var $rule CouponRuleInterface */ - foreach ($rules as $rule) { - // Remove all rule if the "no condition" rule is found -// if ($rule->getServiceId() == 'thelia.constraint.rule.available_for_everyone') { -// return base64_encode(json_encode(array($rule->getSerializableRule()))); -// } - $serializableRules[] = $rule->getSerializableRule(); - } - } - - return base64_encode(json_encode($serializableRules)); - } - - /** - * Unserialize a collection of rules - * - * @param string $serializedRules Serialized Rules - * - * @return CouponRuleCollection Rules ready to be processed - */ - public function unserializeCouponRuleCollection($serializedRules) - { - $unserializedRules = json_decode(base64_decode($serializedRules)); - - $collection = new CouponRuleCollection(); - - if (!empty($serializedRules) && !empty($unserializedRules)) { - /** @var SerializableRule $rule */ - foreach ($unserializedRules as $rule) { - if ($this->container->has($rule->ruleServiceId)) { - /** @var CouponRuleInterface $couponRule */ - $couponRule = $this->build( - $rule->ruleServiceId, - (array) $rule->operators, - (array) $rule->values - ); - $collection->add(clone $couponRule); - } - } - } - - return $collection; - } - - - /** - * Build a Coupon Rule from form - * - * @param string $ruleServiceId Rule class name - * @param array $operators Rule Operator (<, >, = ) - * @param array $values Values setting this Rule - * - * @throws \InvalidArgumentException - * @return CouponRuleInterface Ready to use Rule or false - */ - public function build($ruleServiceId, array $operators, array $values) - { - if (!$this->container->has($ruleServiceId)) { - return false; - } - - /** @var CouponRuleInterface $rule */ - $rule = $this->container->get($ruleServiceId); - $rule->setValidatorsFromForm($operators, $values); - - return $rule; - } - - /** - * Get Coupon Rule inputs from serviceId - * - * @param string $ruleServiceId Rule class name - * - * @return array Ready to be drawn rule inputs - */ - public function getInputs($ruleServiceId) - { - if (!$this->container->has($ruleServiceId)) { - return false; - } - - /** @var CouponRuleInterface $rule */ - $rule = $this->container->get($ruleServiceId); - - return $rule->getValidators(); - } -} \ No newline at end of file From d967242a59b13fcce08960018aadd0a3ca7bf6ef Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Wed, 25 Sep 2013 13:26:12 +0200 Subject: [PATCH 20/98] order admin --- core/lib/Thelia/Action/Order.php | 14 ++ core/lib/Thelia/Config/Resources/config.xml | 4 + .../Thelia/Config/Resources/routing/admin.xml | 10 +- .../Controller/Admin/CustomerController.php | 4 +- .../Controller/Admin/OrderController.php | 54 ++++++++ core/lib/Thelia/Core/Event/OrderEvent.php | 17 +++ core/lib/Thelia/Core/Event/TheliaEvents.php | 3 + core/lib/Thelia/Core/Template/Loop/Order.php | 10 +- .../Core/Template/Smarty/Plugins/Type.php | 63 +++++++++ .../Core/Template/Smarty/SmartyParser.php | 4 + templates/admin/default/admin-layout.tpl | 20 +-- .../default/assets/less/thelia/thelia.less | 5 + .../admin/default/configs/variables.conf | 9 ++ templates/admin/default/order-edit.html | 12 +- templates/admin/default/orders.html | 120 ++++++++++-------- 15 files changed, 278 insertions(+), 71 deletions(-) create mode 100755 core/lib/Thelia/Core/Template/Smarty/Plugins/Type.php create mode 100644 templates/admin/default/configs/variables.conf diff --git a/core/lib/Thelia/Action/Order.php b/core/lib/Thelia/Action/Order.php index 3bc33fc99..6b47d8881 100755 --- a/core/lib/Thelia/Action/Order.php +++ b/core/lib/Thelia/Action/Order.php @@ -287,6 +287,19 @@ class Order extends BaseAction implements EventSubscriberInterface /* @todo */ } + /** + * @param OrderEvent $event + */ + public function updateStatus(OrderEvent $event) + { + $order = $event->getOrder(); + + $order->setStatusId($event->getStatus()); + $order->save(); + + $event->setOrder($order); + } + /** * Returns an array of event names this subscriber wants to listen to. * @@ -316,6 +329,7 @@ class Order extends BaseAction implements EventSubscriberInterface TheliaEvents::ORDER_SET_PAYMENT_MODULE => array("setPaymentModule", 128), TheliaEvents::ORDER_PAY => array("create", 128), TheliaEvents::ORDER_BEFORE_PAYMENT => array("sendOrderEmail", 128), + TheliaEvents::ORDER_UPDATE_STATUS => array("updateStatus", 128), ); } diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index a05ace847..378650057 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -198,6 +198,10 @@ + + + + diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index 838bd6da8..001938b8a 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -59,9 +59,9 @@ - + - + Thelia\Controller\Admin\OrderController::indexAction @@ -70,7 +70,11 @@ \d+ - + + Thelia\Controller\Admin\OrderController::updateStatus + + + diff --git a/core/lib/Thelia/Controller/Admin/CustomerController.php b/core/lib/Thelia/Controller/Admin/CustomerController.php index 9209cb361..bc94fd7be 100644 --- a/core/lib/Thelia/Controller/Admin/CustomerController.php +++ b/core/lib/Thelia/Controller/Admin/CustomerController.php @@ -72,7 +72,7 @@ class CustomerController extends BaseAdminController $customer = CustomerQuery::create()->findPk($customer_id); if(null === $customer) { - throw new \InvalidArgumentException(sprintf("%d customer id does not exists", $customer_id)); + throw new \InvalidArgumentException(sprintf("%d customer id does not exist", $customer_id)); } $form = $this->validateForm($customerModification); @@ -127,7 +127,7 @@ class CustomerController extends BaseAdminController $customer = CustomerQuery::create()->findPk($customer_id); if(null === $customer) { - throw new \InvalidArgumentException(Translator::getInstance("The customer you want to delete does not exists")); + throw new \InvalidArgumentException(Translator::getInstance("The customer you want to delete does not exist")); } $event = new CustomerEvent($customer); diff --git a/core/lib/Thelia/Controller/Admin/OrderController.php b/core/lib/Thelia/Controller/Admin/OrderController.php index b2047cc31..c74e056d8 100644 --- a/core/lib/Thelia/Controller/Admin/OrderController.php +++ b/core/lib/Thelia/Controller/Admin/OrderController.php @@ -23,6 +23,12 @@ namespace Thelia\Controller\Admin; +use Thelia\Core\Event\OrderEvent; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Translation\Translator; +use Thelia\Model\OrderQuery; +use Thelia\Model\OrderStatusQuery; + /** * Class OrderController * @package Thelia\Controller\Admin @@ -44,4 +50,52 @@ class OrderController extends BaseAdminController )); } + public function updateStatus() + { + if (null !== $response = $this->checkAuth("admin.order.update")) return $response; + + $message = null; + + try { + $orderId = $this->getRequest()->get("order_id"); + $order = OrderQuery::create()->findPk($orderId); + + $statusId = $this->getRequest()->get("status_id"); + $status = OrderStatusQuery::create()->findPk($statusId); + + if(null === $order) { + throw new \InvalidArgumentException("The order you want to update status does not exist"); + } + if(null === $status) { + throw new \InvalidArgumentException("The status you want to set to the order does not exist"); + } + + $event = new OrderEvent($order); + $event->setStatus($statusId); + + $this->dispatch(TheliaEvents::ORDER_UPDATE_STATUS, $event); + } catch(\Exception $e) { + $message = $e->getMessage(); + } + + $params = array(); + + if ($message) { + $params["update_status_error_message"] = $message; + } + + $browsedPage = $this->getRequest()->get("order_page"); + + if($browsedPage) { + $params["order_page"] = $browsedPage; + $this->redirectToRoute("admin.order.list", $params); + } else { + $params["order_id"] = $orderId; + $this->redirectToRoute("admin.order.update.view", $params); + } + + + + + } } \ No newline at end of file diff --git a/core/lib/Thelia/Core/Event/OrderEvent.php b/core/lib/Thelia/Core/Event/OrderEvent.php index 7089141bb..03abe7cb7 100755 --- a/core/lib/Thelia/Core/Event/OrderEvent.php +++ b/core/lib/Thelia/Core/Event/OrderEvent.php @@ -35,6 +35,7 @@ class OrderEvent extends ActionEvent protected $paymentModule = null; protected $postage = null; protected $ref = null; + protected $status = null; /** * @param Order $order @@ -108,6 +109,14 @@ class OrderEvent extends ActionEvent $this->ref = $ref; } + /** + * @param $status + */ + public function setStatus($status) + { + $this->status = $status; + } + /** * @return null|Order */ @@ -171,4 +180,12 @@ class OrderEvent extends ActionEvent { return $this->ref; } + + /** + * @return null|int + */ + public function getStatus() + { + return $this->status; + } } diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index ee49d239b..d20535a3f 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -301,9 +301,12 @@ final class TheliaEvents const ORDER_AFTER_CREATE = "action.order.afterCreate"; const ORDER_BEFORE_PAYMENT = "action.order.beforePayment"; + const ORDER_UPDATE_STATUS = "action.order.updateStatus"; + const ORDER_PRODUCT_BEFORE_CREATE = "action.orderProduct.beforeCreate"; const ORDER_PRODUCT_AFTER_CREATE = "action.orderProduct.afterCreate"; + /** * Sent on image processing */ diff --git a/core/lib/Thelia/Core/Template/Loop/Order.php b/core/lib/Thelia/Core/Template/Loop/Order.php index 25e12fec8..5b1e97cc1 100755 --- a/core/lib/Thelia/Core/Template/Loop/Order.php +++ b/core/lib/Thelia/Core/Template/Loop/Order.php @@ -57,7 +57,13 @@ class Order extends BaseLoop ), 'current' ), - Argument::createIntListTypeArgument('status'), + new Argument( + 'status', + new TypeCollection( + new Type\IntListType(), + new Type\EnumType(array('*')) + ) + ), new Argument( 'order', new TypeCollection( @@ -98,7 +104,7 @@ class Order extends BaseLoop $status = $this->getStatus(); - if (null !== $status) { + if (null !== $status && $status != '*') { $search->filterByStatusId($status, Criteria::IN); } diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Type.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Type.php new file mode 100755 index 000000000..333a522ec --- /dev/null +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Type.php @@ -0,0 +1,63 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Template\Smarty\Plugins; + +use Thelia\Core\HttpFoundation\Request; +use Thelia\Core\Template\Smarty\SmartyPluginDescriptor; +use Thelia\Core\Template\Smarty\AbstractSmartyPlugin; +use Thelia\Core\Security\SecurityContext; +use Thelia\Core\Security\Exception\AuthenticationException; +use Thelia\Exception\OrderException; +use Thelia\Model\AddressQuery; +use Thelia\Model\ModuleQuery; + +class Type extends AbstractSmartyPlugin +{ + public function assertTypeModifier($value, $option) + { + $typeClass = "\\Thelia\\Type\\$option"; + if(!class_exists($typeClass)) { + throw new \InvalidArgumentException(sprintf("Invalid type name `%s` in `assertType` modifier", $option)); + } + + $typeInstance = new $typeClass(); + if(!$typeInstance->isValid($value)) { + return ''; + } + + return $value; + } + + /** + * Define the various smarty plugins handled by this class + * + * @return an array of smarty plugin descriptors + */ + public function getPluginDescriptors() + { + return array( + new SmartyPluginDescriptor('modifier', 'assertType', $this, 'assertTypeModifier'), + ); + } +} diff --git a/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php b/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php index d76dd8dfa..dc537bf70 100755 --- a/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php +++ b/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php @@ -105,6 +105,10 @@ class SmartyParser extends Smarty implements ParserInterface $this->template = $template_path_from_template_base; $this->setTemplateDir(THELIA_TEMPLATE_DIR.$this->template); + + $config_dir = THELIA_TEMPLATE_DIR.$this->template.'/configs'; + + $this->setConfigDir($config_dir); } public function getTemplate() diff --git a/templates/admin/default/admin-layout.tpl b/templates/admin/default/admin-layout.tpl index a223bfdb4..4c115431f 100644 --- a/templates/admin/default/admin-layout.tpl +++ b/templates/admin/default/admin-layout.tpl @@ -5,11 +5,7 @@ {/block} {* -- Define some stuff for Smarty ----------------------------------------- *} -{assign 'order-not-paid' 'warning'} -{assign 'order-paid' 'success'} -{assign 'order-processing' 'primary'} -{assign 'order-sent' 'info'} -{assign 'order-canceled' 'danger'} +{config_load file='variables.conf'} @@ -118,21 +114,25 @@ {/loop} {loop name="menu-auth-order" type="auth" roles="ADMIN" permissions="admin.orders.view"} -