-
Notifications
You must be signed in to change notification settings - Fork 0
/
viewStudents.html
70 lines (62 loc) · 2.96 KB
/
viewStudents.html
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
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-1.2.4.js"></script>
<script data-require="angular.js@1.5.0" data-semver="1.5.0" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js"></script>
</head>
<body ng-app="viewApp">
<a href="dashboard.html">Return To Dashboard</a>
<br>
<hr>
<div class="container">
<div ng-controller="studentController">
<table class="table table-striped table table-bordered">
<tr><td>Transaction ID</td><td>First Name</td><td>Last Name</td><td>Phone</td><td>Action</td></tr>
<tr ng-repeat="x in students">
<td>{{x.StudentID}}</td>
<td>{{x.FirstName}}</td>
<td>{{x.LastName}}</td>
<td>{{x.Phone}}</td>
<td><button type="button" ng-click="openModal(x.StudentID)" confirm="Are you sure you want to delete, {{x.FirstName}} {{x.LastName}}?" confirm-settings="{size: 'sm'}">Delete</button> | </a><a href="update.php?id={{$index}}">Update</a></td>
</tr>
</table>
</div>
</div>
</body>
</html>
<script>
var app = angular.module('viewApp', ['ui.bootstrap']);
app.controller('studentController', function($scope, $http, $uibModal) {
$http.get("getStudents.php")
.then(function (response) {$scope.students = response.data.records;
});
$scope.openModal = function(idx) {
var data = $.param({id:idx});
$uibModal.open({
templateUrl: 'modal.html',
controller: function ($scope, $uibModalInstance) {
$scope.ok = function () {
$http.delete('deleteStudents.php?' + data)
.success(function (data, status, headers) {
$uibModalInstance.close();
location.reload();
})
.error(function (data, status, header, config) {
$scope.ServerResponse = htmlDecode("Data: " + data +
"\n\n\n\nstatus: " + status +
"\n\n\n\nheaders: " + header +
"\n\n\n\nconfig: " + config);
});
};
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
location.reload();
};
}
})
}
});
</script>