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

$zyear1 = $_SESSION["zdbyear_" . $dbname];
$zdir   = $_SESSION["zdir"];
$compcd = $_SESSION["comp_" . $dbname];
ini_set('display_errors', 1);
error_reporting(E_ERROR);

$username = $_SESSION["username"];
$cacmst = "accmast";
$cgrpmast = "grpmast";
$cgrphead = "grphead";
$cunit = "unit";
$citem = "item";
$citemgrp = "itemgrp";
$cstkitem = "transacn";
$cgodown = "godown";


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

mysqli_select_db($conn, $zdb);

if (isset($_POST["save"])) {
    $fryear = 'apps2ai_' . $zdir . '_' . 1 . '_' . $_POST["frmyear"];
    $toyear = 'apps2ai_' . $zdir . '_' . 1 . '_' . $_POST["toyear"];
    /*     * **********Copying **************** */
   browse($fryear);
   browse($toyear);
//    die();
    mysqli_select_db($conn, $fryear);
    $acqry = mysqli_query($conn, "SELECT * FROM `$cacmst`") or die(mysqli_error($conn));
    $grpmqry = mysqli_query($conn, "SELECT * FROM `$cgrpmast`") or die(mysqli_error($conn));
    $grpheadqry = mysqli_query($conn, "SELECT * FROM `$cgrphead`") or die(mysqli_error($conn));
//    $unitqry = mysqli_query($conn, "SELECT * FROM `$cunit`") or die(mysqli_error($conn));
    $godownqry = mysqli_query($conn, "SELECT * FROM `$cgodown`") or die(mysqli_error($conn));

    $itemqry = mysqli_query($conn, "SELECT * FROM `$citem`") or die(mysqli_error($conn));
    $itemgqry = mysqli_query($conn, "SELECT * FROM `$citemgrp`") or die(mysqli_error($conn));
    $stkitqry = mysqli_query($conn, "SELECT *,SUM(qty) as tqty FROM `$cstkitem` group by itemcode, godown") or die(mysqli_error($conn));
//      $getit = mysqli_fetch_assoc($stkitqry);
//    $balqty = $get["tqty"];


    browse('grphead');
    while ($rowhead = mysqli_fetch_assoc($grpheadqry)) {
        $grphdsrno = $rowhead["srno"];
        $grphdname = $rowhead["name"];
        $grphdtype = $rowhead["type"];
        $grphdsubtype = $rowhead["subtype"];
        $grphdcode = $rowhead["code"];


        mysqli_select_db($conn, $toyear);
        $chkgrhdpmast = mysqli_query($conn, "SELECT * FROM `$cgrphead` WHERE `code`='$grphdcode'") or die(mysqli_error($conn));
        if (mysqli_num_rows($chkgrhdpmast) > 0) {
            mysqli_query($conn, "UPDATE `$cgrphead` SET `name`='$grphdname', `type`='$grphdtype', `subtype`='$grphdsubtype'
                                                        WHERE code='$grphdcode'") or die(mysqli_error($conn));
        } else {
            mysqli_query($conn, "INSERT INTO `$cgrphead`(`srno`, `code`, `name`, `type`, `subtype`)
                                          VALUES('$grphdsrno', '$grphdcode', '$grphdname', '$grphdtype', '$grphdsubtype')") or die(mysqli_error($conn));
        }
    }

    browse('grpmast');
    while ($row2 = mysqli_fetch_assoc($grpmqry)) {
        $grpcode = $row2["grpcode"];
        $name2 = $row2["name"];
        $type = $row2["type"];
        $subtype = $row2["subtype"];
        $add_info = $row2["add_info"];
        $initial = $row2["initial"];
        $headcode = $row2["headcode"];

        mysqli_select_db($conn, $toyear);
        $chkgrpmast = mysqli_query($conn, "SELECT * FROM `$cgrpmast` WHERE `grpcode`='$grpcode'") or die(mysqli_error($conn));
        if (mysqli_num_rows($chkgrpmast) > 0) {
            mysqli_query($conn, "UPDATE `$cgrpmast` SET `name`='$name2', `type`='$type', `subtype`='$subtype', `add_info`='$add_info', `initial`='$initial',
                                                         headcode='$headcode' WHERE grpcode='$grpcode'") or die(mysqli_error($conn));
        } else {
            mysqli_query($conn, "Insert into $toyear.$cgrpmast Select * from $fryear.$cgrpmast where grpcode='$grpcode'") or die(mysqli_error($conn));

//            mysqli_query($conn, "INSERT INTO `$cgrpmast`(`grpcode`, `name`, `type`, `subtype`, `add_info`, `initial`, headcode)
//                                                 VALUES('$grpcode', '$name2', '$type', '$subtype', '$add_info', '$initial', '$headcode')") or die(mysqli_error($conn));
        }
    }
        browse('accast');

//    /*     * **********accmast **************** */
    while ($row = mysqli_fetch_assoc($acqry)) {
        $accode = $row["accode"];
        $name = mysqli_escape_string($conn, $row["name"]);
//        $consname = $row["consname"];
        $add1 = mysqli_escape_string($conn, $row["add1"]);
        $add2 = mysqli_escape_string($conn, $row["add2"]);
        $add3 = mysqli_escape_string($conn, $row["add3"]);
//        $add4 = $row["add4"];
        $grpcode = $row["grpcode"];
        $custtype = $row["custtype"];
        $custcode = $row["custcode"];
        $deptcode = $row["deptcode"];
        $nameprin = $row["nameprin"];
        $type = $row["type"];
        $init = $row["init"];
        $bankinit = $row["bankinit"];
        $tinno = $row["tinno"];
        $city = $row["city"];
        $pin = $row["pin"];
        $country = $row["country"];
        $station = $row["station"];
        $tel = $row["tel"];
        $fax = $row["fax"];
        $mobile = $row["mobile"];
        $mobile2 = $row["mobile2"];
        $email = $row["email"];
        $openbal = $row["openbal"];
        $dc = $row["dc"];
        $owner = $row["owner"];
        $creditlimit = $row["credlimit"];
        $website = $row["website"];
        $contpers = $row["contpers"];
        $vattin = $row["vattin"];
        $csttin = $row["csttin"];
        $pattern = $row["pattern"];
        $closbal = $row["closbal"];
        $closbdc = $row["closbdc"];
        $pfund = $row["pfund"];
        $saltype = $row["saltype"];
        $salwise = $row["salwise"];
        $salmon = $row["salmon"];
        $travmon = $row["travmon"];
        $convmon = $row["convmon"];
        $p_tax = $row["p_tax"];
        $leaveflag = $row["leaveflag"];
        $leavecode = $row["leavecode"];
        $esic = $row["esic"];
        $salary = $row["salary"];
        $active = $row["active"];
        $username = $row["username"];
        $pan = $row["pan"];
        $staff = $row["staff"];
        $transporter = $row["transporter"];
        $transport = $row["transport"];
        $gstno = $row["gstno"];
        $state = $row["state"];
        $statecode = $row["statecode"];
//        $discount = $row["discount"];
//        $commperc = $row["commperc"];
//        $ledgfrom = $row["ledgfrom"];
//        $ledgto = $row["ledgto"];

        if ($dc == "D") {
            $nopen = abs($openbal) * -1;
        } else {
            $nopen = abs($openbal);
        }
//        if ($accode == "51") {
//            mysql_current_db();
//        }


        mysqli_select_db($conn, $fryear);
        $actranqry = mysqli_query($conn, "SELECT SUM(amount) AS amt FROM `actran` WHERE accode='$accode' AND `chqret` !='Y'") or die(mysqli_error($conn));
        $get = mysqli_fetch_assoc($actranqry);
        $balamt = $get["amt"];

        $topen = $nopen + $balamt;

        if ($topen > 0) {
            $tdc = "C";
        } else {
            $tdc = "D";
        }

        $topen = abs($topen);

        $gettypeqry = mysqli_query($conn, "SELECT * FROM $fryear.$cgrpmast WHERE grpcode='$grpcode'") or die(mysqli_error($conn));
        $fettype = mysqli_fetch_array($gettypeqry);
        $mgtype = $fettype['type'];



        $mamt = 0;
        if ($mgtype != "I" && $mgtype != "E") {
            $getamtqry = mysqli_query($conn, "SELECT sum(amount) as tamt FROM $fryear.actran WHERE accode='$accode' and retdate = '0000-00-00' ") or die(mysqli_error($conn));
            $fetamt = mysqli_fetch_array($getamtqry);
            $mamt = $fetamt['tamt'];
        } else {
            $mamt = 0;
        }
        if ($grpcode == '050' and $percent > 0) {
            $mpl = $mprof * ($percent / 100);
        } else {
            $mpl = 0;
        }

        if ($mgtype != "I" && $mgtype != "E") {
            switch ($accode) {
                case '7':
                    $closbal = $openbal + $currbal;
                    break;
                case '23':
                    $closbal = $openbal + $currbal;
                    break;
                case '24':
                    break;

                default:
                    $currbal = $mamt;
                    $closbal = $openbal + $currbal + $mpl;


                    break;
            }
        } else {
            $currbal = 0.00;
            $closbal = 0.00;
        }

        if ($currbal > 0) {
            $currdc = "C";
        } else {
            $currdc = "D";
        }

        if ($grpcode == '050') {
            if ($closbal < 0) {
                $closbdc = "C";
            } else {
                $closbdc = "D";
            }
        } ELSE {
            if ($closbal > 0) {
                $closbdc = "C";
            } else {
                $closbdc = "D";
            }
        }

        /*        if($accode=="51"){
          browse($balamt);
          browse($nopen);
          browse($topen);
          browse($tdc);
          } */

        mysqli_select_db($conn, $toyear);
        $chkac = mysqli_query($conn, "SELECT * FROM `$cacmst` WHERE accode = '$accode'");
        if (mysqli_num_rows($chkac) > 0) {
            mysqli_query($conn, "UPDATE `$cacmst` SET `name`='$name', `add1`='$add1', `add2`='$add2', `add3`='$add3',
                                           `grpcode`='$grpcode', `custtype`='$custtype', `custcode`='$custcode', `deptcode`='$deptcode', 
                                           `nameprin`='$nameprin', `type`='$type', `init`='$init', `bankinit`='$bankinit', `tinno`='$tinno', `city`='$city',  
                                           `pin`='$pin', `country`='$country',  `tel`='$tel', `fax`='$fax', `mobile`='$mobile',
                                           `mobile2`='$mobile2', `email`='$email', openbal='$topen', `dc`='$tdc', `owner`='$owner',credlimit='$creditlimit',
                                           `website`='$website', `contpers`='$contpers', `vattin`='$vattin', `csttin`='$csttin',
                                           `pattern`='$pattern', closbal='$closbal', `closbdc`='$closbdc', `pfund`='$pfund',
                                           `saltype`='$saltype', `salwise`='$salwise', salmon='$salmon', travmon='$travmon',
                                            convmon='$convmon', `p_tax`='$p_tax', `leaveflag`='$leaveflag', `leavecode`='$leavecode',
                                           `esic`='$esic', salary='$salary', active='$active', `username`='$username', `gstno`='$gstno', `state`='$state',`statecode`='$statecode',
                                           `pan`='$pan', staff='$staff', transporter ='$transporter', transport='$transport', `lbt`='$lbt', discount='$discount'
                                            WHERE accode = $accode") or die(mysqli_error($conn));
        } else {
            mysqli_query($conn, "Insert into $toyear.$cacmst Select * from $fryear.$cacmst where accode='$accode'") or die(mysqli_error($conn));

            mysqli_query($conn, "UPDATE $toyear.$cacmst SET openbal='$topen', `dc`='$tdc',closbal='$closbal',closbdc='$closbdc' WHERE accode = '$accode'") or die(mysqli_error($conn));
//            mysqli_query($conn, "INSERT INTO `$cacmst`(`name`, `add1`, `add2`, `add3`, `grpcode`, `custtype`, `custcode`, `deptcode`,
//                                               `nameprin`, `type`, `init`, `bankinit`, `tinno`, `city`, `pin`, `country`, `station`, `tel`, 
//                                               `fax`, `mobile`, `mobile2`, `email`, openbal, `dc`, `owner`, credlimit, `website`, `contpers`, 
//                                               `vattin`, `csttin`, `pattern`, closbal, `closbdc`, `pfund`, `saltype`, `salwise`, salmon, 
//                                                travmon, convmon, `p_tax`, `leaveflag`, `leavecode`, `esic`, salary, active, `username`, `pan`,
//                                                staff, transporter, transport, `lbt`, discount, `gstno`, `state`, `statecode`)
//   
//                                        VALUES('$name', '$add1', '$add2', '$add3', '$grpcode', '$custtype', '$custcode', '$deptcode',
//                                               '$nameprin', '$type', '$init', '$bankinit', '$tinno', '$city', '$pin', '$country', '$station', '$tel', '$fax', 
//                                               '$mobile', '$mobile2', '$email', '$topen', '$tdc', '$owner', '$website', '$creditlimit', '$contpers', '$vattin', 
//                                               '$csttin', '$pattern', '$closbal', '$closbdc', '$pfund', '$saltype', '$salwise', '$salmon', '$travmon', 
//                                               '$convmon', '$p_tax', '$leaveflag', '$leavecode', '$esic', '$salary', '$active', '$username', '$pan', '$staff',
//                                               '$transporter', '$transport', '$lbt', '$discount', '$gstno', '$state', '$statecode')") or die(mysqli_error($conn));
        }
    }
    browse('stk');

    while ($rowst = mysqli_fetch_assoc($stkitqry)) {

        $source = $rowst["source"];
        $vouchnot = $rowst["vouchno"];
        $vouchndt3 = $rowst["vouchndt"];
        $itemcodet = $rowst["itemcode"];
        $godownt = $rowst["godown"];
        $qtyt = $rowst["tqty"];
        $ratet = $rowst["rate"];
        $amountt = $rowst["amount"];
        $balqty = $rowst["tqty"];


//         mysqli_select_db($conn, $fryear);
//        $transacnqry = mysqli_query($conn, "SELECT SUM(qty) AS tqty FROM `transacn` WHERE `itemcode`='$itemcodet' and `godown` = '$godownt' ") or die(mysqli_error($conn));
//        $transacnqry = mysqli_query($conn, "SELECT SUM(qty) AS tqty FROM `transacn` group by itemcode,godown ") or die(mysqli_error($conn));
//        $gettra = mysqli_fetch_assoc($transacnqry);
//        $balqty = $gettra["tqty"];
//        
        mysqli_select_db($conn, $toyear);

        $chkstkmast = mysqli_query($conn, "SELECT * FROM `$cstkitem` WHERE `itemcode`='$rowst[itemcode]' and `godown` = '$rowst[godown]' group by itemcode, godown") or die(mysqli_error($conn));
//        $getst = mysqli_fetch_assoc($chkstkmast);
//        $bqty = $get["tqty"];
//        if (mysqli_num_rows($chkstkmast) > 0) {
        if (mysqli_num_rows($chkstkmast) > 0) {
            mysqli_query($conn, "UPDATE `$cstkitem` SET `source`='OP', `itemcode`='$itemcodet', `godown`='$godownt', `qty`='$balqty',
                                                         `rate`='$ratet', `amount`='$amountt' WHERE itemcode='$itemcodet' and godown ='$godownt'") or die(mysqli_error($conn));
        } else {
            mysqli_query($conn, "INSERT INTO `$cstkitem`(`source`, `itemcode`, `godown`, `qty`, `rate`, `amount`)
                                                 VALUES('OP', '$itemcodet', '$godownt', '$balqty', '$ratet', '$amountt')") or die(mysqli_error($conn));
        }
    }


    browse('2');

//    while ($row3 = mysqli_fetch_assoc($unitqry)) {
//
//        $name3 = $row3["name"];
//        $username2 = $row3["username"];
//        $code = $row3["code"];
//
//        mysqli_select_db($conn, $toyear);
//        $chkcounhead = mysqli_query($conn, "SELECT * FROM `$cunit` WHERE code='$code'") or die(mysqli_error($conn));
//
//        if (mysqli_num_rows($chkcounhead) > 0) {
//            mysqli_query($conn, "UPDATE `$cunit` SET `name`='$name3', `username`='$username2',
//                                                        code='$code'  WHERE code='$code'") or die(mysqli_error($conn));
//        } else {
//            mysqli_query($conn, "INSERT INTO `$cunit`(code, `name`, `username` )
//                                                  VALUES('$code', '$name3', '$username2' )") or die(mysqli_error($conn));
//        }
//    }
    browse('3');
    while ($row11 = mysqli_fetch_assoc($itemgqry)) {

//        $grpid     = $row11["id"];
        $code4 = $row11["code"];
        $name6 = $row11["name"];
        $hsncode6 = $row11["statecode"];

        mysqli_select_db($conn, $toyear);
        $chkgrphead = mysqli_query($conn, "SELECT * FROM `$citemgrp` WHERE code='$code4'") or die(mysqli_error($conn));

        if (mysqli_num_rows($chkgrphead) > 0) {
            mysqli_query($conn, "UPDATE `$citemgrp` SET  `name`='$name6', hsncode='$hsncode6' WHERE code='$code4'") or die(mysqli_error($conn));
        } else {
            mysqli_query($conn, "Insert into $toyear.$citemgrp Select * from $fryear.$citemgrp where code='$code4'") or die(mysqli_error($conn));

//            mysqli_query($conn, "INSERT INTO `$citemgrp`( code, `name`, `hsncode`)
//                                                  VALUES('$code4', '$name6', '$hsncode6')") or die(mysqli_error($conn));
        }
    }


    browse('4');
    while ($row10 = mysqli_fetch_assoc($itemqry)) {

        $code9 = $row10["code"];
        $barcode9 = $row10["barcode"];
        $name11 = $row10["name"];
        $itemgrp = $row10["itemgrp"];
        $cost = $row10["cost"];
        $rate = $row10["rate"];
        $mrp = $row10["mrp"];
        $trans1 = $row10["trans"];
        $hsncode1 = $row10["hsncode"];

        mysqli_select_db($conn, $toyear);
        $chkitemhead = mysqli_query($conn, "SELECT * FROM `$citem` WHERE code='$code9'") or die(mysqli_error($conn));

        if (mysqli_num_rows($chkitemhead) > 0) {
            mysqli_query($conn, "UPDATE `$citem` SET `barcode`='$barcode9',  `name`='$name11', `hsncode`='$hsncode1',
                                             `itemgrp`='$itemgrp', mrp='$mrp', cost='$cost', rate='$rate' WHERE code='$code9'") or die(mysqli_error($conn));
        } else {
            mysqli_query($conn, "Insert into $toyear.$citem Select * from $fryear.$citem where code='$code9'") or die(mysqli_error($conn));

//            mysqli_query($conn, "INSERT INTO `$citem`(code, `name`, `barcode`, `itemgrp`, cost, rate, mrp, `hsncode` )
//                   VALUES('$code9', '$name11', '$barcode9', '$itemgrp', '$cost', '$rate','$mrp', '$hsncode1')") or die(mysqli_error($conn));
        }
    }

    while ($rowgdwn = mysqli_fetch_assoc($godownqry)) {
        $gdwncode = $rowgdwn["code"];
        $gdwngdcode = $rowgdwn["gdcode"];
        $gdwnname = $rowgdwn["name"];
        $gdwnadd1 = $rowgdwn["add1"];
        $gdwnadd2 = $rowgdwn["add2"];
        $gdwnadd3 = $rowgdwn["add3"];
        $gdwncity = $rowgdwn["city"];
        $gdwnpin = $rowgdwn["pin"];
        $gdwncntry = $rowgdwn["country"];
        $gdwntel = $rowgdwn["tel"];
        $gdwnfax = $rowgdwn["fax"];
        $gdwnmobile = $rowgdwn["mobile"];
        $gdwnmobile2 = $rowgdwn["mobile2"];
        $gdwnemail = $rowgdwn["email"];


        mysqli_select_db($conn, $toyear);
        $chkgodown = mysqli_query($conn, "SELECT * FROM `$cgodown` WHERE `code`='$gdwncode'") or die(mysqli_error($conn));
        if (mysqli_num_rows($chkgodown) > 0) {
            mysqli_query($conn, "UPDATE `$cgodown` SET `name`='$gdwnname', `add1`='$gdwnadd1', `add2`='$gdwnadd2', `add3`='$gdwnadd3'
                                             WHERE code = '$gdwncode'") or die(mysqli_error($conn));
        } else {
                        mysqli_query($conn, "Insert into $toyear.$cgodown Select * from $fryear.$cgodown where code='$gdwncode'") or die(mysqli_error($conn));

//            mysqli_query($conn, "INSERT INTO `$cgodown`(code, `gdcode`, `name`, `add1`, `add2`, `add3`
//                                               )
//   
//                                        VALUES('$gdwncode', '$gdwngdcode', '$gdwnname', '$gdwnadd1', '$gdwnadd2', '$gdwnadd3'
//                                               )") or die(mysqli_error($conn));
        }
    }

    browse("Processing Complete");
    header("refresh: 1;yearend.php");
}
?>

<!DOCTYPE HTML>
<html lang="en-US">
    <head>
        <meta charset="UTF-8">
        <title>Year End</title>
        <meta name="msapplication-TileColor" content="#5bc0de"/>
        <meta name="msapplication-TileImage" content="assets/img/metis-tile.png"/>

        <link rel="stylesheet" href="assets/lib/bootstrap/css/bootstrap.css">
        <link rel="stylesheet" href="assets/css/main.css"/>
        <link rel="stylesheet" href="assets/lib/Font-Awesome/css/font-awesome.css"/>

        <link rel="stylesheet" href="assets/css/theme.css">


        <link rel="stylesheet" href="assets/lib/uniform/themes/default/css/uniform.default.css">
        <link rel="stylesheet" href="assets/lib/inputlimiter/jquery.inputlimiter.1.0.css">
        <link rel="stylesheet" href="assets/lib/chosen/chosen.min.css">
        <link rel="stylesheet" href="assets/lib/colorpicker/css/colorpicker.css">
        <link rel="stylesheet" href="assets/lib/tagsinput/jquery.tagsinput.css">
        <link rel="stylesheet" href="assets/lib/daterangepicker/daterangepicker-bs3.css">
        <link rel="stylesheet" href="assets/lib/datepicker/css/datepicker.css">
        <link rel="stylesheet" href="assets/lib/timepicker/css/bootstrap-timepicker.min.css">
        <link rel="stylesheet" href="assets/lib/switch/static/stylesheets/bootstrap-switch.css">
        <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/flick/jquery-ui.css">


        <!--[if lt IE 9]>
                <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
                <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
        <![endif]-->
        <style>

        </style>

    </head>
    <body onLoad="document.boq.vouchdt.focus();">
        <form action=''  name="invoice" method="POST">
            <div class="row">
                <div class="col-lg-6" style='width:30%;float:left;'>
                    <div class="box dark">
                        <header>
                            <div class="icons"><i class="fa fa-edit"></i></div>
                            <h5>Year End</h5>
                            <!-- .toolbar -->
                            <div class="toolbar">
                                <ul class="nav">
                                    <li>
                                        <input type="submit" name="save" value="Proceed" class="btn btn-primary">
                                    </li>
                                    <li>
                                        <a class="accordion-toggle minimize-box" data-toggle="collapse" href="#div-1">
                                            <i class="fa fa-chevron-up"></i>
                                        </a>
                                    </li>
                                </ul>
                            </div>
                            <!-- /.toolbar -->
                        </header>
                        <div id="div-1" class="accordion-body collapse in body">
                            <div class="form-horizontal">
                                <div class="form-group">
                                    <label class="control-label col-lg-4">From Year</label>
                                    <div class="col-lg-8"> 
                                        <select name="frmyear" class="form-control" >
                                            <?php
                                            require("includes/dbconnect.php");
                                            $tyear = mysqli_query($conn, "SELECT * FROM `compyear`  WHERE finyear ='$zyear'  ORDER BY `lastdate`") OR die(mysqli_error($conn));
                                            while ($row2 = mysqli_fetch_array($tyear)) {
                                                echo "<option value=\"$row2[finyear]\">$row2[finyear]</option>";
                                            }
                                            ?>
                                            <!--<option value="<?php echo $zyear; ?>"><?php // echo $zyear;  ?></option>--> 
                                        </select>
                                    </div> 
                                </div> 
                                <div class="form-group">
                                    <label class="control-label col-lg-4">To Year</label>
                                    <div class="col-lg-8"> 
                                        <select name="toyear" class="form-control" >
                                            <?php
                                            require("includes/dbconnect.php");
                                            $myear = mysqli_query($conn, "SELECT * FROM `compyear` WHERE finyear !='$zyear' AND finyear > '$zyear' ORDER BY `lastdate`") OR die(mysqli_error($conn));
                                            while ($row = mysqli_fetch_array($myear)) {
                                                echo "<option value=\"$row[finyear]\">$row[finyear]</option>";
                                            }
                                            ?>
                                        </select>
                                    </div> 
                                </div> 
                            </div>
                        </div>
                    </div>
                </div>
            </div>



<!--            <table border="0px" width="30%">
                <tr>
                    <td><font color="#FF8C00" size="3px"><b>From Year</b></font></td>
                    <td><font color="#FF8C00" size="3px"><b>To Year</b></font></td>
                </tr>
                <tr>
                    <td><select data-placeholder="From Year" style="width:152px;" id="for" name="frmyear" class="chzn-select-deselect" >
                            <option value="<?php echo $zyear; ?>"><?php echo $zyear; ?></option> 
                        </select></td>
                    <td><select data-placeholder="To Year" style="width:152px;" id="to" name="toyear" class="chzn-select-deselect" >
            <?php
//            require("includes/dbconnect.php");
//            $myear = mysqli_query($conn, "SELECT * FROM `compyear` WHERE finyear !='$zyear' AND finyear > '$zyear' ORDER BY `lastdate`") OR die(mysqli_error($conn));
//            while ($row = mysqli_fetch_array($myear)) {
//                echo "<option value=\"$row[finyear]\">$row[finyear]</option>";
//            }
            ?>
                        </select></td>
                </tr>
                <tr>
                    <td colspan="3">
                        <br/>
                    </td>
                </tr>
                <tr>
                    <td colspan="3">
                        <hr/>
                    </td>
                </tr>
            </table>
            <center><input class="cmdproc" type="submit" name="save" value="Proceed" /></center>-->
        </form>

    </body>
</html>