Skip to content

Commit 17f6a83

Browse files
unknownunknown
authored andcommitted
#5-08-2024
1 parent b98bba1 commit 17f6a83

File tree

12 files changed

+246
-52
lines changed

12 files changed

+246
-52
lines changed

appsTeacher/groups/app.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,6 @@ module.exports = function init(site) {
339339
result.date = date;
340340
}
341341
if (_data.type == "validDay" && doc.paymentMethod.name == "lecture") {
342-
343342
doc.studentList = doc.studentList.map((obj) => ({ ...obj, paidType: "notPaid" }));
344343
}
345344

@@ -397,7 +396,12 @@ module.exports = function init(site) {
397396
}
398397
});
399398
};
400-
399+
site.getGroup = function (where, callBack) {
400+
callBack = callBack || function () {};
401+
app.$collection.find(where, (err, doc) => {
402+
callBack(err, doc);
403+
});
404+
};
401405
app.init();
402406
site.addApp(app);
403407
};

appsTeacher/groups/site_files/html/paymentsModal.html

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,54 @@
1010

1111
<div class="modal-body">
1212
<div class="row">
13-
<h2 class="col3 center border-1 bold padding">
14-
<p>##word.Amount Required##</p>
15-
{{item.price}} ##word.$##
16-
</h2>
13+
<div class="person-cart">
14+
<div class="row">
15+
<div class="col7">
16+
<p class="bold"><span class="darkGray">##word.Group Name## : </span> {{item.name}}</p>
17+
</div>
18+
<div class="col5">
19+
<p class="bold"><span class="darkGray">##word.Subject## : </span> {{item.subject.name}}</p>
20+
</div>
21+
</div>
22+
<div class="row">
23+
<div class="col7">
24+
<p class="bold"><span class="darkGray">##word.Teacher## : </span> {{item.teacher.firstName}}</p>
25+
</div>
26+
<div class="col5">
27+
<p class="bold"><span class="darkGray">##word.Mobile## : </span> {{item.teacher.mobile}}</p>
28+
</div>
29+
</div>
30+
31+
<div class="row">
32+
<div class="col7">
33+
<p class="bold"><span class="darkGray">##word.Educational Level## : </span> {{item.educationalLevel.name}}</p>
34+
</div>
35+
<div class="col5">
36+
<p class="bold"><span class="darkGray">##word.School Year## : </span> {{item.schoolYear.name}}</p>
37+
</div>
38+
</div>
39+
40+
<div class="row">
41+
<div class="col7">
42+
<p class="bold"><span class="darkGray">##word.Payment Method## : </span> {{item.paymentMethod.name##session.lang##}}</p>
43+
</div>
44+
<div class="col5">
45+
<p class="bold"><span class="darkGray">##word.Price## : </span> {{item.price}} ##word.$##</p>
46+
</div>
47+
</div>
48+
</div>
1749
</div>
18-
<div class="row">
19-
<i-date class="col4" ng-click="changePaymentMonth(studentItem)" ng-model="studentItem.$date" label="##word.Date##"></i-date>
50+
<div class="row" ng-show="studentItem.requiredPayment > 0">
51+
<i-date class="col3" ng-click="changePaymentMonth(studentItem)" ng-model="studentItem.$date" label="##word.Date##"></i-date>
2052
<i-list label="##word.Month##" ng-model="studentItem.$month" class="col2" display="name##session.lang##" items="monthList"></i-list>
21-
<i-control type="number" class="col2" ng-change="calcRemain(studentItem)" ng-model="studentItem.$price" label="##word.Paid##"></i-control>
22-
<i-control type="number" disabled class="col2" ng-model="studentItem.$remain" label="##word.Remain##"></i-control>
23-
<i-button type="push" class="col2" label="##word.Pay##" ng-click="addStudentPayment(studentItem)"></i-button>
53+
<i-control type="number" disabled class="col2" ng-model="studentItem.requiredPayment" label="##word.Required payment## ##word.$##"></i-control>
54+
<i-control type="number" class="col2" ng-change="calcRemain(studentItem)" ng-model="studentItem.$price" label="##word.Paid## ##word.$##"></i-control>
55+
<i-control type="number" disabled class="col1" ng-model="studentItem.discount" label="##word.Discount## %"></i-control>
56+
<i-control type="number" disabled class="col1" ng-model="studentItem.$remain" label="##word.Remain## ##word.$##"></i-control>
57+
<i-button type="push" class="col1" label="##word.Pay##" ng-click="addStudentPayment(studentItem)"></i-button>
2458
</div>
2559
<p class="error">{{error}}</p>
26-
<div class="row">
60+
<div class="row" ng-show="studentItem.paymentList.length > 0">
2761
<div class="table-responsive">
2862
<table class="table bold" id="t-students">
2963
<tr>
@@ -58,7 +92,7 @@ <h2 class="col3 center border-1 bold padding">
5892
<td class="center">{{p.price}} ##word.$##</td>
5993
<td class="center">
6094
<i-button type="print" label="##word.Print##" ng-click="thermalPrint(s,p)"></i-button>
61-
<i-button type="delete" label="##word.Delete##" ng-click="calcPayments(studentItem);s.paymentList.splice($index,1)"></i-button>
95+
<i-button type="delete" label="##word.Delete##" ng-click="s.paymentList.splice($index,1);calcPayments(s)"></i-button>
6296
</td>
6397
</tr>
6498
</table>

appsTeacher/groups/site_files/html/studentsModal.html

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,44 @@
99
</div>
1010

1111
<div class="modal-body">
12+
<div class="row">
13+
<div class="person-cart">
14+
<div class="row">
15+
<div class="col7">
16+
<p class="bold"><span class="darkGray">##word.Group Name## : </span> {{item.name}}</p>
17+
</div>
18+
<div class="col5">
19+
<p class="bold"><span class="darkGray">##word.Subject## : </span> {{item.subject.name}}</p>
20+
</div>
21+
</div>
22+
<div class="row">
23+
<div class="col7">
24+
<p class="bold"><span class="darkGray">##word.Teacher## : </span> {{item.teacher.firstName}}</p>
25+
</div>
26+
<div class="col5">
27+
<p class="bold"><span class="darkGray">##word.Mobile## : </span> {{item.teacher.mobile}}</p>
28+
</div>
29+
</div>
30+
31+
<div class="row">
32+
<div class="col7">
33+
<p class="bold"><span class="darkGray">##word.Educational Level## : </span> {{item.educationalLevel.name}}</p>
34+
</div>
35+
<div class="col5">
36+
<p class="bold"><span class="darkGray">##word.School Year## : </span> {{item.schoolYear.name}}</p>
37+
</div>
38+
</div>
39+
40+
<div class="row">
41+
<div class="col7">
42+
<p class="bold"><span class="darkGray">##word.Payment Method## : </span> {{item.paymentMethod.name##session.lang##}}</p>
43+
</div>
44+
<div class="col5">
45+
<p class="bold"><span class="darkGray">##word.Price## : </span> {{item.price}} ##word.$##</p>
46+
</div>
47+
</div>
48+
</div>
49+
</div>
1250
<div class="row">
1351
<i-control type="text" class="col9" ng-model="item.$studentSearch" ng-keydown="getStudent($event,item.$studentSearch)" label="##word.Student Search##"></i-control>
1452
<i-button type="search" class="col3" label="##word.Search##" ng-click="getStudent({which : 13},item.$studentSearch)"></i-button>
@@ -22,6 +60,7 @@
2260
<th>##word.Barcode##</th>
2361
<th>##word.Mobile##</th>
2462
<th>##word.Parent Mobile##</th>
63+
<th class="w150">##word.Discount## %</th>
2564
<th class="not-print">##word.Actions##</th>
2665
</tr>
2766
<tr ng-repeat="s in item.studentList | filter:$search">
@@ -39,8 +78,11 @@
3978
{{s.student.parentMobile}}
4079
</a>
4180
</td>
42-
43-
81+
<td class="center">
82+
<i-control type="number" ng-hide="s.exempt" ng-change="calcRequiredPayment(s)" ng-model="s.discount"></i-control>
83+
<i-button type="save" ng-show="!s.exempt" label="##word.Exempt##" ng-click="exemptPayment(s,true)"></i-button>
84+
<i-button type="exit" ng-show="s.exempt" title="##word.Cancel Exempt##" ng-click="exemptPayment(s,false)"></i-button>
85+
</td>
4486
<td class="center not-print">
4587
<i-button type="view" label="##word.Payments##" ng-show="item.paymentMethod.name == 'monthly'" ng-click="showStudentPayments(s)"></i-button>
4688
<i-button type="delete" label="##word.Delete##" ng-click="item.studentList.splice($index,1)"></i-button>
@@ -52,7 +94,6 @@
5294
</div>
5395

5496
<div class="modal-footer center">
55-
5697
<i-button type="save" label="##word.Save##" onclick="site.hideModal( '#studentsModal')"></i-button>
5798
</div>
5899
</div>

appsTeacher/groups/site_files/html/thermalPrint.html

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,22 @@
3838
<p class="font-18 black">##word.Group Name##</p>
3939
<p class="font-18 black">##word.Payment Date##</p>
4040
<p class="font-18 black" ng-show="thermal.month">##word.Month##</p>
41-
<p class="font-18 black">##word.Paid##</p>
4241
<p class="font-18 black" ng-show="thermal.remain >= 0">##word.Remain##</p>
4342
</div>
4443
<div class="col-7 bold">
4544
<p class="font-18 black">{{thermal.groupName}}</p>
4645
<p class="font-18 black">{{thermal.date | date:"dd / MM / yyyy"}}</p>
4746
<p class="font-18 black" ng-show="thermal.month">{{thermal.month.name##session.lang##}}</p>
4847
<p class="font-18 black" ng-show="thermal.remain >= 0">{{thermal.remain}} ##word.$##</p>
49-
<p class="font-20 black border-dashed">{{thermal.price}} ##word.$##</p>
48+
</div>
49+
</div>
50+
<div class="row border-dashed">
51+
<div class="col-1"></div>
52+
<div class="col-4 font-18 black">
53+
<p class="font-22 black">##word.Amount Paid##</p>
54+
</div>
55+
<div class="col-7 bold">
56+
<p class="font-22 black ">{{thermal.price}} ##word.$##</p>
5057
</div>
5158
</div>
5259

appsTeacher/groups/site_files/js/index.js

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,11 @@ app.controller("groups", function ($scope, $http, $timeout) {
556556
$scope.error = "";
557557

558558
item.paymentList = item.paymentList || [];
559-
if (item.$date && item.$month && item.$month.name && item.$price > 0 && $scope.item.price >= item.$price) {
559+
if (item.$price > $scope.studentItem.requiredPayment) {
560+
$scope.error = "##word.The amount paid is greater than what was required to be paid##";
561+
return;
562+
}
563+
if (item.$date && item.$month && item.$month.name && item.$price > 0) {
560564
if (item.paymentList.some((p) => p.month.name == item.$month.name)) {
561565
$scope.error = "##word.This Month Is Exist##";
562566
return;
@@ -590,21 +594,35 @@ app.controller("groups", function ($scope, $http, $timeout) {
590594
item.paymentList = item.paymentList || [];
591595
item.price = 0;
592596
item.paymentList.forEach((_item) => {
593-
console.log(_item);
594-
595597
item.price += _item.price;
596598
});
597-
item.remain = $scope.item.price - item.price;
599+
item.remain = $scope.studentItem.requiredPayment - item.price;
598600
}, 300);
599601
};
600-
602+
$scope.calcRequiredPayment = function (item) {
603+
$scope.error = "";
604+
$timeout(() => {
605+
item.discountValue = ($scope.item.price * item.discount) / 100;
606+
item.requiredPayment = $scope.item.price - item.discountValue;
607+
}, 300);
608+
};
609+
$scope.exemptPayment = function (item, option) {
610+
if (option == true) {
611+
item.requiredPayment = 0;
612+
item.discount = 100;
613+
} else if (option == false) {
614+
item.requiredPayment = $scope.item.price;
615+
item.discount = 0;
616+
}
617+
item.exempt = option;
618+
};
601619
$scope.calcRemain = function (item) {
602620
$scope.error = "";
603621
$timeout(() => {
604-
if (item.$price > $scope.item.price) {
622+
if (item.$price > item.requiredPayment) {
605623
return;
606624
}
607-
item.$remain = $scope.item.price - item.$price;
625+
item.$remain = item.requiredPayment - item.$price;
608626
}, 300);
609627
};
610628

@@ -614,7 +632,7 @@ app.controller("groups", function ($scope, $http, $timeout) {
614632
item.remain = 0;
615633
item.exception = true;
616634
} else if (option == false) {
617-
item.remain = $scope.item.price - item.price;
635+
item.remain = $scope.studentItem.requiredPayment - item.price;
618636

619637
item.exception = false;
620638
}

appsTeacher/manageUsers/app.js

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ module.exports = function init(site) {
477477
where["host"] = site.getHostFilter(req.host);
478478
}
479479
where["id"] = { $ne: 1 };
480-
480+
481481
app.$collection.findMany({ where, select, limit, sort: { id: -1 } }, (err, users, count) => {
482482
res.json({
483483
done: true,
@@ -487,6 +487,51 @@ module.exports = function init(site) {
487487
});
488488
});
489489
}
490+
site.post({ name: `/api/${app.name}/toDifferentGroup`, public: true }, (req, res) => {
491+
let response = {
492+
done: false,
493+
};
494+
495+
let where = req.body.where || {};
496+
497+
app.$collection.find(where, (err, doc) => {
498+
if (!err && doc) {
499+
response.done = true;
500+
501+
site.getGroup(
502+
{ "studentList.student.id": doc.id, "subject.id": req.body.subjectId, "educationalLevel.id": doc.educationalLevel.id, "schoolYear.id": doc.schoolYear.id },
503+
(errCode, group) => {
504+
if (group && group.id) {
505+
let studentGroup = group.studentList.find((itm) => itm.student.id == doc.id);
506+
response.doc = {
507+
student: {
508+
id: doc.id,
509+
firstName: doc.firstName,
510+
barcode: doc.barcode,
511+
mobile: doc.mobile,
512+
parentMobile: doc.parentMobile,
513+
},
514+
discount: studentGroup.discount,
515+
discountValue: studentGroup.discountValue,
516+
requiredPayment: studentGroup.requiredPayment,
517+
exempt: studentGroup.exempt,
518+
group: {
519+
id: group.id,
520+
name: group.name,
521+
},
522+
};
523+
} else {
524+
response.error = "There is no matching group for the student data";
525+
}
526+
res.json(response);
527+
}
528+
);
529+
} else {
530+
response.error = err?.message || "Not Exists";
531+
res.json(response);
532+
}
533+
});
534+
});
490535
}
491536

492537
site.addNotificationToStudents = function (doc, req) {

appsTeacher/preparingGroups/site_files/html/modalContent.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<div class="person-cart">
2424
<div class="row">
2525
<div class="col7">
26-
<p class="bold"><span class="darkGray">##word.Name## : </span> {{item.group.name}}</p>
26+
<p class="bold"><span class="darkGray">##word.Group Name## : </span> {{item.group.name}}</p>
2727
</div>
2828
<div class="col5">
2929
<p class="bold"><span class="darkGray">##word.Subject## : </span> {{item.subject.name}}</p>

appsTeacher/preparingGroups/site_files/html/studentsModal.html

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<div class="person-cart">
1414
<div class="row">
1515
<div class="col7">
16-
<p class="bold"><span class="darkGray">##word.Name## : </span> {{item.group.name}}</p>
16+
<p class="bold"><span class="darkGray">##word.Group Name## : </span> {{item.group.name}}</p>
1717
</div>
1818
<div class="col5">
1919
<p class="bold"><span class="darkGray">##word.Subject## : </span> {{item.subject.name}}</p>
@@ -101,7 +101,10 @@
101101
<th class="not-print">##word.Actions##</th>
102102
</tr>
103103
<tr ng-repeat="s in item.studentList | filter:$search | filter:$search2">
104-
<td class="center" ng-class="{'bg-yellow' : s.new === true}">{{s.student.firstName}}</td>
104+
<td class="center" ng-class="{'bg-yellow' : s.new === true}">
105+
{{s.student.firstName}}
106+
<p ng-show="s.new">( {{s.group.name}} )</p>
107+
</td>
105108
<td class="center userPrint">{{s.student.barcode}}</td>
106109
<td class="center">
107110
<a target="_blank" ng-class="{'change-color-link' : s.clickStudentMoblie}" ng-click="clickMoblie(s,'studentMobile')" href="https://wa.me/{{s.student.mobile}}">
@@ -121,7 +124,9 @@
121124
<p class="text-danger" ng-show="s.attend == false">##word.Absence##</p>
122125
</td>
123126
<td class="center" ng-show="item.group.paymentMethod.name == 'lecture'">
124-
<i-button type="save" ng-show="s.paidType == 'notPaid' && s.attend" label="##word.Paid##" ng-click="studentPaid(s,'donePaid');getStudentPaid()"></i-button>
127+
<p ng-show="s.requiredPayment > 0">{{s.requiredPayment}} ##word.$##</p>
128+
<p ng-show="s.exempt">##word.Exempt## </p>
129+
<i-button type="save" ng-show="s.paidType == 'notPaid' && s.attend && !s.exempt" label="##word.Paid##" ng-click="studentPaid(s,'donePaid');getStudentPaid()"></i-button>
125130
<i-button type="print" ng-show="s.paidType == 'donePaid'" label="##word.Print##" ng-click="thermalPrint(s)"></i-button>
126131
<i-button type="close" ng-show="s.paidType == 'donePaid'" title="##word.Cancel Paid##" ng-click="studentPaid(s,'notPaid');getStudentPaid()"></i-button>
127132
</td>
@@ -132,7 +137,7 @@
132137
<i-button ng-show="!s.attend" label="##word.Attended##" ng-click="setAttendance(s,'attend');numberAbsencesAttendance()"></i-button>
133138
<i-button ng-show="s.attend && !s.departureDate" label="##word.Departure##" ng-click="setAttendance(s,'departure')"></i-button>
134139
<i-button type="close" ng-hide="s.attend == false && s.departureDate" label="##word.Absence##" ng-click="setAttendance(s,'absence');numberAbsencesAttendance()"></i-button>
135-
<i-button type="delete" label="##word.Delete##" ng-show="s.new == true" ng-click="item.studentList.splice($index,1)"></i-button>
140+
<i-button type="delete" label="##word.Delete##" ng-show="s.new == true" ng-click="item.studentList.splice($index,1);numberAbsencesAttendance();getStudentPaid()"></i-button>
136141
</td>
137142
</tr>
138143
</table>

0 commit comments

Comments
 (0)