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

$formname = 'Confirmed Record Entry';
$maindb = 'confmain';
$trandb = 'conftran';
$printfile = "";
$file = 'confrecd.php';
$trandbexist = 0;
$grid = 'confrecdmain.php';
$keyfld = "vouchno";
$keycond = " ";
$focusfield = "destination";
$mgrpcode = '009';


$admin = $_SESSION["admin_" . $dbname];
$zdb = $_SESSION["zdbyear_" . $dbname];

$usertype = $_SESSION["usertype"];
$user = $_SESSION['username_' . $dbname];

mysqli_select_db($conn,$zdb);
include("includes/vouchno_generate.php");
include("includes/prev&next.php");

$getledvouch = $_GET["vouchno"];
//browse($getledvouch);

$leadresult = mysqli_query($conn,"SELECT * FROM `leadenq` WHERE $keyfld='$getledvouch' ") or die(mysqli_error($conn));
$getlead = mysqli_fetch_array($leadresult);
//browse($getlead[deptdate]);
if (isset($_POST["submit"])) {

    $a = 1;
    $vouchdt = $_POST["vouchdt"];
    $leadvouch = $_POST["leadvouch"];
    $name = $_POST["name"];
    $lastname = $_POST["lastname"];
    $address = $_POST["address"];
    $mob = $_POST["mobile"];
    $email = $_POST["email"];
    $destination = $_POST["destination"];
    $destcity1 = $_POST["destcity1"];
    $destcity2 = $_POST["destcity2"];
    $destcity3 = $_POST["destcity3"];
    $destcity4 = $_POST["destcity4"];
    $destcity5 = $_POST["destcity5"];
    $nonights1 = $_POST["nonights1"];
    $nonights2 = $_POST["nonights2"];
    $nonights3 = $_POST["nonights3"];
    $nonights4 = $_POST["nonights4"];
    $nonights5 = $_POST["nonights5"];
    $deptdt1 = $_POST["deptdt1"];
    $deptdt2 = $_POST["deptdt2"];
    $deptdt3 = $_POST["deptdt3"];
    $deptdt4 = $_POST["deptdt4"];
    $deptdt5 = $_POST["deptdt5"];
    $deptdate = $_POST["deptdate"];
    $nonights = $_POST["nonights"];
    $retndate = $_POST["retndate"];
    $food = $_POST["food"];
    $subtotal = $_POST["subtotal"];
    $leadtot = $_POST["leadtot"];
    $netamt = $_POST["netamt"];
    $taxperc = $_POST["taxperc"];
    $taxamt = $_POST["taxamt"];
    $margamt = $_POST["margamt"];
    $actmarg = $_POST["actmarg"];
    $automarg = $_POST["automarg"];
    $billno = $_POST["billno"];
    $billdate = $_POST["billdate"];
    $leaddone = $_POST["leaddone"];
    $billdone = $_POST["billdone"];
    $leaddndt = $_POST["leaddndt"];
    $billdndt = $_POST["billdndt"];
    $bilaprov = $_POST["bilaprov"];
    $aprovbldt = $_POST["aprovbldt"];
    $mup = $_POST["mup"];
    $confchld = $_POST["confchld"];
    $confadlt = $_POST["confadlt"];
    $conftot = $_POST["conftot"];
    $confremk = $_POST["confremk"];
    $leadremk = $_POST["leadremk"];

//    browse($automarg);
//    $totpax = $_POST["totpax"];
//    $username = $_POST["username"];
    $username = $_SESSION["username_" . $dbname];
    $count = $_POST["items"];

    if ($a == 1) {

        mysqli_query($conn,"DELETE FROM `$trandb` WHERE vouchno='$qvouch'") or die(mysqli_error($conn));

        $cnt = 0;
        $cntamt = 0;

        for ($i = 0; $i < $count; $i++) {
//            browse('1');
            $msrno = $_POST["srno_$i"];
            $msupplier = $_POST["supplier_$i"];
            $particulars = $_POST["particulars_$i"];
            $amt = $_POST["amt_$i"];
            $curr = $_POST["curr_$i"];
            $roe = $_POST["roe_$i"];
            $amtrs = $_POST["amtrs_$i"];
            $acntamt = $_POST["acntamt_$i"];
            $sbillno = $_POST["sbillno_$i"];
            $sbilldt = $_POST["sbilldt_$i"];
            if (!empty($msupplier)) {
//                browse('2');
                mysqli_query($conn,"INSERT INTO `$trandb`(vouchno, vouchdt, leadvouch,  srno, supplier, `particulars`, amt, curr, roe, 
                                                    amtrs, acntamt, sbillno, sbilldt)
                            VALUES('$qvouch', '$vouchdt', $leadvouch, '$msrno', '$msupplier', '$particulars', '$amt', '$curr', '$roe',  
                                     '$amtrs', '$acntamt', '$sbillno', '$sbilldt')") or die(mysqli_error($conn));
            }
        }

//        if ($billno != '') {
        mysqli_query($conn,"UPDATE `leadenq` SET `billno`='$billno', `billdate`='$billdate', `leaddone`='$leaddone', `billdone`='$billdone', `bilaprov`='$bilaprov'   where vouchno = '$leadvouch' ") or die(mysqli_error($conn));
//        }

        if ($addflag == 1) {

            $gen1 = mysqli_query($conn,"SELECT MAX(vouchno) AS maxcode FROM `$maindb` LIMIT 0,1 ") or die(mysqli_error($conn));
            if (mysqli_num_rows($gen1) > 0) {
                $vvouch = mysqli_fetch_assoc($gen1);
                $qvouch = $vvouch["maxcode"] + 1;
            } else {
                $qvouch = '1';
            }
            $mvouch = $qvouch;

            mysqli_query($conn,"INSERT INTO `$maindb`(vouchno, `vouchdt`, `leadvouch`, `name`, `lastname`, `address`, `destination`, mobile , 
                                               `email`,`destcity1`, `destcity2`, `destcity3`,`destcity4`,`destcity5`, `deptdate`, `nonights`, `retndate`,
                                               `deptdt1`, `deptdt2`, `deptdt3`, `deptdt4`, `deptdt5`, `food`, `subtotal`, `leadtot`, `taxperc`, `taxamt`, `actmarg`, 
                                               `nonights1`,`nonights2`,`nonights3`,`nonights4`,`nonights5`,
                                               `margamt`, `billno`, `billdate`, `username`, `netamt`, `leaddone`, `leaddndt`, `billdndt`, `aprovbldt`, `bilaprov`,`billdone`,
                                               `mup`, `confadlt`, `confchld`, `conftot`, `automarg`, `leadremk`, `confremk`)
                                        VALUES($qvouch, '$vouchdt', '$leadvouch', '$name', '$lastname','$address', '$destination', '$mob' , 
                                               '$email', '$destcity1', '$destcity2', '$destcity3', '$destcity4', '$destcity5', '$deptdate', '$nonights', '$retndate', 
                                               '$deptdt1', '$deptdt2', '$deptdt3', '$deptdt4', '$deptdt5', '$food', '$subtotal', '$leadtot', '$taxperc', '$taxamt', '$actmarg',
                                               '$nonights1', '$nonights2', '$nonights3', '$nonights4', '$nonights5',   
                                               '$margamt', '$billno', '$billdate', '$username', '$netamt', '$leaddone', '$leaddndt', '$billdndt', '$aprovbldt', '$bilaprov','$billdone',
                                               '$mup', '$confadlt', '$confchld', '$conftot', '$automarg', '$leadremk', '$confremk' )") or die(mysqli_error($conn));
            insmess();
            $mvouch = $_GET["vouchno"];
            $mvouch = $qvouch;
            header("refresh: 1; $file?$keyfld=$mvouch&mode=edit");

//            header("refresh: 1; $file?mode=true");
        } else {
            $mvouch = $qvouch;
            mysqli_query($conn,"UPDATE `$maindb`  SET `vouchdt`='$vouchdt', `leadvouch`='$leadvouch', `name`='$name',  `lastname`='$lastname',`address`='$address', `destination`='$destination', mobile= '$mob', 
                        `email`='$email', `destcity1`='$destcity1',  `destcity2`='$destcity2', `destcity3`='$destcity3', `destcity4`='$destcity4', `destcity5`='$destcity5',
                        `deptdate`='$deptdate', `deptdt1`='$deptdt1', `deptdt2`='$deptdt2',`deptdt3`='$deptdt3',`deptdt4`='$deptdt4',`deptdt5`='$deptdt5',
                        `nonights`='$nonights', `nonights1`='$nonights1', `nonights2`='$nonights2', `nonights3`='$nonights3',`nonights4`='$nonights4',`nonights5`='$nonights5',
                        `subtotal`='$subtotal', `leadtot`='$leadtot', `food`='$food', `taxperc`='$taxperc', `margamt`='$margamt', `netamt`='$netamt', `billno`='$billno', `billdate`='$billdate',`retndate`='$retndate',
                        `taxamt`='$taxamt', `actmarg`='$actmarg', `leaddone`='$leaddone',`leaddndt`='$leaddndt',`billdndt`='$billdndt',`aprovbldt`='$aprovbldt',`bilaprov`='$bilaprov',`billdone`='$billdone', 
                        `mup`='$mup', `confchld`='$confchld', `confadlt`='$confadlt', `conftot`='$conftot', `automarg`='$automarg', 
                        `leadremk`='$leadremk', `confremk`='$confremk'  where vouchno = '$mvouch' ") or die(mysqli_error($conn));

            updmess();
            header("refresh: 1; $file?$keyfld=$mvouch&mode=edit");
//            header("refresh: 1; $grid");
        }
    }
}

if ($addflag != 1) {

    $getvouch = '';
    if ($addflag == 0) {
        $getvouch = $_GET[$keyfld];
    } else {
        $getvouch = $qvouch;
    }

    $result = mysqli_query($conn,"SELECT * FROM `$maindb` WHERE $keyfld='$getvouch' ") or die(mysqli_error($conn));
    $get = mysqli_fetch_array($result);
}

$senable = "";
$cenable = "";


if (isset($_GET["delete"])) {
    delete($zdb, "$maindb", "$keyfld", $_GET[$keyfld], "$file?mode=last");
    delete($zdb, "$trandb", "$keyfld", $_GET[$keyfld], "$file?mode=last");
}

include("includes/linkshead.php");
?>
<script src="MyScript/confrecd.js?v=2" type="text/javascript"></script>


</head>
<body>
    <!--    <div id="preloader" class="col-lg-12 text-center">
            <h3 class="text-center">Loading</h3>
            <div id="status">&nbsp;</div>
        </div>-->
    <form action='' method='POST'>
        <!-- Default box -->
        <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="row">
                            <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Voucher</label>
                            </div>
                            <div class="col-lg-1 col-md-2 col-sm-2 col-xs-2 pad">
                                <input type="text" class="form-control" name="vouchno" id="vouchno" value="<?php Echo ($addflag != 1) ? $get["vouchno"] : "$qvouch"; ?>" readonly>
                            </div>
                            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Lead Voucher</label>
                            </div>
                            <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 pad">
                                <input type="text" class="form-control leadvouch" id="leadvouch" name="leadvouch" value="<?php Echo ($addflag != 1) ? $get["leadvouch"] : "$getledvouch"; ?>" readonly>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Name</label>
                            </div>
                            <div class="col-lg-3 col-md-8 col-sm-8 col-xs-8 pad">
                                <input type="text" class="form-control name" name="name" value="<?php Echo ($addflag != 1) ? $get["name"] : "$getlead[name]"; ?>" <?php if ($usertype == 4) { ?> readonly <?php } ?>>
                            </div>
                            <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Last Name</label>
                            </div>
                            <div class="col-lg-3 col-md-8 col-sm-8 col-xs-8 pad">
                                <input type="text" class="form-control lastname" name="lastname" value="<?php Echo ($addflag != 1) ? $get["lastname"] : "$getlead[lastname]"; ?>" <?php if ($usertype == 4) { ?> readonly <?php } ?>>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Address</label>
                            </div>
                            <div class="col-lg-7 col-md-8 col-sm-8 col-xs-8 pad">
                                <input type="text" class="form-control mobile" name="address" value="<?php Echo ($addflag != 1) ? $get["address"] : " "; ?>" >
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Mobile</label>
                            </div>
                            <div class="col-lg-2 col-md-8 col-sm-8 col-xs-8 pad">
                                <input type="text" class="form-control mobile" name="mobile" value="<?php Echo ($addflag != 1) ? $get["mobile"] : "$getlead[mobile]"; ?>" <?php if ($usertype == 4) { ?> readonly <?php } ?>>
                            </div>
                            <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Email Id</label>
                            </div>
                            <div class="col-lg-2 col-md-8 col-sm-8 col-xs-8 pad">
                                <input type="text" class="form-control emailid" name="emailid" value="<?php Echo ($addflag != 1) ? $get["emailid"] : "$getlead[emailid]"; ?>" <?php if ($usertype == 4) { ?> readonly <?php } ?>>
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Destination</label>
                            </div>
                            <div class="col-lg-2 col-md-4 col-sm-5 col-xs-5 pad">
                                <?php
                                if ($usertype != 4) {
                                    ?>
                                    <select class="form-control select2 destination" name="destination" <?php if ($usertype == 4) { ?> readonly <?php } ?>>
                                        <option value="<? Echo ($addflag != 1 ) ? $get[destination] : "$getlead[destination]" ?>"><? Echo ($addflag != 1 ) ? $get[destination] : "$getlead[destination]" ?></option>
                                        <?
                                        $getdest = mysqli_query($conn,"SELECT * FROM `destination`")or die(mysqli_error($conn));
                                        while ($mdest = mysqli_fetch_array($getdest)) {
                                            Echo "<option value='$mdest[name]'>$mdest[name]</option>";
                                        }
                                        ?>
                                    </select>
                                <?php } else {
                                    ?>
                                    <input type="text" class="form-control destination" name="destination" value="<?php Echo ($addflag != 1) ? $get["destination"] : ""; ?>" readonly >
                                <?php }
                                ?>
                            </div>
                        </div>
                        <!--                        <div class="row">
                                                    <div class="col-lg-2 text-right  pad">
                                                        <label class="label-control marg">Total MUP</label>
                                                    </div>
                                                    <div class="col-lg-2 text-right  pad">
                                                        <input type="text" class="form-control text-right  mup" name="mup" id="mup" value="<?php Echo ($addflag != 1) ? $get["mup"] : "$getlead[mup]"; ?>" <?php if ($usertype == 4) { ?> readonly <?php } ?>>
                                                    </div>
                                                    <div class="col-lg-1 text-right pad">
                                                        <label class="label-control marg">Adult</label>
                                                    </div><div class="col-lg-1 text-right pad">
                                                        <input type="number" step="any" name="confadlt" id='confadlt' value="<?php echo ($addflag != 1) ? $get['confadlt'] : "$getlead[confadlt]"; ?>" style="width:100px;" class="form-control confadlt text-right"></div>
                                                    <div class="col-lg-1 text-right pad">
                                                        <label class="label-control marg">Child</label></div>
                                                    <div class="col-lg-1 text-right pad">
                                                        <input type="number" step="any" name="confchld" id='confchld' value="<?php echo ($addflag != 1) ? $get['confchld'] : "$getlead[confchld]"; ?>" style="width:100px;" class="form-control confchld text-right"></div>
                                                    <div class="col-lg-1 text-right pad">
                                                        <label class="label-control marg">Total</label></div>    
                                                    <div class="col-lg-1 text-right pad">
                                                        <input type="number" step="any" readonly="readonly" name="conftot" id='conftot' value="<?php echo ($addflag != 1) ? $get['conftot'] : "$getlead[conftot]"; ?>" style="width:100px;" class="form-control conftot text-right">
                                                    </div>
                                                </div>
                                            </div>-->
                        <div class="row">
                            <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Travel Date</label>
                            </div>
                            <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 pad">
                                <input type="date" class="form-control deptdate" name="deptdate" id="deptdate" value="<?php Echo ($addflag != 1) ? $get["deptdate"] : "$getlead[acttrav]"; ?>" <?php if ($usertype == 4) { ?> readonly <?php } ?>>
                            </div>
                            <div class="col-lg-1 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control marg">No. of Nights</label>
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 pad">
                                <input type="text" class="form-control nonights" name="nonights" id="nonights" value="<?php Echo ($addflag != 1) ? $get["nonights"] : ""; ?>" <?php if ($usertype == 4) { ?> readonly <?php } ?>>
                            </div>
                            <div class="col-lg-1 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control marg">Return Date</label>
                            </div>
                            <div class="col-lg-2 col-md-3 col-sm-3 col-xs-3 pad">
                                <input type="date" class="form-control retndate" name="retndate" id="retndate" value="<?php Echo ($addflag != 1) ? $get["retndate"] : ""; ?>" <?php if ($usertype == 4) { ?> readonly <?php } ?>>
                            </div>
                        </div>
                        <div class="row" style="">
                            <div style="" class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control marg">#</label>
                            </div>
                            <div style="" class="col-lg-3 col-md-4 col-sm-4 col-xs-4 text-left pad">
                                <label class="label-control marg">City</label>
                            </div>
                            <div style=""  class="col-lg-1 col-md-1 col-sm-1 col-xs-1 text-left pad">
                                <label class="label-control marg">Nights</label>
                            </div>
                            <div style="" class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-left pad">
                                <label class="label-control marg">Dept. Date</label>
                            </div>
                        </div>

                        <div class="row" style="">
                            <div  style=""  class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control marg">1</label>
                            </div>
                            <div  style="" class="col-lg-3 col-md-4 col-sm-4 col-xs-4 pad">
                                <?php
                                if ($usertype != 4) {
                                    ?>    
                                    <select class="form-control select2 destcity1" name="destcity1" <?php if ($usertype == 4) { ?> readonly <?php } ?>>
                                        <option value="<? Echo ($addflag != 1 ) ? $get[destcity1] : "" ?>"><? Echo ($addflag != 1 ) ? $get[destcity1] : "" ?></option>
                                        <?
                                        $getdestc1 = mysqli_query($conn,"SELECT * FROM `city`")or die(mysqli_error($conn));

                                        while ($mdestc1 = mysqli_fetch_array($getdestc1)) {
                                            Echo "<option value='$mdestc1[name]'>$mdestc1[name]</option>";
                                        }
                                        ?>
                                    </select>
                                <?php } else { ?>
                                    <input type="text" class="form-control destcity1" id="destcity1" name="destcity1" value="<?php Echo ($addflag != 1) ? $get["destcity1"] : ""; ?>" readonly >    
                                <?php } ?>
                            </div>
                            <div  style="" class="col-lg-1 col-md-1 col-sm-1 col-xs-1 pad">
                                <input type="text" class="form-control nonights1" id="nonights1" name="nonights1" value="<?php Echo ($addflag != 1) ? $get["nonights1"] : "0"; ?>" <?php if ($usertype == 4) { ?> readonly <?php } ?>>
                            </div>
                            <div style="" class="col-lg-2 col-md-3 col-sm-3 col-xs-3 pad">
                                <input type="date" class="form-control deptdt1" id="deptdt1" name="deptdt1" value="<?php Echo ($addflag != 1) ? $get["deptdt1"] : "$getlead[acttrav]"; ?>" <?php if ($usertype == 4) { ?> readonly <?php } ?>>
                            </div>
                        </div>
                        <div class="row" style="">
                            <div  style=""  class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control marg">2</label>
                            </div>
                            <div  style="" class="col-lg-3 col-md-4 col-sm-4 col-xs-4 pad">
                                <?php
                                if ($usertype != 4) {
                                    ?>    
                                    <select class="form-control select2 destcity2" name="destcity2">
                                        <option value="<? Echo ($addflag != 1 ) ? $get[destcity2] : "" ?>"><? Echo ($addflag != 1 ) ? $get[destcity2] : "" ?></option>
                                        <?
                                        $getdestc2 = mysqli_query($conn,"SELECT * FROM `city`")or die(mysqli_error($conn));

                                        while ($mdestc2 = mysqli_fetch_array($getdestc2)) {
                                            Echo "<option value='$mdestc2[name]'>$mdestc2[name]</option>";
                                        }
                                        ?>
                                    </select>
                                <?php } else { ?>
                                    <input type="text" class="form-control destcity2" id="destcity2" name="destcity2" value="<?php Echo ($addflag != 1) ? $get["destcity2"] : ""; ?>" readonly >    
                                <?php } ?>
                            </div>
                            <div  style="" class="col-lg-1 col-md-1 col-sm-1 col-xs-1 pad">
                                <input type="text" class="form-control nonights2" id="nonights2" name="nonights2" value="<?php Echo ($addflag != 1) ? $get["nonights2"] : "0"; ?>" <?php if ($usertype == 4) { ?> readonly <?php } ?>>
                            </div>
                            <div style="" class="col-lg-2 col-md-3 col-sm-3 col-xs-3 pad">
                                <input type="date" class="form-control deptdt2" id="deptdt2"  name="deptdt2" value="<?php Echo ($addflag != 1) ? $get["deptdt2"] : ""; ?>" <?php if ($usertype == 4) { ?> readonly <?php } ?>>
                            </div>
                        </div>
                        <div class="row" style="">
                            <div  style="" class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control marg">3</label>
                            </div>
                            <div  style="" class="col-lg-3 col-md-4 col-sm-4 col-xs-4 pad">
                                <?php
                                if ($usertype != 4) {
                                    ?>    
                                    <select class="form-control select2 destcity3" name="destcity3" >
                                        <option value="<? Echo ($addflag != 1 ) ? $get[destcity3] : "" ?>"><? Echo ($addflag != 1 ) ? $get[destcity3] : "" ?></option>
                                        <?
                                        $getdestc3 = mysqli_query($conn,"SELECT * FROM `city`")or die(mysqli_error($conn));

                                        while ($mdestc3 = mysqli_fetch_array($getdestc3)) {
                                            Echo "<option value='$mdestc3[name]'>$mdestc3[name]</option>";
                                        }
                                        ?>
                                    </select>
                                <?php } else { ?>
                                    <input type="text" class="form-control destcity3" id="destcity3" name="destcity3" value="<?php Echo ($addflag != 1) ? $get["destcity3"] : ""; ?>" readonly >    
                                <?php } ?>
                            </div>
                            <div  style="" class="col-lg-1 col-md-1 col-sm-1 col-xs-1 pad">
                                <input type="text" class="form-control nonights3" id="nonights3" name="nonights3" value="<?php Echo ($addflag != 1) ? $get["nonights3"] : "0"; ?>" <?php if ($usertype == 4) { ?> readonly <?php } ?>>
                            </div>
                            <div style="" class="col-lg-2 col-md-3 col-sm-3 col-xs-3 pad">
                                <input type="date" class="form-control deptdt3" id="deptdt3" name="deptdt3" value="<?php Echo ($addflag != 1) ? $get["deptdt3"] : ""; ?>" <?php if ($usertype == 4) { ?> readonly <?php } ?>>
                            </div>
                        </div>
                        <div class="row" >
                            <div  style="" class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control marg">4</label>
                            </div>
                            <div  style="" class="col-lg-3 col-md-4 col-sm-4 col-xs-4 pad">
                                <?php
                                if ($usertype != 4) {
                                    ?>    
                                    <select class="form-control select2 destcity4" name="destcity4" >
                                        <option value="<? Echo ($addflag != 1 ) ? $get[destcity4] : "" ?>"><? Echo ($addflag != 1 ) ? $get[destcity4] : "" ?></option>
                                        <?
                                        $getdestc4 = mysqli_query($conn,"SELECT * FROM `city`")or die(mysqli_error($conn));

                                        while ($mdestc4 = mysqli_fetch_array($getdestc4)) {
                                            Echo "<option value='$mdestc4[name]'>$mdestc4[name]</option>";
                                        }
                                        ?>
                                    </select>
                                <?php } else { ?>
                                    <input type="text" class="form-control destcity4" id="destcity4" name="destcity4" value="<?php Echo ($addflag != 1) ? $get["destcity4"] : ""; ?>" readonly >    
                                <?php } ?>
                            </div>
                            <div  style="" class="col-lg-1 col-md-1 col-sm-1 col-xs-1 pad">
                                <input type="text" class="form-control nonights4" id="nonights4" name="nonights4" value="<?php Echo ($addflag != 1) ? $get["nonights4"] : "0"; ?>" <?php if ($usertype == 4) { ?> readonly <?php } ?>>
                            </div>
                            <div style="" class="col-lg-2 col-md-3 col-sm-3 col-xs-3 pad">
                                <input type="date" class="form-control deptdt4" id="deptdt4"  name="deptdt4" value="<?php Echo ($addflag != 1) ? $get["deptdt4"] : ""; ?>" <?php if ($usertype == 4) { ?> readonly <?php } ?>>
                            </div>
                        </div>
                        <div class="row" style="">
                            <div  style="" class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control marg">5</label>
                            </div>
                            <div  style="" class="col-lg-3 col-md-4 col-sm-4 col-xs-4 pad">
                                <?php
                                if ($usertype != 4) {
                                    ?>    
                                    <select class="form-control select2 destcity5" name="destcity5" >
                                        <option value="<? Echo ($addflag != 1 ) ? $get[destcity5] : "" ?>"><? Echo ($addflag != 1 ) ? $get[destcity5] : "" ?></option>
                                        <?
                                        $getdestc5 = mysqli_query($conn,"SELECT * FROM `city`")or die(mysqli_error($conn));

                                        while ($mdestc5 = mysqli_fetch_array($getdestc5)) {
                                            Echo "<option value='$mdestc5[name]'>$mdestc5[name]</option>";
                                        }
                                        ?>
                                    </select>
                                <?php } else { ?>
                                    <input type="text" class="form-control destcity5" id="destcity5" name="destcity5" value="<?php Echo ($addflag != 1) ? $get["destcity5"] : ""; ?>" readonly >    
                                <?php } ?>
                            </div>
                            <div  style="" class="col-lg-1 col-md-1 col-sm-1 col-xs-1 pad">
                                <input type="text" class="form-control nonights5" id="nonights5" name="nonights5" value="<?php Echo ($addflag != 1) ? $get["nonights5"] : "0"; ?>" <?php if ($usertype == 4) { ?> readonly <?php } ?>>
                            </div>
                            <div style="" class="col-lg-2 col-md-3 col-sm-3 col-xs-3 pad">
                                <input type="date" class="form-control deptdt5" id="deptdt5"  name="deptdt5" value="<?php Echo ($addflag != 1) ? $get["deptdt5"] : ""; ?>" <?php if ($usertype == 4) { ?> readonly <?php } ?>>
                            </div>
                        </div>

                        <div style="border: 1px solid brown;">
                            <div class="row" >
                                <div  style="" class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                    <label style="color:brown;" class="label-control marg">Food</label>
                                </div>

                                <div  style="" class="col-lg-1 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                    <label style="color:red;" class="label-control marg" value="">Non-Veg</label>
                                </div>
                                <div  style="" class="col-lg-1 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                    <input type="radio" name="food" class="" value="N" <?php if ($get['food'] == 'N') echo 'checked'; ?>  style="height:35px; width:20px; vertical-align: middle; margin-right:56px;" <?php if ($usertype == 4) { ?> readonly <?php } ?>>                                    
                                </div>

                                <div  style="" class="col-lg-1 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                    <label style="color:green;" class="label-control marg">Veg</label>
                                </div>
                                <div  style="" class="col-lg-1 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                    <input type="radio" name="food" class="" value="V" <?php if ($get['food'] == 'V') echo 'checked'; ?> style="height:35px; width:20px; vertical-align: middle; margin-right:56px;" <?php if ($usertype == 4) { ?> readonly <?php } ?>>
                                </div>
                                <div  style="" class="col-lg-1 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                    <label style="color:orange;" class="label-control marg">Jain</label>
                                </div>

                                <div  style="" class="col-lg-1 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                    <input type="radio" name="food" class="" value="J" <?php if ($get['food'] == 'J') echo 'checked'; ?> style="height:35px; width:20px; vertical-align: middle; margin-right:56px;" <?php if ($usertype == 4) { ?> readonly <?php } ?>> 
                                </div>
                                <div  style="" class="col-lg-1 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                    <label style="" class="label-control marg">Halal</label>
                                </div>

                                <div  style="" class="col-lg-1 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                    <input type="radio" name="food" class="" value="H" <?php if ($get['food'] == 'H') echo 'checked'; ?> style="height:35px; width:20px; vertical-align: middle; margin-right:56px;" <?php if ($usertype == 4) { ?> readonly <?php } ?>> 
                                </div>
                            </div>
                        </div>

                        <div class="table-responsive">
                            <table id="data" align="center" border="1px" width="100%" class="table-bordered">
                                <thead>
                                    <tr>
                                        <th width="2%" style="font-family: arial-regular;color:black;" align="center"><label class="control-label">Sr.</label></th>
                                        <th width="10%" style="font-family: arial-regular;color:black;" align="center"><label class="control-label">Supplier</label></th>
                                        <th width="10%" align="right" style="text-align:left;color:black;font-family: arial-regular;"><label class="control-label">Pariculars</label></th>
                                        <th width="7%" align="right" style="text-align:right;color:black;font-family: arial-regular;"><label class="control-label">Amount</label></th>
                                        <th width="3%" align="right" style="text-align:left;color:black;font-family: arial-regular;"><label class="control-label">Currency</label></th>
                                        <th width="7%" align="right" style="text-align:right;color:black;font-family: arial-regular;"><label class="control-label">ROE</label></th>
                                        <th width="7%" align="right" style="text-align:right;color:black;font-family: arial-regular;"><label class="control-label">Amt. in Rs.</label></th>
                                        <th width="7%" align="right" style="text-align:right;color:black;font-family: arial-regular;"><label class="control-label">Account Amt.</label></th>
                                        <th width="7%" align="right" style="text-align:left;color:black;font-family: arial-regular;"><label class="control-label">Bill No.</label></th>
                                        <th width="7%" align="right" style="text-align:left;color:black;font-family: arial-regular;"><label class="control-label">Bill Date</label></th>
                                        <th width="15%" align="right" style="text-align:left;color:black;font-family: arial-regular;"><label class="control-label">Bill Upload</label></th>
                                        <th width="15%" align="right" style="text-align:left;color:black;font-family: arial-regular;"><label class="control-label">Ledger Upload</label></th>
                                    </tr>
                                </thead>
                                <?php
                                if ($addflag != 1) {
                                    $qry = mysqli_query($conn,"SELECT * FROM  `$trandb` WHERE vouchno='$getvouch' ORDER BY srno") or die(mysqli_error($conn));

                                    $ctr = 0;
                                    while ($row = mysqli_fetch_array($qry)) {
                                        echo "<tr>";
                                        echo "<td style='height:30px;' align='left' valign='center'><input type='text' id='srno' size='6' maxlength='6' name='srno_" . $ctr . "' class='srno form-control' style='height:29px;' value='$row[srno]'/></td>";
                                        if ($usertype != 4) {
                                            echo "<td style='height:30px;' align='left' valign='center'>";
                                            echo "<select name='supplier_$ctr' style='height:29px;width:100%' class='supplier form-control'>";
                                            echo "<option value='$row[supplier]'>$row[supplier]</option>";
                                            $mitem = mysqli_query($conn,"SELECT * FROM `accmast` where `grpcode`='009' ORDER BY `name`") or die(mysqli_error($conn));
                                            while ($trow1 = mysqli_fetch_array($mitem)) {
                                                echo "<option value='$trow1[name]' >$trow1[name]</option>";
                                            }
                                            echo "</select>";
                                            echo "</td>";
                                            echo "<td style='height:30px;' align='center' valign='center'><input type='text' size=''  name='particulars_$ctr' class='particulars form-control' style='height:29px;text-align:left;' value='$row[particulars]' /></td>";
                                            echo "<td style='height:30px;' align='center' valign='center'><input type='number' step='any' size=''  name='amt_$ctr' class='amt form-control ' style='height:29px;text-align:right;' value='$row[amt]'/></td>";
                                        } else {
                                            echo "<td align='center' style='height:30px;' valign='center'><input type='text' name='supplier_$ctr' class='supplier form-control' style='height:29px;text-align:left;' value='$row[supplier]' readonly/></td>";
                                            echo "<td style='height:30px;' align='center' valign='center'><input type='text' size=''  name='particulars_$ctr' class='particulars form-control' style='height:29px;text-align:left;' value='$row[particulars]'  readonly /></td>";
                                            echo "<td style='height:30px;' align='center' valign='center'><input type='number' step='any' size=''  name='amt_$ctr' class='amt form-control ' style='height:29px;text-align:right;' value='$row[amt]' readonly/></td>";
                                        }
//                                        echo "<td style='height:30px;' align='center' valign='center'><input type='text' size=''  name='particulars_$ctr' class='particulars form-control' style='height:29px;text-align:left;' value='$row[particulars]'  if($usertype ==4) { readonly }/></td>";
//                                        echo "<td style='height:30px;' align='center' valign='center'><input type='text' size=''  name='curr_$ctr' class='curr form-control' style='height:29px;text-align:left;' value='$row[curr]'/></td>";
                                        echo "<td align='left' style='height:30px;'>";
                                        ?>
                                        <select name = "currency_<?= $pctr ?>" class = "currency form-control" style = 'height:29px;width:100%;'>
                                            <option value = "INR">INR</option>
                                            <?php
                                            $mcurrency = mysqli_query($conn,"SELECT * FROM `currency` ORDER BY `name`") or die(mysqli_error($conn));
                                            while ($tcurrency = mysqli_fetch_array($mcurrency)) {
                                                echo "<option value='$tcurrency[name]' >$tcurrency[name]</option>";
                                            }
                                            ?>
                                        </select>
                                        <?php
                                        echo "</td>";
                                        echo "<td style='height:30px;' align='center' valign='center'><input type='number' step='any' size=''  name='roe_$ctr' class='roe form-control' style='height:29px;text-align:right;' value='$row[roe]'/></td>";
                                        echo "<td style='height:30px;' align='center' valign='center'><input type='number' step='any' size=''  name='amtrs_$ctr' class='amtrs form-control ' style='height:29px;text-align:right;' value='$row[amtrs]'  readonly/></td>";
                                        if ($usertype == 1 || $usertype == 4) {
                                            echo "<td style='height:30px;' align='center' valign='center'><input type='number' step='any' size=''  name='acntamt_$ctr' class='acntamt form-control ' style='height:29px;text-align:right;' value='$row[acntamt]'/></td>";
                                            echo "<td style='height:30px;' align='center' valign='center'><input type='text' size=''  name='sbillno_$ctr' class='sbillno form-control ' style='height:29px;text-align:left;' value='$row[sbillno]'  /></td>";
                                            echo "<td style='height:30px;' align='center' valign='center'><input type='date' size=''  name='sbilldt_$ctr' class='sbilldt form-control ' style='height:29px;text-align:left;' value='$row[sbilldt]'/></td>";
                                        } else {
                                            echo "<td style='height:30px;' align='center' valign='center'><input type='number' step='any' size=''  name='acntamt_$ctr' class='acntamt form-control ' style='height:29px;text-align:right;' value='$row[acntamt]' readonly/></td>";
                                            echo "<td style='height:30px;' align='center' valign='center'><input type='text' size=''  name='sbillno_$ctr' class='sbillno form-control ' style='height:29px;text-align:left;' value='$row[sbillno]'  readonly/></td>";
                                            echo "<td style='height:30px;' align='center' valign='center'><input type='date' size=''  name='sbilldt_$ctr' class='sbilldt form-control ' style='height:29px;text-align:left;' value='$row[sbilldt]'   readonly/></td>";
                                        }
                                        ?>
                                        <td>
                                            <button type="button" class="btn btn-square billupload" name="billupload_<?= $ctr ?>" style="background-color:#D4744D; color:white;">
                                                Bill Updload & Download
                                            </button>
                                            <!--<button class="btn btn-square "><a href="demopdf.php?vouchno=<?= $qvouch ?> "></a>Download</button>--> 
                                        </td>
                                        <td>
                                            <button type="button" class="btn btn-square ledgupload" name="ledgupload_<?= $ctr ?>" style="background-color:#64CCFC; color:white;">
                                                Ledger Updload & Download
                                            </button>
                                            <!--<button class="btn btn-square "><a href="demopdf.php?vouchno=<?= $qvouch ?> "></a>Download</button>--> 
                                        </td>
                                        <?php
                                        echo "</tr>";
                                        $ctr++;
                                    }
                                    //browse($ctr);  
                                } else {
                                    $pctr = 0;
                                    $yctr = 0;
                                    for ($i = $pctr; $i < 3; $i++) {
                                        $yctr++;
                                        echo "<tr>";
                                        echo "<td style='height:30px;' align='left' valign='center'><input type='text' size='6' maxlength='6' name='srno_$pctr' id='srno' class='sno form-control' style='height:29px;' value='$yctr'/></td>";
                                        if ($usertype != 4) {
                                            echo "<td align='left' style='height:30px;'>";
                                            ?>
                                            <select name = "supplier_<?= $pctr ?>" class = "supplier form-control" style = 'height:29px;width:100%;'>
                                                <option value = ""></option>
                                                <?php
                                                $mitem = mysqli_query($conn,"SELECT * FROM `accmast` where `grpcode`='009' ORDER BY `name`") or die(mysqli_error($conn));
                                                while ($trow1 = mysqli_fetch_array($mitem)) {
                                                    echo "<option value='$trow1[name]' >$trow1[name]</option>";
                                                }
                                                ?>
                                            </select>
                                            <?php
                                            echo "</td>";
                                            echo "<td align='center' style='height:30px;' valign='center'><input type='text' size=''  name='particulars_$pctr' class='particulars form-control' style='height:29px;text-align:left;' value=''/></td>";
                                            echo "<td align='center' style='height:30px;' valign='center'><input type='number' size='' step='any'  name='amt_$pctr' class='amt form-control' style='height:29px;text-align:right;' value='0'/></td>";
                                        } else {
                                            echo "<td align='center' style='height:30px;' valign='center'><input type='number' size='' step='any'  name='amt_$pctr' class='amt form-control' style='height:29px;text-align:right;' value='0' readonly/></td>";
                                            echo "<td align='center' style='height:30px;' valign='center'><input type='text' name='supplier_$pctr' class='supplier form-control' style='height:29px;text-align:left;' value=''  readonly/></td>";
                                            echo "<td align='center' style='height:30px;' valign='center'><input type='text' size=''  name='particulars_$pctr' class='particulars form-control' style='height:29px;text-align:left;' readonly value=''/></td>";
                                        }


                                        echo "<td align='left' style='height:30px;'>";
                                        ?>
                                        <select name = "currency_<?= $pctr ?>" class = "currency form-control" style = 'height:29px;width:100%;'>
                                            <option value = "INR">INR</option>
                                            <?php
                                            $mcurrency = mysqli_query($conn,"SELECT * FROM `currency` ORDER BY `name`") or die(mysqli_error($conn));
                                            while ($tcurrency = mysqli_fetch_array($mcurrency)) {
                                                echo "<option value='$tcurrency[name]' >$tcurrency[name]</option>";
                                            }
                                            ?>
                                        </select>
                                        <?php
                                        echo "</td>";
//                                        echo "<td align='center' style='height:30px;' valign='center'><input type='text' size=''  name='curr_$pctr' class='curr form-control' style='height:29px;text-align:left;' value=''></td>";
                                        echo "<td align='center' style='height:30px;' valign='center'><input type='number' step='any' size=''  name='roe_$pctr' class='roe form-control' style='height:29px;text-align:right;' value='1'/></td>";
                                        echo "<td align='center' style='height:30px;' valign='center'><input type='number' step='any'  size=''  name='amtrs_$pctr' class='amtrs form-control' style='height:29px;text-align:right;' value='0'  readonly/></td>";
                                        if ($usertype != 4 && $usertype != 1) {
                                            echo "<td style='height:30px;' align='center' valign='center'><input type='number' step='any' size=''  name='acntamt_$ctr' class='acntamt form-control ' style='height:29px;text-align:right;' value='$row[acntamt]' readonly/></td>";
                                            echo "<td style='height:30px;' align='center' valign='center'><input type='text' size=''  name='sbillno_$pctr' class='sbillno form-control ' style='height:29px;text-align:left;' value=''  readonly/></td>";
                                            echo "<td style='height:30px;' align='center' valign='center'><input type='date' size=''  name='sbilldt_$pctr' class='sbilldt form-control ' style='height:29px;text-align:left;' value='' readonly/></td>";
                                        } else {
                                            echo "<td style='height:30px;' align='center' valign='center'><input type='number' step='any' size=''  name='acntamt_$ctr' class='acntamt form-control ' style='height:29px;text-align:right;' value='$row[acntamt]' /></td>";
                                            echo "<td style='height:30px;' align='center' valign='center'><input type='text' size=''  name='sbillno_$pctr' class='sbillno form-control ' style='height:29px;text-align:left;' value=''  /></td>";
                                            echo "<td style='height:30px;' align='center' valign='center'><input type='date' size=''  name='sbilldt_$pctr' class='sbilldt form-control ' style='height:29px;text-align:left;' value=''/></td>";
                                        }
                                        ?>
                                        <td>
                                            <button type="button" class="btn btn-square billupload" name="billupload_<?= $ctr ?>" style="background-color:#D4744D; color:white;">
                                                Bill Updload & Download
                                            </button>
                                            <!--<button class="btn btn-square "><a href="demopdf.php?vouchno=<?= $qvouch ?> "></a>Download</button>--> 
                                        </td>
                                        <td>
                                            <button type="button" class="btn btn-square ledgupload" name="ledgupload_<?= $ctr ?>" style="background-color:#64CCFC; color:white;">
                                                Ledger Updload & Download
                                            </button>
                                            <!--<button class="btn btn-square "><a href="demopdf.php?vouchno=<?= $qvouch ?> "></a>Download</button>--> 
                                        </td>
                                        <?php
                                        echo "</tr>";
                                        $pctr++;
                                    }
                                }
                                ?>
                            </table>
                        </div>
                        <div class="form-group" style="padding-left: 13px;">
                            <?php
                            if ($usertype != 4) {
                                ?>
                                <input type="button" style="height: 30px; width: 30px; padding: 0px" id="addnew" class="btn btn-success btn-lg" accode="addnew2" value="+" />
                            <?php } ?>
                            <input type="hidden" id="items" name="items" value="<?php echo ($addflag != 1) ? $ctr : $pctr; ?>" />  

                        </div>
                        <div class="row">
                            <div class="col-lg-1 col-md-2 col-sm-2 col-xs-2" style="color: green">
                                <label class="label-control marg" style="padding-left: 0px;padding-right: 0px">Lead Done</label>
                            </div>
                            <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2">
                                <select name="leaddone" id='leaddone' class="form-control leaddone" style="color: green" >
                                    <option></option>   
                                    <option value='N'<?php
                                    if ($addflag != 1) {
                                        if ($get["leaddone"] == "N") {
                                            echo "selected='selected'";
                                        }
                                    }
                                    ?> >No</option>
                                    <option value="Y"<?php
                                    if ($addflag != 1) {
                                        if ($get["leaddone"] == "Y") {
                                            echo "selected='selected'";
                                        }
                                    }
                                    ?>>Yes</option>   
                                </select>
                                <input type="date" name="leaddndt" class="form-control leaddndt" value="<?php echo ($addflag != 1) ? $get[leaddndt] : ""; ?>" style="" readonly>
                            </div>
                            <div class="col-lg-1 col-md-2 col-sm-2 col-xs-2 pad" style="color: red">
                                <label style="" class="label-control marg">Bill Done</label>
                            </div>
                            <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 pad">
                                <select name="billdone" id='billdone' class="form-control billdone" style="color: red" >
                                    <option></option>   
                                    <option value='N'<?php
                                    if ($addflag != 1) {
                                        if ($get["billdone"] == "N") {
                                            echo "selected='selected'";
                                        }
                                    }
                                    ?> >No</option>
                                    <option value="Y"<?php
                                    if ($addflag != 1) {
                                        if ($get["billdone"] == "Y") {
                                            echo "selected='selected'";
                                        }
                                    }
                                    ?>>Yes</option>   
                                </select> 
                                <input type="date" name="billdndt" class="form-control billdndt" value="<?php echo ($addflag != 1) ? $get[billdndt] : ""; ?>" style="" readonly>
                            </div>
                            <div class="col-lg-1 col-md-2 col-sm-2 col-xs-2 pad" style="color: blue">
                                <label style="" class="label-control marg">Billing Approved </label>
                            </div>
                            <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 pad">
                                <select name="bilaprov" id='bilaprov' class="form-control bilaprov" style="color: blue" >
                                    <option></option>   
                                    <option value='N'<?php
                                    if ($addflag != 1) {
                                        if ($get["bilaprov"] == "N") {
                                            echo "selected='selected'";
                                        }
                                    }
                                    ?> >No</option>
                                    <option value="Y"<?php
                                    if ($addflag != 1) {
                                        if ($get["bilaprov"] == "Y") {
                                            echo "selected='selected'";
                                        }
                                    }
                                    ?>>Yes</option>  
                                </select> 
                                <input type="date" name="aprovbldt" class="form-control aprovbldt" value="<?php echo ($addflag != 1) ? $get[aprovbldt] : ""; ?>" style="" readonly>
                            </div>

                        </div>

                        <div class="row" style="border: 1px solid gray;">
                            <!--<div class="" style="">-->
                            <div style="" class="col-lg-4 col-md-2 col-sm-2 col-xs-2 text-left pad">
                                <button type="button" class="btn btn-square pdfupload" name="pdfupload" style="background-color:#64CCFC; color:white;">
                                    <i class="fa fa-file-pdf-o"></i>&nbsp;&nbsp;&nbsp;PDF Upload
                                </button>
<!--                                <button class="btn btn-square "><a href="demopdf.php?vouchno=<?= $qvouch ?> ">
                                        PDF Download</a></button> -->
                            </div>
                            <!--                            <div style=""  class="col-lg-1 col-md-1 col-sm-1 col-xs-1 text-right pad">
                                                            <label class="label-control marg"></label>
                                                        </div>-->
                            <div style=""  class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right pad">

                            </div>
                            <div  class="col-lg-1 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control marg">Lead Total</label>
                            </div>
                            <div style=""  class="col-lg-1 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <input type="number"  style="width:135px;text-align: right;" class="form-control leadtot"  id="leadtot"  name="leadtot" value="<?php Echo ($addflag != 1) ? $get["leadtot"] : "0"; ?>" readonly>
                            </div>
                            <div  class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control marg">Account Total</label>
                            </div>
                            <div style=""  class="col-lg-1 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <input type="number"  style="width:135px;text-align: right;" class="form-control subtotal"  id="subtotal"  name="subtotal" value="<?php Echo ($addflag != 1) ? $get["subtotal"] : "0"; ?>" readonly>
                            </div>
                        </div>
                        <div class="row" style="border: 1px solid gray;">
                            <div style="" class="col-lg-3 col-md-2 col-sm-2 col-xs-2 text-left pad">
                                <button type="button" class="btn btn-square zipupload" name="zipupload" toggle="modal" data-target="#zipModal" style="background-color:#727799; color:white;">
                                    <i class="fa fa-file-zip-o"></i>&nbsp;&nbsp;&nbsp;Zip Upload
                                </button>
                                <button class="btn btn-square "><a href="down_zip.php?vouchno=<?= $qvouch ?> ">Zip Download</a></button> 
                            </div>
                            <div style="" class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control marg">Margin/Manual</label>
                            </div>
                            <div style="" class="col-lg-1 col-md-4 col-sm-4 col-xs-4 text-left pad">
                                <select name="automarg" id='automarg' class="form-control automarg" style="" >
                                    <option></option>   
                                    <option value='A'<?php
                                    if ($addflag != 1) {
                                        if ($get["automarg"] == "A") {
                                            echo "selected='selected'";
                                        }
                                    }
                                    ?> >Margin</option>
                                    <option value="M"<?php
                                    if ($addflag != 1) {
                                        if ($get["automarg"] == "M") {
                                            echo "selected='selected'";
                                        }
                                    }
                                    ?>>Manual</option>  
                                </select>
                            </div>
                            <div style=""  class="col-lg-1 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control marg">Margin</label>
                            </div>
                            <div style=""  class="col-lg-1 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <input type="number"  style="width:135px;text-align: right;" class="form-control margamt" id="margamt" name="margamt" value="<?php Echo ($addflag != 1) ? $get["margamt"] : "0"; ?>"  <?php if ($usertype == 4) { ?> readonly <?php } ?>>
                            </div>
                            <div style=""  class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control marg">Service Tax </label>
                            </div>
                            <div  class="col-lg-1 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <input type="number"  style="text-align: right;" class="form-control taxperc" id="taxperc" name="taxperc" value="<?php Echo ($addflag != 1) ? $get["taxperc"] : "0"; ?>"  <?php if ($usertype == 4) { ?> readonly <?php } ?>>
                            </div>
                            <div style=""  class="col-lg-1 col-md-1 col-sm-1 col-xs-1 ">
                                <label class="label-control marg">%</label>
                            </div>
                        </div>
                        <div class="row" style="border: 1px solid gray;">
                            <div style="" class="col-lg-3 col-md-2 col-sm-2 col-xs-2 text-left pad">
                                <label class="label-control marg"></label>
                            </div>
                            <div style="" class="col-lg-3 col-md-4 col-sm-4 col-xs-4 text-left pad">
                                <label class="label-control marg"></label>
                            </div>

                            <div style=""  class="col-lg-1 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control marg">Act. Margin</label>
                            </div>
                            <div style=""  class="col-lg-1 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <input type="number"  style="width:135px;text-align: right;" class="form-control actmarg" id="actmarg" name="actmarg" value="<?php Echo ($addflag != 1) ? $get["actmarg"] : "0"; ?>" readonly>
                            </div>
                            <div style=""  class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control marg">Tax Amt.</label>
                            </div>
                            <div style=""  class="col-lg-1 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <input type="number"  style="width:135px;text-align: right;" class="form-control taxamt" id="taxamt" name="taxamt" value="<?php Echo ($addflag != 1) ? $get["taxamt"] : "0"; ?>" readonly>
                            </div>
                        </div>
                        <div class="row" style="border: 1px solid gray;">
                            <div style="" class="col-lg-1 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control marg" style="color:blue;">Cust. Bill No.</label>
                            </div>
                            <div style="" class="col-lg-2 col-md-4 col-sm-4 col-xs-4 text-left pad">
                                <input type="text"  style="color:blue;" class="form-control billno" name="billno" value="<?php Echo ($addflag != 1) ? $get["billno"] : ""; ?>"   <?php if ($usertype != 4 && $usertype != 1) { ?> readonly <?php } ?>>
                            </div>
                            <div style=""  class="col-lg-1 col-md-1 col-sm-1 col-xs-1 text-right pad">
                                <label class="label-control marg" style="color:blue;">Bill Date</label>
                            </div>
                            <div style=""  class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <input type="date"  style="color:blue;" class="form-control billdate" name="billdate" value="<?php Echo ($addflag != 1) ? $get["billdate"] : ""; ?>"  <?php if ($usertype != 4 && $usertype != 1) { ?> readonly <?php } ?>>
                            </div>
                            <div style=""  class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right pad">

                            </div>
                            <div  class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control marg">Net Amount</label>
                            </div>
                            <div style=""  class="col-lg-1 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <input type="number"  style="width:135px;text-align: right;" class="form-control netamt" id="netamt"  name="netamt" value="<?php Echo ($addflag != 1) ? $get["netamt"] : "0"; ?>" readonly>
                            </div>
                        </div>
                        <div class="row" style="border: 1px solid gray;">
                            <div style="" class="col-lg-1 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control marg" style="">Lead Remark</label>
                            </div>
                            <div style="" class="col-lg-5 col-md-4 col-sm-4 col-xs-4 text-left pad">
                                <input type="text"  style="" class="form-control leadremk" name="leadremk" value="<?php Echo ($addflag != 1) ? $get["leadremk"] : ""; ?>"   <?php if ($usertype == 4) { ?> readonly <?php } ?>>
                            </div>
                            <div style=""  class="col-lg-1 col-md-1 col-sm-1 col-xs-1 text-right pad">
                                <label class="label-control marg" style="">Account Remark</label>
                            </div>
                            <div style=""  class="col-lg-5 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <input type="text"  style="" class="form-control confremk" name="confremk" value="<?php Echo ($addflag != 1) ? $get["confremk"] : ""; ?>"  <?php if ($usertype != 4 && $usertype != 1) { ?> readonly <?php } ?>>
                            </div>
                        </div>
                    </div>
                    <div style="padding-left: 40%;" class="panel-footer">
                        <input type="submit" name="submit" value="Update" id="update" class="btn btn-success" >
                        <input type="button" name="exit" value="Exit" class="btn btn-danger" onClick="window.location.href = '<?= $grid . "?mode=last" ?>'">
                    </div>
                </div>
            </div>
        </div>
    </form>
<!--    <div class="modal fade" id="formModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">Pdf Upload</h4>
                </div>
                <div class="modal-body" style="">
                    <div class="row">
                        <div class="col-lg-12 upload">
                            <p>To Download Right Click And Click On Save As..</p>
                            <form id="upload_form" enctype="multipart/form-data" method="post">
                                <div class="col-lg-12">
                                    <span class="btn btn-default btn-file btn-square btn-warning">
                                        Choose File <input type="file" name="file1" id="file1">
                                    </span>
                                    <input type="hidden" name="evouchno" id="evouchno" value='<?php Echo ($addflag != 1) ? $get['vouchno'] : "$qvouch"; ?>'>
                                    
                                    <input type="hidden" name="epassno" id="epassno"  value="<?php // Echo $row[passport];                ?>">
                                    <input type="button" value="Upload File" class="btn btn-square" style="background-color: #C0CA33; color: white" id="uploadbtn">
                                    <input type="button" value="Delete File" class="btn btn-square btn-danger" id="deletebtn">
                                    <a href="" class="btn btn-primary btn-square print_image" target="_blank">Print Challan</a>
                                </div>
                                <div class="col-lg-12">
                                    <div class="progress">
                                        <progress id="progressBar" class="progress-bar"  role="progressbar" value="0" max="100" style="width:100%;color: red;"></progress>
                                    </div>
                                    <h3 id="status"></h3>
                                    <p id="loaded_n_total"></p>
                                </div>
                            </form>
                        </div>
                        <div class="col-lg-6 upload">
                            <img id="preview" src="#" alt="your pdf" />
                        </div>
                        <div class="col-lg-12 mview">
                            <a  src="<?php Echo ($addflag != 1) ? $qvouch : ''; ?>" alt="PDF" id="mpreview" />
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>-->
    
<!--Bill Upload-->
<div class="modal fade" id="billModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">Bill Upload & Download</h4>
                </div>
                <div class="modal-body" style="">
                    <div class="row">
                        <div class="col-lg-12 upload">
                            <!--<p>To Download Right Click And Click On Save As..</p>-->
                            <form id="upload_form" enctype="multipart/form-data" method="post">
                                <div class="col-lg-12" >
                                    <span class="btn btn-default btn-file btn-square btn-warning">
                                        Choose File <input type="file" name="file3" id="file3">
                                    </span>
                                    <input type="hidden" name="evouchno" id="evouchno" value='<?php Echo ($addflag != 1) ? $get['vouchno'] : "$qvouch"; ?>'>
                                    <input type="hidden" name="eleadvouch" id="eleadvouch" value='<?php Echo ($addflag != 1) ? $get['eleadvouch'] : ""; ?>'>
                                    <input type="hidden" name="esrno" id="esrno" value='<?php Echo ($addflag != 1) ? $get['esrno'] : ""; ?>'>
                                    <input type="hidden" name="esupplier" id="esupplier" value='<?php Echo ($addflag != 1) ? $get['esupplier'] : ""; ?>'>
                                    <!--<input type="hidden" name="epassno" id="epassno"  value="<?php // Echo $row[passport];                ?>">-->
                                    <input type="button" value="Upload File" class="btn btn-square" style="background-color: #C0CA33; color: white" id="uploadbtn3">
                                    <button class="btn btn-square "><a class="billdown" href="" target="_blank">PDF Download</a></button> 
                                    <!--<input type="button" value="Delete File" class="btn btn-square btn-danger" id="deletebtn">-->
                                    <!--<a href="" class="btn btn-primary btn-square print_image" target="_blank">Print Challan</a>-->
                                </div>
                                <div class="col-lg-12">
                                    <div class="progress">
                                        <progress id="progressBar" class="progress-bar"  role="progressbar" value="0" max="100" style="width:100%;color: red;"></progress>
                                    </div>
                                    <h3 id="status"></h3>
                                    <p id="loaded_n_total"></p>
                                </div>
                            </form>
                        </div>
                        <div class="col-lg-6 upload">
                            <!--<img id="preview" src="#" alt="your pdf" />-->
                            <input type="text"  src="" alt="PDF" id="preview" readonly="readonly" style="border:none;width: 200%;font-size: 25px;color:red;font-weight: bold">
                        </div>
                        <div class="col-lg-12 mview">
                            <!--<a  src="<?php Echo ($addflag != 1) ? $qvouch : ''; ?>" alt="PDF" id="mpreview" />-->
                            <input type="text"  src="" alt="PDF" id="mpreview" readonly="readonly"  style="border:none;width: 200%;font-size: 25px;color:red;font-weight: bold">
                            <!--<a  src="" alt="PDF" id="mpreview" />-->
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
<!--Ledger Upload-->
<div class="modal fade" id="ledgModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">Ledger Upload & Download</h4>
                </div>
                <div class="modal-body" style="">
                    <div class="row">
                        <div class="col-lg-12 upload">
                            <!--<p>To Download Right Click And Click On Save As..</p>-->
                            <form id="upload_form" enctype="multipart/form-data" method="post">
                                <div class="col-lg-12" >
                                    <span class="btn btn-default btn-file btn-square btn-warning">
                                        Choose File <input type="file" name="file4" id="file4">
                                    </span>
                                    <input type="hidden" name="fvouchno" id="fvouchno" value='<?php Echo ($addflag != 1) ? $get['vouchno'] : "$qvouch"; ?>'>
                                    <input type="hidden" name="fleadvouch" id="fleadvouch" value='<?php Echo ($addflag != 1) ? $get['eleadvouch'] : ""; ?>'>
                                    <input type="hidden" name="fsrno" id="fsrno" value='<?php Echo ($addflag != 1) ? $get['esrno'] : ""; ?>'>
                                    <input type="hidden" name="fsupplier" id="fsupplier" value='<?php Echo ($addflag != 1) ? $get['esupplier'] : ""; ?>'>
                                    <!--<input type="hidden" name="epassno" id="epassno"  value="<?php // Echo $row[passport];                ?>">-->
                                    <input type="button" value="Upload File" class="btn btn-square" style="background-color: #C0CA33; color: white" id="uploadbtn4">
                                    <button class="btn btn-square "><a class="ledgdown" href="" target="_blank">PDF Download</a></button> 
                                    <!--<input type="button" value="Delete File" class="btn btn-square btn-danger" id="deletebtn">-->
                                    <!--<a href="" class="btn btn-primary btn-square print_image" target="_blank">Print Challan</a>-->
                                </div>
                                <div class="col-lg-12">
                                    <div class="progress">
                                        <progress id="progressBar1" class="progress-bar"  role="progressbar" value="0" max="100" style="width:100%;color: red;"></progress>
                                    </div>
                                    <!--<input type="text" class="status1" id="status1" readonly style="width: 100%;border: none">-->
                                    <h3 id="status1" class="status1"></h3>
                                    <p id="loaded_n_total"></p>
                                </div>
                            </form>
                        </div>
                        <div class="col-lg-6 upload">
                            <!--<img id="preview" src="#" alt="your pdf" />-->
                            <input type="text"  src="" alt="PDF" id="preview1" readonly="readonly" style="border:none;width: 200%;font-size: 25px;color:red;font-weight: bold">
                        </div>
                        <div class="col-lg-12 mview">
                            <!--<a  src="<?php Echo ($addflag != 1) ? $qvouch : ''; ?>" alt="PDF" id="mpreview" />-->
                            <input type="text"  src="" alt="PDF" id="mpreview1" readonly="readonly"  style="border:none;width: 200%;font-size: 25px;color:red;font-weight: bold">
                            <!--<a  src="" alt="PDF" id="mpreview" />-->
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

<!--zip file-->
    <div class="modal fade" id="zipModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">Zip Upload & Download</h4>
                </div>
                <div class="modal-body">
                    <div class="row">
                        <div class="col-lg-12 upload">
                            <!--<p>To Download Right Click And Click On Save As..</p>-->
                            <form id="upload_form2" enctype="multipart/form-data" method="post">
                                <div class="col-lg-12">
                                    <span class="btn btn-default btn-file btn-square btn-warning">
                                        Choose File <input type="file" name="file2" id="file2">
                                    </span>
                                    <input type="hidden" name="evouchno2" id="evouchno2" value='<?php Echo ($addflag != 1) ? $get['vouchno'] : "$qvouch"; ?>'>
                                    <input type="hidden" name="lastname" id="mlastname">
                                    <input type="hidden" name="name" id="mname" >
                                    <!--<input type="hidden" name="epassno" id="epassno"  value="<?php // Echo $row[passport];                ?>">-->
                                    <input type="button" value="Upload File" class="btn btn-square" style="background-color: #C0CA33; color: white" id="uploadbtn2">
                                    <!--<input type="button" value="Delete File" class="btn btn-square btn-danger" id="deletebtn">-->
                                    <!--<a href="" class="btn btn-primary btn-square print_image" target="_blank">Print Challan</a>-->
                                </div>
                                <div class="col-lg-12">
                                    <div class="progress">
                                        <progress id="progressBar2" class="progress-bar2"  role="progressbar" value="0" max="100" style="width:100%;color: red;"></progress>
                                    </div>
                                    <h3 id="status2"></h3>
                                    <p id="loaded_n_total2"></p>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <?php include("includes/linksfoot.php"); ?>
</body>
</html>
