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,101 @@
(function () {
global.dashModule
.controller('customersViewCtrl', ['$scope', '$http', '$', '$translate', 'utilsService', customersViewController])
.directive('customersView', [customersViewDirective]);
function customersViewDirective() {
return {
restrict: 'E',
templateUrl: 'customers/html/customersViewTemplate'
};
}
function customersViewController($scope, $http, $, $translate, utilsService) {
$scope.viewCustomersIntit = viewCustomersIntit;
$scope.saveDefaultOrderType = saveDefaultOrderType;
$scope.saveCustomerOrderTypes = saveCustomerOrderTypes;
$scope.isSameCompany = isSameCompany;
const RESELLER_ORDER_TYPE = '2';
function viewCustomersIntit(){
getCustomers();
getOrderTypes();
}
function getCustomers() {
const params = $.param({
idPackage: global.getParameterByName('idPackage') || 0
});
$http({
method: 'POST',
url: 'customers/api/getComercialLeadCustomers',
data: params
}).then(showCustomers, utilsService.onHttpError);
}
function showCustomers(response) {
if (response.data) {
$scope.customers = response.data.customers;
$scope.defaultIdOrderType = response.data.defaultIdOrderType;
$scope.customers.forEach(customer => {
if(isSameCompany(customer.isSameCompanyAsCl)){
customer.idOrderType = RESELLER_ORDER_TYPE;
}
});
}
}
function getOrderTypes() {
$http({
method: 'GET',
url: 'customers/api/getOrderTypes'
}).then(setOrderTypes, utilsService.onHttpError);
}
function setOrderTypes(response) {
if(response.data) {
$scope.orderTypes = response.data;
}
}
function saveDefaultOrderType(){
const params = $.param({
defaultIdOrderType: $scope.defaultIdOrderType
});
$http({
method: 'POST',
url: 'customers/api/saveDefaultOrderType',
data: params
}).then(showUpdateDefaultMessage, utilsService.onHttpError);
}
function saveCustomerOrderTypes(){
const params = $.param({
customers: JSON.stringify($scope.customers)
});
$http({
method: 'POST',
url: 'customers/api/saveCustomersOrderTypes',
data: params
}).then(showUpdateDefaultMessage, utilsService.onHttpError);
}
function showUpdateDefaultMessage(response) {
if (typeof response.data.messages !== 'undefined') {
response.data.messages.forEach((messageObj) => {
let translatedMessage = $translate.instant('customers.messages.' + messageObj.message);
utilsService.displayMessage(messageObj.code, translatedMessage);
});
}
}
function isSameCompany(isSameCompanyAsCl){
return parseInt(isSameCompanyAsCl) === 1;
}
}
})();

View File

@@ -0,0 +1,38 @@
(function () {
global.dashModule
.controller('customersCtrl', ['$scope', customersController])
.directive('customers', [customersDirective]);
function customersDirective() {
return {
restrict: 'E',
templateUrl: 'customers/html/customersTemplate'
};
}
function customersController($scope) {
$scope.isSubmoduleVisible = isSubmoduleVisible;
$scope.setSubModule = setSubModule;
$scope.subModule = global.getParameterByName('subModule') || 'customersView';
addUrlListener();
function addUrlListener() {
window.addEventListener('popstate', function (e) {
$scope.$evalAsync($scope => {
$scope.subModule = e.state ? e.state.subModule : 'customersView';
});
}, 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,25 @@
@background-layer: rgba(255, 255, 255, 0.8);
.module-layer {
background: @background-layer;
margin-top: 1%;
margin-bottom: 2%;
}
#customers-view-layer {
.module-layer;
.title-header {
font-weight: bold;
font-size: 2rem;
padding: 1rem 0;
}
.customer-row {
padding: 1rem 0;
}
.custom-border {
border-bottom: 2px solid #337ab7;
}
}