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

$formname = 'Challan';
$maindb = 'challan';
$cashdb = 'cashrecp';
$accdb = 'actran';

$printfile = "chal_print.php";
$file = 'chalmain.php';
$fileadd = 'leadenq.php';
$trandbexist = 0;
$grid = 'chalmain.php';
$keyfld = "vouchno";
$keycond = " ";
$focusfield = "name";
$source = "CH";

$zyear = $myear = $_SESSION[$myyear];
$zStartDate = getzdates($zyear, 'S');
$zEndDate = getzdates($zyear, 'E');
//$mgrpcode = '009';

$zroot = $_SESSION["zdir"];

$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");

if (isset($_POST["submit"])) {
    mysqli_select_db($conn, $zdb);
    $a = 1;
    $vouchno = $_POST["vouchno"];
    $vouchdt = $_POST["vouchdt"];
    $mark = $_POST["mark"];
    $delv = $_POST["delv"];
    $delvdate = $_POST["delvdate"];
    $partyname = $_POST["partyname"];
//    $party = $_POST["party"];
    $nag = $_POST["nag"];
    $size = $_POST["size"];
    $stype = $_POST["stype"];
    $sizemm = $_POST["sizemm"];
    $guage = $_POST["guage"];
    $gtype = $_POST["gtype"];
    $guagemm = $_POST["guagemm"];
    $makesize = $_POST["makesize"];
    $mktype = $_POST["mktype"];
    $makemm = $_POST["makemm"];
    $dia = $_POST["dia"];
    $ap = $_POST["ap"];
    $weld = $_POST["weld"];
    $straight = $_POST["straight"];
    $foot = $_POST["foot"];
    $totfeet = $_POST["totfeet"];
    $weight = $_POST["weight"];
    $rate = $_POST["rate"];
    $amount = $_POST["amount"];
    $gstflag = $_POST["gstflag"];
    $gstperc = $_POST["gstperc"];
    $hsncode = $_POST["hsncode"];

    $cashcred = $_POST["cashcred"];
    $type = $cashcred;

    $descrip = $_POST["descrip"];
    $cashvouch = $_POST["cashvouch"];
    $netamt = $amount;

    $count = $_POST["items"];
    $mvouch = $qvouch;


    $getp = mysqli_query($conn, "SELECT `accode`, `name` FROM `accmast` where `name` = '$partyname'")or die(mysqli_error($conn));
    $fset = mysqli_fetch_array($getp);

    $party = $fset['accode'];


    if ($delv == "D") {
        if ($delvdate == '0000-00-00' || $delvdate == '') {
            $delvdate = date("Y-m-d");
        }
    }

    if ($type == 'C' || $type == 'c') {
        $salecode = 14;
    } else {
        $salecode = 15;
    }

    $cgst3 = $sgst3 = $totgst3 = $cgst5 = $sgst5 = $totgst5 = $cgst12 = $sgst12 = $totgst12 = $cgst18 = $sgst18 = $totgst18 = $cgst28 = $sgst28 = $totgst28 = 0.00;
    if ($gstflag == 'Y') {
        $gperc = $gstperc / 2;

        if ($gstperc == 3) {
            $cgst3 = ($gperc * $amount ) / 100;
            $totgst3 = $cgst3 * 2;
        }

        if ($gstperc == 5) {
            $cgst5 = ($gperc * $amount ) / 100;
            $totgst5 = $cgst5 * 2;
        }

        if ($gstperc == 12) {
            $cgst12 = ($gperc * $amount ) / 100;
            $totgst12 = $cgst12 * 2;
        }

        if ($gstperc == 18) {
            $cgst18 = ($gperc * $amount ) / 100;
            $totgst18 = $cgst18 * 2;
        }

        if ($gstperc == 28) {
            $cgst28 = ($gperc * $amount ) / 100;
            $totgst28 = $cgst28 * 2;
        }

        $billamt = $totgst3 + $totgst5 + $totgst12 + $totgst18 + $totgst28 + $amount;
    } else {
        $billamt = $amount;
    }

    if ($a == 1) {

        if ($addflag == 2) {

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

        $mvouch = $qvouch;

#############AUto Cash Receipt Start####################
        $mcashamt = $amount;


        $mcashvouch = $_POST["cashvouch"];

        if ($type == 'C' || $type == 'c') {
            if ($mcashvouch == '0' || $mcashvouch == '') {
                $gen1 = mysqli_query($conn, "SELECT MAX(vouchno) AS maxcode FROM `$cashdb`  LIMIT 0,1 ") or die(mysqli_error($conn));
                if (mysqli_num_rows($gen1) > 0) {
                    $vvouch = mysqli_fetch_assoc($gen1);
//                    browse($vvouch["maxcode"]);
                    $mcashvouch = $vvouch["maxcode"] + 1;
                } else {
                    $mcashvouch = '1';
                }
            }

//            browse($mcashvouch);


            $genrecp = mysqli_query($conn, "SELECT * FROM `$cashdb` where `vouchno` = '$mcashvouch'") or die(mysqli_error($conn));
            if (mysqli_num_rows($genrecp) > 0) {
                $fetrecp = mysqli_fetch_array($genrecp);
                $mrecpno = $fetrecp['recpno'];
                $mcashvouch = $fetrecp['vouchno'];
            } else {

                $gen2 = mysqli_query($conn, "SELECT MAX(recpno) AS maxrecp FROM `$cashdb` where bankname = '3'  LIMIT 0,1 ") or die(mysqli_error($conn));
                if (mysqli_num_rows($gen2) > 0) {
                    $gvouch = mysqli_fetch_assoc($gen2);
                    $mrecpno = $gvouch["maxrecp"] + 1;
                } else {
                    $mrecpno = '1';
                }
            }

            $tamt = $billamt;
            $adv = "Cash Received For";

            mysqli_query($conn, "DELETE FROM `$cashdb` WHERE `$keyfld`='$mcashvouch'") or die(mysqli_error($conn));

            $mtype = '';
//            $weight = 0;
            if ($weight == 0) {
                if ($straight == 'Y' || $straight == 'y') {
                    $qty = $totfeet;
                } else {
                    $qty = $nag;
                }
                $mtype = "F";
            } else {
                $qty = $weight;
                $mtype = "W";
            }

//            browse($totfeet);
//            browse($nag);

            mysqli_query($conn, "INSERT INTO `$cashdb`( vouchno ,`vouchdt`, `bankname`, `bankinit`, 
                `recpno`, `party`,`amount`,`remark1`,`remark2`,`trnflag`, `rate`, `type`, `qty`)
                Values ('$mcashvouch', '$vouchdt', '3', 'COH', '$mrecpno','$party','$tamt',
                        '$descrip','Challan No.$mvouch','S', '$rate', '$mtype', '$qty')") or die(mysqli_error($conn));

// cash part     

            $minus_amt = ($tamt * -1);


            $actamt = $tamt;
            $actminus = $tamt * -1;



            mysqli_query($conn, "DELETE FROM `$accdb` WHERE `$keyfld`='$mcashvouch' and `source` = 'CR'") or die(mysqli_error($conn));

            $qrygrp = mysqli_query($conn, "select `grpcode` from accmast where `accode` = '$party'") or die(mysqli_error($conn));
            $fetgrp = mysqli_fetch_array($qrygrp);
            $pgrp = $fetgrp['grpcode'];


            mysqli_query($conn, "INSERT INTO `$accdb`(date, vouchno, recpno, source, trnno, bankinit, accode, grpcode, amount, trnflag, actamt)
                    VALUES ('$vouchdt','$mcashvouch', '$mrecpno', 'CR', '001', 'COH','3','002', '$minus_amt','S', '$actminus')") or die(mysqli_error($conn));


// party part
            mysqli_query($conn, "INSERT INTO `$accdb`(date, vouchno, recpno, source, trnno, bankinit, accode, grpcode, amount, trnflag, actamt)
                    VALUES ('$vouchdt','$mcashvouch', '$mrecpno', 'CR', '002', 'COH', '$party', '$pgrp', '$tamt','S','$actamt')") or die(mysqli_error($conn));
        } else {
            mysqli_query($conn, "DELETE FROM `$cashdb` WHERE `$keyfld`='$mcashvouch'") or die(mysqli_error($conn));
            mysqli_query($conn, "DELETE FROM `$accdb` WHERE `$keyfld`='$mcashvouch' AND `source`='CR'")or die(mysqli_error($conn));
            $mcashvouch = "";
        }






#################################TRAN PART END #################################
############################### Accounts Part ##################################
        mysqli_query($conn, "DELETE FROM `$accdb` WHERE `vouchno` = '$mvouch' AND `source`='$source' ") OR die(mysqli_error($conn));



        if ($amount > 0 && $delvdate != '0000-00-00' && $delvdate != '' && $gstflag == 'N') {

            $minus_amt = $amount * -1;

// sale part
            mysqli_query($conn, "INSERT INTO `$accdb`(date, vouchno, source, trnno, accode, grpcode, amount)
                    VALUES ('$vouchdt','$mvouch', '$source', '001', '$salecode','005', '$amount')") OR die(mysqli_error($conn));
// party part
            mysqli_query($conn, "INSERT INTO `$accdb`(date, vouchno, source, trnno, accode, grpcode, amount)
                     VALUES ('$vouchdt','$mvouch', '$source', '002', '$party', '010', '$minus_amt')") or die(mysqli_error($conn));
        }
############################## MAIN ######################################################
        if ($addflag == 2) {
            mysqli_query($conn, "INSERT INTO `$maindb`(`vouchno`, `vouchdt`, `mark`, `delv`, `delvdate`, `party`, `nag`, `sizemm`,
                        `guagemm`,`makemm`, `dia`,`ap`, `weld`, `straight`, `foot`, `totfeet`, `weight`, `rate`,
                        `amount`, `cashcred`, `descrip`, `cashvouch` , `size`, `stype`, `makesize`, `mktype`, `guage`, `gtype`, `gstflag`, `hsncode`, `gstperc`,
                         `cgst1`, `sgst1`, `totgst1`, `cgst5`, `sgst5`, `totgst5`, `cgst12`, `sgst12`, `totgst12`, 
                         `cgst18`, `sgst18`, `totgst18`, `cgst28`, `sgst28`, `totgst28`, `billamt`)
                 VALUES ('$qvouch', '$vouchdt', '$mark', '$delv', '$delvdate','$party', '$nag', '$sizemm',
                        '$guagemm', '$makemm', '$dia', '$ap', '$weld', '$straight', '$foot', '$totfeet', '$weight', '$rate',
                        '$amount', '$cashcred', '$descrip', '$mcashvouch', '$size', '$stype', '$makesize','$mktype','$guage','$gtype','$gstflag', '$hsncode', '$gstperc',
                        '$cgst3', '$cgst3', '$totgst3', '$cgst5', '$cgst5', '$totgst5', '$cgst12', '$cgst12', '$totgst12', 
                         '$cgst18', '$cgst18', '$totgst18', '$cgst28', '$cgst28', '$totgst28', '$billamt')") or die(mysqli_error($conn));

            insmess();
            $mvouch = $qvouch; //1
            header("refresh: 1; $grid?mode=true&entry=1&vouchdt=$vouchdt&accode=$party");
        } else {
//            browse($qvouch);
            mysqli_query($conn, "UPDATE `$maindb` SET `vouchno`='$qvouch', `vouchdt`='$vouchdt', `mark`='$mark', `delv`='$delv',
            `party`='$party', `delvdate`='$delvdate', `nag`='$nag', `size`='$size', `stype`='$stype',
            `sizemm`='$sizemm', `guagemm`='$guagemm', `makemm`='$makemm', `makesize`='$makesize', `mktype`='$mktype',
            `guage`='$guage', `gtype`='$gtype',
            `dia`='$dia', `ap`='$ap', `weld`='$weld', `straight`='$straight', `foot`='$foot', `totfeet`='$totfeet',
            `weight`='$weight', `rate`='$rate', `amount`='$amount', `cashcred`='$cashcred', `descrip`='$descrip',
            `cashvouch`='$mcashvouch', `gstflag`='$gstflag', `hsncode`='$hsncode', `gstperc`='$gstperc',
            `cgst1`='$cgst3', `sgst1`='$cgst3', `totgst1`='$totgst3', `cgst5`='$cgst5', `sgst5`='$cgst5', `totgst5`='$totgst5',
            `cgst12`='$cgst12', `sgst12`='$cgst12', `totgst12`='$totgst12', `cgst18`='$cgst18', `sgst18`='$cgst18', `totgst18`='$totgst18',
            `cgst28`='$cgst28', `sgst28`='$cgst28', `totgst28`='$totgst28', `billamt`='$billamt' WHERE `vouchno`='$qvouch'") or die(mysqli_error($conn));
            updmess();
            header("refresh: 1;$file?$keyfld=$mvouch&mode=edit&entry=1");
            header("refresh: 1;$grid?mode=last");
        }
    }
}

mysqli_select_db($conn, $zdb);
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);

    $delcsh = $get['cashvouch'];
    $getparty = mysqli_query($conn, "SELECT `accode`, `name` FROM `accmast` where `accode` = '$get[party]'")or die(mysqli_error($conn));
    $fsetparty = mysqli_fetch_array($getparty);

    $getgst = mysqli_query($conn, "SELECT * FROM `saletype` WHERE code = '$get[gstperc]'") or die(mysqli_error($conn));
    $fetgst = mysqli_fetch_array($getgst);
}

//include("includes/vouchno_generate.php");
//include("includes/prev&next.php");
if (isset($_GET["delete"])) {
    delete($zdb, "$maindb", "$keyfld", $_GET[$keyfld], "$grid?mode=last");

    $delcond2 = " source='CR' and vouchno='$delcsh' ";
    $delcond1 = " source='CH' and vouchno='$_GET[vouchno]' ";
    delnew($zdb, "$accdb", "$delcond1", "$grid?mode=last");
    delnew($zdb, "$accdb", "$delcond2", "$grid?mode=last");
    delete($zdb, "$cashdb", "$keyfld", $delcsh, "$grid?mode=last");
}

$entry = $_GET['entry'];
$entrystyle = $srchstyle = "";
if ($entry == 1) {
    $entrystyle = "";
    $srchstyle = "display: none;";
} else {
    $entrystyle = "display: none;";
    $srchstyle = "";
}

$accode = $_GET['accode'];
$partyname = "";
if ($accode != '') {
    $partyaccode = $accode;
    $getpname = mysqli_query($conn, "select name from accmast where accode='$partyaccode'") or die(mysqli_error($conn));
    $pname = mysqli_fetch_array($getpname);
    $partyname = $pname['name'];
}

$vouchdt = $_GET['vouchdt'];
if ($vouchdt != '') {
    $mvouchdt = $vouchdt;
} else {
    $mvouchdt = date("Y-m-d");
}
include("includes/linkshead.php");
?>
<!--<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.20/css/jquery.dataTables.css">
            <script type = "text/javascript" charset = "utf8" src = "https://cdn.datatables.net/1.10.20/js/jquery.dataTables.js"></script>-->

<script src="MyScript/checkdate.js" type="text/javascript"></script>
<script src="MyScript/chalmain.js" type="text/javascript"></script>
<script src="MyScript/chalmain_search.js" type="text/javascript"></script>
<script src="MyScript/challanfunctn.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).keydown(function (event) {
        if (!(String.fromCharCode(event.which).toLowerCase() == 'a' && event.altKey) && !(event.which == 19))
            return true;
        $("#addnew").click();
        event.preventDefault();
        return false;
    });

    $(document).keydown(function (event) {
        //19 for Mac Command+S
        if (!(String.fromCharCode(event.which).toLowerCase() == 's' && event.altKey) && !(event.which == 19))
            return true;
        //alert("Ctrl-s pressed");
        $("#update").click();
        event.preventDefault();
        return false;
    });

    $(document).keydown(function (event) {
        //19 for Mac Command+S
        if (!(String.fromCharCode(event.which).toLowerCase() == 'f' && event.altKey) && !(event.which == 19))
            return true;
        //alert("Ctrl-s pressed");
        $("#btsearch").click();
        event.preventDefault();
        return false;
    });
</script>

<style>
    .modal-sm > .modal-content{
        margin-top: 40%;
    }

    .parfont{
        font-size: 11px;
    }

    .prevrecbody > td{
        font-size: 11px;

    }

    select:focus, input:focus {
        border: 2px solid #ff0066 !important;
    }

    .button {
        padding: 15px 25px;
        font-size: 15px;
        text-align: center;
        cursor: pointer;
        outline: none;
        color: #fff;
        background-color: #4CAF50;
        border: none;
        border-radius: 15px;
        box-shadow: 0 9px #999;
    }

    .button:hover {background-color: #3e8e41}

    .button:active {
        background-color: #3e8e41;
        box-shadow: 0 5px #666;
        transform: translateY(4px);
    }
    /* Sortable tables */
    table.sortable thead {
        /*background-color:#eee;*/
        /*color:#666666;*/
        font-weight: bold;
        cursor: default;
    }
    .table>tbody>tr>td {
        padding: 1px;
    }
    .form-control{
        padding: 0px 0px; 
    }
    body{
        font-size: 12px;
    }
    table td{
        font-size:13px;
    }

    .partynametd{
        font-size:11px;
    }

    .gstperctd{
        text-align: right !important;
    }


    .f12{
        font-size:12px ;
    }

    input::selection{
        background: black;
        color: white;
    }

    #PTbody{overflow-y: scroll;}

    input[type='checkbox']{
        zoom: 0.5;
    }
    
    .challan-table thead th{
        background: cyan;
        font-weight: 600;
        color: black;
    }
    
    .challan-table tbody tr td{
        font-weight: 800;
    }
    .challan-table tbody tr{
        border: 2px solid black;
    }
         
    /* .challan-table tbody tr:nth-child(odd){
        background-color: lightyellow;
    } */
/* 
    <!-- HTML !-->
<button class="button-27" role="button">Button 27</button> */

/* CSS */
.button-27 {
  appearance: none;
  /* background-color: #000000; */
  /* border: 2px solid #1A1A1A; */
  border-radius: 15px;
  box-sizing: border-box;
  color: #FFFFFF;
  cursor: pointer;
  display: inline-block;
  font-family: Roobert,-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";
  font-size: 16px;
  font-weight: 600;
  line-height: normal;
  margin: 0;
  min-height: 10px;
  min-width: 0;
  outline: none;
  padding: 8px 15px;
  text-align: center;
  text-decoration: none;
  transition: all 300ms cubic-bezier(.23, 1, 0.32, 1);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  width: 100%;
  will-change: transform;
}

.button-27:disabled {
  pointer-events: none;
}

.button-27:hover {
  box-shadow: rgba(0, 0, 0, 0.25) 0 8px 15px;
  transform: translateY(-2px);
}

.button-27:active {
  box-shadow: none;
  transform: translateY(0);
}
</style>

</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' id="chalform" name="chalform"  enctype="multipart/form-data">
        <!-- Default box -->
        <div class="panel panel-default">
            <div class="panel-heading">
                <h4 class="panel-title" style="color:inherit"><span style="color: #77BCFF;font-weight: 600;"><?php Echo $formname; ?></span>
                    <span class="chalcount" style="color: red"></span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <span>(ALT+P) - Print &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        (ALT+Q) - Query &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        (ALT+D) - Dia Print &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
                    <span class="entextlbl" style="display: none">(ALT+S) - Save Entry &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        (ALT+X) - Exit Entry &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
                </h4>
                <div class="actions pull-right">
                    <i class="fa fa-chevron-down"></i>
                    <i class="fa fa-times"></i>
                </div>
            </div>

            <div class="row ndata" style="<?= $entrystyle; ?>" >
                <div class="row">
                    <div class="col-lg-12 table responsive " style="height: 60px;padding-left: 3px;padding-right: 3px;margin-bottom: 0px">
                        <table class="table table-striped  table-bordered" style="font-size: 11px;padding:0px;">
                            <thead>
                                <tr class="mySearchTr" style="background-color: #009552;">
                                    <th style="width: 2%;">Sr</th>
                                    <th style="width: 2%;">?</th>
                                    <th style="width: 3%;">Date</th>
                                    <th style="width: 3%;">P/R/D</th>
                                    <th style="width: 4%;">Delv.Date</th>
                                    <th style="width:20%;">Party Name</th>
                                    <th style="width: 4%;"class='text-right'>Nags</th>
                                    <th style="width: 5%;" class='text-right'>Size(MM)</th>
                                    <th style="width: 5%;" class='text-right'>T(MM)</th>
                                    <th style="width: 5%;" class='text-right'>Make(MM)</th>
                                    <th style="width: 3%;">Dia</th>
                                    <th style="width: 3%">A/P</th>
                                    <th style="width: 3%">Wld</th>
                                    <th style="width: 3%">STRT</th>
                                    <th style="width: 4%" class='text-right'>FTS</th>
                                    <th style="width: 4%" class='text-right'>T.FTS</th>
                                    <th style="width: 4%" class='text-right'>Weight</th>
                                    <th style="width: 5%" class='text-right'>Rate</th>
                                    <th style="width: 6%" class='text-right'>Amount</th>
                                    <th style="width: 10%">Description</th>
                                    <th style="width: 4%">C/R</th>
                                    <th style="width: 4%">GST</th>
                                    <th style="display: none;width: 10%;" class="tblhsncode">Hsncode</th>
                                    <th style="display: none;width: 4%;" class="tblgstperc">GST%</th>
                                    <!--<th style="display: none;width: 10%;" class="tblbillamt">Bill Amount</th>-->
                                </tr>
                            </thead>

                            <tbody class="nTbody">                                
                                <tr class='' style='font-size: 11px;padding:0px !important;' > 
    <!--                                <td align='left'>
                                        <input type="text" class="form-control text-size vouchno" name="vouchno" value="" required readonly>
                                    </td> -->
                                    <td align='left'>
                                        <input type="text" class="form-control text-size srno f12" name="srno" value="1">
                                    </td>
                                    <td align='left'>
                                        <input type="text" class="form-control text-size mark f12" name="mark" value="" maxlength="1">
                                    </td>
                                    <td align='left'>
                                        <input type="date" style="" class="form-control vouchdt f12"  name="vouchdt" value="<?php Echo ($addflag == 0) ? $get["vouchdt"] : $mvouchdt; ?>" required>
                                    </td> 
                                    <td align='left'>
                                        <input type="text" class="form-control text-size f12 delv" maxlength="1" name="delv" value="<?php Echo ($addflag == 0) ? $get["delv"] : ""; ?>" >                                
                                    </td> 
                                    <td align='left'>
                                        <input type="date" class="form-control delvdate f12"  name="delvdate" value="<?php Echo ($addflag == 0) ? $get["delvdate"] : '0000-00-00' ?>" >
                                    </td>
                                    <td align='left'>

                                        <input type="text" name="partyname" class="srchparty party partyname  form-control parfont" autocomplete="off" value="<?php echo ($addflag == 0) ? $fsetparty['name'] : '' ?>">
                                        <div class="table-responsive PartySrchTbl" style="max-height: 150px;overflow: auto;">
                                            <table width="100%" >
                                                <tbody class="PTbody">
                                                    <?php
                                                    $getparty = mysqli_query($conn, "SELECT `accode`, `name` FROM `accmast` WHERE `grpcode`='010' order by name asc")or die(mysqli_error($conn));
                                                    while ($fparty = mysqli_fetch_array($getparty)) {

                                                        Echo "<tr class='bordcolr' >";
                                                        Echo "<td><input type='text' name='disblsrchparty' class='form-control disblsrchparty parfont' value='$fparty[name]' readonly></td>";
                                                        Echo "</tr>";
                                                        $ctr++;
                                                    }
                                                    ?>
                                                </tbody>
                                            </table>
                                        </div>
                                        <!--                                        
                                                                                <input type="text" class="form-control text-size f12 partyname" name="partyname" value="<?php Echo ($addflag == 0) ? $fsetparty["name"] : $partyname; ?>" required>
                                                                                <input type="hidden" class="form-control text-size f12 party" name="party" value="<?php Echo ($addflag == 0) ? $fsetparty["accode"] : $partyaccode; ?>" required>-->
                                                                                <!--<select class="form-control party f12 select2" name="party" style="width:100%;" required>-->
                                                                                    <!--<option value="<?php Echo ($addflag != 1) ? $fsetparty['accode'] : ""; ?>"><?php Echo ($addflag != 1) ? $fsetparty['name'] : ""; ?></option>-->
                                        <?php
//                                            if ($addflag == 1) {
//                                            $gparty = mysqli_query($conn,"SELECT `accode`,`name` FROM `accmast` where grpcode='010' order by name asc")or die(mysqli_error($conn));
//                                            while ($fparty = mysqli_fetch_array($gparty)) {
//                                                Echo "<option value='$fparty[accode]'>$fparty[name]</option>";
//                                            }
//                                            }
                                        ?>
                                        <!--</select>-->
                                    </td> 
                                    <td align='left' class="text-right">
                                        <input type="text" class="form-control text-right text-size nag number f12" name="nag" value="<?php Echo ($addflag == 0) ? $get["nag"] : ""; ?>" required>
                                    </td> 
                                    <td align='left' class="text-right">
                                        <input type="text" class="form-control text-size sizemm text-right f12" name="sizemm" value="<?php Echo ($addflag == 0) ? $get["sizemm"] : ""; ?>" required>
                                    </td> 
                                    <td align='left' class="text-right">
                                        <input type="text" class="form-control guagemm text-right f12"  name="guagemm" value="<?php Echo ($addflag == 0) ? $get["guagemm"] : ""; ?>" >
                                    </td> 
                                    <td align='left' class="text-right">
                                        <input type="text" class="form-control text-size makemm text-right f12" name="makemm" value="<?php Echo ($addflag == 0) ? $get["makemm"] : ""; ?>" >
                                    </td> 
                                    <td align='left'>
                                        <input type="text" class="form-control text-size dia number f12" name="dia" value="<?php Echo ($addflag == 0) ? $get["dia"] : ""; ?>" >                                

                                    </td> 
                                    <td align='left'>
                                        <input type="text" class="form-control text-size ap f12" maxlength="1"  name="ap" value="<?php Echo ($addflag == 0) ? $get["ap"] : "N"; ?>" >                               

                                    </td> 
                                    <td align='left'>
                                        <input type="text" class="form-control text-size weld f12" maxlength="1"  name="weld" value="<?php Echo ($addflag == 0) ? $get["weld"] : "N"; ?>" >                                

                                    </td> 
                                    <td align='left'>
                                        <input type="text" class="form-control straight f12" maxlength="1"  name="straight" value="<?php Echo ($addflag == 0) ? $get["straight"] : "N"; ?>" >

                                    </td> 
                                    <td align='left' class="text-right">
                                        <input type="text" class="form-control text-size foot text-right f12" name="foot" value="<?php Echo ($addflag == 0) ? $get["foot"] : ""; ?>" >                                

                                    </td> 
                                    <td align='left' class="text-right">
                                        <input type="text" class="form-control text-size totfeet text-right f12" name="totfeet" value="<?php Echo ($addflag == 0) ? $get["totfeet"] : ""; ?>" >                                

                                    </td> 
                                    <td align='left' class="text-right">
                                        <input type="text" class="form-control text-size weight text-right f12" id="weight" name="weight" value="<?php Echo ($addflag == 0) ? $get["weight"] : 0; ?>" >                               

                                    </td> 
                                    <td align='left' class="text-right">
                                        <input type="text" class="form-control text-size rate text-right f12" name="rate" value="<?php Echo ($addflag == 0) ? $get["rate"] : 0; ?>" required>                                

                                    </td> 
                                    <td align='left' class="text-right">
                                        <input type="text" class="form-control amount text-right f12"  name="amount" value="<?php Echo ($addflag == 0) ? $get["amount"] : 0; ?>"  required>
                                    </td>
                                    <td align='left'>
                                        <input type="text" class="form-control text-size descrip f12" name="descrip" value="<?php Echo ($addflag == 0) ? $get["descrip"] : ""; ?>" >
                                    </td> 
                                    <td align='left'>
                                        <input type="text" class="form-control text-size cashcred f12" name="cashcred" value="<?php Echo ($addflag == 0) ? $get["cashcred"] : ""; ?>" >                                
                                    </td>
                                    <td><input type="text" class="form-control text-size gstflag f12" maxlength="1" name="gstflag" value="<?php Echo ($addflag == 0) ? $get["gstflag"] : "N"; ?>" required></td>
                                    <td style="display: none;" class="tblhsncode">
                                        <input type="text" class="form-control text-size hsncode f12" name="hsncode" value="<?php Echo ($addflag == 0) ? $get["hsncode"] : ""; ?>" >                                
                                    </td> 

                                    <td style="display: none;" class="tblgstperc">
                                        <select name="gstperc" class="form-control select2">
                                            <option value="<?php Echo ($addflag != 1) ? $fetgst["code"] : ""; ?>"><?php Echo ($addflag != 1) ? $fetgst["name"] : ""; ?></option>
                                            <?php
                                            $getgst = mysqli_query($conn, "SELECT * FROM `saletype` where `code`!='' ORDER BY per")or die(mysqli_error($conn));
                                            while ($fetgst = mysqli_fetch_array($getgst)) {
                                                Echo "<option value='$fetgst[per]'>$fetgst[name]</option>";
                                            }
                                            ?>
                                        </select>
                                    </td>

<!--                                    <td style="display: none;" class="tblbillamt">
                                        <input type="text" class="form-control text-size billamt f12" name="billamt" value="<?php Echo ($addflag == 0) ? $get["billamt"] : ""; ?>" >
                                    </td>-->
                            <input type="hidden" class="form-control text-size cashvouch f12" name="cashvouch" value="<?php Echo ($addflag == 0) ? $get["cashvouch"] : "0"; ?>" >   
                            <input type="date" value="<?= $zStartDate ?>" style="width: 1px;border: none" class="zstdate">
                            <input type="date" value="<?= $zEndDate ?>" style="width: 1px;border: none" class="zenddate">                            
                            </tr>
                            </tbody>  
                        </table>
                    </div>
                </div>
                <div class="row">
                    <div class="panel-footer">
                        <div style="overflow: auto; padding-top: 3%">
                            <table class="table-condensed" style="margin: 0 auto;">
                                <tr>

                                    <td class=" buttonform tooltip-bottom" id="ssubmit" style="" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="Save Record">
                                        <button id='submit' type='submit' name='submit' value='<?php echo ($addflag == 0) ? "Update" : "Save"; ?>' class="btn btn-pad btn-square " style="background-color:#008D4C;display: inline; ">
                                            <i class="fa fa-check" style="color:#ffffff"></i>
                                        </button>
                                    </td>
                                    <td class=" buttonform tooltip-bottom" id="scancel" style="" 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:red; "  onClick="window.location.href = 'chalmain.php?mode=last'">
                                            <i class="fa fa-times" style="color:#ffffff"></i>
                                        </button>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row tohide" style="<?= $srchstyle; ?>">
                <!--<div class="col-lg-1"></div>-->
                <div class="col-lg-2 " style="padding-left: 2%">
                <!--<input id='addnew' value="Add New Challan" type="button"  class="btn btn-success mySearchTr" style="" onclick="window.location.href = '<?= $file . "?mode=true" ?>'" class="btn btn-labeled btn-success">-->
                    <input id='addnew' value="Add New Challan" type="button"  class="  button-27" style="color: #009552;border: 1px solid #009552;background:transparent">

                </div>
                <div class="col-lg-1">
                    <!--<input id='addnew' value="Add New Challan" type="button"  class="btn btn-success mySearchTr" style="" onclick="window.location.href = '<?= $file . "?mode=true" ?>'" class="btn btn-labeled btn-success">-->
                    <!--<a href="menu.php?action=chal_print" class="btn btn-info" role="button">Print</a>-->
                    <a id='' type="button" class="button-27" style="color: #3498db;border: 1px solid #3498db;" href="<?= $printfile ?>" target="_blank">PRINT</a>
                </div>
                <div class="col-lg-1">
                    <button type="button" class="button-27"  style='color: #8C6556; border: 1px solid #8C6556;background:transparent' data-toggle="modal" data-target="#exampleModalCenter">QUERY</button>
                </div>
                <div class="col-lg-1">
                    <a id='diaprint' type="button" class=" button-27" style='color: #40255B;border: 1px solid #40255B;background:transparent'  href="dia_print.php" target="_blank">D I A</a>
                </div>
            </div>
        </div>
        <div class="modal fade" id="sizemmod" role="dialog">
            <div class="modal-dialog modal-sm">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title">Size</h4>
                    </div>
                    <div class="modal-body">
                        <table class="table" width="100%">
                            <thead>
                                <tr>
                                    <td style="width: 50%;"><input type="text" class="form-control text-size sval" name="size" value=""></td>
                                    <td style="width: 50%;"><select class="form-control soval" name="stype" value="">                         
                                            <option value=""></option>
                                            <option value="1">OD</option>
                                            <option value="2">NB</option>
                                            <option value="3">MM</option>
                                        </select>
                                    </td>
                                </tr>
                            </thead>
                        </table>
                    </div>
                </div>
            </div>
        </div>
        <div class="modal fade" id="guagemmod" role="dialog">
            <div class="modal-dialog modal-sm">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title">T(MM)</h4>
                    </div>                
                    <div class="modal-body">
                        <table class="table" width="100%">
                            <thead>
                                <tr>
                                    <td style="width: 50%;"><input type="text" class="form-control text-size gval" name="guage"></td>
                                    <td style="width: 50%;">
                                        <select class="form-control goval" name="gtype">
                                            <option value=""></option>
                                            <option value="1">NR</option>
                                            <option value="2">SH</option>
                                            <option value="3">MM</option>
                                        </select>
                                    </td>
                                </tr>
                            </thead>
                        </table>
                    </div>
                </div>      
            </div>
        </div>
        <div class="modal fade" id="makemmod" role="dialog">
            <div class="modal-dialog modal-sm">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title">Make</h4>
                    </div>                
                    <div class="modal-body">
                        <table class="table" width="100%">
                            <thead>
                                <tr>
                                    <td style="width: 50%;"><input type="text" class="form-control text-size mval" name="makesize" value=""></td>
                                    <td style="width: 50%;">
                                        <select class="form-control moval" name="mktype">                         
                                            <option value=""></option>
                                            <option value="1">OD</option>
                                            <option value="2">NB</option>
                                            <option value="3">MM</option>
                                        </select>
                                    </td>
                                </tr>
                            </thead>
                        </table>
                    </div>
                </div>                
            </div>
        </div>

        <!--        <div class="modal fade" id="getpartydata" role="dialog">
                    <div class="modal-dialog modal-sm" style="width: 25%;">
                        <div class="modal-content">
                            <div class="modal-header">
                                <h4 class="modal-title">Party</h4>
                            </div>
                            <div class="modal-body">
                                <input type="text" name="srchparty" class="srchparty form-control"><br><br>
                                <div class="table-responsive PartySrchTbl" style="max-height: 350px;overflow: auto;">
                                    <table width="100%" >
                                        <tbody class="PTbody">
        <?php
//                                    $getparty = mysqli_query($conn, "SELECT `accode`, `name` FROM `accmast` WHERE `grpcode`='010' order by name asc")or die(mysqli_error($conn));
//                                    while ($fparty = mysqli_fetch_array($getparty)) {
//
//                                        Echo "<tr>";
//                                        Echo "<td><input type='text' name='disblsrchparty' class='form-control disblsrchparty' value='$fparty[name]' readonly></td>";
//                                        Echo "</tr>";
//                                        $ctr++;
//                                    }
        ?>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>                
                    </div>
                </div>-->
    </form>

    <form action="chaluploadimg.php" method="post"  enctype="multipart/form-data" style="<?= $srchstyle; ?>">
        <div class="panel-body tohide" >
            <div class="row">
                <div class="col-lg-12">
                    <input type="hidden" class="vouchno" value="<?php echo $getvouch; ?>">
                    <input type="hidden" class="series" value="<?php echo $bseries; ?>">
                    <input type="hidden" class="type" value="<?php echo $invoicingtype; ?>">
                    <div class="col-lg-2" style="padding-left:0px;">
                        <select class="form-control sfield">                         
                            <option value="1">Date</option>
                            <option value="2">P/R/D</option>
                            <option value="3">Delv.Date</option>
                            <option value="4" selected="">Party</option>                             
                            <option value="5">Nag</option>                             
                            <option value="6">Size(MM)</option>                             
                            <option value="7">T(MM)</option>                             
                            <option value="8">Make(MM)</option>                             
                            <option value="9">Dia</option>                             
                            <option value="10">A/P</option>                             
                            <option value="11">Wld</option>                             
                            <option value="12">STRT</option>                             
                            <option value="13">FTS</option>                             
                            <option value="14">T.FTS</option>                             
                            <option value="15">Weight</option>                             
                            <option value="16">Rate</option>                             
                            <option value="17">Amount</option>                             
                        </select>
                    </div>
                    <div class="col-lg-1">
                        <select class="form-control soperator">
                            <option value="">Type of Search</option>
                            <option value="%">Like</option>
                            <option value="=">Exactly</option>
                        </select>
                    </div>
                    <div class="col-lg-2">
                        <select class="form-control sortBy">
                            <option value="">Sort By</option>
                            <option value="1">Date</option>
                            <option value="2">P/R/D</option>
                            <option value="3">Delv.Date</option>
                            <option value="4">Party</option>                             
                            <option value="5">Nag</option>                             
                            <option value="6">Size(MM)</option>                             
                            <option value="7">T(MM)</option>                             
                            <option value="8">Make(MM)</option>                             
                            <option value="9">Dia</option>                             
                            <option value="10">A/P</option>                             
                            <option value="11">Wld</option>                             
                            <option value="12">STRT</option>                             
                            <option value="13">FTS</option>                             
                            <option value="14">T.FTS</option>                             
                            <option value="15">Weight</option>                             
                            <option value="16">Rate</option>                             
                            <option value="17">Amount</option>    
                        </select> 
                    </div>
                    <div class="col-lg-1">
                        <select class="form-control orderAs">
                            <option value="desc">Desc</option>
                            <option value="asc" selected="">Asc</option>
                        </select>
                    </div>
                    <div class="col-lg-2" style="padding-left:0px;">
                        <select class="form-control sdelv">                         
                            <option value="1">All</option>
                            <option value="2" selected="">Not Delivered</option>
                            <option value="3">Delivered</option>                                
                        </select>
                    </div>
                    <div class="col-lg-2">
                        <input type="text" value="" class="form-control ssearch" placeholder="Search Here" autofocus>
                    </div>
                    <div class="col-lg-1">
                        <input type="button" class="btn btn-primary sload" value="Search" >
                    </div>
                    <div class="col-lg-12 sloader text-center">
                    </div>
                    <div class="col-lg-12 snoRecord text-center">
                        <h3>NO RECORDS FOUND</h3>
                    </div>

                </div>
            </div>

            <div class="col-lg-11 table responsive ssload" style="overflow-y: scroll;height: 350px;">
                <table class="table table-striped table-bordered challan-table" width="100%" style="font-size: 14px;padding:0px;">
                    <thead>

                        <tr >
                            <th style="width:2%;"></th>
                            <th style="width:2%;">Sr</th>
                            <th style="width:2%;">?</th>
                            <th style="width:6%;">Date</th>
                            <th style="width:2%;">P/R/D</th>
                            <th style="width:6%;">Delv.Date</th>
                            <th style="width:13%;">Party Name</th>
                            <th style="width:2%;">Nags</th>
                            <th style="width:4%;">Size(MM)</th>
                            <th style="width:4%;">T(MM)</th>
                            <th style="width:3%;">Make(MM)</th>
                            <th style="width:2%;">Dia</th>
                            <th style="width: 2%">A/P</th>
                            <th style="width: 3%">Wld</th>
                            <th style="width: 3%">STRT</th>
                            <th style="width: 3%">FTS</th>
                            <th style="width: 4%">T.FTS</th>
                            <th style="width: 4%">Weight</th>
                            <th style="text-align:right;width: 5%">Rate</th>
                            <th style="text-align:right;width: 5%">Amount</th>
                            <th style="width: 10%">Description</th>
                            <th style="width: 2%">C/R</th>
                            <th style="width: 4%">Voucher</th>
                            <th style="width: 2%">GST%</th>
                            <?php
                            if ($usertype == 1) {
                                echo "<th align='center'  style='width:2%;'>Action</th>";
                            }
                            ?>
                            <!--<th style="width: 2%">Copy</th>-->
                            <th align="center"  style="width:2%;">Label</th>
                            <th align="center"  style="width:2%;">Copy</th>
                        </tr>
                    </thead>
                    <tbody class="sTbody">

                    </tbody>  
                </table>
            </div>
            <!--<br>-->
            <div class="row">
                <div class="col-xs-11 text-right search-action-bar">
                    <input type="button"  class="btn btn-primary sprev" value="Previous">
                    <input type="button"  class="btn btn-primary snext" value="Next">
                </div>
            </div>
            <div class="row">
                <div  style="background: #64CCFC">
                    <div class="col-xs-2 text-right">
                        <label class="label-control" style="font-size: 18px;">Image Upload (500KB)</label>
                    </div>
                    <div class="col-xs-2">
                        <input type="file" class="form-control btn btn-primary" name="image1" id="image" >
                    </div>
                    <div class="col-xs-1">
                        <input type="submit" class="form-control btn btn-warning" name="imgsubmit" required>
                    </div>
                    <div class="col-xs-2" style="display: none;">
                        <select name="imgdata[]" class="form-control imgdata" multiple>
                            <?php
                            $result1 = mysqli_query($conn, "SELECT vouchno FROM `$maindb` where `vouchno`!='' ") or die(mysqli_error($conn));
                            while ($getres = mysqli_fetch_array($result1)) {
                                echo "<option value='$getres[vouchno]'>$getres[vouchno]</option>";
                            }
                            ?>
                        </select>                     
                    </div>
                </div>
            </div>
        </div>
    </form>

    <div class="modal fade" id="prate" role="dialog">
        <div class="modal-dialog modal-lg" style="padding-top:20%;" >
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" style="font-size: 45px;color:red; opacity: 0">&times;</button>
                    <h4 class="modal-title">Previous Rates / Work Done</h4>

                </div>                
                <div class="modal-body">
                    <table class="table table-striped  table-bordered" width="100%" style="font-size: 11px;padding:0px;">
                        <thead>
                            <tr class="mySearchTr" style="background-color: #009552;">
                                <!--<th style="width:2%;">Voucher</th>-->
                                <th style="width:2%;">?</th>
                                <th style="width:7%;">Date</th>
                                <th style="width:3%;">P/R/D</th>
                                <th style="width:7%;">Delv.Date</th>
                                <th style="width:13%;">Party Name</th>
                                <th style="width:2%;"class='text-right'>Nags</th>
                                <th style="width:4%;" class='text-right'>Size(MM)</th>
                                <th style="width:4%;" class='text-right'>T(MM)</th>
                                <th style="width:3%;" class='text-right'>Make(MM)</th>
                                <th style="width:2%;">Dia</th>
                                <th style="width: 2%">A/P</th>
                                <th style="width: 3%">Wld</th>
                                <th style="width: 3%">STRT</th>
                                <th style="width: 3%" class='text-right'>FTS</th>
                                <th style="width: 4%" class='text-right'>T.FTS</th>
                                <th style="width: 4%" class='text-right'>Weight</th>
                                <th style="text-align:right;width: 6%" class='text-right'>Rate</th>
                                <th style="text-align:right;width: 6%" class='text-right'>Amount</th>
                                <th style="width: 10%">Description</th>
                                <th style="width: 2%">C/R</th>
    <!--                                <th style="width: 6%">Cashvouch</th>-->
                                <!--<th align="center"  style="width:2%;">Action</th>-->
                            </tr>
                        </thead>
                        <tbody class="prTbody">
                        </tbody>
                    </table>
                </div>                
            </div>
        </div>
    </div>

    <div class="col-lg-12 table responsive todaydata" style="<?= $entrystyle; ?>;overflow-y: scroll;height: 350px; padding-top: 10%">
        <table class="table table-striped  table-bordered" width="100%" style="font-size: 11px;padding:0px;">
            <thead>
                <tr class="mySearchTr">
                    <th style="width: 2%;">Sr</th>
                    <th style="width: 2%;">?</th>
                    <th style="width: 8%;">Date</th>
                    <th style="width: 4%;">P/R/D</th>
                    <th style="width: 9%;">Delv.Date</th>
                    <th style="width:16%;">Party Name</th>
                    <th style="width: 4%;" class="text-right">Nags</th>
                    <th style="width: 5%;" class="text-right">Size(MM)</th>
                    <th style="width: 5%;" class="text-right">T(MM)</th>
                    <th style="width: 5%;" class="text-right">Make(MM)</th>
                    <th style="width: 3%;">Dia</th>
                    <th style="width: 3%">A/P</th>
                    <th style="width: 3%">Wld</th>
                    <th style="width: 2%">STRT</th>
                    <th style="width: 3%" class="text-right">FTS</th>
                    <th style="width: 3%" class="text-right">T.FTS</th>
                    <th style="width: 6%" class="text-right">Weight</th>
                    <th style="width: 4%" class="text-right">Rate</th>
                    <th style="width: 6%" class="text-right">Amount</th>
                    <th style="width: 10%">Description</th>
                    <th style="width: 4%">C/R</th>
                    <!--<th style="width: 4%"></th>-->
                    <!--<th style="width: 4%">GST</th>-->
                    <!--<th style="display: none;width: 10%;" class="tblhsncode">Hsncode</th>-->
                    <th class="tblgstperc">GST%</th>
                    <!--<th style="display: none;width: 10%;" class="tblbillamt">Bill Amount</th>-->
                </tr>
            </thead>
            <tbody class="prevrecbody">
                <?php
                $query = "SELECT a.*, DATE_FORMAT(a.`vouchdt`,'%d-%m-%Y') as vouchdt, b.name  FROM `$maindb` a , accmast b
                         where a.party = b.accode  and a.`vouchno`!='' and vouchdt =CURDATE()";
                $result = mysqli_query($conn, $query) or die(mysqli_error($conn));

                while ($r = mysqli_fetch_assoc($result)) {

                    if ($r['cashcred'] == 'C') {
                        $cashcred = 'Cash';
                    } else {
                        $cashcred = 'Credit';
                    }

                    echo "<tr style='font-size: 11px;
                                    padding:0px;
                                    '>" .
                    "<td align='left'></td>" .
                    "<td align='left'>" . $r[mark] . "</td>" .
                    "<td align='left'>" . $r[vouchdt] . "</td>" .
                    "<td align='left'>" . $r[delv] . "</td>" .
                    "<td align='left'>" . $r[delvdate] . "</td>" .
                    "<td align='left' class='partynametd'>" . $r[name] . "</td>" .
                    "<td align='left' class='text-right'>" . $r[nag] . "</td>" .
                    "<td align='left' class='text-right'>" . $r[sizemm] . "</td>" .
                    "<td align='left' class='text-right'>" . $r[guagemm] . "</td>" .
                    "<td align='left' class='text-right'>" . $r[makemm] . "</td>" .
                    "<td align='left'>" . $r[dia] . "</td>" .
                    "<td align='left'>" . $r[ap] . "</td>" .
                    "<td align='left'>" . $r[weld] . "</td>" .
                    "<td align='left'>" . $r[straight] . "</td>" .
                    "<td align='left' class='text-right'>" . $r[foot] . "</td>" .
                    "<td align='left' class='text-right'>" . $r[totfeet] . "</td>" .
                    "<td align='left' class='text-right'>" . $r[weight] . "</td>" .
                    "<td align='left' class='text-right'>" . $r[rate] . "</td>" .
                    "<td align='left' class='text-right'>" . $r[amount] . "</td>" .
                    "<td align='left'>" . $r[descrip] . "</td>" .
                    "<td align='left'>" . $r[cashcred] . "</td>" .
//                    "<td align='left'>" . $r[cashvouch] . "</td>" .
                    "<td align='left' class='gstperctd'>" . $r[gstperc] . "</td>" .
                    "</tr>";
                }
                ?>

            </tbody>  
        </table>
    </div>

    <form action="chal_print_fr2.php" method="POST" target="_blank">

        <div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
            <div class="modal-dialog modal-dialog-centered" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title" id="exampleModalLongTitle">QUERY</h5>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>
                    <div class="modal-body">
                        <div class="row">
                            <div class="col-lg-1 col-md-3">

                            </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">Party Name</label>
                                </div>
                                <div class="col-lg-6" >
                                    <select class="form-control select2 partymod" name="partymod" style="width:100%">
                                        <option value=""></option>
                                        <?php
                                        $getexp = mysqli_query($conn, "SELECT `accode`, `name` FROM `accmast` where `grpcode`='010' ORDER BY `name` asc") or die(mysqli_error($conn));
                                        while ($fetexp = mysqli_fetch_assoc($getexp)) {
                                            Echo "<option value='$fetexp[accode]'>$fetexp[name]</option>";
                                        }
                                        ?>
                                    </select>
                                </div>
                            </div> 
                        </div>
                        <div class="row">
                            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg ">Size</label>
                            </div>
                            <div class="col-lg-2" >
                                <input type="text" class="qsval bcolor form-control " name="mainsize" >
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 " style="margin-left: -29px;">
                                <select name="sizetype" class="querysizeval form-control " style="width: 48px; ">
                                    <option value=""></option>
                                    <option value="1">OD</option>
                                    <option value="2">NB</option>
                                    <option value="3">NM</option>
                                </select>
                            </div>
                            <div class="col-lg-2" >
                                <input type="text" class="qsoval bcolor form-control " style="margin-left: -12px;" name="mm" >
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 text-left pad mmsize" name="mmsize" style="margin-left: -28px;">
                                <label class="label-control marg">MM</label>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Guage</label>
                            </div>
                            <div class="col-lg-2" >
                                <input type="text" class="qgval bcolor form-control size" name="mainguage" >
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 " style="margin-left: -29px;">
                                <select name="guagetype" class="queryggval form-control" change=""  style="width: 48px; ">
                                    <option value=""></option>
                                    <option value="1">NR</option>
                                    <option value="2">SH</option>
                                    <option value="3">NM</option>
                                </select>
                            </div>
                            <div class="col-lg-2" >
                                <input type="text" class="qgoval bcolor form-control guagemm" name="mmguage" style="margin-left: -12px;">
                            </div>
                            <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-left pad"style="margin-left: -25px;">
                                <label class="label-control marg">MM</label>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad" >
                                <label class="label-control marg">Make Size</label>
                            </div>
                            <div class="col-lg-2" >
                                <input type="text" class="qmval bcolor form-control size" name="mainmksize" >
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 " style="margin-left: -29px;">
                                <select name="maketype" class="querymakeval form-control " name="makedrop" style="width: 48px; ">
                                    <option value=""></option>
                                    <option value="1">OD</option>
                                    <option value="2">NB</option>
                                    <option value="3">NM</option>
                                </select>
                            </div>
                            <div class="col-lg-2" >
                                <input type="text" class="qmoval bcolor form-control size" style="margin-left: -12px;" name="makesizemm" >
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 text-left pad" name="makesizemm" style="margin-left: -28px;">
                                <label class="label-control marg">MM</label>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Fts</label>
                            </div>   
                            <div class="col-lg-2" >
                                <input type="text" class="bcolor form-control " name="mainfts" value="0.00" style="text-align: right;" >
                            </div>             
                        </div>
                    </div>
                    <div class="modal-footer">
                        <div class="row">
                            <input type="submit" name="chalmodalprint" value="VIEW" style="margin-left: 13%; width: 12%; background-color:#34a853;"  class="btn" >
                                <!--<span class="" style="color:#ffffff; font-weight: bold;" data-toggle='tooltip' title='Print'>VIEW</span>-->   
                            <a type="button" style=" width: 12%; margin-right: 45%;  background-color:#DC143C;" data-dismiss="modal" onclick="window.close()" class="btn"  id="print" target="_blank">
                                <span class="" style="color:#ffffff; font-weight: bold;" data-toggle='tooltip' title='Print'>Exit</span>   
                            </a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>



    <script type="text/javascript">
<?php if ($addflag == 0) { ?>
            //            $(".ndata").show();
            //            $(".tohide").hide();
            //            //            $("#submit").show();
            //            document.getElementById("submit").style.display = "block";
            //            document.getElementById("submit").style.visibility = "visible";
            $(".ndata").show();
            $("#submit").show();
            $(".mark").focus();
            $(".tohide").hide();
<?php } ?>
    </script>
    <?php include("includes/linksfoot.php"); ?>

</body>
</html>
