Skip to content

Commit a69eef0

Browse files
Some changes
1 parent 11c21a5 commit a69eef0

File tree

10 files changed

+201
-544
lines changed

10 files changed

+201
-544
lines changed

SMS-Front-End/app/js/main/main.module.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ angular.module('main').config(function ($stateProvider, $urlRouterProvider) {
7272

7373
.state('discipline', {
7474
url: '/discipline',
75-
templateUrl: 'app/views/studentsControl/discipline/discipline.html'
75+
templateUrl: 'app/views/studentsControl/discipline/disciplineList.html'
76+
})
77+
.state('disciplinaryNoteProfile', {
78+
url: '/discipline/:disciplinaryNoteId',
79+
templateUrl: 'app/views/studentsControl/discipline/disciplinaryNoteProfile.html'
7680
})
7781

7882
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
angular.module('discipline')
2+
.controller('disciplinaryNoteController', function ($scope, moment, $q, $resource, $state, $stateParams, $mdDialog, toastService, globalService, DisciplineService) {
3+
4+
var vm = this;
5+
6+
// Param url passed to load an existing disciplinary note
7+
vm.disciplinaryNoteId = $stateParams.disciplinaryNoteId;
8+
9+
console.log('disciplinaryNoteId')
10+
console.log(vm.disciplinaryNoteId)
11+
12+
vm.action = null;
13+
14+
if (vm.associationId)
15+
vm.action = 'new';
16+
else
17+
vm.action = 'loaded';
18+
console.log(vm.action);
19+
20+
vm.defaultAvatar = globalService.defaultAvatar;
21+
22+
// Functions:
23+
vm.changeAssistanceForStudent = changeAssistanceForStudent;
24+
vm.changeUniformForStudent = changeUniformForStudent;
25+
vm.checkIfDelayIsEnabled = checkIfDelayIsEnabled;
26+
vm.checkIfJustifiedDelayIsEnabled = checkIfJustifiedDelayIsEnabled;
27+
28+
// To control the loading spinner.
29+
vm.dataIsReady = false;
30+
31+
vm.delayList = ['5', '10', '15', '20', '30', '45'];
32+
33+
activate();
34+
35+
36+
///////////////////////////////////////////////////////////////////
37+
function activate() {
38+
console.log('Activating attendanceControlController controller.');
39+
40+
vm.dn = DisciplineService.get({id: vm.disciplinaryNoteId},
41+
function () {
42+
console.log('Disciplinary Note Data Block received:');
43+
console.log(vm.dn);
44+
vm.dataIsReady = true;
45+
46+
}, function (error) {
47+
console.log('Get disciplinary note process fail.');
48+
console.log(error);
49+
toastService.showToast('Error obteniendo el parte disciplinario.')
50+
})
51+
}
52+
53+
54+
function checkIfDelayIsEnabled(delayValue) {
55+
if (delayValue == null)
56+
return false;
57+
else
58+
return true;
59+
}
60+
61+
function checkIfJustifiedDelayIsEnabled(delayValue) {
62+
if (delayValue == null)
63+
return false;
64+
else
65+
return true;
66+
}
67+
68+
69+
vm.changeDelay = function changeDelay(studentId, delay){
70+
71+
if (delay == 'Sin retraso'){
72+
delay = 0;
73+
}
74+
for (var a = 0; a < vm.acBase.students.length; a++) {
75+
if (vm.acBase.students[a].studentId == studentId) {
76+
vm.acBase.students[a].control.delay = delay;
77+
console.log(vm.acBase.students[a].control.delay);
78+
if (delay !=0)
79+
vm.acBase.students[a].control.justifiedDelay = 0;
80+
else
81+
vm.acBase.students[a].control.justifiedDelay = null;
82+
}
83+
}
84+
}
85+
86+
vm.changeJustifiedDelay = function changeJustifiedDelay(studentId){
87+
for (var a = 0; a < vm.acBase.students.length; a++) {
88+
if (vm.acBase.students[a].studentId == studentId) {
89+
if (vm.acBase.students[a].control.justifiedDelay == true) {
90+
vm.acBase.students[a].control.justifiedDelay = false;
91+
} else {
92+
vm.acBase.students[a].control.justifiedDelay = true;
93+
}
94+
}
95+
}
96+
}
97+
98+
function changeUniformForStudent(studentId) {
99+
for (var a = 0; a < vm.acBase.students.length; a++) {
100+
if (vm.acBase.students[a].studentId == studentId) {
101+
if (vm.acBase.students[a].control.uniform == true) {
102+
vm.acBase.students[a].control.uniform = false;
103+
} else {
104+
vm.acBase.students[a].control.uniform = true;
105+
}
106+
}
107+
}
108+
}
109+
110+
function changeAssistanceForStudent(studentId) {
111+
112+
for (var a = 0; a < vm.acBase.students.length; a++) {
113+
if (vm.acBase.students[a].studentId == studentId) {
114+
if (vm.acBase.students[a].control.assistance == true) {
115+
116+
// Set the student to fault.
117+
vm.acBase.students[a].control.assistance = false;
118+
// It changed to null the rest of values:
119+
vm.acBase.students[a].control.delay = null;
120+
vm.acBase.students[a].control.justifiedDelay = false;
121+
vm.acBase.students[a].control.uniform = null;
122+
123+
console.log(vm.acBase.students[a].control);
124+
125+
126+
} else {
127+
vm.acBase.students[a].control.assistance = true;
128+
vm.acBase.students[a].control.delay = 0;
129+
vm.acBase.students[a].control.justifiedDelay = null;
130+
vm.acBase.students[a].control.uniform = true;
131+
}
132+
}
133+
}
134+
135+
}
136+
137+
vm.saveCA = function saveCA(){
138+
139+
console.log('Saving CA');
140+
console.log(vm.acBase);
141+
142+
vm.acBase.$save(
143+
function(){ // Success
144+
console.log('ac saved successfully');
145+
$state.go('attendanceControls');
146+
toastService.showToast('Control de asistencia realizado con éxito.');
147+
},
148+
function(error){ // Fail
149+
toastService.showToast('Error al enviar control de asistencia.');
150+
console.log('Error while ac was saved.');
151+
console.log(error);
152+
});
153+
}
154+
155+
}
156+
)

SMS-Front-End/app/js/studentsControl/discipline/newDisciplinaryNoteDialog.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ angular.module('discipline')
1212

1313
vm.disciplinaryNote = new DisciplineService();
1414
vm.defaultAvatar = globalService.defaultAvatar;
15-
vm.currentDate = new Date();
15+
vm.disciplinaryNote.dateTime = new Date();
1616
vm.thereAreStudents = false;
1717

1818
///////////////////////////////////////////////////////////
@@ -58,7 +58,17 @@ angular.module('discipline')
5858
* Call to server with POST method ($save = POST) using vm.disciplinaryNote that is
5959
* a instance of TeachersService.*/
6060
function saveDisciplinaryNote() {
61-
console.log('Calling saveTeacher() function.')
61+
console.log('Calling saveDisciplinaryNote() function.')
62+
63+
64+
65+
// Formating date:
66+
dt = vm.disciplinaryNote.dateTime;
67+
new_format = dt.getFullYear()+'-'+dt.getMonth()+'-'+dt.getDate()+' '+dt.getHours()+':'+dt.getMinutes();
68+
69+
vm.disciplinaryNote.dateTime = new_format;
70+
71+
console.log(vm.disciplinaryNote.dateTime);
6272

6373
vm.disciplinaryNote.$save(
6474
function () { // Success

SMS-Front-End/app/js/teaching/subjects/newSubjectDialog.js

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ angular.module('subjects')
1212
vm.subject = new SubjectsService();
1313

1414

15+
1516
///////////////////////////////////////////////////////////
1617
function activate() {
1718
console.log('Activating newSubjectDialogController controller.')

SMS-Front-End/app/views/index.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@
125125
<!-- # Discipline Sub module # -->
126126

127127
<script src="../js/studentsControl/discipline/discipline.module.js"></script>
128-
<script src="../js/studentsControl/discipline/discipline.js"></script>
128+
<script src="../js/studentsControl/discipline/disciplineList.js"></script>
129+
<script src="../js/studentsControl/discipline/disciplinaryNote.js"></script>
129130
<script src="../js/studentsControl/discipline/discipline.service.js"></script>
130131
<script src="../js/studentsControl/discipline/newDisciplinaryNoteDialog.js"></script>
131132

0 commit comments

Comments
 (0)