/var/www/(Del)pathways.org.hk/MIS20140127/old20140407/staff/history_index.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
<?php
include_once '../include/DBConnect.php';
$search "";
$name "";

if (isset(
$_GET['search'])) {
    
$search $_GET['search'];
    
$name $search['Staff_ID'];
    if (
$name != "") {
        
$query "SELECT root_id FROM `staff` WHERE concat(last_name,' ',first_name,'(',ch_name,')') Like '%$name%'";
        
$result $dbh->prepare($query);
        
$result->execute();
        if (
$ResultSet $result->fetch(PDO::FETCH_ASSOC)) {
            
//var_dump($ResultSet['root_id']);
            
$RootID $ResultSet['root_id'];
        };
    }
}
if (isset(
$_GET['root_id'])) {
    
$RootID $_GET['root_id'];
    
$query 'SELECT CONCAT( last_name,  " ", first_name,  "(", ch_name,  ")" ) AS name FROM staff WHERE deleted =0 and root_id=' $RootID ' GROUP BY name';
    
$result $dbh->prepare($query);
    
$result->execute();
    if (
$ResultSet $result->fetch(PDO::FETCH_ASSOC)) {
        
$name $ResultSet['name'];
    };
}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <link href="js/select2/select2.css" rel="stylesheet"/>
        <script src="js/select2/select2.js"></script>
        <?php require_once '../include/head.php'?>
        <?php require_once '../include/checkuser.php'?>
        <?php require_once '../include/Nav_bar.php'?>
        <script>
            $(document).ready(function() {
                $('div input').height(20);
                $('.date-picker').datetimepicker({pickTime: false});
                $("#myselect").select2({
                    placeholder: "Select a Name",
                    minimumInputLength: 2,
                    allowClear: true
                });
                $("#myselect").on("select2-selecting", function(e) {
                    //alert("selecting val=" + e.val);
                    $('#Staff_ID').val(e.val);
                    
                });
                $(function() {
                    $('#myselect').select2().select2('val', '<?= $name ?>');
                    $('#Staff_ID').val('<?= $name ?>');
                });
            });


        </script>
    </head>
    <body>
        <div class="text-right">
            <ul class="breadcrumb">
                <!--<li><a href="#">Master</a> <span class="divider">&gt;</span></li>-->
                <li><a href="index.php">Staff</a> <span class="divider">&gt;</span></li>
                <li class="active">Staff Salary History</li>
            </ul>
        </div>

        <div class="container-fluid pathways-container">
            <a class="btn pull-right" <?= ($name != "") ? 'href="historyfrom.php?root_id=' $RootID '&action=Insert"' 'disabled="disabled"' ?> ><i class="icon-plus"></i>Add</a>
            <h2>Staff Salary History</h2>

            <div class="pathways-search">
                <form id="search_form" class="form-inline" action="" method="">
                    <div class="pathways-inline-block">
                        Search by Name:
                        <select id="myselect" style="width:300px">
                            <option value=""></option>
                            <?php
                            $query 
'SELECT CONCAT( last_name,  " ", first_name,  "(", ch_name,  ")" ) AS name FROM staff WHERE deleted =0 GROUP BY name';
                            
$result $dbh->prepare($query);
                            
$result->execute();
                            while (
$ResultSet $result->fetch(PDO::FETCH_ASSOC)) {
                                
?>
                                <option  value="<?= $ResultSet['name'?>"><?= $ResultSet['name'?></option>
                                <?php
                            
}
                            
?>
                        </select>
                    </div>

                    <div class="pathways-inline-block">
                        <input type="hidden" id="Staff_ID"  name="search[Staff_ID]" value="0" />
                        <button type="submit" class="btn" style="margin-left:30px">GO</button>
                    </div>
                </form>
            </div>

            <form id="form" action="" method="post">
                <table class="table table-striped table-bordered table-hover table-condensed">
                    <thead>
                        <tr>
<!--                            <th style="min-width:130px; width:50px">View</th>-->
                            <th style="min-width:50px; width:50px">Edit</th>
                            <th>CreateDate</th>
                            <th>Position</th>
                            <th>Salary</th>
                            <th>Rate1</th>
                            <th>Rate2</th>
                            <th>Rate3</th>
                            <th>Rate4</th>
                            <th>Rate5</th>
                            <th>Rate6</th>
<!--                            <th>AdminEdit</th>-->
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        
if (isset($RootID)) {
                            
$query "SELECT sh.*,p.position_name FROM staff_salary_history sh,position p WHERE sh.staff_id = '$RootID'  AND sh.deleted = '0' and sh.position_id = p.position_id order by `version`";
                            
//$query = "SELECT * FROM `staff_salary_history` WHERE `staff_id` = '$staff_id'  AND `deleted` = '$deleted' order by `version`"; //
                            
$result $dbh->prepare($query);
                            
$result->execute();
                            while (
$ResultSet $result->fetch(PDO::FETCH_ASSOC)) {
                                
?>
                                <tr>
                                    <td><a href="historyfrom.php?root_id=<?= $ResultSet['staff_id'?>&action=Edit&version=<?= $ResultSet['version'?>" class="btn">Edit</a></td>
                                    <td><?= substr($ResultSet['createdate'], 010?></td>

                                    <td><?= $ResultSet['position_name'?></td>

                                    <td><?= $ResultSet['salary'?></td>
                                    <td><?= $ResultSet['rate1'?></td>
                                    <td><?= $ResultSet['rate2'?></td>
                                    <td><?= $ResultSet['rate3'?></td>
                                    <td><?= $ResultSet['rate4'?></td>
                                    <td><?= $ResultSet['rate5'?></td>
                                    <td><?= $ResultSet['rate6'?></td>

                                </tr>
                                <?php
                            
}
                        }
                        
?>
                    </tbody>
                </table>
            </form>
        </div>
    </body>
</html>