(function() {
        'use strict';
                 angular
                        .module('spmsapp')
                        .controller('StudentAttendanceCtrl', StudentAttendanceCtrl);

        function StudentAttendanceCtrl($scope) {
            var class_id;
            $scope.studLists = [];
            $scope.noStudent;

            $(function () {
                    $scope.getDateRangeData();
                    $('.input-daterange').datepicker().on('changeDate', function(e){
                        $scope.getDateRangeData();
                    });
                    $('#form_class_id').on('change', function (e) {
                        $scope.getDateRangeData();
                    });
            });

            $scope.test = function () {
              console.log('asd');
            };

            $scope.getDateRangeData = function () {
                $scope. getClassValue();
                var date = $('input[name="start"]').val();

                $scope.getClassValue();

                if (date && class_id) {
                    var fromDate = new Date(date);
                    fromDate.setHours(0);
                    fromDate.setMinutes(0);
                    fromDate.setSeconds(0);

                    var toDate = new Date(date);
                    toDate.setHours(23);
                    toDate.setMinutes(59);
                    toDate.setSeconds(59);
                    fromDate = new Date(fromDate) / 1000;
                    toDate = new Date(toDate) / 1000;

                    $.get(BASE_URL + USER_PREFIX + 'attendance/get_attendances/' + class_id + '/' + fromDate + '/' + toDate, function (data) {
                            var parsed = JSON.parse(data);
                         if(data.length > 0) {
                            for (var key in parsed) {
                                $scope.studLists.push(parsed[key]);
                                $scope.$digest($scope.studLists);
                            }
                        } else {
                            $scope.noStudent = "No Student";
                        }
                        $scope.studLists = [];

                    });
                }
            };


            $scope.getClassValue = function () {
                class_id = $('select[name="class_id"] option:selected').val();
            };

            $scope.getStatusValue = function (status) {
                var attendance;
                console.log(status);
                if(status == 4) {
                   attendance =  ATTENDANCE[status].name = "NO Attendance";
                } else {
                    attendance = ATTENDANCE[status].name;
                }
                
                return attendance;

            };

        }

})();






@@ -1885,24 +1885,51 @@
 %5Bkey%5D);%0A    
+                        %7D%0A%0A
             
@@ -1982,38 +1982,8 @@
 s);%0A
-                            %7D%0A
     
@@ -2457,48 +2457,29 @@
     
-console.log(status);%0A                if(
+if(status == null %7C%7C 
 stat
@@ -2524,39 +2524,12 @@
 ce =
-  ATTENDANCE%5Bstatus%5D.name =
  %22N
-O
+o
  Att
@@ -2639,32 +2639,16 @@
       %7D%0A
-                
 %0A       

Fix attendance bug