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

$maindb = 'consultmain';
$trandb = 'consultsymp';
$accdb = 'actran';
$stkdb = 'transacn';

$printfile = "consultent_pdf.php";
$file = 'consult_ent.php';
$trandbexist = 1;
$salecode = 15;
$source = 'CONS';

$formname = 'Consulting Form';
$curdate = date("Y-m-d");

$grid = '';
$keyfld = "vouchno";
$focusfield = "vouchno";
$mgrpcode = '';
$keycond = "";
$myyear = $_SESSION["tit_" . $dbname];

$admin = $_SESSION["admin_" . $dbname];
$zdb = $_SESSION["zdbyear_" . $dbname];
$zroot = $_SESSION["zdir"];
$zcono = $_SESSION["comp_" . $dbname];
$modet = $_GET["mode"];
$accodet = $_GET["accode"];


$username = $_SESSION["username_" . $dbname];
$usertype = $_SESSION["usertype"];
$keycond1 = "";
// browse($usertype);
$yearalpha1 = substr($myyear, 0, 1);
$nyear = substr($myyear, -4);

$yearalpha = strtoupper($yearalpha1);
mysqli_select_db($conn, $zdb);

if ($accodet) {
    $getpat1 = mysqli_query($conn, "SELECT * FROM `accmast` WHERE accode='$accodet'") or die(mysqli_error($conn));
    $fetpat1 = mysqli_fetch_array($getpat1);
    if ($fetpat1['gender'] == 'M') {
        $gval1 = "Male";
    } else if ($fetpat1['gender'] == 'F') {
        $gval1 = "Female";
    } else {
        $gval1 = "Other";
    }
}
include("includes/vouchno_generate.php");
include("includes/prev&next.php");

if($usertype != 1){
    include("includes/menu_rights.php");
}

if (isset($_POST["submit"])) {
    $a = 1;

    foreach ($_POST as $k => $v) {
        $$k = $v;
    }

    /// main post ///////

    $mvouch = $qvouch;

    if ($a == 1) {

        if ($addflag == 1) {
            $gen1 = mysqli_query($conn, "SELECT IFNULL(MAX(vouchno),0) AS maxcode FROM `$maindb` ") or die(mysqli_error($conn));
            $vvouch = mysqli_fetch_assoc($gen1);

            if ($vvouch['maxcode'] > 0) {
                $qvouch = $vvouch["maxcode"] + 1;
            } else {
                $gen11 = mysqli_query($conn, "SELECT vouchno AS maxreg FROM $zroot.`company` WHERE code = '$zcono'  ") or die(mysqli_error($conn));
                if (mysqli_num_rows($gen11) > 0) {
                    $vvouch11 = mysqli_fetch_assoc($gen11);
                    $qvouch = $vvouch11["maxreg"];
                } else {
                    $qvouch = '1';
                }
            }
            $mvouch = $qvouch;
        }


        mysqli_query($conn, "DELETE FROM `$trandb` WHERE vouchno = '$mvouch'");
        $sympcnt = $_POST["sympcnt"];
        $smctr = 0;
        for ($i = 0; $i <= $sympcnt; $i++) {
            $symptoms = $_POST["symptoms_" . $i];
            if ($symptoms != "") {
                $smctr++;
                mysqli_query($conn, "INSERT INTO `$trandb`(`vouchno`, `vouchdt`, srno , symptoms, accode)
                                               VALUES('$mvouch', '$vouchdt', '$smctr', '$symptoms', '$accode' )") or die(mysqli_error($conn));
            }
        }


        mysqli_query($conn, "DELETE FROM `instalment` WHERE vouchno = '$mvouch'");
        $instcnt = 2;
        $ictr = 0;
        for ($p = 0; $p <= $instcnt; $p++) {
            $iamount = $_POST["iamt_" . $p];
            $paiddate = $_POST["paiddate_" . $p];
            $ictr++;
            mysqli_query($conn, "INSERT INTO `instalment`(`vouchno`, `vouchdt`, srno , amount, paiddate, accode)
                                               VALUES('$mvouch', '$vouchdt', '$ictr', '$iamount', '$paiddate', '$accode' )") or die(mysqli_error($conn));
        }

        mysqli_query($conn, "DELETE FROM consulttreat WHERE vouchno = '$mvouch'");
        $treatcnt = $_POST["treatcnt"];
        $trctr = 0;
        for ($t = 0; $t <= $treatcnt; $t++) {
            $treatment = $_POST["treatment_" . $t];
            $tqty = $_POST["qty_" . $t];
            $tduration = $_POST["tduration_" . $t];
            $tremarks = $_POST["tremarks_" . $t];
            $aprov = $_POST["aprov_" . $t];
            $firstdate = $_POST["firstdate_" . $t];
            $aprvqty = $_POST["aprvqty_" . $t];
            $rate = $_POST["rate_" . $t];
            $amt = $_POST["amt_" . $t];
            $treatrate = $_POST["treatrate_" . $t];
            $treatamt = $_POST["treatamt_" . $t];

            if ($treatment != "") {


                $gettt = mysqli_query($conn, "SELECT code,name FROM `treatment` WHERE `name`='$treatment'") or die(mysqli_error($conn));
                if (mysqli_num_rows($gettt) > 0) {
                    $tcode = mysqli_fetch_array($gettt);
                    $treatcode = $tcode['code'];
                } else {
                    $gensz = mysqli_query($conn, "SELECT MAX(code) AS maxcode FROM `treatment` where code != '' LIMIT 0,1 ") or die(mysqli_error($conn));
                    if (mysqli_num_rows($gensz) > 0) {
                        $gsz = mysqli_fetch_assoc($gensz);
                        $treatcode = $gsz["maxcode"] + 1;
                    } else {
                        $treatcode = '1';
                    }
                    mysqli_query($conn, "INSERT INTO `treatment`(`code`, `name`)
                           VALUES('$treatcode',  '$treatment')") or die(mysqli_error($conn));
                }
                $trctr++;
                mysqli_query($conn, "INSERT INTO `consulttreat`(`vouchno`, `vouchdt`, `srno`, `treatment`, `qty`, `duration`, `remarks`, 
                                                                `accode`, `aprov`,firstdate, `treatrate`, `treatamt`, `rate`, `amt`, `aprvqty`)
                                                         VALUES('$mvouch', '$vouchdt',  '$trctr', '$treatcode', '$tqty', '$tduration', '$tremarks', '$accode',
                                                                '$aprov', '$firstdate', '$treatrate', '$treatamt', '$rate', '$amt', '$aprvqty')") or die(mysqli_error($conn));
            }
        }


        mysqli_query($conn, "DELETE FROM treatbill WHERE vouchno = '$mvouch'");
        $btreatcnt = $_POST["btreatcnt"];
        $btrctr = 0;
        for ($bt = 0; $bt <= $btreatcnt; $bt++) {
            $btreatment = $_POST["btreatment_" . $bt];
            $btqty = $_POST["bqty_" . $bt];
            $bduration = $_POST["bduration_" . $bt];
            $bfirstdate = $_POST["bfirstdate_" . $bt];
            $baprov = $_POST["baprov_" . $bt];
            $brate = $_POST["brate_" . $bt];
            $bamt = $_POST["bamt_" . $bt];

            if ($btreatment != "") {


                $gettt = mysqli_query($conn, "SELECT code,name FROM `treatment` WHERE `name`='$btreatment'") or die(mysqli_error($conn));
                if (mysqli_num_rows($gettt) > 0) {
                    $tcode = mysqli_fetch_array($gettt);
                    $treatcode = $tcode['code'];
                }
                $trctr++;
                mysqli_query($conn, "INSERT INTO `treatbill`(`vouchno`, `vouchdt`, `srno`, `treatment`, `qty`, duration, 
                                                                `accode`, `aprov`,firstdate, `rate`, `amt`)
                                                         VALUES('$mvouch', '$vouchdt',  '$btrctr', '$treatcode', '$btqty', '$bduration',
                                                                '$accode', '$baprov', '$bfirstdate', '$brate', '$bamt')") or die(mysqli_error($conn));
            }
        }

        mysqli_query($conn, "DELETE FROM consultmed WHERE vouchno = '$mvouch'") or die(mysqli_error($conn));

        $medcnt = $_POST["medcnt"];
        $mdctr = 0;
        for ($m = 0; $m <= $medcnt; $m++) {
            $item = $_POST["medicine_" . $m];
            $dosage = $_POST["dosage_" . $m];
            $daytake = $_POST["daytake_" . $m];
            $ngttake = $_POST["ngttake_" . $m];
            $duration = $_POST["duration_" . $m];
            $mqty = $_POST["mqty_" . $m];
            $mrate = $_POST["mrate_" . $m];
            $mamt = $_POST["mamt_" . $m];
            if ($item != "") {

                $getitt = mysqli_query($conn, "SELECT code,name FROM `product` WHERE `name`='$item'") or die(mysqli_error($conn));
                if (mysqli_num_rows($getitt) > 0) {
                    $itcode = mysqli_fetch_array($getitt);
                    $itemcode = $itcode['code'];
                } else {
                    $gensz1 = mysqli_query($conn, "SELECT MAX(code) AS maxcode FROM `product` where code != '' LIMIT 0,1 ") or die(mysqli_error($conn));
                    if (mysqli_num_rows($gensz1) > 0) {
                        $gsz1 = mysqli_fetch_assoc($gensz1);
                        $itemcode = $gsz1["maxcode"] + 1;
                    } else {
                        $itemcode = '1';
                    }
                    mysqli_query($conn, "INSERT INTO `product`(`code`, `name`)
                           VALUES('$itemcode',  '$item')") or die(mysqli_error($conn));
                }
                $mdctr++;
                mysqli_query($conn, "INSERT INTO `consultmed`(`vouchno`, `vouchdt`, srno , `item`, `dosage`, `duration`, accode, `qty`, `rate`, `amount`, ngttake, daytake)
                                               VALUES('$mvouch', '$vouchdt', '$mdctr', '$itemcode', '$dosage', '$duration', '$accode' , '$mqty', '$mrate', '$mamt', '$ngttake', '$daytake')") or die(mysqli_error($conn));
            }
        }


        mysqli_query($conn, "DELETE FROM medbill WHERE vouchno = '$mvouch'") or die(mysqli_error($conn));
        mysqli_query($conn, "DELETE FROM `$stkdb` WHERE vouchno='$mvouch'  AND `source`='$source'") or die(mysqli_error($conn));

        $bmedcnt = $_POST["bmedcnt"];

        $bmdctr = 0;
        for ($b = 0; $b <= $bmedcnt; $b++) {
            $bitem = $_POST["bmedicine_" . $b];
            $bmqty = $_POST["bmqty_" . $b];
            $bmrate = $_POST["bmrate_" . $b];
            $bmamt = $_POST["bmamt_" . $b];
            if ($bitem != "") {

                $getitt = mysqli_query($conn, "SELECT code,name FROM `product` WHERE `name`='$bitem'") or die(mysqli_error($conn));
                if (mysqli_num_rows($getitt) > 0) {
                    $itcode = mysqli_fetch_array($getitt);
                    $itemcode = $itcode['code'];
                }
                $mdctr++;
                mysqli_query($conn, "INSERT INTO `medbill`(`vouchno`, `vouchdt`, srno , `item`, accode, `qty`, `rate`, `amount`)
                                               VALUES('$mvouch', '$vouchdt', '$mdctr', '$itemcode', '$accode' , '$bmqty', '$bmrate', '$bmamt')") or die(mysqli_error($conn));

                if ($bmqty > 0) {
                    $stqty = $bmqty * -1;
                    mysqli_query($conn, "INSERT INTO `$stkdb`(`vouchno`, `yearno`, `vouchdt`, `srno`, `barcode`, `itemcode`, `qty`, `unit`,  `source`,
                                `mrp`, `rate`, `amount`) 
                    VALUES ('$mvouch', '$zyear', '$vouchdt', '$mdctr', '$barcode', '$itemcode', '$stqty', '$unit', '$source',
                                '$mrp', '$bmrate', '$bmamt')") or die(mysqli_error($conn));
                }
            }
        }

        mysqli_query($conn, "DELETE FROM schedtreat WHERE vouchno = '$mvouch' and treatment > 0") or die(mysqli_error($conn));
        $schedcnt = $_POST["schedcnt"];
        $msctr = 0;
        for ($s = 0; $s <= $schedcnt; $s++) {
            $streatment = $_POST["streatment_" . $s];
            $scheddate = $_POST["scheddate_" . $s];
            $sremarks = $_POST["sremarks_" . $s];
            $compltdt = $_POST["compltdt_" . $s];
            $checkin = $_POST["checkin_" . $s];
            $consult = $_POST["consult_" . $s];
            if ($streatment != "") {
                $msctr++;
                mysqli_query($conn, "INSERT INTO `schedtreat`(`vouchno`, `vouchdt`, srno , `treatment`, `scheddate`, `compltdt`, `remarks`, accode, checkin, consult )
                                               VALUES('$mvouch', '$vouchdt', '$msctr', '$streatment', '$scheddate', '$compltdt', '$sremarks', '$accode','$checkin', '$consult' )") or die(mysqli_error($conn));
            }
        }
        $tdate = date("Y-m-d");
        mysqli_query($conn, "UPDATE `schedtreat` SET  consult='1' where vouchno='$mvouch' and scheddate='$tdate' and checkin ='1'");
        mysqli_query($conn, "DELETE FROM schedtreattemp WHERE vouchno = '$mvouch'") or die(mysqli_error($conn));
        mysqli_query($conn, "DELETE FROM actran WHERE vouchno = '$mvouch' and source='$source'") or die(mysqli_error($conn));
        if ($invdt != "0000-00-00") {
            $tbillamt = $billamt;
        } else {
            $tbillamt = $consultfees - $discamt;
        }

        if ($tbillamt > 0) {
            $minus_amt = $tbillamt * -1;
            // sale part
            mysqli_query($conn, "INSERT INTO `actran`(date, vouchno,source, trnno, accode, grpcode, amount)
                            VALUES ('$vouchdt','$mvouch','$source', '001', '30','005', '$tbillamt')") or die(mysqli_error($conn));

            // party part
            mysqli_query($conn, "INSERT INTO `actran`(date, vouchno, source, trnno, accode, grpcode, amount)
                                VALUES ('$vouchdt','$mvouch','$source', '002', '$accode','010', '$minus_amt')") or die(mysqli_error($conn));
        }
        $path = "images/consultimg/";
        $uploadOk = 1;

        $filename1 = $mvouch . "_" . "imgbef" . ".jpg";
        $img_file1 = $path . ($filename1);
        $image_ftype = pathinfo($img_file1, PATHINFO_EXTENSION);
        if ($uploadOk == 1) {
            move_uploaded_file($_FILES["imgbef"]["tmp_name"], $img_file1);
        } else {
            browse("Sorry, there was an error uploading your file.");
            header("refresh: 1; $file?mode=last");
        }

        $filename2 = $mvouch . "_" . "imgaft" . ".jpg";
        $img_file2 = $path . ($filename2);
        $image_ftype2 = pathinfo($img_file2, PATHINFO_EXTENSION);
        if ($uploadOk == 1) {
            move_uploaded_file($_FILES["imgaft"]["tmp_name"], $img_file2);
        } else {
            browse("Sorry, there was an error uploading your file.");
            header("refresh: 1; $file?mode=last");
        }

        $tpath = "images/consultpdf/";
        $filename3 = $mvouch . "_" . "conpdf" . ".pdf";
        $img_file3 = $tpath . ($filename3);
        $image_ftype3 = pathinfo($img_file3, PATHINFO_EXTENSION);
        if ($uploadOk == 1) {
            move_uploaded_file($_FILES["conpdf"]["tmp_name"], $img_file3);
        } else {
            browse("Sorry, there was an error uploading your file.");
            header("refresh: 1; $file?mode=last");
        }



        if ($addflag == 1) {


            $uuid = $_SESSION["uuid"];

            mysqli_query($conn, "INSERT INTO `$maindb`(`vouchno`, `vouchdt`, `vouchtime`, `accode`, `diag1`, `diag2`, `invs`, `invs1`,`invs2`,`invs3`,`notes1`, `notes2`, 
                                                       purpvisit, refby, `notes3`, `notes4`,`cmpltdt`,`consultfees`, `ttamount`, `tmedamount`,
                                                       `subtot`,`discamt`,`invdt`,
                                                       `billamt`,`imgbef`,`imgaft`,`consentpdf`, `concern1`,  `treattotal`, `trdiscperc`, `trdiscamt`, 
                                                       `medtotal`, `meddiscperc`, `meddiscamt`, trpaytype )
                                               VALUES('$qvouch', '$vouchdt', '$vouchtime', '$accode', '$diag1', '$diag2', '$invs', '$invs1','$invs2','$invs3', '$notes1', '$notes2', 
                                                      '$purpvisit', '$refby', '$notes3', '$notes4','$cmpltdt', '$consultfees', '$ttamount', '$tmedamount',
                                                      '$subtot','$discamt','$invdt',
                                                      '$billamt','$img_file1','$img_file2','$img_file3', '$concern1',  '$treattotal', '$trdiscperc', '$trdiscamt',
                                                    '$medtotal', '$meddiscperc', '$meddiscamt', '$trpaytype')") or die(mysqli_error($conn));

            $mvouch = $_GET["vouchno"];
        } else {

            mysqli_query($conn, "UPDATE `$maindb` SET  vouchdt='$vouchdt', `accode`='$accode',`diag1`='$diag1',`diag2`='$diag2',`invs`='$invs',`invs1`='$invs1',`invs2`='$invs2',`invs3`='$invs3', apprv='1',
                                                      `notes1`='$notes1',`notes2`='$notes2',`notes3`='$notes3',`notes4`='$notes4',
                                                       purpvisit='$purpvisit', refby='$refby', `cmpltdt`='$cmpltdt', `consultfees`='$consultfees', `ttamount`='$ttamount', 
                                                      `tmedamount`='$tmedamount', trpaytype='$trpaytype',
                                                      `subtot`='$subtot',`discamt`='$discamt',`invdt`='$invdt',
                                                      `billamt`='$billamt',`imgbef`='$img_file1',`imgaft`='$img_file2',`consentpdf`='$img_file3',
                                                      `concern1`='$concern1', `treattotal`='$treattotal', `trdiscperc`='$trdiscperc', `trdiscamt`='$trdiscamt',
                                                      `medtotal`='$medtotal', `meddiscperc`='$meddiscperc', `meddiscamt`='$meddiscamt' WHERE vouchno = '$mvouch' ") or die(mysqli_error($conn));
        }

        if ($addflag == 1) {
            insmess();
            $mvouch = $qvouch;
            header("refresh: 1; $file?$keyfld=$mvouch&mode=edit");
        } else {
            updmess();
            header("refresh: 1; $file?$keyfld=$mvouch&mode=edit");
        }
    }
}


if ($addflag != 1) {

    $getvouch = '';
    if ($addflag == 0) {
        $getvouch = $_GET[$keyfld];
    } else {
        $getvouch = $qvouch;
    }
    $result = mysqli_query($conn, "SELECT *, date_format(`vouchdt`,'%d-%m-%Y') as mydt FROM `$maindb` WHERE $keyfld='$getvouch'") or die(mysqli_error($conn));
    $get = mysqli_fetch_array($result);



    $msched = 0;
    $fbalamt = 0;
    $getpay = mysqli_query($conn, "SELECT sum(amount) as tamt FROM `actran` WHERE slvouch='$getvouch' and accode = '$get[accode]'") or die(mysqli_error($conn));
    if (!empty($getpay)) {
        $mpay = mysqli_fetch_array($getpay);
        $paidamt = $mpay["tamt"];
        $fbalamt = $get['billamt'] - $paidamt;
    }
    $getsched = mysqli_query($conn, "SELECT * FROM `schedtreat` WHERE $keyfld='$getvouch' and treatment > 0") or die(mysqli_error($conn));
    if (!empty($getsched)) {
        $msched = mysqli_num_rows($getsched);
    }

    if ($get['trpaytype'] == 'I') {
        $trval = "Installment";
    } else if ($get['trpaytype'] == 'F') {
        $trval = "Full Payment";
    } else if ($get['trpaytype'] == 'E') {
        $trval = "EMI";
    } else {
        $trval = "";
    }



    $getpat = mysqli_query($conn, "SELECT * FROM `accmast` WHERE accode='$get[accode]'") or die(mysqli_error($conn));
    $fetpat = mysqli_fetch_array($getpat);
    if ($fetpat['gender'] == 'M') {
        $gval = "Male";
    } else if ($fetpat['gender'] == 'F') {
        $gval = "Female";
    } else {
        $gval = "Other";
    }
}

if ($usertype > 2) {
    $rd = "readonly";
    $inputmaxdate = date("Y-m-d");
} else {
    $rd = "";
    $inputmaxdate = "";
}

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

if (isset($_GET["delete"])) {

    delete($zdb, "$maindb", "$keyfld", $_GET[$keyfld], "$file?mode=last");
    delete($zdb, "$trandb", "$keyfld", $_GET[$keyfld], "$file?mode=last");
    delete($zdb, "consulttreat", "$keyfld", $_GET[$keyfld], "$file?mode=last");
    delete($zdb, "consultmed", "$keyfld", $_GET[$keyfld], "$file?mode=last");
    delete($zdb, "medbill", "$keyfld", $_GET[$keyfld], "$file?mode=last");
    delete($zdb, "schedtreat", "$keyfld", $_GET[$keyfld], "$file?mode=last");
    delete($zdb, "treatdet", "$keyfld", $_GET[$keyfld], "$file?mode=last");
    delete($zdb, "treatbill", "$keyfld", $_GET[$keyfld], "$file?mode=last");
    unlink($get['imgbef']);
    unlink($get['consentpdf']);
    unlink($get['imgaft']);
    $delcond = " source = '$source' and vouchno = '$_GET[vouchno]'";

    delnew($zdb, "$accdb", "$delcond", "$file?mode=last");
    delnew($zdb, "$stkdb", "$delcond", "$file?mode=last");
}

include("includes/linkshead.php");
?>

<script src="MyScript/consult_ent.js?a=<?= mt_rand() ?>" type="text/javascript"></script>
<script src="MyScript/consult_ent_search.js?c=<?= mt_rand() ?>" type="text/javascript"></script>
<style>
    /* CSS */
    .button-29 {
        align-items: center;
        appearance: none;
        background: transparent;
        border: 2px solid #0b4c78;
        border-radius: 6px;
        box-sizing: border-box;
        color: #0b4c78;
        cursor: pointer;
        display: inline-flex;
        font-family: "JetBrains Mono", monospace;
        height: 38px;
        width: 88px;
        justify-content: center;
        line-height: 1;
        list-style: none;
        overflow: hidden;
        padding-left: 16px;
        padding-right: 16px;
        position: relative;
        text-align: left;
        text-decoration: none;
        transition: box-shadow .15s, transform .15s;
        user-select: none;
        -webkit-user-select: none;
        touch-action: manipulation;
        white-space: nowrap;
        will-change: box-shadow, transform;
        font-size: 18px;
    }

    /* .button-29:focus {
        box-shadow: #3c4fe0 0 0 0 1.5px inset, rgba(45, 35, 66, .4) 0 2px 4px, rgba(45, 35, 66, .3) 0 7px 13px -3px, #3c4fe0 0 -3px 0 inset;
    }

    .button-29:hover {
        box-shadow: rgba(45, 35, 66, .4) 0 4px 8px, rgba(45, 35, 66, .3) 0 7px 13px -3px, #3c4fe0 0 -3px 0 inset;
        transform: translateY(-2px);
    } */

    .button-29:active {
        box-shadow: #3c4fe0 0 3px 7px inset;
        transform: translateY(2px);
    }

    .sksahil {
        border-radius: 10px;
        background: rgb(11, 76, 120);
        background: linear-gradient(104deg, rgba(11, 76, 120, 1) 60%, rgba(255, 255, 255, 1) 100%);
        margin-left: 1%;
    }

    .sksahil2 {
        border-radius: 10px;
        background-color: #e6f1ff;
        margin-top: 5px;
        margin-bottom: 5px;
    }

    .skbtn {
        background-image: linear-gradient(135deg, #FFFEFF 10%, #D7FFFE 100%) !important;
        border: 1px solid #09C6F9 !important;
        border: 2px solid #0b4c78;
        color: #2A2A72;
        font-weight: bold;
        border-radius: 10px;
    }

    .skk {
        border-bottom: 1px solid grey !important;
        color: white;
    }

    .slk {
        background: black !important;
    }

    .txtt {
        color: whitesmoke;
        text-transform: uppercase;
        font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif
    }

    .adjcol {
        width: 4.33333333%;
    }

    .adjcolh {
        width: 5.33333333%;
    }

    .adjcol2 {
        width: 6.33333333%;
    }

    .adjcolh2 {
        width: 10.33333333%;
    }

    .adjcolh3 {
        width: 12.333333%;
    }

    .adjcolh1_5 {
        width: 8.7%;
    }

    .adjcola {
        width: 20%;
    }

    .adjcol3 {
        width: 25.9999999%;
    }

    .panel.with-nav-tabs .nav-tabs {
        border-bottom: none;
    }

    .panel.with-nav-tabs .nav-justified {
        margin-bottom: -1px;
    }

    .nav-tabs>li {
        margin-bottom: -1px;
        width: 140px;
    }

    .with-nav-tabs.panel-primary .nav-tabs>li>a,
    .with-nav-tabs.panel-primary .nav-tabs>li>a:hover,
    .with-nav-tabs.panel-primary .nav-tabs>li>a:focus {
        color: #fff;
    }

    .with-nav-tabs.panel-primary .nav-tabs>.open>a,
    .with-nav-tabs.panel-primary .nav-tabs>.open>a:hover,
    .with-nav-tabs.panel-primary .nav-tabs>.open>a:focus,
    .with-nav-tabs.panel-primary .nav-tabs>li>a:hover,
    .with-nav-tabs.panel-primary .nav-tabs>li>a:focus {
        color: #fff;
        background-color: #3071a9;
        border-color: transparent;
    }

    .with-nav-tabs.panel-primary .nav-tabs>li.active>a,
    .with-nav-tabs.panel-primary .nav-tabs>li.active>a:hover,
    .with-nav-tabs.panel-primary .nav-tabs>li.active>a:focus {
        color: #428bca;
        background-color: #fff !important;
        border-color: #428bca !important;
        border-bottom-color: transparent !important;
    }

    .with-nav-tabs.panel-primary .nav-tabs>li.dropdown .dropdown-menu {
        background-color: #428bca;
        border-color: #3071a9;
    }

    .with-nav-tabs.panel-primary .nav-tabs>li.dropdown .dropdown-menu>li>a {
        color: #fff;
    }

    .with-nav-tabs.panel-primary .nav-tabs>li.dropdown .dropdown-menu>li>a:hover,
    .with-nav-tabs.panel-primary .nav-tabs>li.dropdown .dropdown-menu>li>a:focus {
        background-color: #3071a9;
    }

    .with-nav-tabs.panel-primary .nav-tabs>li.dropdown .dropdown-menu>.active>a,
    .with-nav-tabs.panel-primary .nav-tabs>li.dropdown .dropdown-menu>.active>a:hover,
    .with-nav-tabs.panel-primary .nav-tabs>li.dropdown .dropdown-menu>.active>a:focus {
        background-color: #4a9fe9;

    }

    .purch {
        font-size: 12px;
    }

    .sknewbtn {
        background-image: linear-gradient(135deg, #09C6F9 10%, #045DE9 100%) !important;
        color: white !important;
    }

    .btn:hover {
        background-color: transparent;
    }

    .colramt {
        color: green;
        font-weight: bold;
    }

    .SKtable>tbody>tr>td {
        padding-right: 15px;
        padding-left: 15px;
    }

    input[type=text]:focus {
        background-color: transparent;
    }

    input[type=number]:focus {
        background-color: transparent;
    }

    input[type=date]:focus {
        background-color: transparent;
    }

    .skfontcolr {
        color: #0b4c78;
        font-weight: bold;
        font-size: 17px;
    }

    #borderimg {
        border: 2px solid #0b4c78;
        padding: 4px;
        border-radius: 7px;
    }

    .txttnew {
        color: #0b4c78;
        text-transform: uppercase;
        font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
        /* overflow-wrap: break-word; */
        margin-bottom: -15px;
        background-color: #f9f9fa;
        overflow: overlay;
        padding: 8px;
    }

    .table-responsive {
        position: relative;
    }

    .table-responsive input[type="checkbox"] {
        position: sticky;
        left: 0;
        z-index: 10;
        /* Ensure it stays above other content */
        background: white;
        /* Ensure visibility over table rows */
    }

    /*    #tab6default {
    
            background-color: #bbc3c9;
             Ensure visibility over table rows 
        }*/
    .form-control{
        text-transform: uppercase;
    }
</style>
</head>

<body>
    <form action='' method='POST' enctype="multipart/form-data">
        <div class="col-lg-2 pad 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-trash"></i></button>
            <div class="normotp">
                <div class="ratemspless">
                    <!--<input type="button" name="genotp" class="form-control genotp" style="color:red;border: none" value="Click here to Generate OTP">-->
                    <div class="row">
                        <div class="col-lg-4 text-right"><label class="label-control">Enter OTP</label></div>
                        <div class="col-lg-4">
                            <input type="text" name="otprecv" id="otprecv" class="form-control otprecv" style="background-color: white;color: green;">
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-lg-4 text-right"></div>
                        <div class="col-lg-4 ">
                            <input type="button" name="subotp" id="subotp" class="form-control form subotp" style="color: blue;background-color: whitesmoke" value="Submit OTP">
                            <input type="button" name="subemail" id="subemail" class="form-control form subemail" style="color: blue;background-color: whitesmoke" value="Submit OTP">
                        </div>
                    </div>
                    <input type="hidden" name="otpsucs" id="otpsucs" class="form-control otpsucs">
                </div>
            </div>
        </div>
        <!-- Default box -->
        <div class="row">
            <div class="col-lg-12">

                <div class="panel panel-default">
                    <div class="panel-heading">
                        <?php
                        if ($get["edituser"] != '') {
                            $user = strtoupper($get["edituser"]);
                        } else {
                            $user = strtoupper($get["adduser"]);
                        }
                        ?>
                        <h5 class="panel-title"><?php echo $formname; ?> <p style="float:right;font-size:14px"> <?php echo $user; ?></p>
                        </h5>
                        <!--<h3 class="pull-right" style="padding:0px"></h3>-->
                    </div>
                    <div class="panel-body">
                        <div class="row">
                            <div class="col-lg-3 col-md-1 col-sm-3 col-xs-3 text-right pad ">
                                <label class="label-control marg">Voucher No.</label>
                            </div>
                            <div class="col-lg-2 col-md-1 col-sm-3 col-xs-3 pad">
                                <input type="hidden" class="form-control addflg" value="<?php echo ($addflag != 1) ? "2" : $addflag; ?>">
                                <input type="hidden" class="form-control form addflag" value="<?php echo ($addflag != 1) ? "2" : $addflag; ?>">
                                <input type="hidden" class="form-control form manual_ent" value="<?= $para ?>">
                                <input type="hidden" name="invno" class="form-control form invno" value="<?php echo ($addflag != 1) ? $get['invno'] : ""; ?>">
                                <input type="text" class="form-control vouchno" name="vouchno" value="<?php echo ($addflag != 1) ? $get["vouchno"] : "NEW"; ?>" readonly required>
                            </div>

                            <div class="col-lg-2 col-md-1 col-sm-1 col-xs-1 text-right pad">
                                <label class="label-control marg">Date</label>
                            </div>
                            <div class="col-lg-3 col-md-3 col-sm-4 col-xs-4 pad">
                                <input type="date" class="form-control form vouchdt" name="vouchdt" value="<?php echo ($addflag != 1) ? $get["vouchdt"] : date("Y-m-d"); ?>" <?= $rd ?>>
                            </div>

                        </div>




                        <div class="col-lg-12 skbackcolor">
                            <div class="with-nav-tabs ">
                                <div class="">
                                    <ul class="nav nav-tabs sksahil2">
                                        <li  class="active"><a href="#tab1default" data-toggle="tab"><b style="font-size:14px;">Personal Info</b></a></li>
                                        <li><a href="#tab2default" data-toggle="tab"><b style="font-size:15px;">Consultation</b></a></li>
                                        <li><a href="#tab3default" data-toggle="tab"><b style="font-size:15px;">Treatment</b></a></li>
                                        <li><a href="#tab4default" data-toggle="tab"><b style="font-size:15px;">Prescription</b></a></li>
                                        <?php
                                        if ($msched <= 0) {
                                            $vis = "display:none;";
                                        }
                                        ?>
                                        <li><a href="#tab7default" data-toggle="tab"><b style="font-size:15px;">Photos</b></a></li>
                                        <!-- <?php
                                        // if($usertype == 1){
                                            // echo"<li ><a href='#tab6default' data-toggle='tab'><b style='font-size:15px;'>Billing</b></a></li>";
                                        // }else{
                                        ?> -->
                                        <li <?= $billing;?>><a href='#tab6default' data-toggle='tab'><b style='font-size:15px;'>Billing</b></a></li>
                                        <li style="<?= $vis ?>" class="tab5"><a href="#tab5default" data-toggle="tab"><b style="font-size:15px;">Schedule</b></a></li>
                                    </ul>
                                </div>

                                <div class="panel-body">
                                    <div class="tab-content">
                                        <div class="tab-pane fade  in active" id="tab1default">
                                            <!--<div class="tab-pane fade  " id="tab1default">-->
                                            <div class="row">
                                                <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                                    <label class="label-control marg">Name</label>
                                                </div>
                                                <div class="col-lg-6 col-md-6 col-sm-9 col-xs-9 pad">
                                                    <select class="form-control form accode" name="accode">
                                                        <?php
                                                        $fetpatname = strtoupper($fetpat["name"]);
                                                        $fetpat1name = strtoupper($fetpat1["name"]);
                                                        ?>
                                                        <option value="<?php echo ($addflag != 1) ? $fetpat["accode"] : $fetpat1["accode"]; ?>"><?php echo ($addflag != 1) ? $fetpatname : $fetpat1name; ?></option>
                                                        <?php
                                                        if ($addflag == 1) {
                                                            $getpat = mysqli_query($conn, "SELECT accode,name FROM `accmast` WHERE grpcode='010' order by name") or die(mysqli_error($conn));
                                                            while ($fetpat = mysqli_fetch_array($getpat)) {
                                                                echo "<option value ='$fetpat[accode]'>$fetpat[name]</option>";
                                                            }
                                                        }
                                                        ?>
                                                    </select>
                                                    <!--<input type="text" class="form-control form focusfield" required name="name" value="<?php echo ($addflag != 1) ? $get["name"] : ""; ?>" autofocus autocomplete="off">-->
                                                </div>
                                            </div>

                                            <div class="row">
                                                <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                                    <label class="label-control marg">Address</label>
                                                </div>
                                                <div class="col-lg-6 col-md-6 col-sm-9 col-xs-9 pad">
                                                    <?php
                                                    $fetpatadd1 = strtoupper($fetpat["add1"]);
                                                    $fetpat1add1 = strtoupper($fetpat1["add1"]);

                                                    $fetpatadd2 = strtoupper($fetpat["add2"]);
                                                    $fetpat1add2 = strtoupper($fetpat1["add2"]);

                                                    $fetpatadd3 = strtoupper($fetpat["add3"]);
                                                    $fetpat1add3 = strtoupper($fetpat1["add3"]);
                                                    ?>
                                                    <input type="text" class="form-control form add1" name="add1" value="<?php echo ($addflag != 1) ? $fetpatadd1 : $fetpat1add1; ?>">
                                                    <input type="text" class="form-control form add2" name="add2" value="<?php echo ($addflag != 1) ? $fetpatadd2 : $fetpat1add2; ?>">
                                                    <input type="text" class="form-control form add3" name="add3" value="<?php echo ($addflag != 1) ? $fetpatadd3 : $fetpat1add3; ?>">
                                                </div>

                                            </div>

                                            <div class="row">
                                                <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                                    <label class="label-control marg">Gender</label>
                                                </div>
                                                <div class="col-lg-2 col-md-2 col-sm-3 col-xs-3 pad">
                                                    <select class="form-control form gender select2" name="gender" style="width: 100%">
                                                        <option value="<?php echo ($addflag != 1) ? $fetpat["gender"] : $fetpat1["gender"]; ?>"><?php echo ($addflag != 1) ? $gval : $gval1; ?></option>
                                                        <option value='M'>Male</option>
                                                        <option value='F'>Female</option>
                                                        <option value='O'>Other</option>
                                                    </select>
                                                </div>
                                                <div class="col-lg-1 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                                    <label class="label-control marg">DOB</label>
                                                </div>
                                                <div class="col-lg-3 col-md-3 col-sm-4 col-xs-4 pad">
                                                    <input type="date" class="form-control form dob" name="dob" value="<?php echo ($addflag != 1) ? $fetpat["dob"] : $fetpat1["dob"]; ?>">
                                                </div>

                                            </div>

                                            <div class="row">
                                                <div class="col-lg-2 col-md-1 col-sm-2 col-xs-2 text-right pad">
                                                    <label class="label-control marg">Age</label>
                                                </div>
                                                <div class="col-lg-1 col-md-1 col-sm-3 col-xs-3 pad">
                                                    <input type="text" class="form-control form age" name="age" value="<?php echo ($addflag != 1) ? $fetpat["age"] : $fetpat1["age"]; ?>" readonly require>
                                                </div>
                                                <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                                    <label class="label-control marg">Mobile </label>
                                                </div>
                                                <div class="col-lg-3 col-md-3 col-sm-4 col-xs-4 pad">
                                                    <input type="text" class="form-control form  number" name="mobile" value="<?php echo ($addflag != 1) ? $fetpat["mobile"] : $fetpat1["mobile"]; ?>">
                                                </div>
                                            </div>
                                            <div class="row">
                                                <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                                    <label class="label-control marg">Email</label>
                                                </div>
                                                <div class="col-lg-6 col-md-6 col-sm-9 col-xs-9 pad">
                                                    <input type="text" class="form-control form email" name="email" value="<?php echo ($addflag != 1) ? $fetpat["email"] : $fetpat1["email"]; ?>">
                                                </div>
                                            </div>
                                            <div class="row">
                                                <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                                    <label class="label-control marg">Purpose of Visit</label>
                                                </div>
                                                <div class="col-lg-6 col-md-6 col-sm-9 col-xs-9 pad">
                                                    <input list='purpvisit' name='purpvisit' value='<?php echo $get['purpvisit'] ?>' class='purpvisit form-control form ' autocomplete="off">
                                                    <datalist id='purpvisit'>
                                                        <option value=''>
                                                            <?php
                                                            $gparty = mysqli_query($conn, "SELECT `purpvisit` FROM `$maindb` group by `purpvisit` order by `purpvisit`") or die(mysqli_error($conn));
                                                            while ($fparty = mysqli_fetch_array($gparty)) {
                                                                echo "<option value='$fparty[purpvisit]'>";
                                                            }
                                                            ?>
                                                    </datalist>
                                                </div>
                                            </div>
                                            <div class="row">
                                                <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                                    <label class="label-control marg">Referred By</label>
                                                </div>
                                                <div class="col-lg-6 col-md-6 col-sm-9 col-xs-9 pad">
                                                    <input list='refby' name='refby' value='<?php echo $get['refby'] ?>' class='refby form-control form ' autocomplete="off">
                                                    <datalist id='refby'>
                                                        <option value=''>
                                                            <?php
                                                            $grefby = mysqli_query($conn, "SELECT `refby` FROM `$maindb` group by `refby` order by refby") or die(mysqli_error($conn));
                                                            while ($frefby = mysqli_fetch_array($grefby)) {
                                                                echo "<option value='$frefby[refby]'>";
                                                            }
                                                            ?>
                                                    </datalist>
                                                </div>
                                            </div>
                                            <div class="row">
                                                <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                                    <label class="label-control marg">Regn. Date</label>
                                                </div>
                                                <div class="col-lg-2 col-md-4 col-sm-4 col-xs-4 pad">
                                                    <input type="date" class="form-control form regndt" name="regndt" value="<?php echo ($addflag != 1) ? $fetpat["regndt"] : date("Y-m-d"); ?>">
                                                </div>
                                                <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                                    <label class="label-control marg" style="color: red;">Complete Date</label>
                                                </div>
                                                <div class="col-lg-2 col-md-4 col-sm-4 col-xs-4 pad">
                                                    <input type="date" class="form-control form cmpltdt" style="color: red;" name="cmpltdt" value="<?php echo ($addflag != 1) ? $get["cmpltdt"] : ""; ?>">
                                                </div>
                                            </div>
                                        </div>

                                        <!-- ///////////////////  FOOD TAB   ///////////////// -->

                                        <div class="tab-pane fade" id="tab2default">
                                            <div class="row">
                                                <div class="col-lg-2 col-md-2 col-sm-3 col-xs-3 text-right pad">
                                                    <label class="label-control marg">Concerns</label>
                                                </div>
                                                <div class="col-lg-6 col-md-6 col-sm-8 col-xs-8 pad">
                                                    <input type="text" class="form-control form concern1" name="concern1" value="<?php echo ($addflag != 1) ? $get["concern1"] : ""; ?>" maxlength="40">

                                                </div>

                                            </div>
                                            <div class="row">
                                                <div class="col-lg-2 col-md-2 col-sm-3 col-xs-3 text-right pad">
                                                    <label class="label-control marg">Diagnosis</label>
                                                </div>
                                                <div class="col-lg-6 col-md-6 col-sm-8 col-xs-8 pad">
                                                    <input type="text" class="form-control form diag1" name="diag1" value="<?php echo ($addflag != 1) ? $get["diag1"] : ""; ?>" maxlength="40">
                                                    <input type="text" class="form-control form diag2" name="diag2" value="<?php echo ($addflag != 1) ? $get["diag2"] : ""; ?>" maxlength="40">
                                                </div>

                                            </div>
                                            <div class="row">
                                                <div class="col-lg-2 col-md-2 col-sm-3 col-xs-3 text-right pad">
                                                    <label class="label-control marg">Investigation</label>
                                                </div>
                                                <div class="col-lg-6 col-md-6 col-sm-8 col-xs-8 pad">
                                                    <input type="text" class="form-control form invs" name="invs" value="<?php echo ($addflag != 1) ? $get["invs"] : ""; ?>" maxlength="40">
                                                </div>
                                            </div>

                                            <div class="row">
                                                <div class="col-lg-2 col-md-2 col-sm-3 col-xs-3 text-right pad">
                                                    <label class="label-control marg"></label>
                                                </div>
                                                <div class="col-lg-6 col-md-6 col-sm-8 col-xs-8 pad">
                                                    <input type="text" class="form-control form invs1" name="invs1" value="<?php echo ($addflag != 1) ? $get["invs1"] : ""; ?>" maxlength="40">
                                                </div>
                                            </div>
                                            <!-- <div class="row">
                                                <div class="col-lg-2 col-md-2 col-sm-3 col-xs-3 text-right pad">
                                                    <label class="label-control marg"></label>
                                                </div>
                                                <div class="col-lg-6 col-md-6 col-sm-8 col-xs-8 pad">
                                                    <input type="text" class="form-control form invs2" name="invs2" value="<?php echo ($addflag != 1) ? $get["invs2"] : ""; ?>" maxlength="40">
                                                </div>
                                            </div>
                                            <div class="row">
                                                <div class="col-lg-2 col-md-2 col-sm-3 col-xs-3 text-right pad">
                                                    <label class="label-control marg"></label>
                                                </div>
                                                <div class="col-lg-6 col-md-6 col-sm-8 col-xs-8 pad">
                                                    <input type="text" class="form-control form invs3" name="invs3" value="<?php echo ($addflag != 1) ? $get["invs3"] : ""; ?>" maxlength="40">
                                                </div>
                                            </div> -->

                                            <br>
                                            <div class="row">
                                                <div class="col-lg-2 col-md-2 col-sm-3 col-xs-3 text-right pad">
                                                    <label class="label-control marg">Symptoms</label>
                                                </div>
                                                <div class="col-lg-6 col-md-6 col-sm-8 col-xs-8 pad sympbody">
                                                    <?php
                                                    if ($addflag != '1') {
                                                        $sctr = 0;
                                                        $gtsmtran = mysqli_query($conn, "Select * from `$trandb` where vouchno='$get[vouchno]' order by srno");
                                                        if (mysqli_num_rows($gtsmtran) > 0) {
                                                            while ($rowsmt = mysqli_fetch_array($gtsmtran)) {
                                                                echo "<input type='text' class='form-control form symptoms' name='symptoms_$sctr' value='$rowsmt[symptoms]' maxlength='40'  autocomplete='on'>";
                                                                $sctr++;
                                                            }
                                                        } else {
                                                            $sctr = 0;
                                                            for ($j = 0; $j < 5; $j++) {
                                                                echo "<input type='text' class='form-control form symptoms' name='symptoms_$j' value='' maxlength='40' autocomplete='on'>";
                                                                $sctr++;
                                                            }
                                                        }
                                                    } else {
                                                        $sctr = 0;
                                                        for ($j = 0; $j < 5; $j++) {
                                                            echo "<input type='text' class='form-control form symptoms' name='symptoms_$j' value='' maxlength='40'  autocomplete='on'>";
                                                            $sctr++;
                                                        }
                                                    }
                                                    ?>
                                                </div>
                                                <input type="hidden" name="sympcnt" id="sympcnt" value="<?php echo $sctr; ?>">
                                            </div>
                                            <div class="row">
                                                <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                                </div>
                                                <div class="col-lg-1 col-md-1 col-sm-3 col-xs-3 pad">
                                                    <button type="button" class="btn btn-primary btn-square form" id="addsymp" style="margin-top: 10px;border-radius:10px;line-height:1">
                                                        <i class="fa fa-plus" data-toggle='tooltip' title='Add Row'>&nbsp;&nbsp;Add More</i>
                                                    </button>
                                                </div>
                                            </div>

                                        </div>


                                        <div class="tab-pane fade " id="tab3default">

                                            <div class="row hidtabpane">

                                                <div class="row table-responsive" style="padding-left:2%">

                                                    <table class="table table-bordered" style="width: 100%">
                                                        <thead>
                                                            <tr class="mySearchTr">
                                                                <th style="width:3%"></th>
                                                                <th style="width:3%">Sr.</th>
                                                                <th style="width:30%">Treatment</th>
                                                                <th style="width:5%" class='text-right'>Nos.</th>
                                                                <th style="width:5%" class='text-right'>Days</th>
                                                                <th style="width:20%">Remarks</th>
                                                                <th style="width:7%" class='billprt'>Rate</th>
                                                                <th style="width:10%" class='billprt'>Amount</th>
                                                                <th style="width:3%" class='billprt text-right'>App<br>rove</th>
                                                                <th style="width:5%" class='billprt'>First Date</th>
                                                                <th style="width:3%" class='billprt'>Approve Nos.</th>
                                                                <th style="width:7%" class='billprt'>Approve Rate</th>
                                                                <th style="width:10%" class='billprt'>Approve Amount</th>
                                                            </tr>

                                                        </thead>

                                                        <!-- Laundry section starts from here -->
                                                        <tbody class="treatbody">
                                                            <?php
                                                            if ($addflag != '1') {
                                                                $tctr = 0;
                                                                $gtsmtrant = mysqli_query($conn, "Select a.*,b.name from `consulttreat` a left join treatment b
                                                                                             on a.treatment = b.code where a.vouchno='$get[vouchno]' order by a.srno");
                                                                if (mysqli_num_rows($gtsmtrant) > 0) {

                                                                    while ($rowsmtt = mysqli_fetch_array($gtsmtrant)) {
                                                                        $chkd = "";
                                                                        if ($rowsmtt['aprov'] == 1) {
                                                                            $chkd = "checked";
                                                                        }

                                                                        echo "<tr>";
                                                                        echo " <td><i class='fa fa-trash remove' style='display:none;font-size:24px'></i></td>";

                                                                        echo "<td><input type='text' class='form-control form srno' value='$rowsmtt[srno]' name='srno_$tctr'></td>";
                                                                        echo "<td>";
                                                                        echo "<input list='treatment' name='treatment_$tctr' class='treatment form-control form ' autocomplete='off' value='$rowsmtt[name]'> ";
                                                                        echo "<datalist id='treatment' char='#'>";
                                                                        echo "<option>";

                                                                        $mit = mysqli_query($conn, "SELECT `name` FROM `treatment` group by name") or die(mysqli_error($conn));

                                                                        while ($tit = mysqli_fetch_array($mit)) {
                                                                            $itname = $tit['name'];
                                                                            echo "<option value='$itname'>";
                                                                        }

                                                                        echo "</datalist>";
                                                                        echo "</td>";
                                                                        echo "<td><input type='text' class='form-control form text-right qty' value='$rowsmtt[qty]' name='qty_$tctr'></td>";
                                                                        echo "<td><input type='text' class='form-control form text-right duration' value='$rowsmtt[duration]' name='tduration_$tctr'></td>";
                                                                        echo "<td><input type='text' class='form-control form remarks' value='$rowsmtt[remarks]' name='tremarks_$tctr'></td>";
                                                                        echo "<td class='billprt'><input type='textbox' name='treatrate_$tctr' class='treatrate text-right form-control form' value='$rowsmtt[treatrate]' readonly></td>";
                                                                        echo "<td class='billprt'><input type='textbox' name='treatamt_$tctr' class='treatamt text-right form-control form' value='$rowsmtt[treatamt]'  readonly tabindex='-1'></td>";
                                                                        echo "<td class='billprt'>";
                                                                        echo "<input type='checkbox' name='aprov_$tctr' class='aprov form-control form' value='1' style='height:25px;width:25px' $chkd>";
                                                                        echo "</td>";
                                                                        echo "<td class='billprt'><input type='date' class='form-control form firstdate' value='$rowsmtt[firstdate]' name='firstdate_$tctr'></td>";
                                                                        echo "<td class='billprt'><input type='textbox' name='aprvqty_$tctr' class='aprvqty text-right form-control form' value='$rowsmtt[aprvqty]' ></td>";
                                                                        echo "<td class='billprt'><input type='textbox' name='rate_$tctr' class='rate text-right form-control form' value='$rowsmtt[rate]' ></td>";
                                                                        echo "<td class='billprt'><input type='textbox' name='amt_$tctr' class='amt text-right form-control form' value='$rowsmtt[amt]'  readonly tabindex='-1'></td>";
                                                                        echo "</tr>";
                                                                        $tctr++;
                                                                    }
                                                                } else {
                                                                    $tctr++;
                                                                    ?>
                                                                    <tr>
                                                                        <td><i class='fa fa-trash remove' style="display:none;font-size: 24px"></i></td>

                                                                        <td><input type="text" class="form-control form srno" value="1" name="srno_0"></td>
                                                                        <td>
                                                                            <input list='treatment' name='treatment_0' class='treatment form-control form ' autocomplete='off' value=''>
                                                                            <datalist id='treatment' char='#'>
                                                                                <option>
                                                                                    <?php
                                                                                    $mit = mysqli_query($conn, "SELECT `name` FROM `treatment` group by name") or die(mysqli_error($conn));

                                                                                    while ($tit = mysqli_fetch_array($mit)) {
                                                                                        $itname = $tit['name'];
                                                                                        echo "<option value='$itname'>";
                                                                                    }
                                                                                    ?>
                                                                            </datalist>
                                                                        </td>
                                                                        <td><input type="text" class="form-control form text-right qty" value="0" name="qty_0"></td>
                                                                        <td><input type="text" class="form-control form text-right duration" value="0" name="tduration_0"></td>
                                                                        <td><input type="text" class="form-control form remarks" value="" name="tremarks_0"></td>
                                                                        <td class="billprt"><input type='textbox' name='treatrate_0' class='treatrate text-right form-control form' value='0' readonly></td>
                                                                        <td class="billprt"><input type='textbox' name='treatamt_0' class='treatamt text-right form-control form' value='0' readonly tabindex="-1"></td>
                                                                        <td class="billprt"><input type="checkbox" name="aprov_0" class="aprov form-control form" value="1" style="height:25px;width:25px"></td>
                                                                        <td class="billprt"><input type='date' class='form-control form firstdate' value='' name='firstdate_0'></td>
                                                                        <td class="billprt"><input type='textbox' name='aprvqty_0' class='aprvqty text-right form-control form' value='0'></td>
                                                                        <td class="billprt"><input type='textbox' name='rate_0' class='rate text-right form-control form' value='0'></td>
                                                                        <td class="billprt"><input type='textbox' name='amt_0' class='amt text-right form-control form' value='0' readonly tabindex="-1"></td>
                                                                    </tr>
                                                                    <?php
                                                                }
                                                            } else {
                                                                ?>
                                                                <tr>
                                                                    <td><i class='fa fa-trash remove' style="font-size: 24px"></i></td>

                                                                    <td><input type="text" class="form-control form srno" value="1" name="srno_0"></td>
                                                                    <td>
                                                                        <input list='treatment' name='treatment_0' class='treatment form-control form ' autocomplete='off' value=''>
                                                                        <datalist id='treatment' char='#'>
                                                                            <option>
                                                                                <?php
                                                                                $mit = mysqli_query($conn, "SELECT `name` FROM `treatment` group by name") or die(mysqli_error($conn));

                                                                                while ($tit = mysqli_fetch_array($mit)) {
                                                                                    $itname = $tit['name'];
                                                                                    echo "<option value='$itname'>";
                                                                                }
                                                                                ?>
                                                                        </datalist>
                                                                    </td>
                                                                    <td><input type="text" class="form-control form text-right qty" value="0" name="qty_0"></td>
                                                                    <td><input type="text" class="form-control form text-right duration" value="0" name="tduration_0"></td>
                                                                    <td><input type="text" class="form-control form remarks" value="" name="tremarks_0"></td>
                                                                    <!--<td><input type='checkbox' class='form-control form aprov' value = '1' name='aprov_0' style='height:25px;width:25px'></td>-->

                                                                    <td class="billprt"><input type='textbox' name='treatrate_0' class='treatrate text-right form-control form' value='0' readonly></td>
                                                                    <td class="billprt"><input type='textbox' name='treatamt_0' class='treatamt text-right form-control form' value='0' readonly tabindex="-1"></td>
                                                                    <td class="billprt"><input type="checkbox" name="aprov_0" class="aprov form-control form" value="1" style="height:25px;width:25px"></td>
                                                                    <td class="billprt"><input type='date' class='form-control form firstdate' value='' name='firstdate_0'></td>
                                                                    <td class="billprt"><input type='textbox' name='aprvqty_0' class='aprvqty text-right form-control form' value='0'></td>
                                                                    <td class="billprt"><input type='textbox' name='rate_0' class='rate text-right form-control form' value='0'></td>
                                                                    <td class="billprt"><input type='textbox' name='amt_0' class='amt text-right form-control form' value='0' readonly tabindex="-1"></td>
                                                                </tr>
                                                            <?php }
                                                            ?>

                                                        </tbody>
                                                        <input type="hidden" name="treatcnt" id="treatcnt" value="<?php echo ($addflag != 1) ? $tctr : "1"; ?>">

                                                    </table>

                                                </div>
                                                <div class="row">
                                                    <div class="col-lg-1 col-md-1 col-sm-2 col-xs-2">

                                                        <button type="button" class="btn btn-primary btn-square form" id="addtreat" style="margin-top: 10px;margin-left:20px">
                                                            <i class="fa fa-plus" data-toggle='tooltip' title='Add Row'>&nbsp;&nbsp;Add More</i>

                                                        </button>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>

                                        <!-- ///////////////////  MEDICINE   ///////////////// -->

                                        <div class="tab-pane fade" id="tab4default">

                                            <div class="row table-responsive">
                                                <table class="table table-bordered" style="width: 100%">
                                                    <thead>
                                                        <tr class="mySearchTr">
                                                            <th style="width:3%"></th>
                                                            <th style="width:3%">Sr.</th>
                                                            <th style="width:40%">Medicine</th>
                                                            <th style="width:15%">Dosage</th>
                                                            <th style="width:5%" class='text-right'>No. Days</th>
                                                            <th style="width:5%" class='text-center'>Morning</th>
                                                            <th style="width:5%" class='text-center'>Night</th>
                                                        </tr>

                                                    </thead>

                                                    <!-- Laundry section starts from here -->
                                                    <tbody class="medbody">
                                                        <?php
                                                        if ($addflag != '1') {
                                                            $mdctr = 0;
                                                            $gtmdtran = mysqli_query($conn, "Select a.*,b.name from `consultmed` a left join product b
                                                                                             on a.item = b.code where a.vouchno='$get[vouchno]' order by a.srno");
                                                            if (mysqli_num_rows($gtmdtran) > 0) {

                                                                while ($rowsmd = mysqli_fetch_array($gtmdtran)) {

                                                                    $chkdt = "";
                                                                    $chknt = "";
                                                                    if ($rowsmd['daytake'] == 1) {
                                                                        $chkdt = "checked";
                                                                    }
                                                                    if ($rowsmd['ngttake'] == 1) {
                                                                        $chknt = "checked";
                                                                    }

                                                                    echo "<tr>";
                                                                    echo " <td><i class='fa fa-trash remove' style='display:none;font-size:24px'></i></td>";

                                                                    echo "<td><input type='text' class='form-control form srno' value='$rowsmd[srno]' name='srno_$mdctr'></td>";
                                                                    echo "<td>";
                                                                    echo "<input list='medicine' name='medicine_$mdctr' class='medicine form-control form ' autocomplete='off' value='$rowsmd[name]'> ";
                                                                    echo "<datalist id='medicine' char='#'>";
                                                                    echo "<option>";

                                                                    $mit2 = mysqli_query($conn, "SELECT `name` FROM `product` group by name  order by name") or die(mysqli_error($conn));

                                                                    while ($tit2 = mysqli_fetch_array($mit2)) {
                                                                        $itname2 = $tit2['name'];
                                                                        echo "<option value='$itname2'>";
                                                                    }

                                                                    echo "</datalist>";
                                                                    echo "</td>";
                                                                    echo "<td>";
                                                                    echo "<input list='dosage' name='dosage_$mdctr' class='dosage form-control form ' autocomplete='off' value='$rowsmd[dosage]' maxlength='20'> ";
                                                                    echo "<datalist id='dosage' char='#'>";
                                                                    echo "<option>";

                                                                    $mitd = mysqli_query($conn, "SELECT `dosage` FROM `consultmed` group by dosage order by dosage") or die(mysqli_error($conn));

                                                                    while ($titd = mysqli_fetch_array($mitd)) {
                                                                        $itnamed = $titd['dosage'];
                                                                        echo "<option value='$itnamed'>";
                                                                    }

                                                                    echo "</datalist>";
                                                                    echo "</td>";
                                                                    echo "<td><input type='text' class='form-control form text-right duration' value='$rowsmd[duration]' name='duration_$mdctr'></td>";
                                                                    echo "<td style='padding-left:2.5%'>";
                                                                    echo "<input type='checkbox' name='daytake_$mdctr' class='daytake form-control form' value='1' style='height:25px;width:25px' $chkdt>";
                                                                    echo "</td>";
                                                                    echo "<td style='padding-left:2.5%'>";
                                                                    echo "<input type='checkbox' name='ngttake_$mdctr' class='ngttake form-control form' value='1' style='height:25px;width:25px' $chknt>";
                                                                    echo "</td>";
                                                                    echo "</tr>";
                                                                    $mdctr++;
                                                                }
                                                            } else {
                                                                $mdctr++;
                                                                ?>
                                                                <tr>
                                                                    <td><i class='fa fa-trash remove' style="display:none;font-size: 24px"></i></td>

                                                                    <td><input type="text" class="form-control form srno" value="1" name="srno_0"></td>
                                                                    <td>
                                                                        <input list='medicine' name='medicine_0' class='medicine form-control form ' autocomplete='off' value=''>
                                                                        <datalist id='medicine' char='#'>
                                                                            <option>
                                                                                <?php
                                                                                $mit = mysqli_query($conn, "SELECT `name` FROM `product` group by name  order by name") or die(mysqli_error($conn));

                                                                                while ($tit = mysqli_fetch_array($mit)) {
                                                                                    $itname = $tit['name'];
                                                                                    echo "<option value='$itname'>";
                                                                                }
                                                                                ?>
                                                                        </datalist>
                                                                    </td>
                                                                    <td>
                                                                        <input list='dosage' name='dosage_0' class='dosage form-control form ' autocomplete='off' value=''  maxlength='20'>
                                                                        <datalist id='dosage' char='#'>
                                                                            <option>
                                                                                <?php
                                                                                $mit1 = mysqli_query($conn, "SELECT `dosage` FROM `consultmed` group by dosage order by dosage") or die(mysqli_error($conn));

                                                                                while ($tit1 = mysqli_fetch_array($mit1)) {
                                                                                    $itname1 = $tit1['dosage'];
                                                                                    echo "<option value='$itname1'>";
                                                                                }
                                                                                ?>
                                                                        </datalist>
                                                                    </td>
                                                                    <td><input type="text" class="form-control form text-right duration" value="" name="duration_0"></td>
                                                                    <td style='padding-left:2.5%'><input type="checkbox" name="daytake_0" class="daytake form-control form" value="1" style="height:25px;width:25px"></td>
                                                                    <td style='padding-left:2.5%'><input type="checkbox" name="ngttake_0" class="ngttake form-control form" value="1" style="height:25px;width:25px"></td>
                                                                </tr>
                                                                <?php
                                                            }
                                                        } else {
                                                            ?>
                                                            <tr>
                                                                <td><i class='fa fa-trash remove' style="font-size: 24px"></i></td>

                                                                <td><input type="text" class="form-control form srno" value="1" name="srno_0"></td>
                                                                <td>
                                                                    <input list='medicine' name='medicine_0' class='medicine form-control form ' autocomplete='off' value=''>
                                                                    <datalist id='medicine' char='#'>
                                                                        <option>
                                                                            <?php
                                                                            $mit = mysqli_query($conn, "SELECT `name` FROM `product` group by name order by name") or die(mysqli_error($conn));

                                                                            while ($tit = mysqli_fetch_array($mit)) {
                                                                                $itname = $tit['name'];
                                                                                echo "<option value='$itname'>";
                                                                            }
                                                                            ?>
                                                                    </datalist>
                                                                </td>
                                                                <td>
                                                                    <input list='dosage' name='dosage_0' class='dosage form-control form ' autocomplete='off' value=''  maxlength='20'>
                                                                    <datalist id='dosage' char='#'>
                                                                        <option>
                                                                            <?php
                                                                            $mit1 = mysqli_query($conn, "SELECT `dosage` FROM `consultmed` group by dosage order by dosage") or die(mysqli_error($conn));

                                                                            while ($tit1 = mysqli_fetch_array($mit1)) {
                                                                                $itname1 = $tit1['dosage'];
                                                                                echo "<option value='$itname1'>";
                                                                            }
                                                                            ?>
                                                                    </datalist>
                                                                </td>
                                                                <td><input type="text" class="form-control form text-right duration" value="" name="duration_0"></td>
                                                                <td style='padding-left:2.5%'><input type="checkbox" name="daytake_0" class="daytake form-control form" value="1" style="height:25px;width:25px"></td>
                                                                <td style='padding-left:2.5%'><input type="checkbox" name="ngttake_0" class="ngttake form-control form" value="1" style="height:25px;width:25px"></td>
                                                            </tr>
                                                        <?php }
                                                        ?>

                                                    </tbody>
                                                    <input type="hidden" name="medcnt" id="medcnt" value="<?php echo ($addflag != 1) ? $mdctr : "1"; ?>">

                                                </table>


                                            </div>

                                            <button type="button" class="btn btn-primary btn-square form" id="addmed" style="margin-top: 10px;margin-left:10px">
                                                <i class="fa fa-plus" data-toggle='tooltip' title='Add Row'>&nbsp;&nbsp;Add More</i>

                                            </button>
                                        </div>

                                        <!-- ///////////////////////////// TAB 5 ////////////////// -->
                                        <div class="tab-pane fade" id="tab5default">

                                            <div class="row hidtabpane">

                                                <div class="row table-responsive"style="padding-left:2%">

                                                    <table class="table table-bordered" style="width: 100%">
                                                        <thead>
                                                            <tr class="mySearchTr">
                                                                <th style="width:3%"></th>
                                                                <th style="width:3%">Sr.</th>
                                                                <th style="width:40%">Treatment</th>
                                                                <th style="width:5%">Schedule Date</th>
                                                                <th style="width:30%">Remarks</th>
                                                                <th style="width:5%">Completed Date</th>
                                                                <th style="width:10%">Details</th>
                                                            </tr>

                                                        </thead>

                                                        <!-- Laundry section starts from here -->
                                                        <tbody class="schedbody">
                                                            <?php
                                                            if ($addflag != '1') {
                                                                $sdctr = 0;
                                                                $rctr = 0;
                                                                $gtsched = mysqli_query($conn, "Select a.*,
                                                                                                b.name from `schedtreat` a left join treatment b
                                                                                                on a.treatment = b.code where a.vouchno='$get[vouchno]'
                                                                                                and a.treatment > 0 order by a.scheddate ASC");
                                                                if (mysqli_num_rows($gtsched) > 0) {

                                                                    while ($rowsched = mysqli_fetch_array($gtsched)) {
                                                                        $rctr++;
                                                                        $rd = "";
                                                                        $vis = "style='display:none'";

                                                                        if ($rowsched['compltdt'] != "0000-00-00") {
                                                                            $rd = "readonly";
                                                                            $vis = "";
                                                                        }
                                                                        echo "<tr>";
                                                                        echo "<td></td>";
                                                                        echo "<td><input type='text' class='form-control form srno' value='$rctr' name='srno_$sdctr'></td>";
                                                                        echo "<td>";
                                                                        echo "<select id='streatment' name='streatment_$sdctr' class='form-control streatment form' style='width:100%'>";
                                                                        echo "<option value='$rowsched[treatment]'>$rowsched[name]</option>";
                                                                        echo "</select>";
                                                                        echo "</td>";
                                                                        echo "<td><input type='date' class='form-control form scheddate' value='$rowsched[scheddate]' name='scheddate_$sdctr' $rd></td>";
                                                                        echo "<td><input type='text' class='form-control form remarks' value='$rowsched[remarks]' name='sremarks_$sdctr'></td>";
                                                                        echo "<td><input type='date' class='form-control form compltdt' value='$rowsched[compltdt]' name='compltdt_$sdctr' $rd>"
                                                                        . "<input type='hidden' class='form-control form checkin' value='$rowsched[checkin]' name='checkin_$sdctr'>"
                                                                        . "<input type='hidden' class='form-control form consult' value='$rowsched[consult]' name='consult_$sdctr'></td>";
                                                                        echo "<td><button type='button' class='treatdet form-control btn' $vis>Details</button></td>";
                                                                        echo "</tr>";
                                                                        $sdctr++;
                                                                    }
                                                                }
                                                            }
                                                            ?>
                                                        <input type="hidden" name="schedcnt" id="schedcnt" value="<?php echo ($addflag != 1) ? $sdctr : "1"; ?>">
                                                        </tbody>

                                                    </table>

                                                </div>


                                                <!--                                                <button type="button" class="btn btn-primary btn-square form" id="addtreat" style="margin-top: 10px;margin-left:20px">
                                                                                                    <i class="fa fa-plus" data-toggle='tooltip' title='Add Row'></i>
                                                                                                </button>-->


                                            </div>
                                        </div>

                                        <!-- ///////////////// TAB 6 //////////////////////// -->
                                        <div class="tab-pane fade" id="tab6default">

                                            <div class="row table-responsive" style="padding-left:1%">
                                                <div class="col-lg-7 col-md-7 col-sm-7 col-xs-7">

                                                    <table class="table table-bordered" style="width: 100%">
                                                        <thead>
                                                            <tr class="mySearchTr">
                                                                <th style="width:3%"></th>
                                                                <th style="width:3%">Sr.</th>
                                                                <th style="width:30%">Treatment</th>
                                                                <th style="width:5%" class='text-right'>Nos.</th>
                                                                <th style="width:5%" class='text-right'>Days</th>
                                                                <th style="width:7%" class='text-right'>Rate</th>
                                                                <th style="width:10%" class='text-right'>Amount</th>
                                                                <th style="width:3%" class='text-right'>App<br>rove</th>
                                                                <th style="width:5%" class=''>First Date</th>
                                                            </tr>

                                                        </thead>

                                                        <!-- Laundry section starts from here -->
                                                        <tbody class="treatbillbody">
                                                            <?php
                                                            $btctr = 0;
                                                            $bmctr = 0;
                                                            $gtsmtrant2 = mysqli_query($conn, "Select a.*,b.name from `treatbill` a left join treatment b
                                                                                             on a.treatment = b.code where a.vouchno='$get[vouchno]' order by a.srno");
                                                            if (mysqli_num_rows($gtsmtrant2) > 0) {

                                                                while ($rowsmtt2 = mysqli_fetch_array($gtsmtrant2)) {
                                                                    $bmctr++;
                                                                    $chkd = "";
                                                                    if ($rowsmtt2['aprov'] == 1) {
                                                                        $chkd = "checked";
                                                                    }

                                                                    echo "<tr class='caltreat'>";
                                                                    echo " <td><i class='fa fa-trash remove' style='display:none;font-size:24px'></i></td>";

                                                                    echo "<td><input type='text' class='form-control form srno' value='$bmctr' name='srno_$btctr'></td>";
                                                                    echo "<td>";
                                                                    echo "<input list='ftreatment' name='btreatment_$btctr' class='ftreatment form-control form ' autocomplete='off' value='$rowsmtt2[name]'> ";
                                                                    echo "<datalist id='ftreatment' char='#'>";
                                                                    echo "<option>";

                                                                    echo "</datalist>";
                                                                    echo "</td>";
                                                                    echo "<td><input type='text' class='form-control form text-right qty' value='$rowsmtt2[qty]' name='bqty_$btctr'></td>";
                                                                    echo "<td><input type='text' class='form-control form text-right duration' value='$rowsmtt2[duration]' name='bduration_$btctr'></td>";
                                                                    echo "<td><input type='textbox' name='brate_$btctr' class='rate text-right form-control form' value='$rowsmtt2[rate]' ></td>";
                                                                    echo "<td><input type='textbox' name='bamt_$btctr' class='amt text-right form-control form' value='$rowsmtt2[amt]'  readonly tabindex='-1'></td>";
                                                                    echo "<td class='text-center'>";
                                                                    echo "<input type='checkbox' name='baprov_$btctr' class='aprov form-control form' value='1' style='height:25px;width:25px' $chkd>";
                                                                    echo "</td>";
                                                                    echo "<td ><input type='date' class='form-control form firstdate' value='$rowsmtt2[firstdate]' name='bfirstdate_$btctr'></td>";
                                                                    //                                                                    echo "<td><input type='textbox' name='aprvqty_$btctr' class='aprvqty text-right form-control form' value='$rowsmtt2[aprvqty]' ></td>";
                                                                    echo "</tr>";
                                                                    $btctr++;
                                                                }
                                                            } else {
                                                                $gtsmtrant2 = mysqli_query($conn, "Select a.*,b.name,b.rate , b.grprate from `consulttreat` a left join treatment b
                                                                                             on a.treatment = b.code where a.vouchno='$get[vouchno]' order by a.srno");
                                                                if (mysqli_num_rows($gtsmtrant2) > 0) {
                                                                    $amtt = 0;
                                                                    $ratet = 0;
                                                                    while ($rowsmtt2 = mysqli_fetch_array($gtsmtrant2)) {
                                                                        $bmctr++;
                                                                        $chkd = "";
                                                                        if ($rowsmtt2['aprov'] == 1) {
                                                                            $chkd = "checked";
                                                                        }

                                                                        $ratet = $rowsmtt2['rate'];
                                                                        $amtt = $ratet * $rowsmtt2['qty'];

                                                                        echo "<tr class='caltreat'>";
                                                                        echo " <td><i class='fa fa-trash remove' style='display:none;font-size:24px'></i></td>";

                                                                        echo "<td><input type='text' class='form-control form srno' value='$bmctr' name='srno_$btctr'></td>";
                                                                        echo "<td>";
                                                                        echo "<input list='ftreatment' name='btreatment_$btctr' class='ftreatment form-control form ' autocomplete='off' value='$rowsmtt2[name]'> ";
                                                                        echo "<datalist id='ftreatment' char='#'>";
                                                                        echo "<option>";
                                                                        echo "</datalist>";
                                                                        echo "</td>";
                                                                        echo "<td><input type='text' class='form-control form text-right qty' value='$rowsmtt2[qty]' name='bqty_$btctr'></td>";
                                                                        echo "<td><input type='text' class='form-control form text-right duration' value='$rowsmtt2[duration]' name='bduration_$btctr'></td>";
                                                                        echo "<td><input type='textbox' name='brate_$btctr' class='rate text-right form-control form' value='$ratet' ></td>";
                                                                        echo "<td><input type='textbox' name='bamt_$btctr' class='amt text-right form-control form' value='$amtt'  readonly tabindex='-1'></td>";
                                                                        echo "<td class='text-center'>";
                                                                        echo "<input type='checkbox' name='baprov_$btctr' class='aprov form-control form' value='1' style='height:25px;width:25px' $chkd>";
                                                                        echo "</td>";
                                                                        echo "<td><input type='date' class='form-control form firstdate' value='$rowsmtt2[firstdate]' name='bfirstdate_$btctr'></td>";
                                                                        echo "</tr>";
                                                                        $btctr++;
                                                                    }
                                                                }
                                                            }
                                                            ?>

                                                        </tbody>
                                                        <input type="hidden" name="btreatcnt" id="btreatcnt" value="<?php echo ($addflag != 1) ? $tctr : "1"; ?>">

                                                    </table>
                                                </div>
                                            </div>
                                            <div class="row">

                                                <div class="col-lg-4 col-md-4 col-sm-8 col-xs-8  text-right">
                                                    <label class='label-control marg'>Treatment Fees</label>
                                                </div>
                                                <div class="col-lg-2 col-md-2 col-sm-3 col-xs-3">
                                                    <input type="text" class="form-control text-right form treattotal" name="treattotal" value="<?php echo ($addflag != 1) ? $get['treattotal'] : "0"; ?>">
                                                </div>
                                            </div>
                                            <div class="row">
                                                <div class="col-lg-2 col-md-2 col-sm-4 col-xs-4  text-right">
                                                    <label class="label-control marg">Treatment Discount</label>
                                                </div>
                                                <div class="col-lg-1 col-md-2 col-sm-3 col-xs-3">
                                                    <input type="text" class="form-control text-right form trdiscperc" name="trdiscperc" value="<?php echo ($addflag != 1) ? $get['trdiscperc'] : "0"; ?>">
                                                </div>
                                                <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1">
                                                    <label class="label-control marg">%</label>
                                                </div>
                                                <div class="col-lg-2 col-md-2 col-sm-3 col-xs-3">
                                                    <input type="text" class="form-control text-right form trdiscamt" name="trdiscamt" value="<?php echo ($addflag != 1) ? $get['trdiscamt'] : "0"; ?>">
                                                </div>
                                            </div>
                                            <div class="row">
                                                <div class="col-lg-2 col-md-2 col-sm-3 col-xs-3  text-right">
                                                    <?php
                                                    if ($msched <= 0) {
                                                        ?>
                                                        <button type="button" class="btn btn-primary btn-square form createsched" id="createsched" style="margin-top: 10px;margin-left:20px">
                                                            Create Schedule
                                                        </button>
                                                    <?php } ?>
                                                </div>
                                                <div class="col-lg-2 col-md-2 col-sm-3 col-xs-3  text-right">
                                                    <label class='label-control marg'>Payment Type</label>
                                                </div>
                                                <div class="col-lg-2 col-md-2 col-sm-4 col-xs-5">
                                                    <select id="trpaytype" name="trpaytype"  class="form-control form pad  select2 trpaytype" style="width:100%" >
                                                        <option value="<?php echo ($addflag != 1) ? $get["trpaytype"] : ""; ?>"><?php echo ($addflag != 1) ? $trval : ""; ?></option>
                                                        <option value='F'>Full</option>
                                                        <option value='I'>Installment</option>
                                                        <option value='E'>EMI</option>

                                                    </select>
                                                </div>
                                            </div>
                                            <div class="row text-center insttable" style="padding-left:30%">

                                                <table class="table table-bordered" style="width: 40%">
                                                    <thead>
                                                        <tr class="mySearchTr">
                                                            <th style="width:3%">Sr.</th>
                                                            <th style="width:60%">Amount</th>
                                                            <th style="width:35%" class='text-right'>Paid Date</th>
                                                        </tr>

                                                    </thead>

                                                    <!-- Laundry section starts from here -->
                                                    <tbody class="">
                                                        <?php
                                                        $ictr = 0;
                                                        $hctr = 0;
                                                        $gtinst = mysqli_query($conn, "Select * from `instalment` where vouchno='$get[vouchno]' order by srno");
                                                        if (mysqli_num_rows($gtinst) > 0) {

                                                            while ($rowisnt = mysqli_fetch_array($gtinst)) {
                                                                $colr = "";
                                                                $bgcolr = "";
                                                                if ($rowisnt['paiddate'] == "0000-00-00" && $rowisnt['amount'] > 0) {
                                                                    $colr = "color:red";
                                                                    $bgcolr = "style='background-color:#fff2cc'";
                                                                }
                                                                $hctr++;
                                                                echo "<tr $bgcolr>";
                                                                echo "<td><input type='text' class='form-control form srno' value='$hctr' name='isrno_$ictr' style='$colr'></td>";

                                                                echo "<td><input type='text' class='form-control form text-right iamt' value='$rowisnt[amount]' name='iamt_$ictr'  style='$colr'></td>";
                                                                echo "<td><input type='date' class='form-control form text-right paiddate' value='$rowisnt[paiddate]' name='paiddate_$ictr'  style='$colr'></td>";

                                                                echo "</tr>";
                                                                $ictr++;
                                                            }
                                                        } else {
                                                            $q = 0;
                                                            for ($p = 0; $p < 3; $p++) {
                                                                $q++;
                                                                echo "<tr>";
                                                                echo "<td><input type='text' class='form-control form srno' value='$q' name='isrno_$p'></td>";

                                                                echo "<td><input type='text' class='form-control form text-right mamt' value='0' name='iamt_$p'  ></td>";
                                                                echo "<td><input type='date' class='form-control form text-right paiddate' value='' name='paiddate_$p'></td>";

                                                                echo "</tr>";
                                                            }
                                                        }
                                                        ?>
                                                    </tbody>

                                                </table>
                                            </div>

                                            <div class="row" style="padding-top:1%">

                                                <div class="col-lg-7 col-md-7 col-sm-7 col-xs-7">

                                                    <table class="table table-bordered" style="width: 100%">
                                                        <thead>
                                                            <tr class="mySearchTr">
                                                                <th style="width:3%"></th>
                                                                <th style="width:3%">Sr.</th>
                                                                <th style="width:40%">Medicine</th>
                                                                <th style="width:5%" class='text-right'>Qty.</th>
                                                                <th style="width:5%" class='text-right'>Rate</th>
                                                                <th style="width:5%" class='text-right'>Amount</th>
                                                            </tr>

                                                        </thead>

                                                        <!-- Laundry section starts from here -->
                                                        <tbody class="">
                                                            <?php
                                                            $bmctr = 0;
                                                            $bmdctr = 0;
                                                            $gtmdtran = mysqli_query($conn, "Select a.*,b.name from `medbill` a left join product b
                                                                                             on a.item = b.code where a.vouchno='$get[vouchno]' order by a.srno");
                                                            if (mysqli_num_rows($gtmdtran) > 0) {

                                                                while ($rowsmd = mysqli_fetch_array($gtmdtran)) {
                                                                    $bmctr++;
                                                                    echo "<tr>";
                                                                    echo " <td><i class='fa fa-trash remove' style='display:none;font-size:24px'></i></td>";

                                                                    echo "<td><input type='text' class='form-control form srno' value='$bmctr' name='srno_$bmdctr'></td>";
                                                                    echo "<td>";
                                                                    echo "<input list='medicine' name='bmedicine_$bmdctr' class='medicine form-control form ' autocomplete='off' value='$rowsmd[name]'> ";
                                                                    echo "<datalist id='medicine' char='#'>";
                                                                    echo "<option>";
                                                                    echo "</datalist>";
                                                                    echo "</td>";
                                                                    echo "<td><input type='text' class='form-control form text-right mqty' value='$rowsmd[qty]' name='bmqty_$bmdctr'></td>";
                                                                    echo "<td><input type='text' class='form-control form text-right mrate' value='$rowsmd[rate]' name='bmrate_$bmdctr'></td>";
                                                                    echo "<td><input type='text' class='form-control form text-right mamt' value='$rowsmd[amount]' name='bmamt_$bmdctr'  readonly></td>";

                                                                    echo "</tr>";
                                                                    $bmdctr++;
                                                                }
                                                            } else {
                                                                $gtmdtran = mysqli_query($conn, "Select a.*,b.name,b.rate from `consultmed` a left join product b
                                                                                             on a.item = b.code where a.vouchno='$get[vouchno]' order by a.srno");
                                                                if (mysqli_num_rows($gtmdtran) > 0) {

                                                                    while ($rowsmd = mysqli_fetch_array($gtmdtran)) {
                                                                        $bmctr++;
                                                                        $ratem = $rowsmd['rate'];
                                                                        $amtm = $ratem * $rowsmd['qty'];

                                                                        echo "<tr>";
                                                                        echo " <td><i class='fa fa-trash remove' style='display:none;font-size:24px'></i></td>";

                                                                        echo "<td><input type='text' class='form-control form srno' value='$bmctr' name='bsrno_$bmdctr'></td>";
                                                                        echo "<td>";
                                                                        echo "<input list='medicine' name='bmedicine_$bmdctr' class='medicine form-control form ' autocomplete='off' value='$rowsmd[name]'> ";
                                                                        echo "<datalist id='medicine' char='#'>";
                                                                        echo "<option>";
                                                                        echo "</datalist>";
                                                                        echo "</td>";
                                                                        echo "<td><input type='text' class='form-control form text-right mqty' value='$rowsmd[qty]' name='bmqty_$bmdctr'></td>";
                                                                        echo "<td><input type='text' class='form-control form text-right mrate' value='$ratem' name='bmrate_$bmdctr'></td>";
                                                                        echo "<td><input type='text' class='form-control form text-right mamt' value='$rowsmd[amount]' name='bmamt_$bmdctr'  readonly></td>";

                                                                        echo "</tr>";
                                                                        $bmdctr++;
                                                                    }
                                                                }
                                                            }
                                                            ?>

                                                        </tbody>
                                                        <input type="hidden" name="bmedcnt" id="bmedcnt" value="<?php echo ($addflag != 1) ? $bmdctr : "1"; ?>">

                                                    </table>
                                                </div>
                                            </div>
                                            <div class="row">
                                                <div class="col-lg-4 col-md-4 col-sm-6 col-xs-6  text-right">
                                                    <label class='label-control marg'>Medicine Fees</label>
                                                </div>
                                                <div class="col-lg-2 col-md-2 col-sm-4 col-xs-5">
                                                    <input type="text" class="form-control text-right form medtotal" name="medtotal" value="<?php echo ($addflag != 1) ? $get['medtotal'] : "0"; ?>" readonly >
                                                </div>
                                            </div>
                                            <div class="row">
                                                <div class="col-lg-2 col-md-2 col-sm-4 col-xs-4  text-right">
                                                    <label class="label-control marg">Medicine Discount</label>
                                                </div>
                                                <div class="col-lg-1 col-md-2 col-sm-1 col-xs-1">
                                                    <input type="text" class="form-control text-right form meddiscperc" name="meddiscperc" value="<?php echo ($addflag != 1) ? $get['meddiscperc'] : "0"; ?>">
                                                </div>
                                                <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1">
                                                    <label class="label-control marg">%</label>
                                                </div>
                                                <div class="col-lg-2 col-md-2 col-sm-4 col-xs-5">
                                                    <input type="text" class="form-control text-right form meddiscamt" name="meddiscamt" value="<?php echo ($addflag != 1) ? $get['meddiscamt'] : "0"; ?>">
                                                </div>
                                            </div>


                                            <div class="row" style="padding-top:1%">
                                                <div class="col-lg-4 col-md-4 col-sm-6 col-xs-6  text-right">
                                                    <label class='label-control marg'>Consulting Fees</label>
                                                </div>
                                                <div class="col-lg-2 col-md-2 col-sm-4 col-xs-5">
                                                    <input type="text" class="form-control text-right form consultfees" name="consultfees" value="<?php echo ($addflag != 1) ? $get['consultfees'] : "0"; ?>">
                                                </div>
                                            </div>
                                            <div class="row">
                                                <div class="col-lg-4 col-md-4 col-sm-6 col-xs-6  text-right">
                                                    <label class='label-control marg'>Treatment Fees</label>
                                                </div>
                                                <div class="col-lg-2 col-md-2 col-sm-4 col-xs-5">
                                                    <input type="text" class="form-control text-right form newamount" name="ttamount" value="<?php echo ($addflag != 1) ? $get['ttamount'] : "0"; ?>" readonly>
                                                </div>
                                            </div>
                                            <div class="row">
                                                <div class="col-lg-4 col-md-4 col-sm-6 col-xs-6  text-right">
                                                    <label class='label-control marg'>Medicine Fees</label>
                                                </div>
                                                <div class="col-lg-2 col-md-2 col-sm-4 col-xs-5">
                                                    <input type="text" class="form-control text-right form tmedamount" name="tmedamount" value="<?php echo ($addflag != 1) ? $get['tmedamount'] : "0"; ?>" readonly>
                                                </div>
                                            </div>

                                            <div class="row">
                                                <div class="col-lg-4 col-md-4 col-sm-6 col-xs-6  text-right">
                                                    <label class='label-control marg'>Sub Total</label>
                                                </div>
                                                <div class="col-lg-2 col-md-2 col-sm-4 col-xs-5">
                                                    <input type="text" class="form-control text-right form subtot" name="subtot" value="<?php echo ($addflag != 1) ? $get['subtot'] : "0"; ?>" readonly>
                                                </div>
                                            </div>
                                            <div class="row">
                                                <div class="col-lg-4 col-md-4 col-sm-6 col-xs-6  text-right">
                                                    <label class='label-control marg'>Discount</label>
                                                </div>
                                                <div class="col-lg-2 col-md-2 col-sm-4 col-xs-5">
                                                    <input type="text" class="form-control text-right form discamt" name="discamt" value="<?php echo ($addflag != 1) ? $get['discamt'] : "0"; ?>" readonly>
                                                </div>
                                            </div>
                                            <div class="row">
                                                <div class="col-lg-4 col-md-4 col-sm-6 col-xs-6  text-right">
                                                    <label class='label-control marg' style="color:green;font-size: 20px">Total Amount</label>
                                                </div>
                                                <div class="col-lg-2 col-md-2 col-sm-4 col-xs-5">
                                                    <input type="text" class="form-control text-right form billamt" style="color:green;font-size: 22px" name="billamt" value="<?php echo ($addflag != 1) ? $get['billamt'] : "0"; ?>" readonly>
                                                </div>
                                            </div>
                                            <div class="row">
                                                <div class="col-lg-4 col-md-4 col-sm-6 col-xs-6  text-right">
                                                    <label class='label-control marg' style="color:blue;font-size: 20px"><a target="_blank" href="ledger_fr.php?view=1&fdt=<?= $get['vouchdt'] ?>&acc=<?= $get['accode'] ?>">Paid Amount</a></label>
                                                </div>
                                                <div class="col-lg-2 col-md-2 col-sm-4 col-xs-5">
                                                    <input type="text" class="form-control text-right form paidamt" style="color:blue;font-size: 20px" name="paidamt" value="<?php echo ($addflag != 1) ? $paidamt : "0"; ?>" readonly>
                                                </div>
                                                <a id='addnewpay' class="btn btn-pad btn-square " style="background-color:#629584;" href="#">Add Payment
                                                    <i class="fa fa-dollar" style="color:#ffffff"></i>
                                                </a>
                                            </div>
                                            <div class="row">
                                                <div class="col-lg-4 col-md-4 col-sm-6 col-xs-6  text-right">
                                                    <label class='label-control marg' style="color:red;font-size: 20px">Balance</label>
                                                </div>
                                                <div class="col-lg-2 col-md-2 col-sm-4 col-xs-5">
                                                    <input type="text" class="form-control text-right form balamt" style="color:red;font-size: 22px" name="balamt" value="<?php echo ($addflag != 1) ? $fbalamt : "0"; ?>" readonly>
                                                </div>
                                            </div>
                                            <div class="row">
                                                <div class="col-lg-4 col-md-4 col-sm-6 col-xs-6  text-right">
                                                    <label class='label-control marg'>Invoice Date</label>
                                                </div>
                                                <div class="col-lg-2 col-md-2 col-sm-4 col-xs-5">
                                                    <input type="date" class="form-control form invdt" name="invdt" value="<?php echo ($addflag != 1) ? $get['invdt'] : ""; ?>">
                                                </div>
                                                <!-- Estimate -->
                                                <!-- <div class=" buttonform tooltip-bottom" id="billingpdf" style="display: <? echo $printdisabled ?>" data-toggle="tooltip" data-placement="top" title="" data-original-title="pdf"> -->
                                                <a id='invprint' class="btn btn-pad btn-square " style="background-color:#798645;" href="<?= "consultation_pdf.php" ?>?vouchno=<?= $get["vouchno"]; ?>" target="_blank">Invoice Pdf
                                                    <i class="fa fa-file-pdf-o" style="color:#ffffff"></i>
                                                </a>
                                                <!-- Invoice -->
                                                <a id='estprint' class="btn btn-pad btn-square " style="background-color:#629584;" href="<?= "consultation_pdf.php?para=E" ?>&vouchno=<?= $get["vouchno"]; ?>" target="_blank">Estimate Pdf
                                                    <i class="fa fa-file-pdf-o" style="color:#ffffff"></i>
                                                </a>
                                                <!-- </div> -->
                                            </div>
                                        </div>
                                        <!-- ////////////////////// TAB 7 /////////////// -->
                                        <div class="tab-pane fade  in" id="tab7default">
                                            <div class="row">
                                                <div class="col-lg-2 col-md-2 col-sm-4 col-xs-4 text-right pad">
                                                    <label class="label-control marg">Image (Before)</label>
                                                </div>
                                                <div class="col-lg-4 col-md-5 col-sm-5 col-xs-5 pad">
                                                    <input type="file" class="btn btn-warning form imgbef" name="imgbef" id="imgbef">
                                                </div>
                                                <div class="col-lg-2 col-md-2 col-sm-4 col-xs-4 text-right pad">
                                                    <label class="label-control marg">Image (After)</label>
                                                </div>
                                                <div class="col-lg-4 col-md-5 col-sm-5 col-xs-5 pad">
                                                    <input type="file" class="btn btn-warning form imgaft" name="imgaft" id="imgaft">
                                                </div>
                                            </div>
                                            <div class="row">
                                                <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right pad"></div>
                                                <div class="col-lg-4 col-md-5 col-sm-5 col-xs-5 pad">
                                                    <img class="view1" src="<?php echo ($addflag != 1) ? $get['imgbef'] : '' ?>" style="width: 250px; height: 180px;" alt="Image 1" />
                                                </div>
                                                <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right pad"></div>
                                                <div class="col-lg-4 col-md-5 col-sm-5 col-xs-5 pad">
                                                    <img class="view2" src="<?php echo ($addflag != 1) ? $get['imgaft'] : '' ?>" style="width: 250px; height: 180px;" alt="Image 2" />
                                                </div>
                                            </div>
                                            <hr>
                                            <div class="row">
                                                <div class="col-lg-2 col-md-2 col-sm-4 col-xs-4 text-right pad">
                                                    <label class="label-control marg">Consent PDF</label>
                                                </div>
                                                <div class="col-lg-4 col-md-5 col-sm-5 col-xs-5 pad">
                                                    <input type="file" class="btn btn-warning form conpdf" accept=".pdf" name="conpdf" id="conpdf">
                                                </div>

                                                <div class="col-lg-4 col-md-5 col-sm-5 col-xs-5 text-center pad">
                                                    <i class='fa fa-4x fa-file-pdf-o visapdf' style="color: #c1121f;" data-pdf-url="<?php echo $get['consentpdf'] ?>"></i>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-2 col-md-2 col-sm-2 col-xs-2 text-right pad">
                                <label class="label-control marg">Notes</label>
                            </div>
                            <div class="col-lg-8 col-md-6 col-sm-9 col-xs-9 pad">
                                <input type="text" class="form-control form notes1" name="notes1" value="<?php echo ($addflag != 1) ? $get["notes1"] : ""; ?>">
                                <input type="text" class="form-control form notes2" name="notes2" value="<?php echo ($addflag != 1) ? $get["notes2"] : ""; ?>">
                                <input type="text" class="form-control form notes3" name="notes3" value="<?php echo ($addflag != 1) ? $get["notes3"] : ""; ?>">
                                <input type="text" class="form-control form notes4" name="notes4" value="<?php echo ($addflag != 1) ? $get["notes4"] : ""; ?>">
                            </div>
                        </div>
                    </div>

                    <div class="modal fade" id="pdfModal" tabindex="-1" aria-labelledby="pdfModalLabel" aria-hidden="true">
                        <div class="modal-dialog modal-lg">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <h5 class="modal-title" id="pdfModalLabel">PDF Viewer <i class="fa fa-trash closeModal" style="float: right;"></i></h5>
                                </div>
                                <div class="modal-body">
                                    <iframe id="pdfFrame" src="" width="100%" height="500px"></iframe>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class=" panel-footer col-lg-12">


                        <?php include("includes/buttons.php"); ?>

                    </div>
                </div>
            </div>

            <div class="modal fade addpayModal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
                <div class="modal-dialog modal-lg">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button class="close" data-dismiss="modal"><span>&times;</span></button>
                            <h4 class="modal-title" id="myLargeModalLabel"><? echo "&nbsp;&nbsp;"; ?></h4>
                        </div>
                        <div class="modal-body">
                            <div class="row">
                                <div class="col-lg-3 col-md-3 col-sm-4 col-xs-4 text-right">
                                    <label class="control-label">Payment Date</label>
                                </div>
                                <div class="col-lg-2 col-md-2 col-sm-4 col-xs-4 pad"> 
                                    <input type="date" name="paydate" id="paydate" value="<?php echo date("Y-m-d"); ?>" class="form-control paydate" >
                                </div>
                            </div>
                            <div class="row">

                                <div class="col-lg-3 col-md-3 col-sm-4 col-xs-4 text-right">
                                    <label class="label-control">Bank / Cash Name</label>
                                </div>
                                <div class="col-lg-6 col-md-6 col-sm-7 col-xs-7   pad "> 
                                    <select id="bankname" name="bankname"  class="form-control pad  select2 bankname" style="width:100%" >
                                        <option value=''></option>
                                        <?php
                                        $mown1 = mysqli_query($conn, "SELECT accode, `name` FROM `accmast` where `grpcode` = '002' or grpcode = '001'") or die(mysqli_error($conn));
                                        while ($trow1 = mysqli_fetch_array($mown1)) {
                                            echo "<option value='$trow1[accode]'>$trow1[name]</option>";
                                        }
                                        ?>
                                    </select>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-lg-3 col-md-3 col-sm-4 col-xs-4 text-right">
                                    <label class="control-label">Amount</label>
                                </div>
                                <div class="col-lg-2 col-md-2 col-sm-4 col-xs-4 pad"> 
                                    <input type="text" name="recvamt" id="recvamt" placeholder="Amount" text-right value="0" class="form-control text-right numeric recvamt" >
                                    <input type="hidden" name="party" id="party"  value="<?php echo ($addflag != 1) ? $get["accode"] : "$accodet"; ?>" class="form-control party"  >
                                </div> 
                            </div>
                            <div class="row">
                                <div class="col-xs-12 text-right search-action-bar">
                                    <input type="button"  class="btn btn-primary savdep" value="SAVE">
                                    <!--<input type="button"  class="btn btn-primary snext" value="Next">-->
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="modal fade detTreatModal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
                <div class="modal-dialog modal-lg">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button class="close" data-dismiss="modal"><span>&times;</span></button>
                            <h4 class="modal-title" id="myLargeModalLabel"><? echo "&nbsp;&nbsp;"; ?></h4>
                        </div>
                        <div class="modal-body dettreatment">

                        </div>
                    </div>
                </div>
            </div>
            <div class="modal fade schedModal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
                <div class="modal-dialog modal-lg">
                    <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 <? echo $formname; ?></h4>
                        </div>
                        <div class="modal-body table-responsive">
                            <table class="table table-bordered" style="width: 100%">
                                <thead>
                                    <tr class="mySearchTr">
                                        <th style="width:3%"></th>
                                        <th style="width:3%">Sr.</th>
                                        <th style="width:40%">Treatment</th>
                                        <th style="width:5%">Schedule Date</th>
                                        <th style="width:30%">Remarks</th>
                                        <th style="width:5%">Completed Date</th>
                                    </tr>

                                </thead>

                                <!-- Laundry section starts from here -->
                                <tbody class="nschedbody">
                                </tbody>


                            </table>

                        </div>
                    </div>
                </div>
            </div>


    </form>
    <div class="modal fade custModal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
        <div class="modal-dialog modal-lg">
            <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 <? echo $formname; ?></h4>
                </div>
                <div class="modal-body">
                    <input type="hidden" value="<?php echo $para ?>" class="form-control mpara">
                    <input type="hidden" value="<?php echo $get['vouchno']; ?>" class="form-control vouchno">
                    <input type="hidden" value="<?php echo $file ?>" class="form-control file">

                    <div class="row">
                        <div class="col-lg-1"></div>
                        <div class="col-lg-2">
                            <select class="form-control  ifield" style="border: 2px solid #0b4c78;border-radius:7px">
                                <option value="1">Name</option>
                                <option value="2">Surname</option>
                                <option value="3">Mobile</option>
                            </select>
                        </div>
                        <div class="col-lg-2">
                            <select class="form-control  ioperator" style="border: 2px solid #0b4c78;border-radius:7px">
                                <option value="">Search Type</option>
                                <option value="%">Like</option>
                                <option value="=">Exactly</option>
                            </select>
                        </div>
                        <div class="col-lg-4">
                            <input type="text" value="" class="form-control isearch" style="border: 2px solid #0b4c78;border-radius:7px">
                        </div>
                        <div class="col-lg-2">
                            <input type="button" class="btn btn-primary iload" value="Search" style="height: 30px;border: 2px solid #0b4c78">
                        </div>
                    </div>

                    <div class="col-lg-12 iloader text-center">
                        <img src="images/search.gif" alt="loading">
                    </div>
                    <div class="col-lg-12 inoRecord 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="23%">Full Name</th>
                                    <th width="10%">Surname</th>
                                    <th width="12%">City</th>
                                    <th width="8%">Mobile</th>
                                    <th width="10%">Aadhaar </th>
                                    <th width="10%">PAN</th>
                                </tr>
                            </thead>
                            <tbody class="iTbody">
                            </tbody>
                        </table>
                    </div>
                    <div class="row">
                        <div class="col-xs-12 text-right search-action-bar">
                            <input type="button" class="btn btn-primary iprevious" value="Previous">
                            <input type="button" class="btn btn-primary inext" value="Next">
                        </div>
                    </div>
                </div>
                <div class="modal-footer"></div>
            </div>
        </div>
    </div>


    <div class="modal fade bs-example-modal-lg searchModal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel">
        <div class="modal-dialog modal-lg">
            <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 <? echo $formname; ?></h4>
                </div>
                <div class="modal-body">
                    <div class="row">
                        <div class="col-lg-2">
                            <select class="form-control sfield">
                                <option value="1">Voucher No</option>
                                <option value="2">Date</option>
                                <option value="3">Name</option>
                                <option value="4">Gender</option>
                                <option value="5">Mobile</option>
                                <option value="6">Email</option>
                                <option value="7">Diagnosis</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">Voucher No</option>
                                <option value="2">Date</option>
                                <option value="3">Name</option>
                                <option value="4">Gender</option>
                                <option value="5">Mobile</option>
                                <option value="6">Email</option>
                                <option value="7">Diagnosis</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="7%">Voucher</th>
                                    <th width="8%">Date</th>
                                    <th width="15%">Name</th>
                                    <th width="20%">Gender</th>
                                    <th width="8%">Mobile</th>
                                    <th width="14%">Email</th>
                                    <th width="14%">Diagnosis</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>
    <?php include("includes/linksfoot.php"); ?>
</body>

</html>