PATH:
home
/
letacommog
/
letaweb
/
scripts
/
editor
/
popup
angular.module('ui.popup') .service('popup_order', ['$compile', '$controller', '$file_manager','communication','popup_form','popup_grid','$templateCache','$filter',function($compile,$controller, $file_manager,communication,popup_form,popup_grid,$templateCache,$filter) { this.open = function(opt) { opt = opt || {}; return popup_form.open( { name:'order', controller: function($scope) { $scope.data = $scope.data || {}; function getPaymentModuleId() { var payment_option_id = $scope.data.payment_option_id; if(payment_option_id == undefined) return false; var payment_option = payment_option_id.split(':'); if(payment_option.length) { return payment_option[0]; } return payment_option_id; } $scope.order_statuses = []; communication.getList("orderStatus", {}, "ecommerce").then(function(json) { $scope.order_statuses = json; }); $scope.countries = []; communication.getList("country", {}, "ecommerce").then(function(json) { $scope.countries = json; }); $scope.filterZoneList = function(index) { if($scope.zones == undefined) return; if(index ==1) $scope.data.customer_zone_code=''; if(index ==2) $scope.data.shipping_zone_code=''; var country_code = ''; if($scope.data != undefined && $scope.data.shipping_country_code != undefined) { country_code = $scope.data.shipping_country_code; } $scope.shipping_zones = []; for(var i in $scope.zones) { if(!$scope.zones[i]) continue; if($scope.zones[i].country_code == country_code) { $scope.shipping_zones.push($scope.zones[i]); } } var country_code = ''; if($scope.data != undefined && $scope.data.customer_country_code != undefined) { country_code = $scope.data.customer_country_code; } $scope.payment_zones = []; for(var i in $scope.zones) { if(!$scope.zones[i]) continue; if($scope.zones[i].country_code == country_code) { $scope.payment_zones.push($scope.zones[i]); } } } $scope.zones = []; communication.getList("zone", {}, "ecommerce").then(function(json) { $scope.zones = json; $scope.filterZoneList(); }); $scope.paymentModules = []; communication.getList("paymentModule", {}, "ecommerce").then(function(json) { $scope.paymentModules = json; }); $scope.order_totalModules = []; communication.getList("order_totalModule", {}, "ecommerce").then(function(json) { $scope.order_totalModules = json; }); $scope.shippingModules = []; communication.getList("shippingModule", {}, "ecommerce").then(function(json) { $scope.shippingModules = json; }); $scope.getProducts = function(val) { return communication.api('searchProducts', {filter:val}, 'ecommerce.promotion.coupon').then(function(response){ return response; }); }; $scope.qty_to_add = 1; $scope.product_id_to_add = 0; $scope.selectProduct_ToAdd = function(product) { $scope.product_id_to_add = product.id; $scope.product_to_add = product; } $scope.addComment = function() { $scope.data = $scope.data || {}; $scope.data.comments = $scope.data.comments || []; $scope.data.comments.push({text:""}); } $scope.removeComment = function(index) { $scope.data.comments.splice(index,1); } $scope.filter_ot_subtotal = function (item) { return item.module_id === 'ot_subtotal'; }; $scope.addProduct = function() { var flag = false; for(var j = $scope.data.items.length - 1; j >= 0; j--) { if(!$scope.data.items.hasOwnProperty(j)) continue; if($scope.data.items[j]['product_id'] == $scope.product_to_add['id']) { $scope.data.items[j].quantity =$scope.data.items[j].quantity*1 + ($scope.qty_to_add||1)*1; flag = true; } } if(!flag) { var new_item = angular.copy($scope.product_to_add); new_item.product_id = $scope.product_to_add.id; new_item.id = 0; new_item.quantity = ($scope.qty_to_add||1); $scope.data.items.push(new_item); } $scope.calculate_total(); } $scope.filterOrderTotal = function(order_total) { return (order_total.module_id != 'ot_total' && order_total.module_id != 'ot_subtotal'); }; $scope.filterOrderTotalModule = function(order_total) { return (order_total.id != 'ot_total' && order_total.id != 'ot_subtotal'); }; $scope.addOrderTotalItem = function(index) { if(index == undefined) index = $scope.data.order_total.length; $scope.data.order_total.splice(index,0, {module_id:$scope.order_totalModules[0].id, title:$scope.order_totalModules[0].title, value:0, tax:0, calculate:1}); $scope.calculate_total(); } $scope.removeOrderTotalItem = function(index) { $scope.data.order_total.splice(index,1); } $scope.removeProduct = function(index) { $scope.data.items.splice(index,1); $scope.calculate_total(); } $scope.calculate_total = function() { var subtotal = 0; var subtotal_tax = 0; for(var i in $scope.data.items) { var item = $scope.data.items[i]; if(item== undefined) continue; subtotal += Number(item.price * item.quantity); subtotal_tax += Number(item.tax) * Number(item.quantity); } subtotal = Math.round(subtotal * 1* 100) / 100; subtotal_tax = Math.round(subtotal_tax * 1* 100) / 100; var order_total = subtotal + subtotal_tax; for(var i in $scope.data.order_total) { var item = $scope.data.order_total[i]; if(item.module_id== 'ot_total') continue; if(item== undefined) continue; if(item.module_id== 'ot_subtotal') { item.value = Number(Number(subtotal)); item.tax = Number(Number(subtotal_tax)); continue; } if (item.calculate==1) { order_total += Number(Number(item.value)); order_total += Number(Number(item.tax)); } } order_total = Math.round(order_total * 100) / 100; $scope.data.payment_due = order_total; for(var i in $scope.data.order_total) { var item = $scope.data.order_total[i]; if(item== undefined) continue; if(item.module_id== 'ot_total') { item.value = Number(Number(order_total)); item.tax = 0; return; } } } communication.api("getOrderForm", {id:opt.data.id}, "ecommerce.order.order").then(function(json) { //var element = angular.element(json); $scope.contentElement = json.html; $scope.data = json.data; $scope.data.currency_value = $scope.data.currency_value || 0; $scope.data.currency_value = parseFloat($scope.data.currency_value); $scope.filterZoneList(); payment_module = getPaymentModuleId(); require([window.baseScriptPath+'/editor/ecommerce/order/' + payment_module + '.js'],function(controller){ templateScope = $scope.$new(); templateCtrl = $controller(controller, {$scope: $scope}); $compile($scope.contentElement)($scope); }); //$scope.data.order_total = object_toArray($scope.data.order_total ); //$scope.data.items = object_toArray($scope.data.items ); //$scope.data.comments = object_toArray($scope.data.comments ); }); }, data:opt.data, size:'lg', execute_path:'ecommerce.order.order', form_name:'OrderForm' }); } }]) .directive('orderPopupBody', ['$parse','$controller','communication','$compile', function($parse,$controller,communication,$compile) { return { restrict: 'A', link: function (scope, element, attrs) { scope.$watch(function () { return scope.$eval(attrs.orderPopupBody); }, function (value) { // In case value is a TrustedValueHolderType, sometimes it // needs to be explicitly called into a string in order to // get the HTML string. element.html(value && value.toString()); // If scope is provided use it, otherwise use parent scope var compileScope = scope; if (attrs.bindHtmlScope) { compileScope = scope.$eval(attrs.orderPopupBody); } $compile(element.contents())(compileScope); }); } }; }]);
[+]
..
[-] 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]