<?php
ob_start();
require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include('includes/function.php');

$formname = 'Change Of Customer Details';
$maindb = 'accmast';

$file = 'chcustdtls.php';
$trandbexist = 0;
$grid = '';
$keyfld = "accode";

$admin = $_SESSION["admin_" . $dbname];
$zdb = $_SESSION["zdbyear_" . $dbname];
mysqli_select_db($conn, $zdb);
include("includes/vouchno_generate.php");
include("includes/prev&next.php");

if (isset($_POST["submit"])) {
    $a = 1;
    $count = $_POST["items"];

    for ($i = 0; $i <= $count; $i++) {
        $accode = $_POST["accode_$i"];
        $name = $_POST["name_$i"];
        $city = $_POST["city_$i"];
        $pin = $_POST["pin_$i"];
        $tel = $_POST["tel_$i"];
        $mobile = $_POST["mobile_$i"];
        $state = $_POST["state_$i"];
        $statecode = $_POST["statecode_$i"];
        $gstno = $_POST["gstno_$i"];
        $vattin = $_POST["vattin_$i"];

        mysqli_query($conn, "UPDATE `$maindb` SET `city`='$city', `state`='$state', `statecode`='$statecode',`pin`='$pin',
                            `tel`='$tel', `mobile`='$mobile', `gstno`='$gstno',vattin='$vattin' WHERE `accode`= '$accode'") or die(mysqli_error($conn));
    }
    updmess();
    header("refresh: 1; $file?mode=last");
}

include("includes/linkshead.php");
?>
<script src="MyScript/chcustdtls.js" type="text/javascript"></script>
</head>
<body>
    <form action='' method='POST'>
        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title"><?php Echo $formname; ?></h3>
                        <div class="actions pull-right">
<!--                            <i class="fa fa-chevron-down"></i>
                            <i class="fa fa-times"></i>-->
                        </div>
                    </div>
                    <div class="panel-body">
                        <div class="form-group">
                            <div class="col-lg-12 col-xs-12 pad table-responsive">
                                <div class="col-lg-2 col-sx-3 text-right pad">
                                    <label class="label-control marg">Customer Name</label>
                                </div>
                                <div class="col-lg-6 col-sx-6 pad">
                                    <input type="text" name="custname"  class="form-control custname">
                                </div>
                                <div class="col-lg-2 col-sx-2 pad">
                                    <input type="button" class="btn btn-primary search" value="Search">
                                </div>
                            </div>
                            <div class="col-lg-12 col-xs-12 pad table-responsive">
                                <table class="table table-hover table-condensed"  style="overflow-x: scroll; overflow-y: scroll; height: 600px; display: block;">
                                    <thead>
                                        <tr class="mySearchTr">
                                            <th style="width:25%">Name</th>
                                            <th style="width:10%">City</th>
                                            <th style="width:10%">Pin</th>
                                            <th style="width:10%">Telephone</th>
                                            <th style="width:10%">Mobile</th>
                                            <th style="width:10%">State</th>
                                            <th style="width:10%">State Code</th>
                                            <th style="width:10%">VAT Tin No.</th>
                                        </tr>
                                    </thead>
                                    <tbody class="tbody">

                                    </tbody>
                                </table>
                                <input type='hidden' name='items' id='items' value='0'>
                            </div> 
                        </div>
                    </div>
                    <div class='panel-footer'>
                        <div style="overflow: auto; ">
                            <table class="table-condensed" style="margin: 0 auto;">
                                <tr>
                                    <td class=" buttonform tooltip-bottom" id="ssubmit" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="Save Record">
                                        <button id='submit' type='submit' name='submit' value='Save' class="btn btn-pad btn-square " style="background-color:#008D4C; ">
                                            <i class="fa fa-check" style="color:#ffffff"></i>
                                        </button>

                                    </td>
                                    <td class=" buttonform tooltip-bottom" id="hexit" style="display: <? Echo $exitdisabled ?>" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="Exit">
                                        <button id='exit' type="button" class="btn btn-pad btn-square " style="background-color:#cccccc; "  onClick="window.location.href = '<?= 'default.php' ?>'">
                                            <i class="fa fa-power-off" style="color:red"></i>
                                        </button>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
    <?php include("includes/linksfoot.php"); ?>
</body>
</html>
