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
|
<?php require_once(__DIR__ . '/../checkuser.php'); function form() { global $dbh; $staff_position = array( 'actived' => 1, 'deleted' => 0, ); $id = isset($_GET['id']) ? $_GET['id'] : null; if (!empty($id)) { $sql = "SELECT * FROM mis_staff_position WHERE id = ? AND deleted = ?"; $parameters = array($id, 0); $sth = Db\Util::execute($dbh, $sql, $parameters); $staff_position = $sth->fetch(PDO::FETCH_ASSOC); } if (isPost()) { $staff_position = array_merge($staff_position, $_POST['staff_position']); if (empty($staff_position['id'])) { // Get max sort $sql = "SELECT MAX(sort) AS max_sort FROM mis_staff_position WHERE actived = ? AND deleted = ?"; $parameters = array(1, 0); $sth = Db\Util::execute($dbh, $sql, $parameters); $record = $sth->fetch(PDO::FETCH_ASSOC); // Assign sort $staff_position['sort'] = $record['max_sort'] + 1; // Save $staff_position['id'] = Db\Util::create($dbh, 'mis_staff_position', $staff_position); } else { // Save Db\Util::update($dbh, 'mis_staff_position', $staff_position); } $data = array( 'message' => 'Saved', ); redirectAndExit(Util::link(__DIR__ . '/index.php') . '?' . http_build_query($data)); } return array( 'staff_position' => $staff_position, ); } extract(form()); ?><!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">Staff Position</li> </ul> </div> <div class="container-fluid pathways-container">
<h3><?=empty($staff_position['id']) ? 'Add' : 'Modify'?> Staff Position</h3> <form id="form" class="form-horizontal" method="post"> <?php $attribute = 'id'; ?> <input type="hidden" name="staff_position[<?=$attribute?>]" value="<?=h($staff_position[$attribute])?>" /> <div class="control-group"> <?php $attribute = 'title'; $label = 'Name'; ?> <label class="control-label" for="<?=$attribute?>"><?=$label?></label> <div class="controls"> <input type="text" id="<?=$attribute?>" name="staff_position[<?=$attribute?>]" class="required" value="<?=h($staff_position[$attribute])?>" placeholder="<?=h($label)?>" maxlength="200" /> </div> </div> <div class="control-group"> <div class="controls"> <button type="submit" class="btn btn-danger">Save</button> </div> </div> </form> <script type="text/javascript"> $(function() { $('#form').validate(); }); </script> <?php require( __DIR__ . '/../inc/_footer.php'); ?>
</div> <!-- /container --> </body> </html>
|