From 0deadcd247c415da6d687f9c734a8e7be224f592 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Thu, 24 Apr 2014 17:02:40 +0200 Subject: [PATCH] create resource and page for export --- .../Thelia/Config/Resources/routing/admin.xml | 6 +- .../Admin/CustomerExportController.php | 59 +++++++++++++++++++ .../Controller/Admin/ExportController.php | 3 +- .../Core/Security/Resource/AdminResources.php | 2 + setup/update/2.0.1.sql | 28 ++++++--- templates/backOffice/default/export.html | 48 +++++++++++++++ templates/backOffice/default/tools.html | 9 ++- 7 files changed, 143 insertions(+), 12 deletions(-) create mode 100644 core/lib/Thelia/Controller/Admin/CustomerExportController.php create mode 100644 templates/backOffice/default/export.html diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index df2afbbcb..0e5a06c4c 100644 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -1156,8 +1156,12 @@ + + Thelia\Controller\Admin\ExportController::indexAction + + - Thelia\Controller\Admin\ExportController::customerNewsletterAction + Thelia\Controller\Admin\CustomerExportController::NewsletterExportAction diff --git a/core/lib/Thelia/Controller/Admin/CustomerExportController.php b/core/lib/Thelia/Controller/Admin/CustomerExportController.php new file mode 100644 index 000000000..efc119d3f --- /dev/null +++ b/core/lib/Thelia/Controller/Admin/CustomerExportController.php @@ -0,0 +1,59 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Controller\Admin; + +use Thelia\Core\Security\AccessManager; +use Thelia\Core\Security\Resource\AdminResources; +use Thelia\Model\CustomerQuery; +use Thelia\Model\NewsletterQuery; + + +/** + * Class CustomerExportController + * @package Thelia\Controller\Admin + * @author Manuel Raynaud + */ +class CustomerExportController extends BaseAdminController +{ + + public function NewsletterExportAction() + { + if (null !== $response = $this->checkAuth([AdminResources::EXPORT_CUSTOMER_NEWSLETTER], [], [AccessManager::VIEW])) { + return $response; + } + + $data = NewsletterQuery::create() + ->select([ + 'email', + 'firstname', + 'lastname', + 'locale' + ]) + ->find(); + + + + } + +} \ No newline at end of file diff --git a/core/lib/Thelia/Controller/Admin/ExportController.php b/core/lib/Thelia/Controller/Admin/ExportController.php index f0f89f043..634f315e4 100644 --- a/core/lib/Thelia/Controller/Admin/ExportController.php +++ b/core/lib/Thelia/Controller/Admin/ExportController.php @@ -35,11 +35,12 @@ use Thelia\Core\Security\Resource\AdminResources; class ExportController extends BaseAdminController { - public function customerNewsletterAction() + public function indexAction() { if (null !== $response = $this->checkAuth([AdminResources::EXPORT], [], [AccessManager::VIEW])) { return $response; } + return $this->render('export'); } } \ No newline at end of file diff --git a/core/lib/Thelia/Core/Security/Resource/AdminResources.php b/core/lib/Thelia/Core/Security/Resource/AdminResources.php index dc44b8275..107aef017 100644 --- a/core/lib/Thelia/Core/Security/Resource/AdminResources.php +++ b/core/lib/Thelia/Core/Security/Resource/AdminResources.php @@ -103,5 +103,7 @@ final class AdminResources const EXPORT = "admin.export"; + const EXPORT_CUSTOMER_NEWSLETTER = "admin.export.customer.newsletter"; + const TOOLS = "admin.tools"; } diff --git a/setup/update/2.0.1.sql b/setup/update/2.0.1.sql index 10e1dac06..f3d7be46f 100644 --- a/setup/update/2.0.1.sql +++ b/setup/update/2.0.1.sql @@ -49,15 +49,6 @@ INSERT INTO resource_i18n (`id`, `locale`, `title`) VALUES SET @max := @max+1; -INSERT INTO `resource` (`id`, `code`, `created_at`, `updated_at`) VALUES -(@max, 'admin.export', NOW(), NOW()); - -INSERT INTO resource_i18n (`id`, `locale`, `title`) VALUES -(@max, 'en_US', 'Back-office export management'), -(@max, 'fr_FR', 'gestion des exports'); - -SET @max := @max+1; - INSERT INTO resource (`id`, `code`, `created_at`, `updated_at`) VALUES (@max, 'admin.configuration.advanced', NOW(), NOW()); @@ -83,6 +74,25 @@ INSERT INTO resource_i18n (`id`, `locale`, `title`) VALUES (@max, 'en_US', 'Tools panel'), (@max, 'fr_FR', 'Outils'); +SET @max := @max+1; + +INSERT INTO `resource` (`id`, `code`, `created_at`, `updated_at`) VALUES +(@max, 'admin.export', NOW(), NOW()); + +INSERT INTO resource_i18n (`id`, `locale`, `title`) VALUES +(@max, 'en_US', 'Back-office export management'), +(@max, 'fr_FR', 'gestion des exports'); + + +SET @max := @max+1; + +INSERT INTO `resource` (`id`, `code`, `created_at`, `updated_at`) VALUES +(@max, 'admin.export.customer.newsletter', NOW(), NOW()); + +INSERT INTO resource_i18n (`id`, `locale`, `title`) VALUES +(@max, 'en_US', 'export of newsletter subscribers'), +(@max, 'fr_FR', 'export des inscrits à la newsletter'); + SET FOREIGN_KEY_CHECKS = 1; diff --git a/templates/backOffice/default/export.html b/templates/backOffice/default/export.html new file mode 100644 index 000000000..ef2ae99d3 --- /dev/null +++ b/templates/backOffice/default/export.html @@ -0,0 +1,48 @@ +{extends file="admin-layout.tpl"} + +{block name="page-title"}{intl l='Exports'}{/block} + +{block name="check-resource"}admin.export{/block} +{block name="check-access"}view{/block} + +{block name="main-content"} +
+ +
+ + {module_include location='tools_top'} + +

{intl l="Thelia tools"}

+ +
+ +
+ +
+ + {module_include location='configuration_bottom'} +
+
+
+{/block} + +{block name="javascript-last-call"} + {module_include location='configuration-js'} +{/block} \ No newline at end of file diff --git a/templates/backOffice/default/tools.html b/templates/backOffice/default/tools.html index d150d5f03..ca41db425 100644 --- a/templates/backOffice/default/tools.html +++ b/templates/backOffice/default/tools.html @@ -24,13 +24,20 @@ {module_include location='tools_col1_top'} - {loop name="menu-auth-coupon" type="auth" role="ADMIN" resource="admin.coupon" access="VIEW"} + {loop name="auth-coupon" type="auth" role="ADMIN" resource="admin.coupon" access="VIEW"} {intl l="Coupons"} {/loop} + {loop name="auth-export" type="auth" role="ADMIN" resource="admin.export" access="VIEW"} + + {intl l="Export"} + + + {/loop} + {module_include location='tools_col1_bottom'}