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

$formname = 'Change Of Customer Details';
$maindb = 'accmast';
//$printfile = "expense_print_fr.php";
$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"];
        $station = $_POST["station_$i"];
        $pin = $_POST["pin_$i"];
        $tel = $_POST["tel_$i"];
        $mobile = $_POST["mobile_$i"];
        $discount = $_POST["discount_$i"];
        $packing = $_POST["packing_$i"];
        $paid = $_POST["paid_$i"];

        if (!empty($name)) {
            mysqli_query($conn, "UPDATE `$maindb` SET `accode`='$accode',`name`='$name', `city`='$city', `station`='$station', `pin`='$pin',
                            `tel`='$tel', `mobile`='$mobile',discount='$discount',packing='$packing',paid='$paid' WHERE `accode`= '$accode' AND `grpcode`='010'") 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-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">

                                <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="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>
                <!--                                    <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 class="col-lg-12 col-xs-12 pad table-responsive" style="overflow-y:scroll;height:600px">
                                <table class="table table-bordered table-condensed">
                                    <thead>
                                        <tr class="mySearchTr">
                                            <th style="width:25%">Name</th>
                                            <th style="width:13%">City</th>
                                            <th style="width:14%">Station</th>
                                            <th style="width:7%">Pin</th>
                                            <th style="width:10%">Telephone</th>
                                            <th style="width:10%">Mobile</th>
                                            <th style="width:7%" class="text-right">Discount</th>
                                            <th style="width:7%" class="text-right">Packing</th>
                                            <th style="width:7%" class="text-right">Paid</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>
                </div>
            </div>
        </div>
    </form>
    <?php include("includes/linksfoot.php"); ?>
</body>
</html>
