/var/www/(Del)pathways.org.hk/MIS20140127/old20140407/Payroll/PayRoll_Generate_List.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
<!DOCTYPE html>
<?php require_once 'PayRoll_Sql.php'?>
<?php
// ### User click search button ### //
if (isset($_GET['search'])) {
    
$start $_GET['search']['start_date'];
    
$end $_GET['search']['end_date'];

    
$sth Search_daterange($start$end);
    
$staff_array = array();
    while (
$ResultSet $sth->fetch(PDO::FETCH_ASSOC)) {
        
array_push($staff_array$ResultSet);
    }
}
?>
<html>
    <head>
        <?php require_once '../include/head.php'?>
        <?php require_once '../include/checkuser.php'?>
        <?php require_once '../include/Nav_bar.php'?> 
        <script>
            $(function() {
                $("#start_date").datetimepicker({autoclose: true, pickTime: false, format: 'yyyy-MM-dd'})
                $("#end_date").datetimepicker({autoclose: true, pickTime: false, format: 'yyyy-MM-dd'})
                $('#start_date').datetimepicker().on('changeDate', function(ev) {
                    date = new Date($('#start_date_input').val());
                    $('#end_date').datetimepicker('setStartDate', date);
                    $('#end_date').datetimepicker('setDate', date);
                    $('#end_date').datetimepicker('show');
                    $('#start_date').datetimepicker('hide');
                    $('#end_date').datetimepicker('remove');
                });
                $('#end_date').datetimepicker().on('changeDate', function(ev) {
                    $('#end_date').datetimepicker('hide');
                });
            });
        </script>
        <style>
            .div-search{
                margin: 0;
                padding: 5px 10px;
                background-color: #F7F7F7;
                border: 1px solid #E6E6E6;
                border-radius: 5px;
                box-shadow: 0 1px 2px rgba(0,0,0,.05);
            }
        </style>
    </head>
    <body>        
        <div class="text-right">
            <ul class="breadcrumb">
                <li class="active">Payroll Generate List</li>
            </ul>
        </div>

        <div class="container-fluid pathways-container">
            <h3>Payroll Generate</h3> 
            <form class="form-inline" action="" method="get" autocomplete="off">
                <div class="div-search">
                    <!-- ### Search Date ###  -->
                    <table style="margin: 10px 10px 10px 10px;">
                        <tr>
                            <!-- ### Start Date ###  -->
                            <td style="padding-top: 5px;"><label for="start_date">Start Date</label></td>
                            <td style="width: 15px;"></td>
                            <td>
                                <div id="start_date" class="input-append date form_datetime datetime_picker">
                                    <input type="text" id="start_date_input"  name="search[start_date]" value="<?= (isset($_GET['search'])) ? ($_GET['search']['start_date']) : "" ?>" />
                                    <span class="add-on"><i class="icon-calendar"></i></span>
                                </div>                                
                            </td>

                            <td style="width: 30px;"></td>

                            <!-- ### End Date ###  -->
                            <td style="padding-top: 5px;"><label for="">End Date</label></td>
                            <td style="width: 10px;"></td>
                            <td>
                                <div id="end_date" class="input-append date form_datetime datetime_picker">
                                    <input type="text" id="end_date_input" name="search[end_date]" value="<?= (isset($_GET['search'])) ? ($_GET['search']['end_date']) : "" ?>"/>
                                    <span class="add-on"><i class="icon-calendar"></i></span>
                                </div>                                  
                            </td>

                            <td style="width: 30px;"></td>

                            <!-- ### Search Button ### -->
                            <td><button type="submit" class="btn" name="search['search_button']">Search</button></td>
                        </tr>
                    </table>
                </div>
            </form>

            <div style="height: 15px;"></div>
            <!-- ###    ↓submit search       &&   ↓User have input start date         &&   ↓ User have input start date ### -->
            <?php if (isset($_GET['search']) && !empty($_GET['search']['start_date']) && !empty($_GET['search']['end_date'])) { ?> 
                <form action="PayRoll_Generate_From.php" method="post" autocomplete="off">
                    <input type="hidden" name="startdate" value="<?= $start ?>"/>
                    <input type="hidden" name="enddate" value="<?= $end ?>" />
                    <table class="table table-striped table-bordered table-hover table-condensed">
                        <thead>
                            <tr>
                                <th style="width: 90px;">Generate</th>
                                <th style="width: 100px">Staff Code</th>
                                <th>Staff Name</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php if (!empty($staff_array)) { ?>
                                <?php foreach ($staff_array as $array) { ?>
                                    <tr>
                                        <td><button type="submit" name="root_id" class="btn" value="<?= $array['root_id'?>">Generate</button></td>
                                        <td><?= $array['staff_code'?></td>
                                        <td><?= $array['staffname'?> ( <?= $array['ch_name'?> )</td>
                                    </tr>
                                <?php ?>
                            <?php } else { ?>
                                <?php if (isset($_GET['back'])) echo '<script>location.href = \"PayRoll_List.php\";</script>'?>
                                <tr>
                                    <td colspan="3"> No Payroll Generate !!</td>
                                </tr>
                            <?php ?>
                        </tbody>
                    </table>
                </form>
            <?php ?>
        </div> <!-- /container -->
    </body>
</html>