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
|
<?php require_once(__DIR__ . '/../checkuser.php'); function index() { global $dbh; $message = $_GET['message'] ?: null; if (isPost()) { Db\Util::transaction($dbh, function() use ($dbh) { foreach ($_POST['area']['sort'] as $id => $sort) { $data = array( 'id' => $id, 'sort' => $sort, ); Db\Util::update($dbh, 'mis_area', $data); } }); $message = 'Updated'; } $sql = "SELECT * FROM mis_area WHERE deleted = ? ORDER BY sort"; $parameters = array(0); $sth = Db\Util::execute($dbh, $sql, $parameters); $areas = $sth->fetchAll(); return array( 'areas' => $areas, 'message' => $message, ); } extract(index()); ?><!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <?php require(__DIR__ . '/../inc/_head_meta.php'); ?> <?php require(__DIR__ . '/../inc/_head_css.php'); ?> <?php require(__DIR__ . '/../inc/_head_script.php'); ?> </head> <body> <?php require( __DIR__ . '/../inc/_navbar.php'); ?> <div class="text-right"> <ul class="breadcrumb"> <li><a href="#">Master</a> <span class="divider">></span></li> <li class="active">Area</li> </ul> </div> <div class="container-fluid pathways-container"> <?php if (isset($message) && !empty($message)): ?> <div class="alert alert-info"> <button type="button" class="close" data-dismiss="alert">×</button> <h5 class="alert-heading">Note:</h5> <p><?=$message?></p> </div> <?php endif; ?>
<a href="form.php" class="btn pull-right"><i class="icon-plus"></i> Add</a> <h3>Area</h3> <?php if (empty($areas)): ?> <p>There are no records.</p> <?php else: ?> <div class="row-fluid" style="margin-bottom:10px"> <div class="btn-group"> <button id="select_all_btn" class="btn btn-small">Select All</button> <button id="delete_btn" class="btn btn-small">Delete</button> </div> </div> <script type="text/javascript"> $(function() { $('#select_all_btn').click(function() { var $selectAllCheckbox = $('.select-all-checkbox'); $selectAllCheckbox.prop('checked', !$selectAllCheckbox.prop('checked')); }); $('#delete_btn').click(function() { if ($('.select-all-checkbox:checked').length == 0) { bootbox.alert('At least select 1 record.'); } else { bootbox.dialog('Delete selected records?', [ { 'label': 'Delete', 'class': 'btn-danger', 'callback': function() { $('#form').attr('action', 'delete.php').submit(); } }, { 'label': 'Cancel', 'class': 'btn' } ]); } }); }); </script> <form id="form" action="" method="post"> <table class="table table-striped table-bordered table-hover table-condensed"> <thead> <tr> <th style="min-width:20px; width:20px"></th> <th style="min-width:50px; width:50px">Edit</th> <th style="min-width:50px; width:50px">Sort</th> <th>Name</th> </tr> </thead> <tbody> <?php foreach ($areas as $area): ?> <tr> <td><input type="checkbox" name="area[selected][]" class="select-all-checkbox" value="<?=h($area['id'])?>" /></td> <td><a href="form.php?id=<?=h($area['id'])?>" class="btn"><i class="icon-pencil"></i></a></td> <td><input type="text" name="area[sort][<?=h($area['id'])?>]" class="input-super-mini digits" value="<?=h($area['sort'])?>" maxlength="200" /></td> <td><?=h($area['title'])?></td> </tr> <?php endforeach; ?> </tbody> </table> <button type="submit" class="btn btn-danger">Update</button> </form> <script type="text/javascript"> $(function() { $('#form').validate(); }); </script> <?php endif; ?> <?php require( __DIR__ . '/../inc/_footer.php'); ?>
</div> <!-- /container --> </body> </html>
|