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

$formname = 'User Creation';
$maindb = 'passmain';
$trandb = 'usercomp';
$printfile = "";
$file = 'user.php';
$trandbexist = 0;
$grid = '';
$keyfld = "code";

$admin = $_SESSION["admin_" . $dbname];
$username = $_SESSION["username_" . $dbname];

include("includes/vouchno_generate.php");
include("includes/prev&next.php");

if (isset($_POST["submit"])) {
    $a = 1;
    $user = $_POST["user"];
    $password = $_POST["password"];
    $usertype = $_POST["usertype"];
    ################## MASTERS ##################
    $customer = $_POST["customer"];
    $supplier = $_POST["supplier"];
    $openbal = $_POST["openbal"];
    $chcustdtl = $_POST["chcustdtl"];
    $driver = $_POST["driver"];
    $transport = $_POST["transport"];
    $unit = $_POST["unit"];
    $openstk = $_POST["openstk"];
    $staff = $_POST["staff"];
    $bank = $_POST["bank"];
    $cash = $_POST["cash"];
    $expense = $_POST["expense"];
    $itemgrp = $_POST["itemgrp"];
    $itemsubgrp = $_POST["itemsubgrp"];
    $item = $_POST["item"];
    $group = $_POST["group"];
    $otherac = $_POST["otherac"];
    $saletype = $_POST["saletype"];

    ################## TRANSACTION ##################
    $purchase = $_POST["purchase"];
    $sale = $_POST["sale"];
    $debnote = $_POST["debnote"];
    $deboth = $_POST["deboth"];
    $crednote = $_POST["crednote"];
    $credoth = $_POST["credoth"];
    $inward = $_POST["inward"];
    $outward = $_POST["outward"];
    $damaged = $_POST["damaged"];
    $excess = $_POST["excess"];
    $bankrecp = $_POST["bankrecp"];
    $bankpay = $_POST["bankpay"];
    $cashrecp = $_POST["cashrecp"];
    $cashpay = $_POST["cashpay"];
    $contra = $_POST["contra"];
    $journal = $_POST["journal"];
    $discgiven = $_POST["discgiven"];
    $discrecv = $_POST["discrecv"];
    $taxinv = $_POST["taxinv"];
    $transfer = $_POST["transfer"];

    ################## REPORTS ##################
    $rpstock = $_POST["stock"]; 
    $rphist = $_POST["inwout"];
    $rpvat = $_POST["vatrep"];
    $rpledger = $_POST["ledger"];
    $rplabels = $_POST["labels"];
    $rpchqnoqry = $_POST["chqrep"];
    $rpamountqry = $_POST["amtrep"];
    $rpitemwise = $_POST["itemwise"];
    $rpitemwisesale = $_POST["itemwisesale"];
    $rpitemgrpwisesale = $_POST["itemgrpwisesale"];
    $rppartygrpwisesale = $_POST["partygrpwisesale"];
    $rpleadparty = $_POST["leadparty"];
    $rpdailyreport = $_POST["dailyreport"];
    $rpdailysalereport = $_POST["dailysalereport"];
    $rpbankbook = $_POST["bankbook"];
    $rpcashbook = $_POST["cashbook"];
    $rpjvrep = $_POST["jvrep"];
    $rpexpense = $_POST["exprep"];
    $rppayable = $_POST["payablerep"];
    $rpreceivable = $_POST["receivable"];

    ################## REGISTERS ##################
    $rgpurch = $_POST["purreg"];
    $rgsale = $_POST["salereg"];
    $rgdebnote = $_POST["debnotreg"];
    $rgdeboth = $_POST["debothreg"];
    $rgcrednote = $_POST["crednotreg"];
    $rgcredoth = $_POST["credothreg"];
    $rginward = $_POST["inwreg"];
    $rgoutward = $_POST["outreg"];
    $rgdamaged = $_POST["damreg"];
    $rgexcess = $_POST["excreg"];
    $rgdriver = $_POST["driverreg"];
    $rgtaxinv = $_POST["taxinvreg"];
    $rgbalance = $_POST["balreg"];


    ################## FINALIZATION ##################
    $fnbalance = $_POST["trbal"];
    $fnprofit = $_POST["profit"];
    $fnprofshar = $_POST["profshar"];
    $fnbalsheet = $_POST["balsheet"];


    ################## TOOLS ##################
    $tlcompany = $_POST["compsetup"];
    $tlbackup = $_POST["backup"];
    $tlprofile = $_POST["profile"];
    $dstock = $_POST["dstock"];

    $count = $_POST["items"];


    if (isset($_POST["name"])) {
        $result = mysqli_query($conn,"SELECT * FROM `$maindb` WHERE `name`= '$name' AND code != '$qvouch'") or die(mysqli_error($conn));
        if (mysqli_num_rows($result) > 0) {
            $a = 0;
            browse("Name Already Exist");
            header("refresh: 1; $file?code=$qvouch&mode=last");
        }
    }

    if ($a == 1) {
        if ($addflag == 1) {
            $gen1 = mysqli_query($conn,"SELECT MAX($keyfld) AS maxcode FROM `$maindb` LIMIT 0,1 ") or die(mysqli_error($conn));

            if (mysqli_num_rows($gen1) > 0) {
                $vvouch = mysqli_fetch_assoc($gen1);
                $qvouch = $vvouch["maxcode"] + 1;
            } else {
                $qvouch = '1';
            }
            $mvouch = $qvouch;
        }

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

        mysqli_query($conn,"DELETE FROM `$trandb` WHERE `username`='$qvouch'") or die(mysqli_error($conn));

        for ($i = 0; $i < $count; $i++) {
            $cono = $_POST["cono_$i"];
            $finyear = $_POST["finyear_$i"];
            $yearname = $_POST["yearname_$i"];
            $startdate = $_POST["startdate_$i"];
            $lastdate = $_POST["lastdate_$i"];

            if (!empty($cono)) {
                $company = mysqli_query($conn,"SELECT `name` FROM `company` WHERE `code`='$cono'")or die(mysqli_error($conn));
                $co = mysqli_fetch_array($company);
                $cname = $co[name];

                mysqli_query($conn,"INSERT INTO `$trandb`(`username`,`cono`,`cname`, `finyear`, `yearname`, `startdate`, `lastdate`) 
                    VALUES ('$qvouch', '$cono', '$cname', '$finyear', '$yearname', '$startdate', '$lastdate')") or die(mysqli_error($conn));
            }
        }

############################## MAIN  ######################################################

        if ($addflag == 1) {

            $usecode = mysqli_query($conn,"SELECT code FROM `passmain` WHERE user='$username'")or die(mysqli_error($conn));
            $getuser = mysqli_fetch_object($usecode);
            $code = $getuser->code;

            mysqli_query($conn,"INSERT INTO `$maindb`(code, `user`, `password`, `usertype`, `customer`, `supplier`, `openbal`, `chcustdtl`, `transport`,
                                `driver`, `unit`, `openstk`, `staff`, `bank`, `cash`, `expense`, `itemgrp`, `itemsubgrp`, `item`, `group`,
                                `otherac`, `saletype`, `purchase`, `sale`, `debnote`, `deboth`, `crednote`, `credoth`, `inward`, `outward`, `damaged`,
                                `excess`, `bankrecp`, `bankpay`, `cashrecp`, `cashpay`, `contra`, `journal`,`discgiven`, `discrecv`, `taxinv`, `stock`, `inwout`,
                                `vatrep`, `ledger`, `labels`, `chqrep`, `amtrep`, `itemwise`, `itemwisesale`, `itemgrpwisesale`, `partygrpwisesale`, 
                                `leadparty`, `dailyreport`, dailysalereport, `bankbook`, `cashbook`, `jvrep`, `exprep`, `payablerep`, `receivable`,
                                `purreg`, `salereg`, `debnotreg`, `debothreg`, `crednotreg`, `credothreg`, `inwreg`, `outreg`, `damreg`, `excreg`,
                                `driverreg`, `taxinvreg`, `balreg`, `trbal`, `profit`, `profshar`, `balsheet`, `compsetup`, `backup`, `profile`, `dstock`, `transfer`)
                        VALUES($qvouch, '$user', '$password', '$usertype', '$customer', '$supplier', '$openbal', '$chcustdtl', '$transport', 
                                '$driver', '$unit', '$openstk', '$staff', '$bank', '$cash', '$expense', '$itemgrp', '$itemsubgrp', '$item', '$group',
                                '$otherac', '$saletype', '$purchase', '$sale', '$debnote', '$deboth', '$crednote', '$credoth', '$inward', '$outward', '$damaged', 
                                '$excess', '$bankrecp', '$bankpay', '$cashrecp', '$cashpay', '$contra', '$journal', '$discgiven', '$discrecv', '$taxinv', '$rpstock', '$rphist',
                                '$rpvat', '$rpledger', '$rplabels', '$rpchqnoqry', '$rpamountqry', '$rpitemwise', '$rpitemwisesale', '$rpitemgrpwisesale', '$rppartygrpwisesale',
                                '$rpleadparty', '$rpdailyreport', '$rpdailysalereport', '$rpbankbook', '$rpcashbook', '$rpjvrep', '$rpexpense', '$rppayable', '$rpreceivable',
                                '$rgpurch', '$rgsale', '$rgdebnote', '$rgdeboth', '$rgcrednote', '$rgcredoth', '$rginward', '$rgoutward', '$rgdamaged', '$rgexcess',
                                '$rgdriver', '$rgtaxinv', '$rgbalance', '$fnbalance', '$fnprofit', '$fnprofshar', '$fnbalsheet', '$tlcompany', '$tlbackup', '$tlprofile', '$dstock', '$transfer')") or die(mysqli_error($conn));
            insmess();
            $mvouch = $qvouch;
            header("refresh: 1; $file?$keyfld=$mvouch&mode=edit");
        } else {
            $mvouch = $qvouch;

            $usecode = mysqli_query($conn,"SELECT code FROM `passmain` WHERE user='$username'")or die(mysqli_error($conn));
            $getuser = mysqli_fetch_object($usecode);
            $code = $getuser->code;

            mysqli_query($conn,"UPDATE `$maindb` SET code='$qvouch', `user`='$user', `password`='$password', `usertype`='$usertype',
                                        `customer`='$customer', `supplier`='$supplier', `openbal`='$openbal',`chcustdtl`='$chcustdtl',
                                        `transport`='$transport', `driver`='$driver', `unit`='$unit', `openstk`='$openstk', `staff`='$staff',
                                        `bank`='$bank',`cash`='$cash', `expense`='$expense', `itemgrp`='$itemgrp', `itemsubgrp`='$itemsubgrp',
                                        `item`='$item', `group`='$group', `otherac`='$otherac', `saletype`='$saletype', `purchase`='$purchase',
                                        `sale`='$sale',`debnote`='$debnote', `deboth`='$deboth', `crednote`='$crednote', `credoth`='$credoth',
                                        `inward`='$inward', `outward`='$outward', `damaged`='$damaged', `excess`='$excess', `bankrecp`='$bankrecp',
                                        `bankpay`='$bankpay', `cashrecp`='$cashrecp', `cashpay`='$cashpay', `contra`='$contra', `journal`='$journal',
                                        `discgiven`='$discgiven', `discrecv`='$discrecv', `taxinv`='$taxinv', `stock`='$rpstock', `inwout`='$rphist', `vatrep`='$rpvat',
                                        `ledger`='$rpledger', `labels`='$rplabels', `chqrep`='$rpchqnoqry', `amtrep`='$rpamountqry', `itemwise`='$rpitemwise',
                                        `itemwisesale`='$rpitemwisesale', `itemgrpwisesale`='$rpitemgrpwisesale', `partygrpwisesale`='$rppartygrpwisesale',
                                        `leadparty`='$rpleadparty', `dailyreport`='$rpdailyreport',  `dailysalereport`='$rpdailysalereport',
                                        `bankbook`='$rpbankbook', `cashbook`='$rpcashbook', `jvrep`='$rpjvrep', `exprep`='$rpexpense', `payablerep`='$rppayable',
                                        `receivable`='$rpreceivable', `purreg`='$rgpurch', `salereg`='$rgsale', `debnotreg`='$rgdebnote',`debothreg`='$rgdeboth',
                                        `crednotreg`='$rgcrednote', `credothreg`='$rgcredoth', `inwreg`='$rginward', `outreg`='$rgoutward', `damreg`='$rgdamaged',
                                        `excreg`='$rgexcess', `driverreg`='$rgdriver', `taxinvreg`='$rgtaxinv', `balreg`='$rgbalance', `trbal`='$fnbalance',
                                        `profit`='$fnprofit', `profshar`='$fnprofshar', `balsheet`='$fnbalsheet', `compsetup`='$tlcompany', `backup`='$tlbackup',
                                        `profile`='$tlprofile', `dstock`='$dstock', `transfer`='$transfer'    WHERE code = '$mvouch' ") or die(mysqli_error($conn));
            updmess();
            header("refresh: 1; $file?$keyfld=$mvouch&mode=edit");
        }
    }
}

if ($addflag != 1) {

    $getvouch = '';
    if ($addflag == 0) {
        $getvouch = $_GET[$keyfld];
    } else {
        $getvouch = $qvouch;
    }
//browse($getvouch);
    $result = mysqli_query($conn,"SELECT * FROM `$maindb` WHERE $keyfld='$getvouch'") or die(mysqli_error($conn));
    $get = mysqli_fetch_array($result);
}

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

/* DELETE */
if (isset($_GET["delete"])) {
    delete($zdb, "$maindb", "$keyfld", $_GET[$keyfld], "$file?mode=last");
}
?>
<?php include("includes/linkshead.php"); ?>
<style>
    input[type = checkbox]{
        width: 20px;
        height: 20px;
    }
</style>
<script src="MyScript/user.js" type="text/javascript"></script>
<body>
    <!-- Default box -->
    <form action='' method='POST'>
        <!-- Default box -->
        <div class="">
            <div class="col-lg-6">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title"><?php Echo $formname; ?></h3>
                        <div class="actions pull-right">
                            <i class="fa fa-chevron-down"></i>
                        </div>
                    </div>
                    <div class="panel-body">
                        <div class="row">
                            <label class="col-sm-3 control-label marg">User Name</label>
                            <div class="col-sm-6">
                                <input type="text" class="form-control form" name="user" placeholder="User Name" autocomplete="off" value='<? echo ($addflag != 1) ? $get['user'] : ''; ?>' required="" autofocus>
                            </div>
                        </div>
                        <div class="row">
                            <label class="col-sm-3 control-label marg">Password</label>
                            <div class="col-sm-6">
                                <input type="password" class="form-control form" name="password" id="pass" autocomplete="off" placeholder="Password" value='<? echo ($addflag != 1) ? $get['password'] : ''; ?>' required="">
                            </div>
                        </div>
                        <div class="row">
                            <label class="col-sm-3 control-label marg">Confirm Pass</label>
                            <div class="col-sm-6">
                                <input type="password" name="confpass" id="confpass" class="form-control form"  placeholder="Cofirm Password" required="" value='<? echo ($addflag != 1) ? $get['password'] : ''; ?>'>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-sm-6">
                                <p id="alert"></p>
                            </div>
                        </div>
                        <div class="row">
                            <label class="col-sm-3 control-label marg">User Type</label>
                            <div class="col-sm-6">

                                <select class='form-control select2 form' name="usertype" id="usertype">                                    
                                    <?php
                                    if ($addflag != 1) {
                                        $usertyp = "";
                                        if ($get[usertype] == 1) {
                                            $ucode = "1";
                                            $usertyp = "Admin";
                                        }
                                        if ($get[usertype] == 2) {
                                            $ucode = "2";
                                            $usertyp = "Supervisor";
                                        }
                                        if ($get[usertype] == 3) {
                                            $ucode = "3";
                                            $usertyp = "Staff";
                                        }
                                        echo "<option value='$ucode'>$usertyp</option>";
                                    }
                                    ?>
                                    <option value=""></option>
                                    <option value="3">Staff</option>
                                    <option value="2">Supervisor</option>
                                    <option value="1">Admin</option>
                                </select>
                            </div>
                        </div>
                        <div class="nav-tabs-custom">
                            <ul class="nav nav-tabs">
                                <li class="active"><a href="#tab_1" data-toggle="tab" aria-expanded="true">Masters</a></li>
                                <li class=""><a href="#tab_2" data-toggle="tab" aria-expanded="false">Transaction</a></li>
                                <li class=""><a href="#tab_3" data-toggle="tab" aria-expanded="false">Reports</a></li>
                                <li class=""><a href="#tab_4" data-toggle="tab" aria-expanded="false">Registers</a></li>
                                <li class=""><a href="#tab_5" data-toggle="tab" aria-expanded="false">Finalization</a></li>
                                <li class=""><a href="#tab_6" data-toggle="tab" aria-expanded="false">Tools & DashBoard</a></li>
                            </ul>
                            <div class="tab-content">
                                <div class="tab-pane active" id="tab_1">
                                    <div class="row">
                                        <label class="col-sm-6 control-label marg selectall">Select All/UnSelect All</label>
                                        <div class="col-sm-1" style="margin-top:6px">
                                            <input type="checkbox" class="form " id="Smasters" value="1">
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Customer</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="customer" name="customer" value="1" <?
                                            if ($get[customer] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Supplier</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="supplier" name="supplier" value="1" <?
                                            if ($get[supplier] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Opening Balance</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="broker" name="openbal" value="1" <?
                                            if ($get[openbal] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Change Of Customer Details</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="chcustdtl" name="chcustdtl" value="1" <?
                                            if ($get[chcustdtl] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Driver</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="driver" name="driver" value="1" <?
                                            if ($get[driver] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Transporter</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="transport" name="transport" value="1" <?
                                            if ($get[transport] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Unit</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="unit" name="unit" value="1" <?
                                            if ($get[unit] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Change Of Rates</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="openstk" name="openstk" value="1" <?
                                            if ($get[openstk] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Staff</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="staff" name="staff" value="1" <?
                                            if ($get[staff] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Bank</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="bank" name="bank" value="1" <?
                                            if ($get[bank] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>

                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Cash</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="cash" name="cash" value="1" <?
                                            if ($get[cash] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Expense</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="expense" name="expense" value="1" <?
                                            if ($get[expense] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Item Group</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="itemgrp" name="itemgrp" value="1" <?
                                            if ($get[itemgrp] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Item Sub Group</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="itemsubgrp" name="itemsubgrp" value="1" <?
                                            if ($get[itemsubgrp] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Item</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="item" name="item" value="1" <?
                                            if ($get[item] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Group</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="group" name="group" value="1" <?
                                            if ($get[group] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Other A/c.</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="otherac" name="otherac" value="1" <?
                                            if ($get[otherac] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Sale Type</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="saletype" name="saletype" value="1" <?
                                            if ($get[saletype] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                </div><!-- /.tab-pane -->
                                <div class="tab-pane" id="tab_2">
                                    <div class="row">
                                        <label class="col-sm-6 control-label marg selectall">Select All/UnSelect All</label>
                                        <div class="col-sm-4" style="margin-top:6px">
                                            <input type="checkbox" class="form " id="Stransactions" value="1">
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Purchase</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="purchase" name="purchase" value="1" <?
                                            if ($get[purchase] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Sale</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="sale" name="sale" value="1" <?
                                            if ($get[sale] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Debit-note : Good Returns </label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="debnote" name="debnote" value="1" <?
                                            if ($get[debnote] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Debit-note : Other</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="deboth" name="deboth" value="1" <?
                                            if ($get[deboth] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Credit-note : Good Returns</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="crednote" name="crednote" value="1" <?
                                            if ($get[crednote] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Credit-note : Other</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="credoth" name="credoth" value="1" <?
                                            if ($get[credoth] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Inward</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="inward" name="inward" value="1" <?
                                            if ($get[inward] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Outward</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="outward" name="outward" value="1" <?
                                            if ($get[outward] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Damaged</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="damaged" name="damaged" value="1" <?
                                            if ($get[damaged] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Excess</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="excess" name="excess" value="1" <?
                                            if ($get[excess] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Bank Recd.</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="bankrecp" name="bankrecp" value="1" <?
                                            if ($get[bankrecp] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Bank Payment</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="bankpay" name="bankpay" value="1" <?
                                            if ($get[bankpay] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Cash Recd.</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="bankrecp" name="cashrecp" value="1" <?
                                            if ($get[cashrecp] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Cash Payment</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="cashpay" name="cashpay" value="1" <?
                                            if ($get[cashpay] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Contra</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="contra" name="contra" value="1" <?
                                            if ($get[contra] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Journal</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="journal" name="journal" value="1" <?
                                            if ($get[journal] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Tax Invoice</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="taxinv" name="taxinv" value="1" <?
                                            if ($get[taxinv] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Transfer</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="transfer" name="transfer" value="1" <?
                                            if ($get[transfer] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                </div><!-- /.tab-pane -->
                                <div class="tab-pane" id="tab_3">
                                    <div class="row">
                                        <label class="col-sm-6 control-label marg selectall">Select All/UnSelect All</label>
                                        <div class="col-sm-4" style="margin-top:6px">
                                            <input type="checkbox" class="form " id="Sreports" value="1">
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Stock</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="stock" name="stock" value="1" <?
                                            if ($get[stock] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Inward/Outward History</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="inwout" name="inwout" value="1" <?
                                            if ($get[inwout] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">V.A.T.</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="vatrep" name="vatrep" value="1" <?
                                            if ($get[vatrep] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Ledger</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="ledger" name="ledger" value="1" <?
                                            if ($get[ledger] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Labels</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="labels" name="labels" value="1" <?
                                            if ($get[labels] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Query- Cheque No.</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="chqrep" name="chqrep" value="1" <?
                                            if ($get[chqrep] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Query- Amount.</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="amtrep" name="amtrep" value="1" <?
                                            if ($get[amtrep] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Itemwise P/L</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="itemwise" name="itemwise" value="1" <?
                                            if ($get[itemwise] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Itemwise Sale</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="itemwisesale" name="itemwisesale" value="1" <?
                                            if ($get[itemwisesale] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Item Group Wise Sale</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="itemgrpwisesale" name="itemgrpwisesale" value="1" <?
                                            if ($get[itemgrpwisesale] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Party Wise Item Group Sale</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="partygrpwisesale" name="partygrpwisesale" value="1" <?
                                            if ($get[partygrpwisesale] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Leading Parties</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="leadparty" name="leadparty" value="1" <?
                                            if ($get[leadparty] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Daily Report</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="dailyreport" name="dailyreport" value="1" <?
                                            if ($get[dailyreport] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Daily Sale Report</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="dailysalereport" name="dailysalereport" value="1" <?
                                            if ($get[dailysalereport] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Bank Book</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="bankbook" name="bankbook" value="1" <?
                                            if ($get[bankbook] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Cash Book</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="cashbook" name="cashbook" value="1" <?
                                            if ($get[cashbook] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Journal Book</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="jvrep" name="jvrep" value="1" <?
                                            if ($get[jvrep] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Expense Report</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="exprep" name="exprep" value="1" <?
                                            if ($get[exprep] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Outstanding Payable</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="payablerep" name="payablerep" value="1" <?
                                            if ($get[payablerep] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Expense Receivable</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="receivable" name="receivable" value="1" <?
                                            if ($get[receivable] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                </div>
                                <!-- /.tab-pane -->
                                <div class="tab-pane" id="tab_4">
                                    <div class="row">
                                        <label class="col-sm-6 control-label marg selectall">Select All/UnSelect All</label>
                                        <div class="col-sm-4" style="margin-top:6px">
                                            <input type="checkbox" class="form " id="Sregisters" value="1">
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Purchase</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  registers" id="purreg" name="purreg" value="1" <?
                                            if ($get[purreg] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Sale</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  registers" id="salereg" name="salereg" value="1" <?
                                            if ($get[salereg] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Purchase Return/Debit-note - Good Returns</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  registers" id="debnotreg" name="debnotreg" value="1" <?
                                            if ($get[debnotreg] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Purchase Return/Debit-note - Others</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  registers" id="debothreg" name="debothreg" value="1" <?
                                            if ($get[debothreg] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Sale Return/Credit-note - Good Returns</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  registers" id="crednotreg" name="crednotreg" value="1" <?
                                            if ($get[crednotreg] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Sale Return/Credit-note - Others</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  registers" id="credothreg" name="credothreg" value="1" <?
                                            if ($get[credothreg] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Inward</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  registers" id="inwreg" name="inwreg" value="1" <?
                                            if ($get[inwreg] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Outward</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  registers" id="outreg" name="outreg" value="1" <?
                                            if ($get[outreg] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Damaged</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  registers" id="damreg" name="damreg" value="1" <?
                                            if ($get[damreg] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Excess</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  registers" id="excreg" name="excreg" value="1" <?
                                            if ($get[excreg] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Driver Wise Sale</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  registers" id="driverreg" name="driverreg" value="1" <?
                                            if ($get[driverreg] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Tax Invoice</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  registers" id="taxinvreg" name="taxinvreg" value="1" <?
                                            if ($get[taxinvreg] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Balance Register</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  registers" id="balreg" name="balreg" value="1" <?
                                            if ($get[balreg] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                </div> 
                                <div class="tab-pane" id="tab_5">
                                    <div class="row">
                                        <label class="col-sm-6 control-label marg selectall">Select All/UnSelect All</label>
                                        <div class="col-sm-4" style="margin-top:6px">
                                            <input type="checkbox" class="form " id="Sfinalization" value="1">
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Trial Balance</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  finalization" id="trbal" name="trbal" value="1" <?
                                            if ($get[trbal] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Profit/Loss</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  finalization" id="profit" name="profit" value="1" <?
                                            if ($get[profit] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Profit Sharing</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  finalization" id="profshar" name="profshar" value="1" <?
                                            if ($get[profshar] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Balance Sheet</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  finalization" id="balsheet" name="balsheet" value="1" <?
                                            if ($get[balsheet] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                </div> 
                                <div class="tab-pane" id="tab_6">
                                    <div class="row">
                                        <label class="col-sm-6 control-label marg selectall">Select All/UnSelect All</label>
                                        <div class="col-sm-4" style="margin-top:6px">
                                            <input type="checkbox" class="form " id="Stools" value="1">
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Company Setup</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  tools" id="compsetup" name="compsetup" value="1" <?
                                            if ($get[compsetup] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Backup</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  tools" id="backup" name="backup" value="1" <?
                                            if ($get[backup] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Profile</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  tools" id="profile" name="profile" value="1" <?
                                            if ($get[profile] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Stock</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  tools" id="dstock" name="dstock" value="1" <?
                                            if ($get[dstock] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                </div> 
                            </div><!-- /.tab-content -->
                        </div>
                    </div>
                    <div class="panel-footer">
                        <?php include("includes/buttons.php"); ?>
                    </div>
                </div>
            </div>
            <div class="col-lg-6 col-md-12 col-sm-12 col-xs-12 pad">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title">Year Details</h3>
                        <div class="actions pull-right">
                            <i class="fa fa-chevron-down"></i>
                        </div>
                    </div>
                    <div class="panel-body">
                        <div class="table-responsive">
                            <table class="table table-striped table-condensed table-bordered" width="100%">
                                <thead  class="mySearchTr">
                                    <tr>
                                        <th width="3%"></th>
                                        <th width="17%">Company</th>
                                        <th width="10%">Year</th>
                                        <th width="10%">Name</th>
                                        <th width="10%">From</th>
                                        <th width="10%">To</th>
                                    </tr>
                                </thead>
                                <tbody class="tbody">
                                    <?php
                                    if ($addflag != 1) {
                                        $ctr = 0;
                                        $gettran = mysqli_query($conn,"SELECT `cono`,`cname`,`finyear`,`startdate`,`lastdate`,`yearname` FROM `usercomp` WHERE `username`='$get[code]' ORDER BY `cono`")or die(mysqli_error($conn));
                                        while ($tran = mysqli_fetch_array($gettran)) {
                                            $fetcomp = mysqli_query($conn,"SELECT `code`,`name` FROM `company` WHERE `code`='$tran[cono]'")or die(mysqli_error($conn));
                                            $fcomp = mysqli_fetch_array($fetcomp);

                                            $fetyear = mysqli_query($conn,"SELECT `finyear` FROM `compyear` WHERE `finyear`='$tran[finyear]'")or die(mysqli_error($conn));
                                            $fyear = mysqli_fetch_array($fetyear);

                                            Echo "<tr>";
                                            Echo "<td><i class='fa fa-close remove' style='display:none;'></i></td>";
                                            Echo "<td>";
                                            Echo "<select class='form-control form cono select2' name='cono_$ctr' style='width:100%'>";
                                            Echo "<option value='$fcomp[code]'>$fcomp[name]</option>";
                                            $gcomp = mysqli_query($conn,"SELECT `code`,`name` FROM `company`")or die(mysqli_error($conn));
                                            while ($comp = mysqli_fetch_array($gcomp)) {
                                                Echo "<option value='$comp[code]'>$comp[name]</option>";
                                            }
                                            Echo "</select>";
                                            Echo "</td>";
                                            Echo "<td>";
                                            Echo "<select class='form-control form finyear select2' name='finyear_$ctr' style='width:100%'>";
                                            Echo "<option value='$fyear[finyear]'>$fyear[finyear]</option>";
                                            $gyear = mysqli_query($conn,"SELECT `finyear` FROM `compyear`")or die(mysqli_error($conn));
                                            while ($year = mysqli_fetch_array($gyear)) {
                                                Echo "<option value='$year[finyear]'>$year[finyear]</option>";
                                            }
                                            Echo "</select>";
                                            Echo "</td>";
                                            Echo "<td><input type='text' class='form-control form yearname' name='yearname_$ctr' value='$tran[yearname]' readonly></td>";
                                            Echo "<td><input type='text' class='form-control form startdate' name='startdate_$ctr' value='$tran[startdate]' readonly></td>";
                                            Echo "<td><input type='text' class='form-control form lastdate' name='lastdate_$ctr' value='$tran[lastdate]' readonly></td>";
                                            Echo "</tr >";
                                            $ctr++;
                                        }
                                    } else {
                                        ?>
                                        <tr>
                                            <td><i class='fa fa-close remove'></i></td>
                                            <td>
                                                <select class="form-control form cono select2" name="cono_0" style='width:100%' required>
                                                    <option value=""></option>
                                                    <?php
                                                    $gcomp = mysqli_query($conn,"SELECT `code`,`name` FROM `company`")or die(mysqli_error($conn));
                                                    while ($comp = mysqli_fetch_array($gcomp)) {
                                                        Echo "<option value='$comp[code]'>$comp[name]</option>";
                                                    }
                                                    ?>
                                                </select>
                                            </td>
                                            <td>
                                                <select class="form-control form finyear select2" name="finyear_0" style='width:100%' required>
                                                    <option value=""></option>
                                                    <?php
                                                    $gyear = mysqli_query($conn,"SELECT `finyear` FROM `compyear`")or die(mysqli_error($conn));
                                                    while ($year = mysqli_fetch_array($gyear)) {
                                                        Echo "<option value='$year[finyear]'>$year[finyear]</option>";
                                                    }
                                                    ?>
                                                </select>
                                            </td>
                                            <td><input type="text" class="form-control form yearname" name="yearname_0" value="" readonly></td>
                                            <td><input type="text" class="form-control form startdate" name="startdate_0" value="" readonly></td>
                                            <td><input type="text" class="form-control form lastdate" name="lastdate_0" value="" readonly></td>
                                        </tr>  
                                        <?
                                    }
                                    ?>
                                </tbody>
                            </table>
                        </div>
                        <div class="col-lg-12 pad">
                            <button type="button" class="btn btn-primary btn-square form"  id="addnew">
                                <i class="fa fa-plus" data-toggle='tooltip' title='Add Row'></i>    
                            </button>
                            <input type="hidden" id="items" name="items" value="<?php echo ($addflag != 1) ? $ctr : 1; ?>" />  
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
    <div class="modal fade bs-example-modal-lg" 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=" table-responsive">
                        <table id="example1" class="table table-striped">
                            <thead>
                                <tr class="mySearchTr">
                                    <th>code</th>
                                    <th>Name</th>
                                    <th>Action</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
                                if ($addflag != 1) {
                                    $srchresult = mysqli_query($conn,"SELECT * FROM `$maindb`")or die(mysqli_error($conn));
                                    while ($row = mysqli_fetch_array($srchresult)) {
                                        echo "<tr>";
                                        echo "<td align='left'>$row[code]</td>";
                                        echo "<td align='left'>$row[user]</td>";
                                        echo "<td align='left'><a href=\"$file?mode=edit&$keyfld=$row[$keyfld]\"><i class='fa fa-pencil' style='font-size:1.3em;color:#00C0EF;cursor:pointer;'></i></a></td>";
                                        echo "</tr>";
                                    }
                                }
                                ?>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="modal-footer"></div>
            </div>
        </div>
    </div>
</body>
</html>
<?php include("includes/linksfoot.php"); ?>