PATH:
home
/
letacommog
/
letaweb
/
scripts
/
editor
/
popup
angular.module('ui.popup') .service('popup_discount', ['communication','popup_form','$templateCache','popup_grid',function(communication,popup_form,$templateCache,popup_grid) { this.open = function(opt) { opt = opt || {}; return popup_form.open( { name:'discount', data:opt.data, controller: function($scope,$modalInstance) { mergeCategories = function() { var mergeCategory = function(category, data) { for(var i = 0;i < data.length;i++) { if(category.id== data[i]) category.checked = true; } if(angular.isDefined(category.items)) { for(var i = 0;i <category.items.length;i++) { var cat = category.items[i]; mergeCategory(cat,data); } } } if(!angular.isDefined($scope.product_categories_list) || !angular.isDefined($scope.data.categories)) { return; } for(var i = 0;i < $scope.product_categories_list.length;i++) { var category = $scope.product_categories_list[i]; mergeCategory(category,$scope.data.categories); } } if(angular.isDefined($scope.data.id) && $scope.data.id !== 0) { communication.moduleExecute('getCategories', {id:$scope.data.id},'ecommerce.promotion.coupon').then(function(json) { $scope.data.categories = json; mergeCategories(); }); if($scope.data.to_buy_product_id || $scope.data.to_get_product_id) communication.moduleExecute('getProducts', {id:$scope.data.id},'ecommerce.promotion.discount').then(function(json) { if(angular.isDefined(json['to_buy_product'])) { $scope.product = json['to_buy_product']; } if(angular.isDefined(json['to_get_product'])) { $scope.get_product = json['to_get_product']; } }); communication.moduleExecute('getZones', {id:$scope.data.id},'ecommerce.promotion.coupon').then(function(json) { $scope.data.zones = json; }); communication.moduleExecute('getShipping_Methods', {id:$scope.data.id},'ecommerce.promotion.coupon').then(function(json) { $scope.data.shipping_methods = json; }); } var couponProductCategoryTree_recursiveTpl = '<i class="jstree-icon" ng-click="openCategoryItem(item)"></i>'+ '<i class="jstree-cat-icon"></i>'+ '<input type="checkbox" value="{{item.value}}" ng-model="item.checked" ng-change="selectedCategory()" />'+ '<label>{{item.name}}</label>'+ '<ul class="jstree">' + '<li ng-class="{\'jstree-close\': angular.isDefined(item.items) && item.opened,\'jstree-leaf\':!angular.isDefined(item.items) }" ng-repeat="item in item.items" ng-include="\'couponProductCategoryTree_recursiveTpl.html\'" ng-model="item">' + '</li>'+ '</ul>'; $templateCache.put('couponProductCategoryTree_recursiveTpl.html', couponProductCategoryTree_recursiveTpl); $scope.cancel = function () { $modalInstance.dismiss('cancel'); } $scope.expired_date_data =($scope.data.expired_date); ($scope.data.expired_date == null || $scope.data.expired_date=="") && ( $scope.expired_date_data=moment() ); var m = moment($scope.expired_date_data); $scope.$watch('expired_date_data', function() { var d = moment($scope.expired_date_data); if(d.isValid) { $scope.data.expired_date = moment($scope.expired_date_data).format('YYYY-MM-DD'); $scope.expired_date_text = moment($scope.expired_date_data).format(window.t('MM/DD/YYYY')); } }) $scope.start_date_data =($scope.data.start_date); ($scope.data.start_date_data == null || $scope.data.start_date=="") && ( $scope.start_date_data=moment() ); $scope.$watch('expired_date_data', function() { var d = moment($scope.start_date_data); if(d.isValid) { $scope.data.start_date = moment($scope.start_date_data).format('YYYY-MM-DD'); $scope.start_date_text = moment($scope.start_date_data).format(window.t('MM/DD/YYYY')); } }) $scope.data.is_active = $scope.data.is_active || 1; $scope.data.quantity_per_customer = $scope.data.quantity_per_customer || 0; $scope.data.quantity = $scope.data.quantity || 0; $scope.data.zone_limit = $scope.data.zone_limit || 0; $scope.data.shipping_method_limit = $scope.data.shipping_method_limit || 0; $scope.data.is_active = $scope.data.is_active || 0; $scope.data.free_shipping = $scope.data.free_shipping || 0; communication.getDefaultCurrency().then(function(default_currency) { $scope.curr_symbol_left = default_currency['symbol_left']; $scope.curr_symbol_right = default_currency['symbol_right']; }); var couponProductCategoryTree_recursiveTpl = '<i class="jstree-icon" ng-click="openCategoryItem(item)"></i>'+ '<i class="jstree-cat-icon"></i>'+ '<input type="checkbox" value="{{item.value}}" ng-model="item.checked" ng-change="selectedCategory()" />'+ '<label>{{item.name}}</label>'+ '<ul class="jstree">' + '<li ng-class="{\'jstree-close\': angular.isDefined(item.items) && item.opened,\'jstree-leaf\':!angular.isDefined(item.items) }" ng-repeat="item in item.items" ng-include="\'couponProductCategoryTree_recursiveTpl.html\'" ng-model="item">' + '</li>'+ '</ul>'; $templateCache.put('couponProductCategoryTree_recursiveTpl.html', couponProductCategoryTree_recursiveTpl); communication.getList('product_categories', {},'ecommerce.catalog.category').then(function(json) { $scope.product_categories_list = angular.copy(json); $scope.product_categories_list.unshift({id: 0, name: window.t('LBL_ALL_CATEGORIES')}); mergeCategories(); }); communication.getList('shipping_methods', {},'ecommerce.promotion.coupon').then(function(json) { $scope.shipping_method_list = angular.copy(json); }); communication.getList('zones', {}).then(function(json) { $scope.zone_list = angular.copy(json); }); var gencode = function(size) { var value = ''; var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; for (var i = 1; i <= size; ++i) value += chars.charAt(Math.floor(Math.random() * chars.length)); return value; }; $scope.data.quantity_limit=$scope.data.quantity_limit || 0; $scope.data.categories=$scope.data.categories ||[]; $scope.selectedCategory = function() { $scope.data.categories=[]; function checkCat(cat) { if(cat.checked) $scope.data.categories.push(cat.id); if(angular.isDefined(cat.items)) { for(var i = 0;i < cat.items.length;i++) { checkCat(cat.items[i]); } } } for(var i = 0;i < $scope.product_categories_list.length;i++) { checkCat($scope.product_categories_list[i]); } console.log($scope.data.categories); } $scope.generateCode = function() { $scope.data.code= gencode(10); } $scope.products = []; $scope.product = {name:window.t('LBL_DISCOUNT_THIS_PRODUCT_NONE_SELECT')}; $scope.selectProduct = function() { popup_grid.open( { name:'product_grid' }).result.then(function(json) { for(var i = 0; i < json.length;i++) $scope.product = (json[i]); $scope.data.to_buy_product_id = $scope.product.id; }); } $scope.get_product = {name:window.t('LBL_DISCOUNT_THIS_PRODUCT_NONE_SELECT')}; $scope.selectGetProduct = function() { popup_grid.open( { name:'product_grid' }).result.then(function(json) { for(var i = 0; i < json.length;i++) $scope.get_product = (json[i]); $scope.data.to_get_product_id = $scope.product.id; }); } }, size:'lg', execute_path:'ecommerce.promotion.discount', form_name:'DiscountForm' }); } }]);
[+]
..
[-] profile.js
[edit]
[-] pagelist.js
[edit]
[-] order.js
[edit]
[-] customer_group.js
[edit]
[-] module_list.js
[edit]
[-] backgroundeditor.js
[edit]
[-] product.js
[edit]
[-] visualcsseditor.js
[edit]
[-] shipping_rule.js
[edit]
[-] profile_change_password.js
[edit]
[-] review.js
[edit]
[-] contributor_invite.js
[edit]
[-] dbfilter.js
[edit]
[-] tax_class.js
[edit]
[-] special_module_style_editor.js
[edit]
[-] idletimeout.js
[edit]
[-] address.js
[edit]
[-] contributor.js
[edit]
[-] login.js
[edit]
[-] skin.js
[edit]
[-] mail.js
[edit]
[-] discount.js
[edit]
[-] customer.js
[edit]
[-] productgrid.js
[edit]
[-] socialsharebuttonconfig.js
[edit]
[-] news.js
[edit]
[-] color.js
[edit]
[-] palette.js
[edit]
[-] newsgrid.js
[edit]
[-] product_option_combination_grid.js
[edit]
[-] page.js
[edit]
[-] product_option.js
[edit]
[-] tax_rate.js
[edit]
[-] coupons.js
[edit]
[-] zone.js
[edit]
[-] product_bulk_price.js
[edit]
[-] option_set.js
[edit]
[-] product_option_combination.js
[edit]