问:点击对话框时的PHP更新

时间:2015-12-18 07:18:03

标签: javascript php jquery

我无法将status_id从1(待定)更新为2(确认)。这是我想要的每当我点击检查按钮(确认按钮)时,它会显示窗口。如果单击“是”按钮,它将自动将数据库从1(待定)更新为2(确认状态)。遗憾的是,我的代码不会更新数据库。

这是我的代码:

<table class="table table-condensed tablehead table-sortable" id="table" style="width:100%; ">
    <tr>
        <thead>
        <th style="text-wrap:normal">Transmittal #</th>
        <th>Transmittal Date</th>
        <th>Sender Name</th>
        <th>Department</th>
        <th>Invoice #</th>
        <th>Document Type</th>
        <th>Vendor Name</th>
        <th>Remark</th>
        <th>Action</th>
        </thead>
    </tr>

        <?php
            include('connection.php');

            $sql = "SELECT en.transid, en.transdate, CONCAT(userlist.lname, ', ', userlist.fname, ' ', userlist.mname) AS sender_name,
                    userlist.`department`, en.document_number, doctype.document_type, doctype.document_description, vendor.`vendor_name`, en.`remarks`, 
                    en.status_id, stat.status_name
                    FROM tbl_encode_transmittal en
                    LEFT JOIN tbl_vendor vendor ON vendor.`vendor_id` =  en.vendor_id
                    LEFT JOIN tbl_doctype doctype ON doctype.`doc_id` = en.doctype_id
                    LEFT JOIN tbl_userlist userlist ON userlist.userid = en.sender_id
                    LEFT JOIN tbl_userlist userlist1 ON userlist1.userid = en.`receiver_id`
                    LEFT JOIN tbl_status stat ON stat.status_id = en.status_id
                    WHERE userlist1.`userid` = '".$_SESSION['userid']."'";

            $rs = mysql_query($sql) or die(mysql_error());

            while($row = mysql_fetch_array($rs)){
                echo "<tr>";
                echo "<tbody id=\"myTable\">";
                echo "<td><h6>" . $row['transid'] . "</h6></td>";
                echo "<td><h6>" . $row['transdate'] . "</h6></td>";
                echo "<td><h6>" . $row['sender_name'] . "</h6></td>";
                echo "<td><h6>" . $row['department']. "</h6></td>";
                echo "<td><h6>" . $row['document_number'] . "</h6></td>";
                echo "<td><h6>" . $row['document_type'] . " " . $row['document_description'] . "</h5></td>";
                echo "<td width=\"50\"><h6>" . $row['vendor_name'] . "</h6></td>"; ?>
                <td style="text-align:center; padding-top:10;"><a href="#" class="remarksBtn"><i class="fa fa-info-circle fa-lg"></i></a></td>

                <div id="remarks-dialog" title="Remarks">
                    <?php echo $row['remarks']; ?>
                </div>

                <td>
                    <?php
                        if($row['status_id'] == 1){
                            echo "<button type=\"button\" class=\"btn btn-success\" ><i class=\"acknowledge fa fa-check-circle fa-lg\"></i></button>";
                            echo "<button type=\"button\" class=\"btn btn-danger\" ><i class=\"incomplete fa fa-times-circle fa-lg\"></i></button>";
                            echo "<button type=\"button\" class=\"btn btn-warning\" ><i class=\"onprocess fa fa-cogs fa-lg\"></i></button>";
                        }
                        else if($row['status_id'] == 2){
                            echo"<button type=\"button\" class=\"btn btn-success disabled\"><i class=\"fa fa-thumbs-o-up fa-lg\"> ".$row['status_name']."</i></button>";
                        }
                        else if($row['status_id'] == 3){
                            echo "<button type=\"button\" class=\"btn btn-warning disabled\"><i class=\"fa fa-cogs fa-lg\"> ".$row['status_name']."</i></button>";
                        }
                        else if($row['status_id'] == 4){
                            echo "<button type=\"button\" class=\"btn btn-success\" id=\"acknowledge-btn\"><i class=\"acknowledge fa fa-check-circle fa-lg\"></i></button>";
                            echo "<button type=\"button\" class=\"btn btn-warning\" id=\"onprocess-btn\"><i class=\"onprocess fa fa-cogs fa-lg\"></i></button>";
                        }
                    ?>
                </td>
            <?php } ?>
        </tbody>
    </tr>
</table>

这是我窗口的div id:

<!--////////////////////////////////////////////////////////////////////////////////////////////////////////////////////-->
<!--/////////                                Acknowledge Button Window Function                               ///////// -->
<!--/////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
<div id="window_acknowledge-btn">
    <div id="windowHeader">
        <span>
            Acknowledge Status
        </span>
    </div>
    <div id="windowContent">
        <form method="post" action="acknowledge_process.php">
            <center><h4>Do you want to acknowledge this transmittal?</h4>
                <button type="submit" class="btn btn-success" name="submit"><i class="fa fa-check-circle-o fa-lg"></i> YES</button>&nbsp;&nbsp;
                <button type="button" class="btn btn-danger" id="cancel-btn"><i class="fa fa-times-circle-o fa-lg"></i> NO</button>            
            </center>
        </form>
    </div>
</div>

这是我的窗口javascript代码:

$(document).ready(function(){

    <!--////////////////////////////////////////////////////////////////////////////////-->
    <!--/////////         Acknowledge Button jqxWindow Function                /////////-->
    <!--////////////////////////////////////////////////////////////////////////////////-->

    $('.acknowledge').click(function(){
        $('#window_acknowledge-btn').jqxWindow('open');
        $('#window_acknowledge-btn').jqxWindow('draggable', true);
        $('#window_acknowledge-btn').jqxWindow('resizable', false);
    });

    $('#window_acknowledge-btn').jqxWindow({
        autoOpen: false,
        position: {x: 300, y: 200},
        showCollapseButton: false,
        maxHeight: 700,
        maxWidth: 1000,
        minHeight: 10,
        minWidth: 10,
        height: 135,
        width: 440
    });

    <!--////////////////////////////////////////////////////////////////////////////////-->
    <!--/////////         Incomplete Button jqxWindow Function                   //////////-->
    <!--////////////////////////////////////////////////////////////////////////////////-->

    $('.incomplete').click(function(){
        $('#window_incomplete-btn').jqxWindow('open');
        $('#window_incomplete-btn').jqxWindow('draggable', true);
        $('#window_incomplete-btn').jqxWindow('resizable', false);
    });

    $('#window_incomplete-btn').jqxWindow({
        autoOpen: false,
        position: {x: 300, y: 200},
        showCollapseButton: false,
        maxHeight: 400,
        maxWidth: 700,
        minHeight: 10,
        minWidth: 10,
        height: 265,
        width: 350
    });

    <!--////////////////////////////////////////////////////////////////////////////////-->
    <!--/////////         On-Process Button jqxWindow Function                   //////////-->
    <!--////////////////////////////////////////////////////////////////////////////////-->

    $('.onprocess').click(function(){
        $('#window_onprocess-btn').jqxWindow('open');
        $('#window_onprocess-btn').jqxWindow('draggable', true);
        $('#window_onprocess-btn').jqxWindow('resizable', false);
    });

    $('#window_onprocess-btn').jqxWindow({
        autoOpen: false,
        position: {x: 300, y: 200},
        showCollapseButton: false,
        maxHeight: 400,
        maxWidth: 700,
        minHeight: 10,
        minWidth: 10,
        height: 130,
        width: 470
    });

    $('#cancel-btn').click(function(){
        $('#window_acknowledge-btn').hide(1000);
    });

    $('#cancel1-btn').click(function(){
        $('#window_incomplete-btn').hide(1000);
    });

    $('#cancel2-btn').click(function(){
        $('#window_onprocess-btn').hide(1000);
    });

    $('.remarksBtn').click(function(){
        $('#remark-dialog').dialog();
    });
});

这是我的acknowledge_process.php

<?php

    include('dbconnection_set.inc.php');
    include('dbconnection_create.inc.php');

    if(isset($_POST['submit'])){
        $sql = "UPDATE `tbl_encode_transmittal` SET status_id = '2' WHERE transid = '" . $_SESSION['transid']. "'";

        if($conn->query($sql) === TRUE){
            header('location: acknowledge_transmittal.php');
        }
        else{
            echo "Error: " . $sql . "<br>" . $conn->error;
        }
    }



?>

enter image description here

0 个答案:

没有答案