Initial commit

This commit is contained in:
Senad Uka
2018-06-11 11:09:35 +02:00
commit ed7df7b11f
1954 changed files with 483354 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
(function () {
global.dashModule
.directive('cartReview', ['$', '$translate', 'shopCartService', cartReviewDirective]);
function cartReviewDirective($, $translate, shopCartService) {
return {
restrict: 'A',
templateUrl: 'shop/html/cartReview',
scope: {
countryNames: '<',
cartPackages: '<',
delivery: '<',
billing: '<',
details: '<'
},
link: function (scope) {
scope.sumPrice = shopCartService.sumPrice;
}
};
}
})();

View File

@@ -0,0 +1,488 @@
(function () {
global.dashModule
.controller('shopCartCtrl', ['$scope', '$http', '$', '$translate', 'Upload', 'utilsService', 'shopCartService', shopCartCtrl])
.directive('shopCart', [shopCartDirective]);
function shopCartDirective() {
return {
restrict: 'E',
templateUrl: 'shop/html/shopCartTemplate'
};
}
function shopCartCtrl($scope, $http, $, $translate, Upload, utilsService, shopCartService) {
let addressType = '';
const countryNames = {};
$scope.DOCUMENT_TYPES = {
'TEMPLATE_QUESTINNAIRE': 1,
'QUESTIONNAIRE': 2,
'TEMPLATE_AGREEMENT': 6,
'AGREEMENT': 7
};
$scope.startOrderDetails = startOrderDetails;
$scope.cartPackages = [];
$scope.countries = [];
$scope.details = {};
$scope.delivery = {};
$scope.billing = {};
$scope.countryNames = {};
$scope.updateQuantity = updateQuantity;
$scope.removeFromCart = removeFromCart;
$scope.actionButton = 'NEXT';
$scope.prevButton = '';
$scope.isStepVisible = isStepVisible;
$scope.hasPrevStep = hasPrevStep;
$scope.goToNextStep = goToNextStep;
$scope.showHideDialog = showHideDialog;
$scope.isDialogVisible = false;
$scope.placeOrder = placeOrder;
$scope.changeCountryName = changeCountryName;
$scope.isCartEmpty = isCartEmpty;
$scope.sumPrice = shopCartService.sumPrice;
$scope.isAvailable = isAvailable;
$scope.getAvailabilityMessage = getAvailabilityMessage;
$scope.termsAndConditionCheckbox = false;
$scope.setTermsCheckboxValue = setTermsCheckboxValue;
$scope.getAlertClass = getAlertClass;
$scope.isActionBtnDisabled = isActionBtnDisabled;
$scope.deliveryEqualsBilling = {
checked: false
};
$scope.setBillingSameAsDeliveryAddress = setBillingSameAsDeliveryAddress;
$scope.getOptionAvailabilityClass = getOptionAvailabilityClass;
$scope.documents = {};
$scope.selectionSteps = {
'show-order-items': {
current: 'show-order-items',
next: 'upload-customer-questionaire',
prev: '',
isActionPromise: false,
beforeAction: isCartValid,
action: getInfo
},
'upload-customer-questionaire': {
current: 'upload-customer-questionaire',
next: 'upload-agreement',
prev: 'show-order-items',
isActionPromise: false,
beforeAction: isQuestionaireUploaded,
action: () => {
return true;
}
},
'upload-agreement': {
current: 'upload-agreement',
next: 'show-customer-details',
prev: 'upload-customer-questionaire',
isActionPromise: false,
beforeAction: isAgreementUploaded,
action: () => {
return true;
}
},
'show-customer-details': {
current: 'show-customer-details',
next: 'show-customer-billing',
prev: 'upload-agreement',
isActionPromise: false,
beforeAction: () => {
return true;
},
action: () => {
return true;
}
},
'show-customer-billing': {
current: 'show-customer-billing',
next: '',
prev: 'show-customer-details',
isActionPromise: false,
beforeAction: () => {
return true;
},
action: showHideDialog
},
};
$scope.step = $scope.selectionSteps['show-order-items'];
$scope.uploadFile = uploadFile;
$scope.isOrderPlaced = false;
function startOrderDetails() {
getShopCart();
isActionBtnDisabled();
utilsService.registerFunction('isActionBtnDisabled', isActionBtnDisabled);
}
function getOptionAvailabilityClass(isAvailable) {
return isAvailable ? '' : 'not-available';
}
function isStepVisible(step) {
return step === $scope.step.current;
}
function getShopCart() {
$http({
method: 'POST',
url: 'shop/api/getShopCart'
}).then(setShopCartPackages, utilsService.onHttpError);
}
function setShopCartPackages(response) {
if (typeof response.data !== 'undefined') {
$scope.cartPackages = response.data;
$.each($scope.cartPackages, function (key, packageObject) {
$scope.commercialLead = packageObject.commercialLead;
packageObject.quantity = parseInt(packageObject.quantity);
packageObject.extraFixedPrice = calculateTotalPrice(packageObject, 'fixedPrice');
packageObject.extraRecurrentPrice = calculateTotalPrice(packageObject, 'recurrentPrice') + calculateTotalPrice(packageObject, 'servicesPrice');
});
}
}
function calculateTotalPrice(packageObject, priceKey) {
let prices = packageObject.options.map((option) => {
return option[priceKey];
});
prices = prices.concat(packageObject.additionalPackages.map((additionalPackage) => {
return additionalPackage[priceKey];
}));
return shopCartService.sumPrice(prices, 1);
}
function updateQuantity(packageObject) {
const params = $.param({
idPackage: packageObject.idPackage,
idCustomerInstance: packageObject.idCustomerInstance,
idPrice: packageObject.idPrice,
quantity: packageObject.quantity
});
$http({
method: 'POST',
url: 'shop/api/updateQuantity',
data: params
}).then(updateMessage, utilsService.onHttpError);
}
function removeFromCart(packageObject) {
const params = $.param({
idCart: packageObject.idCart
});
$http({
method: 'POST',
url: 'shop/api/removeFromCart',
data: params
}).then(updateMessage, utilsService.onHttpError);
}
function updateMessage(response) {
if (typeof response.data.messages !== 'undefined') {
response.data.messages.forEach((messageObj) => {
const key = messageObj.key ? $translate.instant('shop.messages.' + messageObj.key) : '';
let translatedMessage = $translate.instant('shop.messages.' + messageObj.message);
translatedMessage = key !== '' ? key + ': ' + translatedMessage : translatedMessage;
if (messageObj.message !== 'NO_CHANGE') {
utilsService.displayMessage(messageObj.code, translatedMessage);
}
if (messageObj.message === 'PACKAGE_REMOVED_FROM_CART') {
getShopCart();
shopCartService.updateShopCartCount();
}
if (messageObj.message === 'ORDER_PLACED') {
getShopCart();
shopCartService.updateShopCartCount();
$scope.isOrderPlaced = true;
}
if (messageObj.message === 'FILE_UPLOADED') {
getCartDocuments();
}
});
}
}
function hasPrevStep() {
return $scope.prevButton !== '';
}
function showWarning(translateKey) {
const translatedMessage = $translate.instant('shop.messages.' + translateKey);
utilsService.displayMessage('warning', translatedMessage);
}
function goToNextStep(action, promiseFinished) {
if ($scope.step.isActionPromise && !promiseFinished) {
$scope.step.beforeAction();
} else {
const beforeActionSuccesfull = promiseFinished || $scope.step.beforeAction();
if (!$scope.isBtnDisabled && action === 'next' && beforeActionSuccesfull) {
$scope.step.action();
}
if ($scope.step[action] !== '' && (beforeActionSuccesfull || action === 'prev')) {
const newClassForActive = action === 'next' ? 'done-step' : 'inactive-step';
const removeClassForNew = action === 'next' ? 'inactive-step' : 'done-step';
$('.' + $scope.step.current).removeClass('active-step');
$('.' + $scope.step.current).addClass(newClassForActive);
$('.' + $scope.step[action]).removeClass(removeClassForNew);
$('.' + $scope.step[action]).addClass('active-step');
$scope.step = $scope.selectionSteps[$scope.step[action]];
if (action === 'next' && $scope.step.next === '') {
$scope.actionButton = 'SAVE';
isActionBtnDisabled();
} else {
isActionBtnDisabled(false);
$scope.actionButton = 'NEXT';
}
$scope.prevButton = (action === 'prev' && $scope.step.prev === '') ? '' : 'PREV';
}
}
}
function isCartValid() {
let isCartValid = {
qunatity: true,
available: true
};
$scope.cartPackages.forEach((cartPackage) => {
if (!cartPackage.quantity || cartPackage.quantity <= 0 || cartPackage.quantity > 100) {
isCartValid.qunatity = false;
}
if (!isAvailable(cartPackage)) {
isCartValid.available = false;
}
});
if (!isCartValid.qunatity) {
showWarning('INVALID_QUANTITY');
}
if (!isCartValid.available) {
showWarning('PRODUCT_NOT_AVAILABLE');
}
return isCartValid.qunatity && isCartValid.available;
}
function getInfo() {
if (isCartValid) {
Promise.all([getCustomerDetails(), getCountries(), getCartDocuments()]).then(values => {
$scope.$evalAsync(() => {
setCustomerDetails(values[0]);
setCountries(values[1]);
});
});
}
}
function getCustomerDetails() {
return $http({
method: 'POST',
url: 'shop/api/getCustomerDetails'
});
}
function setCustomerDetails(response) {
if (response.data) {
$scope.delivery = response.data.delivery ? response.data.delivery : $scope.delivery;
$scope.billing = response.data.billing ? response.data.billing : $scope.billing;
$scope.vatCode = response.data.vat ? response.data.vat : '';
$scope.countryNames = response.data.countryNames ? response.data.countryNames : $scope.countryNames;
}
}
function getCountries() {
return $http({
method: 'POST',
url: 'shop/api/getCountries'
});
}
function setCountries(response) {
$scope.countries = response.data || [];
}
function setBillingSameAsDeliveryAddress() {
if (Object.keys($scope.delivery).length) {
if ($scope.deliveryEqualsBilling.checked) {
$scope.billing.detailedAddress = $scope.delivery.detailedAddress;
$scope.billing.idCountrySelected = $scope.delivery.idCountrySelected;
changeCountryName('billing', $scope.billing.idCountrySelected);
$scope.billing.city = $scope.delivery.city;
$scope.billing.zipCode = $scope.delivery.zipCode;
} else {
$scope.billing.detailedAddress = '';
$scope.billing.idCountrySelected = 0;
$scope.billing.city = '';
$scope.billing.zipCode = '';
}
}
}
function showHideDialog() {
$scope.$evalAsync(() => {
$scope.isDialogVisible = !$scope.isDialogVisible;
});
}
function placeOrder() {
$scope.isTermsChecked = shopCartService.getTermsCheckboxValue();
if ($scope.isTermsChecked) {
const params = $.param({
cartPackages: JSON.stringify($scope.cartPackages),
deliveryInfo: JSON.stringify($scope.delivery),
billingInfo: JSON.stringify($scope.billing),
details: JSON.stringify($scope.details)
});
$http({
method: 'POST',
url: 'shop/api/placeOrder',
data: params
}).then(updateMessage, utilsService.onHttpError);
} else {
const errorMessage = $translate.instant('shop.messages.NOT_ACCEPTED_TERMS');
utilsService.displayMessage('error', errorMessage);
}
}
function changeCountryName(addrType, idCountry) {
addressType = addrType;
$http({
method: 'POST',
url: 'shop/api/getCountryDetailsById',
data: $.param({
idCountry
})
}).then(setCountryName, utilsService.onHttpError);
}
function setCountryName(response) {
if (response && response.data.length > 0) {
countryNames[addressType] = response.data[0]['countryName'];
}
if ($scope.countryNames) {
$scope.countryNames[addressType] = countryNames[addressType];
} else {
$scope.countryNames = countryNames;
}
}
function isCartEmpty() {
return $scope.cartPackages.length === 0;
}
function getCartDocuments() {
let packagesIds = [];
$scope.cartPackages.forEach((pkg) => {
packagesIds.push(pkg.idPackage);
});
$http({
method: 'POST',
url: 'shop/api/getCartDocuments',
data: $.param({
packages: JSON.stringify(packagesIds)
})
}).then(setDocuments, utilsService.onHttpError);
}
function setDocuments(response) {
if (response.data) {
$scope.documents[$scope.DOCUMENT_TYPES['TEMPLATE_QUESTINNAIRE']] = response.data[$scope.DOCUMENT_TYPES['TEMPLATE_QUESTINNAIRE']] ?
response.data[$scope.DOCUMENT_TYPES['TEMPLATE_QUESTINNAIRE']] : [];
$scope.documents[$scope.DOCUMENT_TYPES['TEMPLATE_AGREEMENT']] = response.data[$scope.DOCUMENT_TYPES['TEMPLATE_AGREEMENT']] ?
response.data[$scope.DOCUMENT_TYPES['TEMPLATE_AGREEMENT']] : [];
}
}
function isOrderDocumentUploaded(documentType) {
let areAllDocumentsUploaded = true;
$scope.documents[documentType].forEach((document) => {
if (!document.isUploaded) {
areAllDocumentsUploaded = false;
}
});
if (!areAllDocumentsUploaded) {
showWarning('NOT_UPLOADED');
}
return areAllDocumentsUploaded;
}
function isQuestionaireUploaded() {
return isOrderDocumentUploaded(1);
}
function isAgreementUploaded() {
return isOrderDocumentUploaded(6);
}
function uploadFile(file, idPackage, documentType) {
const idDocumentType = documentType === 'questionnaire' ? $scope.DOCUMENT_TYPES['QUESTIONNAIRE'] : $scope.DOCUMENT_TYPES['AGREEMENT'];
if (file) {
Upload.upload({
url: 'shop/api/uploadOrderDocument',
method: 'POST',
file: file,
data: {
idDocumentType,
idPackage
}
}).then(updateMessage, utilsService.onHttpError);
} else {
let translatedMessage = $translate.instant('shop.messages.NO_FILE');
utilsService.displayMessage('error', translatedMessage);
}
}
function isAvailable(packageObj) {
return packageObj.status === 'available' &&
parseInt(packageObj.isLinkEnabled) === 1 &&
packageObj.areOptionsAvailable &&
packageObj.areAdditionalAvailable;
}
function getAvailabilityMessage(packageObj) {
if (packageObj.status !== 'available') {
return 'PACKAGE_UNAVIALABLE';
}
if (parseInt(packageObj.isLinkEnabled) !== 1) {
return 'CL_UNAVIALABLE';
}
if (!packageObj.areOptionsAvailable) {
return 'OPTIONS_UNAVAILABLE';
}
if (!packageObj.areAdditionalAvailable) {
return 'ADDITIONAL_PACKAGES_UNAVAILABLE';
}
return '';
}
function setTermsCheckboxValue(termsAndConditionCheckbox) {
shopCartService.setTermsCheckboxValues(termsAndConditionCheckbox);
}
function getAlertClass(termsAndConditionCheckbox) {
return termsAndConditionCheckbox ? 'alert-success' : 'alert-warning';
}
function isActionBtnDisabled(isDisabled = true) {
$scope.isBtnDisabled = $scope.actionButton === 'SAVE' ? isDisabled : false;
}
}
})();

View File

@@ -0,0 +1,74 @@
(function () {
global.dashModule
.service('shopCartService', ['$http', 'utilsService', shopCartService])
.controller('shopCartIconCtrl', ['$scope', 'shopCartService', shopCartIconCtrl]);
function shopCartService($http, utilsService) {
let shopCartItems = 0;
let isTermsAndConditionsChecked = false;
const calbackFunctions = [];
return {
updateShopCartCount,
registerCallbackFunction,
setTermsCheckboxValues,
getTermsCheckboxValue,
sumPrice
};
function updateShopCartCount() {
$http({
method: 'POST',
url: 'shop/api/getShopCartCount'
}).then((response) => {
if (response.data && response.data.newShopCartItemsCount) {
shopCartItems = response.data.newShopCartItemsCount;
} else {
shopCartItems = 0;
}
calbackFunctions.forEach((calbackFunction) => {
calbackFunction(shopCartItems);
});
});
}
function registerCallbackFunction(newFunction) {
calbackFunctions.push(newFunction);
}
function setTermsCheckboxValues(isTermsChecked) {
isTermsAndConditionsChecked = isTermsChecked;
utilsService.executeRegisteredFunction('isActionBtnDisabled', !isTermsChecked);
}
function getTermsCheckboxValue() {
return isTermsAndConditionsChecked;
}
function sumPrice(values, quantity) {
let total = 0;
values.forEach((val) => {
total += parseFloat(val);
});
return quantity ? total * quantity : 0;
}
}
function shopCartIconCtrl($scope, shopCartService) {
$scope.shopCartItemsCount = shopCartService.shopCartItems;
$scope.hasPackagesInCart = hasPackagesInCart;
shopCartService.registerCallbackFunction(updateCartValue);
shopCartService.updateShopCartCount();
function updateCartValue(newCartValue) {
$scope.shopCartItemsCount = newCartValue;
}
function hasPackagesInCart() {
return $scope.shopCartItemsCount > 0;
}
}
})();

View File

@@ -0,0 +1,305 @@
(function () {
global.dashModule
.controller('shopPackageDetailsCtrl', ['$scope', '$http', '$', '$translate', '$sce', 'utilsService', 'shopCartService', shopPackageDetailsController])
.directive('shopPackageDetails', [shopPackageDetailsDirective]);
function shopPackageDetailsDirective() {
return {
restrict: 'E',
templateUrl: 'shop/html/shopPackageDetailsTemplate'
};
}
function shopPackageDetailsController($scope, $http, $, $translate, $sce, utilsService, shopCartService) {
$scope.onPriceSelect = onPriceSelect;
$scope.getShopPackageDetails = getShopPackageDetails;
$scope.addToCart = addToCart;
$scope.sumPrices = sumPrices;
$scope.showInfo = showInfo;
$scope.getPriceClass = getPriceClass;
$scope.getOptionClass = getOptionClass;
$scope.getAdditionalClass = getAdditionalClass;
$scope.selectOption = selectOption;
$scope.getOptionPriceText = getOptionPriceText;
$scope.getFixedPrice = getFixedPrice;
$scope.getRecurrentPrice = getRecurrentPrice;
$scope.selectAdditional = selectAdditional;
$scope.hasOptions = hasOptions;
$scope.renderHtml = renderHtml;
$scope.showOptionInfo = showOptionInfo;
$scope.selectedPackage = {};
$scope.selectedOptions = {
other: {}
};
$scope.idCommercialLead = 0;
function renderHtml(htmlCode) {
return $sce.trustAsHtml(htmlCode);
}
function getShopPackageDetails() {
const idPackage = global.getParameterByName('idPackage') || 0;
const idCommercialLead = global.getParameterByName('idCommercialLead') || 0;
const params = $.param({
idCommercialLead,
idPackage
});
$http({
method: 'POST',
url: 'shop/api/getShopPackageDetails',
data: params
}).then(setShopPackageDetails, utilsService.onHttpError);
}
function setShopPackageDetails(response) {
if (response.data && response.data.prices && response.data.packageInfo && response.data.commercialLead) {
$scope.country = response.data.country;
$scope.selectedPackage = response.data.packageInfo;
$scope.selectedPackage.documents = response.data.documents;
$scope.selectedPackage.prices = response.data.prices || [];
$scope.selectedPackage.commercialLead = response.data.commercialLead || [];
$scope.selectedPackage.groups = response.data.groups || [];
$scope.selectedPackage.additionalPackages = response.data.additionalPackages || [];
if ($scope.selectedPackage.prices[0]) {
$scope.selectedOptions.idPaymentType = $scope.selectedPackage.prices[0].idPaymentType;
$scope.selectedOptions.price = $scope.selectedPackage.prices[0];
}
$.each($scope.selectedPackage.groups, (key, group) => {
const defaultValue = group.options.find((value) => {
return parseInt(value.isDefault) === 1;
});
$scope.selectedOptions.other[group.idGroup] = defaultValue ? defaultValue.idOptionPackage : group.options[0].idOptionPackage;
});
$scope.selectedOptions.additionalPackages = {};
updateAvailability();
}
}
function hasOptions() {
return Object.keys($scope.selectedPackage.groups).length > 0;
}
function getPriceClass(price) {
return price === $scope.selectedOptions.price ? 'selected-price' : '';
}
function getOptionClass(key, value) {
return value === $scope.selectedOptions.other[key] ? 'selected-option' : '';
}
function getAdditionalClass(key) {
return $scope.selectedOptions.additionalPackages[key] ? 'selected-option' : '';
}
function updateAvailability() {
$.each($scope.selectedPackage.groups, (key, group) => {
group.options.forEach((value) => {
value.isAvailable = getSelectedPriceForOption(value) ? true : false;
value.isInfoBoxVisible = false;
});
});
$scope.selectedPackage.additionalPackages.forEach((value) => {
value.isAvailable = getSelectedPriceForOption(value) ? true : false;
value.isInfoBoxVisible = false;
});
}
function onPriceSelect(idPaymentType) {
$scope.selectedOptions.idPaymentType = idPaymentType;
$scope.selectedOptions.price = $scope.selectedPackage.prices.filter(value => {
return value.idPaymentType === idPaymentType;
})[0];
updateAvailability();
}
function showUnavailableMessage(unavailablePackages) {
let translatedMessage = $translate.instant('shop.messages.UNAVAILABLE_PACKAGES');
unavailablePackages.forEach((unavailablePacakgeName) => {
translatedMessage += ' ' + unavailablePacakgeName + ',';
});
translatedMessage = translatedMessage.slice(0, -1);
utilsService.displayMessage('warning', translatedMessage);
}
function addToCart() {
const unavailablePackages = [];
const extraPackages = [];
Object.keys($scope.selectedOptions.additionalPackages).forEach((idAdditionalPackage) => {
if ($scope.selectedOptions.additionalPackages[idAdditionalPackage] === true) {
const extraPackage = $scope.selectedPackage.additionalPackages.find((additionalPackage) => {
return additionalPackage.idAdditionalPackage === idAdditionalPackage;
});
if (!extraPackage.isAvailable) {
unavailablePackages.push(extraPackage.packageName);
}
extraPackages.push(idAdditionalPackage);
}
});
$.each($scope.selectedOptions.other, (key, idOptionValue) => {
let extraPackage;
$.each($scope.selectedPackage.groups, (key, group) => {
if(extraPackage){
return;
}
extraPackage = group.options.find((optionPackage) => {
return optionPackage.idOptionPackage === idOptionValue;
});
});
if (!extraPackage.isAvailable) {
unavailablePackages.push(extraPackage.optionName);
}
extraPackages.push(idOptionValue);
});
if (unavailablePackages.length) {
showUnavailableMessage(unavailablePackages);
} else {
const params = $.param({
idPackage: $scope.selectedPackage.idPackage,
idPrice: $scope.selectedOptions.price.idPrice,
options: JSON.stringify(extraPackages)
});
$http({
method: 'POST',
url: 'shop/api/addToCart',
data: params
}).then(updateMessage, utilsService.onHttpError);
}
}
function updateMessage(response) {
if (typeof response.data.messages !== 'undefined') {
response.data.messages.forEach((messageObj) => {
const translatedMessage = $translate.instant('shop.messages.' + messageObj.message);
utilsService.displayMessage(messageObj.code, translatedMessage);
if (messageObj.message === 'PACKAGE_ADDED') {
shopCartService.updateShopCartCount();
}
});
}
}
function sumPrices(values) {
let total = 0;
values.forEach((val) => {
total += parseFloat(val);
});
return total;
}
function showInfo(price) {
price.isInfoVisible = !price.isInfoVisible;
}
function selectOption(key, value) {
$scope.selectedOptions.other[key] = value;
}
function selectAdditional(key) {
$scope.selectedOptions.additionalPackages[key] = !$scope.selectedOptions.additionalPackages[key];
}
function getSelectedPriceForOption(optionPackage) {
return optionPackage.prices.find((price) => {
return price.idPaymentType === $scope.selectedOptions.idPaymentType;
});
}
function getOptionPriceText(name, optionPackage) {
let optionPriceText = name + ' ';
const selectedPrice = getSelectedPriceForOption(optionPackage);
if (!selectedPrice) {
optionPriceText += '<span class="not-available">(' + $translate.instant('shop.extra.NOT_AVAILABLE') + ')</span>';
return $sce.trustAsHtml(optionPriceText);
}
const fixedPrice = selectedPrice.fixedExtra + ' ' + $scope.country.currency;
const recurentPrice = sumPrices([selectedPrice.recurentExtra, selectedPrice.servicesExtra]) + ' ' + $scope.country.currency;
if (parseFloat(fixedPrice) === 0 && parseFloat(recurentPrice) === 0) {
optionPriceText += '(' + $translate.instant('shop.extra.NO_COST') + ')';
return $sce.trustAsHtml(optionPriceText);
}
optionPriceText += parseFloat(recurentPrice) === 0 ? fixedPrice : fixedPrice + ' + (' + recurentPrice + ' / ' + selectedPrice.periodUnit + ' )';
return $sce.trustAsHtml(optionPriceText);
}
function getFixedPrice() {
let totalPrice = $scope.selectedOptions.price.fixedExtra;
$.each($scope.selectedOptions.other, (idGroup, idOptionPackage) => {
const selectedOption = $scope.selectedPackage.groups[idGroup].options.find((option) => {
return option.idOptionPackage === idOptionPackage;
});
const selectedPrice = selectedOption.prices.find((price) => {
return price.idPaymentType === $scope.selectedOptions.idPaymentType;
});
if (selectedPrice && selectedPrice.fixedExtra) {
totalPrice = sumPrices([totalPrice, selectedPrice.fixedExtra]);
}
});
$.each($scope.selectedOptions.additionalPackages, (idAdditionalPackage, value) => {
if (value === true) {
const selectedAdditional = $scope.selectedPackage.additionalPackages.find((option) => {
return option.idAdditionalPackage === idAdditionalPackage;
});
const selectedPrice = selectedAdditional.prices.find((price) => {
return price.idPaymentType === $scope.selectedOptions.idPaymentType;
});
if (selectedPrice && selectedPrice.fixedExtra) {
totalPrice = sumPrices([totalPrice, selectedPrice.fixedExtra]);
}
}
});
return totalPrice;
}
function getRecurrentPrice() {
let totalPrice = sumPrices([$scope.selectedOptions.price.recurentExtra, $scope.selectedOptions.price.servicesExtra]);
$.each($scope.selectedOptions.other, (idGroup, idOptionPackage) => {
const selectedOption = $scope.selectedPackage.groups[idGroup].options.find((option) => {
return option.idOptionPackage === idOptionPackage;
});
const selectedPrice = selectedOption.prices.find((price) => {
return price.idPaymentType === $scope.selectedOptions.idPaymentType;
});
if (selectedPrice && selectedPrice.recurentExtra && selectedPrice.servicesExtra) {
totalPrice = sumPrices([totalPrice, selectedPrice.recurentExtra, selectedPrice.servicesExtra]);
}
});
$.each($scope.selectedOptions.additionalPackages, (idAdditionalPackage, value) => {
if (value === true) {
const selectedAdditional = $scope.selectedPackage.additionalPackages.find((option) => {
return option.idAdditionalPackage === idAdditionalPackage;
});
const selectedPrice = selectedAdditional.prices.find((price) => {
return price.idPaymentType === $scope.selectedOptions.idPaymentType;
});
if (selectedPrice && selectedPrice.recurentExtra && selectedPrice.servicesExtra) {
totalPrice = sumPrices([totalPrice, selectedPrice.recurentExtra, selectedPrice.servicesExtra]);
}
}
});
return totalPrice;
}
function showOptionInfo(optionPacakge) {
optionPacakge.isInfoBoxVisible = !optionPacakge.isInfoBoxVisible;
}
}
})();

View File

@@ -0,0 +1,38 @@
(function () {
global.dashModule
.controller('shopPackageSearchCtrl', ['$scope', shopPackageSearchCtrl])
.directive('shopPackageSearch', [shopPackageSearchDirective]);
function shopPackageSearchDirective() {
return {
restrict: 'E',
templateUrl: 'shop/html/shopPackageSearchTemplate'
};
}
function shopPackageSearchCtrl($scope) {
$scope.searchString = global.getParameterByName('search') || '';
$scope.searchInPage = searchInPage;
$scope.clearSearch = clearSearch;
$scope.updateUrl = updateUrl;
function updateUrl(){
const url = $scope.searchString ? '?search=' + $scope.searchString : '?';
history.pushState({
search: $scope.searchString
}, null, url);
}
function searchInPage(event){
if((event.type && event.type === 'click') || (event.which && event.which === 13)){
window.location = 'shop?search=' + $scope.searchString;
}
}
function clearSearch(){
$scope.searchInPage = '';
window.location = 'shop';
}
}
})();

View File

@@ -0,0 +1,63 @@
(function () {
global.dashModule
.controller('shopPackagesCtrl', ['$scope', '$http', '$', 'utilsService', shopPackagesController])
.directive('shopPackages', [shopPackagesDirective]);
function shopPackagesDirective() {
return {
restrict: 'E',
templateUrl: 'shop/html/shopPackagesTemplate'
};
}
function shopPackagesController($scope, $http, $, utilsService) {
$scope.getShopPackages = getShopPackages;
$scope.getComemrcialLeads = getComemrcialLeads;
$scope.selectCommercialLead = selectCommercialLead;
$scope.isComemrcialLeadSelected = isComemrcialLeadSelected;
$scope.commercialLeads = [];
$scope.shopPackages = [];
$scope.idCommercialLead = 0;
$scope.commercialLeadName = '';
function getComemrcialLeads(){
$http({
method: 'POST',
url: 'shop/api/getAllCommercialLeads'
}).then(setCommercialLeads, utilsService.onHttpError);
}
function setCommercialLeads(response){
if (response.data.length > 0) {
$scope.commercialLeads = response.data;
selectCommercialLead($scope.commercialLeads[0]);
}
}
function selectCommercialLead(comemrcialLead){
$scope.idCommercialLead = comemrcialLead.idCommercialLead;
$scope.commercialLeadName = comemrcialLead.commercialLeadName;
getShopPackages();
}
function isComemrcialLeadSelected(idCommercialLead){
return $scope.idCommercialLead === idCommercialLead ? 'selected-cl' : '';
}
function getShopPackages() {
const params = $.param({
idCommercialLead: $scope.idCommercialLead,
search: global.getParameterByName('search') || ''
});
$http({
method: 'POST',
url: 'shop/api/getShopPackages',
data: params
}).then(setShopPackages, utilsService.onHttpError);
}
function setShopPackages(response) {
$scope.shopPackages = response.data.length > 0 ? response.data : [];
}
}
})();

View File

@@ -0,0 +1,38 @@
(function () {
global.dashModule
.controller('shopCtrl', ['$scope', shopController])
.directive('shop', [shopDirective]);
function shopDirective() {
return {
restrict: 'E',
templateUrl: 'shop/html/shopTemplate'
};
}
function shopController($scope) {
$scope.isSubmoduleVisible = isSubmoduleVisible;
$scope.setSubModule = setSubModule;
$scope.subModule = global.getParameterByName('subModule') || 'shop';
addUrlListener();
function addUrlListener() {
window.addEventListener('popstate', function (e) {
$scope.$evalAsync($scope => {
$scope.subModule = e.state ? e.state.subModule : 'shop';
});
}, false);
}
function setSubModule($event) {
$scope.subModule = $event.currentTarget.attributes.subModule.value;
history.pushState({
subModule: $scope.subModule
}, null, '?subModule=' + $scope.subModule);
}
function isSubmoduleVisible(subModule) {
return subModule === $scope.subModule;
}
}
})();

View File

@@ -0,0 +1,402 @@
@background-layer: rgba(255, 255, 255, 0.8);
.ui-dialog-titlebar-close{
display: none;
}
#web-shop-layer {
padding-bottom: 2%;
.shop-packages-found {
font-size: 70%;
}
.shop-package-layer {
position: relative;
margin-top: 2%;
background: @background-layer;
padding: 3%;
height: 200px;
}
.shop-package-title {
font-size: 120%;
text-align: center;
font-weight: bold;
}
.shop-package-reference {
margin-bottom: 5%;
text-align: center;
font-weight: bold;
}
.shop-package-details-btn {
position: absolute;
bottom: 5%;
right: 5%;
}
.shop-package-extra {
position: absolute;
bottom: 5%;
left: 5%;
}
.shop-package-label {
display: inline-block;
font-weight: bold;
}
.shop-package-text {
display: inline-block;
}
.commercial-leads-layer {
margin: 1% 0;
}
.comemrcial-lead {
margin-right: 1%;
}
.selected-cl {
color: #FFFF00;
}
}
#shop-package-details-layer {
.shop-package-details-layer {
position: relative;
background: @background-layer;
padding: 1% 3%;
margin-top: 1%;
}
.shop-package-title {
font-size: 160%;
text-align: center;
font-weight: bold;
}
.shop-package-reference {
margin-bottom: 5%;
text-align: center;
font-weight: bold;
}
.shop-package-label {
display: inline-block;
font-weight: bold;
}
.shop-package-text {
display: inline-block;
vertical-align: top;
}
.shop-package-full-description {
margin-top: 3%;
}
.shop-package-details-country {
margin-top: 3%;
}
.selection-price {
font-size: 160%;
color: #E42217;
}
.shop-package-prices, .shop-package-options {
margin-top: 3%;
padding: 1%;
border-bottom: 2px solid #000;
}
.package-option {
margin-top: 2%;
}
.package-option-input, .price-type-option{
cursor: pointer;
}
.package-option-checkbox{
cursor: pointer;
font-size: 120%;
}
.option-value {
padding: 3px;
margin-right: 3%;
}
.option-value-text, .shop-package-pay-type{
cursor: pointer;
}
.option-value:hover, .shop-package-pay-type:hover {
background: rgba(59, 185, 255, 0.5);
border-radius: 5px;
}
.add-to-cart-btn {
margin-top: 5%;
}
.shop-pacakge-option-agreement {
width: 20%;
}
.shop-pacakge-option-price {
margin-left: 5%;
}
.shop-packages-details-cl {
border-top: 2px solid #000;
margin-top: 2%;
padding-top: 2%;
}
.back-btn-layer {
margin-top: 2%;
}
.price-info-btn {
color: #337ab7;
cursor: pointer;
margin-left: 5px;
}
.price-info-title {
font-weight: bold;
}
.selected-price {
font-weight: bold;
}
.selected-option{
font-weight: bold;
}
.shop-package-details-documents{
margin-top: 3%;
}
.options-header {
margin-top: 2%;
}
.not-available{
font-weight: bold;
color: #FFA62F;
}
}
#shop-package-search-btn {
cursor: pointer;
}
#shop-package-serach-input {
background: @background-layer;
border-radius: 5px;
margin: 0;
padding: 0 5px;
border: 1px solid #2e6da4;
}
#shop-package-clear-btn {
color: #E42217;
cursor: pointer;
}
#shop-cart-container {
background: @background-layer;
padding-left: 2%;
.address-type {
font-size: 150%;
margin-bottom: 1%;
}
}
#shop-cart {
.not-available {
display: inline-block;
color: #FFA62F;
}
.shop-cart-item {
padding: 1% 0;
border-bottom: 2px solid #337ab7;
}
.shop-item-name {
font-weight: bold;
}
.shop-item-option {
font-weight: normal;
font-size: 90%;
}
.shop-item-remove {
font-size: 150%;
cursor: pointer;
color: #E42217;
}
.show-customer-addresses {
.label-value-pair {
margin-bottom: 1%;
}
.address-area {
height: 80px;
}
}
.drop-box {
color: #337ab7;
border: 5px dashed #337ab7;
border-radius: 10px;
text-align: center;
vertical-align: middle;
font-size: 200%;
padding: 10% 0;
margin-top: 2%;
}
.dragover {
border: 5px dashed #4CC417;
}
.document-layer {
padding: 1% 0;
border-bottom: 2px solid #337ab7;
}
.upload-status {
font-size: 200%;
padding: 10% 0;
margin-top: 2%;
}
.file-uploaded {
color: #4CC417;
}
.no-file-uploaded {
color: #800080;
}
.shop-terms-conditions {
padding-left: 2%;
font-size: 135%;
font-weight: bold;
width: 98%;
}
.shop-item-options, .shop-item-additional-packages {
margin-top: 1%;
margin-left: 4%;
font-size: 90%;
}
}
#show-order-info-headers {
padding-top: 1%;
padding-bottom: 2%;
.step {
display: inline-block;
padding: 1%;
border-radius: 5px;
cursor: default;
}
.active-step {
background: #2184be;
color: #FFF;
}
.inactive-step {
background: #eee;
color: #aaa;
}
.done-step {
background: #9dc8e2;
color: #FFF;
}
.step-link {
display: inline-block;
background: #2184be;
width: 30px;
height: 2px;
}
}
#order-action-buttons {
padding-top: 2%;
padding-bottom: 3%;
.prev-btn {
float: right;
margin-right: 3%;
}
.next-btn {
float: right;
margin-right: 5%;
}
.save-btn {
float: right;
margin-right: 5%;
}
}
#cart-informations-review {
.package-details {
margin-top: 1%;
}
.package-details-list {
margin-left: 10%;
margin-top: 1%;
}
.label-value-pair {
display: block;
}
.value-pair {
display: inline;
margin-left: 3%;
}
.cart-review-title {
color: #045FB4;
}
.package-name-review {
font-weight: bold;
}
}
.shop-message{
padding-left: 2%;
font-size: 130%;
}
#shop-cart-empty-container {
background: @background-layer;
}
.mail-order-package-detail {
padding-left: 35px;
display: block;
}