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

$formname = 'Invoice';
$maindb = 'invmain';
$trandb = 'invtran';

$printfile = "invoice_print.php";
$file = 'invoice.php';
$keyfld = "vouchno";

$admin = $_SESSION["admin_" . $dbname];
$zdb = $_SESSION["zdbyear_" . $dbname];
$myyear = $_SESSION[$myyear];
//browse($myyear);
$compcd = $_SESSION["comp_" . $dbname];
$zroot = $_SESSION["zdir"];

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

if (isset($_POST["emailbut"])) {
//    $name = ($_POST["name"]);
//    $cdate = Date("Y-m-d");
//    $email = ($_POST["email"]);
//    $sub = ($_POST["subject"]);
//    $mess = ($_POST["message"]);
//    $mobile = ($_POST["mobile"]);
//    $to = "arish850@gmail.com";
//    $subject = "ENQUIRY FROM  WEBSITE";
//    $message = 'Name:    ' . $name . "\r\n" .
//            'Date:    ' . $cdate . "\r\n" .
//            'Email:   ' . $email . "\r\n" .
//            'Subject: ' . $sub . "\r\n" .
//            'Message: ' . $mess . "\r\n" .
//            'Mobile:  ' . $mobile;
//    $message .= '<html><body>';
//    $message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
//    $message .= "<tr style='background: #eee;'><td><strong>Click Here</strong> </td><td>" . www . apps4real . com / epiweb / index . php . "</td></tr>";
//    $message .= "</table>";
//    $message .= "</body></html>"; 

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

    $dcode = "";

    for ($i = 0; $i < $clen; $i++) {
        $c1 = substr($convmsp, $i, 1);
        $getmsp = mysqli_query($conn, "Select * from $zroot.msp where no = '$c1'") or die(mysqli_error($conn));
        $fetmsp = mysqli_fetch_array($getmsp);
        $codmsp = $fetmsp['code'];
        $dcode = $dcode . $codmsp;
    }

    $convmsp2 = (string) $myyear;
    $clen2 = strlen($convmsp2);

    $dcode2 = "";

    for ($i2 = 0; $i2 < $clen2; $i2++) {
        $c12 = substr($convmsp2, $i2, 1);
        $getmsp2 = mysqli_query($conn, "Select * from $zroot.msp where no = '$c12'") or die(mysqli_error($conn));
        $fetmsp2 = mysqli_fetch_array($getmsp2);
        $codmsp2 = $fetmsp2['code'];
        $dcode2 = $dcode2 . $codmsp2;
    }

//    $convmsp2 = (string) $dcode;
//browse($dcode);

    $mmail = mysqli_query($conn, "SELECT * FROM `$maindb` WHERE $keyfld='$getvouch'") or die(mysqli_error($conn));
    $mget = mysqli_fetch_array($mmail);
    $accode = $mget['accode'];
//    browse($accode);

    $mfschool = mysqli_query($conn, "SELECT * FROM `accmast` WHERE accode='$accode'") or die(mysqli_error($conn));
    $mgschool = mysqli_fetch_array($mfschool);

    $emailid = $mgschool['email'];
    browse($emailid);
//    $emailid = 'arish850@gmail.com';
    if ($emailid == '') {
        browse('Please Enter Email Address For This School in Masters');
    } else {
        $from = "rajcomputers@hotmail.com";
        $to = $emailid;
        $subject = 'INVOICE FROM MAHARASHTRA BHARATEEYA SHIKSHAN MANDAL';
//        $headers = "From: " . strip_tags($_POST['req-email']) . "\r\n";
        $headers = "From: MBSM\r\n";
        $headers .= "MIME-Version: 1.0\r\n";
        $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

        $message  = 'Reply at :mbsmandal@gmail.com';
        $message .= '<html><body>';
        $message .= '<h1></h1>';
        $message .= '</body></html>';

        $message .= '<html><body>';

        $message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
        $message .= "<tr style='background: #eee;'><td><strong>Name:</strong> </td><td>" . 'MAHARASHTRA BHARATEEYA SHIKSHAN MANDAL' . "</td></tr>";

//        $message .= "<tr><td><strong>COPY LINK TO DOWNLOAD OR PRINT INVOICE:</strong> </td><td>" . 'http://apps4real.com/epiweb/invoice_print_mail.php?v_qx_a=' . 'siez' . '&yr_i=' . 'nddl' . '&v_qx_n=' . $dcode . '&yr_f=' . $dcode2 . '&v_qx_o=' . 'sief' . '&yr_u=' . 'mkln' . "</td></tr>";
        $message .= "<tr><td><strong>COPY LINK TO DOWNLOAD OR PRINT INVOICE:</strong> </td><td><a href='http://apps4real.com/epiweb/invoice_print_mail.php?v_qx_a=siez&yr_i=nddl&v_qx_n=$dcode&yr_f=$dcode2&v_qx_o=sief&yr_u=mkln'>Click To View Invoice</a></td></tr>";
        $addURLS = $_POST['addURLS'];
        if (($addURLS) != '') {
            $message .= "<tr><td><strong>URL To Change (additional):</strong> </td><td>" . strip_tags($addURLS) . "</td></tr>";
        }
        $curText = htmlentities($_POST['curText']);
        if (($curText) != '') {
            $message .= "<tr><td><strong>CURRENT Content:</strong> </td><td>" . $curText . "</td></tr>";
        }

        $message .= "</table>";
        $message .= "</body></html>";

        mail($to, $subject, $message, $headers);
        browse('Mail Send');
    }
}
if (isset($_POST["submit"])) {
    $a = 1;
    $vouchdt = $_POST["vouchdt"];
    $code = $_POST["code"];
    $school = $_POST["school"];
    $medium = $_POST["medium"];
    $exam = $_POST["exam"];
    $section = $_POST["section"];
    $session = $_POST["session"];
    $nopack = $_POST["nopack"];
    $packrate = $_POST["packrate"];
    $packamt = $_POST["packamt"];
    $rem1 = $_POST["remark"];
    $rem2 = $_POST["remark2"];
    $parcno = $_POST["parcno"];
    $stamt = $_POST["stamt"];
    $other = $_POST["other"];
    $otheramt = $_POST["otheramt"];
    $subtotal = $_POST["subtotal"];
    $billamt = $_POST["billamt"];

    $bamtinwds = rsword($billamt);


    $count = $_POST["items"];
    $count2 = $_POST["items2"];
    $count3 = $_POST["items3"];

    $mvouch = $qvouch;


    if ($a == 1) {
        mysqli_query($conn, "LOCK TABLES `$maindb` WRITE, `$trandb` WRITE, `actran` WRITE,`subject` WRITE") or die(mysqli_error($conn));

        ########### ACTRAN########## 
        $source = 'SL';

        ### FOR  SALE #####
        $svouchno = $newvouch;
        $strnno = '001';
        $accode = '015';
        $sgrpcode = '005';
        mysqli_query($conn, "DELETE FROM `actran` WHERE `vouchno`='$mvouch'") or die(mysqli_error($conn));

        mysqli_query($conn, "INSERT INTO `actran`(`vouchno`, `vouchdt`, `date`, `trnno`, `accode`, `grpcode`, `amount`,`source`)
                VALUES ('$mvouch', '$vouchdt', '$vouchdt', '$strnno', '$accode', '$sgrpcode',  '$billamt', '$source')") or die(mysqli_error($conn));

        ### for party #####
        $trnno = '002';
        $grpcode = '010';
        $amount = $billamt * -1;

        mysqli_query($conn, "INSERT INTO `actran`(`vouchno`, `vouchdt`, `date`, `trnno`, `accode`, `grpcode`, `amount`,`source`)
                VALUES ('$mvouch', '$vouchdt', '$vouchdt', '$trnno', '$school', '$grpcode',  '$amount', '$source')") or die(mysqli_error($conn));

#################################TRAN PART #################################



        mysqli_query($conn, "DELETE FROM `$trandb` WHERE `vouchno`='$mvouch' and `section`='P'") or die(mysqli_error($conn));

        $cntr = 0;
        for ($j = 0; $j < $count; $j++) {

            $srno = $_POST["srno_$j"];
            $subject = $_POST["subject_$j"];

            $first = $_POST["first_$j"];
            $rt1 = $_POST["rt1_$j"];

            $second = $_POST["second_$j"];
            $rt2 = $_POST["rt2_$j"];

            $third = $_POST["third_$j"];
            $rt3 = $_POST["rt3_$j"];

            $fourth = $_POST["fourth_$j"];
            $rt4 = $_POST["rt4_$j"];

            $amount = $_POST["amount_$j"];


            $query = "SELECT  `code`, `name` FROM `subject` WHERE `name`='$subject'";
            $result = mysqli_query($conn, $query)or die(mysqli_error($conn));
            $r = mysqli_fetch_assoc($result);
            $subcode = $r['code'];

            if (!empty($subject)) {
                $cntr++;

                mysqli_query($conn, "INSERT INTO `$trandb`(`vouchno`,`vouchdt`, `srno`, `subjcode`, `subjname`,`pq1`, `rt1`,
                                                   `pq2`, `rt2`, `pq3`, `rt3`, `pq4`, `rt4`, `amount`,`section`)
                VALUES ('$mvouch', '$vouchdt', '$cntr', '$subcode', '$subject',  '$first','$rt1', '$second', '$rt2',
                         '$third', '$rt3', '$fourth','$rt4', '$amount','P')") or die(mysqli_error($conn));
            }
        }

        #################################TRAN PART 3 #################################

        mysqli_query($conn, "DELETE FROM `$trandb` WHERE `vouchno`='$mvouch' and `section`='S'") or die(mysqli_error($conn));

        $cntr2 = 0;
        for ($k = 0; $k < $count2; $k++) {
            $srno2 = $_POST["srno2_$k"];
            $subject2 = $_POST["subject2_$k"];

            $fifth = $_POST["fifth_$k"];
            $rt5 = $_POST["rt5_$k"];

            $sixth = $_POST["sixth_$k"];
            $rt6 = $_POST["rt6_$k"];

            $seventh = $_POST["seventh_$k"];
            $rt7 = $_POST["rt7_$k"];

            $eight = $_POST["eight_$k"];
            $rt8 = $_POST["rt8_$k"];

            $ninth = $_POST["ninth_$k"];
            $rt9 = $_POST["rt9_$k"];

            $tenth = $_POST["tenth_$k"];
            $rt10 = $_POST["rt10_$k"];

            $amount2 = $_POST["amount2_$k"];

            $query2 = "SELECT  `code`, `name` FROM `subject` WHERE `name`='$subject2'";
            $result2 = mysqli_query($conn, $query2)or die(mysqli_error($conn));
            $r2 = mysqli_fetch_assoc($result2);
            $subcode2 = $r2['code'];



            if (!empty($subject2)) {
                $cntr2++;
                mysqli_query($conn, "INSERT INTO `$trandb`(`vouchno`, `vouchdt`, `srno`, `subjcode`, `subjname`, `pq5`,`rt5`,
                                                    `pq6`,`rt6`, `pq7`,`rt7`, `pq8`,`rt8`, `pq9`,`rt9`, `pq10`,`rt10`,`amount`,`section`)
                            VALUES ('$mvouch', '$vouchdt', '$cntr2', '$subcode2', '$subject2', '$fifth','$rt5', 
                           '$sixth', '$rt6', '$seventh', '$rt7', '$eight', '$rt8', '$ninth', '$rt9', '$tenth', '$rt10','$amount2','S')") or die(mysqli_error($conn));
            }
        }

        mysqli_query($conn, "DELETE FROM `$trandb` WHERE `vouchno`='$mvouch' and `section`='M'") or die(mysqli_error($conn));

        $cntr3 = 0;
        for ($i = 0; $i < $count3; $i++) {
            $srno3 = $_POST["srno3_$i"];
            $subject3 = $_POST["subject3_$i"];

            $pqrelm = $_POST["pqrelm_$i"];
            $rtprelm = $_POST["rtprelm_$i"];

            $amount3 = $_POST["amount3_$i"];

            $query3 = "SELECT  `code`, `name` FROM `subject` WHERE `name`='$subject3'";
            $result3 = mysqli_query($conn, $query3)or die(mysqli_error($conn));
            $r3 = mysqli_fetch_assoc($result3);
            $subcode3 = $r['code'];

            if (!empty($subject3)) {
                $cntr3++;
                mysqli_query($conn, "INSERT INTO `$trandb`(`vouchno`, `vouchdt`,`srno`, `subjcode`, `subjname`,`pqrelm`, `rtprelm`,`amount`,`section`)
                            VALUES ('$mvouch', '$vouchdt', '$cntr3', '$subcode3', '$subject3', '$pqrelm', '$rtprelm', '$amount3','M')") or die(mysqli_error($conn));
            }
        }

#################################TRAN PART END #################################
############################## MAIN ######################################################
        if ($addflag == 1) {
            mysqli_query($conn, "INSERT INTO `$maindb`(`vouchno`, `year`,`vouchdt`, `billno`,`accode`, `custcode`, `medmcode`,
                                               `examcode`, `section`, `session`,`nopack`,`rem1`,`rem2`, `parcno`,`stamt`,
                                               `other`,`otheramt`,`rsword`,`genflag`,`billamt`,`packamt`,`packrate`,`subtotal`,`manual`
                                     VALUES ($qvouch, '$myyear','$vouchdt', '$qvouch','$school', '$code', '$medium', 
                                            '$exam', '$section', '$session', '$nopack','$rem1','$rem2', '$parcno',
                                             '$stamt','$other','$otheramt','$bamtinwds','M','$billamt','$packamt','$packrate','$subtotal','1')") or die(mysqli_error($conn));

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

            mysqli_query($conn, "UPDATE `$maindb` SET `vouchno`='$mvouch', `billno`='$mvouch',`vouchdt`='$vouchdt', `accode`='$school', `custcode`='$code',
                        `medmcode`='$medium', `examcode`='$exam', `section`='$section', `session`='$session',
                        `nopack`='$nopack',`rem1`='$rem1', `rem2`='$rem2', `parcno`='$parcno', `stamt`='$stamt', `other`='$other',
                        `otheramt` = '$otheramt', `rsword`='$bamtinwds', `billamt`='$billamt', `genflag`='M', `packamt`='$packamt',`subtotal`='$subtotal',
                        `packrate`='$packrate' WHERE `vouchno`= '$mvouch' ") or die(mysqli_error($conn));
            updmess();
            header("refresh: 1; $file?$keyfld=$mvouch&mode=edit");
        }
        mysqli_query($conn, "UNLOCK TABLES");
    }
}

if ($addflag != 1) {

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

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

    $fschool = mysqli_query($conn, "SELECT * FROM `accmast` WHERE accode='$get[accode]'") or die(mysqli_error($conn));
    $gschool = mysqli_fetch_array($fschool);

    $fmed = mysqli_query($conn, "SELECT * FROM `medium` WHERE code='$get[medmcode]'") or die(mysqli_error($conn));
    $gmed = mysqli_fetch_array($fmed);

    $fexm = mysqli_query($conn, "SELECT * FROM `exam` WHERE code='$get[examcode]'") or die(mysqli_error($conn));
    $gexm = mysqli_fetch_array($fexm);
}
$senable = "";
$cenable = "";

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

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

    $delcond1 = " source = 'SL' and vouchno = '$_GET[vouchno]' ";
    delnew($zdb, "actran", "$delcond1", "$file?mode=last");
}

include("includes/linkshead.php");
?>
<script src="MyScript/school.js" type="text/javascript"></script>
<script src="MyScript/invoice.js" type="text/javascript"></script>
<script src="MyScript/invoice_search.js" type="text/javascript"></script>
<style>
    .colr{
        border: 1px solid red;
    }
    input[type=number]::-webkit-inner-spin-button, 
    input[type=number]::-webkit-outer-spin-button { 
        -webkit-appearance: none; 
        margin: 0; 
    }
</style>
</head>
<body>
    <form action='' method='POST'>
        <!-- Default box -->
        <div  class="row">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12  pad">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <div class="row">
                            <div class="col-lg-11 col-md-1">
                                <h3 class="panel-title" style="color:inherit"><?php Echo $formname; ?></h3>
                            </div>
                            <div class="col-lg-1 col-md-1">
                                <input type="button" class="btn btn proceed form" style="color: white;background-color: #6082BF" value="Proceed">
                            </div>
                        </div>
                    </div>
                    <div class="panel-body">
                        <div class="row">
                            <div class="col-lg-1 col-md-1 col-sm-1 col-xs- text-right pad">
                                <label class="label-control marg">Bill No.</label>
                            </div>
                            <div class="col-lg-1 col-md-1 col-sm-8 col-xs-8 pad">
                                <input type="text" class="form-control text-size form vouchno" name="vouchno" value="<?php Echo ($addflag != 1) ? $get["vouchno"] : " $qvouch"; ?>" readonly>
                            </div>
                            <div class="col-lg-1 col-md-2 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Date</label>
                            </div>
                            <div class="col-lg-2 col-md-5 col-sm-8 col-xs-8 pad">
                                <input type="date" class="form-control form"  name="vouchdt" value="<?php Echo ($addflag != 1) ? $get["vouchdt"] : date('Y-m-d'); ?>" autofocus>
                            </div>
                            <div class="col-lg-1 col-md-2 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg" style="color: #6082BF;">Code</label>
                            </div>
                            <div class="col-lg-1 col-md-2 col-sm-8 col-xs-8 pad">
                                <input type="text" class="form-control form scode"  name="code" value="<?php Echo ($addflag != 1) ? $get["custcode"] : '' ?>">
                            </div>
                            <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg" style="color: #6082BF;">School</label>
                            </div>
                            <div class="col-lg-3 col-md-6 col-sm-8 col-xs-8 pad">
                                <select class="form-control form select2 school"  name="school" style="width: 100%">
                                    <option value="<?php Echo ($addflag != 1) ? $gschool["accode"] : ""; ?>"><?php Echo ($addflag != 1) ? $gschool["name"] : ""; ?></option>
                                    <?php
                                    $gschl = mysqli_query($conn, "SELECT * FROM `accmast` where `grpcode`='010' order by name")or die(mysqli_error($conn));
                                    while ($fschl = mysqli_fetch_array($gschl)) {
                                        Echo "<option value='$fschl[accode]'>$fschl[name]</option>";
                                    }
                                    ?>
                                </select>
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Medium</label>
                            </div>
                            <div class="col-lg-1 col-md-2 col-sm-8 col-xs-8 pad">
                                <select class="form-control form select2 medium"  name="medium" style="width: 100%">
                                    <option value="<?php Echo ($addflag != 1) ? $gmed["code"] : ""; ?>"><?php Echo ($addflag != 1) ? $gmed["name"] : ""; ?></option>
                                    <?php
                                    if ($addflag == 1) {
                                        $gmedm = mysqli_query($conn, "SELECT * FROM `medium` order by name")or die(mysqli_error($conn));
                                        while ($fmedm = mysqli_fetch_array($gmedm)) {
                                            Echo "<option value='$fmedm[code]'>$fmedm[name]</option>";
                                        }
                                    }
                                    ?>
                                </select>
                            </div>

                            <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Exam</label>
                            </div>
                            <div class="col-lg-2 col-md-8 col-sm-8 col-xs-8 pad">
                                <select class="form-control form select2 exam"  name="exam" style="width: 100%">
                                    <option value="<?php Echo ($addflag != 1) ? $gexm["code"] : ""; ?>"><?php Echo ($addflag != 1) ? $gexm["name"] : ""; ?></option>
                                    <?php
                                    if ($addflag == 1) {
                                        $gtexm = mysqli_query($conn, "SELECT * FROM `exam` order by name")or die(mysqli_error($conn));
                                        while ($ftexm = mysqli_fetch_array($gtexm)) {
                                            Echo "<option value='$ftexm[code]'>$ftexm[name]</option>";
                                        }
                                    }
                                    ?>
                                </select>
                            </div>

                            <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Section</label>
                            </div>
                            <div class="col-lg-2 col-md-8 col-sm-8 col-xs-8 pad">

                                <?php
                                if ($addflag == 1) {
                                    ?>
                                    <select class="form-control form select2 section"  name="section" style="width: 100%">

                                        <option value=""></option>
                                        <option value="P" <?php
                                        if ($get['section'] == 'P') {
                                            echo 'selected="selected"';
                                        }
                                        ?>>Primary</option>
                                        <option value="S" <?php
                                        if ($get['section'] == 'S') {
                                            echo 'selected="selected"';
                                        }
                                        ?>>Secondary</option>
                                        <option value="M" <?php
                                        if ($get['section'] == 'M') {
                                            echo 'selected="selected"';
                                        }
                                        ?>>Preliums</option>
                                    </select>
                                <?php } else {
                                    ?>
                                    <input type='hidden' class="form-control form  section"  name="section" value="<?php Echo ($addflag != 1) ? $get["section"] : '' ?>">

                                    <?php
                                    $section = $get[section];
                                    switch ($section) {
                                        case 'P':
                                            $showsection = 'Primary';
                                            break;
                                        case 'S':
                                            $showsection = 'Secondary';
                                            break;

                                        case 'M':
                                            $showsection = 'Preliums';
                                            break;
                                    }
                                    ?>
                                    <input type = 'text' class = "form-control form  " name = "" value = "<?php Echo ($addflag != 1) ? $showsection : '' ?>" readonly>
                                <?php }
                                ?>
                            </div>

                            <div class="col-lg-1 col-md-3 col-sm-3 col-xs-3 text-right pad">
                                <label class="label-control marg">Session</label>
                            </div>
                            <div class="col-lg-2 col-md-8 col-sm-8 col-xs-8 pad">
                                <?php
                                if ($addflag == 1) {
                                    ?>
                                    <select class="form-control form select2 session"  name="session" style="width: 100%">
                                        <option value=""></option>
                                        <option value="M" <?php
                                        if ($get['session'] == 'M') {
                                            echo 'selected="selected"';
                                        }
                                        ?>>Morning</option>
                                        <option value="A" <?php
                                        if ($get['session'] == 'A') {
                                            echo 'selected="selected"';
                                        }
                                        ?>>Afternoon</option>
                                    </select>
                                <?php } else {
                                    ?>
                                    <input type='hidden' class="form-control form  session"  name="session" value="<?php Echo ($addflag != 1) ? $get["session"] : '' ?>">
                                    <?php
                                    $session = $get[session];
                                    switch ($session) {
                                        case 'M':
                                            $showsession = 'Morning';
                                            break;
                                        case 'A':
                                            $showsession = 'Afternoon';
                                            break;
                                    }
                                    ?>
                                    <input type = 'text' class = "form-control form" name = "" value = "<?php Echo ($addflag != 1) ? $showsession : '' ?>" readonly>
                                <?php }
                                ?>
                            </div>
                        </div>                                                                                                                      
                    </div>                    
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-lg-12 pad">
                <div class="panel panel-default">

                    <div class="panel-body">
                        <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" style="float: right">
                            <div class="primary">
                                <table class="table table-striped table-condensed table-bordered"  style="width: 100%">
                                    <thead>
                                        <tr style="background-color: #6082BF;">
                                            <th width="2%"></th>
                                            <th width="4%" class="text-right">Sr</th>
                                            <th width="12%">Subject</th>
                                            <th width="7%" class="text-right">First</th>
                                            <th width="5%" class="text-right">Rt.</th>
                                            <th width="7%" class="text-right">Second</th>
                                            <th width="5%" class="text-right">Rt.</th>
                                            <th width="7%" class="text-right">Third</th>
                                            <th width="5%" class="text-right">Rt.</th>
                                            <th width="7%" class="text-right">Fourth</th>
                                            <th width="5%" class="text-right">Rt.</th>
                                            <th width="10%" class="text-right">Amount</th>
                                        </tr>
                                    </thead>
                                    <tbody class="tbody"> 
                                        <?php
                                        if ($addflag != 1) {
                                            ?>

                                            <?php
                                            $ctr = 0;
                                            $gettran = mysqli_query($conn, "SELECT * FROM `$trandb` WHERE `vouchno`='$get[vouchno]' and `section`='P' ORDER BY `srno`")or die(mysqli_error($conn));
                                            while ($tran = mysqli_fetch_array($gettran)) {

                                                $srno = $tran['srno'];
                                                $pq1 = $tran['pq1'];
                                                $pq2 = $tran['pq2'];
                                                $pq3 = $tran['pq3'];
                                                $pq4 = $tran['pq4'];
                                                $totpq = $pq1 + $pq2 + $pq3 + $pq4;

                                                if ($totpq > 1) {

                                                    Echo "<tr>";
                                                    Echo "<td><i class='fa fa-close remove' style='display:none;'></i></td>";
                                                    Echo "<td><input type='text' class='form-control form text-right srno'    name='srno_$ctr'      value='$srno' readonly></td>";
                                                    Echo "<td>";
                                                    Echo "<select class='form-control form subject select2' name='subject_$ctr' style='width:100%' >";
                                                    Echo "<option value='$tran[subjname]'>$tran[subjname]</option>";
                                                    $getmsub = mysqli_query($conn, "SELECT `code`,`name` FROM `subject` order by name")or die(mysqli_error($conn));
                                                    while ($msub = mysqli_fetch_array($getmsub)) {
                                                        Echo "<option value='$msub[name]'>$msub[name]</option>";
                                                    }
                                                    Echo "</select>";
                                                    echo "<input type='hidden' name='subname_$ctr' class='subname' value='$tran[subjcode]'>";
                                                    Echo "</td>";
                                                    Echo "<td><input type='number' class='form-control form text-right first'   name='first_$ctr'  step='any'   value='$pq1'></td>";
                                                    Echo "<td><input type='number' class='form-control form text-right rt1'   name='rt1_$ctr'  step='any'   value='$tran[rt1]' readonly></td>";

                                                    Echo "<td><input type='number' class='form-control form text-right second'   name='second_$ctr' step='any'  value='$pq2'></td>";
                                                    Echo "<td><input type='number' class='form-control form text-right rt2'   name='rt2_$ctr' step='any'  value='$tran[rt2]' readonly></td>";

                                                    Echo "<td><input type='number' class='form-control form text-right third'   name='third_$ctr' step='any'  value='$pq3'></td>";
                                                    Echo "<td><input type='number' class='form-control form text-right rt3'   name='rt3_$ctr' step='any'  value='$tran[rt3]' readonly></td>";

                                                    Echo "<td><input type='number' class='form-control form text-right fourth'   name='fourth_$ctr'  step='any' value='$pq4'></td>";
                                                    Echo "<td><input type='number' class='form-control form text-right rt4'   name='rt4_$ctr'  step='any' value='$tran[rt4]' readonly></td>";

                                                    Echo "<td><input type='number' class='form-control form text-right amount'   name='amount_$ctr'  step='any' value='$tran[amount]' readonly></td>";
                                                    Echo "</tr>";
                                                    $ctr++;
                                                }
                                            }
                                        } else {
                                            $pctr = 0;
                                            $mctr = 1;
                                            ?>
                                            <tr>
                                                <td><i class='fa fa-close remove' ></i></td>
                                                <td><input type='text' class='form-control form text-right srno3'  name='srno3_<?= $pctr ?>' value='<?= $mctr ?>'></td>
                                                <td>
                                                    <select class='form-control form subject select2' name='subject_<?= $pctr ?>' style='width:100%' >
                                                        <option></option>
                                                        <?php
                                                        $getmsub = mysqli_query($conn, "SELECT `code`,`name` FROM `subject` order by name")or die(mysqli_error($conn));
                                                        while ($msub = mysqli_fetch_array($getmsub)) {
                                                            echo "<option value='$msub[name]'>$msub[name]</option>";
                                                        }
                                                        ?>
                                                    </select>
                                                    <input type='hidden' class='subname' name='subname_<?= $pctr ?>' value=''>
                                                </td>
                                                <td><input type='number' class='form-control form text-right first'   name='first_<?= $pctr ?>'  step='any'   value=''></td>
                                                <td><input type='number' class='form-control form text-right rt1'   name='rt1_<?= $pctr ?>'  step='any'   value='' readonly></td>
                                                <td><input type='number' class='form-control form text-right second'   name='second_<?= $pctr ?>' step='any'  value='' ></td>
                                                <td><input type='number' class='form-control form text-right rt2'   name='rt2_<?= $pctr ?>' step='any'  value='' readonly></td>
                                                <td><input type='number' class='form-control form text-right third'   name='third_<?= $pctr ?>' step='any'  value=''></td>
                                                <td><input type='number' class='form-control form text-right rt3'   name='rt3_<?= $pctr ?>' step='any'  value='' readonly></td>
                                                <td><input type='number' class='form-control form text-right fourth'   name='fourth_<?= $pctr ?>'  step='any' value=''></td>
                                                <td><input type='number' class='form-control form text-right rt4'   name='rt4_<?= $pctr ?>'  step='any' value='' readonly></td>
                                                <td><input type='number' class='form-control form text-right amount'   name='amount_<?= $pctr ?>'  step='any' value='0' readonly></td>
                                            </tr>
                                            <?
                                            $pctr++;
                                            $mctr++;
                                        }
                                        ?>
                                    </tbody>
                                </table>

                                <button type="button"  class="btn btn-success btn-square form"  id="addnew">
                                    <i class="fa fa-plus" style="color:#ffffff" data-toggle='tooltip' title='Add Row'></i>    
                                </button>
                                <input type="hidden" id="items" name="items" value="<?php echo ($addflag != 1) ? $ctr : 1; ?>" />
                            </div>
                            <div class="secondary">
                                <table class="table table-striped table-condensed table-bordered" style="width: 100%">
                                    <thead>
                                        <tr style="background-color: #6082BF;">
                                            <th width="2%"></th>
                                            <th width="4%" class="text-right">Sr</th>
                                            <th width="12%">Subject</th>
                                            <th width="7%" class="text-right">Fifth</th>
                                            <th width="5%" class="text-right">Rt.</th>
                                            <th width="7%" class="text-right">Sixth</th>
                                            <th width="5%" class="text-right">Rt.</th>
                                            <th width="7%" class="text-right">Seventh</th>
                                            <th width="5%" class="text-right">Rt.</th>
                                            <th width="7%" class="text-right">Eight</th>
                                            <th width="5%" class="text-right">Rt.</th>
                                            <th width="7%" class="text-right">Ninth</th>
                                            <th width="5%" class="text-right">Rt.</th>
                                            <th width="7%" class="text-right">Tenth</th>
                                            <th width="5%" class="text-right">Rt.</th>
                                            <th width="10%" class="text-right">Amount</th>
                                        </tr>
                                    </thead>
                                    <tbody class="tbody2">

                                        <?php
                                        if ($addflag != 1) {

                                            $ctr2 = 0;
                                            $gettran2 = mysqli_query($conn, "SELECT * FROM `$trandb` WHERE `vouchno`='$get[vouchno]' and `section`='S' ORDER BY `srno`")or die(mysqli_error($conn));
                                            while ($tran2 = mysqli_fetch_array($gettran2)) {

                                                $srno2 = $tran2['srno'];
                                                $pq5 = $tran2['pq5'];
                                                $pq6 = $tran2['pq6'];
                                                $pq7 = $tran2['pq7'];
                                                $pq8 = $tran2['pq8'];
                                                $pq9 = $tran2['pq9'];
                                                $pq10 = $tran2['pq10'];
                                                $totpq2 = $pq5 + $pq6 + $pq7 + $pq8 + $pq9 + $pq10;

                                                if ($totpq2 > 1) {

                                                    Echo "<tr>";
                                                    Echo "<td><i class='fa fa-close remove' style='display:none;'></i></td>";
                                                    Echo "<td><input type='text' class='form-control form text-right srno2'    name='srno2_$ctr2'      value='$srno2'></td>";
                                                    Echo "<td>";
                                                    Echo "<select class='form-control form subject2 select2' name='subject2_$ctr2' style='width:100%' >";
                                                    Echo "<option value='$tran2[subjname]'>$tran2[subjname]</option>";
                                                    $getmsub4 = mysqli_query($conn, "SELECT `code`,`name` FROM `subject` order by name")or die(mysqli_error($conn));
                                                    while ($msub4 = mysqli_fetch_array($getmsub4)) {
                                                        Echo "<option value='$msub4[name]'>$msub4[name]</option>";
                                                    }
                                                    Echo "</select>";
                                                    echo "<input type='hidden' class='subname2' name='subname2_$ctr2' value='$tran2[subjcode]'>";
                                                    Echo "</td>";
                                                    Echo "<td><input type='number' step='any' class='form-control form text-right fifth'   name='fifth_$ctr2'     value='$pq5'></td>";
                                                    Echo "<td><input type='number' step='any' class='form-control form text-right rt5'   name='rt5_$ctr2'     value='$tran2[rt5]' readonly></td>";
                                                    Echo "<td><input type='number' step='any' class='form-control form text-right sixth'   name='sixth_$ctr2'   value='$pq6'></td>";
                                                    Echo "<td><input type='number' step='any' class='form-control form text-right rt6'   name='rt6_$ctr2'   value='$tran2[rt6]' readonly></td>";
                                                    Echo "<td><input type='number' step='any' class='form-control form text-right seventh' name='seventh_$ctr2'   value='$pq7'></td>";
                                                    Echo "<td><input type='number' step='any' class='form-control form text-right rt7' name='rt7_$ctr2'   value='$tran2[rt7]' readonly></td>";
                                                    Echo "<td><input type='number' step='any' class='form-control form text-right eight'   name='eight_$ctr2'   value='$pq8'></td>";
                                                    Echo "<td><input type='number' step='any' class='form-control form text-right rt8'   name='rt8_$ctr2'   value='$tran2[rt8]' readonly></td>";
                                                    Echo "<td><input type='number' step='any' class='form-control form text-right ninth'   name='ninth_$ctr2'   value='$pq9'></td>";
                                                    Echo "<td><input type='number' step='any' class='form-control form text-right rt9'   name='rt9_$ctr2'   value='$tran2[rt9]' readonly></td>";
                                                    Echo "<td><input type='number' step='any' class='form-control form text-right tenth'   name='tenth_$ctr2'   value='$pq10'></td>";
                                                    Echo "<td><input type='number' step='any' class='form-control form text-right rt10'   name='rt10_$ctr2'   value='$tran2[rt10]' readonly></td>";
                                                    Echo "<td><input type='number' step='any' class='form-control form text-right amount2'   name='amount2_$ctr2'   value='$tran2[amount]' readonly></td>";
                                                    Echo "</tr>";
                                                    $ctr2++;
                                                }
                                            }
                                        } else {
                                            $pctr2 = 0;
                                            $mctr2 = 1;
                                            ?>
                                            <tr>
                                                <td><i class='fa fa-close remove' ></i></td>
                                                <td><input type='text' class='form-control form text-right srno3'  name='srno3_<?= $pctr2 ?>' value='<?= $mctr2 ?>'></td>
                                                <td>
                                                    <select class='form-control form subject2 select2' name='subject2_<?= $pctr2 ?>' style='width:100%' >
                                                        <option value=""></option>
                                                        <?php
                                                        $getmsub4 = mysqli_query($conn, "SELECT `code`,`name` FROM `subject` order by name")or die(mysqli_error($conn));
                                                        while ($msub4 = mysqli_fetch_array($getmsub4)) {
                                                            echo "<option value='$msub4[name]'>$msub4[name]</option>";
                                                        }
                                                        ?>
                                                    </select>
                                                    <input type='hidden' class='subname2' name='subname2_<?= $pctr2 ?>' value=''>
                                                </td>
                                                <td><input type='number' step='any' class='form-control form text-right fifth'   name='fifth_<?= $pctr2 ?>'     value=''></td>
                                                <td><input type='number' step='any' class='form-control form text-right rt5'   name='rt5_<?= $pctr2 ?>'     value='' readonly></td>
                                                <td><input type='number' step='any' class='form-control form text-right sixth'   name='sixth_<?= $pctr2 ?>'   value=''></td>
                                                <td><input type='number' step='any' class='form-control form text-right rt6'   name='rt6_<?= $pctr2 ?>'   value='' readonly></td>
                                                <td><input type='number' step='any' class='form-control form text-right seventh' name='seventh_<?= $pctr2 ?>'   value=''></td>
                                                <td><input type='number' step='any' class='form-control form text-right rt7' name='rt7_<?= $pctr2 ?>'   value='' readonly></td>
                                                <td><input type='number' step='any' class='form-control form text-right eight'   name='eight_<?= $pctr2 ?>'   value=''></td>
                                                <td><input type='number' step='any' class='form-control form text-right rt8'   name='rt8_<?= $pctr2 ?>'   value='' readonly></td>
                                                <td><input type='number' step='any' class='form-control form text-right ninth'   name='ninth_<?= $pctr2 ?>'   value=''></td>
                                                <td><input type='number' step='any' class='form-control form text-right rt9'   name='rt9_<?= $pctr2 ?>'   value='' readonly></td>
                                                <td><input type='number' step='any' class='form-control form text-right tenth'   name='tenth_<?= $pctr2 ?>'   value=''></td>
                                                <td><input type='number' step='any' class='form-control form text-right rt10'   name='rt10_<?= $pctr2 ?>'   value='' readonly></td>
                                                <td><input type='number' step='any' class='form-control form text-right amount2'   name='amount2_<?= $pctr2 ?>'   value='0' readonly></td>
                                            </tr>
                                            <?
                                            $pctr2++;
                                            $mctr2++;
                                        }
                                        ?>
                                    </tbody>
                                </table>

                                <button type="button"  class="btn btn-success btn-square form"  id="addnew2">
                                    <i class="fa fa-plus" style="color:#ffffff" data-toggle='tooltip' title='Add Row'></i>    
                                </button>
                                <input type="hidden" id="items2" name="items2" value="<?php echo ($addflag != 1) ? $ctr2 : 1; ?>" />
                            </div>
                            <div class="prelium">
                                <table class="table table-striped table-condensed table-bordered" style="width: 100%">
                                    <thead>
                                        <tr style="background-color: #6082BF;">
                                            <th width="3%"></th>
                                            <th width="5%" class="text-right">Sr</th>
                                            <th width="22%">Subject</th>
                                            <th width="10%" class="text-right">Prelium</th>
                                            <th width="10%" class="text-right">Rt.</th>
                                            <th width="15%" class="text-right">Amount</th>
                                        </tr>
                                    </thead>
                                    <tbody class="tbody3">

                                        <?php
                                        if ($addflag != 1) {
                                            ?>
                                            <?php
                                            $ctr3 = 0;
                                            $gettran3 = mysqli_query($conn, "SELECT * FROM `$trandb` WHERE `vouchno`='$get[vouchno]' and `section`='M' ORDER BY `srno`")or die(mysqli_error($conn));
                                            while ($tran3 = mysqli_fetch_array($gettran3)) {

                                                $srno3 = $tran3['srno'];
                                                $pqrelm = $tran['pqrelm'];

                                                if ($pqrelm > 0) {

                                                    Echo "<tr>";
                                                    Echo "<td><i class='fa fa-close remove' style='display:none;'></i></td>";
                                                    Echo "<td><input type='text' class='form-control form text-right srno3'    name='srno3_$ctr3'      value='$tran3[srno]'></td>";
                                                    Echo "<td>";
                                                    Echo "<select class='form-control form subject3 select2' name='subject3_$ctr3' style='width:100%' >";
                                                    Echo "<option value='$tran3[subjname]'>$tran3[subjname]</option>";
                                                    $getmsub1 = mysqli_query($conn, "SELECT `code`,`name` FROM `subject` order by name")or die(mysqli_error($conn));
                                                    while ($msub1 = mysqli_fetch_array($getmsub1)) {
                                                        Echo "<option value='$msub1[name]'>$msub1[name]</option>";
                                                    }
                                                    Echo "</select>";
                                                    echo "<input type='hidden' class='subname3' name='subname3_$ctr3' value='$tran3[subjcode]'>";
                                                    Echo "</td>";
                                                    Echo "<td><input type='number' step='any' class='form-control form text-right pqrelm'    name='pqrelm_$ctr3'      value='$pqrelm'></td>";
                                                    Echo "<td><input type='number' step='any' class='form-control form text-right rtprelm'    name='rtprelm_$ctr3'      value='$tran3[rtprelm]' readonly></td>";
                                                    Echo "<td><input type='number' step='any' class='form-control form text-right amount3'    name='amount3_$ctr3'      value='$tran3[amount3]' readonly></td>";
                                                    Echo "</tr>";
                                                    $ctr3++;
                                                }
                                            }
                                        } else {
                                            $pctr3 = 0;
                                            $mctr3 = 1;
                                            ?>

                                            <tr>
                                                <td><i class='fa fa-close remove' style='display:none;'></i></td>
                                                <td><input type='text' class='form-control form text-right srno3'  name='srno3_<?= $pctr3 ?>' value='<?= $mctr3 ?>'></td>
                                                <td>
                                                    <select class='form-control form subject3 select2' name='subject3_<?= $pctr3 ?>' style='width:100%' >
                                                        <option></option>
                                                        <?php
                                                        $getmsub1 = mysqli_query($conn, "SELECT `code`,`name` FROM `subject` order by name")or die(mysqli_error($conn));
                                                        while ($msub1 = mysqli_fetch_array($getmsub1)) {
                                                            echo "<option value='$msub1[name]'>$msub1[name]</option>";
                                                        }
                                                        ?>
                                                    </select>
                                                    <input type='hidden' class='subname3' name='subname3_<?= $pctr3 ?>' value=''>
                                                </td>
                                                <td><input type='number' step='any' class='form-control form text-right pqrelm'    name='pqrelm_<?= $pctr3 ?>'      value=''></td>
                                                <td><input type='number' step='any' class='form-control form text-right rtprelm'    name='rtprelm_<?= $pctr3 ?>'      value='' readonly></td>
                                                <td><input type='number' step='any' class='form-control form text-right amount3'    name='amount3_<?= $pctr3 ?>'      value='0' readonly></td>
                                            </tr>
                                            <?
                                            $pctr3++;
                                            $mctr3++;
                                        }
                                        ?>
                                    </tbody>
                                </table>

                                <button type="button"  class="btn btn-success btn-square form"  id="addnew3">
                                    <i class="fa fa-plus" style="color:#ffffff" data-toggle='tooltip' title='Add Row'></i>    
                                </button>
                                <input type="hidden" id="items3" name="items3" value="<?php echo ($addflag != 1) ? $ctr3 : 1; ?>" />

                            </div>
                            <div class="cal">

                                <div class="row">
                                    <div class="col-lg-10 col-md-5 col-sm-3 col-xs-3 text-right pad">
                                        <label class="label-control text-size marg">Subtotal</label>
                                    </div>
                                    <!--                                    <div class="col-lg-4 col-md-3 col-sm-8 col-xs-8 pad">
                                                                        </div>-->
                                    <div class="col-lg-2 col-md-3 col-sm-8 col-xs-8 text-right">
                                        <input type="text" class="form-control form subtotal text-right" name="subtotal" value="<?php Echo ($addflag != 1) ? $get[subtotal] : ""; ?>">
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-lg-7 col-md-5 col-sm-3 col-xs-3 text-right pad">
                                        <label class="label-control text-size marg">No of Packets</label>
                                    </div>
                                    <div class="col-lg-1 col-md-1 col-sm-8 col-xs-8 pad">
                                        <input type="text" class="form-control form text-right nopack" name="nopack" value="<?php Echo ($addflag != 1) ? $get[nopack] : "0"; ?>" readonly>
                                    </div>
                                    <div class="col-lg-1 col-md-5 col-sm-3 col-xs-3 text-right pad">
                                        <label class="label-control text-size marg">Rate</label>
                                    </div>
                                    <div class="col-lg-1 col-md-1 col-sm-8 col-xs-8 pad">
                                        <input type="text" class="form-control form text-right packrate" name="packrate" value="<?php Echo ($addflag != 1) ? $get[packrate] : "0"; ?>" readonly>
                                    </div>
                                    <div class="col-lg-2 col-md-1 col-sm-8 col-xs-8 text-right">
                                        <input type="text" class="form-control form text-right packamt" name="packamt" value="<?php Echo ($addflag != 1) ? $get[packamt] : "0"; ?>" readonly>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-lg-7 col-md-5 col-sm-3 col-xs-3 text-right pad">
                                        <label class="label-control text-size marg">ST. Parcel Charges</label>
                                    </div>
                                    <div class="col-lg-3 col-md-3 col-sm-8 col-xs-8 pad">
                                        <input type="text" class="form-control form parcno" name="parcno" value="<?php Echo ($addflag != 1) ? $get[parcno] : ""; ?>">
                                    </div>
                                    <div class="col-lg-2 col-md-1 col-sm-8 col-xs-8 text-right">
                                        <input type="text" class="form-control form text-right stamt" name="stamt" value="<?php Echo ($addflag != 1) ? $get[stamt] : "0"; ?>" >
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-lg-7 col-md-5 col-sm-3 col-xs-3 text-right pad">
                                        <label class="label-control text-size marg">Other Charges</label>
                                    </div>
                                    <div class="col-lg-3 col-md-3 col-sm-8 col-xs-8 pad">
                                        <input type="text" class="form-control form other" name="other" value="<?php Echo ($addflag != 1) ? $get[other] : ""; ?>">
                                    </div>
                                    <div class="col-lg-2 col-md-1 col-sm-8 col-xs-8 text-right">
                                        <input type="text" class="form-control form text-right otheramt" name="otheramt" value="<?php Echo ($addflag != 1) ? $get[otheramt] : "0"; ?>">
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-lg-10 col-md-5 col-sm-3 col-xs-3 text-right pad">
                                        <label class="label-control text-size marg">Total Bill Amount</label>
                                    </div>
                                    <div class="col-lg-2 col-md-4 col-sm-8 col-xs-8">
                                        <input type="text" class="form-control form text-right billamt" name="billamt" value="<?php Echo ($addflag != 1) ? $get[billamt] : "0"; ?>" readonly>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-lg7 col-md-7 col-sm-3 col-xs-3 text-right pad">
                                    </div>
                                    <div class="col-lg-5 col-md-5 col-sm-3 col-xs-3 text-right ">
                                        <textarea class='form-control form' readonly ><?php echo ($addflag != 1) ? $get['rsword'] : '' ?></textarea>
                                    </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 text-size marg">Remark</label>
                                    </div>
                                    <div class="col-lg-6 col-md-8 col-sm-8 col-xs-8 pad">
                                        <input type="text" class="form-control form " name="remark" value="<?php Echo ($addflag != 1) ? $get["rem1"] : ""; ?>" >
                                        <input type="text" class="form-control form " name="remark2" value="<?php Echo ($addflag != 1) ? $get["rem2"] : ""; ?>" >
                                    </div>
                                    <div class="col-lg-3 col-xs-3 text-right pad">
                                        <input type="submit" class="btn btn-primary emailbut" name="emailbut" value="e-mail" tabindex="-1">
                                    </div>
                                </div>

                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="panel-footer">
            <?php include("includes/buttons.php"); ?>
        </div>
    </form>
    <!--    <div class="modal fade" id="schlmodal"  role="dialog" aria-labelledby="myLargeModalLabel">
            <div class="modal-dialog modal-lg" style="margin-top: 5%;">
                <div class="modal-content">
                    <div class="modal-header">
                        <button class="close" data-dismiss="modal"><span>&times;</span></button>
                        <div class="row">
                            <div class="col-lg-2 text-right padi">
                                <label class="label-control">Search By Code</label>
                            </div>
                            <div class="col-lg-2 padi" >
                                <input type='text' style="" name='search' class="form-control tsearch">    
                            </div>
                        </div>
                    </div>
                    <div class="modal-body">
                        <div class="table-responsive" style="height: 300px;">
    <?php
//                        $srchresult = mysqli_query($conn, "SELECT * FROM `accmast` WHERE `accode` != '' and `grpcode` = '010' ")or die(mysqli_error($conn));
//                        if (mysqli_num_rows($srchresult) > 0) {
//                            echo "<table class='table table-bordered table-hover myTable'>";
//                            echo "<tr class='clickable-row' style='background-color: #6082BF;color: white;'>";
//                            echo "<td><b>Code</b></td>";
//                            echo "<td><b>Name</b></td>";
//                            echo "<td><b>Address</b></td>";
//                            echo "</tr>";
//                            $sctr = 0;
//                            $ctr = 0;
//                            while ($row2 = mysqli_fetch_array($srchresult)) {
//                                $modcode = $row2['custcode'];
//                                $modname = $row2['name'];
//                                $add1 = $row2[add1];
//                                $add2 = $row2[add2];
//                                $add3 = $row2[add3];
//                                echo "<tr class='schltab'>";
//                                echo "<td><b>$modcode</b>
//                                    <input type='hidden' style='border: none' class='scust' value='$modcode' readonly>
//                                            <input type='hidden' value='$row2[medmcode]' class='medium'>
//                                            <input type='hidden' value='$row2[accode]' class='accode'>
//                                    </td>";
//                                echo "<td><b>$modname<input type='hidden' style='border: none' class='sname' value='$modname' readonly></b></td>";
//                                echo "<td><b>$add1 $add2 $add3
//                                     <input type='hidden' style='border: none' class='sadd1' value='$row2[add1]' readonly>
//                                     <input type='hidden' style='border: none' class='sadd2' value='$row2[add2]' readonly>          
//                                     <input type='hidden' style='border: none' class='sadd3' value='$row2[add3]' readonly>          
//                                   </b></td>";
//                                echo "</tr>";
//                                $sctr++;
//                                $ctr++;
//                            }
//                            echo "</table>";
//                        } 
    ?>
                        </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">Bill No.</option>
                                <option value="2">Code</option>
                                <option value="3">School</option>
                                <option value="4">Medium</option>
                                <option value="5">Exam</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">Bill No.</option>
                                <option value="2">Code</option>
                                <option value="3">School</option>
                                <option value="4">Medium</option>
                                <option value="5">Exam</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;">
                        <thead>
                        <table id="" class="table table-striped table-condensed table-bordered" width="100%">
                            <tr style="background-color:#6082BF;">
                                <th width="10%">Bill No.</th>
                                <th width="10%">Code</th>
                                <th width="20%">School</th>
                                <th width="20%">Medium</th>
                                <th width="20%">Exam</th>
                                <th width="20%">Action</th>
                            </tr>
                            </thead>
                            <tbody class="sTbody">
                            </tbody>
                        </table>
                    </div>
                    <div class="row">
                        <div class="col-xs-12 text-right search-action-bar">
                            <input type="button"  class="btn btn-primary sprev" value="Previous">
                            <input type="button"  class="btn btn-primary snext" value="Next">
                        </div>
                    </div>
                </div>
                <div class="modal-footer"></div>
            </div>
        </div>
    </div>
    <?php include("includes/linksfoot.php"); ?>
</body>
</html>
