Notice: Undefined index: csrf_token in /var/www/html/yc_dashboard/newdashboard/app/index.php on line 3
(function(){
$('select').selectpicker();
});
function generateColors() {
var colors = [];
var arrayColors = [
"67, 89, 250",
"82, 163, 94",
"204, 0, 51",
"230, 145, 0",
"145, 181, 138",
"46, 87, 138"
];
for (var i = 0, countColors = arrayColors.length; i < countColors; i++) {
var rgb = arrayColors[i];
colors.push({
'fillColor': "rgba("+rgb+",0.5)",
'strokeColor': "rgba(" + rgb + ",0.5)",
'pointColor': "rgba(" + rgb + ",0.5)",
'pointHighlightStroke': "rgba(" + rgb + ",0.8)",
'pointStrokeColor': "#fff",
'pointHighlightFill': "#fff"
});
}
return colors;
}
$(document).ready(function(){
$('[data-toggle="tooltip"]').tooltip();
});
document.documentElement.addEventListener('touchstart', function (event) {
if (event.touches.length > 1) {
event.preventDefault();
}
}, false);
angular.module('yodash', ['ngRoute', 'chart.js', 'LocalStorageModule', 'ui.bootstrap', 'colorpicker.module', 'ngDraggable', 'ngjsColorPicker', 'angularjs-datetime-picker',
'ngSanitize', 'ui.select', 'ngFileUpload', 'mwl.calendar', 'textAngular','toaster', 'agGrid'])
.config(function($routeProvider, ChartJsProvider) {
$routeProvider
.when('/', {
templateUrl : 'views/view.overview.php?session=
Notice: Undefined index: csrf_token in /var/www/html/yc_dashboard/newdashboard/app/app.config.php on line 5
',
controller : 'overviewController'
})
.when('/login', {
templateUrl : 'views/view.login.php?session=
Notice: Undefined index: csrf_token in /var/www/html/yc_dashboard/newdashboard/app/app.config.php on line 9
',
controller : 'loginController'
})
.when('/passwordrecovery', {
templateUrl : 'views/view.passwordrecovery.php?session=
Notice: Undefined index: csrf_token in /var/www/html/yc_dashboard/newdashboard/app/app.config.php on line 13
',
controller : 'passwordrecoveryController'
})
.when('/vendors', {
templateUrl : 'views/view.vendors.php?session=
Notice: Undefined index: csrf_token in /var/www/html/yc_dashboard/newdashboard/app/app.config.php on line 17
',
controller : 'vendorsController'
})
.when('/vendorview', {
templateUrl : 'views/view.vendorview.php?session=
Notice: Undefined index: csrf_token in /var/www/html/yc_dashboard/newdashboard/app/app.config.php on line 21
',
controller : 'vendorviewController'
})
.when('/helpdesk', {
templateUrl : 'views/view.helpdesk.php?session=
Notice: Undefined index: csrf_token in /var/www/html/yc_dashboard/newdashboard/app/app.config.php on line 25
',
controller : 'helpdeskController'
})
.when('/chips', {
templateUrl : 'views/view.chips.php?session=
Notice: Undefined index: csrf_token in /var/www/html/yc_dashboard/newdashboard/app/app.config.php on line 29
',
controller : 'chipsController'
})
.when('/devices', {
templateUrl : 'views/view.devices.php?session=
Notice: Undefined index: csrf_token in /var/www/html/yc_dashboard/newdashboard/app/app.config.php on line 33
',
controller : 'devicesController'
})
.when('/system', {
templateUrl : 'views/view.system.php?session=
Notice: Undefined index: csrf_token in /var/www/html/yc_dashboard/newdashboard/app/app.config.php on line 37
',
controller : 'systemController'
})
.when('/reports', {
templateUrl : 'views/view.reports.php?session=
Notice: Undefined index: csrf_token in /var/www/html/yc_dashboard/newdashboard/app/app.config.php on line 41
',
controller : 'reportsController'
})
.when('/postevent', {
templateUrl : 'views/view.postevent.php?session=
Notice: Undefined index: csrf_token in /var/www/html/yc_dashboard/newdashboard/app/app.config.php on line 45
',
controller : 'posteventController'
})
.when('/credentials', {
templateUrl : 'views/view.vendors.credentials.php?session=
Notice: Undefined index: csrf_token in /var/www/html/yc_dashboard/newdashboard/app/app.config.php on line 49
',
controller : 'vendorsCredentialsController'
})
.when('/selftopup', {
templateUrl : 'views/view.selftopup.php?session=
Notice: Undefined index: csrf_token in /var/www/html/yc_dashboard/newdashboard/app/app.config.php on line 53
',
controller : 'selftopupController'
})
.when('/anomalies', {
templateUrl : 'views/view.anomalies.php?session=
Notice: Undefined index: csrf_token in /var/www/html/yc_dashboard/newdashboard/app/app.config.php on line 57
',
controller : 'anomaliesController'
})
.when('/mapping', {
templateUrl : 'views/view.tlmapping.php?session=
Notice: Undefined index: csrf_token in /var/www/html/yc_dashboard/newdashboard/app/app.config.php on line 61
',
controller : 'tlmappingController'
})
.when('/users', {
templateUrl : 'views/view.users.php?session=
Notice: Undefined index: csrf_token in /var/www/html/yc_dashboard/newdashboard/app/app.config.php on line 65
',
controller : 'usersController'
})
.when('/eventdetails', {
templateUrl : 'views/view.eventdetails.php?session=
Notice: Undefined index: csrf_token in /var/www/html/yc_dashboard/newdashboard/app/app.config.php on line 69
',
controller : 'eventdetailsController'
})
.when('/articles', {
templateUrl : 'views/view.articles.php?session=
Notice: Undefined index: csrf_token in /var/www/html/yc_dashboard/newdashboard/app/app.config.php on line 73
',
controller : 'articlesController'
})
.when('/eventdevices', {
templateUrl : 'views/view.eventdevices.php?session=
Notice: Undefined index: csrf_token in /var/www/html/yc_dashboard/newdashboard/app/app.config.php on line 77
',
controller : 'assigneddevicesController'
})
.when('/stock', {
templateUrl : 'views/view.stock.php?session=
Notice: Undefined index: csrf_token in /var/www/html/yc_dashboard/newdashboard/app/app.config.php on line 81
',
controller : 'stockController'
})
.when('/promoterdevices', {
templateUrl : 'views/view.promoterdevices.php?session=
Notice: Undefined index: csrf_token in /var/www/html/yc_dashboard/newdashboard/app/app.config.php on line 85
',
controller : 'promoterdevicesController'
})
.when('/vendordevices', {
templateUrl : 'views/view.deviced.php?session=
Notice: Undefined index: csrf_token in /var/www/html/yc_dashboard/newdashboard/app/app.config.php on line 89
',
controller : 'vendordevicesController'
})
.when('/devicetransactions', {
templateUrl : 'views/view.devicetransactions.php?session=
Notice: Undefined index: csrf_token in /var/www/html/yc_dashboard/newdashboard/app/app.config.php on line 93
',
controller : 'devicetransactionsController'
})
.when('/areas', {
templateUrl : 'views/view.areas.php?session=
Notice: Undefined index: csrf_token in /var/www/html/yc_dashboard/newdashboard/app/app.config.php on line 97
',
controller : 'areasController'
})
.when('/tickettypes', {
templateUrl : 'views/view.tickettypes.php?session=
Notice: Undefined index: csrf_token in /var/www/html/yc_dashboard/newdashboard/app/app.config.php on line 101
',
controller : 'tickettypesController'
})
.when('/crowd', {
templateUrl : 'views/crowd_managment/index.php?session=
Notice: Undefined index: csrf_token in /var/www/html/yc_dashboard/newdashboard/app/app.config.php on line 105
',
controller : 'crowdController'
})
.when('/usertopup', {
templateUrl : 'views/view.usertopup.php?session=
Notice: Undefined index: csrf_token in /var/www/html/yc_dashboard/newdashboard/app/app.config.php on line 109
',
controller : 'usertopupController'
})
.when('/eventconfig', {
templateUrl : 'views/view.eventconfig.php?session=
Notice: Undefined index: csrf_token in /var/www/html/yc_dashboard/newdashboard/app/app.config.php on line 113
',
controller : 'eventconfigController'
})
.when('/accesscontrol', {
templateUrl : 'views/view.accesscontrol.php?session=
Notice: Undefined index: csrf_token in /var/www/html/yc_dashboard/newdashboard/app/app.config.php on line 117
',
controller : 'accesscontrolController'
})
.when('/catering', {
templateUrl : 'views/view.catering.php?session=
Notice: Undefined index: csrf_token in /var/www/html/yc_dashboard/newdashboard/app/app.config.php on line 121
',
controller : 'cateringController'
})
.when('/ycontrol', {
templateUrl : 'views/view.ycontrol.php?session=
Notice: Undefined index: csrf_token in /var/www/html/yc_dashboard/newdashboard/app/app.config.php on line 125
',
controller : 'ycontrolController'
})
.when('/youcontrolreport', {
templateUrl : 'views/view.youControlReport.php?session=
Notice: Undefined index: csrf_token in /var/www/html/yc_dashboard/newdashboard/app/app.config.php on line 129
',
controller : 'youControlReportController'
})
.when('pendingamounts', {
templateUrl : 'views/view.pendingamounts.php?session=
Notice: Undefined index: csrf_token in /var/www/html/yc_dashboard/newdashboard/app/app.config.php on line 133
',
controller : 'pendingamountsController'
})
.when('/guestclient', {
templateUrl : 'views/view.guestClient.php?session=
Notice: Undefined index: csrf_token in /var/www/html/yc_dashboard/newdashboard/app/app.config.php on line 137
',
controller : 'guestClientController'
})
.when('/upeople', {
templateUrl : 'views/view.upeople.php?session=
Notice: Undefined index: csrf_token in /var/www/html/yc_dashboard/newdashboard/app/app.config.php on line 141
',
controller : 'uPeopleController'
})
.when('/dreport', {
templateUrl : 'views/view.dynamic_report.php?session=
Notice: Undefined index: csrf_token in /var/www/html/yc_dashboard/newdashboard/app/app.config.php on line 145
',
controller : 'dynamicReportCtrl'
})
.otherwise({
redirectTo: '/login'
});
ChartJsProvider.setOptions('Pie', {
colours: generateColors(),
});
ChartJsProvider.setOptions('Line', {
colours: generateColors(),
});
ChartJsProvider.setOptions('Bar', {
colours: generateColors(),
});
Chart.defaults.global.multiTooltipTemplate = function (label) {
return label.datasetLabel + ': ' + label.value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
};
})
.factory("Data", ['$http', '$rootScope',
function ($http, $rootScope) {
var serviceBase = 'api/';
$rootScope.loading = true;
var obj = {};
$http.defaults.headers.common['csrf_token'] = '
Notice: Undefined index: csrf_token in /var/www/html/yc_dashboard/newdashboard/app/app.factory.php on line 7
';
obj.get = function (q) {
//console.log("Pending requests: " + $http.pendingRequests.length);
$rootScope.loading = true;
return $http.get(serviceBase + q).then(function (results) {
$rootScope.loading = false;
return results.data;
});
};
obj.post = function (q, object) {
$rootScope.loading = true;
//console.log("Pending requests: " + $http.pendingRequests.length);
return $http.post(serviceBase + q, object).then(function (results) {
$rootScope.loading = false;
return results.data;
}, function errorCallback(response) {
$rootScope.loading = false;
});
};
$rootScope.loading = false;
return obj;
}])
.factory('_', ['$window', function($window) {
return $window._; // assumes underscore has already been loaded on the page
}])
.factory('Helper', function () {
'use strict';
return {
closestSlider: function (elem) {
var matchesSelector = elem.matches || elem.webkitMatchesSelector || elem.mozMatchesSelector || elem.msMatchesSelector;
if (matchesSelector.bind(elem)('I')) {
return elem.parentNode;
}
return elem;
},
getOffset: function (elem, fixedPosition) {
var
scrollX = 0,
scrollY = 0,
rect = elem.getBoundingClientRect();
while (elem && !isNaN(elem.offsetLeft) && !isNaN(elem.offsetTop)) {
if (!fixedPosition && elem.tagName === 'BODY') {
scrollX += document.documentElement.scrollLeft || elem.scrollLeft;
scrollY += document.documentElement.scrollTop || elem.scrollTop;
} else {
scrollX += elem.scrollLeft;
scrollY += elem.scrollTop;
}
elem = elem.offsetParent;
}
return {
top: rect.top + window.pageYOffset,
left: rect.left + window.pageXOffset,
scrollX: scrollX,
scrollY: scrollY
};
},
// a set of RE's that can match strings and generate color tuples. https://github.com/jquery/jquery-color/
stringParsers: [
{
re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
parse: function (execResult) {
return [
execResult[1],
execResult[2],
execResult[3],
execResult[4]
];
}
},
{
re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
parse: function (execResult) {
return [
2.55 * execResult[1],
2.55 * execResult[2],
2.55 * execResult[3],
execResult[4]
];
}
},
{
re: /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/,
parse: function (execResult) {
return [
parseInt(execResult[1], 16),
parseInt(execResult[2], 16),
parseInt(execResult[3], 16)
];
}
},
{
re: /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/,
parse: function (execResult) {
return [
parseInt(execResult[1] + execResult[1], 16),
parseInt(execResult[2] + execResult[2], 16),
parseInt(execResult[3] + execResult[3], 16)
];
}
}
]
};
})
.factory('Color', ['Helper', function (Helper) {
'use strict';
return {
value: {
h: 1,
s: 1,
b: 1,
a: 1
},
// translate a format from Color object to a string
'rgb': function () {
var rgb = this.toRGB();
return 'rgb(' + rgb.r + ',' + rgb.g + ',' + rgb.b + ')';
},
'rgba': function () {
var rgb = this.toRGB();
return 'rgba(' + rgb.r + ',' + rgb.g + ',' + rgb.b + ',' + rgb.a + ')';
},
'hex': function () {
return this.toHex();
},
// HSBtoRGB from RaphaelJS
RGBtoHSB: function (r, g, b, a) {
r /= 255;
g /= 255;
b /= 255;
var H, S, V, C;
V = Math.max(r, g, b);
C = V - Math.min(r, g, b);
H = (C === 0 ? null :
V === r ? (g - b) / C :
V === g ? (b - r) / C + 2 :
(r - g) / C + 4
);
H = ((H + 360) % 6) * 60 / 360;
S = C === 0 ? 0 : C / V;
return {h: H || 1, s: S, b: V, a: a || 1};
},
//parse a string to HSB
setColor: function (val) {
val = (val) ? val.toLowerCase() : val;
for (var key in Helper.stringParsers) {
if (Helper.stringParsers.hasOwnProperty(key)) {
var parser = Helper.stringParsers[key];
var match = parser.re.exec(val),
values = match && parser.parse(match);
if (values) {
this.value = this.RGBtoHSB.apply(null, values);
return false;
}
}
}
},
setHue: function (h) {
this.value.h = 1 - h;
},
setSaturation: function (s) {
this.value.s = s;
},
setLightness: function (b) {
this.value.b = 1 - b;
},
setAlpha: function (a) {
this.value.a = parseInt((1 - a) * 100, 10) / 100;
},
// HSBtoRGB from RaphaelJS
// https://github.com/DmitryBaranovskiy/raphael/
toRGB: function (h, s, b, a) {
if (!h) {
h = this.value.h;
s = this.value.s;
b = this.value.b;
}
h *= 360;
var R, G, B, X, C;
h = (h % 360) / 60;
C = b * s;
X = C * (1 - Math.abs(h % 2 - 1));
R = G = B = b - C;
h = ~~h;
R += [C, X, 0, 0, X, C][h];
G += [X, C, C, X, 0, 0][h];
B += [0, 0, X, C, C, X][h];
return {
r: Math.round(R * 255),
g: Math.round(G * 255),
b: Math.round(B * 255),
a: a || this.value.a
};
},
toHex: function (h, s, b, a) {
var rgb = this.toRGB(h, s, b, a);
return '#' + ((1 << 24) | (parseInt(rgb.r, 10) << 16) | (parseInt(rgb.g, 10) << 8) | parseInt(rgb.b, 10)).toString(16).substr(1);
}
};
}])
.factory('Slider', ['Helper', function (Helper) {
'use strict';
var
slider = {
maxLeft: 0,
maxTop: 0,
callLeft: null,
callTop: null,
knob: {
top: 0,
left: 0
}
},
pointer = {};
return {
getSlider: function() {
return slider;
},
getLeftPosition: function(event) {
return Math.max(0, Math.min(slider.maxLeft, slider.left + ((event.pageX || pointer.left) - pointer.left)));
},
getTopPosition: function(event) {
return Math.max(0, Math.min(slider.maxTop, slider.top + ((event.pageY || pointer.top) - pointer.top)));
},
setSlider: function (event, fixedPosition) {
var
target = Helper.closestSlider(event.target),
targetOffset = Helper.getOffset(target, fixedPosition),
rect = target.getBoundingClientRect(),
offsetX = event.clientX - rect.left,
offsetY = event.clientY - rect.top;
slider.knob = target.children[0].style;
slider.left = event.pageX - targetOffset.left - window.pageXOffset + targetOffset.scrollX;
slider.top = event.pageY - targetOffset.top - window.pageYOffset + targetOffset.scrollY;
pointer = {
left: event.pageX - (offsetX - slider.left),
top: event.pageY - (offsetY - slider.top)
};
},
setSaturation: function(event, fixedPosition, componentSize) {
slider = {
maxLeft: componentSize,
maxTop: componentSize,
callLeft: 'setSaturation',
callTop: 'setLightness'
};
this.setSlider(event, fixedPosition);
},
setHue: function(event, fixedPosition, componentSize) {
slider = {
maxLeft: 0,
maxTop: componentSize,
callLeft: false,
callTop: 'setHue'
};
this.setSlider(event, fixedPosition);
},
setAlpha: function(event, fixedPosition, componentSize) {
slider = {
maxLeft: 0,
maxTop: componentSize,
callLeft: false,
callTop: 'setAlpha'
};
this.setSlider(event, fixedPosition);
},
setKnob: function(top, left) {
slider.knob.top = top + 'px';
slider.knob.left = left + 'px';
}
};
}])
.directive('colorpicker', ['$document', '$compile', 'Color', 'Slider', 'Helper', function ($document, $compile, Color, Slider, Helper) {
'use strict';
return {
require: '?ngModel',
restrict: 'A',
link: function ($scope, elem, attrs, ngModel) {
var
thisFormat = attrs.colorpicker ? attrs.colorpicker : 'hex',
position = angular.isDefined(attrs.colorpickerPosition) ? attrs.colorpickerPosition : 'bottom',
inline = angular.isDefined(attrs.colorpickerInline) ? attrs.colorpickerInline : false,
fixedPosition = angular.isDefined(attrs.colorpickerFixedPosition) ? attrs.colorpickerFixedPosition : false,
target = angular.isDefined(attrs.colorpickerParent) ? elem.parent() : angular.element(document.body),
withInput = angular.isDefined(attrs.colorpickerWithInput) ? attrs.colorpickerWithInput : false,
componentSize = angular.isDefined(attrs.colorpickerSize) ? attrs.colorpickerSize : 100,
componentSizePx = componentSize + 'px',
inputTemplate = withInput ? '' : '',
closeButton = !inline ? '' : '',
template =
'' +
'' +
'
',
colorpickerTemplate = angular.element(template),
pickerColor = Color,
componentSizePx,
sliderAlpha,
sliderHue = colorpickerTemplate.find('colorpicker-hue'),
sliderSaturation = colorpickerTemplate.find('colorpicker-saturation'),
colorpickerPreview = colorpickerTemplate.find('colorpicker-preview'),
pickerColorPointers = colorpickerTemplate.find('i');
$compile(colorpickerTemplate)($scope);
colorpickerTemplate.css('min-width', parseInt(componentSize) + 29 + 'px');
sliderSaturation.css({
'width' : componentSizePx,
'height' : componentSizePx
});
sliderHue.css('height', componentSizePx);
if (withInput) {
var pickerColorInput = colorpickerTemplate.find('input');
pickerColorInput.css('width', componentSizePx);
pickerColorInput
.on('mousedown', function(event) {
event.stopPropagation();
})
.on('keyup', function() {
var newColor = this.value;
elem.val(newColor);
if (ngModel && ngModel.$modelValue !== newColor) {
$scope.$apply(ngModel.$setViewValue(newColor));
update(true);
}
});
}
function bindMouseEvents() {
$document.on('mousemove', mousemove);
$document.on('mouseup', mouseup);
}
if (thisFormat === 'rgba') {
colorpickerTemplate.addClass('alpha');
sliderAlpha = colorpickerTemplate.find('colorpicker-alpha');
sliderAlpha.css('height', componentSizePx);
sliderAlpha
.on('click', function(event) {
Slider.setAlpha(event, fixedPosition, componentSize);
mousemove(event);
})
.on('mousedown', function(event) {
Slider.setAlpha(event, fixedPosition, componentSize);
bindMouseEvents();
})
.on('mouseup', function(event){
emitEvent('colorpicker-selected-alpha');
});
}
sliderHue
.on('click', function(event) {
Slider.setHue(event, fixedPosition, componentSize);
mousemove(event);
})
.on('mousedown', function(event) {
Slider.setHue(event, fixedPosition, componentSize);
bindMouseEvents();
})
.on('mouseup', function(event){
emitEvent('colorpicker-selected-hue');
});
sliderSaturation
.on('click', function(event) {
Slider.setSaturation(event, fixedPosition, componentSize);
mousemove(event);
if (angular.isDefined(attrs.colorpickerCloseOnSelect)) {
hideColorpickerTemplate();
}
})
.on('mousedown', function(event) {
Slider.setSaturation(event, fixedPosition, componentSize);
bindMouseEvents();
})
.on('mouseup', function(event){
emitEvent('colorpicker-selected-saturation');
});
if (fixedPosition) {
colorpickerTemplate.addClass('colorpicker-fixed-position');
}
colorpickerTemplate.addClass('colorpicker-position-' + position);
if (inline === 'true') {
colorpickerTemplate.addClass('colorpicker-inline');
}
target.append(colorpickerTemplate);
if (ngModel) {
ngModel.$render = function () {
elem.val(ngModel.$viewValue);
update();
};
}
elem.on('blur keyup change', function() {
update();
});
elem.on('$destroy', function() {
colorpickerTemplate.remove();
});
function previewColor() {
try {
colorpickerPreview.css('backgroundColor', pickerColor[thisFormat]());
} catch (e) {
colorpickerPreview.css('backgroundColor', pickerColor.toHex());
}
sliderSaturation.css('backgroundColor', pickerColor.toHex(pickerColor.value.h, 1, 1, 1));
if (thisFormat === 'rgba') {
sliderAlpha.css.backgroundColor = pickerColor.toHex();
}
}
function mousemove(event) {
var
left = Slider.getLeftPosition(event),
top = Slider.getTopPosition(event),
slider = Slider.getSlider();
Slider.setKnob(top, left);
if (slider.callLeft) {
pickerColor[slider.callLeft].call(pickerColor, left / componentSize);
}
if (slider.callTop) {
pickerColor[slider.callTop].call(pickerColor, top / componentSize);
}
previewColor();
var newColor = pickerColor[thisFormat]();
elem.val(newColor);
if (ngModel) {
$scope.$apply(ngModel.$setViewValue(newColor));
}
if (withInput) {
pickerColorInput.val(newColor);
}
return false;
}
function mouseup() {
emitEvent('colorpicker-selected');
$document.off('mousemove', mousemove);
$document.off('mouseup', mouseup);
}
function update(omitInnerInput) {
pickerColor.setColor(elem.val());
if (withInput && !omitInnerInput) {
pickerColorInput.val(elem.val());
}
pickerColorPointers.eq(0).css({
left: pickerColor.value.s * componentSize + 'px',
top: componentSize - pickerColor.value.b * componentSize + 'px'
});
pickerColorPointers.eq(1).css('top', componentSize * (1 - pickerColor.value.h) + 'px');
pickerColorPointers.eq(2).css('top', componentSize * (1 - pickerColor.value.a) + 'px');
previewColor();
}
function getColorpickerTemplatePosition() {
var
positionValue,
positionOffset = Helper.getOffset(elem[0]);
if(angular.isDefined(attrs.colorpickerParent)) {
positionOffset.left = 0;
positionOffset.top = 0;
}
if (position === 'top') {
positionValue = {
'top': positionOffset.top - 147,
'left': positionOffset.left
};
} else if (position === 'right') {
positionValue = {
'top': positionOffset.top,
'left': positionOffset.left + 126
};
} else if (position === 'bottom') {
positionValue = {
'top': positionOffset.top + elem[0].offsetHeight + 2,
'left': positionOffset.left
};
} else if (position === 'left') {
positionValue = {
'top': positionOffset.top,
'left': positionOffset.left - 150
};
}
return {
'top': positionValue.top + 'px',
'left': positionValue.left + 'px'
};
}
function documentMousedownHandler() {
hideColorpickerTemplate();
}
function showColorpickerTemplate() {
if (!colorpickerTemplate.hasClass('colorpicker-visible')) {
update();
colorpickerTemplate
.addClass('colorpicker-visible')
.css(getColorpickerTemplatePosition());
emitEvent('colorpicker-shown');
if (inline === false) {
// register global mousedown event to hide the colorpicker
$document.on('mousedown', documentMousedownHandler);
}
if (attrs.colorpickerIsOpen) {
$scope[attrs.colorpickerIsOpen] = true;
if (!$scope.$$phase) {
$scope.$digest(); //trigger the watcher to fire
}
}
}
}
if (inline === false) {
elem.on('click', showColorpickerTemplate);
} else {
showColorpickerTemplate();
}
colorpickerTemplate.on('mousedown', function (event) {
event.stopPropagation();
event.preventDefault();
});
function emitEvent(name) {
if (ngModel) {
$scope.$emit(name, {
name: attrs.ngModel,
value: ngModel.$modelValue
});
}
}
function hideColorpickerTemplate() {
if (colorpickerTemplate.hasClass('colorpicker-visible')) {
colorpickerTemplate.removeClass('colorpicker-visible');
emitEvent('colorpicker-closed');
// unregister the global mousedown event
$document.off('mousedown', documentMousedownHandler);
if (attrs.colorpickerIsOpen) {
$scope[attrs.colorpickerIsOpen] = false;
if (!$scope.$$phase) {
$scope.$digest(); //trigger the watcher to fire
}
}
}
}
colorpickerTemplate.find('button').on('click', function () {
hideColorpickerTemplate();
});
if (attrs.colorpickerIsOpen) {
$scope.$watch(attrs.colorpickerIsOpen, function(shouldBeOpen) {
if (shouldBeOpen === true) {
showColorpickerTemplate();
} else if (shouldBeOpen === false) {
hideColorpickerTemplate();
}
});
}
}
};
}])
.directive('ngRightClick', function($parse) {
return function(scope, element, attrs) {
var fn = $parse(attrs.ngRightClick);
element.bind('contextmenu', function(event) {
scope.$apply(function() {
event.preventDefault();
fn(scope, {$event:event});
});
});
};
})
.directive('ngEnter', function () {
return function (scope, element, attrs) {
element.bind("keydown keypress", function (event) {
if(event.which === 13) {
scope.$apply(function (){
scope.$eval(attrs.ngEnter);
});
event.preventDefault();
}
});
};
})
.filter('groupBy', ['$parse', function ($parse) {
return function (list, group_by) {
var filtered = [];
var prev_item = null;
var group_changed = false;
// this is a new field which is added to each item where we append "_CHANGED"
// to indicate a field change in the list
//was var new_field = group_by + '_CHANGED'; - JB 12/17/2013
var new_field = 'group_by_CHANGED';
// loop through each item in the list
angular.forEach(list, function (item) {
group_changed = false;
// if not the first item
if (prev_item !== null) {
// check if any of the group by field changed
//force group_by into Array
group_by = angular.isArray(group_by) ? group_by : [group_by];
//check each group by parameter
for (var i = 0, len = group_by.length; i < len; i++) {
if ($parse(group_by[i])(prev_item) !== $parse(group_by[i])(item)) {
group_changed = true;
}
}
}// otherwise we have the first item in the list which is new
else {
group_changed = true;
}
// if the group changed, then add a new field to the item
// to indicate this
if (group_changed) {
item[new_field] = true;
} else {
item[new_field] = false;
}
filtered.push(item);
prev_item = item;
});
return filtered;
};
}])
.filter('capitalize', function() {
return function(input, all) {
return (!!input) ? input.replace(/([^\W_]+[^\s-]*) */g, function(txt) {
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
}) : '';
}
})
.filter('propsFilter', function() {
return function(items, props) {
var out = [];
if (angular.isArray(items)) {
var keys = Object.keys(props);
items.forEach(function(item) {
var itemMatches = false;
for (var i = 0; i < keys.length; i++) {
var prop = keys[i];
var text = props[prop].toLowerCase();
if (item[prop].toString().toLowerCase().indexOf(text) !== -1) {
itemMatches = true;
break;
}
}
if (itemMatches) {
out.push(item);
}
});
} else {
// Let the output be the input untouched
out = items;
}
return out;
};
})
.run(function($rootScope, $location, Data, localStorageService, _, $sce, $interval, $routeParams) {
$rootScope.dates = {dt1: '', dt2: ''};
$rootScope.showPopover = false;
$rootScope.location = $location;
$rootScope.loading = false;
$rootScope.cevent = localStorageService.get("cevent");
$rootScope.data = {evv: "", genericModal: {}, maplocaltype: 1};
$rootScope.autorefresh = false;
$rootScope.Req = Data;
$rootScope.DisplayRows = 5;
$rootScope.autoexpand = 0;
$rootScope.relateddates = "";
$rootScope.grouping = "";
$rootScope.expanded = [];
$rootScope.exp = [];
$rootScope.expandfilter = false;
$rootScope.data.userreports = [];
$rootScope.data.orilayers = [];
$rootScope.data.gjdevices = [];
$rootScope.customOptions = {
size: 20,
total: -2
};
$rootScope.showGjendjeStand = 0;
$rootScope.data.SLayer = {};
$rootScope.toggleExpandFilter = function(){
$rootScope.expandfilter = !$rootScope.expandfilter
}
$rootScope.resetFilterDates = function(){
$rootScope.dates = {dt1: '', dt2: ''};
$rootScope.getReportsreset($rootScope.data.evv);
}
$rootScope.data.TxTypes = [
{
id: 10,
name: 'Top Up'
},{
id: 20,
name: 'Pay'
}, {
id: 30,
name: 'Refund'
},
{
id: 40,
name: 'Cashout'
}];
$rootScope.gotoChip = function(c){
$rootScope.data.chipsearch = c;
$rootScope.location.path("/chips");
}
$rootScope.routechange = 0;
$rootScope.smVals = function(a, b){
return parseFloat(a)+parseFloat(b);
}
$rootScope.setDates = function(){
$rootScope.relateddates = "";
if($rootScope.dates.dt1 != "" && $rootScope.dates.dt2 != "")
$rootScope.relateddates = "&dt1="+$rootScope.dates.dt1+"&dt2="+$rootScope.dates.dt2;
}
$rootScope.setfDates = function(a){
$rootScope.dates = a;
}
$rootScope.getFilterReports = function(){
Data.get('filterreport?evv='+$rootScope.data.evv).then(function(results) {
$rootScope.data.userreports = results;
});
}
$rootScope.userIsAllowed = function(v){
var ret = $location.path().replace("/", "")+"_"+v;
if(!angular.isUndefined($rootScope.U))
return $rootScope.U.permissions[ret] == 1;
return false;
};
$rootScope.savefilter = function(){
/*console.log($rootScope.dates);*/
$rootScope.genericModal(
'Save Filter',
'views/filters/template.savefilter.php',
'SAVE',
'Cancel',
function(){
Data.get('savefilter?evv='+$rootScope.data.evv+'&name='+$rootScope.dates.name
+'&dt1='+$rootScope.dates.dt1+'&dt2='+$rootScope.dates.dt2).then(function(results) {
$rootScope.getFilterReports();
});
},
null);
}
$rootScope.deletefilter = function(f){
$rootScope.dates = f;
$rootScope.confirmModal(
'Confirmation',
'Are you sure you want to delete this filter?',
'Yes',
'Cancel',
function(){
Data.get('deletefilter?evv='+$rootScope.data.evv+'&dbid='+f.dbid).then(function(results) {
$rootScope.getFilterReports();
});
},
null);
}
$rootScope.getDeviceDetails = function(){
console.log("GetDeviceDetails");
Data.get('devicedetails?evv='+$rootScope.data.evv).then(function(results){
$rootScope.devicedetails = results
$rootScope.devicetypes = JSON.parse($rootScope.devicedetails[0]);
/*console.log($rootScope.devicetypes);*/
$rootScope.devicelayers = JSON.parse($rootScope.devicedetails[1]);
/*console.log($rootScope.devicelayers);*/
});
}
$rootScope.getallroles = function (){
Data.get('getallroles?evv='+$rootScope.data.evv).then(function(results) {
$rootScope.data.allroles = results[0];
});
}
$rootScope.hdsolved = function(dbid){
Data.get('marksolve?evv='+$rootScope.data.evv+'&dbid='+dbid).then(function(results) {
$rootScope.getReports($rootScope.data.evv);
});
}
$rootScope.getDTHeaders = function(){
Data.get('dtheaders?evv='+$rootScope.data.evv).then(function(results) {
$rootScope.data.dtheaders = results;
/*console.log($rootScope.data.dtheaders);*/
});
}
$rootScope.getDtransactions = function(){
$rootScope.getDTHeaders();
Data.get('dtransactions?evv='+$rootScope.data.evv).then(function(results) {
$rootScope.data.devicetransactions = results;
console.log($rootScope.data.devicetransactions);
$rootScope.location.path("/devicetransactions");
});
}
$rootScope.gotodt = function(n){
$("#contentModal").modal("toggle");
$rootScope.getDtransactions();
$rootScope.data.dtsearch = n;
}
$rootScope.$on('$routeChangeSuccess', function() {
$rootScope.routechange = 1;
if($location.path() != "/passwordrecovery")
Data.get('session').then(function(results) {
if(results == "-") {
delete $rootScope.U;
$rootScope.location.path("login");
}
else {
$rootScope.U = results;
if (($rootScope.cevent) && ($rootScope.dates.dt1 == '') && ($rootScope.dates.dt2 == '')) {
for (var i = 0; i < $rootScope.U.eventsData.length; i++) {
if ($rootScope.U.eventsData[i][7] == $rootScope.cevent) {
$rootScope.dates.dt1 = $rootScope.U.eventsData[i][3];
$rootScope.dates.dt2 = $rootScope.U.eventsData[i][4];
break;
}
}
}
if(angular.isUndefined($rootScope.U.access)){
$rootScope.Req.get("/logout").then(function(){
delete $rootScope.U;
$rootScope.location.path("/login");
});
}
if($rootScope.U.access.indexOf($location.path())<0)
$location.path($rootScope.U.access[0]);
$rootScope.getReports($rootScope.cevent);
if($rootScope.data.userreports.length == 0)
{
$rootScope.getFilterReports();
}
if($location.path() == '/login'){
$location.path('/');
}
}
});
// else $location.path($rootScope.U.access[0]);
});
/*
Functions
*/
$rootScope.isMobile = false;
window.onload = function() {
$rootScope.exportData = function (table, name) {
var blob = new Blob([document.getElementById(table).innerHTML], {
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"
});
saveAs(blob, name+".xls");
};
};
$rootScope.trustshtml = function(s){
if(angular.isDefined(s)){
s = s.replace('|', "
");
return $sce.trustAsHtml(s);
}
return '';
}
$rootScope.trashtml = function(s){
s = s.replace('#', " - ");
//console.log(s);
return $sce.trustAsHtml(s);
}
$rootScope.GroupVendors = function(){
if(!angular.isUndefined($rootScope.data.idGrouping)){
$rootScope.getReports($rootScope.data.evv);
console.log("Filtering content !!!");
}
}
$rootScope.UndoGrouping = function(){
delete $rootScope.data.idGrouping;
$rootScope.getReports($rootScope.data.evv);
}
$rootScope.filterContent = function(){
console.log($rootScope.dates.dt1 + $rootScope.dates.dt2);
$rootScope.routechange = 1;
if($rootScope.dates.dt1 != '' && $rootScope.dates.dt2 != ''){
$rootScope.getReports($rootScope.data.evv);
console.log("Filtering content !!!");
}
else{
$rootScope.confirmModal(
'Alert!',
'Please make sure to put valid date and time!',
'Okay',
null,
null,
null);
$rootScope.dates = {dt1: '', dt2: ''};
}
}
$rootScope.genericModal = function(t, d, sb, cb, ofunc, cfunc){
$rootScope.data.genericModal.title = $sce.trustAsHtml(t);
$rootScope.data.genericModal.template = $sce.trustAsHtml(d);
$rootScope.data.genericModal.saveBtn = sb;
$rootScope.data.genericModal.cancelBtn = cb;
$rootScope.data.genericModal.okFunction = ofunc;
$rootScope.data.genericModal.cancelFunction = cfunc;
$("#contentModal").modal("show");
};
$rootScope.rgb2hex = function (rgb){
rgb = rgb.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);
return (rgb && rgb.length === 4) ? "#" +
("0" + parseInt(rgb[1],10).toString(16)).slice(-2) +
("0" + parseInt(rgb[2],10).toString(16)).slice(-2) +
("0" + parseInt(rgb[3],10).toString(16)).slice(-2) : '';
};
$rootScope.confirmModal = function(t, d, sb, cb, ofunc, cfunc){
$rootScope.data.genericModal.title = $sce.trustAsHtml(t);
$rootScope.data.genericModal.description = $sce.trustAsHtml(d);
$rootScope.data.genericModal.saveBtn = sb;
$rootScope.data.genericModal.cancelBtn = cb;
$rootScope.data.genericModal.okFunction = ofunc;
$rootScope.data.genericModal.cancelFunction = cfunc;
$("#genericModal").modal("show");
};
$rootScope.logout = function(){
$rootScope.confirmModal(
'Confirm',
'Do you want to logout?',
'Yes',
'Cancel',
function(){
$rootScope.Req.get("/logout").then(function(){
if($rootScope.U.events.length == 1 && $rootScope.U.accessType == 3){
window.location.href = 'https://dashboard.youchip.com/__dashboard/' + '
Notice: Undefined index: path in /var/www/html/yc_dashboard/newdashboard/app/index.php on line 361
';
}
else
{
delete $rootScope.U;
$rootScope.location.path("/login");
}
});
}, null);
};
$rootScope.getTxTime = function (){
$rootScope.data.txtime = {};
Data.get('txtiming?evv='+$rootScope.data.evv).then(function(results) {
$rootScope.data.txtime = results[0];
console.log($rootScope.data.txtime);
});
}
$rootScope.getPlus = function (l) {
$rootScope.data.plus = [];
//$rootScope.data.ona = 1;
//console.log(l);
//$rootScope.thelayer = l;
console.log("Calling get Plus !!!");
Data.get('getplusV?evv='+$rootScope.data.evv+'&p=' + l.vendorid).then(function(results) {
$rootScope.data.plus = results;
console.log($rootScope.data.plus);
});
}
$rootScope.getGjendjeV = function(v){
console.log("Calling getGjendje Vendor !!!");
$rootScope.data.plus = [];
Data.get('getplusV?evv='+$rootScope.data.evv+'&p=' + v.vendorid).then(function(results) {
$rootScope.data.plus = results;
//console.log($rootScope.data.plus);
//TODO: GET MAIN PLUS AND ADD THEM TO THE OTHER ONES
Data.get('getmainplusV?evv='+$rootScope.data.evv+'&p=' + v.vendorid).then(function(results) {
for(var i=0;i= 0; i--) {
if($rootScope.data.SVendor.layers[i].idLayer != $rootScope.data.SLayer.idLayer)
$rootScope.data.orilayers.push($rootScope.data.SVendor.layers[i]);
}
}
$rootScope.data.lvselector = w;
$rootScope.getGjendjeV($rootScope.data.SVendor);
$rootScope.location.path("/stock");
}
$rootScope.loadVDevices = function(v){
$rootScope.data.DVendor = v;
//console.log($rootScope.data.DVendor);
$rootScope.getPromoterGjendje();
$rootScope.getVDGjendje($rootScope.data.DVendor);
$rootScope.location.path("/vendordevices");
}
$rootScope.getPromoterGjendje = function(){
Data.get('promoterdevicegjendje?evv='+$rootScope.data.evv).then(function(results) {
$rootScope.data.promoterdevices = results;
console.log($rootScope.data.promoterdevices);
});
}
$rootScope.getVDGjendje = function(v){
Data.get('devicegjendje?vendor='+v.vendorid+'&evv='+$rootScope.data.evv).then(function(results) {
$rootScope.data.gjdevices = results;
console.log($rootScope.data.gjdevices);
});
}
$rootScope.getarticles = function(){
Data.get('aoverview?evv='+$rootScope.data.evv).then(function(results) {
$rootScope.data.articles = results;
console.log($rootScope.data.articles);
});
}
$rootScope.loadtlmapping = function (v, l) {
console.log("Load the mapping!!!");
/* console.log(v);
console.log(l);*/
$rootScope.data.lmlayer = l;
$rootScope.data.lmvendor = v;
Data.get('varticles?evv='+$rootScope.data.evv+'&vendorid=' + v.vendorid ).then(function(results) {
$rootScope.data.varticles = results;
$rootScope.data.departicles = [];
$rootScope.da = {
FCAllowed:0,
PLU: null,
Price:0,
SCAllowed:0,
TXType:0,
ProductGroup : "",
Titel:"DELETE ARTICLE",
VATType:"",
VAllowed:0,
keyColor:"255,0,0",
keyFRGColor:"0,0,0"
};
for (var i = $rootScope.data.varticles.length - 1; i >= 0; i--) {
if($rootScope.data.varticles[i].ProductGroup == 'Deposit'){
$rootScope.data.departicles.push($rootScope.data.varticles[i]);
$rootScope.data.varticles.splice(i,1);
}
}
for(var j = 0; j< $rootScope.data.varticles.length; j++){
$rootScope.data.varticles[j].jincounter = j;
}
$rootScope.data.varticles.unshift($rootScope.da);
console.log($rootScope.data.varticles);
console.log($rootScope.data.departicles);
});
Data.get('credentials?evv='+$rootScope.data.evv).then(function(results) {
$rootScope.data.credentials = JSON.parse(results[0]);
for(var i=0;i<$rootScope.data.credentials.length;i++){
if($rootScope.data.credentials[i].LayerName == $rootScope.data.lmlayer.LayerName && $rootScope.data.credentials[i].Titel == $rootScope.data.lmlayer.vendorName){
$rootScope.data.lmlayercr = $rootScope.data.credentials[i];
console.log($rootScope.data.lmlayercr);
break;
}
}
});
Data.get('getplus?evv='+$rootScope.data.evv+'&p=' + v.vendorid +'&idlayer=' + l.idLayer).then(function(results) {
$rootScope.data.tmplus = results;
console.log($rootScope.data.tmplus);
});
$rootScope.location.path("/mapping");
}
$rootScope.getModalData = function(t, key){
switch(t)
{
case 'ctran':
$rootScope.data.currentchip = key;
Data.get('modaldata?evv='+$rootScope.data.evv+'&t=' + t + '&k='+ key).then(function(results) {
$rootScope.data.ctran = JSON.parse(results[0]);
$rootScope.data.chipanomalies = JSON.parse(results[1]);
$rootScope.data.balances = JSON.parse(results[2]);
$rootScope.data.blockedvalue = JSON.parse(results[3]);
$rootScope.data.chipinfo = JSON.parse(results[4]);
$rootScope.data.rawdata = JSON.parse(results[5]);
$rootScope.data.scans = JSON.parse(results[6]);
$rootScope.data.genericModal.template = "views/modal.chiptransactions.php";
});
break;
}
};
$rootScope.resetTotals = function(){
for(var i=0; i<$rootScope.data.vendorslist.length; i++){
$rootScope.data.vendorslist[i].ttx10 = 0;
$rootScope.data.vendorslist[i].ttx20 = 0;
$rootScope.data.vendorslist[i].ttx30 = 0;
$rootScope.data.vendorslist[i].ttx40 = 0;
}
};
$rootScope.calculateTotals = function (){
$rootScope.resetTotals();
for(var i=0; i<$rootScope.data.vendorslist.length; i++){
for(var j=0; j<$rootScope.data.vendorslist[i].layers.length; j++){
if($rootScope.data.vendorslist[i].layers[j].TXType == 10)
$rootScope.data.vendorslist[i].ttx10 += (parseFloat($rootScope.data.vendorslist[i].layers[j].FC) + parseFloat($rootScope.data.vendorslist[i].layers[j].SC));
if($rootScope.data.vendorslist[i].layers[j].TXType == 20)
$rootScope.data.vendorslist[i].ttx20 += (parseFloat($rootScope.data.vendorslist[i].layers[j].FC) + parseFloat($rootScope.data.vendorslist[i].layers[j].SC));
if($rootScope.data.vendorslist[i].layers[j].TXType == 30)
$rootScope.data.vendorslist[i].ttx30 += (parseFloat($rootScope.data.vendorslist[i].layers[j].FC) + parseFloat($rootScope.data.vendorslist[i].layers[j].SC));
if($rootScope.data.vendorslist[i].layers[j].TXType == 40)
$rootScope.data.vendorslist[i].ttx40 += (parseFloat($rootScope.data.vendorslist[i].layers[j].FC) + parseFloat($rootScope.data.vendorslist[i].layers[j].SC));
}
}
};
$rootScope.getInt = function(n){
return parseInt(n);
};
var interval = $interval(
function(){
if($rootScope.autorefresh)
$rootScope.getReports($rootScope.data.evv);
}, 30000
);
$rootScope.$on(
"$destroy",
function( event ) {
$interval.cancel( interval );
}
);
$rootScope.toggleAutorefresh = function(){
$rootScope.autorefresh = !$rootScope.autorefresh;
};
if ((!angular.isUndefined($rootScope.U)) && ($rootScope.cevent) && ($rootScope.dates.dt1 == '') && ($rootScope.dates.dt2 == '')) {
for (var i = 0; i < $rootScope.U.eventsData.length; i++) {
if ($rootScope.U.eventsData[i][7] == $rootScope.cevent) {
$rootScope.dates.dt1 = $rootScope.U.eventsData[i][3];
$rootScope.dates.dt2 = $rootScope.U.eventsData[i][4];
break;
}
}
}
$rootScope.getReportsreset = function(e){
$rootScope.dates = {dt1: '', dt2: ''};
for (var i = 0; i < $rootScope.U.eventsData.length; i++) {
if ($rootScope.U.eventsData[i][7] == e) {
$rootScope.dates.dt1 = $rootScope.U.eventsData[i][3];
$rootScope.dates.dt2 = $rootScope.U.eventsData[i][4];
break;
}
}
$rootScope.routechange = 1;
$rootScope.getReports(e);
$rootScope.getFilterReports();
};
/* REPORTS */
$rootScope.getReports = function(event){
console.log("GetReports: " + event);
$rootScope.cevent = event;
$rootScope.relateddates = "";
if($rootScope.dates.dt1 != "" && $rootScope.dates.dt2 != "")
$rootScope.relateddates = "&dt1="+$rootScope.dates.dt1+"&dt2="+$rootScope.dates.dt2;
//event = $rootScope.cevent;
localStorageService.set("cevent", $rootScope.cevent);
$rootScope.data.evv = $rootScope.cevent;
//console.log($rootScope.data.evv);
if($rootScope.autorefresh == true || $rootScope.routechange == 1){
$rootScope.routechange = 0;
switch($location.path())
{
case '/':
if(!angular.isUndefined($rootScope.cevent)){
delete $rootScope.data.reports;
//var relateddates = "";
Data.get('overview?evv='+$rootScope.data.evv+$rootScope.relateddates).then(function(results) {
$rootScope.data.reports = results;
});
}
break;
case '/vendors':
if(!angular.isUndefined($rootScope.cevent)){
delete $rootScope.data.vendors;
var relateddates = "";
$rootScope.routechange = 1;
if($rootScope.dates.dt1 != "" && $rootScope.dates.dt2 != "")
relateddates = "&dt1="+$rootScope.dates.dt1+"&dt2="+$rootScope.dates.dt2;
if(!angular.isUndefined($rootScope.data.idGrouping))
grouping = "&idGrouping=" + $rootScope.data.idGrouping;
else grouping = "";
Data.get('vendors?evv='+$rootScope.data.evv+relateddates+grouping).then(function(results) {
if(JSON.parse(results[0]) != $rootScope.data.vendors){
$rootScope.data.vendors = JSON.parse(results[0]);
$rootScope.data.YCLocations = JSON.parse(results[1]);
$rootScope.data.vendorslist = _.chain($rootScope.data.vendors).groupBy('idVendor')
.map(function(value, key) {
return {
vendorid: key,
layers: value,
expanded: $rootScope.autoexpand
}}).value();
$rootScope.calculateTotals();
}
});
}
break;
case '/credentials':
if(!angular.isUndefined($rootScope.cevent)){
delete $rootScope.data.helpdesk;
Data.get('credentials?evv='+$rootScope.data.evv).then(function(results) {
$rootScope.data.credentials = JSON.parse(results[0]);
});
}
break;
case '/selftopup':
if(!angular.isUndefined($rootScope.cevent)){
var relateddates = "";
if($rootScope.dates.dt1 != "" && $rootScope.dates.dt2 != "")
relateddates = "&dt1="+$rootScope.dates.dt1+"&dt2="+$rootScope.dates.dt2;
delete $rootScope.data.selftopups;
delete $rootScope.data.stpzreports;
Data.get('devicetu?evv='+$rootScope.data.evv+relateddates).then(function(results) {
$rootScope.data.selftopups = JSON.parse(results[0]);
console.log($rootScope.data.selftopups);
});
Data.get('stpzreports?evv='+$rootScope.data.evv+relateddates).then(function(results) {
$rootScope.data.stpzreports = JSON.parse(results[0]);
console.log($rootScope.data.stpzreports);
});
}
break;
case '/reports':
if(!angular.isUndefined($rootScope.cevent)){
var relateddates = "";
if($rootScope.dates.dt1 != "" && $rootScope.dates.dt2 != "")
relateddates = "&dt1="+$rootScope.dates.dt1+"&dt2="+$rootScope.dates.dt2;
delete $rootScope.data.zreports;
Data.get('reports?evv='+$rootScope.data.evv+relateddates).then(function(results) {
$rootScope.data.zreports = JSON.parse(results[0]);
});
}
break;
case '/anomalies':
if(!angular.isUndefined($rootScope.cevent)){
var relateddates = "";
if($rootScope.dates.dt1 != "" && $rootScope.dates.dt2 != "")
relateddates = "&dt1="+$rootScope.dates.dt1+"&dt2="+$rootScope.dates.dt2;
delete $rootScope.data.anomalies;
Data.get('anomalies?evv='+$rootScope.data.evv+relateddates).then(function(results) {
$rootScope.data.anomalies = results;
});
}
break;
case '/helpdesk':
if(!angular.isUndefined($rootScope.cevent)){
var relateddates = "";
if($rootScope.dates.dt1 != "" && $rootScope.dates.dt2 != "")
relateddates = "&dt1="+$rootScope.dates.dt1+"&dt2="+$rootScope.dates.dt2;
delete $rootScope.data.helpdesk;
Data.get('helpdesk?evv='+$rootScope.data.evv+relateddates).then(function(results) {
$rootScope.data.helpdesk = JSON.parse(results[0]);
});
}
break;
case '/devices':
if(!angular.isUndefined($rootScope.cevent)){
var relateddates = "";
if($rootScope.dates.dt1 != "" && $rootScope.dates.dt2 != "")
relateddates = "&dt1="+$rootScope.dates.dt1+"&dt2="+$rootScope.dates.dt2;
delete $rootScope.data.helpdesk;
Data.get('devices?evv='+$rootScope.data.evv+relateddates).then(function(results) {
$rootScope.data.devices = JSON.parse(results[0]);
});
}
break;
case '/vendorview':
if(!angular.isUndefined($rootScope.cevent)){
console.log("On Vendorview !!!");
}
break;
case '/chips':
if(!angular.isUndefined($rootScope.cevent)){
var relateddates = "";
$rootScope.routechange = 1;
if($rootScope.dates.dt1 != "" && $rootScope.dates.dt2 != "")
relateddates = "&dt1="+$rootScope.dates.dt1+"&dt2="+$rootScope.dates.dt2;
delete $rootScope.data.chips;
Data.get('chips?evv='+$rootScope.data.evv+relateddates).then(function(results) {
$rootScope.data.chips = JSON.parse(results[0]);
$rootScope.data.blockedchipstx = JSON.parse(results[1]);
});
}
break;
case '/usertopup':
if(!angular.isUndefined($rootScope.cevent)){
delete $rootScope.data.usertopups;
Data.get('usertopups?evv='+$rootScope.data.evv).then(function(results) {
$rootScope.data.usertopups = results;
console.log($rootScope.data.usertopups[0]);
});
}
break;
case '/users':
if(!angular.isUndefined($rootScope.cevent)){
delete $rootScope.data.chips;
Data.get('users?evv='+$rootScope.data.evv).then(function(results) {
$rootScope.data.users = results[0];
});
}
break;
case '/eventdetails':
if(!angular.isUndefined($rootScope.cevent)){
Data.get('eventdetails?evv='+$rootScope.data.evv).then(function(results) {
$rootScope.data.onlineconfig = results[0];
$rootScope.data.appconfig = results[1];
$rootScope.data.onsiteconfig = results[2];
$rootScope.data.chipconfig = results[3];
console.log(results);
});
}
break;
case '/eventconfig':
if(!angular.isUndefined($rootScope.cevent)){
Data.get('promoeventdetails?evv='+$rootScope.data.evv).then(function(results) {
$rootScope.data.promoeventconfig = results;
console.log(results);
});
}
break;
case '/articles':
if(!angular.isUndefined($rootScope.cevent)){
var relateddates = "";
if($rootScope.dates.dt1 != "" && $rootScope.dates.dt2 != "")
relateddates = "&dt1="+$rootScope.dates.dt1+"&dt2="+$rootScope.dates.dt2;
Data.get('aoverview?evv='+$rootScope.data.evv+relateddates).then(function(results) {
$rootScope.data.articles = results;
$rootScope.getarticleoverview();
for(var i=0;i<$rootScope.data.articles.length;i++){
$rootScope.data.articles[i].selected = 0;
$rootScope.data.articles[i].FirstCurrencyAllowed = $rootScope.data.articles[i].FirstCurrencyAllowed.toString();
$rootScope.data.articles[i].SecondCurrencyAllowed = $rootScope.data.articles[i].SecondCurrencyAllowed.toString();
$rootScope.data.articles[i].VoucherAllowed = $rootScope.data.articles[i].VoucherAllowed.toString();
if($rootScope.data.articles[i].PriceType != null){
$rootScope.data.articles[i].PriceType = $rootScope.data.articles[i].PriceType.toString();
}
$rootScope.data.articles[i].keyColor = $rootScope.rgb2hex("rgb("+ $rootScope.data.articles[i].keyColor+")");
$rootScope.data.articles[i].keyFRGColor = $rootScope.rgb2hex("rgb("+ $rootScope.data.articles[i].keyFRGColor+")");
if($rootScope.data.articles[i].TXType == "10")
$rootScope.data.articles[i].TXType = $rootScope.data.TxTypes[0];
else if($rootScope.data.articles[i].TXType == "20")
$rootScope.data.articles[i].TXType = $rootScope.data.TxTypes[1];
else if($rootScope.data.articles[i].TXType == "30")
$rootScope.data.articles[i].TXType = $rootScope.data.TxTypes[2];
else if($rootScope.data.articles[i].TXType == "40")
$rootScope.data.articles[i].TXType = $rootScope.data.TxTypes[3];
}
//console.log($rootScope.data.articles);
});
}
break;
case '/eventdevices':
if(!angular.isUndefined($rootScope.cevent)){
delete $rootScope.data.assigneddevices;
Data.get('doverview?evv='+$rootScope.data.evv).then(function(results) {
$rootScope.data.assigneddevices = JSON.parse(results[0]);
});
}
break;
case '/promoterdevices':
if(!angular.isUndefined($rootScope.cevent)){
Data.get('promoterdevicegjendje?evv='+$rootScope.data.evv).then(function(results) {
$rootScope.data.promoterdevices = results;
});
}
break;
case '/crowd':
if(!angular.isUndefined($rootScope.cevent)){
Data.get('crowd?evv='+$rootScope.data.evv).then(function(results) {
$rootScope.data.crowd = results;
});
}
break;
case '/areas':
if(!angular.isUndefined($rootScope.cevent)){
Data.get('areasoverview?evv='+$rootScope.data.evv).then(function(results) {
$rootScope.data.areas = JSON.parse(results[0]);
});
}
break;
case '/tickettypes':
if(!angular.isUndefined($rootScope.cevent)){
Data.get('getticketroles?evv='+$rootScope.data.evv).then(function(results) {
$rootScope.data.roles = results;
});
}
break;
case '/accesscontrol':
if(!angular.isUndefined($rootScope.cevent)){
var relateddates = "";
if($rootScope.dates.dt1 != "" && $rootScope.dates.dt2 != "")
relateddates = "&dt1="+$rootScope.dates.dt1+"&dt2="+$rootScope.dates.dt2;
Data.get('accessoverview?evv='+$rootScope.data.evv+relateddates).then(function(results) {
$rootScope.data.access = results;
});
}
break;
case '/catering':
if(!angular.isUndefined($rootScope.cevent)){
var relateddates = "";
if($rootScope.dates.dt1 != "" && $rootScope.dates.dt2 != "")
relateddates = "&dt1="+$rootScope.dates.dt1+"&dt2="+$rootScope.dates.dt2;
/* Data.get('accessoverview?evv='+$rootScope.data.evv+relateddates).then(function(results) {
$rootScope.data.access = results;
});*/
}
break;
case '/ycontrol':
if(!angular.isUndefined($rootScope.cevent)){
var relateddates = "";
if($rootScope.dates.dt1 != "" && $rootScope.dates.dt2 != "")
relateddates = "&dt1="+$rootScope.dates.dt1+"&dt2="+$rootScope.dates.dt2;
Data.get('locationoverview?evv='+$rootScope.data.evv+relateddates).then(function(results) {
$rootScope.yclocations = results[0];
$rootScope.providers = results[1];
$rootScope.ycticketype = results[2];
});
}
break;
case '/guestclient':
if(!angular.isUndefined($rootScope.cevent)){
var relateddates = "";
if($rootScope.dates.dt1 != "" && $rootScope.dates.dt2 != "")
relateddates = "&dt1="+$rootScope.dates.dt1+"&dt2="+$rootScope.dates.dt2;
/* Data.get('accessoverview?evv='+$rootScope.data.evv+relateddates).then(function(results) {
$rootScope.data.access = results;
});*/
}
break;
}
}
};
})
.controller('overviewController', function($scope, $rootScope, $interval, Data) {
$ctrl = this;
$scope.reports = [];
$scope.reports.generaldata = [];
$rootScope.$watch("data.reports", function(){
if(!angular.isUndefined($rootScope.data.reports)){
$scope.reports.generaldata = JSON.parse($rootScope.data.reports[0]);
$scope.reports.turnover = JSON.parse($rootScope.data.reports[1])[0]["tover"];
$scope.reports.turnoverFC = JSON.parse($rootScope.data.reports[1])[0]["toverFC"];
$scope.reports.turnoverSC = JSON.parse($rootScope.data.reports[1])[0]["toverSC"];
$scope.reports.activechips = JSON.parse($rootScope.data.reports[1])[0]["activechips"];
$scope.reports.newvisitors = JSON.parse($rootScope.data.reports[1])[0]["newvisitors"];
$scope.reports.tickets = JSON.parse($rootScope.data.reports[1])[0]["tickets"];
$scope.reports.exchanges = JSON.parse($rootScope.data.reports[1])[0]["exchanges"];
$scope.reports.chips = JSON.parse($rootScope.data.reports[1])[0]["chips"];
$scope.reports.trannum = JSON.parse($rootScope.data.reports[1])[0]["trannum"];
$scope.reports.tranchip = JSON.parse($rootScope.data.reports[1])[0]["chip"];
$scope.reports.trancash = JSON.parse($rootScope.data.reports[1])[0]["cash"];
$scope.reports.trancard = JSON.parse($rootScope.data.reports[1])[0]["card"];
$scope.reports.registeredchips = JSON.parse($rootScope.data.reports[1])[0]["registeredchips"];
$scope.reports.transperday = JSON.parse($rootScope.data.reports[2]);
$scope.reports.transpermin = JSON.parse($rootScope.data.reports[3]);
$scope.reports.onlinetopup = JSON.parse($rootScope.data.reports[4]);
$scope.reports.moneyStatus = JSON.parse($rootScope.data.reports[5]);
try {
$scope.reports.vouchers = JSON.parse($rootScope.data.reports[6]);
} catch (error) {
$scope.reports.vouchers = JSON.parse('{}');
}
$scope.labels = [];
$scope.data = [[], [], [], []];
for(var i = 0; i < $scope.reports.transperday.length; i++){
$scope.labels.push($scope.reports.transperday[i].date);
$scope.data[0].push($scope.reports.transperday[i].topups);
$scope.data[1].push($scope.reports.transperday[i].purchases);
$scope.data[2].push($scope.reports.transperday[i].cancellations);
$scope.data[3].push($scope.reports.transperday[i].refunds);
}
$scope.labelsperminute = [];
$scope.dataperminute = [[], [], [], []];
for(var i = 0; i < $scope.reports.transpermin.length; i++){
$scope.labelsperminute.push($scope.reports.transpermin[i].minu);
$scope.dataperminute[0].push($scope.reports.transpermin[i].numTx10);
$scope.dataperminute[1].push($scope.reports.transpermin[i].numTx20);
$scope.dataperminute[2].push($scope.reports.transpermin[i].numTx30);
$scope.dataperminute[3].push($scope.reports.transpermin[i].numTx40);
}
}
});
$scope.preloaded = [];
$scope.labels = [];
$scope.series = ["TopUps", "Purchases", "Cancellations", "Refunds"];
$scope.data = [];
$scope.onClickTest = function (points, evt) {
console.log(points, evt);
};
$scope.datasetOverride = [{ yAxisID: 'y-axis-1' }, { yAxisID: 'y-axis-2' }];
$scope.options = {
legend: { display: true },
tooltip:{
formatter: function() {
return 'The value for ' + this.x + ' is ' + this.y + ', in series '+ this.series.name;
}
},
responsive: true,
maintainAspectRatio: true,
scales: {
yAxes: [
{
id: 'y-axis-1',
type: 'linear',
display: true,
position: 'left'
},
{
id: 'y-axis-2',
type: 'linear',
display: true,
position: 'right'
}
]
},
scaleLabel: function(label){return label.value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");}
};
$scope.optionsa = {
legend: { display: true },
tooltip:{
formatter: function() {
return 'The value for ' + this.x + ' is ' + this.y + ', in series '+ this.series.name;
}
},
responsive: false,
maintainAspectRatio: false,
scales: {
yAxes: [
{
id: 'y-axis-1',
type: 'linear',
display: true,
position: 'left'
},
{
id: 'y-axis-2',
type: 'linear',
display: true,
position: 'right'
}
]
},
scaleLabel: function(label){return label.value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");}
};
$scope.reports.moneyOnChip = {
labels: ["Money On Chip", "Money Not On Chip"],
data: [300, 100]
};
$scope.openUpfrontModal = function () {
Data.get('getPreloadedValues?evv='+$rootScope.data.evv).then(function(results) {
$scope.preloaded = results;
$('#TopupUpfront_modal').modal('show');
});
};
}).controller('loginController', function($scope, $rootScope, $routeParams, Data, $location) {
if(!angular.isUndefined($rootScope.U)){
console.log("login");
$rootScope.location.path("/");
}
$scope.regconfirm = 0;
$scope.lostpass = 0;
$scope.login = function(){
if(
Notice: Undefined index: eventsession in /var/www/html/yc_dashboard/newdashboard/app/ctrl/ctrl.login.php on line 13
0 == 0){
window.localStorage.setItem('sessione', 'x');
$rootScope.Req.post('login', $scope.auth).then(function(results){
if(results.eventsData.length == 0)
$rootScope.location.path("/");
$rootScope.U = results;
$rootScope.cevent = $rootScope.U.events;
$rootScope.location.path($rootScope.U.access[0] == '/login' ? $rootScope.U.access[1] : $rootScope.U.access[0]);
});
}
else {
window.localStorage.setItem('sessione', '
Notice: Undefined index: eventsession in /var/www/html/yc_dashboard/newdashboard/app/ctrl/ctrl.login.php on line 24
');
$rootScope.Req.post('login?evv='+'
Notice: Undefined index: eventsession in /var/www/html/yc_dashboard/newdashboard/app/ctrl/ctrl.login.php on line 25
', $scope.auth).then(function(results){
if(results.eventsData.length > 0 && results.events[0] != null){
$rootScope.U = results;
$rootScope.cevent = $rootScope.U.events
$rootScope.location.path($rootScope.U.access[0]);
}
else
$rootScope.location.path("/");
});
}
}
$scope.login2 = function(u){
window.localStorage.setItem('sessione', '
Notice: Undefined index: eventsession in /var/www/html/yc_dashboard/newdashboard/app/ctrl/ctrl.login.php on line 40
');
$location.search('ack', null);
$rootScope.Req.post('login?evv='+'
Notice: Undefined index: eventsession in /var/www/html/yc_dashboard/newdashboard/app/ctrl/ctrl.login.php on line 42
', {'username':u.Email, 'password':$scope.data.newpass1}).then(function(results){
if(results.eventsData.length > 0){
$rootScope.U = results;
$rootScope.cevent = $rootScope.U.events
$rootScope.location.path($rootScope.U.access[0]);
}
else
$rootScope.location.path("/");
//$rootScope.location.path($rootScope.U.access[0]);
});
}
$scope.fps = function(){
$scope.lostpass = 1;
}
$scope.requestpass = function(){
console.log("Request pass for this email:" +$scope.data.fpemail);
Data.get('forgotpassword?evv='+'
Notice: Undefined index: eventsession in /var/www/html/yc_dashboard/newdashboard/app/ctrl/ctrl.login.php on line 62
'+'&fpemail=' + $scope.data.fpemail).then(function(results) {
$rootScope.location.path("/whatever");
});
}
/*if($routeParams.ack){
$scope.regconfirm = 1;
// console.log("Activation key is: " + $routeParams.ack);
// console.log("Event key: " + $routeParams.ev);
}
else{
$scope.regconfirm = 0;
}*/
if('
Notice: Undefined index: ack in /var/www/html/yc_dashboard/newdashboard/app/ctrl/ctrl.login.php on line 75
' != '')
{
$scope.regconfirm = 1;
}
else{
$scope.regconfirm = 0;
}
$scope.data.newpass1 = "";
$scope.data.newpass2 = "";
$scope.data.fpemail = "";
$scope.confirmpass = function(){
if ($scope.data.newpass1.valueOf() == $scope.data.newpass2.valueOf() && $scope.data.newpass1.length >= 4 ){
// console.log("Correct Password !!!");
// console.log($scope.data.newpass1);
// console.log($scope.data.newpass2);
Data.get('confirmpass?evv='+'
Notice: Undefined index: eventsession in /var/www/html/yc_dashboard/newdashboard/app/ctrl/ctrl.login.php on line 93
'+'&pwd=' + $scope.data.newpass1 +'&actkey='+'
Notice: Undefined index: ack in /var/www/html/yc_dashboard/newdashboard/app/ctrl/ctrl.login.php on line 93
').then(function(results) {
if(results[0] == "Success")
$scope.login2(results[1]);
//window.location.href = ("https://dashboard.youchip.com/__dashboard/eurosonic?vendor=1");
});
}
else{
$rootScope.confirmModal(
'Error',
'Something is wrong with your password, please try again!',
null,
'Okay',
null,
null);
$scope.data.newpass1 = "";
$scope.data.newpass2 = "";
}
}
}).controller('vendorsController', function($scope, $rootScope, Data, $timeout,localStorageService, $location, Upload) {
$rootScope.$watch("data.vendorslist", function(){
if(!angular.isUndefined($rootScope.data.vendors)){
$scope.vendors = $rootScope.data.vendors;
$scope.vendorslist = $rootScope.data.vendorslist;
}
});
$timeout(function() {
$rootScope.getTxTime();
$rootScope.getDeviceDetails();
$rootScope.getContactList();
$rootScope.getVendorFilter();
$rootScope.getvddevices($rootScope.data.evv);
if($rootScope.U.accessType != 1){
if($rootScope.U.canSeeViews.indexOf('/vendor.managment') == -1 && $rootScope.U.canSeeViews.indexOf('/vendor.reports') == -1)
$location.path($rootScope.U.canSeeViews[0]);
else if($rootScope.U.canSeeViews.indexOf('/vendor.managment') > -1 && $rootScope.U.canSeeViews.indexOf('/vendor.reports') == -1)
$scope.activetab = 1;
else if($rootScope.U.canSeeViews.indexOf('/vendor.managment') == -1 && $rootScope.U.canSeeViews.indexOf('/vendor.reports') > -1)
$scope.activetab = 2;
$rootScope.getvddevices($rootScope.data.evv);
}
}, 500).then(function() {
});
//$rootScope.plus = [];
$rootScope.newData = {};
$rootScope.data.vname = "";
$rootScope.data.vemail = "";
$rootScope.data.clayername = "";
$rootScope.data.cpaybutton = "";
$rootScope.data.newlayername = "";
$rootScope.data.invuseremail = "";
$rootScope.data.vstatuses = [];
$rootScope.newAddon = "";
$rootScope.data.companydata = {};
$rootScope.data.stockarticles = [];
$rootScope.selectedvendorid = "";
$rootScope.selectedlayerid = "";
$rootScope.groupid = "";
$rootScope.nocontact = 0;
$rootScope.data.amo = 1;
$rootScope.data.maxs = 0;
$rootScope.emp = {};
$rootScope.emps = [];
$rootScope.showMasterlist = 0;
$rootScope.data.PM = [{"code":"1", "name":"CHIP"},
{"code":"4", "name":"CHIP and CASH"},
{"code":"2", "name":"CASH and CARD"},
{"code":"5", "name":"CHIP and CARD"},
{"code":"3", "name":"CHIP, CASH and CARD"}];
$rootScope.data.PMselected = {"code":"1", "name":"CHIP"};
$scope.activetab = 1;
$scope.setactive = function(ind){
$scope.activetab = ind;
if($scope.activetab == 3){
$rootScope.showMasterlist = 1;
}
else
$rootScope.showMasterlist = 0;
}
$rootScope.activeOv = 1;
$rootScope.setActiveOv = function(ind){
$rootScope.activeOv = ind;
if($scope.activeOv == 3){
$rootScope.getVendorFilter();
}
}
$rootScope.activeAd = 1;
$rootScope.setActiveAd = function(ind){
$rootScope.activeAd = ind;
}
$rootScope.activetabM = 1;
$rootScope.setactiveM = function(ind){
$rootScope.activetabM = ind;
if(ind == 2){
$rootScope.genericModal(
'Edit Company Data',
'views/vendors/template.editcompanydata.php',
null,
'Cancel',
function(){
$rootScope.Req.post('editvendordetails?evv='+$rootScope.data.evv, [$rootScope.data.companydata]).then(function(results) {
console.log($rootScope.data.companydata);
$rootScope.getReports($rootScope.data.evv);
});
},
null);
$rootScope.getemployee();
}
else{
$rootScope.genericModal(
'Edit Company Data',
'views/vendors/template.editcompanydata.php',
'SAVE',
'Cancel',
function(){
$rootScope.Req.post('editvendordetails?evv='+$rootScope.data.evv, [$rootScope.data.companydata]).then(function(results) {
console.log($rootScope.data.companydata);
$rootScope.getReports($rootScope.data.evv);
});
},
null);
}
}
$rootScope.addemployee = function(){
$rootScope.emp = {};
console.log($rootScope.emp);
}
$rootScope.saveemployee = function(){
console.log($rootScope.emp);
if($rootScope.emp.dbid){
$rootScope.Req.post('updateemployee?evv='+$rootScope.data.evv+"&idv="+$rootScope.data.companydata.idVendor, [$rootScope.emp]).then(function(results) {
$rootScope.getemployee();
$rootScope.getContactList();
});
}
else{
$rootScope.Req.post('createemployee?evv='+$rootScope.data.evv+"&idv="+$rootScope.data.companydata.idVendor, [$rootScope.emp]).then(function(results) {
$rootScope.getemployee();
$rootScope.getContactList();
});
}
}
$rootScope.exportdata = function(){
window.location = "http://dashboard.youchip.com/__dashboard/api/services/staff.exportdata.php?evv="+$rootScope.data.evv+"&idv="+$rootScope.data.companydata.idVendor;
}
$rootScope.exportSettlement = function(v){
if(v.ttx10 != 0 || v.ttx20 != 0 || v.ttx30 != 0 || v.ttx40 != 0)
{
window.location = "http://dashboard.youchip.com/excelexport/vendorsettlement.php?evv="+$rootScope.data.evv+"&idv="+v.vendorid+"&vname="+v.layers[0].vendorName;
}
else
var isConfirmed = confirm("There are no Z-Reports for this vendor!");
}
$rootScope.getemployee = function(){
Data.get('getemployee?evv='+$rootScope.data.evv+"&idv="+$rootScope.data.companydata.idVendor).then(function(results) {
$rootScope.emps = results;
});
}
$rootScope.deleteemployee = function(e){
console.log(e);
Data.get('deleteemployee?evv='+$rootScope.data.evv+"&dbid="+e.dbid+"&Picture="+e.Picture).then(function(results) {
$rootScope.getemployee();
});
}
$rootScope.showEmpDetails = function(e){
$rootScope.emp = e;
}
$scope.uploadFiles = function(file, errFiles) {
$rootScope.emp.Picture = file;
}
$rootScope.onFileSelect = function(file){
$rootScope.emp.Picture = file.name;
console.log($rootScope.emp);
if(file != null)
Upload.upload({
url: '/__dashboard/uploadpp.php',
data: {file: file}
}).then(function(resp) {
});
};
$scope.manageexpand = function(v){
$rootScope.data.SVendor = v;
$rootScope.getPlus(v);
$rootScope.getGjendjeV(v);
console.log(v);
if($rootScope.expanded.includes(v.vendorid)){
for(var i=0;i<$rootScope.expanded.length;i++){
if($rootScope.expanded[i] == v.vendorid){
$rootScope.expanded.splice(i,1);
break;
}
}
}
else
$rootScope.expanded.push(v.vendorid);
}
$scope.checkexpand = function(v){
if($rootScope.expanded.includes(v.vendorid))
return true;
else
return false;
}
$scope.addVStock = function(){
console.log("Calling add Vendor Stock!");
console.log($rootScope.data.plus);
}
$scope.addSStock = function(){
}
$scope.addstocks = function (s){
$rootScope.getGjendjeS(s);
console.log(s);
$rootScope.data.SLayer = s;
for(var i=0;i<$rootScope.data.plus.length;i++){
for(var j=0;j<$rootScope.data.gjendja.length;j++){
if($rootScope.data.plus[i].PLU == $rootScope.data.gjendja[j].PLU){
$rootScope.data.plus[i].gjendja = $rootScope.data.gjendja[j].Gjendje;
}
}
}
console.log($rootScope.data.plus);
$rootScope.genericModal(
'Add stock to this stand',
'views/vendors/template.addstocks.php',
'SAVE',
'Cancel',
function(){
$rootScope.Req.post('addstock?evv='+$rootScope.data.evv+'&orig='+$rootScope.data.SVendor.vendorid+'&dest='+$rootScope.data.SLayer.idLayer+'&user='+$rootScope.U.name, [$rootScope.data.stockarticles]).then(function(results) {
$rootScope.data.stockarticles = [];
});
},
null);
}
$scope.addstockv = function (v){
$rootScope.data.SVendor = v;
$rootScope.getPlus(v);
$rootScope.genericModal(
'Add stock to this vendor',
'views/vendors/template.addstockv.php',
'SAVE',
'Cancel',
function(){
$rootScope.Req.post('addstock?evv='+$rootScope.data.evv+'&orig=NULL&dest='+$rootScope.data.SVendor.vendorid+'&user='+$rootScope.U.name, [$rootScope.data.stockarticles]).then(function(results) {
$rootScope.data.stockarticles = [];
});
},
null);
}
$rootScope.addToStock = function(){
if($rootScope.data.art){
if($rootScope.data.stockarticles.length != 0){
for(var i=0; i<$rootScope.data.stockarticles.length;i++){
if(parseInt($rootScope.data.art.PLU) == parseInt($rootScope.data.stockarticles[i].article.PLU)){
$rootScope.data.stockarticles[i].amount = parseInt($rootScope.data.stockarticles[i].amount) + parseInt($rootScope.data.amo);
$rootScope.data.art = {};
$rootScope.data.amo = 1;
break;
}
if((i == ($rootScope.data.stockarticles.length - 1)) && (parseInt($rootScope.data.art.PLU) != parseInt($rootScope.data.stockarticles[i].article.PLU))){
if(!angular.equals($rootScope.data.art, {})){
$scope.as = {};
$scope.as.article = angular.copy($rootScope.data.art);
$scope.as.amount = angular.copy($rootScope.data.amo);
$rootScope.data.stockarticles.push($scope.as);
$rootScope.data.art = {};
$rootScope.data.amo = 1;
}
break;
}
}
}
else if ($rootScope.data.stockarticles.length == 0){
$scope.as = {};
$scope.as.article = angular.copy($rootScope.data.art);
$scope.as.amount = angular.copy($rootScope.data.amo);
$rootScope.data.stockarticles.push($scope.as);
$rootScope.data.art = {};
$rootScope.data.amo = 1;
}
console.log($rootScope.data.stockarticles);
}
}
$rootScope.removea = function(i){
$rootScope.data.stockarticles.splice(i,1);
}
$scope.enddate = function (){
console.log($rootScope.data.txtime.enddate);
}
$scope.createVendor = function (){
$rootScope.genericModal(
'Create new vendor',
'views/vendors/template.createvendor.php',
'SAVE',
'Cancel',
function(){
Data.get('createvendor?evv='+$rootScope.data.evv+'&vname='+$rootScope.data.vname+'&email='+$rootScope.data.vemail).then(function(results) {
console.log(results);
$rootScope.getReports($rootScope.data.evv);
});
},
null);
}
$scope.createLayer = function (v){
console.log(v);
$rootScope.genericModal(
'Create new layer',
'views/vendors/template.createlayer.php',
'SAVE',
'Cancel',
function(){
console.log($rootScope.data.newlayername);
console.log($rootScope.data.PMselected.code);
Data.get('createlayer?evv='+$rootScope.data.evv+'&vname='+$rootScope.data.newlayername+'&paybutton='+$rootScope.data.PMselected.code+'&idvendor='+v.vendorid).then(function(results) {
$rootScope.getReports($rootScope.data.evv);
});
},
null);
}
$scope.gotoCredentials = function(){
$rootScope.location.path("/credentials");
}
$scope.deletelayer = function(l){
$rootScope.confirmModal(
'Confirmation',
'Are you sure you want to delete this layer?',
'Yes',
'Cancel',
function(){
console.log(l);
Data.get('deletelayer?evv='+$rootScope.data.evv+'&tm='+l.idLayer+'&pg='+l.idvg+'&idvendor='+l.idVendor).then(function(results) {
$rootScope.getReports($rootScope.data.evv);
$rootScope.getvddevices($rootScope.data.evv);
});
},
null);
}
$scope.deletevendor = function(v){
$rootScope.confirmModal(
'Confirmation',
'Are you sure you want to delete this vendor?',
'Yes',
'Cancel',
function(){
Data.get('deletevendor?evv='+$rootScope.data.evv+'&idVendor='+v.vendorid).then(function(results) {
$rootScope.getReports($rootScope.data.evv);
});
},
null);
}
$scope.isCompleted = function(l,i){
Data.get('isCompleted?evv='+$rootScope.data.evv +'&idVendor=' + l.idVendor + '&idVendorGroups=' + l.idvg + '&isCompleted=' +i).then(function(results) {
$rootScope.getReports($rootScope.data.evv);
});
}
$scope.getOverview = function (){
Data.get('vendorstatuses?evv='+$rootScope.data.evv).then(function(results) {
$rootScope.data.vstatuses = results[0];
console.log($rootScope.data.vstatuses);
});
$rootScope.genericModal(
'Vendors overview',
'views/vendors/template.vendorsoverview.php',
null,
'OK',
null,
null);
}
$scope.getvendordetails = function (v){
console.log(v);
Data.get('vendordetails?evv='+$rootScope.data.evv+'&p='+v.vendorid).then(function(results) {
$rootScope.data.companydata = results[0];
console.log($rootScope.data.companydata);
});
}
$scope.editvendordetails = function(v){
$scope.getvendordetails(v);
$rootScope.data.companydata = v;
$rootScope.genericModal(
'Edit Company Data',
'views/vendors/template.editcompanydata.php',
'SAVE',
'Cancel',
function(){
$rootScope.Req.post('editvendordetails?evv='+$rootScope.data.evv, [$rootScope.data.companydata]).then(function(results) {
console.log($rootScope.data.companydata);
$rootScope.getReports($rootScope.data.evv);
});
},
null);
}
$rootScope.addcontactperson = function(v){
$rootScope.activetabM = 2;
$rootScope.data.companydata.idVendor = v.vendorid;
$rootScope.setactiveM($rootScope.activetabM);
}
$scope.inviteUsers = function (v){
console.log(v);
$rootScope.genericModal(
'Invite user',
'views/vendors/template.inviteusers.php',
'Invite',
'Cancel',
function(){
console.log($rootScope.data.invuseremail);
Data.get('inviteusers?evv='+$rootScope.data.evv+'&p='+v.vendorid+'&email='+$rootScope.data.invuseremail).then(function(results) {
console.log(results);
});
},
null);
}
$scope.editLayer = function ( l ){
console.log(l);
$rootScope.data.layer = l;
$rootScope.data.PM.code = l.paybutton;
$rootScope.genericModal(
'Edit Layer',
'views/vendors/template.editlayer.php',
'SAVE',
'Cancel',
function(){
console.log(l.paybutton);
$rootScope.Req.post('editlayer?evv='+$rootScope.data.evv, [$rootScope.data.layer,l.paybutton]).then(function(results) {
$rootScope.getReports($rootScope.data.evv);
});
},
null);
}
$scope.getPLUs = function(idl, ln){
//console.log("ID Layer :" + idl);
var dt1 = '';
var dt2 = '';
if($rootScope.dates.dt1 != '' && $rootScope.dates.dt2 != ''){
dt1 = $rootScope.dates.dt1;
dt2 = $rootScope.dates.dt2;
}
list = '';
if(dt1 != '') list = '&dt1='+dt1+'&dt2='+dt2;
Data.get('pluslayer?evv='+$rootScope.data.evv+'&idl='+idl+list).then(function(results) {
$rootScope.plus = JSON.parse(results[0]);
// console.log($rootScope.plus);
$scope.validateTypes();
$rootScope.genericModal(
ln + '- Transactions',
'views/vendors/template.plu.php',
null,
'OK',
null,
null);
});
}
$scope.usersstatus = function(v){
console.log(v);
Data.get('usersstatus?evv='+$rootScope.data.evv+'&p='+v.vendorid).then(function(results) {
$rootScope.data.ustatus = results;
$rootScope.genericModal(
'Users status',
'views/vendors/template.usersstatus.php',
null,
'Close',
null,
null);
});
}
$rootScope.calcultateTotM = function ( a , tx ){
$rootScope.totali = 0;
for (var i=0; i < a.length; i++){
if(tx == 10){
if( a[i].amount10 != 0){
$rootScope.totali += a[i].tx10;
}
}
else if(tx == 20){
if( a[i].amount20 != 0){
$rootScope.totali += a[i].tx20;
}
}
else if(tx == 30){
if( a[i].amount30 != 0){
$rootScope.totali += a[i].tx30;
}
}
else if(tx == 40){
if( a[i].amount40 != 0){
$rootScope.totali += a[i].tx40;
}
}
}
return $rootScope.totali/100;
}
$scope.validateTypes = function () {
$rootScope.tx10 = 0;
$rootScope.ttx10 = 0;
$rootScope.tx20 = 0;
$rootScope.ttx20 = 0;
$rootScope.tx30 = 0;
$rootScope.ttx30 = 0;
$rootScope.tx40 = 0;
$rootScope.ttx40 = 0;
for (var i=0; i < $rootScope.plus.length; i++){
if( $rootScope.plus[i].amount10 != 0){
$rootScope.tx10 = 1;
$rootScope.ttx10 += $rootScope.plus[i].tx10;
}
if( $rootScope.plus[i].amount20 != 0){
$rootScope.tx20 = 1;
$rootScope.ttx20 += $rootScope.plus[i].tx20;
}
if( $rootScope.plus[i].amount30 != 0){
$rootScope.tx30 = 1;
$rootScope.ttx30 += $rootScope.plus[i].tx30;
}
if( $rootScope.plus[i].amount40 != 0){
$rootScope.tx40 = 1;
$rootScope.ttx40 += $rootScope.plus[i].tx40;
}
}
}
$scope.getMedia = function(idl, tx){
//console.log("ID Layer :" + idl + " dhe TXType eshte " + tx);
Data.get('mediaperTx?evv='+$rootScope.data.evv+'&idl='+idl+'&tx='+tx).then(function(results) {
$rootScope.media = JSON.parse(results[0]);
// console.log($rootScope.media);
$scope.validateMedia();
$rootScope.genericModal(
'Media types',
'views/vendors/template.media.php',
null,
'OK',
null,
null);
});
}
$scope.validateMedia = function() {
// 1 CHIP
// 2 CASH
// 3 CARD
for (var i=0; i < $rootScope.media.length; i++){
if( $rootScope.media[i].PM == '1')
$rootScope.media[i].PM = 'CHIP';
if( $rootScope.media[i].PM == '2')
$rootScope.media[i].PM = 'CASH';
if( $rootScope.media[i].PM == '3')
$rootScope.media[i].PM = 'CARD';
}
}
/* $rootScope.vddevicetype = [];
var groups = {};
for (var i = 0; i < results.length; i++) {
var groupName = results[i].idVendor + '-' + results[i].Titel;
if (!groups[groupName]) {
groups[groupName] = [];
}
groups[groupName].push(results[i]);
}
var myArray = [];
for (var groupName in groups) {
var layers = {};
for (var i = 0; i < groups[groupName].length; i++){
var groupLayer = groups[groupName][i].idTillLayerMapping + '-' + groups[groupName][i].LayerName;
if(!layers[groupLayer]){
layers[groupLayer] = [];
}
layers[groupLayer].push(groups[groupName][i]);
}
myArray.push({vendor: groupName, layers: layers});
}
$rootScope.vddevicetype = myArray;*/
$rootScope.getvddevices = function(){
Data.get('getvddevices?evv='+$rootScope.data.evv).then(function(results) {
$rootScope.layerdevices = results[0];
$rootScope.vendordevices = results[1];
});
}
$scope.saveVendorDevices = function (vd, key){
var type = key.substring(key.indexOf("_") + 1);
if(angular.isUndefined(vd.idTillLayerMapping)){
vd.idTillLayerMapping = 'NULL';
}
Data.get('editvdevices?evv='+$rootScope.data.evv+'&idVendor='+vd.idVendor +'&token='+type
+'&idtlmp=' +vd.idTillLayerMapping +'&amount=' +vd[key]).then(function(results) {
$rootScope.getvddevices($rootScope.data.evv);
});
}
$rootScope.getSetupBreakDown = function(vendorid, layerid)
{
if(angular.isUndefined(layerid)){
layerid = 'NULL';
}
Data.get('gettimes?evv='+$rootScope.data.evv+'&vendorid='+vendorid
+'&itlmp=' +layerid).then(function(results) {
$rootScope.timerange = results[0];
$rootScope.alltimes = results;
$rootScope.newData = $rootScope.timerange;
});
}
$rootScope.editTime = function(vendorid, layerid){
$rootScope.getSetupBreakDown(vendorid,layerid);
if($rootScope.newData.length > 0){
$rootScope.newData = {};
}
$rootScope.genericModal(
'Add SetupDate/TearDownDate',
'views/vendors/template.time.php',
'SAVE',
'Cancel',
function(){
Data.get('edittime?evv='+$rootScope.data.evv+'&idVendor='+vendorid +'&idtlmp=' +layerid +'&setup='+$rootScope.newData.SetupDate +'&breakdown='+$rootScope.newData.TearDownDate).then(function(results) {
$rootScope.getvddevices($rootScope.data.evv);
$rootScope.newData = {};
});
},
null);
}
$scope.editteardowntime = function(vd){
if(angular.isUndefined(vd.idTillLayerMapping)){
vd.idTillLayerMapping = 'NULL';
}
Data.get('editteardowntime?evv='+$rootScope.data.evv+'&idVendor='+vd.idVendor +'&idtlmp=' +vd.idTillLayerMapping
+'&breakdown=' +vd.TearDownDate).then(function(results) {
$rootScope.getvddevices($rootScope.data.evv);
});
}
$scope.changeContact = function(vd){
if(angular.isUndefined(vd.idTillLayerMapping)){
vd.idTillLayerMapping = 'NULL';
}
Data.get('changecontact?evv='+$rootScope.data.evv+'&idVendor='+vd.idVendor +'&idtlmp=' +vd.idTillLayerMapping
+'&idContact=' +vd.idContact).then(function(results) {
$rootScope.getvddevices($rootScope.data.evv);
});
}
$scope.getcpdetails = function(vd){
Data.get('getassignedcp?evv='+$rootScope.data.evv+'&idtlmp=' +vd.idLayer).then(function(results) {
$rootScope.cpdetails = results;
if($rootScope.cpdetails.length == 0){
$rootScope.nocontact = 0;
}
else
$rootScope.nocontact = 1;
});
$rootScope.genericModal(
'Contact Person For ' + vd.LayerName,
'views/vendors/template.cpdetails.php',
null,
'OK',
null,
null);
}
$rootScope.AddOnsOverview = function(vd){
console.log(vd);
$rootScope.getSetupBreakDown(vd.idVendor, vd.idTillLayerMapping);
$rootScope.VendorName = vd.VendorName;
$rootScope.LayerName = vd.LayerName;
$rootScope.TypesOfDevices = vd;
if(angular.isUndefined(vd.idTillLayerMapping)){
vd.idTillLayerMapping = 'NULL';
}
Data.get('addonov?evv='+$rootScope.data.evv+'&idVendor='+vd.idVendor
+'&idtlmp=' +vd.idTillLayerMapping).then(function(results) {
$rootScope.addonoverview = results;
$rootScope.genericModal(
'Summary Add-Ons' + ' - ' + $rootScope.VendorName,
'views/vendors/template.addons.php',
'',
'Close',
null,
null);
});
}
$rootScope.saveWifi = function(ld){
if(angular.isUndefined(ld.idTillLayerMapping)){
ld.idTillLayerMapping = 'NULL';
}
$rootScope.new = ld;
$rootScope.genericModal(
'Edit WiFi',
'views/vendors/template.editwifi.php',
'SAVE',
'Cancel',
function(){
Data.get('editwifi?evv='+$rootScope.data.evv+'&idVendor='+ld.idVendor +'&idtlmp=' +ld.idTillLayerMapping +'&WiFi='+$rootScope.new.WiFi
+'&SSID=' +$rootScope.new.SSID).then(function(results) {
$rootScope.getvddevices($rootScope.data.evv);
});
},
null);
}
$rootScope.saveNotes = function(ld){
if(angular.isUndefined(ld.idTillLayerMapping)){
ld.idTillLayerMapping = 'NULL';
}
$rootScope.new = ld;
$rootScope.genericModal(
'Edit Notes',
'views/vendors/template.editnotes.php',
'SAVE',
'Cancel',
function(){
Data.get('editnotes?evv='+$rootScope.data.evv +'&idVendor='+ld.idVendor +'&idtlmp=' +ld.idTillLayerMapping+
'&Notes='+$rootScope.new.Notes).then(function(results) {
$rootScope.getvddevices($rootScope.data.evv);
});
},
null);
}
$rootScope.getAddOns = function(key, vd)
{
var type = key.split('_')[1];
$rootScope.selectedvendorid = vd.idVendor;
$rootScope.selectedlayerid = vd.idTillLayerMapping;
if(angular.isUndefined($rootScope.selectedlayerid)){
$rootScope.selectedlayerid = 'NULL';
}
Data.get('getaddons?evv='+$rootScope.data.evv+'&token='+type+'&idVendor='+$rootScope.selectedvendorid
+'&idtlmp=' +$rootScope.selectedlayerid).then(function(results) {
$rootScope.addons = results;
});
$rootScope.genericModal(
'AddOns' + ' - ' + vd.VendorName,
'views/vendors/template.addonspertype.php',
'SAVE',
'Cancel',
function(){
for($i = 0; $i < $rootScope.addons.length; $i++)
{
$rootScope.saveVendorAddons($rootScope.addons[$i],$rootScope.addons[$i].Amount);
}
});
}
$rootScope.saveVendorAddons = function (addon, amount){
if(angular.isUndefined($rootScope.selectedlayerid)){
$rootScope.selectedlayerid = 'NULL';
}
Data.get('editaddons?evv='+$rootScope.data.evv+'&idVendor='+$rootScope.selectedvendorid +'&idaddon=' +addon.idAddOn
+'&idtlmp=' +$rootScope.selectedlayerid +'&amount=' + amount + '&token=' +addon.tokenDeviceType).then(function(results) {
});
}
$rootScope.getContactList = function (){
Data.get('getcontacts?evv='+$rootScope.data.evv).then(function(results) {
$rootScope.contactlist = results;
});
}
$rootScope.saveVendorFilter = function(titel){
$rootScope.groupname = titel;
Data.get('createfilter?evv='+$rootScope.data.evv + '&groupname=' +$rootScope.groupname).then(function(results) {
$rootScope.getVendorFilter();
});
}
$rootScope.getVendorFilter = function(){
Data.get('getfilter?evv='+$rootScope.data.evv).then(function(results) {
$rootScope.vendorfilter = results;
});
}
$rootScope.deleteVendorFilter = function(v){
var isConfirmed = confirm("Are you sure you want to delete this group?");
if(isConfirmed)
{
Data.get('deletevfilter?evv='+$rootScope.data.evv+'&idGrouping='+v.idGrouping).then(function(results) {
$rootScope.getVendorFilter();
});
}
else {
return false;
}
}
$rootScope.AssignVendorFilter = function(m){
console.log(m);
Data.get('changefilter?evv='+$rootScope.data.evv+ '&idVendor=' +m.idVendor +'&idGrouping='+m.idGrouping).then(function(results) {
$scope.getOverview();
});
}
}).controller('vendorsCredentialsController', function($scope, $rootScope, Data) {
$rootScope.$watch("data.credentials", function(){
if(!angular.isUndefined($rootScope.data.credentials)){
$scope.credentials = $rootScope.data.credentials;
}
});
}).controller('selftopupController', function($scope, $rootScope, Data) {
$rootScope.$watch("data.selftopups", function(){
if(!angular.isUndefined($rootScope.data.selftopups)){
$scope.selftopups = $rootScope.data.selftopups;
}
});
$scope.obthing = 'device';
$rootScope.validateuidtu = function (){
for (var i=0; i < $rootScope.uidtu.length; i++){
if( $rootScope.uidtu[i].PaymentMethod == '1')
$rootScope.uidtu[i].PaymentMethod = 'CHIP';
if( $rootScope.uidtu[i].PaymentMethod == '2')
$rootScope.uidtu[i].PaymentMethod = 'CASH';
if( $rootScope.uidtu[i].PaymentMethod == '3')
$rootScope.uidtu[i].PaymentMethod = 'CARD';
}
}
$rootScope.stp = {};
$rootScope.getUidtu = function(d){
$rootScope.stp = d;
$rootScope.uidtu = [];
Data.get('uidtu?evv='+$rootScope.data.evv+'&dv='+d).then(function(results) {
$rootScope.uidtu = JSON.parse(results[0]);
$rootScope.validateuidtu();
console.log($rootScope.uidtu);
$rootScope.genericModal(
d,
'views/selftopup/template.uidtopup.php',
null,
'OK',
null,
null);
});
}
$scope.changeorder = function(c){
$scope.obthing = c;
}
$rootScope.openstpReport = function(id){
Data.get('getzreport?evv='+$rootScope.data.evv+'&idzp=' + id ).then(function(results) {
$rootScope.stpreport = JSON.parse(results[0]);
$rootScope.billreport = JSON.parse(results[1]);
$rootScope.cardreport = JSON.parse(results[2]);
$rootScope.totalcash = JSON.parse(results[3]);
$rootScope.totalcard = JSON.parse(results[4]);
$rootScope.genericModal('ZReport ECR: ' + $rootScope.stpreport[0].ECR, "views/selftopup/template.stpzreport.php", '', 'Close', null, null)
});
}
}).controller('helpdeskController', function($scope, $rootScope) {
$scope.helpdesk = [];
$rootScope.$watch("data.helpdesk", function(){
if(!angular.isUndefined($rootScope.data.helpdesk))
$scope.helpdesk = $rootScope.data.helpdesk;
});
$scope.sendEmail = function(u){
$rootScope.data.helpdeskemail = u.email;
$rootScope.genericModal(
'Send email',
'views/modal.sendemail.php',
null,
'Send',
null,
null);
};
}).controller('chipsController', function($scope, $rootScope, Data, $timeout) {
$rootScope.addPreloaded = {};
$rootScope.addhditem = [];
$rootScope.activetabC = 1;
$scope.ctab = 1;
$timeout(function () {
$rootScope.gettitel();
$rootScope.getstatus();
$rootScope.getseverity();
}, 500).then(function () {
});
$rootScope.$watch("data.chips", function () {
if (!angular.isUndefined($rootScope.data.chips))
$scope.chips = $rootScope.data.chips;
$scope.blockedchipstx = $rootScope.data.blockedchipstx;
console.log($scope.chips);
});
$scope.setc = function (i) {
$scope.ctab = i;
}
$rootScope.gettitel = function () {
Data.get('gettitel?evv=' + $rootScope.data.evv).then(function (results) {
$rootScope.quickfill = results;
console.log($rootScope.quickfill);
});
}
$rootScope.getstatus = function () {
Data.get('getstatus?evv=' + $rootScope.data.evv).then(function (results) {
$rootScope.status = results;
console.log($rootScope.status);
});
}
$rootScope.getseverity = function () {
Data.get('getseverity?evv=' + $rootScope.data.evv).then(function (results) {
$rootScope.severity = results;
console.log($rootScope.severity);
});
}
$rootScope.blockChip = function (c) {
console.log(c);
/*Data.get('blockchip?evv='+$rootScope.data.evv+'&uid='+c).then(function(results) {
console.log(JSON.parse(results[0]));
});*/
}
$rootScope.setactiveC = function (ind) {
$rootScope.activetabC = ind;
}
$rootScope.addprelvalues = function (c) {
$rootScope.addPreloaded.uid = c.uid;
$rootScope.addPreloaded.idTicket = c.idTicket;
$rootScope.addPreloaded.idChip = c.idChip;
$rootScope.addPreloaded.barcode = c.barcode;
$rootScope.addPreloaded.sc = 0;
$rootScope.addPreloaded.fc = "";
$rootScope.genericModal(
'Add Preloaded Value',
'views/chips/template.addpreloadedvalues.php',
'SAVE',
'Cancel',
function () {
Data.get('addprelvalues?evv=' + $rootScope.data.evv + '&idTicket=' + c.idTicket + '&idChip=' + c.idChip
+ '&barcode=' + c.barcode + '&fc=' + $rootScope.addPreloaded.fc + '&sc=' + $rootScope.addPreloaded.sc).then(function (results) {
$rootScope.getReports($rootScope.data.evv);
});
},
null);
}
$rootScope.fixanomalie = function (c) {
var d = confirm("Are you sure you want to fix this record?");
if (d) {
Data.get('fixanomal?evv=' + $rootScope.data.evv + '&dbid=' + c.dbid + '&uid=' + c.UID + '&sessionhash=' + c.SessionHash).then(function (results) {
$rootScope.getModalData('ctran', $rootScope.data.currentchip);
});
}
}
$rootScope.unblockmoney = function (c) {
var d = confirm("Are you sure you want to release the money for this UID?");
if (d) {
Data.get('toschip?evv=' + $rootScope.data.evv + '&UID2=' + $rootScope.data.currentchip + '&sessionhash=' + c.SessionHash).then(function (results) {
$rootScope.getModalData('ctran', $rootScope.data.currentchip);
});
}
}
$rootScope.addhditem = function (c) {
$rootScope.addhditem = c;
$rootScope.genericModal(
'Add Helpdesk Item',
'views/chips/template.addhditems.php',
'SAVE',
'Cancel',
function () {
$rootScope.Req.post('addhditem?evv=' + $rootScope.data.evv, [$rootScope.addhditem]).then(function (results) {
$rootScope.addhditem = [];
});
},
null);
}
}).controller('systemController', function($scope, $rootScope) {
}).controller('reportsController', function($scope, $rootScope, $timeout, Data) {
$rootScope.allowedusers = ['Administrator', 'Job', 'Daniel Taga'];
$rootScope.$watch("data.zreports", function(){
if(!angular.isUndefined($rootScope.data.zreports))
$scope.zreports = $rootScope.data.zreports;
});
$scope.openZ = function(z){
Data.get('report?evv='+$rootScope.data.evv+'&z=' + z ).then(function(results) {
$rootScope.data.zreport = results;//JSON.parse(results);
if(!angular.isUndefined($rootScope.data.zreport.VAT.ReportVAT.VATType)){
var object = $rootScope.data.zreport.VAT.ReportVAT;
$rootScope.data.zreport.VAT.ReportVAT = [];
$rootScope.data.zreport.VAT.ReportVAT.push(object);
}
if(!angular.isUndefined($rootScope.data.zreport.PLUs.XReportPLU.PLU)){
var objectPLU = $rootScope.data.zreport.PLUs.XReportPLU;
$rootScope.data.zreport.PLUs.XReportPLU = [];
$rootScope.data.zreport.PLUs.XReportPLU.push(objectPLU);
}
$rootScope.genericModal('ZReport ECR: ' + $rootScope.data.zreport.ECR, "views/modal.zreport.php", '', 'Close', null, null)
});
};
$scope.deleteZ = function(z){
$rootScope.confirmModal(
'Confirm',
'Do you want to remove ZCount '+z.ZCount+' of '+ z.device +'\'s ZReport?',
'Yes',
'Cancel',
function(){
Data.get('dreport?evv='+$rootScope.data.evv+'&z=' + z.zrepid ).then(function(results) {
$rootScope.getReports($rootScope.data.evv);
});
}, null);
};
}).controller('devicesController', function($scope, $rootScope) {
$rootScope.$watch("data.devices", function(){
if(!angular.isUndefined($rootScope.data.devices))
$scope.devices = $rootScope.data.devices;
});
}).controller('anomaliesController', function($scope, $rootScope, Data) {
$rootScope.$watch("data.anomalies", function(){
if(!angular.isUndefined($rootScope.data.anomalies))
$scope.anomalies = $rootScope.data.anomalies;
$scope.data.unln = JSON.parse($scope.anomalies[0]);
$scope.data.dup = JSON.parse($scope.anomalies[1]);
$scope.data.cminuses = JSON.parse($scope.anomalies[2]);
$scope.data.minuseschips = JSON.parse($scope.anomalies[3]);
$scope.data.pm = JSON.parse($scope.anomalies[4]);
$scope.data.txdupes = JSON.parse($scope.anomalies[5]);
$scope.data.notpickedup = JSON.parse($scope.anomalies[6]);
$scope.data.missingtopup = JSON.parse($scope.anomalies[7]);
$scope.data.blockedchips = JSON.parse($scope.anomalies[8]);
});
/* $scope.fchip = function(o){
//console.log(o);
$rootScope.confirmModal(
'Confirmation',
'Are you sure you want to release the money for the first UID?',
'Yes',
'Cancel',
function(){
Data.get('tofchip?dbid='+o.dbid+'&evv='+$rootScope.data.evv+'&UID='+o.UID+'&id='+o.id).then(function(results) {
$rootScope.loadAnomalies();
});
},
null);
};*/
/* $scope.schip = function(o){
//console.log(o);
$rootScope.confirmModal(
'Confirmation',
'Are you sure you want to release the money for the second UID?',
'Yes',
'Cancel',
function(){
Data.get('toschip?dbid='+o.dbid+'&evv='+$rootScope.data.evv+'&UID='+o.UID+'&id='+o.id+'&UID2='+o.UID2).then(function(results) {
$rootScope.loadAnomalies();
});
},
null);
};
*/
$scope.deletetxdupes = function(t){
console.log(t);
Data.get('deletetxdupes?txlog='+ t.txlog +'&evv='+$rootScope.data.evv).then(function(results) {
$rootScope.getReports($rootScope.data.evv);
});
};
$scope.getfailedperchip = function(o){
//console.log(o);
Data.get('failedtxperchip?evv='+$rootScope.data.evv+'&UID='+o.UID).then(function(results) {
$rootScope.data.failedtx = results;
$scope.failedtx = $rootScope.data.failedtx;
$scope.data.failedtopup = JSON.parse($scope.failedtx[0]);
$scope.data.failedpurchase = JSON.parse($scope.failedtx[1]);
$scope.data.failedcancellation = JSON.parse($scope.failedtx[2]);
$rootScope.genericModal(
'Failed transactions for this chip',
'views/anomalies/template.failedtxperchip.php',
null,
'Close',
null,
null);
});
};
$scope.getFailed = function(){
Data.get('failedtrans?evv='+$rootScope.data.evv).then(function(results) {
console.log(results);
$rootScope.data.failedtrans = results;
$rootScope.genericModal(
'Failed transactions',
'views/anomalies/template.failedtrans.php',
null,
'Close',
null,
null);
});
};
}).controller('vendorviewController', function($scope, $rootScope, Data, $timeout, localStorageService, $sce, $location) {
$scope.avendor = {};
$scope.layers = [];
$rootScope.newRole = {};
$rootScope.newArticle = {};
$rootScope.thelayer = {};
$rootScope.data.ona = 0;
$scope.data.addArt = 0;
//$rootScope.data.plus = [];
$scope.avendor = localStorageService.get("thevendor");
//$scope.layers = localStorageService.get("thelayers");
$rootScope.newArticle.selectedB = '#A9A9A9';
$rootScope.newArticle.selectedT = '#000000';
$rootScope.TxTypes = [
{
id: 10,
name: 'Top Up'
},{
id: 20,
name: 'Pay'
}, {
id: 30,
name: 'Refund'
},
{
id: 40,
name: 'Cashout'
}];
$scope.vid = $scope.avendor.vendorid;
$scope.vname = $scope.avendor.layers[0].vendorName;
$rootScope.data.action = "";
$rootScope.fp = false;
$rootScope.at = false;
$timeout(function() {
$rootScope.getPlus($scope.avendor);
$rootScope.getticketroles();
}, 500).then(function() {
});
$timeout(function() {
$rootScope.getArticleDetails();
}, 500).then(function() {
});
$rootScope.togglefp = function(){
if($rootScope.fp == false)
$rootScope.fp = true;
else if($rootScope.fp == true)
$rootScope.fp = false;
$rootScope.at = false;
}
$rootScope.toggleat = function(){
if($rootScope.at == false){
$rootScope.at = true;
$rootScope.fp = false;}
else if($rootScope.at == true)
$rootScope.at = false;
}
/*$rootScope.$watch("data.avendor", function(){
if(!angular.isUndefined($rootScope.data.avendor))
$scope.avendor = $rootScope.data.avendor;
$scope.layers = $scope.avendor.layers;
$scope.vid = $scope.avendor.vendorid;
$scope.vname = $scope.avendor.layers[0].vendorName;
localStorageService.set("thevendor", $rootScope.data.avendor);
});*/
$rootScope.$watch("data.layers", function(){
if(!angular.isUndefined($rootScope.data.layers))
$scope.layers = $rootScope.data.layers;
});
$scope.rgb2hex = function (rgb){
rgb = rgb.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);
return (rgb && rgb.length === 4) ? "#" +
("0" + parseInt(rgb[1],10).toString(16)).slice(-2) +
("0" + parseInt(rgb[2],10).toString(16)).slice(-2) +
("0" + parseInt(rgb[3],10).toString(16)).slice(-2) : '';
}
$scope.showac = function(){
if($scope.data.addArt == 0)
$scope.data.addArt = 1;
else if($scope.data.addArt == 1)
$scope.data.addArt = 0;
$rootScope.newArticle = {};
$rootScope.newArticle.selectedB = '#A9A9A9';
$rootScope.newArticle.selectedT = '#000000';
$rootScope.getArticleDetails();
}
$rootScope.generaterole = function(){
$rootScope.newRole = {};
$rootScope.generateletter();
$rootScope.getticketroles();
$rootScope.genericModal(
'Create new role',
'views/tickettypes/template.addroles.article.php',
'SAVE',
'Cancel',
function(){
Data.get('addroles?evv='+$rootScope.data.evv+'&titel='+$rootScope.newRole.Titel
+'&from='+$rootScope.newRole.GueltigVon +'&to='+$rootScope.newRole.GueltigBis
+'&keyTag='+$rootScope.data.letter.role).then(function(results) {
$rootScope.getticketroles();
});
},
null);
}
$rootScope.generateletter = function(){
$rootScope.getticketroles();
Data.get('generateletter?evv='+$rootScope.data.evv).then(function(results) {
$rootScope.data.letter = results[0];
console.log($rootScope.data.letter);
});
}
$scope.saveArticle = function(){
$rootScope.getticketroles();
console.log("saveArticle");
if($rootScope.fp == false){
if(angular.isUndefined($rootScope.newArticle.unitFraction) || angular.isUndefined($rootScope.newArticle.alertAmount)){
$rootScope.newArticle.unitFraction = '0';
$rootScope.newArticle.alertAmount = '0';
}
if($rootScope.at == true){
$rootScope.newArticle.name = $rootScope.newArticle.name + ' |' + $rootScope.newArticle.keyTag;
console.log($rootScope.newArticle.name);
}
Data.get('plucreate?evv='+$rootScope.data.evv +'&p='+$scope.avendor.vendorid
+'&pg='+$rootScope.newArticle.productgroup+'&titel='+$rootScope.newArticle.name
+'&price='+$rootScope.newArticle.price+'&vattype='+$rootScope.newArticle.vat+'&txtype='+$rootScope.newArticle.txtype.id
+'&bc='+$rootScope.newArticle.selectedB.replace('#', '')
+'&tc='+$rootScope.newArticle.selectedT.replace('#', '')
+'&unitFraction='+$rootScope.newArticle.unitFraction
+'&alertAmount='+$rootScope.newArticle.alertAmount).then(function(results) {
console.log(results);
$rootScope.getPlus($scope.avendor);
$scope.clearArticle();
$rootScope.fp = false;
});
}
else
{
console.log("Free Price!!!");
Data.get('createfp?evv='+$rootScope.data.evv +'&p='+$scope.avendor.vendorid
+'&pg='+$rootScope.newArticle.productgroup+'&titel='+$rootScope.newArticle.name
+'&vattype='+$rootScope.newArticle.vat+'&txtype='+$rootScope.newArticle.txtype.id
+'&bc='+$rootScope.newArticle.selectedB.replace('#', '')
+'&tc='+$rootScope.newArticle.selectedT.replace('#', '')).then(function(results) {
console.log(results);
$rootScope.getPlus($scope.avendor);
$scope.clearArticle();
$rootScope.fp = false;
});
}
}
$scope.clearArticle = function(){
$rootScope.newArticle = {};
$rootScope.newArticle.selectedB = '#A9A9A9';
$rootScope.newArticle.selectedT = '#000000';
$rootScope.getArticleDetails();
}
$rootScope.getticketroles = function(){
Data.get('getticketroles?evv='+$rootScope.data.evv).then(function(results) {
$rootScope.roles = results;
});
}
$rootScope.createplu = function(){
$rootScope.newArticle = {};
$rootScope.newArticle.selectedB = '#A9A9A9';
$rootScope.newArticle.selectedT = '#000000';
$rootScope.getArticleDetails();
$rootScope.genericModal(
'Create new article',
'views/vendorview/template.createplu.php',
'SAVE',
'Cancel',
function(){
console.log($rootScope.newArticle);
Data.get('plucreate?evv='+$rootScope.data.evv +'&p='+$scope.avendor.vendorid
+'&pg='+$rootScope.newArticle.productgroup+'&titel='+$rootScope.newArticle.name
+'&price='+$rootScope.newArticle.price+'&vattype='+$rootScope.newArticle.vat+'&txtype='+$rootScope.newArticle.txtype.id
+'&bc='+$rootScope.newArticle.selectedB.replace('#', '')
+'&tc='+$rootScope.newArticle.selectedT.replace('#', '')).then(function(results) {
console.log(results);
$rootScope.getPlus($scope.avendor);
});
},
null);
}
$rootScope.getArticleDetails = function(){
console.log("getArticleDetails");
Data.get('pludetails?evv='+$rootScope.data.evv).then(function(results) {
$rootScope.details = results;
$rootScope.vats = JSON.parse($rootScope.details[0]);
$rootScope.vats = $rootScope.vats[0].value.replace('[','').replace(']','').split(',');
for(var i=0;i<$rootScope.vats.length;i++){
$rootScope.vats[i] = $rootScope.vats[i].concat('.00').trim();
}
console.log($rootScope.vats);
$rootScope.pgroups = JSON.parse($rootScope.details[1]);
console.log($rootScope.pgroups);
});
}
// $timeout(function() {
// $rootScope.getArticleDetails();
// }, 500).then(function() {
// });
$scope.setOnEdit = function (plu){
console.log(plu);
if (plu.Price == 0 && plu.PriceType == 2)
$rootScope.fp = true;
else
$rootScope.fp = false;
$rootScope.getArticleDetails();
$rootScope.newArticle.blabel = plu.keyCaption;
$rootScope.newArticle.dbid = plu.dbid;
$rootScope.newArticle.name = plu.Titel;
$rootScope.newArticle.price = plu.Price;
$rootScope.newArticle.productgroup = plu.productgroup;
$rootScope.newArticle.selectedB = $scope.rgb2hex("rgb("+ plu.keyColor+")");
$rootScope.newArticle.selectedT = $scope.rgb2hex("rgb("+ plu.keyFRGColor+")");
$rootScope.newArticle.etldbid = plu.etldbid;
$rootScope.newArticle.unitFraction = plu.unitFraction;
$rootScope.newArticle.alertAmount = plu.alertAmount;
$timeout(function() {
/*for(var i=0;i<$rootScope.vats.length;i++){
$rootScope.vats[i] = parseInt($rootScope.vats[i]);
}*/
/* for(var i=0;i<$rootScope.pgroups.length;i++){
if(plu.productgroup == $rootScope.pgroups[i].PGNumber)
$rootScope.newArticle.group = $rootScope.newArticle[i];
}
*/
if(plu.TXType == "10")
$rootScope.newArticle.txtype = $rootScope.TxTypes[0];
else if(plu.TXType == "20")
$rootScope.newArticle.txtype = $rootScope.TxTypes[1];
else if(plu.TXType == "30")
$rootScope.newArticle.txtype = $rootScope.TxTypes[2];
else if(plu.TXType == "40")
$rootScope.newArticle.txtype = $rootScope.TxTypes[3];
var vati = parseInt(plu.VATTYPE.slice(0, -3));
for(var i=0;i<$rootScope.vats.length;i++){
if (vati == $rootScope.vats[i])
$rootScope.newArticle.vat = $rootScope.vats[i];
}
}, 500).then(function() {
});
$rootScope.genericModal(
'Create new article',
'views/vendorview/template.createplu.php',
'SAVE',
'Cancel',
function(){
console.log($rootScope.newArticle.name);
if($rootScope.fp == false && plu.Tag != ""){
$rootScope.newArticle.name = $rootScope.newArticle.name.concat(' |',plu.Tag)
Data.get('pluedit?evv='+$rootScope.data.evv+'&p='+$scope.avendor.vendorid +'&PluDbId='+$rootScope.newArticle.dbid
+'&pg='+$rootScope.newArticle.productgroup+'&titel='+$rootScope.newArticle.name
+'&price='+$rootScope.newArticle.price
+'&vattype='+$rootScope.newArticle.vat+'&txtype='+$rootScope.newArticle.txtype.id
+'&bc='+$rootScope.newArticle.selectedB.replace('#', '')
+'&tc='+$rootScope.newArticle.selectedT.replace('#', '')
+'&unitFraction='+$rootScope.newArticle.unitFraction
+'&alertAmount='+$rootScope.newArticle.alertAmount).then(function(results) {
console.log(results);
$rootScope.getPlus($scope.avendor);
$scope.clearArticle();
});
}
else if ($rootScope.fp == false){
Data.get('pluedit?evv='+$rootScope.data.evv+'&p='+$scope.avendor.vendorid +'&PluDbId='+$rootScope.newArticle.dbid
+'&pg='+$rootScope.newArticle.productgroup+'&titel='+$rootScope.newArticle.name
+'&price='+$rootScope.newArticle.price
+'&vattype='+$rootScope.newArticle.vat+'&txtype='+$rootScope.newArticle.txtype.id
+'&bc='+$rootScope.newArticle.selectedB.replace('#', '')
+'&tc='+$rootScope.newArticle.selectedT.replace('#', '')
+'&unitFraction='+$rootScope.newArticle.unitFraction
+'&alertAmount='+$rootScope.newArticle.alertAmount).then(function(results) {
console.log(results);
$rootScope.getPlus($scope.avendor);
$scope.clearArticle();
});
}
else{
console.log("Waiting for free price service edit!!");
Data.get('plufpedit?evv='+$rootScope.data.evv+'&p='+$scope.avendor.vendorid +'&PluDbId='+$rootScope.newArticle.dbid
+'&pg='+$rootScope.newArticle.productgroup+'&titel='+$rootScope.newArticle.name
+'&vattype='+$rootScope.newArticle.vat+'&txtype='+$rootScope.newArticle.txtype.id
+'&bc='+$rootScope.newArticle.selectedB.replace('#', '')
+'&tc='+$rootScope.newArticle.selectedT.replace('#', '')).then(function(results) {
console.log(results);
$rootScope.getPlus($scope.avendor);
$scope.clearArticle();
});
}
},
function(){
$scope.clearArticle();
}
);
}
$scope.SavePrice = function (p) {
console.log(p);
Data.get('editprice?evv='+$rootScope.data.evv+'&pludbid='+p.dbid+'&price=' + p.Price ).then(function(results) {
$rootScope.getPlus($scope.avendor);
});
}
$scope.SaveName = function (p) {
console.log(p);
if(p.Tag != ""){
p.Titel = p.Titel.concat(' |',p.Tag);
Data.get('editname?evv='+$rootScope.data.evv+'&pludbid='+p.dbid+'&name=' + p.Titel ).then(function(results) {
$rootScope.getPlus($scope.avendor);
});
}
else{
Data.get('editname?evv='+$rootScope.data.evv+'&pludbid='+p.dbid+'&name=' + p.Titel ).then(function(results) {
$rootScope.getPlus($scope.avendor);
});
}
}
$scope.SaveVat = function (p) {
console.log(p);
Data.get('editvat?evv='+$rootScope.data.evv+'&pludbid='+p.dbid+'&vat='+p.VATTYPE ).then(function(results) {
});
}
$scope.SaveGroup = function (p) {
console.log(p);
Data.get('editproductgroup?evv='+$rootScope.data.evv+'&pludbid='+p.dbid+'&pgnumber='+p.productgroup ).then(function(results) {
});
}
$scope.editunitfra = function (p) {
console.log(p);
Data.get('editunitfra?evv='+$rootScope.data.evv+'&pludbid='+p.dbid+'&unitFraction='+p.unitFraction).then(function(results) {
});
}
$scope.editaamount = function (p) {
console.log(p);
Data.get('editaamount?evv='+$rootScope.data.evv+'&pludbid='+p.dbid+'&alertAmount='+p.alertAmount).then(function(results) {
});
}
$scope.deleteP = function (plu){
console.log(plu);
$rootScope.confirmModal(
'Confirm',
'Do you want to delete the article?',
'Yes',
'Cancel',
function(){
console.log($rootScope.newArticle.name);
Data.get('pludelete?evv='+$rootScope.data.evv+'&PluDbId='+plu.dbid+'&plu='+plu.PLU ).then(function(results) {
$rootScope.getPlus($scope.avendor);
});
}
, null);
}
$scope.exportplus = function(){
var url = "https://dashboard.youchip.com/requests/guestclient/exportexcel.php?evv="+$rootScope.data.evv+"&v="+$scope.vid;
console.log(url);
window.open(url);
};
$scope.importplus = function(){
$rootScope.data.action = $sce.trustAsResourceUrl("https://dashboard.youchip.com/requests/guestclient/importexcel.php?evv="+$rootScope.data.evv+"&p="+$scope.vid);
$rootScope.genericModal(
'Import articles',
'views/vendorview/template.importarticles.php',
'Import',
'Close',
function(){
angular.element('#theform').submit();
$timeout(function(){
window.location.reload();
}, 10000);
},
null
);
};
$rootScope.mbyllmodal = function(){
$("#genericModal").modal("hide");
console.log("Close modal!!!");
};
}).controller('posteventController', function($scope, $rootScope, Data, localStorageService) {
$rootScope.Ind = 1;
$rootScope.setInd = function(ind)
{
$rootScope.Ind = ind;
if($rootScope.Ind == 2)
$scope.getOverview();
};
$scope.getOverview = function(){
Data.get('refundingov?evv='+$rootScope.data.evv).then(function(results) {
$rootScope.fee = results[0];
$rootScope.refundlist = results[1];
});
};
}).controller('tlmappingController', function($scope, $rootScope, Data, localStorageService) {
$scope.pages = [];
$scope.currentpage = 1;
$scope.data.linkbuttons = [];
$scope.data.deposits = [];
$scope.sellink = {};
$rootScope.from = false;
$rootScope.to = false;
$scope.data.caktivizofilter = 0;
$scope.data.PM = [{"code":"1", "name":"CHIP"},
{"code":"4", "name":"CHIP and CASH"},
{"code":"2", "name":"CASH and CARD"},
{"code":"3", "name":"CHIP, CASH and CARD"}];
$scope.data.indi = 0;
$scope.nextva = function(){
if($scope.data.indi <= $rootScope.data.varticles.length - 14)
$scope.data.indi += 14;
else
$scope.data.indi = 0;
}
$scope.prevva = function(){
if($scope.data.indi != 0)
$scope.data.indi -= 14;
else
$scope.data.indi = $rootScope.getInt($rootScope.data.varticles.length/14) * 14 ;
}
$scope.setthefilter = function(){
console.log($scope.arsearch);
if($scope.arsearch != '')
$scope.data.caktivizofilter = 1;
else
$scope.data.caktivizofilter = 0;
}
if(angular.isUndefined($rootScope.data.lmlayer))
$rootScope.location.path("/vendors");
$rootScope.$watch("data.varticles", function(){
if(!angular.isUndefined($rootScope.data.varticles)){
$scope.varticles = $rootScope.data.varticles;
}
});
$rootScope.$watch("data.tmplus", function(){
if(!angular.isUndefined($rootScope.data.tmplus)){
$scope.tmplus = $rootScope.data.tmplus;
var pagesnr = $scope.tmplus.length / 25;
$scope.pages = [];
for(var i = 0; i < pagesnr; i++)
$scope.pages.push(i+1);
}
});
$scope.copylayer = function(){
console.log($rootScope.data.lmlayer);
$rootScope.confirmModal(
'Confirmation',
'Are you sure you want to clone this layer ? A new layer will be created with the same data!',
'Yes',
'Cancel',
function(){
Data.get('copylayer?evv='+$rootScope.data.evv+'&vname='+$rootScope.data.lmlayer.vendorName+'&idvendor='+$rootScope.data.lmlayer.idVendor+'&paybutton='+$rootScope.data.lmlayer.paybutton
+'&idLayer='+$rootScope.data.lmlayer.idLayer+'&receiptheader='+ $rootScope.data.lmlayer.receiptheader +'&receiptfooter='+ $rootScope.data.lmlayer.receiptfooter).then(function(results) {
$rootScope.confirmModal(
'Confirmation',
'Layer is successfuly cloned!',
'Okay',
'',
null,
null);
});
},
null);
}
$scope.showPM = function(){
for (var i = $scope.data.PM.length - 1; i >= 0; i--) {
if($scope.data.PM[i].code == $rootScope.data.lmlayer.paybutton)
$scope.data.thislpay = $scope.data.PM[i];
}
}
$scope.showPM();
$scope.rgb2hex = function (rgb){
rgb = rgb.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);
return (rgb && rgb.length === 4) ? "#" +
("0" + parseInt(rgb[1],10).toString(16)).slice(-2) +
("0" + parseInt(rgb[2],10).toString(16)).slice(-2) +
("0" + parseInt(rgb[3],10).toString(16)).slice(-2) : '';
}
$scope.getlinkbutton = function(){
Data.get('getlinkbutton?evv='+$rootScope.data.evv+'&idlayer=' + $rootScope.data.lmlayer.idLayer ).then(function(results) {
$scope.data.linkbuttons = results[0];
console.log($scope.data.linkbuttons);
});
};
$scope.getlinkbutton();
$scope.setPage = function(p){
$scope.currentpage = p;
};
$scope.getdeposits = function(){
Data.get('getdeposits?evv='+$rootScope.data.evv+'&vendorid='+$rootScope.data.lmvendor.vendorid+'&idlayer=' + $rootScope.data.lmlayer.idLayer +'¶m=' + $rootScope.data.lmlayer.Parameter ).then(function(results) {
$scope.data.deposits = results[0];
console.log($scope.data.deposits);
});
};
$rootScope.getlayers = function(){
Data.get('getlayers?evv='+$rootScope.data.evv+'&p=' + $rootScope.data.lmvendor.vendorid).then(function(results) {
$rootScope.data.lay = results;
console.log($rootScope.data.lay);
});
};
$scope.editva = function(a){
$rootScope.data.lmlayer.Parameter = a.Parameter;
$scope.getdeposits();
console.log($rootScope.data.lmlayer);
console.log($rootScope.data.lmvendor);
$rootScope.data.vArticle = angular.copy(a);
$rootScope.data.vArticle.keyColor = $scope.rgb2hex("rgb("+$rootScope.data.vArticle.keyColor+")");
$rootScope.data.vArticle.keyFRGColor = $scope.rgb2hex("rgb("+$rootScope.data.vArticle.keyFRGColor+")");
$rootScope.genericModal(
'Edit color',
'views/tlmapping/template.editva.php',
'SAVE',
'Cancel',
function(){
console.log($rootScope.data.vArticle);
/*Data.get('editcolor?evv='+$rootScope.data.evv+'&idFunctionMapping='+$rootScope.data.vArticle.idFunctionMapping +'&idlayer='+ $rootScope.data.lmlayer.idLayer +'&idVendor=' +$rootScope.data.lmvendor.vendorid +'¶meter='+$rootScope.data.vArticle.Parameter +'&keynr=' + $rootScope.data.vArticle.keyNr +'&caption=' + $rootScope.data.vArticle.keyCaption
+'&bc='+$rootScope.data.vArticle.keyColor +'&fc='+$rootScope.data.vArticle.keyFRGColor ).then(function(results) {
$rootScope.loadtlmapping($rootScope.data.lmvendor, $rootScope.data.lmlayer);
});*/
$rootScope.Req.post('editcolor?evv='+$rootScope.data.evv+'&keyCaption=' + $rootScope.data.vArticle.keyCaption, [$rootScope.data.vArticle, $rootScope.data.lmlayer.idLayer, $rootScope.data.lmvendor.vendorid]).then(function(results) {
$rootScope.loadtlmapping($rootScope.data.lmvendor, $rootScope.data.lmlayer);
$scope.getlinkbutton();
$scope.getdeposits();
});
},
null);
};
$scope.addpage = function(){
console.log($rootScope.data.lmlayer);
$rootScope.confirmModal(
'Confirm',
'Do you want to create a new page?',
'Yes',
'Cancel',
function(){
Data.get('addpage?evv='+$rootScope.data.evv+'&idtillaymap=' + $rootScope.data.lmlayer.idLayer ).then(function(results) {
//console.log(results);
$rootScope.loadtlmapping($rootScope.data.lmvendor, $rootScope.data.lmlayer);
$scope.getlinkbutton();
});
}, null);
};
$rootScope.choosefrom = function (){
$rootScope.from = true;
$rootScope.to = false;
};
$rootScope.chooseto = function (){
$rootScope.from = false;
$rootScope.to = true;
};
$rootScope.opencopymodal = function (){
$rootScope.getlayers();
$rootScope.layer = {};
$rootScope.genericModal(
'Copy From/To this layer',
'views/tlmapping/template.copyfromto.php',
'SAVE',
'Cancel',
function(){
if($rootScope.from == true){
Data.get('copyfrom?evv='+$rootScope.data.evv+'&idlayer=' + $rootScope.data.lmlayer.idLayer +'&fromlayer=' +$rootScope.layer.idLayer).then(function(results) {
console.log(results);
$rootScope.loadtlmapping($rootScope.data.lmvendor, $rootScope.data.lmlayer);
$rootScope.from =false;
});
}
else if ($rootScope.to == true){
Data.get('copyto?evv='+$rootScope.data.evv+'&idlayer=' + $rootScope.data.lmlayer.idLayer +'&tolayer=' +$rootScope.layer.idLayer).then(function(results) {
console.log(results);
$rootScope.loadtlmapping($rootScope.data.lmvendor, $rootScope.data.lmlayer);
$rootScope.to =false;
});
}
},
null);
};
$scope.onDropComplete=function(data,evt,lm){
console.log("drop success, data:", data, " at ", lm);
if(data.pagenr){
Data.get('setpagelink?evv='+$rootScope.data.evv+'&pagenr=' + data.pagenr +'&button=' + data.button +'&idlayer=' + lm.idTillLayerMapping +'&keyNr=' + lm.keyNr).then(function(results) {
console.log(results);
$rootScope.loadtlmapping($rootScope.data.lmvendor, $rootScope.data.lmlayer);
});
}
else if(data.Titel == "DELETE ARTICLE"){
console.log("Delete this article!!!");
Data.get('deleteav?evv='+$rootScope.data.evv+'&idlayer=' + lm.idTillLayerMapping +'&keyNr=' + lm.keyNr).then(function(results) {
console.log(results);
$rootScope.loadtlmapping($rootScope.data.lmvendor, $rootScope.data.lmlayer);
$scope.getlinkbutton();
//$rootScope.data.varticles = results;
});
}
else if(data.ProductGroup == "Deposit" && lm.Parameter != null){
console.log("Deposit article!!!");
if(lm.Parameter.search(",") >= 0)
alert("Only one deposit can be used for an article!");
else
Data.get('depositmapping?evv='+$rootScope.data.evv+'&idlayer=' + lm.idTillLayerMapping +'&keyNr=' + lm.keyNr + '&PLU=' + lm.Parameter + '¶m=' +data.PLU).then(function(results) {
console.log(results);
$rootScope.loadtlmapping($rootScope.data.lmvendor, $rootScope.data.lmlayer);
});
}
else{
console.log("ADD THIS ARTICLE!!!");
Data.get('domapping?evv='+$rootScope.data.evv+'&PLU=' + data.PLU +'&titel=' + data.Titel +'&idlayer=' + lm.idTillLayerMapping +'&keyNr=' + lm.keyNr
+'&bc=' + data.keyColor+'&fc=' + data.keyFRGColor).then(function(results) {
console.log(results);
$rootScope.loadtlmapping($rootScope.data.lmvendor, $rootScope.data.lmlayer);
//$rootScope.data.varticles = results;
});
}
}
}).controller('usersController', function($scope, $rootScope) {
$rootScope.newUser = {};
$rootScope.permissions = {};
$rootScope.AccessTypes = [
{
id: 1,
name: 'Administrator'
},{
id: 2,
name: 'Promoter'
}, {
id: 3,
name: 'Vendor'
}];
$rootScope.$watch("data.users", function(){
if(!angular.isUndefined($rootScope.data.users))
$scope.users = $rootScope.data.users;
console.log($scope.users);
});
$scope.openUserDetails = function(u){
$rootScope.data.currentUser = u;
$rootScope.Req.post('usersdetails?evv='+$rootScope.data.evv, [$rootScope.data.currentUser]).then(function(results) {
$rootScope.data.views = results[0];
$rootScope.data.databases = results[1];
console.log(results[1]);
});
};
$scope.createuser = function (){
$rootScope.newUser = {};
$rootScope.genericModal(
'Add new user',
'views/users/template.createuser.php',
'SAVE',
'Cancel',
function(){
console.log($rootScope.newUser);
$rootScope.Req.get('createuser?evv='+$rootScope.data.evv +'&name='+$rootScope.newUser.name+'&username='+$rootScope.newUser.username
+'&password='+$rootScope.newUser.password+'&accesstype='+$rootScope.newUser.accessType).then(function(results) {
$rootScope.loadUsers();
});
},
null);
};
$scope.edituser = function (u){
console.log(u);
$rootScope.newUser.name = u.name;
$rootScope.newUser.username = u.username;
$rootScope.newUser.password = u.password;
$rootScope.newUser.dbid = u.dbid;
$rootScope.newUser.accessType = u.accessType;
$rootScope.genericModal(
'Edit user',
'views/users/template.createuser.php',
'SAVE',
'Cancel',
function(){
$rootScope.Req.get('edituser?evv='+$rootScope.data.evv +'&dbid='+$rootScope.newUser.dbid +'&name='+$rootScope.newUser.name+'&username='+$rootScope.newUser.username
+'&password='+$rootScope.newUser.password+'&accesstype='+$rootScope.newUser.accessType).then(function(results) {
$rootScope.loadUsers();
});
},
null);
};
$scope.deleteuser = function(u){
$rootScope.confirmModal(
'Confirmation',
'Are you sure you want to delete this user?',
'Yes',
'Cancel',
function(){
$rootScope.Req.get('deleteuser?evv='+$rootScope.data.evv+'&dbid='+u.dbid).then(function(results) {
$rootScope.loadUsers();
});
},
null);
}
$scope.userDatabaseAccess = function(dbu){
$rootScope.data.currentUser = dbu;
$rootScope.Req.get('usersdatabase?evv='+$rootScope.data.evv+'&idUser'+dbu.idUser +'&hasaccess=' + dbu.hasaccess).then(function(results) {
$rootScope.data.views = results;
});
};
$scope.updateuser = function(v){
$rootScope.Req.post('updateUser?evv='+$rootScope.data.evv, [$rootScope.data.currentUser, v]).then(function(results) {
$rootScope.data.currentUser.canSeeViews = results;
$scope.openUserDetails($rootScope.data.currentUser);
});
};
$scope.updateuserE = function(d){
console.log(d);
$rootScope.Req.post('updateUserE?evv='+$rootScope.data.evv, [$rootScope.data.currentUser, d]).then(function(results) {
$scope.openUserDetails($rootScope.data.currentUser);
});
};
$scope.updateuserV = function(d){
console.log(d);
$rootScope.Req.post('updateUserV?evv='+$rootScope.data.currentEvent, [$rootScope.data.currentUser, d, $rootScope.data.currentDB]).then(function(results) {
$scope.getVendors($rootScope.data.currentDB);
});
};
$scope.getVendors = function(d){
$rootScope.data.currentDB = d;
$rootScope.data.currentEvent = d.idevent;
$rootScope.Req.post('getuvendors?evv='+$rootScope.data.currentEvent, [d, $rootScope.data.currentUser]).then(function(results) {
$rootScope.data.uVendors = results;
});
};
$scope.openpermissionmanagement = function(permissions){
$rootScope.permissions = permissions;
$('#manage_permissions').modal('show');
};
$scope.assignpermission = function(key, value){
$rootScope.Req.post('assignpermission?evv='+$rootScope.data.evv, [key, $rootScope.data.currentUser.dbid, value]).then(function(results) {
});
};
}).controller('eventdetailsController', function($scope, $rootScope, Data, $timeout, localStorageService, $sce) {
$rootScope.$watch("data.onlineconfig", function(){
if(!angular.isUndefined($rootScope.data.onlineconfig))
$scope.onlineconfig = $rootScope.data.onlineconfig;
});
$rootScope.$watch("data.appconfig", function(){
if(!angular.isUndefined($rootScope.data.appconfig))
$scope.appconfig = $rootScope.data.appconfig;
});
$rootScope.$watch("data.onsiteconfig", function(){
if(!angular.isUndefined($rootScope.data.onsiteconfig))
$scope.onsiteconfig = $rootScope.data.onsiteconfig;
});
$rootScope.$watch("data.chipconfig", function(){
if(!angular.isUndefined($rootScope.data.chipconfig))
$scope.chipconfig = $rootScope.data.chipconfig;
});
$scope.reqconfig = ["FIRSTCURRENCYTEXT",
"SECONDCURRENCYTEXT",
"MAX1STCUR",
"MAX2NDCUR",
"MAX1STCASHOUT",
"TILL_PRINTRECEIPT",
"TILL_USECCTERMINAL",
"VATTYPES",
"READERWELCOMEMESSAGE",
"SELFTOPUPAMOUNTS",
"STUReceiptHeader",
"TILL_CASHLESS"];
$scope.activetab = 1;
$scope.addrequired = function(){
console.log("Adding required!!!");
for(var i=0; i< $scope.onlineconfig.length; i++){
for(var j=0; j< $scope.reqconfig.length; j++){
if($scope.onlineconfig[i].name == $scope.reqconfig[j]){
$scope.onlineconfig[i].req = 1;
//console.log("Changed");
}
}
}
for(var i=0; i< $scope.appconfig.length; i++){
for(var j=0; j< $scope.reqconfig.length; j++){
if($scope.appconfig[i].name == $scope.reqconfig[j]){
$scope.appconfig[i].req = 1;
//console.log("Changed");
}
}
}
for(var i=0; i< $scope.onsiteconfig.length; i++){
for(var j=0; j< $scope.reqconfig.length; j++){
if($scope.onsiteconfig[i].name == $scope.reqconfig[j]){
$scope.onsiteconfig[i].req = 1;
//console.log("Changed");
}
}
}
}
$timeout(function() {
$scope.addrequired();
}, 500);
$scope.setactive = function(ind){
$scope.activetab = ind;
}
$scope.saveonlinec = function(c){
console.log(c);
$rootScope.confirmModal(
'Confirm',
'Are you sure you want to edit this field?',
'Yes',
'Cancel',
function(){
Data.get('editonlinec?evv='+$rootScope.data.evv+'&id='+c.idOnlineConfig+'&value='+c.value).then(function(results) {
$rootScope.getReports($rootScope.data.evv);
});
}, null);
}
$scope.saveappc = function(c){
console.log(c);
$rootScope.confirmModal(
'Confirm',
'Are you sure you want to edit this field?',
'Yes',
'Cancel',
function(){
Data.get('editappc?evv='+$rootScope.data.evv+'&id='+c.dbid+'&value='+c.value).then(function(results) {
$rootScope.getReports($rootScope.data.evv);
});
}, null);
}
$scope.saveonsitec = function(c){
console.log(c);
$rootScope.confirmModal(
'Confirm',
'Are you sure you want to edit this field?',
'Yes',
'Cancel',
function(){
Data.get('editonsitec?evv='+$rootScope.data.evv+'&id='+c.idOnSiteConfig+'&value='+c.value).then(function(results) {
$rootScope.getReports($rootScope.data.evv);
});
}, null);
}
}).controller('articlesController', function($scope, $rootScope, Data, $timeout) {
$rootScope.$watch("data.articles", function(){
if(!angular.isUndefined($rootScope.data.articles))
$scope.articles = $rootScope.data.articles;
/*for(var i=0;i<$scope.articles.length;i++){
$scope.articles[i].selected = 0;
$scope.articles[i].keyColor = $rootScope.rgb2hex("rgb("+ $scope.articles[i].keyColor+")");
$scope.articles[i].keyFRGColor = $rootScope.rgb2hex("rgb("+ $scope.articles[i].keyFRGColor+")");
if($scope.articles[i].TXType == "10")
$scope.articles[i].TXType = $rootScope.data.TxTypes[0];
else if($scope.articles[i].TXType == "20")
$scope.articles[i].TXType = $rootScope.data.TxTypes[1];
else if($scope.articles[i].TXType == "30")
$scope.articles[i].TXType = $rootScope.data.TxTypes[2];
else if($scope.articles[i].TXType == "40")
$scope.articles[i].TXType = $rootScope.data.TxTypes[3];
}*/
console.log($scope.articles);
});
$rootScope.pgroups = [];
$rootScope.vats = [];
$scope.sl = 0;
$scope.changeall = 0;
$rootScope.data.vats = [];
$rootScope.data.pgroups = {};
$scope.filteredarticles = [];
$scope.limiteri = 50;
$scope.updatedarticles = [];
$scope.data.ordiner = "vname";
$rootScope.voucherrunover = 0;
$scope.atab = 1;
$rootScope.showColorModal = 0;
$scope.seta = function(i){
$scope.atab = i;
}
$scope.gettotal = function(art){
$scope.totalart = art;
console.log(art);
}
$rootScope.getColorModal = function(i, plu){
$rootScope.index = i;
if($rootScope.index == 1)
{
$rootScope.showColorModal = 1;
$rootScope.plu = plu;
console.log($rootScope.showColorModal);
$rootScope.genericModal(
'Choose the background color',
'views/articles/template.choosecolor.php',
'Ok',
'Close',
function(){
if($rootScope.plu != 0 ){
$rootScope.updaterow($rootScope.plu);
}
else {
$scope.thebtcolor = plu.keyColor;
}
},
null
);
}
else if ( $rootScope.index == 2)
{
$rootScope.showColorModal = 2;
$rootScope.plu = plu;
$rootScope.genericModal(
'Choose the text color',
'views/articles/template.choosecolor.php',
'Ok',
'Close',
function(){
$rootScope.updaterow($rootScope.plu);
},
null
);
}
}
$rootScope.getarticleoverview = function(){
var relateddates = "";
if($rootScope.dates.dt1 != "" && $rootScope.dates.dt2 != "")
relateddates = "&dt1="+$rootScope.dates.dt1+"&dt2="+$rootScope.dates.dt2;
Data.get('saoverview?evv='+$rootScope.data.evv+relateddates).then(function(results) {
$rootScope.data.saoverview = results;
$scope.gettotal();
console.log($rootScope.data.saoverview);
});
}
$rootScope.getPluDetaildReport = function(){
Data.get('sadetailedreport?evv='+$rootScope.data.evv).then(function(results) {
$rootScope.data.sadetailedreport = results;
});
}
$scope.changesel = function(p){
$scope.changeall = 1;
for(var i=0;i<$scope.filteredarticles.length;i++){
if($scope.filteredarticles[i].dbid == p.dbid){
if($scope.filteredarticles[i].selected == 0)
$scope.filteredarticles[i].selected = 1;
else
$scope.filteredarticles[i].selected = 0;
break;
}
}
}
$scope.selvendor = function(a){
$scope.changeall = 1;
for(var i=0;i<$scope.filteredarticles.length;i++){
if ($scope.filteredarticles[i].idVendor == a.idVendor) {
if($scope.filteredarticles[i].selected == 0)
$scope.filteredarticles[i].selected = 1;
else
$scope.filteredarticles[i].selected = 0;
}
}
}
$scope.selgroup = function(a){
console.log(a);
$scope.changeall = 1;
for(var i=0;i<$scope.filteredarticles.length;i++){
if ($scope.filteredarticles[i].groupname == a.groupname) {
if($scope.filteredarticles[i].selected == 0)
$scope.filteredarticles[i].selected = 1;
else
$scope.filteredarticles[i].selected = 0;
}
}
}
$scope.setOrder = function(w){
$scope.data.ordiner = w;
}
$scope.selectAll = function(){
$scope.changeall = 1;
if($scope.sl == 0){
for(var i=0;i<$scope.filteredarticles.length;i++){
$scope.filteredarticles[i].selected = 1;
}
$scope.sl = 1;
}
else if ($scope.sl == 1){
for(var i=0;i<$scope.filteredarticles.length;i++){
$scope.filteredarticles[i].selected = 0;
}
$scope.sl = 0;
}
}
$scope.showUnshowAll = function(){
if($scope.limiteri == 50)
$scope.limiteri = $scope.articles.length;
else
$scope.limiteri = 50;
}
$rootScope.getArticleDetails = function(){
console.log("getArticleDetails");
Data.get('pludetails?evv='+$rootScope.data.evv).then(function(results) {
$rootScope.details = results;
$rootScope.vats = JSON.parse($rootScope.details[0]);
$rootScope.vats = $rootScope.vats[0].value.replace('[','').replace(']','').split(',');
for(var i=0;i<$rootScope.vats.length;i++){
$rootScope.data.vats[i] = $rootScope.vats[i].concat('.00').trim();
}
console.log($rootScope.vats);
$rootScope.data.pgroups = JSON.parse($rootScope.details[1]);
console.log($rootScope.pgroups);
});
}
$timeout(function() {
if($rootScope.U.accessType != 1){
if($rootScope.U.canSeeViews.indexOf('/article.managment') == -1 && $rootScope.U.canSeeViews.indexOf('/article.reports') == -1)
$rootScope.location.path($rootScope.U.canSeeViews[0]);
else if($rootScope.U.canSeeViews.indexOf('/article.managment') > -1 && $rootScope.U.canSeeViews.indexOf('/article.reports') == -1)
$scope.atab = 1;
else if($rootScope.U.canSeeViews.indexOf('/article.managment') == -1 && $rootScope.U.canSeeViews.indexOf('/article.reports') > -1)
$scope.atab = 2;
}
$rootScope.getArticleDetails();
$rootScope.getarticleoverview();
$rootScope.getPluDetaildReport();
}, 500);
$scope.updateSelected = function(){
console.log($scope.updatedarticles);
if($scope.updatedarticles[0].Tag !=""){
$scope.updatedarticles[0].Titel = $scope.updatedarticles[0].Titel.concat(' |',$scope.updatedarticles[0].Tag)
$rootScope.Req.post('aupdate?evv='+$rootScope.data.evv, [$scope.updatedarticles]).then(function(results) {
$rootScope.getReports($rootScope.data.evv);
$scope.resetfields();
$scope.updatedarticles = [];
});
}
else{
$rootScope.Req.post('aupdate?evv='+$rootScope.data.evv, [$scope.updatedarticles]).then(function(results) {
$rootScope.getReports($rootScope.data.evv);
$scope.resetfields();
$scope.updatedarticles = [];
});
}
}
$scope.deleteplus = function(){
for(var i=0;i<$scope.filteredarticles.length;i++){
if($scope.filteredarticles[i].selected == 1){
$scope.updatedarticles.push($scope.filteredarticles[i]);
}
}
console.log($scope.updatedarticles);
$rootScope.confirmModal(
'Confirm',
'Do you want to delete the selected articles?',
'Yes',
'Cancel',
function(){
$rootScope.Req.post('adelete?evv='+$rootScope.data.evv, [$scope.updatedarticles]).then(function(results) {
$rootScope.getReports($rootScope.data.evv);
$scope.updatedarticles = [];
$rootScope.getarticles();
});
});
}
$rootScope.updaterow = function(p){
$scope.updatedarticles = [];
$scope.updatedarticles.push(p);
$scope.updateSelected();
}
$scope.applychanges = function(){
for(var i=0;i<$scope.filteredarticles.length;i++){
if($scope.filteredarticles[i].selected == 1){
if($scope.filteredarticles[i].PriceType == null)
$scope.filteredarticles[i].PriceType = 0;
if($scope.thegroup)
$scope.filteredarticles[i].productgroup = $scope.thegroup ;
if($scope.theprice)
$scope.filteredarticles[i].Price = $scope.theprice;
if($scope.thevat)
$scope.filteredarticles[i].VATTYPE = $scope.thevat;
if($scope.thebtcolor)
$scope.filteredarticles[i].keyColor = $scope.thebtcolor;
if($scope.theftcolor)
$scope.filteredarticles[i].keyFRGColor = $scope.theftcolor;
if($scope.thetxtype)
$scope.filteredarticles[i].TXType = $scope.thetxtype;
if($scope.thefp){
if($scope.thefp == 2)
$scope.filteredarticles[i].Price = 0;
$scope.filteredarticles[i].PriceType = $scope.thefp;
}
if($scope.thefc)
$scope.filteredarticles[i].FirstCurrencyAllowed = $scope.thefc;
if($scope.thesc)
$scope.filteredarticles[i].SecondCurrencyAllowed = $scope.thesc;
if($scope.thevoucher)
$scope.filteredarticles[i].VoucherAllowed = $scope.thevoucher;
console.log($scope.thefp);
$scope.updatedarticles.push($scope.filteredarticles[i]);
}
if(i == ($scope.filteredarticles.length - 1))
$scope.updateSelected();
}
}
$scope.resetfields = function(){
delete $scope.thegroup;
delete $scope.theprice;
delete $scope.thevat;
delete $rootScope.thebtcolor;
delete $rootScope.theftcolor;
delete $scope.thetxtype;
delete $scope.thefp;
delete $scope.thefc;
delete $scope.thesc;
delete $scope.thevoucher;
}
}).controller('assigneddevicesController', function($scope, $rootScope, Data, $timeout,$sce) {
$scope.adevice = {};
$rootScope.newDevice = {};
$scope.limit = 50;
$scope.data.addDev = 0;
$timeout(function() {
$rootScope.getDeviceDetails();
}, 500).then(function() {
});
$rootScope.$watch("data.assigneddevices", function(){
if(!angular.isUndefined($rootScope.data.assigneddevices))
$scope.assigneddevices = $rootScope.data.assigneddevices;
console.log($rootScope.data.assigneddevices);
});
$rootScope.getDeviceDetails = function(){
console.log("GetDeviceDetails");
Data.get('devicedetails?evv='+$rootScope.data.evv).then(function(results){
$rootScope.devicedetails = results
$rootScope.devicetypes = JSON.parse($rootScope.devicedetails[0]);
console.log($rootScope.devicetypes);
$rootScope.devicelayers = JSON.parse($rootScope.devicedetails[1]);
console.log($rootScope.devicelayers);
});
}
$scope.showUnshowAll = function(){
if($scope.limit == 50)
$scope.limit = $scope.assigneddevices.length;
else
$scope.limit = 50;
}
$scope.showad = function(){
if($scope.data.addDev == 0)
$scope.data.addDev = 1;
else if($scope.data.addDev == 1)
$scope.data.addDev = 0;
$rootScope.newDevice = {};
}
$rootScope.adddevice = function(){
$rootScope.getDeviceDetails();
Data.get('adddevice?evv='+$rootScope.data.evv +'&titel='+$rootScope.newDevice.devicename+'&mac='+$rootScope.newDevice.mac
+'&devicetype='+$rootScope.newDevice.tkdevicetype +'&idvg='+$rootScope.newDevice.idvg).then(function(results) {
$rootScope.loadDevices();
$scope.clearDevice();
});
}
$scope.editdevice = function(device){
console.log(device);
$rootScope.newDevice.devicename = device.devicename;
$rootScope.newDevice.mac = device.mac;
$rootScope.newDevice.tkdevicetype = device.tkdevicetype;
$rootScope.newDevice.idvg = device.idvg;
$rootScope.newDevice.layer = device.layer;
$rootScope.genericModal(
'Edit the device',
'views/eventdevices/template.adddevice.php',
'SAVE',
'Cancel',
function(){
console.log($rootScope.newDevice);
Data.get('editdevice?evv='+$rootScope.data.evv +'&titel='+$rootScope.newDevice.devicename
+'&mac='+$rootScope.newDevice.mac +'&devicetype='+$rootScope.newDevice.tkdevicetype
+'&idvg='+$rootScope.newDevice.idvg+'&idDevice='+device.idDevice).then(function(results) {
$rootScope.loadDevices();
});
},
null);
}
$scope.deletedevice = function (device){
console.log(device);
$rootScope.confirmModal(
'Confirm',
'Do you want to delete the device?',
'Yes',
'Cancel',
function(){
Data.get('deletedevice?evv='+$rootScope.data.evv+'&idDevice='
+device.idDevice).then(function(results) {
$rootScope.loadDevices();
});
}
, null);
}
$scope.SaveName = function (device){
console.log(device);
Data.get('editdevname?evv='+$rootScope.data.evv+'&idDevice='+device.idDevice
+'&titel=' + device.devicename ).then(function(results) {
});
}
$scope.SaveEventName = function(device){
console.log(device);
Data.get('editeventname?evv='+$rootScope.data.evv+'&idDevice='+device.idDevice
+'&titel=' + device.deviceeventname ).then(function(results) {
});
}
$scope.SaveMac = function(device){
console.log(device);
Data.get('editmac?evv='+$rootScope.data.evv+'&idDevice='+device.idDevice
+'&mac=' + device.mac ).then(function(results) {
});
}
$scope.SaveType = function(device){
console.log(device);
Data.get('edittype?evv='+$rootScope.data.evv+'&idDevice='+device.idDevice
+'&devicetype='+device.tkdevicetype ).then(function(results) {
});
}
$scope.SaveLayer = function(device){
console.log(device);
Data.get('layeredit?evv='+$rootScope.data.evv+'&idDevice='+device.idDevice
+'&idvg='+device.idvg ).then(function(results) {
});
}
$scope.importdevices = function(){
$rootScope.data.action = $sce.trustAsResourceUrl("https://dashboard.youchip.com/requests/guestclient/importdevice.php?evv="+$rootScope.data.evv);
$rootScope.genericModal(
'Import devices',
'views/eventdevices/template.importdevices.php',
'Import',
'Close',
function(){
angular.element('#theform').submit();
$timeout(function(){
window.location.reload();
}, 1000);
},
null
);
};
$scope.exportdevices = function(){
var url = "https://dashboard.youchip.com/requests/guestclient/exportdevice.php?evv="+$rootScope.data.evv;
console.log(url);
window.open(url);
};
$scope.clearDevice = function(){
$rootScope.newDevice = {};
$rootScope.getDeviceDetails();
}
})
.controller('stockController', function($scope, $rootScope, Data, $timeout,localStorageService, $location) {
$rootScope.$watch("data.stocktra", function(){
if(!angular.isUndefined($rootScope.data.stocktra)){
$scope.stocktra = $rootScope.data.stocktra;
}
});
$rootScope.data.stockarticles = [];
$rootScope.data.amo = 1;
$rootScope.data.maxs = 0;
$scope.activetabS = 1;
$rootScope.data.originselector = 0;
$rootScope.pickvl = function(x){
$rootScope.data.originselector = x;
if(x == 0)
$rootScope.getGjendjeV($rootScope.data.SVendor)
}
$scope.transDetails = function(d){
console.log(d);
$rootScope.data.currentsttr = d;
Data.get('stocktransdetails?evv='+$rootScope.data.evv+'&sid=' + d.idStock ).then(function(results) {
$rootScope.data.stdetails = results;
$rootScope.data.bsdtotal = 0;
for(var i=0; i<$rootScope.data.stdetails.length; i++){
$rootScope.data.stdetails[i].total = $rootScope.data.stdetails[i].Price * $rootScope.data.stdetails[i].Amount;
$rootScope.data.bsdtotal += $rootScope.data.stdetails[i].total;
}
console.log($rootScope.data.stdetails);
});
$rootScope.genericModal(
'Transaction details',
'views/stock/template.viewtrans.php',
'Print',
'Close',
null,
null);
}
$scope.setactiveS = function(l){
$scope.activetabS = l;
if(l == 2){
if($rootScope.data.lvselector == 1){
$rootScope.getGjendjeV($rootScope.data.SVendor);
}
else if($rootScope.data.lvselector == 2){
$rootScope.getGjendjeS($rootScope.data.SLayer);
}
}
}
$scope.addstocks = function (){
$rootScope.getGjendjeV($rootScope.data.SVendor);
/*for(var i=0;i<$rootScope.data.plus.length;i++){
for(var j=0;j<$rootScope.data.gjendja.length;j++){
if($rootScope.data.plus[i].PLU == $rootScope.data.gjendja[j].PLU){
$rootScope.data.plus[i].gjendja = $rootScope.data.gjendja[j].Gjendje;
}
}
}
console.log($rootScope.data.plus);*/
$scope.origjina = {};
$rootScope.genericModal(
'Add stock to this stand',
'views/vendors/template.addstocks.php',
'SAVE',
'Cancel',
function(){
if($rootScope.data.originselector == 0)
$scope.origjina = $rootScope.data.SVendor.vendorid;
else if($rootScope.data.originselector == 1)
$scope.origjina = $rootScope.data.originlayer.idLayer;
$rootScope.Req.post('addstock?evv='+$rootScope.data.evv+'&orig='+$scope.origjina+'&dest='+$rootScope.data.SLayer.idLayer+'&user='+$rootScope.U.name, [$rootScope.data.stockarticles]).then(function(results) {
$rootScope.data.stockarticles = [];
$rootScope.loadStock($rootScope.data.SLayer, 2);
$rootScope.getGjendjeS($rootScope.data.SLayer);
});
},
null);
}
$scope.addstockv = function (){
$rootScope.genericModal(
'Add stock to this vendor',
'views/vendors/template.addstockv.php',
'SAVE',
'Cancel',
function(){
$rootScope.Req.post('addstock?evv='+$rootScope.data.evv+'&orig=NULL&dest='+$rootScope.data.SVendor.vendorid+'&user='+$rootScope.U.name, [$rootScope.data.stockarticles]).then(function(results) {
$rootScope.data.stockarticles = [];
$rootScope.loadStock($rootScope.data.SVendor, 1);
$rootScope.getGjendjeV($rootScope.data.SVendor);
});
},
null);
}
$scope.addStock = function(){
if($rootScope.data.lvselector == 1)
$scope.addstockv();
else if($rootScope.data.lvselector == 2)
$scope.addstocks();
}
$rootScope.addToStock = function(){
if($rootScope.data.art){
if($rootScope.data.stockarticles.length != 0){
for(var i=0; i<$rootScope.data.stockarticles.length;i++){
if(parseInt($rootScope.data.art.PLU) == parseInt($rootScope.data.stockarticles[i].article.PLU)){
$rootScope.data.stockarticles[i].amount = parseInt($rootScope.data.stockarticles[i].amount) + parseInt($rootScope.data.amo);
$rootScope.data.art = {};
$rootScope.data.amo = 1;
break;
}
if((i == ($rootScope.data.stockarticles.length - 1)) && (parseInt($rootScope.data.art.PLU) != parseInt($rootScope.data.stockarticles[i].article.PLU))){
if(!angular.equals($rootScope.data.art, {})){
$scope.as = {};
$scope.as.article = angular.copy($rootScope.data.art);
$scope.as.amount = angular.copy($rootScope.data.amo);
$rootScope.data.stockarticles.push($scope.as);
$rootScope.data.art = {};
$rootScope.data.amo = 1;
}
break;
}
}
}
else if ($rootScope.data.stockarticles.length == 0){
$scope.as = {};
$scope.as.article = angular.copy($rootScope.data.art);
$scope.as.amount = angular.copy($rootScope.data.amo);
$rootScope.data.stockarticles.push($scope.as);
$rootScope.data.art = {};
$rootScope.data.amo = 1;
}
console.log($rootScope.data.stockarticles);
}
}
$rootScope.removea = function(i){
$rootScope.data.stockarticles.splice(i,1);
}
}).controller('promoterdevicesController', function($scope, $rootScope, Data, $timeout,$sce) {
$rootScope.newDevice = {};
$rootScope.newType = {};
$rootScope.data.thisdevice = [];
$timeout(function() {
$rootScope.gettype();
$rootScope.getPromoterGjendje();
}, 500).then(function() {
});
$rootScope.$watch("data.promoterdevices", function(){
if(!angular.isUndefined($rootScope.data.promoterdevices))
$scope.promoterdevices = $rootScope.data.promoterdevices;
});
$scope.editpname = function (device){
console.log(device);
Data.get('editpname?evv='+$rootScope.data.evv+'&idDevice='+device.idDevice
+'&deviceName=' + device.deviceName).then(function(results) {
});
}
$scope.editpstock = function (device){
console.log(device);
Data.get('editpstock?evv='+$rootScope.data.evv+'&idDevice='+device.idDevice
+'&Stock=' + device.Stock).then(function(results) {
});
}
$scope.devicedetails = function(d){
console.log(d);
Data.get('devicedist?evv='+$rootScope.data.evv+'&idDevice='+d.idDevice).then(function(results) {
console.log(results);
$rootScope.data.thisdevice = results;
$rootScope.genericModal(
'Device vendors',
'views/promoterdevices/template.dddetails.php',
'',
'Cancel',
function(){
},
null);
});
}
$scope.editptype = function (device){
console.log(device);
Data.get('editpdevicetype?evv='+$rootScope.data.evv+'&idDevice='+device.idDevice
+'&idDeviceGroup=' + device.idDeviceGroup).then(function(results) {
});
}
$rootScope.gettype = function(){
Data.get('gettype?evv='+$rootScope.data.evv).then(function(results){
$rootScope.devicetypes = results;
});
}
$rootScope.openmodal = function(){
$rootScope.gettype();
$rootScope.newType.groupName = "";
$rootScope.genericModal(
'Add new device type',
'views/promoterdevices/template.adddevicetype.php',
'',
'Cancel',
function(){
},
null);
}
$rootScope.adddevicetype = function(){
Data.get('adddevicetype?evv='+$rootScope.data.evv +'&groupName='+$rootScope.newType.groupName
).then(function(results) {
$rootScope.openmodal();
});
}
$rootScope.addpdevice = function(){
$rootScope.newDevice = {};
$rootScope.gettype();
$rootScope.genericModal(
'Add new device',
'views/promoterdevices/template.adddevice.php',
'SAVE',
'Cancel',
function(){
console.log($rootScope.newDevice);
if (angular.isUndefined($rootScope.newDevice.idDeviceGroup)){
$rootScope.newDevice.idDeviceGroup = 0;
}
Data.get('addpromodevice?evv='+$rootScope.data.evv +'&deviceName='+$rootScope.newDevice.deviceName
+'&Stock='+$rootScope.newDevice.Stock +'&idDeviceGroup='+$rootScope.newDevice.idDeviceGroup
).then(function(results) {
$rootScope.getPromoterGjendje();
});
},
null);
}
$rootScope.editpdevice = function(device){
console.log(device);
$rootScope.newDevice.deviceName = device.deviceName;
$rootScope.newDevice.Stock = device.Stock;
$rootScope.newDevice.idDeviceGroup = device.idDeviceGroup;
$rootScope.genericModal(
'Edit device',
'views/promoterdevices/template.adddevice.php',
'SAVE',
'Cancel',
function(){
console.log($rootScope.newDevice);
Data.get('editpdevice?evv='+$rootScope.data.evv +'&deviceName='+$rootScope.newDevice.deviceName
+'&Stock='+$rootScope.newDevice.Stock +'&idDeviceGroup='+$rootScope.newDevice.idDeviceGroup
+'&idDevice='+device.idDevice).then(function(results) {
$rootScope.getPromoterGjendje();
});
},
null);
}
$scope.deletepdevice = function (device){
console.log(device);
$rootScope.confirmModal(
'Confirm',
'Do you want to delete the device?',
'Yes',
'Cancel',
function(){
Data.get('deletepdevice?evv='+$rootScope.data.evv+'&idDevice='
+device.idDevice).then(function(results) {
$rootScope.getPromoterGjendje();
});
}
, null);
}
$rootScope.deletetype = function (dt){
console.log(dt);
var isConfirmed = confirm("Are you sure you want to delete this type of device?");
if(isConfirmed){
Data.get('deletetype?evv='+$rootScope.data.evv+'&idDeviceGroup='
+dt.idDeviceGroup).then(function(results) {
$rootScope.gettype();
$rootScope.getPromoterGjendje();
});
}
else {
return false;
}
};
$rootScope.save = function (dt){
console.log(dt);
$rootScope.newType.groupName = dt.groupName;
Data.get('edittypename?evv='+$rootScope.data.evv+'&idDeviceGroup='
+dt.idDeviceGroup+'&groupName='
+$rootScope.newType.groupName).then(function(results) {
$rootScope.gettype();
$rootScope.openmodal();
});
}
}).controller('vendordevicesController', function($scope, $rootScope, Data, $timeout,localStorageService, $location) {
$rootScope.$watch("data.vendordevices", function(){
if(!angular.isUndefined($rootScope.data.vendordevices)){
$scope.vendordevices = $rootScope.data.vendordevices;
}
});
$rootScope.data.stockdevices = [];
$rootScope.data.amod = 1;
$scope.activetabD = 1;
$scope.setactiveD = function(l){
$scope.activetabD = l;
}
$scope.addDevices = function(){
$rootScope.genericModal(
'Add devices to this vendor',
'views/vendordevices/template.adddevices.php',
'SAVE',
'Cancel',
function(){
$rootScope.Req.post('adddevices?evv='+$rootScope.data.evv+'&vendor='+$rootScope.data.DVendor.vendorid+'&user='+$rootScope.U.name+'&type=1'+'¬e='+$scope.data.note, [$rootScope.data.stockdevices]).then(function(results) {
$rootScope.data.stockdevices = [];
$rootScope.getVDGjendje($rootScope.data.DVendor);
$scope.data.note = "";
//$rootScope.loadStock($rootScope.data.SVendor, 1);
//$rootScope.getGjendjeV($rootScope.data.SVendor);
});
},
null);
}
$scope.returnDevices = function(){
$rootScope.genericModal(
'Return devices to suplier',
'views/vendordevices/template.returndevices.php',
'SAVE',
'Cancel',
function(){
$rootScope.Req.post('adddevices?evv='+$rootScope.data.evv+'&vendor='+$rootScope.data.DVendor.vendorid+'&user='+$rootScope.U.name+'&type=2'+'¬e='+$scope.data.note, [$rootScope.data.stockdevices]).then(function(results) {
$rootScope.data.stockdevices = [];
$rootScope.getVDGjendje($rootScope.data.DVendor);
$scope.data.note = "";
//$rootScope.loadStock($rootScope.data.SVendor, 1);
//$rootScope.getGjendjeV($rootScope.data.SVendor);
});
},
null);
}
$rootScope.addToDStock = function(){
if($rootScope.data.dev){
if($rootScope.data.stockdevices.length != 0){
for(var i=0; i<$rootScope.data.stockdevices.length;i++){
if($rootScope.data.dev.idDevice == $rootScope.data.stockdevices[i].device.idDevice){
$rootScope.data.stockdevices[i].amount = parseInt($rootScope.data.stockdevices[i].amount) + parseInt($rootScope.data.amod);
$rootScope.data.dev = {};
$rootScope.data.amod = 1;
break;
}
if((i == ($rootScope.data.stockdevices.length - 1)) && ($rootScope.data.dev.idDevice != $rootScope.data.stockdevices[i].device.idDevice)){
if(!angular.equals($rootScope.data.dev, {})){
$scope.as = {};
$scope.as.device = angular.copy($rootScope.data.dev);
$scope.as.amount = angular.copy($rootScope.data.amod);
$rootScope.data.stockdevices.push($scope.as);
$rootScope.data.dev = {};
$rootScope.data.amod = 1;
}
break;
}
}
}
else if ($rootScope.data.stockdevices.length == 0){
$scope.as = {};
$scope.as.device = angular.copy($rootScope.data.dev);
$scope.as.amount = angular.copy($rootScope.data.amod);
$rootScope.data.stockdevices.push($scope.as);
$rootScope.data.dev = {};
$rootScope.data.amod = 1;
}
console.log($rootScope.data.stockdevices);
}
}
$rootScope.removead = function(i){
$rootScope.data.stockdevices.splice(i,1);
}
}).controller('devicetransactionsController', function($scope, $rootScope, Data, $timeout,$sce) {
$rootScope.$watch("data.devicetransactions", function(){
if(!angular.isUndefined($rootScope.data.devicetransactions))
$scope.devicetransactions = $rootScope.data.promoterdevices;
});
$scope.haptra = 0;
$scope.data.devicetransactionss = [];
$scope.openDtrans = function(vid){
$scope.haptra = 1;
console.log(vid);
$scope.data.devicetransactionss = [];
for (var i = $rootScope.data.devicetransactions.length - 1; i >= 0; i--) {
if($rootScope.data.devicetransactions[i].idDeviceTransaction == vid)
$scope.data.devicetransactionss.push($rootScope.data.devicetransactions[i]);
}
console.log($scope.data.devicetransactionss);
}
}).controller('areasController', function($scope, $rootScope, Data) {
$rootScope.newArea = {};
$rootScope.zones = [{id : 0, value : "No"},
{id : 1, value : "Yes"}];
$rootScope.$watch("data.areas", function(){
if(!angular.isUndefined($rootScope.data.areas)){
$scope.areas = $rootScope.data.areas;
}
});
$rootScope.addarea = function (){
$rootScope.newArea = {};
$rootScope.genericModal(
'Create new area',
'views/areas/template.addareas.php',
'SAVE',
'Cancel',
function(){
if(angular.isUndefined($rootScope.newArea.isZone)){
$rootScope.newArea.isZone = '0';
}
Data.get('addareas?evv='+$rootScope.data.evv+'&Titel='+$rootScope.newArea.Titel
+'&keyTag='+$rootScope.newArea.keyTag +'&isZone='+$rootScope.newArea.isZone).then(function(results) {
$rootScope.loadAreas();
});
},
null);
}
$rootScope.getarea = function(a){
Data.get('getarea?evv='+$rootScope.data.evv).then(function(results) {
$rootScope.data.area = results[0];
console.log(results);
});
}
$rootScope.editarea = function (a){
console.log(a);
$rootScope.newArea.Titel = a.Titel;
$rootScope.newArea.keyTag = a.keyTag;
$rootScope.newArea.isZone = a.isZone;
$rootScope.genericModal(
'Edit this area',
'views/areas/template.addareas.php',
'SAVE',
'Cancel',
function(){
Data.get('editarea?evv='+$rootScope.data.evv+'&Titel='+$rootScope.newArea.Titel
+'&keyTag='+$rootScope.newArea.keyTag +'&isZone='+$rootScope.newArea.isZone
+'&idArea='+a.idArea).then(function(results) {
$rootScope.loadAreas();
});
},
null);
}
$rootScope.removerole = function(ar){
var isConfirmed = confirm("Are you sure you want to delete this role from the area?");
if(isConfirmed){
Data.get('removerole?evv='+$rootScope.data.evv
+'&idTicketRole='+ar.idTicketRole+'&idArea='+ar.idArea).then(function(results) {
$rootScope.loadAreas();
$rootScope.getroles(ar);
});
}
else {
return false;
}
};
$rootScope.getroles = function (a){
console.log(a);
Data.get('areasticketroles?evv='+$rootScope.data.evv+'&idArea='+a.idArea).then(function(results) {
$rootScope.data.arearoles = results;
console.log($rootScope.data.arearoles);
});
}
$rootScope.openmodal = function (a){
$rootScope.getallroles();
$rootScope.getroles(a);
$rootScope.genericModal(
'Ticket Roles Assigned to this area',
'views/areas/template.getroles.php',
null,
'Close',
null,
null);
$rootScope.assigntoArea = function (ar){
console.log(ar);
Data.get('assignrole?evv='+$rootScope.data.evv
+'&idTicketRole='+ar.idTicketRole+'&idArea='+a.idArea).then(function(results) {
$rootScope.getroles(a);
$rootScope.loadAreas();
});
};
}
}).controller('tickettypesController', function($scope, $rootScope, Data, $timeout) {
$rootScope.newRole = {};
$rootScope.newType = {};
$rootScope.$watch("data.roles", function(){
if(!angular.isUndefined($rootScope.data.roles)){
$scope.roles = $rootScope.data.roles;
console.log($scope.roles);
$rootScope.gettickettypes();
}
});
$rootScope.gettickettypes = function(){
Data.get('gettickettypes?evv='+$rootScope.data.evv).then(function(results) {
$rootScope.data.tickettypes = results;
console.log(results);
});
}
$rootScope.gettperrole = function(a){
Data.get('gettperrole?evv='+$rootScope.data.evv+'&idTicketRole='+a.idTicketRole).then(function(results) {
$rootScope.data.typesperrole = results;
console.log(results);
});
}
$rootScope.addroles = function (){
$rootScope.newRole = {};
$rootScope.genericModal(
'Create new role',
'views/tickettypes/template.addroles.php',
'SAVE',
'Cancel',
function(){
Data.get('addroles?evv='+$rootScope.data.evv+'&titel='+$rootScope.newRole.Titel
+'&from='+$rootScope.newRole.GueltigVon +'&to='+$rootScope.newRole.GueltigBis
+'&keyTag='+$rootScope.newRole.keyTag).then(function(results) {
$rootScope.loadTickettypes();
$rootScope.gettickettypes();
});
},
null);
}
$rootScope.editroles = function (a){
$rootScope.newRole.Titel = a.Titel;
$rootScope.newRole.GueltigVon = a.GueltigVon;
$rootScope.newRole.GueltigBis = a.GueltigBis;
$rootScope.newRole.keyTag = a.keyTag
$rootScope.genericModal(
'Edit this role',
'views/tickettypes/template.addroles.php',
'SAVE',
'Cancel',
function(){
Data.get('editroles?evv='+$rootScope.data.evv+'&titel='+$rootScope.newRole.Titel
+'&from='+$rootScope.newRole.GueltigVon +'&to='+$rootScope.newRole.GueltigBis
+'&keyTag='+$rootScope.newRole.keyTag +'&idTicketRole='+a.idTicketRole).then(function(results) {
$rootScope.loadTickettypes();
$rootScope.gettickettypes();
});
},
null);
}
$rootScope.addtype = function (){
$rootScope.newType = {};
$rootScope.genericModal(
'Create new type',
'views/tickettypes/template.addtype.php',
'SAVE',
'Cancel',
function(){
if(angular.isUndefined($rootScope.newType.Friendlyname)){
$rootScope.newType.Friendlyname = 'NULL';
}
Data.get('addtype?evv='+$rootScope.data.evv+'&Titel='+$rootScope.newType.Titel
+'&fname='+$rootScope.newType.Friendlyname ).then(function(results) {
$rootScope.gettickettypes();
});
},
null);
}
$rootScope.edittickettype = function (t){
$rootScope.newType.Titel = t.Titel;
$rootScope.newType.Friendlyname = t.Friendlyname;
$rootScope.genericModal(
'Edit this type',
'views/tickettypes/template.addtype.php',
'SAVE',
'Cancel',
function(){
if(angular.isUndefined($rootScope.newType.Friendlyname)){
$rootScope.newType.Friendlyname = 'NULL';
}
Data.get('edittickettype?evv='+$rootScope.data.evv+'&Titel='+$rootScope.newType.Titel
+'&fname='+$rootScope.newType.Friendlyname
+'&idTicketType='+t.idResellerTicketType).then(function(results) {
$rootScope.gettickettypes();
});
},
null);
}
$rootScope.deleteticktype = function (t){
console.log(t);
$rootScope.confirmModal(
'Confirm',
'Do you want to delete this ticketype?',
'Yes',
'Cancel',
function(){
Data.get('deleteticktype?evv='+$rootScope.data.evv+'&idTicketType='
+t.idResellerTicketType).then(function(results) {
$rootScope.gettickettypes();
});
}
, null);
}
$rootScope.openmodal = function (a){
$rootScope.gettickettypes();
$rootScope.gettperrole(a);
$rootScope.genericModal(
'Ticket Types Assigned to this role',
'views/tickettypes/template.gettype.php',
null,
'Close',
null,
null);
$rootScope.assigntype = function (t){
console.log(t);
Data.get('assigntype?evv='+$rootScope.data.evv
+'&idTicketRole='+a.idTicketRole+'&idTicketType='+t.idResellerTicketType).then(function(results) {
$rootScope.gettperrole(a);
$rootScope.gettickettypes();
});
};
}
$rootScope.removetype = function(t){
var isConfirmed = confirm("Are you sure you want to delete this type from the role?");
if(isConfirmed){
Data.get('removettype?evv='+$rootScope.data.evv
+'&idTicketRole='+t.idTicketRole+'&idTicketType='+t.idTicketType).then(function(results) {
$rootScope.gettperrole(t);
$rootScope.gettickettypes();
});
}
else {
return false;
}
};
$rootScope.getTicketAndTypeInfo = function(){
Data.get('getinfo?evv='+$rootScope.data.evv).then(function(results) {
$rootScope.ticketinfo = results[0];
$rootScope.tickettypeinfo = results[1];
});
$rootScope.genericModal(
'Tickets & Ticket Types Encode',
'views/tickettypes/template.encode.php',
null,
'Close',
null,
null
);
}
$rootScope.encode = function(type){
Data.get('encode?evv='+$rootScope.data.evv + "&encodetype=" + type).then(function(results) {
});
}
}).controller('eventconfigController', function($scope, $rootScope, Data, $timeout, localStorageService, $sce) {
$rootScope.$watch("data.promoeventconfig", function(){
if(!angular.isUndefined($rootScope.data.promoeventconfig))
$scope.promoeventconfig = $rootScope.data.promoeventconfig;
console.log($scope.promoeventconfig);
});
$scope.saveeventc = function(p){
console.log(p);
$rootScope.confirmModal(
'Confirm',
'Are you sure you want to edit this field?',
'Yes',
'Cancel',
function(){
Data.get('editonsitec?evv='+$rootScope.data.evv+'&id='+p.idOnSiteConfig+'&value='+p.value).then(function(results) {
$rootScope.getReports($rootScope.data.evv);
});
}, null);
}
}).controller('passwordrecoveryController', function($scope, $rootScope, $routeParams, Data) {
if(!angular.isUndefined($rootScope.U)){
console.log("login");
$rootScope.location.path("/");
}
$scope.data.newpass1 = "";
$scope.data.newpass2 = "";
$scope.login2 = function(u){
window.localStorage.setItem('sessione', '
Notice: Undefined index: eventsession in /var/www/html/yc_dashboard/newdashboard/app/ctrl/ctrl.passwordrecovery.php on line 13
');
$location.search('ack', null);
$rootScope.Req.post('login?evv='+'
Notice: Undefined index: eventsession in /var/www/html/yc_dashboard/newdashboard/app/ctrl/ctrl.passwordrecovery.php on line 15
', {'username':u.Email, 'password':$scope.data.newpass1}).then(function(results){
if(results.eventsData.length > 0){
$rootScope.U = results;
$rootScope.cevent = $rootScope.U.events
$rootScope.location.path($rootScope.U.access[0]);
}
else
$rootScope.location.path("/");
//$rootScope.location.path($rootScope.U.access[0]);
});
}
$scope.newpass = function(){
if ($scope.data.newpass1.valueOf() == $scope.data.newpass2.valueOf() && $scope.data.newpass1.length >= 4 ){
Data.get('newpassword?evv='+'
Notice: Undefined index: eventsession in /var/www/html/yc_dashboard/newdashboard/app/ctrl/ctrl.passwordrecovery.php on line 31
'+'&pwd=' + $scope.data.newpass1 +'&actkey='+'
Notice: Undefined index: ack in /var/www/html/yc_dashboard/newdashboard/app/ctrl/ctrl.passwordrecovery.php on line 31
').then(function(results) {
$scope.login2(results);
});
}
else{
$rootScope.confirmModal(
'Error',
'Something is wrong with your password, please try again!',
null,
'Okay',
null,
null);
$scope.data.newpass1 = "";
$scope.data.newpass2 = "";
}
}
}).controller('usertopupController', function($scope, $rootScope, Data, $timeout, $http) {
$rootScope.$watch("data.usertopups", function(){
if(!angular.isUndefined($rootScope.data.usertopups))
$scope.usertopups = $rootScope.data.usertopups;
console.log($scope.usertopups);
});
$scope.obthing = 'Firstname';
$rootScope.newpass = {};
$rootScope.ddcat = { user_data: [], locations: [], slots: []};
$scope.changeorder = function(c){
$scope.obthing = c;
}
$scope.exportData = function(){
window.location.href = "//dashboard.youchip.com/excelexport/exportuserprofile.php?evv="+$rootScope.data.evv;
}
$rootScope.sendActivationEmail = function (v){
var d = confirm("Are you sure you want to send an activation link to this user?");
if(d)
{
Data.get('actemail?evv='+$rootScope.data.evv+ '&email='+v.Email).then(function(results) {
console.log(v);
});
}
}
$scope.getkts = function(){
for(var i = 0; i < $rootScope.U.eventsData.length; i++){
if($rootScope.U.eventsData[i][7] == $rootScope.cevent)
return $rootScope.U.eventsData[i][2];
}
return '';
}
$rootScope.addnewpass = function(){
$http({
method: 'post',
url: '../index.php?kt='+$scope.getkts()+'&r=cateringlocationaddpass&bc='+$rootScope.userfV.barcode,
data: $rootScope.newpass
}).then(function successCallback(response) {
$scope.vouchers = [];
$http({
method: 'GET',
url: '../index.php?kt='+$scope.getkts()+'&r=cateringlocationsof&bc='+$rootScope.userfV.barcode
}).then(function successCallback(response) {
$rootScope.ddcat.user_data = response.data[0];
$rootScope.ddcat.locations = response.data[1];
$rootScope.ddcat.slots = response.data[2];
}, function errorCallback(response) {
});
}, function errorCallback(response) {
});
};
$rootScope.addprofilehditem = function(c){
$rootScope.addprofilehditem = c;
$rootScope.genericModal(
'Add Helpdesk Item',
'views/chips/template.addhditems.php',
'',
'',
null,
null);
}
$scope.getTicketDetails = function(barcode)
{
Data.get('ticketdeatils?evv='+$rootScope.data.evv+'&barcode=' + barcode).then(function(results) {
$rootScope.ticketDetails = results[0];
$rootScope.pendingMoney = results[1];
$rootScope.pendingVouchers = results[2];//JSON.parse(results);
$rootScope.genericModal('Ticket: ' + barcode, "views/modal.ticketdetails.php", '', 'Close', null, null)
});
};
$scope.showVouchers = function (v){
console.log(v);
$rootScope.userfV = v;
$scope.vouchers = [];
/*Data.get('createlayer?evv='+$rootScope.data.evv+'&vname='+$rootScope.data.newlayername+'&paybutton='+$rootScope.data.PMselected.code+'&idvendor='+v.vendorid).then(function(results) {
});*/
$http({
method: 'GET',
url: '../index.php?kt='+$scope.getkts()+'&r=cateringlocationsof&bc='+$rootScope.userfV.barcode
}).then(function successCallback(response) {
$rootScope.ddcat.user_data = response.data[0];
$rootScope.ddcat.locations = response.data[1];
$rootScope.ddcat.slots = response.data[2];
}, function errorCallback(response) {
});
$rootScope.genericModal(
$rootScope.userfV.Firstname + ' ' + $rootScope.userfV.Lastname,
'views/usertopup/template.uservouchers.php',
'SAVE',
'Cancel',
function(){
/*Data.get('createlayer?evv='+$rootScope.data.evv+'&vname='+$rootScope.data.newlayername+'&paybutton='+$rootScope.data.PMselected.code+'&idvendor='+v.vendorid).then(function(results) {
});*/
},
null);
};
}).controller('accesscontrolController', function($scope, $rootScope, Data) {
$rootScope.$watch("data.access", function(){
if(!angular.isUndefined($rootScope.data.access)){
$scope.access = $rootScope.data.access;
$scope.data.accessov = JSON.parse($scope.access[0]);
$scope.data.accessperhour = JSON.parse($scope.access[1]);
}
});
})
.controller('cateringController', function($scope, $rootScope, $http, $timeout) {
$scope.allpasses = [];
$scope.alllocations = [];
$scope.currentLocation = {};
$scope.alllocations = [];
$scope.catering_reports = [];
$scope.catering_dates = [];
$scope.catering_data = [];
$scope.datascope = { showAll: false};
$scope.dataperminute = [];
$scope.labelsperminute = [];
$scope.datasetOverride = [{ yAxisID: 'y-axis-1' }, { yAxisID: 'y-axis-2' }];
$scope.options = {
legend: { display: true },
tooltip:{
formatter: function() {
return 'The value for ' + this.x + ' is ' + this.y + ', in series '+ this.series.name;
}
},
/*multiTooltipTemplate: function(label) {
return label.label + ' ' + label.value;
},*/
responsive: true,
maintainAspectRatio: true,
scales: {
yAxes: [
{
id: 'y-axis-1',
type: 'linear',
display: true,
position: 'left'
},
{
id: 'y-axis-2',
type: 'linear',
display: true,
position: 'right'
}
]
},
scaleLabel: function(label){return label.value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");}
};
$scope.getkts = function(){
for(var i = 0; i < $rootScope.U.eventsData.length; i++){
if($rootScope.U.eventsData[i][7] == $rootScope.cevent)
return $rootScope.U.eventsData[i][2];
}
return '';
}
$scope.getData = function(){
$timeout(function(){
$http({
method: 'GET',
url: '../index.php?kt='+$scope.getkts()+'&r=cateringlocations'
}).then(function successCallback(response) {
$scope.alllocations = response.data[0];
$scope.catering_reports = response.data[1];
$scope.catering_dates = response.data[2];
$scope.dataperminute[0] = response.data[3];
$scope.catering_data = [];
$scope.labelsperminute = [];
$scope.series = [];
for(var l = 0; l < $scope.alllocations.length; l++){
$scope.catering_data.push([]);
$scope.series.push($scope.alllocations[l].LocationName);
for (var i = 0; i < $scope.dataperminute[0].length; i++) {
if($scope.alllocations[l].idCateringLocation == $scope.dataperminute[0][i]['location']){
var cp = $scope.dataperminute[0][i]['dates'].split(' ');
$scope.labelsperminute.push(cp[1]+'0');
$scope.catering_data[l].push($scope.dataperminute[0][i]['number']);
}
}
}
console.log($scope.catering_data);
}, function errorCallback(response) {
});
}, 1500);
};
$scope.getData();
$scope.refreshData = function () {
$scope.getData();
};
$scope.setLo = function(l){
$scope.currentLocation = l;
$scope.catering_data = [[]];
$scope.labelsperminute = [];
$scope.datascope.showAll = false;
for (var i = 0; i < $scope.dataperminute[0].length; i++) {
if ($scope.dataperminute[0][i]['location'] == l.idCateringLocation) {
var cp = $scope.dataperminute[0][i]['dates'].split(' ');
$scope.labelsperminute.push(cp[1]+'0');
$scope.catering_data[0].push($scope.dataperminute[0][i]['number']);
}
}
};
$scope.reportTime = function(start, end) {
if (start == '09:00' || start == '10:00')
return "Breakfast";
if (start == '12:00' || start == '11:00')
return "Lunch";
if (start == '17:00' || start == '18:00')
return "Dinner";
};
$scope.editFeedback = function (fbd) {
$scope.currentFeedback = fbd;
$('#edit_feedback').modal('show');
};
$scope.saveFeedback = function (fdb, loc) { //SET THE PATH
Api.post('PATH', fdb).then(function (result) {
$scope.alllocations = result;
});
$('#edit_feedback').modal('hide');
};
$scope.calcChart = function(){
$scope.catering_data = [];
$scope.labelsperminute = [];
$scope.series = [];
for(var l = 0; l < $scope.alllocations.length; l++){
$scope.catering_data.push([]);
$scope.series.push($scope.alllocations[l].LocationName);
for (var i = 0; i < $scope.dataperminute[0].length; i++) {
if($scope.alllocations[l].idCateringLocation == $scope.dataperminute[0][i]['location']){
var cp = $scope.dataperminute[0][i]['dates'].split(' ');
$scope.labelsperminute.push(cp[1]+'0');
$scope.catering_data[l].push($scope.dataperminute[0][i]['number']);
}
}
}
};
$scope.editLocationName = function (name) {
$scope.currentName = name;
$('#edit_locationName').modal('show');
};
$scope.saveLocationName = function (name, loc) { //SET THE PATH
Api.post('PATH', name).then(function (result) {
$scope.alllocations = result;
});
$('#edit_locationName').modal('hide');
};
})
.filter('range', function() {
return function(input, total) {
total = parseInt(total);
for (var i=0; i' +
'' +
'\u2606' +
'' +
'',
scope: {
ratingValue: '=',
max: '='
},
link: function (scope, elem, attrs) {
scope.stars = [];
for (var i = 0; i < scope.max; i++) {
scope.stars.push({
filled: i < scope.ratingValue
});
}
}
}
}).controller('crowdController', function($scope, $rootScope) {
$rootScope.$watch("data.crowd", function(){
if(!angular.isUndefined($rootScope.data.crowd))
$scope.crowd = $rootScope.data.crowd[0];
});
}).controller('youControlReportController', function(Data,$scope, $rootScope, $http, $timeout) {
$scope.calendarView = 'week';
$scope.viewDate = moment();
$scope.events = [
/*{
title: 'My event title', // The title of the event
startsAt: moment(), // A javascript date object for when the event starts
endsAt: moment().add(7, 'days'), // Optional - a javascript date object for when the event ends
color: { // can also be calendarConfig.colorTypes.warning for shortcuts to the deprecated event types
primary: '#e3bc08', // the primary event color (should be darker than secondary)
secondary: '#fdf1ba' // the secondary event color (should be lighter than primary)
},
actions: [{ // an array of actions that will be displayed next to the event title
label: '', // the label of the action
cssClass: 'edit-action', // a CSS class that will be added to the action element so you can implement custom styling
onClick: function(args) { // the action that occurs when it is clicked. The first argument will be an object containing the parent event
console.log('Edit event', args.calendarEvent);
}
},
{
label: '',
onClick: function(args) {
alert.show('Deleted', args.calendarEvent);
}
}],
draggable: true, //Allow an event to be dragged and dropped
resizable: true, //Allow an event to be resizable
incrementsBadgeTotal: true, //If set to false then will not count towards the badge total amount on the month and year view
recursOn: 'year', // If set the event will recur on the given period. Valid values are year or month
cssClass: 'a-css-class-name', //A CSS class (or more, just separate with spaces) that will be added to the event when it is displayed on each view. Useful for marking an event as selected / active etc
allDay: true // set to true to display the event as an all day event on the day view
}*/
];
$scope.events_copy = [];
$timeout(function () {
Data.get('getyclocations?evv='+$rootScope.data.evv).then(function (result) {
$scope.locations = result;
$scope.selectAllLocations($scope.locations);
});
Data.get('getallycactype?evv='+$rootScope.data.evv).then(function (result) {
$scope.activity_types = result;
});
}, 1000);
$scope.selected_location = null;
$rootScope.cu_loc = {data: null};
$rootScope.cu_acc_type = {data: null};
$scope.search = {data: ''};
$scope.change = true;
$scope.searchData = function (string) {
$scope.events = [];
if (string.length == 0) {
$scope.events = angular.copy( $scope.events_copy);
}
else{
for (var i = 0; i < $scope.events_copy.length; i++) {
if ($scope.events_copy[i]['search'].toLowerCase().indexOf(string) > -1) {
$scope.events.push($scope.events_copy[i]);
}
}
}
};
$scope.refreshData = function (location, activity) {
$timeout(function () {
Data.get('getallycactype?evv='+$rootScope.data.evv).then(function (result) {
$scope.activity_types = result;
});
Data.get('getyclocations?evv='+$rootScope.data.evv).then(function (result) {
$scope.locations = result;
$scope.selected_location = location;
$scope.selected_activity = activity;
if ($scope.selected_location != null) {
if ($scope.selected_activity == null) {
for (var i = 0; i < $scope.locations.length; i++) {
if ($scope.locations[i]['idYCLocation'] == $scope.selected_location['idYCLocation']) {
$scope.change = false;
$rootScope.cu_loc['data'] = $scope.locations[i];
$scope.setCurrentLocation($rootScope.cu_loc['data']);
break;
}
}
}
else{
for (var i = 0; i < $scope.locations.length; i++) {
if ($scope.locations[i]['idYCLocation'] == $scope.selected_location['idYCLocation']) {
$scope.change = false;
$rootScope.cu_loc['data'] = $scope.locations[i];
$scope.setCurrentLocation($rootScope.cu_loc['data']);
break;
}
}
$scope.setCurrentActivity($scope.selected_activity);
}
}
else{
if ($scope.selected_activity == null) {
$scope.change = true;
$scope.selectAllLocations($scope.locations);
}
else{
$scope.setCurrentActivity($scope.selected_activity);
}
}
});
}, 1000);
};
$scope.selectAllLocations = function (locations) {
$scope.events = [];
for (var i = 0; i < locations.length; i++) {
for (var j = 0; j < locations[i]['activities'].length; j++) {
$scope.color = locations[i]['activities'][j]['BackgroundColor'].split(',');
$scope.add = {
search: locations[i]['LocationName']+locations[i]['activities'][j]['Titel']+locations[i]['activities'][j]['TOTALIN']
+locations[i]['activities'][j]['Max_Capacity']+locations[i]['Max_Capacity'],
idActivity: locations[i]['activities'][j]['idActivity'],
activityTitle: locations[i]['activities'][j]['Titel'],
title:
''+locations[i]['LocationName']+' | '+
locations[i]['activities'][j]['Titel']
+'
'
+locations[i]['activities'][j]['TOTALIN']
+' / '
+(locations[i]['activities'][j]['Max_Capacity'] == 0 ? '∞' : locations[i]['activities'][j]['Max_Capacity'])
+' ['
+(locations[i]['activities'][j]['Max_Capacity'] == 0 ? '∞' : locations[i]['Max_Capacity'])+']',// The title of the event
startsAt: (new Date(locations[i]['activities'][j]['FromDateTime'])), // A javascript date object for when the event starts
endsAt: (new Date(locations[i]['activities'][j]['ToDateTime'])), // Optional - a javascript date object for when the event ends
color: { // can also be calendarConfig.colorTypes.warning for shortcuts to the deprecated event types
secondary: rgb2hex($scope.color[0], $scope.color[1], $scope.color[2]), // the primary event color (should be darker than secondary)
primary: rgb2hex($scope.color[0], $scope.color[1], $scope.color[2]) // the secondary event color (should be lighter than primary)
},
actions: [{ // an array of actions that will be displayed next to the event title
label: '', // the label of the action
cssClass: 'edit-action', // a CSS class that will be added to the action element so you can implement custom styling
onClick: function(args) { // the action that occurs when it is clicked. The first argument will be an object containing the parent event
//console.log('Edit event', args.calendarEvent);
$scope.current_tickets = [];
$scope.current_activity = [];
$scope.current_activity = args.calendarEvent;
Data.get('getallycacscans?evv='+$rootScope.data.evv+'&act='+args.calendarEvent['idActivity']).then(function (result) {
$scope.current_tickets = result;
$scope.title = 'ALL GUESTS OVERVIEW';
$('#location_activities').modal('show');
});
}
}],
draggable: true, //Allow an event to be dragged and dropped
resizable: true, //Allow an event to be resizable
incrementsBadgeTotal: true, //If set to false then will not count towards the badge total amount on the month and year view
recursOn: 'year', // If set the event will recur on the given period. Valid values are year or month
cssClass: 'a-css-class-name', //A CSS class (or more, just separate with spaces) that will be added to the event when it is displayed on each view. Useful for marking an event as selected / active etc
allDay: false // set to true to display the event as an all day event on the day view
};
////////CHECK FOR SCANS////////////
if ((locations[i]['activities'][j]['TOTALIN'] > locations[i]['Max_Capacity']) && (locations[i]['activities'][j]['Max_Capacity'] != 0)) {
$scope.add['title'] = $scope.add['title']+' ';
}
if ((locations[i]['activities'][j]['TOTALIN'] > locations[i]['activities'][j]['Max_Capacity']) && (locations[i]['activities'][j]['Max_Capacity'] != 0)) {
$scope.add['title'] = $scope.add['title']+' ';
$scope.add['search'] = $scope.add['search']+'over capacity';
}
$scope.events.push(angular.copy($scope.add));
}
}
$scope.change = true;
$scope.events_copy = angular.copy($scope.events);
};
$scope.setCurrentLocation = function (location) {
if ($scope.change == true) {
$rootScope.cu_loc['data'] = location;
}
$scope.events = [];
$scope.selected_location = $rootScope.cu_loc['data'];
if ($scope.selected_location == null) {
$scope.selectAllLocations($scope.locations);
}
else{
$scope.loc_array = $rootScope.cu_loc['data'];
for (var i = 0; i < $scope.loc_array['activities'].length; i++) {
$scope.color = $scope.loc_array['activities'][i]['BackgroundColor'].split(',');
$scope.add = {
search: $scope.loc_array['activities'][i]['Titel']+$scope.loc_array['activities'][i]['TOTALIN']
+$scope.loc_array['activities'][i]['Max_Capacity']+$scope.loc_array['Max_Capacity'],
idActivity: $scope.loc_array['activities'][i]['idActivity'],
activityTitle: $scope.loc_array['activities'][i]['Titel'],
title:
$scope.loc_array['activities'][i]['Titel']
+'
'
+$scope.loc_array['activities'][i]['TOTALIN']
+' / '
+($scope.loc_array['activities'][i]['Max_Capacity'] == 0 ? '∞' : $scope.loc_array['activities'][i]['Max_Capacity'])
+' ['
+($scope.loc_array['activities'][i]['Max_Capacity'] == 0 ? '∞' : $scope.loc_array['Max_Capacity'])+']',// The title of the event
startsAt: (new Date($scope.loc_array['activities'][i]['FromDateTime'])), // A javascript date object for when the event starts
endsAt: (new Date($scope.loc_array['activities'][i]['ToDateTime'])), // Optional - a javascript date object for when the event ends
color: { // can also be calendarConfig.colorTypes.warning for shortcuts to the deprecated event types
primary: rgb2hex($scope.color[0], $scope.color[1], $scope.color[2]), // the primary event color (should be darker than secondary)
secondary: rgb2hex($scope.color[0], $scope.color[1], $scope.color[2]) // the secondary event color (should be lighter than primary)
},
actions: [{ // an array of actions that will be displayed next to the event title
label: '', // the label of the action
cssClass: 'edit-action', // a CSS class that will be added to the action element so you can implement custom styling
onClick: function(args) { // the action that occurs when it is clicked. The first argument will be an object containing the parent event
//console.log('Edit event', args.calendarEvent);
$scope.current_tickets = [];
$scope.current_activity = [];
$scope.current_activity = args.calendarEvent;
Data.get('getallycacscans?evv='+$rootScope.data.evv+'&act='+args.calendarEvent['idActivity']).then(function (result) {
$scope.current_tickets = result;
$scope.title = 'ALL GUESTS OVERVIEW';
$('#location_activities').modal('show');
});
}
}],
draggable: true, //Allow an event to be dragged and dropped
resizable: true, //Allow an event to be resizable
incrementsBadgeTotal: true, //If set to false then will not count towards the badge total amount on the month and year view
recursOn: 'year', // If set the event will recur on the given period. Valid values are year or month
cssClass: 'a-css-class-name', //A CSS class (or more, just separate with spaces) that will be added to the event when it is displayed on each view. Useful for marking an event as selected / active etc
allDay: false // set to true to display the event as an all day event on the day view
};
////////CHECK FOR SCANS////////////
if (($scope.loc_array['activities'][i]['TOTALIN'] > $scope.loc_array['Max_Capacity']) && ($scope.loc_array['activities'][i]['Max_Capacity'] != 0)) {
$scope.add['title'] = $scope.add['title']+' ';
}
if (($scope.loc_array['activities'][i]['TOTALIN'] > $scope.loc_array['activities'][i]['Max_Capacity']) && ($scope.loc_array['activities'][i]['Max_Capacity'] != 0)) {
$scope.add['title'] = $scope.add['title']+' ';
$scope.add['search'] = $scope.add['search']+'over capacity';
}
$scope.events.push(angular.copy($scope.add));
}
}
$scope.change = true;
$scope.events_copy = angular.copy($scope.events);
};
$scope.setCurrentActivity = function (activity) {
$scope.events_copy = angular.copy($scope.events);
$scope.events = [];
$scope.selected_acc = $rootScope.cu_acc_type['data'];
if ($rootScope.cu_loc['data'] == null) {
if ($scope.selected_acc == null) {
$scope.selectAllLocations($scope.locations);
}
else{
$scope.events = [];
$scope.loc_array = $scope.locations;
for (var i = 0; i < $scope.loc_array.length; i++) {
for (var j = 0; j < $scope.loc_array[i]['activities'].length; j++) {
if ($scope.loc_array[i]['activities'][j]['ActivityType'] == $scope.selected_acc) {
$scope.color = $scope.loc_array[i]['activities'][j]['BackgroundColor'].split(',');
$scope.add = {
search: $scope.loc_array[i]['activities'][j]['Titel']+$scope.loc_array[i]['activities'][j]['TOTALIN']
+$scope.loc_array[i]['activities'][j]['Max_Capacity']+$scope.loc_array[i]['Max_Capacity'],
idActivity: $scope.loc_array[i]['activities'][j]['idActivity'],
activityTitle: $scope.loc_array[i]['activities'][j]['Titel'],
title:
$scope.loc_array[i]['activities'][j]['Titel']
+'
'
+$scope.loc_array[i]['activities'][j]['TOTALIN']
+' / '
+($scope.loc_array[i]['activities'][j]['Max_Capacity'] == 0 ? '∞' : $scope.loc_array[i]['activities'][j]['Max_Capacity'])
+' ['
+($scope.loc_array[i]['activities'][j]['Max_Capacity'] == 0 ? '∞' : $scope.loc_array[i]['Max_Capacity'])+']',// The title of the event
startsAt: (new Date($scope.loc_array[i]['activities'][j]['FromDateTime'])), // A javascript date object for when the event starts
endsAt: (new Date($scope.loc_array[i]['activities'][j]['ToDateTime'])), // Optional - a javascript date object for when the event ends
color: { // can also be calendarConfig.colorTypes.warning for shortcuts to the deprecated event types
primary: rgb2hex($scope.color[0], $scope.color[1], $scope.color[2]), // the primary event color (should be darker than secondary)
secondary: rgb2hex($scope.color[0], $scope.color[1], $scope.color[2]) // the secondary event color (should be lighter than primary)
},
actions: [{ // an array of actions that will be displayed next to the event title
label: '', // the label of the action
cssClass: 'edit-action', // a CSS class that will be added to the action element so you can implement custom styling
onClick: function(args) { // the action that occurs when it is clicked. The first argument will be an object containing the parent event
$scope.current_tickets = [];
$scope.current_activity = [];
$scope.current_activity = args.calendarEvent;
Data.get('getallycacscans?evv='+$rootScope.data.evv+'&act='+args.calendarEvent['idActivity']).then(function (result) {
$scope.current_tickets = result;
$scope.title = 'ALL GUESTS OVERVIEW';
$('#location_activities').modal('show');
});
}
}],
draggable: true, //Allow an event to be dragged and dropped
resizable: true, //Allow an event to be resizable
incrementsBadgeTotal: true, //If set to false then will not count towards the badge total amount on the month and year view
recursOn: 'year', // If set the event will recur on the given period. Valid values are year or month
cssClass: 'a-css-class-name', //A CSS class (or more, just separate with spaces) that will be added to the event when it is displayed on each view. Useful for marking an event as selected / active etc
allDay: false // set to true to display the event as an all day event on the day view
};
////////CHECK FOR SCANS////////////
if (($scope.loc_array[i]['activities'][j]['TOTALIN'] > $scope.loc_array[i]['Max_Capacity']) && ($scope.loc_array[i]['activities'][j]['Max_Capacity'] != 0)) {
$scope.add['title'] = $scope.add['title']+' ';
}
if (($scope.loc_array[i]['activities'][j]['TOTALIN'] > $scope.loc_array[i]['activities'][j]['Max_Capacity']) && ($scope.loc_array[i]['activities'][j]['Max_Capacity'] != 0)) {
$scope.add['title'] = $scope.add['title']+' ';
$scope.add['search'] = $scope.add['search']+'over capacity';
}
$scope.events.push(angular.copy($scope.add));
}
}
}
}
}
else{
if ($scope.selected_acc == null) {
$scope.setCurrentLocation($rootScope.cu_loc['data']);
}
else{
$scope.events = [];
$scope.loc_array = $rootScope.cu_loc['data'];
for (var i = 0; i < $scope.loc_array['activities'].length; i++) {
if ($scope.loc_array['activities'][i]['ActivityType'] == $scope.selected_acc) {
$scope.color = $scope.loc_array['activities'][i]['BackgroundColor'].split(',');
$scope.add = {
search: $scope.loc_array['activities'][i]['Titel']+$scope.loc_array['activities'][i]['TOTALIN']
+$scope.loc_array['activities'][i]['Max_Capacity']+$scope.loc_array['Max_Capacity'],
idActivity: $scope.loc_array['activities'][i]['idActivity'],
activityTitle: $scope.loc_array['activities'][i]['Titel'],
title:
$scope.loc_array['activities'][i]['Titel']
+'
'
+$scope.loc_array['activities'][i]['TOTALIN']
+' / '
+($scope.loc_array['activities'][i]['Max_Capacity'] == 0 ? '∞' : $scope.loc_array['activities'][i]['Max_Capacity'])
+' ['
+($scope.loc_array['activities'][i]['Max_Capacity'] == 0 ? '∞' : $scope.loc_array['Max_Capacity'])+']',// The title of the event
startsAt: (new Date($scope.loc_array['activities'][i]['FromDateTime'])), // A javascript date object for when the event starts
endsAt: (new Date($scope.loc_array['activities'][i]['ToDateTime'])), // Optional - a javascript date object for when the event ends
color: { // can also be calendarConfig.colorTypes.warning for shortcuts to the deprecated event types
primary: rgb2hex($scope.color[0], $scope.color[1], $scope.color[2]), // the primary event color (should be darker than secondary)
secondary: rgb2hex($scope.color[0], $scope.color[1], $scope.color[2]) // the secondary event color (should be lighter than primary)
},
actions: [{ // an array of actions that will be displayed next to the event title
label: '', // the label of the action
cssClass: 'edit-action', // a CSS class that will be added to the action element so you can implement custom styling
onClick: function(args) { // the action that occurs when it is clicked. The first argument will be an object containing the parent event
//console.log('Edit event', args.calendarEvent);
$scope.current_tickets = [];
$scope.current_activity = [];
$scope.current_activity = args.calendarEvent;
Data.get('getallycacscans?evv='+$rootScope.data.evv+'&act='+args.calendarEvent['idActivity']).then(function (result) {
$scope.current_tickets = result;
$scope.title = 'ALL GUESTS OVERVIEW';
$('#location_activities').modal('show');
});
}
}],
draggable: true, //Allow an event to be dragged and dropped
resizable: true, //Allow an event to be resizable
incrementsBadgeTotal: true, //If set to false then will not count towards the badge total amount on the month and year view
recursOn: 'year', // If set the event will recur on the given period. Valid values are year or month
cssClass: 'a-css-class-name', //A CSS class (or more, just separate with spaces) that will be added to the event when it is displayed on each view. Useful for marking an event as selected / active etc
allDay: false // set to true to display the event as an all day event on the day view
};
////////CHECK FOR SCANS////////////
if (($scope.loc_array['activities'][i]['TOTALIN'] > $scope.loc_array['Max_Capacity']) && ($scope.loc_array['activities'][i]['Max_Capacity'] != 0)) {
$scope.add['title'] = $scope.add['title']+' ';
}
if (($scope.loc_array['activities'][i]['TOTALIN'] > $scope.loc_array['activities'][i]['Max_Capacity']) && ($scope.loc_array['activities'][i]['Max_Capacity'] != 0)) {
$scope.add['title'] = $scope.add['title']+' ';
$scope.add['search'] = $scope.add['search']+'over capacity';
}
$scope.events.push(angular.copy($scope.add));
}
}
}
}
$scope.events_copy = angular.copy($scope.events);
};
$scope.goChip = function(c){
$('#location_activities').modal('hide');
$timeout(function () {
$rootScope.data.chipsearch = c;
$rootScope.location.path("/chips");
}, 1000);
};
$scope.eventClicked = function (activity) {
$scope.current_tickets = [];
$scope.current_activity = [];
$scope.current_activity = activity;
Data.get('getycacscans?evv='+$rootScope.data.evv+'&act='+activity['idActivity']).then(function (result) {
$scope.current_tickets = result[0];
$scope.activity_details = result[1];
$scope.title = 'GUESTS CURRENTLY IN';
$('#location_activities').modal('show');
});
};
$scope.bulkCheckout = function(activity){
$scope.current_activity = activity;
var d = confirm("Are you sure you want to perform a bulk checkout for this activity?");
if(d)
{
Data.get('bulkcheckout?evv='+$rootScope.data.evv+'&idAct='+activity['idActivity']).then(function (result) {
$scope.checkout = result;
$('#location_activities').modal('hide');
$scope.refreshData($scope.selected_location, $scope.selected_activity);
});
}
else
$('#location_activities').modal('hide');
};
function rgb2hex(red, green, blue) {
var rgb = blue | (green << 8) | (red << 16);
return '#' + (0x1000000 + rgb).toString(16).slice(1)
}
}).controller('ycontrolController', function(Data,$scope, $rootScope, $http, $timeout,toaster) {
$scope.newName = '';
$scope.newCapacity = '';
$scope.currentLocation = {};
$scope.currentAttribute = {};
$scope.currentSubActivity = {};
$scope.currentActivity = {};
$scope.currentParentActivity = {};
$rootScope.selectedOption = '';
$rootScope.selectedRole = '';
$scope.currentType = {};
$scope.getMapping = {};
$scope.chosenActType = {};
$scope.currentName = '';
$scope.NewGroup = '';
$scope.NewColor = '';
$rootScope.activeOv = 1;
$rootScope.Index = 1;
$rootScope.providerName = {};
$rootScope.passtypes = [];
$rootScope.selectedProvider = {};
$scope.showActivities = false;
$scope.showSubAct = false;
$scope.showTickets = false;
$scope.showAttributes = false;
$scope.copyData = false;
$scope.RealFrom = 0;
$scope.RealTo = 0;
$scope.Issuer = [{ id: 0, name: 'Choose' }, { id: -1, name: 'Guest' }, { id: -2, name: 'Helpdesk' }];
$rootScope.showApprove = false;
$rootScope.AssignedCompany = false;
$scope.activitysearch = '';
$rootScope.AssignmentAllowed = true;
$scope.data.orderParam = "ActivityType";
$rootScope.showadvanced = false;
$scope.clone = 0;
$scope.LocationGrouping = [];
$scope.currentScans = {};
$scope.nrscansnow = 0;
$scope.setOrder = function (o) {
$scope.data.orderParam = o;
}
$scope.setStatus = function (ind) {
if (ind == 1)
$scope.copyData = true;
else
$scope.copyData = false;
}
$rootScope.rgb2hex = function (rgb) {
rgb = rgb.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);
return (rgb && rgb.length === 4) ? "#" +
("0" + parseInt(rgb[1], 10).toString(16)).slice(-2) +
("0" + parseInt(rgb[2], 10).toString(16)).slice(-2) +
("0" + parseInt(rgb[3], 10).toString(16)).slice(-2) : '';
};
$rootScope.setActiveOv = function (i) {
$rootScope.activeOv = i;
}
$rootScope.setIndex = function (ind) {
$rootScope.Index = ind;
$scope.currentLocation = {};
$scope.currentAttribute = {};
$scope.currentActivity = {};
$scope.currentType = {};
$scope.getMapping = {};
$scope.chosenActType = {};
if ($rootScope.Index == 3) {
$scope.refreshData();
$scope.getLocalTicketTypes();
}
if($rootScope.Index == 4)
$scope.getApprovaloverview();
};
$scope.refreshData = function () {
$scope.chosenActType = {};
$scope.currentActivity = {};
$scope.currentLocation = {};
$scope.currentName = '';
$scope.showActivities = false;
$scope.showSubAct = false;
var relateddates = "";
if ($rootScope.dates.dt1 != "" && $rootScope.dates.dt2 != "")
relateddates = "&dt1=" + $rootScope.dates.dt1 + "&dt2=" + $rootScope.dates.dt2;
Data.get('locationoverview?evv=' + $rootScope.data.evv + relateddates).then(function (results) {
$rootScope.yclocations = results[0];
$rootScope.providers = results[1];
$rootScope.ycticketype = results[2];
$rootScope.parentactivity = results[3];
$rootScope.ycactivitytype = results[4];
});
};
$scope.openScans = function(activity){
Data.get('geteactivityscans?evv=' + $rootScope.data.evv+'&idActivity='+activity.idActivity ).then(function (results) {
$scope.curActivity = activity;
$scope.currentScans = results[0];
$scope.nrscansnow = $scope.currentScans.length;
$('#activity_scans').modal('show');
});
};
$scope.getApprovaloverview = function () {
Data.get('approvalov?evv=' + $rootScope.data.evv ).then(function (results) {
$scope.approvalOverview = results;
});
};
$scope.addLocation = function () {
$('#add_location').modal('show');
};
$scope.createLocation = function (name, capacity, newAddress, newZip) {
Data.get('savelocation?evv=' + $rootScope.data.evv + '&locationname=' + name
+ '&capacity=' + capacity
+ '&address=' + newAddress
+ '&zip=' + newZip
).then(function (results) {
$('#add_location').modal('hide');
$scope.refreshData();
});
};
$scope.deleteLocation = function (l) {
$scope.currentLocation = l;
$('#delete_location').modal('show');
};
$scope.confirmDeletion = function (l) {
Data.get('deletelocation?evv=' + $rootScope.data.evv + '&idloc=' + l.idYCLocation).then(function (results) {
$('#delete_location').modal('hide');
$scope.refreshData();
});
};
$scope.editLocation = function (l) {
$scope.currentLocation = l;
$('#edit_location').modal('show');
};
$scope.updateLocation = function (l) {
Data.get('updatelocation?evv=' + $rootScope.data.evv + '&locationname=' + l.LocationName
+ '&capacity=' + l.Max_Capacity + '&idlocation=' + l.idYCLocation
+ '&address=' + l.Address
+ '&zip=' + l.Zip
).then(function (results) {
$('#edit_location').modal('hide');
$scope.refreshData();
});
};
$scope.showTypes = function (a, idtickettype = 0) {
$scope.currentActivity = a;
$('#assign_tickettypes').modal('show');
Data.get('getpasstype?evv=' + $rootScope.data.evv + '&idActivity=' + a.idActivity + '&type=' + idtickettype).then(function (results) {
$rootScope.passtypes = results[0];
$rootScope.ticketproviders = results[1];
});
};
$rootScope.assignAllTickets = function (p) {
Data.get('assignpasstype?evv=' + $rootScope.data.evv + '&idActivity=' + $scope.currentActivity.idActivity + '&idtickettype=' + p.idResellerTicketType + '&titel=' + p.Titel).then(function (results) {
if (results == "1") {
$rootScope.AssignmentAllowed = true;
$scope.openTicketList($scope.currentType, $rootScope.AssignmentAllowed);
}
else {
$rootScope.AssignmentAllowed = false;
$scope.openTicketList($scope.currentType, $rootScope.AssignmentAllowed);
}
});
};
$rootScope.assignTicket = function (t) {
if($rootScope.userIsAllowed('access_edit')){
Data.get('assignticket?evv=' + $rootScope.data.evv + '&idActivity=' + $scope.currentActivity.idActivity + '&idtickettype=' + $scope.currentType.idResellerTicketType + '&titel=' + $scope.currentType.Titel + '&ticket=' + t.idTicket + '&qnt=' + t.Quantity).then(function (results) {
$scope.openTicketList($scope.currentType);
});
}
else
alert("You have no permission to perform this operation!");
};
$rootScope.removeAllTickets = function (p) {
Data.get('removepasstype?evv=' + $rootScope.data.evv + '&idActivity=' + $scope.currentActivity.idActivity + '&idtickettype=' + p.idResellerTicketType).then(function (results) {
$scope.openTicketList($scope.currentType);
});
};
$rootScope.removeTicket = function (t) {
if($rootScope.userIsAllowed('access_edit')){
Data.get('removeticket?evv=' + $rootScope.data.evv + '&idActivity=' + $scope.currentActivity.idActivity + '&idtickettype=' + $scope.currentType.idResellerTicketType + '&ticket=' + t.idTicket).then(function (results) {
$scope.openTicketList($scope.currentType);
});
}
else
alert("You have no permission to perform this operation!");
};
$scope.showActivity = function (l) {
$scope.currentLocation = l;
$scope.showActivities = true;
$scope.showSubAct = false;
Data.get('getact?evv=' + $rootScope.data.evv + '&idlocation=' + $scope.currentLocation.idYCLocation + '&idacttype=' + $scope.currentType.idActivityType).then(function (results) {
$rootScope.acttype = results[0];
$rootScope.act = results[1];
$rootScope.actaction = results[2];
$rootScope.actroles = results[3];
$rootScope.selectedOption = $rootScope.actaction[0].idActivityAction;
$rootScope.selectedRole = $rootScope.actroles[0].idActivityRole;
for (var i = 0; i < $rootScope.act.length; i++) {
$rootScope.act[i].BackgroundColor = $rootScope.rgb2hex("rgb(" + $rootScope.act[i].BackgroundColor + ")");
}
});
};
$scope.showSubActivities = function (a) {
$scope.currentActivity = a;
$scope.currentParentActivity = a;
$scope.showSubAct = true;
Data.get('getsubact?evv=' + $rootScope.data.evv + '&idActivity=' + $scope.currentActivity.idActivity).then(function (results) {
$rootScope.subact = results[1];
for (var i = 0; i < $rootScope.subact.length; i++) {
$rootScope.subact[i].BackgroundColor = $rootScope.rgb2hex("rgb(" + $rootScope.subact[i].BackgroundColor + ")");
}
});
};
$scope.HideSubActivity = function () {
$scope.showSubAct = false;
$scope.currentActivity = {};
};
$scope.addActivity = function () {
var NewDate = new Date().toISOString().slice(0, -8);
NewDate = NewDate.replace("T", " ");
NewDate = NewDate + ":00";
$rootScope.activity = { OneDirection: 0, idActivityType: $rootScope.acttype[0]["idActivityType"], FromDateTime: NewDate, ToDateTime: NewDate, Issuer: $scope.Issuer[0]['id'] };
$('#add_activity').modal('show');
};
$scope.createActivity = function (from, to, actaction, actrole) {
$scope.RealFrom = from;
$scope.RealTo = to;
$rootScope.Req.post('saveactivity?evv=' + $rootScope.data.evv + '&idlocation=' + $scope.currentLocation.idYCLocation + '&realfrom=' + $scope.RealFrom + '&realto=' + $scope.RealTo + '&idactaction=' + actaction + '&idactrole=' + actrole, [$rootScope.activity]).then(function (results) {
$scope.showActivity($scope.currentLocation);
});
$('#add_activity').modal('hide');
};
$scope.editActivity = function (a) {
$rootScope.activity = a;
$('#edit_activity').modal('show');
};
$scope.updateActivity = function (a) {
if($rootScope.userIsAllowed('access_edit')){
$rootScope.Req.post('updateactivity?evv=' + $rootScope.data.evv, [$rootScope.activity]).then(function (results) {
if (results == "False") {
$('#edit_activity').modal('hide');
$('#activityupdate_info').modal('show');
}
else
$scope.showActivity($scope.currentLocation);
});
$('#edit_activity').modal('hide');
}
else{
$('#edit_activity').modal('hide');
alert("You have no permission to perform this operation!");
}
};
$scope.addSubActivity = function () {
$rootScope.activity = $scope.currentActivity;
$rootScope.subactivity = {};
$rootScope.subactivity.FromDateTime = $rootScope.activity.FromDateTime;
$rootScope.subactivity.ToDateTime = $rootScope.activity.ToDateTime;
$('#add_subactivity').modal('show');
};
$scope.createSubActivity = function (from, to) {
$scope.RealFrom = from;
$scope.RealTo = to;
$rootScope.Req.post('savesubactivity?evv=' + $rootScope.data.evv + '&idActivity=' + $scope.currentActivity.idActivity + '&realfrom=' + $scope.RealFrom + '&realto=' + $scope.RealTo, [$rootScope.subactivity]).then(function (results) {
$scope.showSubActivities($scope.currentActivity);
$scope.RealFrom = 0;
$scope.RealTo = 0;
});
$('#add_subactivity').modal('hide');
};
$scope.editSubActivity = function (sa) {
$rootScope.subactivity = sa;
$('#edit_subactivity').modal('show');
};
$scope.updateSubActivity = function (sa) {
if($rootScope.userIsAllowed('access_edit')){
$rootScope.Req.post('updatesubactivity?evv=' + $rootScope.data.evv, [$rootScope.subactivity]).then(function (results) {
});
$('#edit_subactivity').modal('hide');
}
else
alert("You have no permission to perform this operation!");
};
$scope.deleteSubActivity = function (sa) {
$rootScope.confirmModal(
'Confirm',
'Do you want to delete Sub-Activity ' + sa['Titel'] + '?',
'Yes',
'Cancel',
function () {
$rootScope.Req.post('deletesubactivity?evv=' + $rootScope.data.evv, [sa]).then(function (results) {
$scope.showSubActivities($scope.currentActivity);
});
}, null);
};
$scope.deleteActivity = function (a) {
$rootScope.confirmModal(
'Confirm',
'Do you want to delete Activity ' + a['Titel'] + '?',
'Yes',
'Cancel',
function () {
$rootScope.Req.post('deleteactivity?evv=' + $rootScope.data.evv, [a]).then(function (results) {
$scope.showActivity($scope.currentLocation);
});
}, null);
};
$scope.getOverview = function (p) {
$scope.currentType = p;
$('#assign_tickettypes').modal('hide');
$('#tickettype_overview').modal('show');
Data.get('typeoverview?evv=' + $rootScope.data.evv + '&idtickettype=' + $scope.currentType.idResellerTicketType).then(function (results) {
/*console.table(results[0]);*/
$rootScope.access = results[0];
$rootScope.tickpertype = results[1];
$rootScope.ticketinfo = results[2];
});
};
$scope.getLocations = function () {
Data.get('locationoverview?evv=' + $rootScope.data.evv).then(function (results) {
$rootScope.yclocations = results[0];
$rootScope.providers = results[1];
$rootScope.ycticketype = results[2];
$rootScope.parentactivity = results[3];
});
};
$scope.getActPerTypes = function (p) {
$scope.Types = p;
$('#activities_types').modal('show');
Data.get('getactpertypes?evv=' + $rootScope.data.evv + '&idtickettype=' + $scope.Types.id).then(function (results) {
$rootScope.actpertype = results[0];
$rootScope.acttickinfo = results[1];
});
};
$scope.addActGroup = function () {
$scope.NewGroup = '';
$scope.NewColor = '';
$('#add_activitygroup').modal('show');
Data.get('getactgroup?evv=' + $rootScope.data.evv).then(function (results) {
$rootScope.actgroup = results;
for (var i = 0; i < $rootScope.actgroup.length; i++) {
$rootScope.actgroup[i].BackgroundColor = $rootScope.rgb2hex("rgb(" + $rootScope.actgroup[i].BackgroundColor + ")");
}
});
};
$scope.editActGroup = function (acttype) {
$scope.chosenActType = acttype;
$('#add_activitygroup').modal('hide');
$('#edit_activitygroup').modal('show');
};
$scope.SaveEditedActType = function (a) {
Data.get('updateactype?evv=' + $rootScope.data.evv + '&acttype=' + a.ActivityType + '&bgcolor=' + a.BackgroundColor.replace('#', '') + '&idacttype=' + a.idActivityType).then(function (results) {
$('#edit_activitygroup').modal('hide');
$scope.addActGroup();
});
};
$scope.createActGroup = function (titel, color) {
Data.get('saveactype?evv=' + $rootScope.data.evv + '&acttype=' + titel + '&bgcolor=' + color.replace('#', '')).then(function (results) {
$scope.addActGroup();
});
};
$scope.returnBack = function () {
$('#tickettype_overview').modal('hide');
$('#assign_tickettypes').modal('show');
};
$scope.closeActTicketTypes = function () {
$('#activities_types').modal('hide');
};
$scope.getproviderTypes = function (pov) {
$rootScope.selectedProvider = pov;
Data.get('gettypeprov?evv=' + $rootScope.data.evv + '&provider=' + $rootScope.selectedProvider.idTicketProvider + "&ot=" + $rootScope.selectedProvider.OAUTH).then(function (results) {
$scope.providerTypes = results;
/*console.log($rootScope.ycticketype);*/
for (var i = 0; i < $scope.providerTypes.length; i++) {
$scope.providerTypes[i].imported = false;
for (var j = 0; j < $scope.ycticketype.length; j++) {
//console.log($scope.ticketTypes[j].idResellerTicketType);
if ($rootScope.ycticketype[j].idResellerTicketType == pov.CODE + "-" + $scope.providerTypes[i].id && $rootScope.ycticketype[j].Titel == $scope.providerTypes[i].name) {
$scope.providerTypes[i].imported = true;
}
}
}
});
};
$scope.showproviderTickets = function (type) {
$scope.showTickets = true;
$scope.showAttributes = false;
Data.get('getticketprov?evv=' + $rootScope.data.evv + '&provider=' + $rootScope.selectedProvider.idTicketProvider + "&ot=" + $rootScope.selectedProvider.OAUTH + '&idtype=' + type.id + '&event_id=' + type.event_id).then(function (results) {
$scope.providerTickets = results[0];
$scope.dbtickets = results[1];
for (var i = 0; i < $scope.providerTickets.length; i++) {
for (var j = 0; j < $scope.dbtickets.length; j++) {
if ($scope.providerTickets[i].barcode == $scope.dbtickets[j].Barcode) {
$scope.providerTickets[i].imported = $scope.dbtickets[j].isimported;
}
}
}
});
};
$scope.getTicketAttributes = function (type) {
$scope.currentType = type;
$scope.showTickets = false;
$scope.showAttributes = true;
Data.get('getproperties?evv=' + $rootScope.data.evv + '&provider=' + $rootScope.selectedProvider.idTicketProvider + "&ot=" + $rootScope.selectedProvider.OAUTH + '&idtype=' + type.id + '&event_id=' + type.event_id).then(function (results) {
$scope.providerAttributes = results[0];
$scope.getMapping = results[1];
$scope.gspreadExtend = results[2];
for (var i = 0; i < $scope.providerAttributes.length; i++) {
$scope.providerAttributes[i].isfound = false;
for (var j = 0; j < $scope.getMapping.length; j++)
if ($scope.providerAttributes[i].idproperty == $scope.getMapping[j].idProperty && $scope.providerAttributes[i].propertyvalue == $scope.getMapping[j].PropertyValue)
$scope.providerAttributes[i].isfound = true;
}
for (var i = 0; i < $scope.gspreadExtend.length; i++) {
$scope.gspreadExtend[i].isfound = false;
for (var j = 0; j < $scope.getMapping.length; j++)
if ($scope.gspreadExtend[i].idproperty == $scope.getMapping[j].idProperty && $scope.gspreadExtend[i].propertyvalue == $scope.getMapping[j].PropertyValue)
$scope.gspreadExtend[i].isfound = true;
}
});
};
$scope.openAttributesMapping = function (at) {
$('#map_attributes').modal('show');
$scope.currentAttribute = at;
Data.get('getproptype?evv=' + $rootScope.data.evv + '&idquest=' + $scope.currentAttribute.idproperty + '&ans=' + $scope.currentAttribute.propertyvalue).then(function (results) {
$scope.mapped = results;
});
};
$scope.mapToActivity = function (m) {
$rootScope.Req.post('maptoactivity?evv=' + $rootScope.data.evv + '&idprovider=' + $rootScope.selectedProvider.idTicketProvider + '&idActivity=' + m.idActivity, [$scope.currentAttribute]).then(function (results) {
$scope.openAttributesMapping($scope.currentAttribute);
$scope.getTicketAttributes($scope.currentType);
});
};
$scope.unmapFromActivity = function (id) {
Data.get('unmapfromactivity?evv=' + $rootScope.data.evv + '&dbid=' + id).then(function (results) {
$scope.openAttributesMapping($scope.currentAttribute);
$scope.getTicketAttributes($scope.currentType);
});
};
$scope.openTicketList = function (t, aallowed = true) {
$scope.currentType = t;
$rootScope.AssignmentAllowed = aallowed;
$rootScope.showApprove = false;
$('#assign_tickettypes').modal('hide');
$('#assign_tickets').modal('show');
Data.get('gettickets?evv=' + $rootScope.data.evv + '&idtype=' + $scope.currentType.idResellerTicketType + '&idact=' + $scope.currentActivity.idActivity).then(function (results) {
$rootScope.tickets = results[0];
$scope.alltickets = results[1];
$scope.ticketprops = results[2];
for (var i = 0; i < $rootScope.tickets.length; i++) {
if ($rootScope.tickets[i].Approved != 1 && $rootScope.tickets[i].TicketAssigned == 1) {
$rootScope.showApprove = true;
return $rootScope.showApprove;
}
}
return $rootScope.showApprove;
});
};
$scope.backTicketTypes = function () {
$('#assign_tickets').modal('hide');
$scope.showTypes($scope.currentActivity);
};
$scope.import_ticket_type = function (type) {
/*var cleanstring = type.name.replace("#", "@");*/
$rootScope.TypeOfTicket = type;
$rootScope.Req.post('importtypes?evv=' + $rootScope.data.evv + '&idtype=' + $rootScope.selectedProvider.CODE + '-' + type.id + '&idprov=' + $rootScope.selectedProvider.idTicketProvider, [$rootScope.TypeOfTicket]).then(function (results) {
$scope.getproviderTypes($rootScope.selectedProvider);
$rootScope.setIndex(2);
});
};
$scope.openCloneConfirmation = function (act, clone) {
$scope.currentActivity = act;
$scope.clone = clone;
$('#confirm_clone').modal('show');
};
$scope.cloneActivity = function (act, clone) {
Data.get('cloneact?evv=' + $rootScope.data.evv + '&idact=' + act.idActivity+'&clone='+ $scope.clone).then(function (results) {
if($scope.clone == 0)
$scope.showActivity($scope.currentLocation);
else
$rootScope.subact.push(results[0]);
$('#confirm_clone').modal('hide');
});
};
$scope.copyActivity = function () {
Data.get('getallacts?evv=' + $rootScope.data.evv).then(function (results) {
$scope.getallacts = results;
$('#copy_activity').modal('show');
});
};
$scope.saveCopyingActivity = function (id) {
Data.get('copyact?evv=' + $rootScope.data.evv + '&idloc=' + $scope.currentLocation.idYCLocation + '&idact=' + id + '©data=' + $scope.copyData).then(function (results) {
$scope.showActivity($scope.currentLocation);
$('#copy_activity').modal('hide');
});
};
$scope.setLocation = function () {
if($rootScope.data.ActivityM != null){
$rootScope.data.ActivityM = null;
$scope.currentActivity.idActivity = null;
$rootScope.data.idActivityTypeM = null;
}
$scope.currentLocation.idYCLocation = $rootScope.data.idYCLocationM;
$scope.getLocalTicketTypes();
};
$scope.setParentActivity = function() {
$timeout(
function(){
if($rootScope.data.ActivityM == null){
$scope.currentActivity.idActivity = null;
$rootScope.data.idYCLocationM = null;
$scope.currentLocation.idYCLocation = null;
$rootScope.data.idActivityTypeM = null;
}
else{
$scope.currentActivity = $rootScope.data.ActivityM.idActivity;
$rootScope.data.idYCLocationM = $rootScope.data.ActivityM.idYCLocation;
$scope.currentLocation.idYCLocation = $rootScope.data.idYCLocationM;
$rootScope.data.idActivityTypeM = $rootScope.data.ActivityM.ActivityType;
}
$scope.getLocalTicketTypes();
}
);
};
$scope.setActivityTypeFilter = function(){
if($rootScope.data.ActivityM != null){
$rootScope.data.ActivityM = null;
$scope.currentActivity.idActivity = null;
$rootScope.data.idYCLocationM = null;
$scope.currentLocation.idYCLocation = $rootScope.data.idYCLocationM;
}
$scope.getLocalTicketTypes();
};
$scope.setActivityType = function (idActType, cl) {
if(idActType != null)
{
$scope.currentType.idActivityType = idActType.idActivity;
}
else
{
$scope.currentType.idActivityType = 'undefined';
}
$scope.showActivity(cl);
}
$scope.getLocalTicketTypes = function () {
$rootScope.AllTicketTypes = [];
$rootScope.AllActivities = [];
$rootScope.ActPerTicketType = [];
$scope.LocationGrouping = [];
if($rootScope.data.maplocaltype)
{
Data.get('getlocalticktypes?evv=' + $rootScope.data.evv + '&idloc=' + $scope.currentLocation.idYCLocation + '&idparent=' + $scope.currentActivity.idActivity+'&canview='+$rootScope.data.maplocaltype+'&acttype='+$rootScope.data.idActivityTypeM).then(function (results) {
$rootScope.AllTicketTypes = results[0];
$rootScope.AllActivities = results[1];
$rootScope.ActPerTicketType = results[2];
for (var index = 0; index < $rootScope.ActPerTicketType[0].activities.length; index++) {
var found = -1;
for (var i = 0; i < $scope.LocationGrouping.length; i++) {
// console.log($scope.LocationGrouping[i].idYCLocation);
if($scope.LocationGrouping[i].idYCLocation == $rootScope.ActPerTicketType[0].activities[index].idYCLocation){
found = i;
}
}
if(found == -1)
$scope.LocationGrouping.push({
'idYCLocation': $rootScope.ActPerTicketType[0].activities[index].idYCLocation,
'LocationName': $rootScope.ActPerTicketType[0].activities[index].LocationName,
'occurence': 1
});
else
$scope.LocationGrouping[found].occurence = $scope.LocationGrouping[found].occurence + 1;
}
});
}
};
$rootScope.giveIndividualAccess = function (p, c) {
if($rootScope.userIsAllowed('access_edit')){
Data.get('individualaccess?evv=' + $rootScope.data.evv + '&idact=' + $scope.currentActivity.idActivity + '&tickettype=' + p.idResellerTicketType + '&qnt=' + p.Quantity + "&idc=" + c).then(function (results) {
if(c == '0')
$scope.showTypes($scope.currentActivity, p.idResellerTicketType);
});
}
else
alert("You have no permission to perform this operation!");
};
$rootScope.removeIndividualAccess = function (p, c) {
if($rootScope.userIsAllowed('access_edit')){
var tickettype = p.idResellerTicketType;
Data.get('removeiaccess?evv=' + $rootScope.data.evv + '&idact=' + $scope.currentActivity.idActivity + '&tickettype=' + p.idResellerTicketType + "&idc=" + c).then(function (results) {
$scope.showTypes($scope.currentActivity, p.idResellerTicketType);
});
}
else
alert("You have no permission to perform this operation!");
};
$scope.giveGroupAccess = function (p) {
if (p.IndividualAccess == 1 || p.IndividualAccess == 2) {
$('#assign_tickettypes').modal('hide');
$rootScope.confirmModal(
'Attention',
'Please note that changing this option will affect all the ticket types/tickets of this activity. Are you sure you want to continue?',
'Yes',
'Cancel',
function () {
Data.get('groupaccess?evv=' + $rootScope.data.evv + '&idact=' + $scope.currentActivity.idActivity + '&tickettype=' + p.idResellerTicketType + '&qnt=' + p.Quantity).then(function (results) {
$scope.showTypes($scope.currentActivity);
});
}
, null);
}
else {
Data.get('groupaccess?evv=' + $rootScope.data.evv + '&idact=' + $scope.currentActivity.idActivity + '&tickettype=' + p.idResellerTicketType + '&qnt=' + p.Quantity).then(function (results) {
$scope.showTypes($scope.currentActivity);
});
}
};
$scope.giveChoicesAccess = function (p) {
if (p.IndividualAccess == 1 || p.IndividualAccess == 0) {
$('#assign_tickettypes').modal('hide');
$rootScope.confirmModal(
'Attention',
'Please note that changing this option will affect all the ticket types/tickets of this activity. Are you sure you want to continue?',
'Yes',
'Cancel',
function () {
Data.get('choicesaccess?evv=' + $rootScope.data.evv + '&idact=' + $scope.currentActivity.idActivity + '&tickettype=' + p.idResellerTicketType).then(function (results) {
$scope.showTypes($scope.currentActivity);
});
}
, null);
}
else {
Data.get('choicesaccess?evv=' + $rootScope.data.evv + '&idact=' + $scope.currentActivity.idActivity + '&tickettype=' + p.idResellerTicketType).then(function (results) {
$scope.showTypes($scope.currentActivity);
});
}
};
$scope.giveApprovalRights = function (p) {
$('#assign_tickettypes').modal('hide');
$rootScope.confirmModal(
'Attention',
'Please note that changing this option will allow the user to approve this assignment. Are you sure you want to continue?',
'Yes',
'Cancel',
function () {
Data.get('userapproval?evv=' + $rootScope.data.evv + '&idact=' + $scope.currentActivity.idActivity + '&tickettype=' + p.idResellerTicketType).then(function (results) {
$scope.showTypes($scope.currentActivity);
});
}
, null);
};
$scope.saveQuantity = function (p) {
Data.get('savequantity?evv=' + $rootScope.data.evv + '&idact=' + $scope.currentActivity.idActivity + '&tickettype=' + p.idResellerTicketType + '&qnt=' + p.Quantity).then(function (results) {
$scope.showTypes($scope.currentActivity);
});
};
$scope.checkActivity = function (ind, acttype) {
$('#edit_activitygroup').modal('hide');
$rootScope.confirmModal(
'Attention',
'Please note that changing this option will affect all the activities/sub-activities of this activity type. Are you sure you want to continue?',
'Yes',
'Cancel',
function () {
$scope.MainActivity = ind;
$scope.idActivityType = acttype.idActivityType;
Data.get('getmainacttype?evv=' + $rootScope.data.evv + '&mainAct=' + $scope.MainActivity + '&idacttype=' + $scope.idActivityType).then(function (results) {
$scope.chosenActType = results[0];
});
}
, null);
};
$rootScope.maplocaltickettype = function (tickettype, activity) {
if($rootScope.userIsAllowed('tickettypes_edit')){
$rootScope.Req.post('maplocaltickettypes?evv=' + $rootScope.data.evv, {idActivity:activity.idActivity, idtickettype:tickettype.idResellerTicketType, titel:tickettype.Titel, canview:$rootScope.data.maplocaltype}).then(function (results) {
$scope.getLocalTicketTypes();
});
}
else
alert("You have no permission to perform this operation!");
};
$rootScope.unmaplocaltickettype = function (tickettype, activity) {
if($rootScope.userIsAllowed('tickettypes_edit')){
$rootScope.Req.post('unmaplocaltickettypes?evv=' + $rootScope.data.evv, {idActivity:activity.idActivity, idtickettype:tickettype.idResellerTicketType, titel:tickettype.Titel, canview:$rootScope.data.maplocaltype}).then(function (results) {
$scope.getLocalTicketTypes();
});
}
else
alert("You have no permission to perform this operation!");
};
$scope.saveOrderNr = function (activity, ordernr) {
Data.get('updateOrderNr?evv=' + $rootScope.data.evv + '&idActivity=' + activity.idActivity + '&OrderNr=' + ordernr).then(function (results) {
$scope.getLocalTicketTypes();
});
};
$scope.moveOrder = function (subact, index) {
if($rootScope.userIsAllowed('access_edit')){
Data.get('swapOrderNr?evv=' + $rootScope.data.evv + '&idActivity=' + subact.idActivity + '&index=' +index).then(function (results) {
$scope.showSubActivities($scope.currentActivity);
});
}
else
alert("You have no permission to perform this operation!");
};
$scope.approve = function (obj, type) {
//approve location
if (type == 1) {
$scope.currentLocation = obj;
Data.get('approve?evv=' + $rootScope.data.evv + '&type=' + type + '&idapprove=' + $scope.currentLocation.idYCLocation).then(function (results) {
toaster.pop("success", $scope.currentLocation.LocationName, "Location approved successfully!");
$scope.getLocations();
});
}
//approve parent activity and location linked to it
else if (type == 2) {
$scope.currentActivity = obj;
Data.get('approve?evv=' + $rootScope.data.evv + '&type=' + type + '&idapprove=' + $scope.currentActivity.idActivity).then(function (results) {
toaster.pop("success", $scope.currentActivity.Titel, "Activity approved successfully!");
$scope.getLocations();
$scope.showActivity($scope.currentLocation);
});
}
//approve subactivity and activity/location linked to it
else if (type == 3) {
$scope.currentSubActivity = obj;
Data.get('approve?evv=' + $rootScope.data.evv + '&type=' + type + '&idapprove=' + $scope.currentSubActivity.idActivity).then(function (results) {
toaster.pop("success", $scope.currentSubActivity.Titel, "Sub-Activity approved successfully!");
$scope.getLocations();
$scope.showActivity($scope.currentLocation);
$scope.showSubActivities($scope.currentActivity);
});
}
else if (type == 4) {
Data.get('approve?evv=' + $rootScope.data.evv + '&type=' + type + '&idact=' + $scope.currentActivity.idActivity + '&idticktype=' + obj.idResellerTicketType).then(function (results) {
$scope.showTypes($scope.currentActivity);
});
}
else if (type == 5) {
Data.get('approve?evv=' + $rootScope.data.evv + '&type=' + type + '&idact=' + $scope.currentActivity.idActivity + '&tick=' + obj.idTicket).then(function (results) {
$scope.openTicketList($scope.currentType, true);
});
}
};
$scope.approveall = function ($idact) {
var approveatticketview = 0;
if ($idact == 1) {
$idact = $scope.currentActivity.idActivity;
approveatticketview = 1;
}
Data.get('approveall?evv=' + $rootScope.data.evv + '&type=' + $scope.currentType.idResellerTicketType + '&idact=' + $idact).then(function (results) {
if (approveatticketview == 1)
$scope.openTicketList($scope.currentType, true);
else
$scope.getOverview($scope.currentType);
});
};
$scope.usassignalltickets = function () {
Data.get('unassignalltickets?evv=' + $rootScope.data.evv + '&type=' + $scope.currentType.idResellerTicketType + '&idact=' + $scope.currentActivity.idActivity).then(function (results) {
$scope.openTicketList($scope.currentType, true);
});
};
$scope.assignallticketsfromtype = function () {
Data.get('assignalltickets?evv=' + $rootScope.data.evv + '&type=' + $scope.currentType.idResellerTicketType + '&idact=' + $scope.currentActivity.idActivity).then(function (results) {
$scope.openTicketList($scope.currentType, true);
});
};
$scope.assignRuleToCompany = function (c) {
Data.get('assignruletocompany?evv=' + $rootScope.data.evv + '&type=' + $scope.currentType.idResellerTicketType + '&idact=' + $scope.currentActivity.idActivity + '&idc=' + c.idCompany).then(function (results) {
$scope.getCompanies($scope.currentType, $scope.currentActivity.idActivity);
});
};
$scope.unassignRuleToCompany = function (c) {
Data.get('unassignruletocompany?evv=' + $rootScope.data.evv + '&type=' + $scope.currentType.idResellerTicketType + '&idact=' + $scope.currentActivity.idActivity + '&idc=' + c.idCompany).then(function (results) {
$scope.getCompanies($scope.currentType, $scope.currentActivity.idActivity);
});
};
$scope.backToTicketType = function () {
$('#assign_companies').modal('hide');
$('#assign_tickettypes').modal('show');
};
$scope.showAdvanced = function (param) {
$rootScope.showadvanced = param;
};
$scope.mngapproveone = function(data, w){
var d = [];
d.push({dbid: data.dbid});
var wc = '';
if(w == 'location') wc = 'idYCLocation';
else if(w == 'activity') wc = 'idActivity';
else if(w =='typeofticket' || w =='ticket') wc = 'dbid';
$rootScope.Req.post('mngapproval?evv=' + $rootScope.data.evv, {data:d, w:w, wc:wc}).then(function (results) {
$scope.getApprovaloverview();
});
};
$scope.mngapproveall = function(data,w){
var d = [];
for (var index = 0; index < data.length; index++) {
if(data[index].Approved != 1){
var newobj = data[index];
d.push({dbid: newobj.dbid});
}
}
var wc = '';
if(w == 'location') wc = 'idYCLocation';
else if(w == 'activity') wc = 'idActivity';
else if(w =='typeofticket' || w =='ticket') wc = 'dbid';
$rootScope.Req.post('mngapproval?evv=' + $rootScope.data.evv, {data:d, w:w, wc:wc}).then(function (results) {
$scope.getApprovaloverview();
});
};
$scope.showApproveAll = function(data){
for (var index = 0; index < data.length; index++) {
if(data[index].Approved != 1)
return true;
}
return false;
};
$scope.showSelectAll = function(data){
if(data.isMaped != 1)
return true;
return false;
};
$scope.showHorizontalSelectAll = function(data){
var $mappedact = 0;
for (var index = 0; index < data.activities.length; index++) {
if(data.activities[index].isMaped == 1)
$mappedact = $mappedact + 1;
}
if($mappedact == $rootScope.ActPerTicketType[0].activities.length)
return false;
else return true;
};
$scope.mapVertical = function(typeofmapping, act){
if($rootScope.userIsAllowed('tickettypes_edit')){
$rootScope.confirmModal(
'Attention',
'Are you sure you want to set this access for all ticket types?',
'Yes',
'Cancel',
function () {
$rootScope.Req.post('mapvertically?evv=' + $rootScope.data.evv, {mappingtype:typeofmapping, act:act, tickettypes: $rootScope.data.filteredarray}).then(function (results) {
$scope.getLocalTicketTypes();
});
}
, null);
}
else
alert("You have no permission to perform this operation!");
};
$scope.unmapVertical = function(typeofmapping, act){
if($rootScope.userIsAllowed('tickettypes_edit')){
$rootScope.confirmModal(
'Attention',
'Are you sure you want to remove this access from all ticket types?',
'Yes',
'Cancel',
function () {
$rootScope.Req.post('unmapvertically?evv=' + $rootScope.data.evv, {mappingtype:typeofmapping, act:act, tickettypes: $rootScope.data.filteredarray}).then(function (results) {
$scope.getLocalTicketTypes();
});
}
, null);
}
else
alert("You have no permission to perform this operation!");
};
$scope.mapHorizontal = function(typeofmapping, tickettype,act){
if($rootScope.userIsAllowed('tickettypes_edit')){
$rootScope.confirmModal(
'Attention',
'Are you sure you want to set this access for all activities?',
'Yes',
'Cancel',
function () {
$rootScope.Req.post('maphorizontally?evv=' + $rootScope.data.evv, {mappingtype:typeofmapping, tickettype:tickettype, activities: act}).then(function (results) {
$scope.getLocalTicketTypes();
});
}
, null);
}
alert("You have no permission to perform this operation!");
};
$scope.unmapHorizontal = function(typeofmapping, tickettype, act){
if($rootScope.userIsAllowed('tickettypes_edit')){
$rootScope.confirmModal(
'Attention',
'Are you sure you want to remove this access for all activities?',
'Yes',
'Cancel',
function () {
$rootScope.Req.post('unmaphorizontally?evv=' + $rootScope.data.evv, {mappingtype:typeofmapping, tickettype:tickettype, activities: act}).then(function (results) {
$scope.getLocalTicketTypes();
});
}
, null);
}
alert("You have no permission to perform this operation!");
};
}).filter('myDateFormat', function myDateFormat($filter){
return function(text){
console.log(text);
var tempdate= new Date(text.replace(/-/g,"/"));
return $filter('date')(tempdate, "yyyy-MM-dd HH:mm");
}
}).controller('pendingamountsController', function(Data,$scope, $rootScope, $http, $timeout) {
$rootScope.$watch("data.pendingamounts", function(){
if(!angular.isUndefined($rootScope.data.pendingamounts)){
/*$scope.vendors = $rootScope.data.vendors;
$scope.vendorslist = $rootScope.data.vendorslist;*/
}
});
}).controller('guestClientController', function(Data,$scope, $rootScope, $http, $timeout) {
$scope.currentStep = {};
$scope.stepfields = {};
$scope.getData = function(){
$timeout(function () {
Data.get('getguestclient?evv='+$rootScope.data.evv).then(function(results){
$scope.steps = results;
$scope.currentStep = results[0];
$scope.showStepFields($scope.currentStep);
});
}, 1000);
};
$scope.getData();
$scope.editField = function (field) {
$scope.currentField = field;
$('#edit_field').modal('show');
};
$scope.submitEditField = function(field){
Data.get('editfield?evv='+$rootScope.data.evv+'&field='+field['field_id']+'&en='+field['field_name_en']+'&de='+field['field_name_de']).then(function(result){
$scope.getData();
});
};
$scope.editStep = function (step) {
$scope.currentStep = step;
$('#edit_step').modal('show');
};
$scope.submitEdit = function(step){
Data.get('editstep?evv='+$rootScope.data.evv+'&step='+step['dbid']+'&en='+step['en_name']+'&de='+step['de_name']).then(function(result){
$scope.getData();
});
};
$scope.showStepFields = function(step){
$scope.currentStep = step;
Data.get('getstepfields?evv='+$rootScope.data.evv+'&step='+$scope.currentStep.dbid).then(function(result){
$scope.stepfields = result[0];
$scope.fields_add = result[1];
});
};
$scope.activateStep = function (step) {
Data.get('updatestep?evv='+$rootScope.data.evv+'&step='+step['dbid']+'&active=1').then(function(result){
$scope.getData();
});
};
$scope.disableStep = function (step) {
Data.get('updatestep?evv='+$rootScope.data.evv+'&step='+step['dbid']+'&active=0').then(function(result){
$scope.getData();
});
};
$scope.addField = function(){
$scope.adddata = {field: $scope.fields_add[0]['dbid'], order: 1, required: 0};
$('#add_field').modal('show');
};
$scope.submitAdd = function(data){
Data.get('addfield?evv='+$rootScope.data.evv+'&step='+$scope.currentStep.dbid+'&field='+data['field']+'&order='+data['order']+'&required='+data['required']).then(function(result){
$scope.showStepFields($scope.currentStep);
});
};
$scope.removeField = function(field) {
Data.get('removestepfield?evv='+$rootScope.data.evv+'&step='+$scope.currentStep.dbid+'&stepfield='+field['stepfield_id']).then(function(result){
$scope.showStepFields($scope.currentStep);
});
};
}).controller('dynamicReportCtrl', function($scope, $rootScope, Data, $timeout, localStorageService, $sce) {
// $scope.gridReport = {
// };
$scope.gridReport = {
columnDefs: [
{headerName: "id", field: "id", width: 250, headerGroup: "Info", cellClass: 'bold'},
{headerName: "Name", field: "name", width: 150, headerGroup: "Info", cellClass: 'bold', template: "{{data.name}}"},
// {headerName: "Layer", field: "idlayer", width: 150, headerGroup: "Info", cellClass: 'bold', template: "{{data.idlayer}}"},
// {headerName: "Device", field: "device",width: 100, headerGroup: "Info", cellClass: 'bold'},
// {headerName: "Topup", field: "topup",width: 80, headerGroup: "Values", filter: 'number', template: "", aggFunc: 'sum'},
// {headerName: "Total", field: "total",width: 80, headerGroup: "Values", filter: 'number', template: "", aggFunc: 'sum'},
// {headerName: "Cancellations", field: "cancellations", headerGroup: "Values", width: 80, filter: 'number', template: "", aggFunc: 'sum'},
// {headerName: "Turnover", field: "turnover",width: 80, headerGroup: "Values", filter: 'number', template: "", aggFunc: 'sum'},
// {headerName: "Cashout", field: "cout",width: 80, headerGroup: "Values", filter: 'number', template: "", aggFunc: 'sum'},
// {headerName: "Sales", headerGroup: "ZReports", field: "totalsales",width: 80,
// template: "",aggFunc: 'sum'},/*{{(parseFloat(data.totalsales) != parseFloat(data.turnover) && data.topup == 0) || (parseFloat(data.totalsales) != parseFloat((data.topup - data.cout)+data.turnover) && data.topup != 0) ? 'red' : 'nihil'}}*/
// {headerName: "ExclVat", headerGroup: "ZReports", field: "totalsalesexclvat",width: 80, template: "", aggFunc: 'sum'},
// {headerName: "Transactions", headerGroup: "ZReports", field: "", hide: true, width: 350, template: "{{data.firsttransaction}} - {{data.lasttransaction}}"},
// {headerName: "Last Update", field: "lastupdate",width: 180, headerGroup: "ZReports"},
// {headerName: "Date", field: "lastupdate_day",width: 180, headerGroup: "ZReports"},
// {headerName: "ZCount", field: "ZCount",width: 50, headerGroup: "ZReports", hide: true},
// {headerName: "Receipts", field: "ReceiptCount",width: 50, headerGroup: "ZReports", hide: true, filter: 'number', aggFunc: 'sum', template: ""},
/*{headerName: "#", field: "", headerGroup: "ZReports", template: ""},*/
],
headerGroups: ["id", "name"],
enableCellExpressions: true,
enableSorting: true,
enableColResize: true,
enableFilter: true,
angularCompileFilters: true,
rowSelection: 'single',
rowDeselection: true,
angularCompileRows: true,
groupIncludeFooter: true,
overlayLoadingTemplate: 'Generating report, please wait...',
overlayNoRowsTemplate: 'No data...',
showToolPanel: true,
toolPanelSuppressValues: false,
groupDefaultExpanded: true,
groupRowRendererParams: {
checkbox: true,
innerRenderer: function(params) {return params.node.key;},
},
groupHeaders: true,
groupKeys: ['name'],
onRowDoubleClicked: function(row) {
console.log(row.node.data);
},
rowData:[
{id: 1, name: 'daniel'},
{id: 2, name: 'daniel'},
]
};
// $scope.gridReport.api.setRowData([
// {id: 1, name: 'daniel'},
// {id: 2, name: 'daniel'},
// ]);
}).controller('uPeopleController', function(Data,$scope, $rootScope, $http, $timeout, $sce, toaster) {
$timeout(function () {
Data.get('getcompanies?evv=' + $rootScope.data.evv).then(function (result) {
$scope.companies = result;
});
Data.get('getusertypes?evv=' + $rootScope.data.evv).then(function (result) {
$scope.user_types = result;
});
Data.get('gettickettemplates?evv=' + $rootScope.data.evv).then(function (result) {
$scope.tickettemps = result;
});
}, 1000);
$scope.currentCompany = null;
$scope.currentUser = null;
$scope.currentTicketTemplate = { data: '' };
$scope.currentTicketType = { data: '' };
$scope.company_users = [];
$rootScope.Index = 1;
$scope.current_view = 'companies';
$scope.current_tab = 'profile';
$scope.TabVisible = 1;
$scope.AccStatus = [{ id: 1, name: 'Active' }, { id: 0, name: "Closed" }];
$scope.search = { location: '', activity: '' };
$scope.ExportType = [{ id: 1, name: 'Activity List View Access' }, { id: 2, name: 'User List View Access' }];
$rootScope.showPreview = 0;
/* TICKET TYPES */
$scope.manageTicketType = function (tickettype) {
if (tickettype['countT'] == 0) {
$rootScope.confirmModal(
'Confirm',
'Do you want to Delete ticket type or to Move it to another ticket type?',
'Delete',
'Move',
function () {
$rootScope.Req.post('deletetickettype?evv=' + $rootScope.data.evv, [tickettype]).then(function (results) {
$scope.getTicketTypes();
$scope.currentTicketType = { data: '' };
});
},
function () {
$('#magane_ticket_type').modal('show');
});
}
else {
$rootScope.confirmModal(
'Alert',
'You canoot delete or move this ticket type, because there are tickets behind.',
null,
'Close',
null,
null);
}
};
$scope.moveTicketType = function (from, to) {
$scope.send = { from: from, to: to };
$rootScope.Req.post('movetickettype?evv=' + $rootScope.data.evv, [$scope.send]).then(function (results) {
$scope.getTicketTypes();
});
};
$scope.addTicketType = function (tickettype) {
$scope.create_update = 'Create';
$scope.currentTicketType.data = null;
};
$scope.createTicketType = function (tickettype, string) {
if (string == 'Create') { /*CREATE TICKET TYPE*/
$rootScope.Req.post('createtickettype?evv=' + $rootScope.data.evv, [tickettype]).then(function (results) {
$scope.tickettypes = [];
$scope.getTicketTypes();
$scope.currentTicketType = { data: '' };
});
}
else { /*UPDATE TICKET TYPE*/
$rootScope.Req.post('updatetickettype?evv=' + $rootScope.data.evv, [tickettype]).then(function (results) {
$scope.tickettypes = [];
$scope.showTicketType($scope.currentTicketType.data);
});
}
};
$scope.showTicketType = function (tickettype) {
$scope.create_update = 'update';
$scope.currentCompany = null;
$scope.currentTicketTemplate.data = '';
$scope.currentTicketType.data = angular.copy(tickettype);
};
$scope.getTicketTypes = function () {
$scope.currentCompany = null;
$scope.currentTicketTemplate.data = '';
Data.get('gettickettypespeople?evv=' + $rootScope.data.evv).then(function (result) {
$scope.tickettypes = result;
});
};
/* TICKET TEMPLATE*/
$(document).click(function (event) {
/*$scope.target_element = $(event.target).parent()['0'].offsetParent.className;*/
$scope.node = "$(event.target)['0'].nodeName";
});
function insertTextAtPosition(text, range) {
range.insertNode(document.createTextNode(text));
}
$scope.getCursorPosition = function () {
var sel, range;
sel = window.getSelection();
if (sel.getRangeAt && sel.rangeCount) {
return sel.getRangeAt(0);
}
};
$scope.addTicketAttribute = function (text) {
if (($scope.target_element == 'ta-scroll-window ng-scope ta-text ta-editor form-control')) {/*|| ($scope.node == "TEXTAREA")*/
insertTextAtPosition(text, $scope.getCursorPosition());
}
};
$scope.deleteTicketTemplate = function (tickettemp) {
$rootScope.confirmModal(
'Confirm',
'Do you want to Delete template ' + tickettemp['Name'] + ' ?',
'Yes',
'Cancel',
function () {
$rootScope.Req.post('deletetickettemp?evv=' + $rootScope.data.evv, [tickettemp]).then(function (results) {
$scope.tickettemps = results;
$scope.currentTicketTemplate = { data: '' };
});
}, null);
};
$scope.makeDefaultTemp = function (tickettemp) {
$rootScope.Req.post('deafulttickettemp?evv=' + $rootScope.data.evv + '&idTicketTemplate=' + tickettemp['idTicketTemplate'], [tickettemp]).then(function (results) {
$scope.tickettemps = results;
for (var i = 0; i < $scope.tickettemps.length; i++) {
if ($scope.tickettemps[i]['idTicketTemplate'] == $scope.currentTicketTemplate.data['idTicketTemplate']) {
$scope.currentTicketTemplate.data = $scope.tickettemps[i];
break;
}
}
});
};
$scope.editTicketTemp = function (tickettemp) {
$rootScope.Req.post('updatetickettemp?evv=' + $rootScope.data.evv + '&idTicketTemplate=' + tickettemp['idTicketTemplate'], [tickettemp]).then(function (results) {
$scope.tickettemps = results;
for (var i = 0; i < $scope.tickettemps.length; i++) {
if ($scope.tickettemps[i]['idTicketTemplate'] == $scope.currentTicketTemplate.data['idTicketTemplate']) {
$scope.currentTicketTemplate.data = $scope.tickettemps[i];
break;
}
}
});
};
$scope.addTicketTemp = function () {
$scope.create_ticket_temp = { IsDefault: 0 };
$scope.create_update = 'Create';
$("#add_ticket_temp").modal("show");
};
$scope.hasDefaultEmail = function(type){
$scope.usertype = type;
Data.get('hasdefaultemail?evv=' + $rootScope.data.evv + '&type=' + type).then(function(results){
if(!angular.isUndefined(results[0])){
$scope.create_ticket_temp = { IsDefault: 0, UserType: $scope.usertype, Body: results[0].Body}
}
else{
$scope.create_ticket_temp = { IsDefault: 0, UserType: $scope.usertype, Body: ''}
}
});
};
$scope.createTicketTemplate = function (tickettemp) {
$rootScope.Req.post('createtickettemp?evv=' + $rootScope.data.evv, [tickettemp]).then(function (results) {
$scope.tickettemps.push(results[0]);
});
};
$scope.showTicketTemplate = function (tickettemp) {
$scope.currentCompany = null;
$scope.currentTicketType.data = '';
$scope.currentTicketTemplate.data = angular.copy(tickettemp);
};
$scope.getTicketTemplates = function () {
$scope.currentCompany = null;
$scope.currentTicketTemplate.data = '';
Data.get('gettickettemplates?evv=' + $rootScope.data.evv).then(function (result) {
$scope.tickettemps = result;
});
};
/* USERS */
$scope.confirmAccount = function (user) {
$rootScope.confirmModal(
'Confirm',
'Are you sure you want to confirm this account? If the user has not set an password yet, the default password will be: "2018' + $scope.currentCompany['Code'] + '2018".',
'Yes',
'Cancel',
function () {
$rootScope.Req.post('confirmuseraccount?evv=' + $rootScope.data.evv, [user]).then(function (results) {
Data.get("getcompanyusers?evv=" + $rootScope.data.evv + "&Company=" + $scope.currentCompany['idCompany']).then(function (result) {
$scope.company_users = result;
for (var i = 0; i < $scope.company_users.length; i++) {
if ($scope.company_users[i]['idIdentity'] == user['idIdentity']) {
$scope.currentUser = $scope.company_users[i];
break;
}
}
});
});
}, null);
};
$scope.accessGuestAccount = function (user) {
$rootScope.confirmModal(
'Confirm',
'Are you sure you want to access the profile of the user in guest client?',
'Yes',
'Cancel',
function () {
var url = $scope.currentCompany['GuestPath'] + '/dashboardaccess/' + user['idUser'];
window.open(url);
}, null);
};
$scope.resetAccount = function (user) {
$rootScope.confirmModal(
'Confirm',
'Which email do you want to send to the user?',
'Invitation Email',
'Actiovation Email',
function () {
$rootScope.Req.post('sendemail?evv=' + $rootScope.data.evv + "&idCompany=" + $scope.currentCompany['idCompany'], [user]).then(function (results) {
Data.get("getcompanyusers?evv=" + $rootScope.data.evv + "&Company=" + $scope.currentCompany['idCompany']).then(function (result) {
$scope.company_users = result;
for (var i = 0; i < $scope.company_users.length; i++) {
if ($scope.company_users[i]['idIdentity'] == user['idIdentity']) {
$scope.currentUser = $scope.company_users[i];
break;
}
}
});
});
},
function () {
$rootScope.Req.post('resetaccount?evv=' + $rootScope.data.evv + "&idCompany=" + $scope.currentCompany['idCompany'], [user]).then(function (results) {
Data.get("getcompanyusers?evv=" + $rootScope.data.evv + "&Company=" + $scope.currentCompany['idCompany']).then(function (result) {
$scope.company_users = result;
for (var i = 0; i < $scope.company_users.length; i++) {
if ($scope.company_users[i]['idIdentity'] == user['idIdentity']) {
$scope.currentUser = $scope.company_users[i];
break;
}
}
});
});
});
};
$scope.createAccount = function (user) {
$rootScope.confirmModal(
'Confirm',
'Do you want to Create the Account for the User? By creating and account an email will be sent automatically to the user.',
'Yes',
'Cancel',
function () {
$rootScope.Req.post('createaccount?evv=' + $rootScope.data.evv, [user]).then(function (results) {
Data.get("getcompanyusers?evv=" + $rootScope.data.evv + "&Company=" + $scope.currentCompany['idCompany']).then(function (result) {
$scope.company_users = result;
for (var i = 0; i < $scope.company_users.length; i++) {
if ($scope.company_users[i]['idIdentity'] == user['idIdentity']) {
$scope.currentUser = $scope.company_users[i];
break;
}
}
});
});
}, null);
};
$scope.addAccess = function (access, ticket, amount) {
if($rootScope.userIsAllowed('companies_edit')){
$scope.send = { idTicket: ticket, access: access, amount: amount };
$rootScope.Req.post('addaccess?evv=' + $rootScope.data.evv, [$scope.send]).then(function (results) {
$scope.getAllTypeOfAccesses($scope.currentUser);
});
}
else
alert("You have no permission to perform this operation!");
};
// $scope.addAccess = function (access, ticket, amount) {
// $scope.send = {idTicket: ticket, string: '', access: access, amount: amount};
// if (!angular.isUndefined(access['IndividualAccess'])) {
// switch(access['IndividualAccess']){
// case 9: /*WHEN access['IndividualAccess'] IS NULL*/
// if (access['ParentRule'] == 5621) { /*GROUP*/
// $rootScope.confirmModal(
// 'Confirm',
// 'Do you want to apply the rule to the all tickets of the current type?',
// 'Yes',
// 'No',
// function(){
// $scope.send.string = 'ALL_TICKETS_GROUP';
// $rootScope.Req.post('addaccess?evv='+$rootScope.data.evv, [$scope.send]).then(function(results) {
// $scope.getAllTypeOfAccesses($scope.currentUser);
// });
// },
// function(){
// $scope.send.string = 'TICKET_GROUP';
// $rootScope.Req.post('addaccess?evv='+$rootScope.data.evv, [$scope.send]).then(function(results) {
// $scope.getAllTypeOfAccesses($scope.currentUser);
// });
// });
// }
// else if(access['ParentRule'] == 1543){ /*Multiple Choices*/
// $scope.send.string = 'CHOICES';
// $rootScope.Req.post('addaccess?evv='+$rootScope.data.evv, [$scope.send]).then(function(results) {
// $scope.getAllTypeOfAccesses($scope.currentUser);
// });
// }
// else{ /*Single*/
// $rootScope.confirmModal(
// 'Confirm',
// 'Do you want to apply the rule to the all tickets of the current type?',
// 'Yes',
// 'No',
// function(){
// $scope.send.string = 'ALL_TICKETS_SINGLE';
// $rootScope.Req.post('addaccess?evv='+$rootScope.data.evv, [$scope.send]).then(function(results) {
// $scope.getAllTypeOfAccesses($scope.currentUser);
// });
// },
// function(){
// $scope.send.string = 'TICKET_SINGLE';
// $rootScope.Req.post('addaccess?evv='+$rootScope.data.evv, [$scope.send]).then(function(results) {
// $scope.getAllTypeOfAccesses($scope.currentUser);
// });
// });
// }
// break;
// case 1:
// $scope.send.string = 'TICKET';
// $rootScope.Req.post('addaccess?evv='+$rootScope.data.evv, [$scope.send]).then(function(results) {
// $scope.getAllTypeOfAccesses($scope.currentUser);
// });
// break;
// case 0:
// $rootScope.confirmModal(
// 'Confirm',
// 'This rule will apply to the whole group with this ticket type. Are you sure you want to continue?',
// 'Yes',
// 'No',
// function(){
// $scope.send.string = 'ALL_TICKETS';
// $rootScope.Req.post('addaccess?evv='+$rootScope.data.evv, [$scope.send]).then(function(results) {
// $scope.getAllTypeOfAccesses($scope.currentUser);
// });
// },null);
// break;
// }
// }
// else{
// console.log('error');
// }
// };
$scope.removeAccess = function (access, ticket) {
if($rootScope.userIsAllowed('companies_edit')){
$scope.send = { idTicket: ticket, idActivity: access['idActivity'] };
$rootScope.confirmModal(
'Confirm',
'Are you sure you want to remove this accesss?',
'Yes',
'No',
function () {
$rootScope.Req.post('removeaccess?evv=' + $rootScope.data.evv, [$scope.send]).then(function (results) {
$scope.getAllTypeOfAccesses($scope.currentUser);
});
}, null);
}
else
alert("You have no permission to perform this operation!");
};
$scope.unblockAccess = function (access, ticket) {
if($rootScope.userIsAllowed('companies_edit')){
$scope.send = { idTicket: ticket, access: access };
$rootScope.confirmModal(
'Confirm',
'Are you sure you want to unblock this accesss?',
'Yes',
'No',
function () {
$rootScope.Req.post('unblockaccess?evv=' + $rootScope.data.evv, [$scope.send]).then(function (results) {
$scope.getAllTypeOfAccesses($scope.currentUser);
});
}, null);
}
else
alert("You have no permission to perform this operation!");
};
$scope.getAllTypeOfAccesses = function (user) {
/* NEEDS WORK TO DO WITH THE QUANTITY MIN MAX */
Data.get("getuseraccess?evv=" + $rootScope.data.evv + "&idTicket=" + user['idTicket']).then(function (result) {
$scope.user_access = result;
});
/*Data.get("getotheraccess?evv="+$rootScope.data.evv+"&idTicket="+user['idTicket']).then(function (result) {
$scope.other_access = result;
});*/
};
$scope.showProfile = function (user) {
/* NEEDS WORK TO DO WITH THE QUANTITY MIN MAX */
Data.get("getuseraccess?evv=" + $rootScope.data.evv + "&idTicket=" + user['idTicket']).then(function (result) {
$scope.user_access = result;
});
/*Data.get("getotheraccess?evv="+$rootScope.data.evv+"&idTicket="+user['idTicket']).then(function (result) {
$scope.other_access = result;
console.log(result);
});*/
Data.get("getonlinetopup?evv=" + $rootScope.data.evv + "&idTicket=" + user['idTicket']).then(function (result) {
$scope.online_topup = result;
});
Data.get("getlocations?evv=" + $rootScope.data.evv).then(function (result) {
$scope.locations = result;
});
Data.get("getactivities?evv=" + $rootScope.data.evv).then(function (result) {
$scope.activities = result;
});
$scope.currentUser = user;
$("#userProfileModal").modal("show");
};
$scope.checkAll = function (users, node, table, status) {
switch (table) {
case 'emails':
$scope.check_emails = status;
for (var i = 0; i < users.length; i++) {
if (users[i]['Ticket'] == 1) {
users[i][node] = status;
}
}
break;
case 'tickets':
$scope.check_tickets = status;
for (var i = 0; i < users.length; i++) {
if (users[i]['Ticket'] != 1) {
users[i][node] = status;
}
}
break;
}
};
$scope.createTicketsConfirm = function (users, selectedTicketType) {
$rootScope.confirmModal(
'Confirm',
'Do you want to Create Tickets for the selected users?',
'Yes',
'Cancel',
function () {
$scope.createTickets(users, selectedTicketType);
}, null);
};
$scope.createTickets = function (users, selectedTicketType) {
for (var i = 0; i < users.length; i++) {
if (users[i]['selected_ticket'] == 1) {
/*$scope.createUserTicket(users[i]);*/
$rootScope.Req.post('createuserticket?evv=' + $rootScope.data.evv + "&idCompany=" + $scope.currentCompany['idCompany'] + $rootScope.data.evv + "&idTicketType=" + selectedTicketType['idTicketType'], [user]).then(function (results) {
/*$scope.company_users = results;*/
/*$scope.showCompany($scope.currentCompany);*/
});
}
}
$scope.check_tickets = 0;
};
$scope.createUserTicket = function (user) {
$rootScope.confirmModal(
'Confirm',
'Do you want to Create Ticket for ' + user['Firstname'] + '?',
'Yes',
'Cancel',
function () {
$scope.currentUser = user;
$rootScope.Req.post('createuserticket?evv=' + $rootScope.data.evv + "&idCompany=" + $scope.currentCompany['idCompany'] + $rootScope.data.evv + "&idTicketType=" + $scope.currentCompany['idTicketType'], [user]).then(function (results) {
/*$scope.company_users = results;*/
$scope.showCompany($scope.currentCompany);
});
}, null);
};
$scope.sendEmailsConfirm = function (users, string) {
$scope.string_email = string;
$rootScope.confirmModal(
'Confirm',
'Do you want to resend the email to the users that already got it once?',
'Yes',
'No',
function () {
$scope.sendResendEmails(users);
},
function () {
$scope.sendEmails(users);
}
);
};
$scope.sendEmails = function (users) {
for (var i = 0; i < users.length; i++) {
if ((users[i]['selected_email'] == 1) && (users[i]['EmailSent'] != 1) && (users[i]['selected_email'].toLowerCase().indexOf("/") == -1)) {
$scope.sendEmail(users[i]);
}
}
$scope.check_emails = 0;
};
$scope.sendResendEmails = function (users) {
for (var i = 0; i < users.length; i++) {
if (users[i]['selected_email'] == 1) {
$scope.sendEmail(users[i]);
}
}
$scope.check_emails = 0;
};
$scope.sendEmail = function (user) {
$scope.currentUser = user;
if ($scope.string_email == 'invitation') {
$rootScope.Req.post('sendemail?evv=' + $rootScope.data.evv + "&idCompany=" + $scope.currentCompany['idCompany'], [user]).then(function (results) {
/*$scope.company_users = results;*/
$scope.showCompany($scope.currentCompany);
});
}
else {
$rootScope.Req.post('sendaccupdateemail?evv=' + $rootScope.data.evv + "&idCompany=" + $scope.currentCompany['idCompany'], [user]).then(function (results) {
/*$scope.company_users = results;*/
$scope.showCompany($scope.currentCompany);
});
}
};
$scope.sendEmailConf = function (user) {
$rootScope.confirmModal(
'Confirm',
'Do you want to send the email to ' + user['Firstname'] + '?',
'Yes',
'No',
function () {
$scope.sendEmail(user);
}, null);
};
$scope.deleteUser = function (user) {
$rootScope.confirmModal(
'Confirm',
'Do you want to Delete user ' + user['Firstname'] + ' ?',
'Yes',
'Cancel',
function () {
$rootScope.Req.post('deletecompanyuser?evv=' + $rootScope.data.evv + "&idCompany=" + $scope.currentCompany['idCompany'], [user]).then(function (results) {
/*$scope.company_users = results;*/
$scope.showCompany($scope.currentCompany);
});
}, null);
};
$scope.editUser = function (user) {
$scope.create_user = user;
$scope.currentUser = user;
$scope.create_update = 'Edit';
$("#add_user").modal("show");
};
$scope.addUser = function (company) {
$scope.create_user = { idTicketType: $scope.currentCompany.idTicketType, UserType: 2 };
$scope.create_update = 'Create';
$("#add_user").modal("show");
};
$scope.createUser = function (user, string) {
//if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(user['Email'])) {
if (user['idTicketType'] == null) {
user['idTicketType'] = '0';
}
if (string == 'Create') { /*CREATE USER*/
$rootScope.Req.post('createcompanyuser?evv=' + $rootScope.data.evv + "&idCompany=" + $scope.currentCompany['idCompany'], [user]).then(function (results) {
$scope.company_users = [];
$scope.showCompany($scope.currentCompany);
});
}
else { /*UPDATE USER*/
$rootScope.Req.post('updatecompanyuser?evv=' + $rootScope.data.evv + "&idCompany=" + $scope.currentCompany['idCompany'], [user]).then(function (results) {
$scope.company_users = [];
$scope.showCompany($scope.currentCompany);
$timeout(function () {
for (var i = 0; i < $scope.company_users.length; i++) {
if ($scope.company_users[i]['idIdentity'] == $scope.currentUser['idIdentity']) {
$scope.currentUser = [];
$scope.currentUser = angular.copy($scope.company_users[i]);
break;
}
}
});
});
}
//}
};
/* COMPANY */
$scope.importCompanyData = function (company) {
if (company['dbid'] > 0)
$rootScope.data.action = $sce.trustAsResourceUrl("https://dashboard.youchip.com/requests/guestclient/importcompanyaccess.php?evv=" + $rootScope.data.evv + "&c=" + company['idCompany'] + "&u=" +$rootScope.U.username);
else
$rootScope.data.action = $sce.trustAsResourceUrl("https://dashboard.youchip.com/requests/guestclient/importcompanyaccess.php?evv=" + $rootScope.data.evv + "&c=0"+ "&u=" +$rootScope.U.username);
$rootScope.genericModal(
'Import ' + company['Name'] + ' Data',
'views/upeople/modals/importcompanyusers.php',
'Import',
'Close',
function () {
angular.element('#theform').submit();
var res = $sce.valueOf($rootScope.data.action);
$timeout(function () {
$http.post(res).then(function(response){
if(response.status = 200){
alert("Your import was succesfull!");
$scope.getCompanies();
}
else{
alert("Your import failed");
$scope.getCompanies();
}
});
}, 15000);
},
null
);
};
$scope.exportCompanyData = function (company) {
$("#choose_exporttype").modal("show");
$scope.currentCompany = company;
$scope.DefaultExportType = $scope.ExportType[0];
};
$scope.exportchosentemplate = function (templatetype) {
var url = "https://dashboard.youchip.com/excelexport/upeople.php?evv=" + $rootScope.data.evv + "&idc=" + $scope.currentCompany.idCompany + "&name=" + $scope.currentCompany.Name + "&type=" + templatetype;
window.location.href = url;
};
$scope.createCompanyTicketType = function (company) {
$rootScope.confirmModal(
'Confirm',
'Do you want to Create Ticket Type for ' + company['Name'] + '?',
'Yes',
'Cancel',
function () {
$rootScope.Req.post('createcompanytickettype?evv=' + $rootScope.data.evv, [company]).then(function (results) {
$scope.getCompanies();
});
}, null);
};
$scope.deleteCompany = function (company) {
$rootScope.confirmModal(
'Confirm',
'Do you want to Delete company ' + company['Name'] + ' ?',
'Yes',
'Cancel',
function () {
$rootScope.Req.post('deletecompany?evv=' + $rootScope.data.evv, [company]).then(function (results) {
$scope.companies = results;
$scope.currentCompany = null;
});
}, null);
};
$scope.editRootCompany = function (company) {
$scope.create_company = company;
$scope.currentCompany = company;
$scope.create_update = 'Edit';
$scope.showCompany(company);
$("#add_root_company").modal("show");
/*Data.get("getcompanyaccess?evv="+$rootScope.data.evv+"&idTicketType="+company['idTicketType']).then(function (result) {
$scope.company_access = result;
});*/
};
$scope.editCompany = function (company) {
$scope.create_company = company;
$scope.currentCompany = company;
$scope.create_update = 'Edit';
$scope.showCompany(company);
$("#add_company").modal("show");
Data.get("getcompanyaccess?evv=" + $rootScope.data.evv + "&idTicketType=" + company['idTicketType']).then(function (result) {
$scope.company_access = result;
});
};
$scope.modal = { showchild: false };
$scope.showRootCompany = function (company) {
$scope.modal.showchild = !$scope.modal.showchild;
$scope.currentRootCompany = angular.copy(company);
$scope.companychilds = [];
for (var i = 0; i < $scope.companies.length; i++) {
if ($scope.companies[i]['idParent'] == company['idCompany']) {
$scope.companychilds.push($scope.companies[i]);
}
}
};
$scope.showCompany = function (company) {
/*$scope.modal = {showchild: false};*/
Data.get('gettickettypespeople?evv=' + $rootScope.data.evv).then(function (result) {
$scope.types = [];
/*$scope.types.push({idResellerTicketType: '0', Titel: 'Create Later'});*/
for (var i = 0; i < result.length; i++) {
$scope.types.push(result[i]);
}
$scope.typesemail = result;
});
$scope.currentTicketTemplate.data = '';
$scope.currentTicketType.data = '';
$scope.currentCompany = angular.copy(company);
$scope.selectedTicketType = { idTicketType: $scope.currentCompany['idTicketType'] };
Data.get("getcompanyusers?evv=" + $rootScope.data.evv + "&Company=" + company['idCompany']).then(function (result) {
$scope.company_users = result;
});
};
$scope.searchUser = function (text) {
Data.get("searchcompanyusers?evv=" + $rootScope.data.evv + "&text=" + text).then(function (result) {
$scope.company_users = result;
$scope.currentCompany = {};
$scope.search.query1 = '';
});
};
$scope.addCompany = function () {
Data.get('gettickettypespeople?evv=' + $rootScope.data.evv).then(function (result) {
$scope.types = [];
/*$scope.types.push({idResellerTicketType: '0', Titel: 'Create Later'});*/
for (var i = 0; i < result.length; i++) {
$scope.types.push(result[i]);
}
});
$scope.create_company = { TicketType: null, isGroup: 0 };
$scope.create_update = 'Create';
$("#add_company").modal("show");
};
$scope.addRootCompany = function () {
$scope.create_update = 'Create';
$("#add_root_company").modal("show");
};
$scope.createCompany = function (company, string) {
if (company['idTicketType'] == null) {
company['idTicketType'] = '1';
}
if (company['TicketType'] == null) {
company['TicketType'] = '1';
}
//if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(company['Email'])) {
if (string == 'Create') { /*CREATE COMPANY*/
$rootScope.Req.post('createcompany?evv=' + $rootScope.data.evv, [company]).then(function (results) {
$scope.companies = results;
});
}
else { /*UPDATE COMPANY*/
$rootScope.Req.post('updatecompany?evv=' + $rootScope.data.evv + "&idCompany=" + company['idCompany'], [company]).then(function (results) {
$scope.companies = results;
for (var i = 0; i < $scope.companies.length; i++) {
if ($scope.companies[i]['idCompany'] == $scope.currentCompany['idCompany']) {
$scope.currentCompany = $scope.companies[i];
break;
}
}
});
}
//}
};
$scope.getCompanies = function () {
$scope.currentTicketTemplate.data = '';
$scope.currentTicketType.data = '';
$scope.currentCompany = null;
Data.get('getcompanies?evv=' + $rootScope.data.evv).then(function (result) {
$scope.companies = result;
});
};
$scope.importCompanies = function () {
$rootScope.data.action = $sce.trustAsResourceUrl("https://dashboard.youchip.com/requests/guestclient/importcompanies.php?evv=" + $rootScope.data.evv);
$rootScope.genericModal(
'Import Users',
'views/upeople/modals/importcompanies.php',
'Import',
'Close',
function () {
angular.element('#theform').submit();
$timeout(function () {
$scope.getCompanies();
}, 3000);
},
null
);
};
$scope.exportCompanies = function () {
var url = "https://dashboard.youchip.com/requests/guestclient/exportcompanies.php?evv=" + $rootScope.data.evv;
window.open(url);
};
/* GENERAL*/
$scope.watchLocation = function () {
if ($scope.search.location == null) {
$scope.search.location = '';
$scope.search.activity = '';
}
else
$scope.search.activity = '';
};
$scope.watchActivity = function () {
if ($scope.search.activity == null) {
$scope.search.activity = '';
$scope.search.location = '';
}
else
$scope.search.location = $scope.search.activity.idYCLocation;
};
$scope.makeid = function () {
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for (var i = 0; i < 10; i++)
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
};
$scope.refreshData = function () {
if ($scope.current_view == 'companies') {
Data.get('getcompanies?evv=' + $rootScope.data.evv).then(function (result) {
$scope.companies = result;
if ($scope.currentCompany != null) {
$scope.showCompany($scope.currentCompany);
}
});
}
else if ($scope.current_view == 'tickettypes') {
Data.get('gettickettypespeople?evv=' + $rootScope.data.evv).then(function (result) {
$scope.tickettypes = result;
});
}
else {
Data.get('gettickettemplates?evv=' + $rootScope.data.evv).then(function (result) {
$scope.tickettemps = result;
});
}
};
$scope.exportCompanyUsers = function (company) {
var url = "https://dashboard.youchip.com/requests/guestclient/exportcompanyusers.php?evv=" + $rootScope.data.evv + "&c=" + company['idCompany'];
window.open(url);
};
$rootScope.importCompanyUsers = function (company) {
$rootScope.data.action = $sce.trustAsResourceUrl("https://dashboard.youchip.com/requests/guestclient/importcompanyusers.php?evv=" + $rootScope.data.evv + "&c=" + company['idCompany']);
$rootScope.genericModal(
'Import Users',
'views/upeople/modals/importcompanyusers.php',
'Import',
'Close',
function () {
angular.element('#theform').submit();
$timeout(function () {
$scope.showCompany($scope.currentCompany);
}, 3000);
},
null
);
};
$rootScope.setIndex = function (company, ind) {
$rootScope.Index = ind;
$scope.getCompanies();
$scope.currentCompany = company;
};
$scope.showTab = function (tabnr) {
$scope.TabVisible = tabnr;
};
$scope.setCurrentCompany = function (company) {
$scope.currentCompany = company;
};
$scope.SaveUpdate = function (company) {
$rootScope.Req.post('saveupdatecompany?evv=' + $rootScope.data.evv, [company]).then(function (results) {
toaster.pop("success", $scope.currentCompany.Name, "Company was updated successfully!");
});
};
$scope.setPreviewVisibility = function (ind) {
$rootScope.showPreview = ind;
};
$scope.updateAccEmail = function (body) {
$rootScope.Req.post('updateaccemail?evv=' + $rootScope.data.evv, [body]).then(function (results) {
toaster.pop("success", "Email Update", "Email was updated successfully!");
});
};
$scope.sentAccEmail = function (company) {
$rootScope.Req.post('sentaccemail?evv=' + $rootScope.data.evv, [company]).then(function (results) {
toaster.pop("success", "Email Sent", "Email was sent successfully!");
$scope.currentCompany.contactuser = '';
$scope.currentCompany.contactemail = '';
});
};
$scope.replytoAnswer = function(com){
$rootScope.Req.post('savereply?evv=' + $rootScope.data.evv, [com]).then(function (results) {
});
};
$scope.approveForTicket = function(u, idact){
if(idact == 0){
$rootScope.confirmModal(
'Confirm',
'Are you sure you want to approve all the accesses assigned to this user?',
'Yes',
'Cancel',
function () {
$rootScope.Req.post('approveforticket?evv=' + $rootScope.data.evv+"&idact="+idact, [u]).then(function (results) {
$scope.showCompany($scope.currentCompany);
});
}, null);
}
else{
$rootScope.Req.post('approveforticket?evv=' + $rootScope.data.evv+"&idact="+idact, [u]).then(function (results) {
$scope.getAllTypeOfAccesses(u);
});
}
};
})
.filter('myDateFormat', function myDateFormat($filter){
return function(text){
var tempdate = new Date(text.replace(/-/g,"/"));
var string = $filter('date')(tempdate, "yyyy-MM-dd HH:mm");
if(string.search(" 00:00") == -1){
return string;
}
else{
return string.split(" ")[0];
}
}
})
/*.filter('propsFilter', function() {
return function(items, props) {
var out = [];
if (angular.isArray(items)) {
var keys = Object.keys(props);
items.forEach(function(item) {
var itemMatches = false;
for (var i = 0; i < keys.length; i++) {
var prop = keys[i];
var text = props[prop].toLowerCase();
if (item[prop].toString().toLowerCase().indexOf(text) !== -1) {
itemMatches = true;
break;
}
}
if (itemMatches) {
out.push(item);
}
});
} else {
// Let the output be the input untouched
out = items;
}
return out;
};
})*/