@@ -297,6 +297,12 @@ app.controller("preparingGroups", function ($scope, $http, $timeout) {
297297 }
298298 ) ;
299299 } ;
300+ $scope . getStudentPaid = function ( ) {
301+ if ( $scope . item . group . paymentMethod && $scope . item . group . paymentMethod . name == "lecture" ) {
302+ $scope . item . paidCount = $scope . item . studentList . filter ( ( s ) => s . paidType == "donePaid" ) . length ;
303+ $scope . item . notPaidCount = $scope . item . studentList . filter ( ( s ) => s . paidType == "notPaid" ) . length ;
304+ }
305+ } ;
300306
301307 $scope . setAttendance = function ( item , type ) {
302308 $scope . error = "" ;
@@ -333,16 +339,63 @@ app.controller("preparingGroups", function ($scope, $http, $timeout) {
333339 $scope . error = "" ;
334340 $scope . item . attendanceCount = $scope . item . studentList . filter ( ( s ) => s . attend ) . length ;
335341 $scope . item . absenceCount = $scope . item . studentList . filter ( ( s ) => ! s . attend ) . length ;
342+ $scope . $applyAsync ( ) ;
343+
336344 } ;
337345
338346 $scope . attendStudent = function ( search , ev ) {
339347 $scope . error = "" ;
340348 if ( ev . which == 13 ) {
349+ if ( $scope . busyAttend ) {
350+ return ;
351+ }
352+ $scope . busyAttend = true ;
341353 let index = $scope . item . studentList . findIndex ( ( itm ) => itm . student . barcode == search ) ;
342- if ( index !== - 1 && ! $scope . item . studentList [ index ] . attend ) {
343- $scope . item . studentList [ index ] . attendDate = new Date ( ) ;
344- $scope . item . studentList [ index ] . attend = true ;
345- $scope . numberAbsencesAttendance ( ) ;
354+ if ( index !== - 1 ) {
355+ if ( ! $scope . item . studentList [ index ] . attend ) {
356+ $scope . item . studentList [ index ] . attendDate = new Date ( ) ;
357+ $scope . item . studentList [ index ] . attend = true ;
358+ $scope . numberAbsencesAttendance ( ) ;
359+ }
360+ $scope . busyAttend = false ;
361+ } else {
362+ $http ( {
363+ method : "POST" ,
364+ url : "/api/manageUsers/all" ,
365+ data : {
366+ where : {
367+ type : "student" ,
368+ barcode : search ,
369+ "educationalLevel.id" : $scope . item . educationalLevel . id ,
370+ "schoolYear.id" : $scope . item . schoolYear . id ,
371+ active : true ,
372+ } ,
373+ select : { id : 1 , firstName : 1 , barcode : 1 , mobile : 1 , parentMobile : 1 } ,
374+ } ,
375+ } ) . then (
376+ function ( response ) {
377+ $scope . busyAttend = false ;
378+ if ( response . data . done && response . data . list . length > 0 ) {
379+ if ( ! $scope . item . studentList . some ( ( k ) => k . student && k . student . id === response . data . list [ 0 ] . id ) ) {
380+ let stu = { student : response . data . list [ 0 ] , attend : true , attendDate : new Date ( ) , new : true } ;
381+ if ( $scope . item . group . paymentMethod && $scope . item . group . paymentMethod . name == "lecture" ) {
382+ stu . paidType = "notPaid" ;
383+ }
384+ $scope . item . studentList . push ( stu ) ;
385+ $scope . numberAbsencesAttendance ( ) ;
386+ } else {
387+ $scope . error = "##word.Student Exist##" ;
388+ }
389+ } else {
390+ $scope . error = "##word.Not Found##" ;
391+ }
392+ $scope . item . $studentSearch = "" ;
393+ } ,
394+ function ( err ) {
395+ $scope . busyAttend = false ;
396+ $scope . error = err ;
397+ }
398+ ) ;
346399 }
347400 }
348401 } ;
@@ -388,13 +441,15 @@ app.controller("preparingGroups", function ($scope, $http, $timeout) {
388441 $ ( "#thermalPrint" ) . addClass ( "hidden" ) ;
389442 } , 8000 ) ;
390443 } ;
391- $scope . studentPAid = function ( item , type ) {
444+ $scope . studentPaid = function ( item , type ) {
392445 $scope . error = "" ;
393- if ( type == "paid " ) {
446+ if ( type == "donePaid " ) {
394447 item . price = $scope . item . group . price ;
448+ item . paidType = type ;
395449 $scope . thermalPrint ( item ) ;
396- } else if ( type == "unpaid " ) {
450+ } else if ( type == "notPaid " ) {
397451 item . price = 0 ;
452+ item . paidType = type ;
398453 }
399454 } ;
400455 $scope . searchAll = function ( ) {
0 commit comments