Merge pull request #341 from lunika/export

newsletter subscriber export
This commit is contained in:
Manuel Raynaud
2014-04-25 01:26:39 +02:00
16 changed files with 361 additions and 10 deletions

View File

@@ -549,6 +549,10 @@
<!-- Routes to the Config (system variables) controller -->
<route id="admin.configuration.inedx" path="/admin/configuration">
<default key="_controller">Thelia\Controller\Admin\ConfigurationController::indexAction</default>
</route>
<route id="admin.configuration.variables.default" path="/admin/configuration/variables">
<default key="_controller">Thelia\Controller\Admin\ConfigController::defaultAction</default>
</route>
@@ -1150,6 +1154,16 @@
<default key="_controller">Thelia\Controller\Admin\TranslationsController::updateAction</default>
</route>
<!-- export management -->
<route id="export.main" path="/admin/export">
<default key="_controller">Thelia\Controller\Admin\ExportController::indexAction</default>
</route>
<route id="export.customer.newsletter" path="/admin/export/customer/newsletter">
<default key="_controller">Thelia\Controller\Admin\CustomerExportController::NewsletterExportAction</default>
</route>
<!-- The default route, to display a template -->
<route id="admin.processTemplate" path="/admin/{template}">

View File

@@ -0,0 +1,34 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Thelia\Controller\Admin;
use Thelia\Core\Security\AccessManager;
use Thelia\Core\Security\Resource\AdminResources;
/**
* Class ConfigurationController
* @package Thelia\Controller\Admin
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class ConfigurationController extends BaseAdminController
{
public function indexAction()
{
if (null !== $response = $this->checkAuth([AdminResources::CONFIG], [], [AccessManager::VIEW])) {
return $response;
}
return $this->render('configuration');
}
}

View File

@@ -0,0 +1,67 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Thelia\Controller\Admin;
use Thelia\Core\HttpFoundation\Response;
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 <mraynaud@openstudio.fr>
*/
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();
$handle = fopen('php://memory', 'r+');
fputcsv($handle, ['email','firstname','lastname','locale'], ';', '"');
foreach ($data->toArray() as $customer) {
fputcsv($handle, $customer, ';', '"');
}
rewind($handle);
$content = stream_get_contents($handle);
fclose($handle);
return Response::create(
$content,
200,
array(
"Content-Type"=>"application/csv-tab-delimited-table",
"Content-disposition"=>"filename=export_customer_newsletter.csv"
)
);
}
}

View File

@@ -0,0 +1,35 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Thelia\Controller\Admin;
use Thelia\Core\Security\AccessManager;
use Thelia\Core\Security\Resource\AdminResources;
/**
* Class ExportController
* @package Thelia\Controller\Admin
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class ExportController extends BaseAdminController
{
public function indexAction()
{
if (null !== $response = $this->checkAuth([AdminResources::EXPORT], [], [AccessManager::VIEW])) {
return $response;
}
return $this->render('export');
}
}

View File

@@ -0,0 +1,34 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Thelia\Controller\Admin;
use Thelia\Core\Security\AccessManager;
use Thelia\Core\Security\Resource\AdminResources;
/**
* Class ToolsController
* @package Thelia\Controller\Admin
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class ToolsController extends BaseAdminController
{
public function indexAction()
{
if (null !== $response = $this->checkAuth([AdminResources::TOOLS], [], [AccessManager::VIEW])) {
return $response;
}
return $this->render('tools');
}
}

View File

@@ -100,4 +100,10 @@ final class AdminResources
const TRANSLATIONS = "admin.configuration.translations";
const UPDATE = "admin.configuration.update";
const EXPORT = "admin.export";
const EXPORT_CUSTOMER_NEWSLETTER = "admin.export.customer.newsletter";
const TOOLS = "admin.tools";
}

View File

@@ -1277,7 +1277,9 @@ INSERT INTO resource (`id`, `code`, `created_at`, `updated_at`) VALUES
(29, 'admin.configuration.admin-logs', NOW(), NOW()),
(30, 'admin.configuration.system-logs', NOW(), NOW()),
(31, 'admin.configuration.advanced', NOW(), NOW()),
(32, 'admin.configuration.translations', NOW(), NOW());
(32, 'admin.configuration.translations', NOW(), NOW()),
(33, 'admin.export', NOW(), NOW()),
(34, 'admin.tools', NOW(), NOW());
/**
generated with command : php Thelia thelia:generate-resources --output sql-i18n
@@ -1346,7 +1348,11 @@ INSERT INTO resource_i18n (`id`, `locale`, `title`) VALUES
(31, 'en_US', 'Advanced configuration'),
(31, 'fr_FR', 'Configuration avancée'),
(32, 'en_US', 'Translations'),
(32, 'fr_FR', 'Traductions');
(32, 'fr_FR', 'Traductions'),
(33, 'en_US', 'Back-office export management'),
(33, 'fr_FR', 'gestion des exports'),
(34, 'en_US', 'Tools panel'),
(34, 'fr_FR', 'Outils');
INSERT INTO `message` (`id`, `name`, `secured`, `text_layout_file_name`, `text_template_file_name`, `html_layout_file_name`, `html_template_file_name`, `created_at`, `updated_at`) VALUES

View File

@@ -12,6 +12,7 @@ ALTER TABLE `module` ADD INDEX `idx_module_activate` (`activate`);
SELECT @max := MAX(`id`) FROM `resource`;
SET @max := @max+1;
INSERT INTO resource (`id`, `code`, `created_at`, `updated_at`) VALUES
(@max, 'admin.configuration.store', NOW(), NOW());
@@ -64,4 +65,34 @@ INSERT INTO resource_i18n (`id`, `locale`, `title`) VALUES
(@max, 'en_US', 'Translations'),
(@max, 'fr_FR', 'Traductions');
SET @max := @max+1;
INSERT INTO resource (`id`, `code`, `created_at`, `updated_at`) VALUES
(@max, 'admin.tools', NOW(), NOW());
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;

View File

@@ -205,6 +205,7 @@ return array(
'Current quantity' => 'Quantité actuelle',
'Current version' => 'Version en cours',
'Customer' => 'Client',
'Customer export' => 'Export client',
'Customer informations' => 'Informations client',
'Customers' => 'Clients',
'Customers list' => 'Liste des clients',
@@ -456,6 +457,8 @@ return array(
'Existing combinations will be deleted. Do you want to continue ?' => 'Les combinaisons existantes seront supprimées. Voulez-vous continuer ?',
'Expiration date' => 'Date de fin de validité',
'Expiration date :' => 'Date de fin de validité : ',
'Export' => 'Export',
'Exports' => 'Exports',
'Failed to get converted prices. Please try again.' => 'Erreur lors de la récupération des prix convertis. Veuillez réessayer.',
'Failed to get prices. Please try again.' => 'Erreur lors de la récupération des prix. Veuillez réessayer.',
'Fax number' => 'Numéro de fax',
@@ -487,6 +490,7 @@ return array(
'General' => 'Général',
'General configuration' => 'Configuration générale',
'General description' => 'Description générale',
'General tools' => 'outils généraux',
'Go to administration home' => 'Aller à l\'accueil de l\'interface d\'administration',
'Go to first page' => 'Aller à la première page',
'Go to last page' => 'Aller à la dernière page',
@@ -837,6 +841,7 @@ return array(
'Thelia product templates' => 'templates produit Thelia',
'Thelia support forum' => 'Forum de Thelia',
'Thelia system variables' => 'Variables Thelia',
'Thelia tools' => 'Outils Thelia',
'Thelia, the open source e-commerce solution' => 'Thelia, la solution e-commerce libre',
'There are no shipping zones attached to this module.' => 'Ce module de transport n\'est associé à aucune zone de livraison',
'There is currently no active module here.' => 'Il n\'y a aucun module actif ici',
@@ -880,6 +885,7 @@ return array(
'To remove a value from the combination, select it and click "remove"' => 'Afin de supprimer une valeur de la combinaison, sélectionnez la et cliquez sur "Enlever"',
'To use features or attributes on this product, please select a product template. You can define product templates in the <a href=\"%tpl_mgmt_url\" target=\"tpl_window\">configuration section</a> of the administration.' => 'Pour utiliser les déclinaisons et les caractéristiques sur ce produit, choisissez un tempplate produit. Vous pouvez gérer les templates de produit dans <a href=\"%tpl_mgmt_url\" target=\"tpl_window\">la section configuration</a> de l\'administration.',
'Today' => 'Aujourd\'hui',
'Tools' => 'Outils',
'Top level' => 'Niveau 1',
'Top level Contents' => 'Contenus de niveau 1',
'Top level Products' => 'Produits mis en avant',
@@ -970,6 +976,7 @@ return array(
'last order' => 'Dernière commande',
'long description' => 'description longue',
'max usage' => 'utilisations max',
'newsletter subscribers' => 'Inscrits à la newsletter',
'order amount' => 'Montant de la commande',
'orders for this customer' => 'commandes pour ce client',
'short description' => 'description court',

View File

@@ -187,26 +187,28 @@
</li>
{/loop}
{loop name="menu-auth-coupon" type="auth" role="ADMIN" resource="admin.coupon" access="VIEW"}
<li class="{if $admin_current_location == 'coupon'}active{/if}" id="coupon_menu">
<a href="{url path='/admin/coupon'}">{intl l="Coupons"}</a>
{loop name="menu-auth-tools" type="auth" role="ADMIN" resource="admin.tools" access="VIEW"}
<li class="{if $admin_current_location == 'tools'}active{/if}" id="tools_menu">
<a href="{url path='/admin/tools'}">{intl l="Tools"}</a>
</li>
{/loop}
{loop name="menu-auth-modules" type="auth" role="ADMIN" resource="admin.module" access="VIEW"}
<li class="{if $admin_current_location == 'modules'}active{/if}" id="modules_menu">
<a href="{url path='/admin/modules'}">{intl l="Modules"}</a>
</li>
{/loop}
{loop name="menu-auth-config" type="auth" role="ADMIN" resource="admin.configuration" access="VIEW"}
<li class="{if $admin_current_location == 'configuration'}active{/if}" id="config_menu">
<a href="{url path='/admin/configuration'}">{intl l="Configuration"}</a>
</li>
{/loop}
{loop name="menu-auth-modules" type="auth" role="ADMIN" resource="admin.module" access="VIEW"}
<li class="{if $admin_current_location == 'modules'}active{/if}" id="modules_menu">
<a href="{url path='/admin/modules'}">{intl l="Modules"}</a>
</li>
{module_include location='in_top_menu_items'}
{/loop}
</ul>
{loop name="top-bar-search" type="auth" role="ADMIN" resource="admin.search" access="VIEW"}

View File

@@ -11,6 +11,7 @@
<nav>
<ul class="breadcrumb">
<li><a href="{url path='admin/home'}">{intl l='Home'}</a></li>
<li><a href="{url path='admin/tools'}">{intl l='Tools'}</a></li>
<li><a href="{url path='admin/coupon'}">{intl l='Coupon'}</a></li>
<li>{intl l='Create'}</li>
</ul>

View File

@@ -13,6 +13,7 @@
<nav>
<ul class="breadcrumb">
<li><a href="{url path='admin/home'}">{intl l='Home'}</a></li>
<li><a href="{url path='admin/tools'}">{intl l='Tools'}</a></li>
<li><a href="{url path='admin/coupon'}">{intl l='Coupon'}</a></li>
</ul>
</nav>

View File

@@ -14,6 +14,7 @@
<nav>
<ul class="breadcrumb">
<li><a href="{url path='admin/home'}">{intl l='Home'}</a></li>
<li><a href="{url path='admin/tools'}">{intl l='Tools'}</a></li>
<li><a href="{url path='admin/coupon'}">{intl l='Coupon'}</a></li>
<li>{$CODE}</li>
</ul>

View File

@@ -12,6 +12,7 @@
<nav>
<ul class="breadcrumb">
<li><a href="{url path='admin/home'}">{intl l='Home'}</a></li>
<li><a href="{url path='admin/tools'}">{intl l='Tools'}</a></li>
<li><a href="{url path='admin/coupon'}">{intl l='Coupon'}</a></li>
<li>{intl l="Editing %title" title="$couponCode"}</li>
</ul>

View File

@@ -0,0 +1,56 @@
{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"}
<div class="configuration">
<div id="wrapper" class="container">
<nav>
<ul class="breadcrumb">
<li><a href="{url path='admin/home'}">{intl l='Home'}</a></li>
<li><a href="{url path='admin/tools'}">{intl l='Tools'}</a></li>
<li>{intl l="Exports"}</li>
</ul>
</nav>
{module_include location='tools_top'}
<h2>{intl l="Thelia tools"}</h2>
<div class="row">
<div class="col-md-4">
<div class="menu-list-table general-block-decorator">
<div class="table-responsive">
<table class="table table-striped table-condensed">
<caption>{intl l='Customer export'}</caption>
{module_include location='tools_col1_top'}
{loop name="auth-export" type="auth" role="ADMIN" resource="admin.export.customer.newsletter" access="VIEW"}
<tr>
<td><a href="{url path='/admin/export/customer/newsletter'}">{intl l="newsletter subscribers"}</a></td>
<td><a class="btn btn-default btn-xs" href="{url path='/admin/export/customer/newsletter'}"><i class="glyphicon glyphicon-edit"></i></a></td>
</tr>
{/loop}
{module_include location='tools_col1_bottom'}
</table>
</div>
</div>
</div>
{module_include location='configuration_bottom'}
</div>
</div>
</div>
{/block}
{block name="javascript-last-call"}
{module_include location='configuration-js'}
{/block}

View File

@@ -0,0 +1,55 @@
{extends file="admin-layout.tpl"}
{block name="page-title"}{intl l='Tools'}{/block}
{block name="check-resource"}admin.tools{/block}
{block name="check-access"}view{/block}
{block name="main-content"}
<div class="configuration">
<div id="wrapper" class="container">
{module_include location='tools_top'}
<h2>{intl l="Thelia tools"}</h2>
<div class="row">
<div class="col-md-4">
<div class="menu-list-table general-block-decorator">
<div class="table-responsive">
<table class="table table-striped table-condensed">
<caption>{intl l='General tools'}</caption>
{module_include location='tools_col1_top'}
{loop name="auth-coupon" type="auth" role="ADMIN" resource="admin.coupon" access="VIEW"}
<tr>
<td><a href="{url path='/admin/coupon'}">{intl l="Coupons"}</a></td>
<td><a class="btn btn-default btn-xs" href="{url path='/admin/coupon'}"><i class="glyphicon glyphicon-edit"></i></a></td>
</tr>
{/loop}
{loop name="auth-export" type="auth" role="ADMIN" resource="admin.export" access="VIEW"}
<tr>
<td><a href="{url path='/admin/export'}">{intl l="Export"}</a></td>
<td><a class="btn btn-default btn-xs" href="{url path='/admin/export'}"><i class="glyphicon glyphicon-edit"></i></a></td>
</tr>
{/loop}
{module_include location='tools_col1_bottom'}
</table>
</div>
</div>
</div>
{module_include location='configuration_bottom'}
</div>
</div>
</div>
{/block}
{block name="javascript-last-call"}
{module_include location='configuration-js'}
{/block}