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

$formname = 'Change Of Customer Details';
$maindb = 'item';
//$printfile = "expense_print_fr.php";
$file = 'chcustdtls.php';
$trandbexist = 0;
$grid = '';
$keyfld = "code";

$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++) {
        $code       = $_POST["code_$i"];
        $name       = $_POST["name_$i"];
        $city       = $_POST["city_$i"];
        $station    = $_POST["station_$i"];
        $pin        = $_POST["pin_$i"];
        $tel        = $_POST["tel_$i"];
        $mobile     = $_POST["mobile_$i"];
        
        if (!empty($name)) {
            mysqli_query($conn, "UPDATE `$maindb` SET `code`='$code',`name`='$name', `city`='$city', `station`='$station', `pin`='$pin',
                            `tel`='$tel', `mobile`='$mobile' WHERE `code`= '$code' AND `grpcode`='010'") or die(mysqli_error($conn));
        }
    }
    updmess();
            header("refresh: 1; $file?mode=last");
}

include("includes/linkshead.php");
?>
<script src="MyScript/chrateop.js" type="text/javascript"></script>
</head>
<body>
    <form action='' method='POST'>
        <div class="row">
            <div class="col-lg-10">
                <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">
                                    <thead>
                                        <tr class="mySearchTr">
                                            <th>Name</th>
                                            <th>City</th>
                                            <th>Station</th>
                                            <th>Pin</th>
                                            <th>Telephone</th>
                                            <th>Mobile</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='Update' 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="scancel" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="Cancel Record">
                                        <button id='cancel' type="button" class="btn btn-pad btn-square " style="background-color:#39CCCC; "  onClick="window.location.href = '<?= $file . "?mode=last" ?>'">
                                            <i class="fa fa-times" style="color:#ffffff"></i>
                                        </button>
                                    </td>-->
                                </tr>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
    <?php include("includes/linksfoot.php"); ?>
</body>
</html>
