From 3253290860a3f0b5d8a078c53e263f0281bc3c3a Mon Sep 17 00:00:00 2001 From: Sylvain Date: Tue, 16 Aug 2016 11:33:10 +0200 Subject: [PATCH] [ongoing] send a coupon to a user --- .../controllers/admin/pricing.coffee.erb | 17 ++++++++++ app/assets/javascripts/router.coffee.erb | 2 +- .../templates/admin/pricing/coupons.html.erb | 1 + .../admin/pricing/sendCoupon.html.erb | 31 +++++++++++++++++++ config/locales/app.admin.en.yml | 4 ++- config/locales/app.admin.fr.yml | 4 ++- 6 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 app/assets/templates/admin/pricing/sendCoupon.html.erb diff --git a/app/assets/javascripts/controllers/admin/pricing.coffee.erb b/app/assets/javascripts/controllers/admin/pricing.coffee.erb index 91928083e..7d23701e1 100644 --- a/app/assets/javascripts/controllers/admin/pricing.coffee.erb +++ b/app/assets/javascripts/controllers/admin/pricing.coffee.erb @@ -341,6 +341,23 @@ Application.Controllers.controller "EditPricingController", ["$scope", "$state", + ## + # Open a modal allowing to select an user and send him the details of the provided coupon + # @param coupon {Object} The coupon to send + ## + $scope.sendCouponToUser = (coupon) -> + $uibModal.open + templateUrl: '<%= asset_path "admin/pricing/sendCoupon.html" %>' + resolve: + coupon: -> coupon + size: 'md' + controller: ['$scope', '$uibModalInstance', 'Coupon', 'coupon', ($scope, $uibModalInstance, Coupon, coupon) -> + $scope.coupon = coupon + $scope.ok = -> + $uibModalInstance.close(user) + ] + + ### PRIVATE SCOPE ### ## diff --git a/app/assets/javascripts/router.coffee.erb b/app/assets/javascripts/router.coffee.erb index f9c32c06a..1dd4b362d 100644 --- a/app/assets/javascripts/router.coffee.erb +++ b/app/assets/javascripts/router.coffee.erb @@ -735,7 +735,7 @@ angular.module('application.router', ['ui.router']). TrainingsPricing.query().$promise ] translations: [ 'Translations', (Translations) -> - Translations.query('app.admin.pricing').$promise + Translations.query(['app.admin.pricing', 'app.shared.member_select', 'app.shared.coupon']).$promise ] trainingsPromise: ['Training', (Training) -> Training.query().$promise diff --git a/app/assets/templates/admin/pricing/coupons.html.erb b/app/assets/templates/admin/pricing/coupons.html.erb index a71db820b..61c97dff1 100644 --- a/app/assets/templates/admin/pricing/coupons.html.erb +++ b/app/assets/templates/admin/pricing/coupons.html.erb @@ -18,6 +18,7 @@ {{coupon.usages}} {{coupon.status}} + diff --git a/app/assets/templates/admin/pricing/sendCoupon.html.erb b/app/assets/templates/admin/pricing/sendCoupon.html.erb new file mode 100644 index 000000000..1e1c10ee6 --- /dev/null +++ b/app/assets/templates/admin/pricing/sendCoupon.html.erb @@ -0,0 +1,31 @@ + +
+ +
+ +
+
+

{{ 'coupon' }}

+
+
+ + + + + + + + + + +
{{'code'}}{{coupon.code}}
{{'percent_off'}}{{coupon.percent_off}} %
{{'validity_per_user'}}{{coupon.validity_per_user}}
{{'valid_until'}}{{coupon.valid_until | amDateFormat:'L'}}
+
+
+
+
+ \ No newline at end of file diff --git a/config/locales/app.admin.en.yml b/config/locales/app.admin.en.yml index 17bcaacbb..af08af174 100644 --- a/config/locales/app.admin.en.yml +++ b/config/locales/app.admin.en.yml @@ -113,7 +113,7 @@ en: back_to_monitoring: "Back to monitoring" pricing: - # subscriptions, prices and credits management + # subscriptions, prices, credits and coupons management pricing_management: "Pricing management" list_of_the_subscription_plans: "List of the subscription plans" beware_the_subscriptions_are_disabled_on_this_application: "Beware, the subscriptions are disabled on this application." @@ -158,6 +158,8 @@ en: coupon_was_successfully_deleted: "Coupon was successfully deleted." unable_to_delete_the_specified_coupon_already_in_use: "Unable to delete the specified coupon: it is already used with some invoices." unable_to_delete_the_specified_coupon_an_unexpected_error_occurred: "Unable to delete the specified coupon: an unexpected error occurred." + send_a_coupon: "Send a coupon" + coupon: "Coupon" coupons_new: # ajouter un code promotionnel diff --git a/config/locales/app.admin.fr.yml b/config/locales/app.admin.fr.yml index f594466db..70f37d74a 100644 --- a/config/locales/app.admin.fr.yml +++ b/config/locales/app.admin.fr.yml @@ -113,7 +113,7 @@ fr: back_to_monitoring: "Retour au suivi" pricing: - # gestion des abonnements, des tarifs et des crédits + # gestion des abonnements, des tarifs, des crédits et des codes promo pricing_management: "Gestion de la tarification" list_of_the_subscription_plans: "Liste des formules d'abonnements" beware_the_subscriptions_are_disabled_on_this_application: "Attention, les abonnements sont désactivés sur cette application." @@ -158,6 +158,8 @@ fr: coupon_was_successfully_deleted: "Le code promotionnel a bien été supprimé." unable_to_delete_the_specified_coupon_already_in_use: "Impossible de supprimer le code promotionnel : il est utilisé dans des factures." unable_to_delete_the_specified_coupon_an_unexpected_error_occurred: "Impossible de supprimer le code promotionnel : une erreur inattendue s'est produite." + send_a_coupon: "Envoyer un code promo" + coupon: "Code promo" coupons_new: # ajouter un code promotionnel