<?php
date_default_timezone_set('Asia/Colombo');
session_start();
require_once("connectioni.php");
// ini_set('session.gc_maxlifetime', 30 * 60 * 60 * 60); 
$_SESSION["brand"] = "";

if ($_SESSION["CURRENT_USER"] == "") {
    echo "Please Loging Again !!!";
    exit();
}

if ($_SESSION["dev"] == "") {
    echo "Invalid User Session";
    exit();
}

$sql_invpara = "SELECT * from invpara where flag='" . $_SESSION['company'] . "'";
$result_invpara = mysqli_query($GLOBALS['dbinv'], $sql_invpara);
$row_invpara = mysqli_fetch_array($result_invpara);
?>

<style>
    /* Modern UI Overrides */
    :root {
        --primary-color: #3c8dbc;
        --bg-light: #f4f6f9;
        --border-color: #e0e0e0;
        --text-color: #333;
    }

    body {
        background-color: var(--bg-light);
        font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        color: var(--text-color);
    }

    .content {
        padding: 20px;
    }

    /* Card/Box Styling */
    .modern-box {
        background: #fff;
        border-radius: 8px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
        border: 1px solid var(--border-color);
        padding: 20px;
        margin-bottom: 20px;
    }

    /* Form Controls */
    .form-control {
        border-radius: 4px;
        border: 1px solid #ced4da;
        box-shadow: none;
        height: 38px; /* Taller inputs for better touch/click */
        font-size: 14px;
    }

    .form-control:focus {
        border-color: var(--primary-color);
        box-shadow: 0 0 0 0.2rem rgba(60, 141, 188, 0.25);
    }

    .form-control[disabled], .form-control[readonly] {
        background-color: #e9ecef;
        opacity: 1;
    }

    /* Labels */
    .control-label {
        font-weight: 600;
        color: #555;
        margin-bottom: 5px;
        padding-top: 7px;
        text-align: left !important; /* Align labels left for cleanliness */
    }

    /* Buttons */
    .btn {
        border-radius: 4px;
        font-weight: 500;
        padding: 8px 16px;
        transition: all 0.2s;
        margin-bottom: 5px;
    }

    .btn-default { background: #f8f9fa; border-color: #ddd; color: #444; }
    .btn-default:hover { background: #e2e6ea; }
    .btn-primary { background-color: var(--primary-color); border-color: var(--primary-color); }

    /* Payment Context Box (Hidden areas) */
    .payment-context-box {
        background-color: #fff3cd; /* Softer yellow than #edddb3 */
        border: 1px solid #ffeeba;
        color: #856404;
        border-radius: 6px;
        padding: 15px;
        margin-bottom: 15px;
        margin-top: 10px;
    }

    /* Tabs */
    .nav-tabs {
        border-bottom: 2px solid var(--border-color);
        margin-bottom: 15px;
    }
    .nav-tabs > li > a {
        border: none;
        color: #666;
        font-weight: 600;
        padding: 10px 20px;
    }
    .nav-tabs > li.active > a, 
    .nav-tabs > li.active > a:focus, 
    .nav-tabs > li.active > a:hover {
        border: none;
        border-bottom: 2px solid var(--primary-color);
        color: var(--primary-color);
        background: transparent;
    }

    /* Table Styling */
    .table-bordered {
        border: 1px solid var(--border-color);
    }
    .table > thead > tr > th, 
    .table > tbody > tr > th, 
    .table > tfoot > tr > th, 
    .table > thead > tr > td, 
    .table > tbody > tr > td, 
    .table > tfoot > tr > td {
        border: 1px solid var(--border-color);
        vertical-align: middle;
        padding: 8px;
    }
    .table tr.info th {
        background-color: #f1f5f9;
        color: #333;
        border-bottom: 2px solid #ddd;
    }

    /* Utility */
    .talign { text-align: left; }
    .mb-10 { margin-bottom: 10px; }
    .mt-10 { margin-top: 10px; }
    .flex-center-v { display: flex; align-items: center; }
    
    /* Footer Totals */
    .invoice-totals th {
        text-align: right;
        font-weight: 600;
    }
</style>

<section class="content">

    <form role="form" name="form1" class="form-horizontal">
        
        <div class="modern-box">
            <div class="row">
                <div class="col-md-5">
                    <div class="btn-group">
                        <a onclick="new_inv();" class="btn btn-default">
                            <span class="fa fa-plus-circle"></span> &nbsp; New
                        </a>
                        <?php
                        $sql_userp = "select * from view_userpermission where username='" . $_SESSION["UserName"] . "' and docname='POS Invoice' and grp='Data Capture' ";
                        $result_userp = $conn->query($sql_userp);
                        if ($row_userp = $result_userp->fetch()) {

                            if ($row_userp['doc_feed'] == 1) {
                                echo " <a onclick='save_inv();' class='btn btn-success'>
                                        <span class='fa fa-save'></span> &nbsp; Save
                                    </a> ";
                            }
                            if ($row_userp['doc_view'] == 1) {
                                echo " <a onclick='sales_inv_search()' class='btn btn-info'>
                                        <span class='fa fa-search'></span> &nbsp; Search
                                    </a> ";
                            }

                            if ($row_userp['doc_print'] == 1) {
                                echo " <a onclick='print_inv();' class='btn btn-default'>
                                        <span class='fa fa-print'></span> &nbsp; Print
                                    </a> ";
                            }

                            if ($row_userp['doc_cancel'] == 1) {
                                echo " <a onclick='cancel_inv();' class='btn btn-danger'>
                                        <span class='fa fa-trash'></span> &nbsp; Cancel
                                    </a> ";
                            }
                        }
                        ?>
                    </div>
                </div>

                <div class="col-md-3 flex-center-v">
                    <div class="btn-group" data-toggle="buttons" style="width: 100%; display: flex; gap: 10px; align-items: center;">
                        <label class="btn btn-default btn-sm active">
                            <input type="radio" name="paymethod" value="credit" id="paymethod_1" onclick="paytype('CA');" autocomplete="off"> CASH
                        </label>
                        <label class="btn btn-default btn-sm">
                            <input type="radio" name="paymethod" value="credit" id="paymethod_0" onclick="paytype('CREDIT');" autocomplete="off"> CREDIT
                        </label>
                    </div>
                </div>
            </div>
            
            <input type="hidden" id="tmpno" class="form-control">
            <input type="hidden" id="item_count" class="form-control">
            <input type="hidden" name="c_subcode" id="c_subcode">
            <input type="hidden" name="ordno" id="ordno">
            <input type="hidden" name="balance" id="balance">
            <input type="hidden" name="creditlimit" id="creditlimit">
        </div>

        <div class="row">
            <div class="col-md-12">
                <div id="cheque_view" class="payment-context-box" style='display: none;'>
                    <div class="row">
                        <div class="col-md-3">
                            <label class="control-label">Cheque No</label>
                            <input type="text" placeholder="Cheque No" id="cheque_no" name="cheque_no" class="form-control">
                        </div>
                        <div class="col-md-3">
                            <label class="control-label">Cheque Date</label>
                            <input type="date" placeholder="Cheque Date" id="cheque_date" name="cheque_date" class="form-control">
                        </div>
                        <div class="col-md-3">
                            <label class="control-label">Bank Name</label>
                            <select class="form-control" id="cheque_bank_name" name="cheque_bank_name">
                                <option value="">Select Bank Name</option>
                                <?php
                                $sql = "select * from s_bank where CANCELL='0'";
                                foreach ($conn->query($sql) as $row) {
                                    echo "<option value=\"" . $row["REFNO"] . "\">" . $row["NAME"] . " </option>";
                                }
                                ?>
                            </select>
                        </div>
                    </div>
                </div>

                <div id="card_view" class="payment-context-box" style='display: none;'>
                    <div class="row">
                        <div class="col-md-3">
                            <label class="control-label">Card Number</label>
                            <input type="text" placeholder="Card Number" id="card_number" name="card_number" class="form-control">
                        </div>
                        <div class="col-md-3">
                            <label class="control-label">Card Name</label>
                            <select class="form-control" id="card_type" name="card_type">
                                <option value="">Select Card Name</option>
                                <?php
                                $sql = "Select * from s_paycard_type where CANCELL='0'  ";
                                foreach ($conn->query($sql) as $row) {
                                    echo "<option value=\"" . $row["REFNO"] . "\">" . $row["NAME"] . "</option>";
                                }
                                ?>
                            </select>
                        </div>
                        <div class="col-md-3">
                            <label class="control-label">Card Date</label>
                            <input type="date" placeholder="Card Date" id="card_date" name="card_date" class="form-control">
                        </div>
                    </div>
                </div>

                <div id="bank_deposit_view" class="payment-context-box" style='display: none;'>
                    <div class="row">
                        <div class="col-md-3">
                            <label class="control-label">Bank Name</label>
                            <select class="form-control" id="bank_deposit_bank_name" name="bank_deposit_bank_name">
                                <option value="">Select Bank Name</option>
                                <?php
                                $sql = "select * from a_lcodes where (cat='B' or cat='C') AND COMPANY='" . $_SESSION['company'] . "'";
                                foreach ($conn->query($sql) as $row) {
                                    echo "<option value=\"" . $row["C_CODE"] . "\">" . $row["C_CODE"] . " " . $row["C_NAME"] . "</option>";
                                }
                                ?>
                            </select>
                        </div>
                        <div class="col-md-3">
                            <label class="control-label">TT Date</label>
                            <input type="date" placeholder="TT Date" id="bank_deposit_date" name="bank_deposit_date" class="form-control">
                        </div>
                        <div class="col-md-3">
                            <label class="control-label">Note</label>
                            <input type="text" placeholder="Note" id="bank_deposit_note" name="bank_deposit_note" class="form-control">
                        </div>
                    </div>
                </div>

                <div id="online_pay_view" class="payment-context-box" style='display: none;'>
                    <div class="row">
                        <div class="col-md-3">
                            <label class="control-label">Bank Name</label>
                            <select class="form-control" id="online_pay_bank_name" name="online_pay_bank_name">
                                <option value="">Select Bank Name</option>
                                <?php
                                $sql = "select * from a_lcodes where (cat='B' or cat='C') AND COMPANY='" . $_SESSION['company'] . "'";
                                foreach ($conn->query($sql) as $row) {
                                    echo "<option value=\"" . $row["C_CODE"] . "\">" . $row["C_CODE"] . " " . $row["C_NAME"] . "</option>";
                                }
                                ?>
                            </select>
                        </div>
                        <div class="col-md-3">
                            <label class="control-label">Note</label>
                            <input type="text" placeholder="Note" id="online_pay_note" name="online_pay_note" class="form-control">
                        </div>
                    </div>
                </div>

                <div id="gift_card_view" class="payment-context-box" style='display: none;'>
                    <div class="row">
                        <div class="col-md-3">
                            <label class="control-label">Gift Card No</label>
                            <input type="text" placeholder="Gift Card No" id="gift_card_no" name="gift_card_no" class="form-control">
                        </div>
                    </div>
                </div>

                <div id="msg_box" class="span12 text-center"></div>
            </div>
        </div>


        <div class="modern-box">
            <div class="row">
                <div class="col-md-1">
                        <label class="control-label">Invoice No</label>
                        <input type="text" placeholder="Ref No" disabled id="invno" class="form-control">
                </div>
                <div class="col-md-2">
                    <div class="form-group">
                        <label class="control-label">Pay Type</label>
                        <select id="pay_type" class="form-control" onclick="pay_type_change();" onchange="pay_type_change();">
                            <?php
                            $sql = "select * from s_paytype where CANCELL='0' ";
                            $result = mysqli_query($GLOBALS['dbinv'], $sql);
                            foreach ($conn->query($sql) as $row) {
                                echo "<option value=\"" . $row["REFNO"] . "\">" . $row["NAME"] . " " . $row["c_name"] . "</option>";
                            }
                            ?>
                        </select>
                    </div>
                </div>

                <div class="form-group mb-0">
                        <div class="col-md-2">
                            <label for="type2" class="control-label">Company Type</label>
                            <select id="type2" class="form-control" disabled onclick="paytype()" onchange="paytype()">
                                <option value="NORMAL">NORMAL</option>
                                <option value="DOT">DOT</option>
                            </select>
                        </div>
                        <div class="col-md-1">
                            <label for="invdate" class="control-label">Date</label>
                            <?php if (($_SESSION['User_Type'] == "1") or ($_SESSION['CURRENT_USER'] == "SEWWANDI_KLN") or ($_SESSION['CURRENT_USER'] == "SEWWANDI_KLN DOT")) { ?>
                                <input type="date" value="<?php echo date('Y-m-d'); ?>" name="invdate" id="invdate" disabled class="form-control">
                            <?php } else { ?>
                                <input type="date" value="<?php echo date('Y-m-d'); ?>" name="invdate" id="invdate" disabled class="form-control">
                            <?php } ?>
                        </div>
                    </div>

                <div class="col-md-6">
                     </div>
            </div>

            <hr style="margin-top: 5px; margin-bottom: 15px; border-top: 1px solid #eee;">

            <div class="row">
                <div class="col-md-2">
                    <label class="control-label">Customer Code</label>
                    <input type="text" class="form-control" disabled="disabled" name="firstname_hidden" id="firstname_hidden">
                </div>
                <div class="col-md-4">
                    <label class="control-label">Customer Name</label>
                    <div class="input-group">
                        <input type="text" class="form-control" id="firstname" oninput="this.value = this.value.toUpperCase()" name="firstname" />
                        <span class="input-group-btn">
                            <a class="btn btn-primary" onclick="search_customer();" title="Find Customer"><i class="fa fa-search"></i></a>
                            <a class="btn btn-warning" onclick="customer_modelll();" title="New Customer"><i class="fa fa-plus"></i></a>
                        </span>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="col-md-4">
                    <label class="control-label">Address</label>
                    <input type="text" class="form-control" oninput="this.value = this.value.toUpperCase()" name="cus_address" id="cus_address">
                    <input type="hidden" class="form-control" name="cus_address2" id="cus_address2">
                </div>
                <div class="col-md-2">
                    <label class="control-label">Tel</label>
                    <input type="text" class="form-control" name="tel" id="tel">
                </div>
            </div>

            <div class="row mt-10">
                <div class="col-md-2">
                    <label class="control-label">Department</label>
                    <select id="department" class="form-control">
                        <?php
                        if ($_SESSION["CURRENT_DEP"] != "") {
                            $sql = "select * from s_stomas where act ='1' and CODE='" . $_SESSION["CURRENT_DEP"] . "'  order by CODE";
                        } else {
                            $sql = "select * from s_stomas where act='1' order by CODE";
                        }
                        $result = mysqli_query($GLOBALS['dbinv'], $sql);
                        while ($row = mysqli_fetch_array($result)) {
                            if ($row["CODE"] == "01") {
                                echo "<option selected value='" . $row["CODE"] . "'>" . $row["DESCRIPTION"] . "-" . $row["CODE"] . "</option>";
                            } else {
                                echo "<option value='" . $row["CODE"] . "'>" . $row["DESCRIPTION"] . "-" . $row["CODE"] . "</option>";
                            }
                        }
                        ?>
                    </select>
                </div>
                <div class="col-md-2">
                    <label class="control-label">Sales Ex</label>
                    <select id="salesrep" class="form-control">
                        <?php
                        require_once("connectioni.php");
                        if ($_SESSION["MANAGER"] != "") {
                            $sql = "select * from s_salrep where pactive='1' and manager='" . $_SESSION["MANAGER"] . "'order by REPCODE";
                            $result = mysqli_query($GLOBALS['dbinv'], $sql);
                            while ($row = mysqli_fetch_array($result)) {
                                echo "<option value='" . $row["REPCODE"] . "'>" . $row["REPCODE"] . " " . $row["Name"] . "</option>";
                            }
                        } else if ($_SESSION["CURRENT_REP"] == "") {
                            $sql = "select * from s_salrep where pactive='1' order by REPCODE";
                            $result = mysqli_query($GLOBALS['dbinv'], $sql);
                            while ($row = mysqli_fetch_array($result)) {
                                echo "<option value='" . $row["REPCODE"] . "'>" . $row["REPCODE"] . " " . $row["Name"] . "</option>";
                            }
                        } else {
                            $sql = "select * from s_salrep where pactive='1' and repcode = '" . $_SESSION["CURRENT_REP"] . "' order by REPCODE";
                            $result = mysqli_query($GLOBALS['dbinv'], $sql);
                            while ($row = mysqli_fetch_array($result)) {
                                echo "<option value='" . $row["REPCODE"] . "'>" . $row["REPCODE"] . " " . $row["Name"] . "</option>";
                            }
                        }
                        ?>
                    </select>
                </div>
                <div class="col-md-2">
                    <label class="control-label">Labour</label>
                    <select id="labour" class="form-control"></select>
                </div>
                
                <div class="col-md-2 hidden">
                    <select id="brand" class="form-control hidden" onblur="brandsession();">
                        <?php
                        if (($_SESSION["CURRENT_DEP"] != "") and (!is_numeric($_SESSION["CURRENT_DEP"]))) {
                            $sql = "select * from brand_mas where act ='1' and costcenter='" . $_SESSION["CURRENT_DEP"] . "' and barnd_name='TYRE' order by barnd_name";
                        } else {
                            $sql = "select * from brand_mas where act ='1' and barnd_name='TYRE' order by barnd_name";
                        }
                        $result = mysqli_query($GLOBALS['dbinv'], $sql);
                        while ($row = mysqli_fetch_array($result)) {
                            echo "<option value='" . $row["barnd_name"] . "'>" . $row["barnd_name"] . "</option>";
                        }
                        ?>
                    </select>
                </div>

                 <div class="col-md-1 hidden">
                    <input type="checkbox" name="promotion" id="promotion">
                    <input type="text" class="form-control" onkeyup="calc();" DISABLED name="discount_org1" id="discount_org1">
                    <input type="text" class="form-control" onkeyup="calc();" DISABLED name="discount_org2" id="discount_org2">
                    <input type="hidden" class="form-control" onkeyup="calc();" name="discount_org3" id="discount_org3">
                    <select id="delitype" class="form-control">
                        <option value="NORMAL">NORMAL</option>
                        <option value="URGENT">URGENT</option>
                        <option value="TRANSPORT">TRANSPORT</option>
                        <option value="URGENT / TRANSPORT">URGENT / TRANSPORT</option>
                    </select>
                </div>
            </div>
        </div>

        <div class="modern-box">
            <ul class="nav nav-tabs">
                <li class="active"><a data-toggle="tab" href="#product">PRODUCT</a></li>
                <li><a data-toggle="tab" href="#dag">DAG</a></li>
                <li><a data-toggle="tab" href="#purchase">PURCHASE</a></li>
            </ul>

            <div class="tab-content">
                <div id="product" class="tab-pane fade in active">
                    <div class="row">
                        <div class="col-md-9">
                            <table class="table table-bordered table-striped">
                                <thead>
                                    <tr class='info'>
                                        <th style="width: 5%;">Item Code</th>
                                        <th style="width: 2%;"></th>
                                        <th style="width: 15%;">Description</th>
                                        <th style="width: 7%;">Price</th>
                                        <th style="width: 5%;">Qty</th>
                                        <th style="width: 5%;">Dis1 (%)</th>
                                        <th style="width: 5%;">Dis2 (%)</th>
                                        <th style="width: 7%;">Unit Total</th>
                                        <th style="width: 8%;">Action</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr>
                                        <td>
                                            <input type="text" class="form-control" name="itemd_hidden" id="itemd_hidden" disabled onblur="itno_ind();">
                                            <input type="hidden" name="cat1" id="cat1">
                                        </td>
                                        <td>
                                            <a onclick="search_item();" class="btn btn-primary btn-sm btn-block">
                                                <i class="fa fa-list"></i>
                                            </a>
                                        </td>
                                        <td>
                                            <input type="text" class="form-control" id="itemd" name="itemd" disabled="disabled">
                                        </td>
                                        <td>
                                            <input type="number" name="rate" id="rate" value="" class="form-control" onkeyup="calc();">
                                            <input type="hidden" name="part_no" id="part_no"> <input type="hidden" name="actual_selling" id="actual_selling">
                                        </td>
                                        <td>
                                            <input type="number" name="qty" id="qty" value="" onkeyup="calc();" class="form-control">
                                        </td>
                                        <td>
                                            <input type="number" name="discountper" id="discountper" value="" onkeyup="calcnew();" class="form-control" onkeypress="keyset('subtotal', event);">
                                        </td>
                                        <td>
                                            <input type="number" name="discountper1" id="discountper1" value="" onkeyup="calcnew();" class="form-control" onkeypress="keyset('subtotal', event);">
                                        </td>
                                        <td>
                                            <input type="text" name="subtotal" id="subtotal" value="" class="form-control" disabled="disabled" onkeypress="keyset('additem_tmp', event);">
                                        </td>
                                        <td>
                                            <input type="button" name="additem_tmp" id="additem_tmp" value="Add" onclick="add_tmp('add');" class="btn btn-primary btn-block">
                                        </td>
                                    </tr>
                                </tbody>
                            </table>

                            <div class="table-responsive">
                                <table class="table table-bordered" id="itemdetails"></table>
                            </div>
                        </div>
                    </div>
                </div>

                <div id="dag" class="tab-pane fade">
                    <div class="row">
                        <div class="col-md-9">
                            <table class="table table-bordered">
                                <tr class='info'>
                                    <th style="width: 100px;">Job No</th>
                                    <th style="width: 40px;"></th>
                                    <th>Make</th>
                                    <th>Design</th>
                                    <th>Size</th>
                                    <th>Serial No</th>
                                    <th hidden>Cost</th>
                                    <th>Selling</th>
                                    <th>Dis</th>
                                    <th>SubTotal</th>
                                    <th></th>
                                </tr>
                                <tr>
                                    <td><input type="text" placeholder="Job No" id="dag_jobno" disabled class="form-control"></td>
                                    <td>
                                        <a href="" onclick="NewWindow('invoice_search_dag.php', 'mywin', '800', '700', 'yes', 'center'); return false" class="btn btn-primary btn-sm">...</a>
                                    </td>
                                    <td><input type="text" placeholder="Make" id="dag_make" disabled class="form-control"></td>
                                    <td><input type="text" placeholder="Design" id="dag_design" disabled class="form-control"></td>
                                    <td><input type="text" placeholder="Size" id="dag_size" disabled class="form-control"></td>
                                    <td><input type="text" placeholder="Serial No" id="dag_serialno" disabled class="form-control"></td>
                                    <td hidden><input type="number" placeholder="COST" id="dag_cost" disabled onkeyup="calc_dag();" hidden onchange="calc_dag();" class="form-control" hidden></td>
                                    <td><input type="text" placeholder="Selling" id="dag_selling" onkeyup="calc_dag();" onchange="calc_dag();" onload="calc_dag();" class="form-control"></td>
                                    <td><input type="number" placeholder="Dis" id="dag_dis" onkeyup="calc_dag();" onchange="calc_dag();" class="form-control"></td>
                                    <td><input type="number" placeholder="Subtotal" id="dag_subtotal" disabled="" class="form-control"></td>
                                    <td><a onclick="add_tmp('dag');" class="btn btn-default"> <span class="fa fa-plus"></span> </a></td>
                                </tr>
                            </table>
                            <table class="table table-bordered" id="dag_table"></table>
                        </div>
                    </div>
                </div>

                <div id="purchase" class="tab-pane fade">
                    <div class="row">
                        <div class="col-md-12">
                            <table class="table table-bordered" id="purchase_table"></table>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="modern-box">
            <div class="row">
                <div class="col-md-2">
                    <div class="form-group row">
                        <label class="col-md-4 control-label">Cash Type</label>
                        <div class="col-md-5">
                             <input type="text" class="form-control" name="ctype" id="ctype">
                        </div>
                    </div>
                     <div class="form-group row">
                         <div class="col-md-4"></div>
                         <div class="col-md-6">
                            <input type="button" style="visibility: hidden" id="ctype" name="ctype" value="Cred Period Update" onclick="credupdate();" class="btn btn-primary btn-sm">
                            <div id="msg_boxcredup"></div>
                            <div id="transp"></div>
                         </div>
                    </div>
                    
                    <div id="storgrid"></div>
                    <div id="msg_boxdeliup" class="text-center"></div>

                     <div class="form-group" style="visibility: hidden">
                        <div class="col-md-4"><input type="text" class="form-control" placeholder="Name" id="deli_name"></div>
                        <div class="col-md-4"><input type="text" class="form-control" placeholder="Address" id="deli_address" /></div>
                        <div class="col-md-4" id="deli_upbut"><a onclick="deli_update();" class="btn btn-primary">Update Sub</a></div>
                        <div id="printdeli"></div>
                    </div>
                </div>
                <div class="col-md-4"></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>

                <div class="col-md-3">
                    <table class="table table-bordered invoice-totals">
                        <tr>
                            <th style="width: 50%;">Sub Total</th>
                            <td><input type="text" disabled class="form-control text-right" name="subtot" id="subtot"></td>
                        </tr>
                        <tr>
                            <th>Discount</th>
                            <td><input type="text" disabled class="form-control text-right" name="totdiscount" id="totdiscount"></td>
                        </tr>
                        <tr>
                            <th>Tax</th>
                            <td><input type="text" disabled class="form-control text-right" name="tax" id="tax"></td>
                        </tr>
                        <tr class="info">
                            <th>Grand Total</th>
                            <td><input type="text" disabled class="form-control text-right input-lg" style="font-weight:bold;" name="invtot" id="invtot"></td>
                        </tr>
                    </table>
                </div>
            </div>
        </div>

    </form>
</section>

<?php
include 'item_search_model.php';
include 'customer_search_model.php';
include 'customer_model.php';

include 'sales_inv_search.php';
?>
<script src="js/sales_inv.js?v8"></script>
<script src="js/comman.js"></script>
<script>
    new_inv();
</script>