-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathqueue.php
203 lines (183 loc) · 8.36 KB
/
queue.php
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Queue Management System</title>
<link rel="stylesheet" href="css/bootstrap.min.css" type="text/css" media="all">
<link href="css/bootstrap-theme.min.css" rel="stylesheet">
<link href="css/font-awesome.min.css" rel="stylesheet">
<link href="css/bootstrap-social.css" rel="stylesheet">
<link href="css/jquery.bootgrid.css" rel="stylesheet" />
<script src="js/jquery-1.11.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery.bootgrid.min.js"></script>
<?php include('connection.php');?>
<div class="container">
<br> <br>
<div class="col-sm-12">
<div class="pull-right"><button type="button" class="btn btn-xs btn-primary" id="command-add" data-row-id="0">
<span class="glyphicon glyphicon-plus"></span> Record</button></div></div>
<table id="employee_grid" class="table table-condensed table-hover table-striped" width="60%" cellspacing="0" data-toggle="bootgrid">
<thead>
<tr>
<th data-column-id="id" data-type="numeric" data-identifier="true">Position</th>
<th data-column-id="ticket_no">Ticket No.</th>
<th data-column-id="airline">Airline</th>
<th data-column-id="full_name">Full name</th>
<th data-column-id="departure">Departure</th>
<th data-column-id="source">Source</th>
<th data-column-id="destination">Destination</th>
<th data-column-id="arrival">Arrival</th>
<th data-column-id="date">Date</th>
<th data-column-id="commands" data-formatter="commands" data-sortable="false">Commands</th>
</tr>
</thead>
</table>
</div>
<div id="add_model" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Add Pasanger</h4>
</div>
<div class="modal-body">
<form method="post" id="frm_add">
<input type="hidden" value="add" name="action" id="action">
<div class="form-group">
<label for="name" class="control-label">POsition:</label>
<input type="text" class="form-control" id="pos" name="name"/>
</div>
<div class="form-group">
<label for="salary" class="control-label">Ticket No:</label>
<input type="text" class="form-control" id="salary" name="ticket"/>
</div>
<div class="form-group">
<label for="salary" class="control-label">Airline No:</label>
<input type="text" class="form-control" id="salary" name="airline"/>
</div>
<div class="form-group">
<label for="salary" class="control-label">Full Name:</label>
<input type="text" class="form-control" id="age" name="fullname"/>
</div>
<div class="form-group">
<label for="salary" class="control-label">Departure:</label>
<input type="time" class="form-control" id="age" name="depa"/>
</div>
<div class="form-group">
<label for="salary" class="control-label">Source</label>
<input type="text" class="form-control" id="age" name="source"/>
</div>
<div class="form-group">
<label for="salary" class="control-label">Destination</label>
<input type="text" class="form-control" id="age" name="dest"/>
</div>
<div class="form-group">
<label for="salary" class="control-label">Arrival:</label>
<input type="time" class="form-control" id="age" name="arrival"/>
</div>
<div class="form-group">
<label for="salary" class="control-label">Date:</label>
<input type="date" class="form-control" id="age" name="date"/>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" id="btn_add" class="btn btn-primary">Save</button>
</div>
</form>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$( document ).ready(function() {
var grid = $("#employee_grid").bootgrid({
ajax: true,
rowSelect: true,
post: function ()
{
/* To accumulate custom parameter with the request object */
return {
id: "b0df282a-0d67-40e5-8558-c9e93b7befed"
};
},
url: "response.php",
formatters: {
"commands": function(column, row)
{
return "<button type=\"button\" class=\"btn btn-xs btn-default command-edit\" data-row-ticket_no=\"" + row.ticket_no + "\"><span class=\"glyphicon glyphicon-edit\"></span></button> " +
"<button type=\"button\" class=\"btn btn-xs btn-default command-delete\" data-row-ticket_no=\"" + row.ticket_no + "\"><span class=\"glyphicon glyphicon-trash\"></span></button>";
}
}
}).on("loaded.rs.jquery.bootgrid", function()
{
/* Executes after data is loaded and rendered */
grid.find(".command-edit").on("click", function(e)
{
//alert("You pressed edit on row: " + $(this).data("row-id"));
var ele =$(this).parent();
var g_pos = $(this).parent().siblings(':first').html();
var g_ticket = $(this).parent().siblings(':nth-of-type(2)').html();
var g_name = $(this).parent().siblings(':nth-of-type(3)').html();
var g_name = $(this).parent().siblings(':nth-of-type(2)').html();
var g_name = $(this).parent().siblings(':nth-of-type(2)').html();
var g_name = $(this).parent().siblings(':nth-of-type(2)').html();
var g_name = $(this).parent().siblings(':nth-of-type(2)').html();
var g_name = $(this).parent().siblings(':nth-of-type(2)').html();
var g_name = $(this).parent().siblings(':nth-of-type(2)').html();
console.log(g_id);
console.log(g_name);
//console.log(grid.data());//
$('#edit_model').modal('show');
if($(this).data("row-id") >0) {
// collect the data
$('#edit_id').val(ele.siblings(':first').html()); // in case we're changing the key
$('#edit_name').val(ele.siblings(':nth-of-type(2)').html());
$('#edit_salary').val(ele.siblings(':nth-of-type(3)').html());
$('#edit_age').val(ele.siblings(':nth-of-type(4)').html());
} else {
alert('Now row selected! First select row, then click edit button');
}
}).end().find(".command-delete").on("click", function(e)
{
var conf = confirm('Delete ' + $(this).data("row-ticket_no") + ' items?');
alert(conf);
if(conf){
$.post('response.php', { ticket_no: $(this).data("row-ticket_no"), action:'delete'}
, function(){
// when ajax returns (callback),
$("#employee_grid").bootgrid('reload');
});
$(this).parent('tr').remove();
$("#employee_grid").bootgrid('remove', $(this).data("row-ticket_no"))
}
});
});
function ajaxAction(action) {
data = $("#frm_"+action).serializeArray();
$.ajax({
type: "POST",
url: "response.php",
data: data,
dataType: "json",
success: function(response)
{
$('#'+action+'_model').modal('hide');
$("#employee_grid").bootgrid('reload');
}
});
}
$( "#command-add" ).click(function() {
$('#add_model').modal('show');
});
$( "#btn_add" ).click(function() {
ajaxAction('add');
});
$( "#btn_edit" ).click(function() {
ajaxAction('edit');
});
});
</script>