controllers.js
6.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
angular.module('starter.controllers', [])
.controller('AppCtrl', function($scope, $ionicModal, $timeout,Mensajes,$rootScope) {
// Form data for the login modal
$scope.loginData = {};
// Create the login modal that we will use later
$ionicModal.fromTemplateUrl('templates/login.html', {
scope: $scope
}).then(function(modal) {
$scope.modal = modal;
});
// Triggered in the login modal to close it
$scope.closeLogin = function() {
$scope.modal.hide();
};
// Open the login modal
$scope.login = function() {
$scope.modal.show();
};
// Perform the login action when the user submits the login form
$scope.doLogin = function() {
console.log('Doing login', $scope.loginData);
// Simulate a login delay. Remove this and replace with your login
// code if using a login system
$timeout(function() {
$scope.closeLogin();
}, 1000);
};
$scope.refreshMensajes = function() {
$rootScope.MensajesTotal = Mensajes.all($scope);
};
})
.controller('parqueaderoCtrl', function($scope,Parqueadero,$ionicPopup,Registrar,Mensajes,$ionicModal,LeerMensaje,$rootScope,RegistrarCliente) {
$scope.mensajesParqueadero = {};
$rootScope.MensajesTotal = $scope.mensajesParqueadero = Mensajes.all($scope,2);
$scope.parqueadero = Parqueadero.all($scope);
// Create the login modal that we will use later
$ionicModal.fromTemplateUrl('templates/mensajesparqueaderos.html', {
scope: $scope
}).then(function(modal) {
$scope.modal = modal;
});
$scope.popupMensajeRegistrarCliente= function() {
//$scope.myPopup.close();
$scope.myPopupMensajeCliente = $ionicPopup.show({
template: '<label>Cedula</label> <input type="number" ng-model="Usuario.cedula"> <button class="button button-full button-light icon-left ion-edit" ng-click="registrarClienteParqueadero(Usuario)">Registrar</button> ',
title: 'Registrar Cliente',
scope: $scope,
buttons: [
{ text: 'Cancelar' },
]
});
$scope.myPopupMensajeCliente.then(function(res) {
});
};
$scope.mostrarMensajeParqueadero= function() {
$scope.mensajesParqueadero = Mensajes.all($scope,2);
$scope.modal.show();
};
// A confirm dialog
$scope.refresh = function() {
$rootScope.MensajesTotal = $scope.mensajesParqueadero = Mensajes.all($scope,2);
};
// Triggered in the login modal to close it
$scope.closeMensajes= function() {
$scope.modal.hide();
};
$scope.showConfirmMensaje = function(mensaje) {
//$scope.myPopupMensaje.close();
LeerMensaje.Leer(mensaje.mensaje_id);
$scope.mensajesParqueadero = Mensajes.all($scope,2);
$scope.confirmPopupMensaje = $ionicPopup.confirm({
title: 'El conductor: ' + mensaje.cedula_cliente,
template: mensaje.descripcion_mensaje
});
$scope.confirmPopupMensaje.then(function(res) {
if(res) {
$scope.refresh();
} else {
console.log('You are not sure');
}
});
};
$scope.popupMensaje= function() {
//$scope.myPopup.close();
$scope.myPopupMensaje = $ionicPopup.show({
template: '<label>Cedula</label> <input type="number" ng-model="Usuario.cedula"> <label>Mensaje</label><input type="text" ng-model="Usuario.mensaje"> <button class="button button-full button-light icon-left ion-email" ng-click="enviarMensaje(Usuario)">Enviar</button> ',
title: 'Enviar Mensaje',
scope: $scope,
buttons: [
{ text: 'Cancelar' },
]
});
$scope.myPopupMensaje.then(function(res) {
});
};
$scope.enviarMensaje = function(usuario) {
Registrar.Enviar(usuario.cedula,usuario.mensaje,1);
$scope.myPopupMensaje.close();
$scope.myPopup.close();
//$scope.showConfirmMensaje();
};
$scope.registrarClienteParqueadero = function(usuario) {
RegistrarCliente.Enviar(usuario.cedula,$rootScope.deviceID);
$scope.myPopupMensajeCliente.close();
$scope.myPopup.close();
$scope.showConfirm();
};
$scope.popupMenu = function(parqueadero) {
$scope.myPopup = $ionicPopup.show({
template: '<button class="button button-full button-light icon-left ion-edit" ng-click="popupMensajeRegistrarCliente()">Registar</button> <button class="button button-full button-light icon-left ion-email" ng-click="popupMensaje()">Enviar Mensaje</button>',
title: parqueadero.nombre,
scope: $scope,
buttons: [
{ text: 'Cancelar' },
]
});
$scope.myPopup.then(function(res) {
});
};
// A confirm dialog
$scope.showConfirm = function() {
//$scope.myPopup.close();
$scope.confirmPopup = $ionicPopup.confirm({
title: 'Registro',
template: 'Usuario Registado Correctamente'
});
$scope.confirmPopup.then(function(res) {
if(res) {
console.log('You are sure');
} else {
console.log('You are not sure');
}
});
};
})
.controller('MensajesCtrl', function($scope,$ionicPopup,Mensajes,LeerMensaje,$rootScope,Registrar) {
$rootScope.MensajesTotal = $scope.mensajes = Mensajes.all($scope,1);
// A confirm dialog
$scope.refresh = function() {
$rootScope.MensajesTotal = $scope.mensajes = Mensajes.all($scope,1);
};
// A confirm dialog
$scope.showConfirmMensaje = function(mensaje) {
//$scope.myPopupMensaje.close();
LeerMensaje.Leer(mensaje.mensaje_id);
$scope.confirmPopupMensaje = $ionicPopup.confirm({
title: 'Cliente: ' + mensaje.cedula_cliente,
template: mensaje.descripcion_mensaje
});
$scope.confirmPopupMensaje.then(function(res) {
if(res) {
$scope.confirmPopupMensaje.close();
$scope.popupMensaje();
$scope.refresh();
} else {
console.log('You are not sure');
}
});
};
$scope.enviarMensaje = function(usuario) {
Registrar.Enviar(usuario.cedula,usuario.mensaje,2);
$scope.myPopupMensaje.close();
//$scope.showConfirmMensaje();
};
$scope.popupMensaje= function() {
//$scope.myPopup.close();
$scope.myPopupMensaje = $ionicPopup.show({
template: '<label>Placa</label> <input type="text" ng-model="Usuario.cedula"> <label>Mensaje</label><input type="text" ng-model="Usuario.mensaje"> <button class="button button-full button-light icon-left ion-email" ng-click="enviarMensaje(Usuario)">Enviar</button> ',
title: 'Enviar Mensaje',
scope: $scope,
buttons: [
{ text: 'Cancelar' },
]
});
$scope.myPopupMensaje.then(function(res) {
});
};
})
.controller('PlaylistsCtrl', function($scope,$ionicPopup) {
$scope.playlists = [
{ title: 'Mensaje Nuevo', id: 1 },
];
})
.controller('PlaylistCtrl', function($scope, $stateParams) {
});