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

$maindb = 'challan';
$trandb = '';
$accdb = 'actran';
$stkdb = '';
$printfile = "chal_pdf.php";
$file = 'challan.php';
$trandbexist = 0;
$source = "SL";
$keyfld = "vouchno";
$myyear = $_SESSION["tit_" . $dbname];

date_default_timezone_set('Asia/Kolkata');
$time = date('H:i:s');

$usertype = $_SESSION["usertype"];
$username = $_SESSION["username_" . $dbname];

$formname = 'Challan / Bill';
$admin = $_SESSION["admin_" . $dbname];
$zdb = $_SESSION["zdbyear_" . $dbname];
$par = $_GET["par"];
$zyear = right($zdb, 4);
$comp = $_SESSION["comp_" . $dbname];

$zStartDate = getzdates($zyear, 'S', $conn);
$zEndDate = getzdates($zyear, 'E', $conn);

mysqli_select_db($conn, $zdb);

include("includes/vouchno_generate.php");
include("includes/prev&next.php");
if (isset($_POST["submit"])) {

    $a = 1;

    $vouchdt = $_POST["vouchdt"];
    $rem1 = trim($_POST["rem1"]);
    $rem2 = trim($_POST["rem2"]);
    $note1 = trim($_POST["note1"]);
    $note2 = trim($_POST["note2"]);
    $party = trim($_POST["party"]);
    $vessel = $_POST["vessel"];
    $manualno = $_POST["manualno"];
    $timesheetno = $_POST["timesheetno"];
    $ordby = $_POST["ordby"];
    $anchor = $_POST["anchor"];
    $nomin = $_POST["nomin"];
    $rate = $_POST["rate"];
    $chalamt = $_POST["chalamt"];
    $purpose = $_POST["purpose"];
    $purpose2 = $_POST["purpose2"];
    $purpose3 = $_POST["purpose3"];
    $purpose4 = $_POST["purpose4"];
    $type = $_POST["type"];
    $launch = $_POST["launch"];
    $frmdt = $_POST["frmdt"];
    $frmtime = $_POST["frmtime"];
    $todt = $_POST["todt"];
    $totime = $_POST["totime"];
    $nohrs = $_POST["nohrs"];
    $otamt = $_POST["otamt"];

    $mvouch = $qvouch;

    $gtacode = mysqli_query($conn, "Select accode from accmast where `name`='$party'") or die(mysqli_error($conn));
    $ftacode = mysqli_fetch_array($gtacode);
    $accode = $ftacode['accode'];

    if ($vouchdt <= 0) {
        browse("Date Cannot Be Empty");
        $a = 0;
    }

    if ($vouchdt == '0000-00-00') {
        browse("Voucher Date Cannot Be Empty");
        $a = 0;
    }

    if ($vouchdt == '') {
        browse("Voucher Date Cannot Be Empty");
        $a = 0;
    }


    if ($accode == "") {
        browse("Party Cannot Be Empty");
        $a = 0;
    }

    if ($a == 1) {

        $path = "images/" . $myyear . "/" . $comp . "/";
        if (!is_dir($path)) {
            mkdir($path);
        }

        #####################IMAGE#####################
        $filename1 = $mvouch . ".jpg";
        $img_file1 = $path . ($filename1);
        $image_ftype = pathinfo($img_file1, PATHINFO_EXTENSION);
        $size = $_FILES["file1"]["size"];

        if ($size > 20480000) {
            $uploadOk = 0;
            $a = 0;
        } else {
            $uploadOk = 1;
            $a = 1;
        }

        if ($uploadOk == 1) {
            move_uploaded_file($_FILES["file1"]["tmp_name"], $img_file1);
        } else {
            browse("Sorry, there was an error uploading your file.(Check Size)");
            header("refresh: 1; $file?mode=last");
        }

        mysqli_query($conn, "LOCK TABLES `$maindb` WRITE");

        if ($addflag == 1) {
            $gen1 = mysqli_query($conn, "SELECT MAX(vouchno) AS maxcode FROM `$maindb` where vouchno != '' $keycond 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;
        }

        if ($addflag == 1) {

            mysqli_query($conn, "INSERT INTO `$maindb`(`vouchno`, `vouchdt`, purchdt, `accode`, `rate`,
                                                        `amount`, `rem1`, `rem2`, `note1`, `note2`, `imgpath`,
                                                        `ordby`,`anchor`, `purpose`,`purpose2`,`purpose3`,`purpose4`,
                                                       `launch`,`frmdt`, `frmtime`,`todt`,`totime`, `nohrs`,`type`,`nomin`,`vessel`,
                                                       `manualno`,`timesheetno`,`otamt`)
                                                VALUES('$mvouch', '$vouchdt', '$purchdt', '$accode', '$rate', 
                                                       '$chalamt', '$rem1', '$rem2', '$note1', '$note2','$img_file1',
                                                       '$ordby','$anchor','$purpose','$purpose2','$purpose3','$purpose4',
                                                       '$launch','$frmdt','$frmtime','$todt','$totime','$nohrs','$type','$nomin','$vessel',
                                                       '$manualno','$timesheetno','$otamt')") or die(mysqli_error($conn));
        } else {
            mysqli_query($conn, "UPDATE `$maindb` SET  `vouchdt`='$vouchdt',`accode`='$accode',`rem1`='$rem1',`vehcode`='$vehcode',
                                `rem2`='$rem2', `note1`='$note1', `note2`='$note2',`rate`='$rate',`imgpath`= '$img_file1',
                                `amount`='$chalamt', `ordby`='$ordby',`anchor`='$anchor',
                                `purpose`='$purpose',`purpose2`='$purpose2',`purpose3`='$purpose3',`purpose4`='$purpose4',`launch`='$launch',`frmdt`='$frmdt',`frmtime`='$frmtime',`todt`='$todt',`totime`='$totime',
                                `nohrs`='$nohrs',`type`='$type',`nomin`='$nomin',`vessel`='$vessel',`manualno`='$manualno',
                                `timesheetno`='$timesheetno',`otamt`='$otamt' WHERE `vouchno` = '$mvouch' ") or die(mysqli_error($conn));
        }

        mysqli_query($conn, "UNLOCK TABLES");
        if ($addflag == 1) {
            insmess();
            header("refresh: 1; $file?mode=true&par=A");
        } else {
            updmess();
        }
    }
}

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);
    if ($get['type'] == 'H') {
        $type = "Hours";
    } else {
        $type = "Lumsum";
    }
    $imgpath = $get['imgpath'];
    $getparty = mysqli_query($conn, "SELECT `accode`,`name` FROM `accmast` WHERE `accode`= '$get[accode]'") or die(mysqli_error($conn));
    $lparty = mysqli_fetch_array($getparty);

    $getanch = mysqli_query($conn, "SELECT `name` FROM `port` WHERE `code`= '$get[anchor]'") or die(mysqli_error($conn));
    $fanch = mysqli_fetch_array($getanch);

    $getlaunch = mysqli_query($conn, "SELECT `name` FROM `launch` WHERE `code`= '$get[launch]'") or die(mysqli_error($conn));
    $flaunch = mysqli_fetch_array($getlaunch);
    
    $gordby = mysqli_query($conn, "SELECT `name` FROM `ordby` WHERE `code`= '$get[ordby]'") or die(mysqli_error($conn));
    $fordby = mysqli_fetch_array($gordby);
    
    $getvessel = mysqli_query($conn, "SELECT `name` FROM `vessel` WHERE `code`= '$get[vessel]'") or die(mysqli_error($conn));
    $fvessel = mysqli_fetch_array($getvessel);

    $delcsh = $get['cashvouch'];

    if ($get['irn'] != "") {
        $tno = 1;
    } else {
        $tno = 0;
    }
} else {
    $result1 = mysqli_query($conn, "SELECT * FROM `$maindb` WHERE $keyfld < $qvouch order by vouchno desc limit 0,1") or die(mysqli_error($conn));
    if (mysqli_num_rows($result1) > 0) {
        $get1 = mysqli_fetch_array($result1);
        if ($par == 'A') {
            $vchdt = $get1['vouchdt'];
            $purchdt = $get1['purchdt'];
            $vehcode2 = $get1['vehcode'];
            $vehicle2 = $get1['vehicle'];
        } else {
            $vchdt = date("Y-m-d");
            $purchdt = date("Y-m-d");
            $vehcode2 = '';
            $vehicle2 = '';
        }
    }
}


if (isset($_GET["delete"])) {
    mysqli_query($conn, "LOCK TABLES `$maindb` WRITE") or die(mysqli_error($conn));

    $delcond = " source = '$source' and vouchno = '$_GET[vouchno]'";
    $delcond2 = " vouchno = '$_GET[vouchno]'";

    delnew($zdb, "$maindb", "$delcond2", "$file?mode=last$para", $conn);
    // delnew($zdb, "$accdb", "$delcond", "$file?mode=last$para", $conn);

    mysqli_query($conn, "UNLOCK TABLES");
}

include("includes/linkshead.php");
?>
<script src="MyScript/challan.js?a=5" type="text/javascript"></script>
<script src="MyScript/checkdate.js" type="text/javascript"></script>
<!--<script src="MyScript/search_item.js?A=<?php echo mt_rand(); ?>" type="text/javascript"></script>-->
<script src="MyScript/challan_search.js" type="text/javascript"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/js/select2.full.js"></script>
<!--<script src="js/searchsel.js" type="text/javascript"></script>-->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
    .tabital {
        font-family: verdana;
        font-style: italic;
        /*font-size: 16px;*/
    }

    .PTbody>tr>td>input:focus {
        border: 1px solid #ff0066 !important;
    }

    /*    table > thead > tr > td{
           ding: 5px;
        }*/
    .tbodyy tr:nth-child(even) {
        background-color: #ede3ff;
    }

    .btnpdf {
        max-width: 20%;
    }

    .bgrow {
        background-color: #a2d2ff;
        color: #780000 !important;
    }

    .bgfrmrow {
        background-color: #ffafcc;
        color: #780000 !important;
    }

    .bgtorow {
        background-color: #ffe5d9;
        color: #780000 !important;
    }

    .panel {
        margin-bottom: 0px !important;
    }

    input[type="file"] {
        position: relative;
    }

    input[type="file"]::file-selector-button {
        width: 136px;
        color: transparent;
    }

    /* Faked label styles and icon */
    input[type="file"]::before {
        position: absolute;
        pointer-events: none;
        top: 5px;
        left: 16px;
        height: 20px;
        width: 20px;
        content: "";
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%230964B0'%3E%3Cpath d='M18 15v3H6v-3H4v3c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2v-3h-2zM7 9l1.41 1.41L11 7.83V16h2V7.83l2.59 2.58L17 9l-5-5-5 5z'/%3E%3C/svg%3E");
    }

    input[type="file"]::after {
        position: absolute;
        pointer-events: none;
        top: 5px;
        left: 40px;
        color: #0964b0;
        content: "Upload File";
    }

    /* ------- From Step 1 ------- */

    /* file upload button */
    input[type="file"]::file-selector-button {
        border-radius: 4px;
        padding: 0 5px;
        height: 25px;
        cursor: pointer;
        background-color: white;
        border: 1px solid rgba(0, 0, 0, 0.16);
        box-shadow: 0px 1px 0px rgba(0, 0, 0, 0.05);
        margin-right: 5px;
        transition: background-color 200ms;
    }

    /* file upload button hover state */
    input[type="file"]::file-selector-button:hover {
        background-color: #f3f4f6;
    }

    /* file upload button active state */
    input[type="file"]::file-selector-button:active {
        background-color: #e5e7eb;
    }

    @media only screen and (min-width: 1280px) {
        .divMob {
            display: none;
        }
    }

    @media only screen and (max-width: 600px) {
        .divMob {
            display: block;
        }
    }

    /* Modal Styles */
    .modal {
        display: none;
        position: fixed;
        /* z-index: 1; */
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        overflow: auto;
        background-color: rgba(0, 0, 0, 0.4);
    }

    .modal-content {
        background-color: #fefefe;
        margin: 15% auto;
        padding: 20px;
        border: 1px solid #888;
        width: 100%;
    }

    .modal-img {
        background-color: #fefefe;
        margin: 15% auto;
        padding: 20px;
        border: 1px solid #888;
        width: 50%;
    }

    .close-btn {
        color: #aaa;
        font-size: 28px;
        font-weight: bold;
        position: absolute;
        top: 0;
        right: 15px;
        cursor: pointer;
    }


    /*    .row{
            margin-bottom: 1rem;
            margin-top: 1rem;
        }*/
</style>
</head>

<body>
    <form action='' method='POST' enctype="multipart/form-data">
        <div class="col-lg-3 text-center" id="overlay_form" style="display:none;z-index:999;">
            <button type="button" id="close_form" style="float: right;font-weight: bold;font-size: 18px;color:red;"><i class="fa fa-close"></i></button>
            <div style='width:100%;' id='browdata'>
            </div>
        </div>
        <!-- Default box -->
        <div class="row">
            <div class="col-lg-5 col-md-6 col-sm-6 col-xs-12 ">
                <div class="panel panel-default">
                    <div class="panel-heading" style="height:40px">
                        <div class="col-lg-10 col-md-10 col-sm-10  col-xs-10">
                            <h3 class="panel-title" style="color:#78909C"><a class="myPrint"><?php echo $formname; ?></a></h3>
                        </div>
                        <div class="col-lg-2 col-md-2 col-sm-2  col-xs-2">

                            <h4 class="panel-title" style="float:right"><b><?php echo $get['username'] ?></b></h4>
                        </div>

                    </div>
                    <div class="panel-body">
                        <div class="row">
                            <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right">
                                <label class="label-control marg">No</label>
                            </div>
                            <div class="col-lg-2 col-md-1 col-sm-3 col-xs-3 pad">
                                <input type="hidden" class="tno" value="<?= $tno ?>" />

                                <input type="hidden" class="form-control einvpar" value="<?php echo $_SESSION["einv"] ?>">
                                <input type="hidden" class="form-control par" value="<?php echo $par ?>">
                                <input type="hidden" class="form-control addflag" value="<?php echo $addflag ?>">
                                <input type="text" name="vouchno" tabindex="-1" class="form-control form vouchno" id="vouchno" value="<?php echo ($addflag != 1) ? $get['vouchno'] : "$qvouch" ?>" readonly>
                            </div>
                            <div class="col-lg-3 col-md-2 col-sm-1 col-xs-1 text-right">
                                <label class="label-control marg">Date</label>
                            </div>
                            <div class="col-lg-4 col-md-4 col-sm-5 col-xs-6 pad">
                                <input type="date" class="form-control form focusfield vouchdt " name="vouchdt" value="<?php echo ($addflag != 1) ? $get["vouchdt"] : "$vchdt"; ?>" autofocus required>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right">
                                <label class="label-control marg">Man. No</label>
                            </div>
                            <div class="col-lg-2 col-md-1 col-sm-3 col-xs-3 pad">
                                <input type="text" name="manualno" class="form-control form manualno" id="manualno" value="<?php echo ($addflag != 1) ? $get['manualno'] : "" ?>" required>
                            </div>
                            <div class="col-lg-3 col-md-2 col-sm-1 col-xs-1 text-right">
                                <label class="label-control marg">Timesheet No.</label>
                            </div>
                            <div class="col-lg-4 col-md-4 col-sm-5 col-xs-6 pad">
                                <input type="text" class="form-control form timesheetno" name="timesheetno" value="<?php echo ($addflag != 1) ? $get["timesheetno"] : ""; ?>" required>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-2 col-xs-2 text-right">
                                <label class="label-control marg">Party</label>
                            </div>
                            <div class="col-lg-6 col-xs-9 pad">
                                <input type="text" name="party" class="srchparty party form-control form" autocomplete="off" value="<?php echo ($addflag != 1) ? $lparty['name'] : '' ?>" required>
                                <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 class='bordcolr'>";
                                                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 class="row">
                            <div class="col-lg-2 col-xs-2 text-right">
                                <label class="label-control marg">Vessel</label>
                            </div>
                            <div class="col-lg-6 col-xs-9 pad">
                                <select class="form-control form  vessel select2" id="vessel" name="vessel" style="width: 100%" required>
                                    <option value="<?php echo ($addflag != 1) ? $get["vessel"] : ""; ?>"><?php echo ($addflag != 1) ? $fvessel["name"] : ""; ?></option>
                                    <?php
                                    $gvessel = mysqli_query($conn, "SELECT `code`,`name` FROM `vessel` WHERE `code`!='' order by name") or die(mysqli_error($conn));
                                    while ($fetvessel = mysqli_fetch_array($gvessel)) {
                                        echo "<option value='$fetvessel[code]'>$fetvessel[name]</option>";
                                    }
                                    ?>
                                </select>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-2 col-md-3 col-sm-1 col-xs-2 text-right">
                                <label class="label-control marg">Ord. By</label>
                            </div>
                            <div class="col-lg-4 col-md-5 col-sm-8 col-xs-8 pad">
                            <select class="form-control form  vessel select2" id="ordby" name="ordby" style="width: 100%" required>
                                    <option value="<?php echo ($addflag != 1) ? $get["ordby"] : ""; ?>"><?php echo ($addflag != 1) ? $fordby["name"] : ""; ?></option>
                                    <?php
                                    $getordby = mysqli_query($conn, "SELECT `code`,`name` FROM `ordby` WHERE `code`!='' order by name") or die(mysqli_error($conn));
                                    while ($fetordby = mysqli_fetch_array($getordby)) {
                                        echo "<option value='$fetordby[code]'>$fetordby[name]</option>";
                                    }
                                    ?>
                                </select>
                            </div>
                            <div class="col-lg-1 col-xs-2 text-right pad">
                                <input type="file" name="file1" id="file1" class="form file1">
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-2 col-xs-2 text-right">
                                <label class="label-control marg">Anchor</label>
                            </div>
                            <div class="col-lg-4 col-md-5 col-sm-8 col-xs-8 pad">
                                <select class="form-control form  anchor select2" id="anchor" name="anchor" style="width: 100%" required>
                                    <option value="<?php echo ($addflag != 1) ? $get["anchor"] : $get['anchor']; ?>"><?php echo ($addflag != 1) ? $fanch["name"] : $fanch['name']; ?></option>
                                    <?php
                                    $ganch = mysqli_query($conn, "SELECT `code`,`name` FROM `port` WHERE `code`!='' order by name") or die(mysqli_error($conn));
                                    while ($fetanch = mysqli_fetch_array($ganch)) {
                                        echo "<option value='$fetanch[code]'>$fetanch[name]</option>";
                                    }
                                    ?>
                                </select>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-2 col-md-3 col-sm-1 col-xs-2 text-right">
                                <label class="label-control marg">Purpose</label>
                            </div>
                            <div class="col-lg-8 col-md-5 col-sm-8 col-xs-8 pad">
                                <input type="text" class="form-control form purpose" name="purpose" value="<?php echo ($addflag != 1) ? $get["purpose"] : ""; ?>">
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-2 col-md-3 col-sm-1 col-xs-2 text-right">
                                <label class="label-control marg"></label>
                            </div>
                            <div class="col-lg-8 col-md-5 col-sm-8 col-xs-8 pad">
                                <input type="text" class="form-control form purpose2" name="purpose2" value="<?php echo ($addflag != 1) ? $get["purpose2"] : ""; ?>">
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-2 col-md-3 col-sm-1 col-xs-2 text-right">
                                <label class="label-control marg"></label>
                            </div>
                            <div class="col-lg-8 col-md-5 col-sm-8 col-xs-8 pad">
                                <input type="text" class="form-control form purpose3" name="purpose3" value="<?php echo ($addflag != 1) ? $get["purpose3"] : ""; ?>">
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-2 col-md-3 col-sm-1 col-xs-2 text-right">
                                <label class="label-control marg"></label>
                            </div>
                            <div class="col-lg-8 col-md-5 col-sm-8 col-xs-8 pad">
                                <input type="text" class="form-control form purpose4" name="purpose4" value="<?php echo ($addflag != 1) ? $get["purpose4"] : ""; ?>">
                            </div>
                        </div>
                        <div>
                            <div class="row bgrow">

                                <div class="col-lg-2 col-xs-2 text-right">
                                    <label class="label-control marg" style="font-weight:bold">Launch</label>
                                </div>
                                <div class="col-lg-6 col-xs-2 pad">
                                    <select class="form-control form  launch select2" id="launch" name="launch" style="width: 100%" required>
                                        <option value="<?php echo ($addflag != 1) ? $get["launch"] : $get['launch']; ?>"><?php echo ($addflag != 1) ? $flaunch["name"] : $flaunch['name']; ?></option>
                                        <?php
                                        $glaunch = mysqli_query($conn, "SELECT `code`,`name` FROM `launch` WHERE `code`!='' order by name") or die(mysqli_error($conn));
                                        while ($fetlaunch = mysqli_fetch_array($glaunch)) {
                                            echo "<option value='$fetlaunch[code]'>$fetlaunch[name]</option>";
                                        }
                                        ?>
                                    </select>
                                </div>
                                <div class="col-lg-2 col-xs-2 text-right">
                                    <label class="label-control marg" style="font-weight:bold">Type</label>
                                </div>
                                <div class="col-lg-2 col-xs-2 pad">
                                    <select class="form-control form type select2" id="type" name="type" style="width: 100%" required>
                                        <option value="<?php echo ($addflag != 1) ? $get["type"] : "H"; ?>"><?php echo ($addflag != 1) ? $type : "Hours" ?></option>
                                        <option value="L">Lumsum</option>
                                        <option value="H">Hours</option>
                                    </select>
                                </div>
                            </div>
                            <div class="row bgfrmrow">
                                <div class="col-lg-2 col-xs-3 text-right">
                                    <label class="label-control marg" style="font-weight:bold">From</label>
                                </div>
                                <div class="col-lg-3 col-xs-3 text-right pad">
                                    <input type="date" step="any" name="frmdt" class="form-control form frmdt" value="<?php echo ($addflag != 1) ? $get['frmdt'] : '' ?>">
                                </div>
                                <div class="col-lg-5 col-xs-7 text-right">
                                    <label class="label-control marg" style="font-weight:bold">From Time</label>
                                </div>
                                <div class="col-lg-2 col-xs-3 text-right pad">
                                    <input type="number" step="any" name="frmtime" maxlength="4" class="form-control form text-right frmtime" value="<?php echo ($addflag != 1) ? $get['frmtime'] : '' ?>" required>
                                </div>
                            </div>
                        </div>
                        <div class="row bgtorow">
                            <div class="col-lg-2 col-xs-3 text-right">
                                <label class="label-control marg" style="font-weight:bold">To</label>
                            </div>

                            <div class="col-lg-3 col-xs-3 text-right pad">
                                <input type="date" step="any" name="todt" class="form-control form todt" value="<?php echo ($addflag != 1) ? $get['todt'] : '' ?>">
                            </div>
                            <div class="col-lg-5 col-xs-7 text-right">
                                <label class="label-control marg" style="font-weight:bold">To Time</label>
                            </div>
                            <div class="col-lg-2 col-xs-3 text-right pad">
                                <input type="number" step="any" name="totime" class="form-control form text-right totime" value="<?php echo ($addflag != 1) ? $get['totime'] : '' ?>" required>
                            </div>
                        </div>

                        <div class="row bgrow">
                            <div class="col-lg-2 col-xs-2 text-right">
                                <label class="label-control marg" style="font-weight:bold;font-size: 12px">Hours</label>
                            </div>

                            <div class="col-lg-1 col-xs-2 text-right pad">
                                <input type="number" step="any" name="nohrs" class="form-control form text-right nohrs" tabindex="-1" readonly value="<?php echo ($addflag != 1) ? $get['nohrs'] : 0 ?>">
                            </div>
                            <div class="col-lg-2 col-xs-2 text-right">
                                <label class="label-control marg" style="font-weight:bold;font-size: 12px">Mins</label>
                            </div>

                            <div class="col-lg-1 col-xs-2 text-right pad">
                                <input type="number" step="any" name="nomin" class="form-control form text-right nomin" tabindex="-1" readonly value="<?php echo ($addflag != 1) ? $get['nomin'] : 0 ?>">
                            </div>
                            <div class="col-lg-4 col-xs-3 text-right">
                                <label class="label-control marg" style="font-weight:bold">Rate</label>
                            </div>
                            <div class="col-lg-2 col-xs-3 text-right pad">
                                <input type="number" step="any" name="rate" class="form-control form text-right rate" value="<?php echo ($addflag != 1) ? $get['rate'] : '0' ?>">
                            </div>
                        </div>
                        <div class="row bgrow">
                            <div class="col-lg-10 col-xs-3 text-right">
                                <label class="label-control marg" style="font-weight:bold">Crew O/T</label>
                            </div>
                            <div class="col-lg-2 col-xs-3 text-right pad">
                                <input type="number" step="any" name="otamt" class="form-control form text-right otamt" value="<?php echo ($addflag != 1) ? $get['otamt'] : '0' ?>">
                            </div>
                        </div>
                        <div class="row bgrow">
                            <div class="col-lg-10 col-xs-3 text-right">
                                <label class="label-control marg" style="font-weight:bold">Amount</label>
                            </div>
                            <div class="col-lg-2 col-xs-3 text-right pad">
                                <input type="number" step="any" name="chalamt" class="form-control form text-right chalamt" value="<?php echo ($addflag != 1) ? $get['amount'] : '0' ?>" required readonly>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-2 col-xs-2 text-right">

                            </div>
                            <div class="col-lg-4 col-xs-2 text-right pad " id="openModal">
                                <?php if ($imgpath != '') { ?>
                                    <img id="preview" src="<?php echo $imgpath; ?>" style="height: 80px;width:80px" alt="your image" />
                                <?php } ?>
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2  text-right">
                                <label class="label-control marg">Remarks</label>
                            </div>
                            <div class="col-lg-8 col-md-8 col-sm-10 col-xs-10 pad">
                                <input type="text" name="rem1" class="form-control form " value="<?php echo ($addflag != 1) ? $get["rem1"] : ""; ?>">
                            </div>
                            <!-- <div class="col-lg-8  col-md-8 col-sm-10  col-xs-10 pad">
                                <input type="text" name="rem2" class="form-control form " value="<?php echo ($addflag != 1) ? $get["rem2"] : ""; ?>">
                            </div> -->
                        </div>
                        <!-- <div class="row">
                            <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right">
                                <label class="label-control marg">Note</label>
                            </div>
                            <div class="col-lg-8 col-md-8 col-sm-10 col-xs-10 pad">
                                <input type="text" name="note1" class="form-control form " maxlength="50" value="<?php echo ($addflag != 1) ? $get["note1"] : ""; ?>">
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right">
                            <label class="label-control marg"></label>
                            </div>
                            <div class="col-lg-8  col-md-8 col-sm-10  col-xs-10 pad">
                                <input type="text" name="note2" class="form-control form " maxlength="50" value="<?php echo ($addflag != 1) ? $get["note2"] : ""; ?>">
                            </div>
                        </div> -->
                    </div>
                    <!-- <div class="row">
                        <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3 text-right pad">
                        </div>
                        <div class="col-lg-7 col-md-7 col-sm-8 col-xs-8 text-right pad">
                            <img src="MyStyle/pdficon.png" title="Pdf Print" class="btnpdf pdf" style="display: <?= $editdisabled ?>" onclick="window.open('sale_pdf.php?vouchno=<?= $qvouch ?>')">
                        </div>

                    </div> -->
                </div>
                <div class="row">
                    <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                        <div class="panel panel-default">
                            <div class="panel-footer">
                                <!--<img src="MyStyle/pdficon.png" title="Pdf Print" class="btn-pad pdf" style="width: 115px; height: 75px;cursor: pointer; margin-bottom: -64px;margin-left:-45px; display: <?= $editdisabled ?>" onclick="window.open('sale_pdf.php?vouchno=<?= $qvouch ?>')">-->
                                <?php include("includes/buttons.php"); ?>
                                <script>
                                    $("#hedit").click(function() {
                                        $(".pdf").hide();
                                    });
                                </script>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-lg-7 col-md-6 col-sm-10 col-xs-12 ">
                <div class="row">
                    <table class="table-bordered">
                        <thead>
                            <tr class="mySearchTr" style="color:white;">
                                <th style="width:4%;">Sr.</th>
                                <th style="width:20%;">Party</th>
                                <th style="width:10%;" class='text-center'>Launch</th>
                                <th style="width:10%;" class='text-center'>T</th>
                                <th style="width:10%;" class='text-center'>From</th>
                                <th style="width:10%;" class='text-center'>Time</th>
                                <th style="width:10%;" class='text-center'>To</th>
                                <th style="width:10%;" class='text-center'>Time</th>
                                <th style="width:10%;" class='text-center'>Hrs</th>
                                <th style="width:10%;" class='text-center'>Mins</th>
                                <th style="width:10%;" class='text-center'>Amount</th>
                                <th style="width:6%;" class='text-center'>No</th>
                            </tr>
                        </thead>
                        <tbody class="tbodyy">
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <input type="date" value="<?= $zStartDate ?>" style="width: 1px;border: none" class="zstdate">
        <input type="date" value="<?= $zEndDate ?>" style="width: 1px;border: none" class="zenddate">
    </form>

    <div class="modal fade searchModal bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
        <div class="modal-dialog modal-lg" style="margin-top: 4%">
            <div class="modal-content">
                <div class="modal-header">
                    <button class="close" data-dismiss="modal"><span>&times;</span></button>
                    <h4 class="modal-title" id="myLargeModalLabel">Search <?php echo $formname; ?></h4>
                </div>
                <div class="modal-body">
                    <input type="hidden" value="<?php echo $fseries ?>" class="form-control series">
                    <input type="hidden" value="<?php echo $get['vouchno']; ?>" class="form-control vouchno">
                    <input type="hidden" value="<?php echo $file ?>" class="form-control file">
                    <input type="hidden" value="<?php echo $para ?>" class="form-control para">
                    <div class="row">
                        <div class="col-lg-2">
                            <select class="form-control sfield">
                                <option value="1"> Party Name</option>
                                <option value="2">Date</option>
                                <option value="3">Amount</option>
                                <option value="4">No.</option>
                                <option value="5">Anchor</option>
                                <option value="6">Order By</option>
                                <option value="7">Launch</option>
                                <option value="8">Vessel</option>
                            </select>
                        </div>
                        <div class="col-lg-2">
                            <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"> Party Name</option>
                                <option value="2">Date</option>
                                <option value="3">Amount</option>
                                <option value="4">No.</option>
                                <option value="5">Anchor</option>
                                <option value="6">Order By</option>
                                <option value="7">Launch</option>
                                <option value="8">Vessel</option>
                            </select>
                        </div>
                        <div class="col-lg-2">
                            <select class="form-control orderAs">
                                <option value="desc">Desc</option>
                                <option value="asc">Asc</option>
                            </select>
                        </div>
                        <div class="col-lg-2">
                            <input type="text" value="" class="form-control ssearch" placeholder="Search Here">
                        </div>
                        <div class="col-lg-2">
                            <input type="button" class="btn btn-primary sload" value="Search">
                        </div>
                    </div>

                    <div class="col-lg-12 sloader text-center">
                        <img src="images/search.gif" alt="loading">
                    </div>
                    <div class="col-lg-12 snoRecord text-center">
                        <h3>NO RECORDS FOUND</h3>
                    </div>
                    <div class="table-responsive" style="max-height: 400px;overflow: auto;">
                        <table id="" class="table table-striped table-condensed table-bordered" width="100%">
                            <thead>
                                <tr class="mySearchTr">
                                    <th width="20%">Party Name</th>
                                    <th width="10%">Date</th>
                                    <th width="9%">Amount</th>
                                    <th width="5%">No</th>
                                    <th width="20%">Anchor</th>
                                    <th width="9%">Order By..</th>
                                    <th width="9%">Launch</th>
                                    <th width="9%">Vessel</th>
                                    <th width="9%">Action</th>
                                </tr>
                            </thead>
                            <tbody class="sTbody">
                            </tbody>
                        </table>
                    </div>
                    <div class="row">
                        <div class="col-xs-12 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>
                <div class="modal-footer"></div>
            </div>
        </div>
    </div>
    <div id="myModal" class="modal">
        <div class="modal-img">
            <span class="close-btn">&times;</span>
            <img id="preview" src="<?php echo $imgpath; ?>" style="height: 500px;width:100%" alt="your image" />
        </div>
    </div>
    <?php include("includes/linksfoot.php"); ?>
</body>

</html>