<?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];
$password = $_SESSION["password_" . $dbname];
$spectype = $_SESSION["spltype_" . $dbname];

//browse($spectype);
if ($spectype == "1") {
    $speccond = "and `compchng`='1'";
} else {
    $speccond = "and `compchng`=''";
}

$keycond = "and `spltype`='$spectype'";
//browse($spectype);

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

if (isset($_POST["submit"])) {
    $a = 1;
    $user = $_POST["user"];
    $password = $_POST["password"];
    $confpass = $_POST["confpass"];
    $spltype  = $_POST["spltype"];
    $usertype = $_POST["usertype"];
    $mobno    = $_POST["mobno"];
    ################## MASTERS ##################

    $airline   = $_POST["airline"];
    $sector    = $_POST["sector"];
    $city      = $_POST["city"];
    $tour      = $_POST["tour"];
    $hotelcatg = $_POST["hotelcatg"];
    $hotels    = $_POST["hotels"];
    $roomcatg  = $_POST["roomcatg"];
    $roomview  = $_POST["roomview"];
    $rooms     = $_POST["rooms"];
    $customer  = $_POST["customer"];
    $supplier  = $_POST["supplier"];
    $class     = $_POST["class"];
    $vehicle   = $_POST["vehicle"];
    $bank      = $_POST["bank"];
    $cash      = $_POST["cash"];
    $expense   = $_POST["expense"];
    $agent     = $_POST["agent"];
    $visa      = $_POST["visa"];
    $envprint      = $_POST["envprint"];

    ################## FIT ##################

    $fit_ent          = $_POST["fit_ent"];
    $hotelpurch      = $_POST["hotelpurch"];
    $osbill          = $_POST["osbill"];
    $summary         = $_POST["summary"];
    $tiktpurchreg    = $_POST["tiktpurchreg"];
    $hotelpurchreg   = $_POST["hotelpurchreg"];
    $laundrypurchreg = $_POST["laundrypurchreg"];
    $transpurchreg   = $_POST["transpurchreg"];
    $visapurchreg    = $_POST["visapurchreg"];
    $visanew         = $_POST["visanew"];
    $recdbook        = $_POST["recdbook"];

    ################## HAJ UMRAH ##################

    $bookform   = $_POST["bookform"];
    $paxform    = $_POST["paxform"];
    $updform    = $_POST["updform"];
    $classrep   = $_POST["classrep"];
    $monclass   = $_POST["monclass"];
    $agentclass = $_POST["agentclass"];
    $mainsum    = $_POST["mainsum"];
    $maindt     = $_POST["maindt"];
    $namerep    = $_POST["namerep"];
    $airrep     = $_POST["airrep"];
    $visarep    = $_POST["visarep"];
    $passexprep = $_POST["passexprep"];
    $qurrep     = $_POST["qurrep"];
    $datarep    = $_POST["datarep"];
    $ostt       = $_POST["ostt"];
    $revreg     = $_POST["revreg"];
    $payrecdreg = $_POST["payrecdreg"];
    $recpbook   = $_POST["recpbook"];
    $paybook    = $_POST["paybook"];
    $agewise    = $_POST["agewise"];

    ################## EXPENSES / ACCOUNTS ##################
    $bankrecp   = $_POST["bankrecp"];
    $cashrecp   = $_POST["cashrecp"];
    $bankpay    = $_POST["bankpay"];
    $cashpay    = $_POST["cashpay"];
    $ledger     = $_POST["ledger"];
    $bankpayexp = $_POST["bankpayexp"];
    $cashpayexp = $_POST["cashpayexp"];
    $expreg     = $_POST["expreg"];

    ################## DASHBOARD ##################

    $tourname = $_POST["tourname"];
    $compsetup = $_POST["compsetup"];
    $hotelstat = $_POST["hotelstat"];
    $checkinout = $_POST["checkinout"];
    $inquiry   = $_POST["inquiry"];

    if (isset($_POST["name"])) {
        $result = mysqli_query($conn, "SELECT * FROM `$maindb` WHERE `user`= '$user' AND code != '$qvouch' and `spltype`='$spectype'") 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));
        $count = $_POST["items"];
        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 `compname` FROM `company` WHERE `code`='$cono'") or die(mysqli_error($conn));
                $co = mysqli_fetch_array($company);
                $cname = $co['compname'];

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

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

        if ($addflag == 1) {
            // $usecode = mysqli_query($conn, "SELECT code FROM `passmain` WHERE user='$username' and `password`='$password' and `spltype`='$spltype'") or die(mysqli_error($conn));
            // $getuser = mysqli_fetch_object($usecode);
            // $code = $getuser->code;
            mysqli_query($conn, "INSERT INTO `$maindb`(`code`, `user`, `password`, `confpass`,`spltype`, `usertype`, `mobno`,
                                                        `airline`, `sector`, `city`, `tour`, `hotelcatg`, `hotels`, `roomcatg`, `roomview`, `rooms`,
                                                        `customer`, `supplier`, `class`, `vehicle`, `bank`, `cash`, `expense`, `agent`, `visa`, `envprint`,
                                                        `fit_ent`, `hotelpurch`, `osbill`, `summary`, `tiktpurchreg`, `hotelpurchreg`, `laundrypurchreg`,
                                                        `transpurchreg`, `visapurchreg`, `bookform`, `paxform`, `updform`, `classrep`, `monclass`, `agentclass`,
                                                        `mainsum`, `maindt`, `namerep`, `airrep`, `visarep`, `passexprep`, `qurrep`, `datarep`, `ostt`, `revreg`, 
                                                        `payrecdreg`,`recpbook`, `paybook`, `agewise`, `bankrecp`, `cashrecp`, `bankpay`,`cashpay`,`ledger`, `bankpayexp`,
                                                        `cashpayexp`, `expreg`,`tourname`,`visanew`,`compsetup`, `hotelstat`, `checkinout`, `recdbook`, `inquiry`)
                                                VALUES ('$qvouch', '$user', '$password', '$confpass','$spltype', '$usertype', '$mobno',
                                                        '$airline', '$sector', '$city', '$tour', '$hotelcatg', '$hotels', '$roomcatg', '$roomview', '$rooms',
                                                        '$customer', '$supplier', '$class', '$vehicle','$bank', '$cash' ,'$expense','$agent','$visa', '$envprint',
                                                        '$fit_ent','$hotelpurch','$osbill', '$summary', '$tiktpurchreg', '$hotelpurchreg', '$laundrypurchreg',
                                                        '$transpurchreg', '$visapurchreg', '$bookform', '$paxform','$updform', '$classrep','$monclass', '$agentclass',
                                                        '$mainsum', '$maindt', '$namerep', '$airrep','$visarep','$passexprep', '$qurrep', '$datarep', '$ostt', '$revreg',
                                                        '$payrecdreg','$recpbook', '$paybook', '$agewise', '$bankrecp','$cashrecp', '$bankpay','$cashpay', '$ledger', '$bankpayexp',
                                                        '$cashpayexp', '$expreg','$tourname','$visanew', '$compsetup', '$hotelstat', '$checkinout', '$recdbook', '$inquiry')") or die(mysqli_error($conn));
            insmess();
            $mvouch = $qvouch;
            header("refresh: 1; $file?$keyfld=$mvouch&mode=edit&spltype=$spectype");
        } else {
            $mvouch = $qvouch;

            $usecode = mysqli_query($conn, "SELECT code FROM `passmain` WHERE user='$username' and `password`='$password' and `spltype`='$spltype'") or die(mysqli_error($conn));
            $getuser = mysqli_fetch_object($usecode);
            $code = $getuser->code;
            mysqli_query($conn, "UPDATE `$maindb` SET  `user`='$user', `password`='$password', `confpass`='$confpass',`usertype`='$usertype',mobno='$mobno',
                                        `airline`='$airline', `sector`='$sector', `city`='$city', `tour`='$tour',`hotelcatg`='$hotelcatg',
                                        `hotels`='$hotels', `roomcatg`='$roomcatg', `roomview`='$roomview', `rooms`='$rooms',`customer`='$customer',
                                        `supplier`='$supplier', `class`='$class', `vehicle`='$vehicle',`bank`='$bank', `cash`='$cash',
                                        `expense`='$expense', `agent`='$agent', `visa`='$visa', `envprint`='$envprint', `fit_ent`='$fit_ent',`hotelpurch`='$hotelpurch',
                                        `osbill`='$osbill',`summary`='$summary',`tiktpurchreg`='$tiktpurchreg',`hotelpurchreg`='$hotelpurchreg', `laundrypurchreg`='$laundrypurchreg',
                                        `transpurchreg`='$transpurchreg', `visapurchreg`='$visapurchreg',`bookform`='$bookform', `paxform`='$paxform', `updform`='$updform',
                                        `classrep`='$classrep',`monclass`='$monclass', `agentclass`='$agentclass', `mainsum`='$mainsum', `maindt`='$maindt',
                                        `namerep`='$namerep',`airrep`='$airrep', `visarep`='$visarep', `passexprep`='$passexprep', `qurrep`='$qurrep',
                                        `datarep`='$datarep',`ostt`='$ostt', `revreg`='$revreg', `payrecdreg`='$payrecdreg', `recpbook`='$recpbook',
                                        `paybook`='$paybook',`agewise`='$agewise', `bankrecp`='$bankrecp', `cashrecp`='$cashrecp', `bankpay`='$bankpay',
                                        `cashpay`='$cashpay',`ledger`='$ledger', `bankpayexp`='$bankpayexp', `cashpayexp`='$cashpayexp', `expreg`='$expreg',
                                        `tourname`='$tourname', `visanew`='$visanew', `compsetup`='$compsetup', `recdbook`='$recdbook', `hotelstat`='$hotelstat', `checkinout`='$checkinout', `inquiry`='$inquiry'
                                         WHERE code = '$mvouch' and `spltype`='$spltype' ") or die(mysqli_error($conn));
            updmess();
            header("refresh: 1; $file?$keyfld=$mvouch&spltype=$spectype&mode=edit");
        }
    }
}

if ($addflag != 1) {

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

if ($get['usertype'] == "1") { ?>
    <style>
       #hdelete {
           display: none;
       }
    </style>
<?php }

$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;
        margin-bottom: 10px;
    }
</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>
                    <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 focusfield user" name="user" placeholder="User" 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="Confirm Password" required="" value='<? echo ($addflag != 1) ? $get['confpass'] : ''; ?>'>
                            </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>

                        <?php
                        if ($spectype == "1") {
                        ?>
                            <div class="row">
                                <label class="col-sm-4 control-label marg">Special</label>
                                <div class="col-sm-2" style="margin-top:6px">
                                    <input type="checkbox" class="form  spltype" id="spltype" name="spltype" value="1" <?
                                                                                                                        if ($get['spltype'] == 1) {
                                                                                                                            echo "checked";
                                                                                                                        }
                                                                                                                        ?>>
                                </div>
                            </div>
                        <?php } ?>

                        <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">Fit</a></li>
                                <li class=""><a href="#tab_3" data-toggle="tab" aria-expanded="false">Haj Umrah</a></li>
                                <li class=""><a href="#tab_4" data-toggle="tab" aria-expanded="false">Expenses/Accounts</a></li>
                                <li class=""><a href="#tab_5" data-toggle="tab" aria-expanded="false">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-4" style="margin-top:6px">
                                            <input type="checkbox" class="form " id="Smasters" value="1">
                                        </div>
                                    </div>
                                    <br>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Airline</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="airline" name="airline" value="1" <?
                                                                                                                                if ($get['airline'] == 1) {
                                                                                                                                    echo "checked";
                                                                                                                                }
                                                                                                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Sector</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  master" id="sector" name="sector" value="1" <?
                                                                                                                            if ($get['sector'] == 1) {
                                                                                                                                echo "checked";
                                                                                                                            }
                                                                                                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">City</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="city" name="city" value="1" <?
                                                                                                                            if ($get['city'] == 1) {
                                                                                                                                echo "checked";
                                                                                                                            }
                                                                                                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Tour</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  master" id="tour" name="tour" value="1" <?
                                                                                                                        if ($get['tour'] == 1) {
                                                                                                                            echo "checked";
                                                                                                                        }
                                                                                                                        ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Hotel Category</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="hotelcatg" name="hotelcatg" value="1" <?
                                                                                                                                    if ($get['hotelcatg'] == 1) {
                                                                                                                                        echo "checked";
                                                                                                                                    }
                                                                                                                                    ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Hotels</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  master" id="hotels" name="hotels" value="1" <?
                                                                                                                            if ($get['hotels'] == 1) {
                                                                                                                                echo "checked";
                                                                                                                            }
                                                                                                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Room Category</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="roomcatg" name="roomcatg" value="1" <?
                                                                                                                                    if ($get['roomcatg'] == 1) {
                                                                                                                                        echo "checked";
                                                                                                                                    }
                                                                                                                                    ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Room View</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  master" id="roomview" name="roomview" value="1" <?
                                                                                                                                if ($get['roomview'] == 1) {
                                                                                                                                    echo "checked";
                                                                                                                                }
                                                                                                                                ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Rooms</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="rooms" name="rooms" value="1" <?
                                                                                                                            if ($get['rooms'] == 1) {
                                                                                                                                echo "checked";
                                                                                                                            }
                                                                                                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Customer</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  master" id="customer" name="customer" value="1" <?
                                                                                                                                if ($get['customer'] == 1) {
                                                                                                                                    echo "checked";
                                                                                                                                }
                                                                                                                                ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <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>
                                        <label class="col-sm-4 control-label marg">Class</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  master" id="class" name="class" value="1" <?
                                                                                                                            if ($get['class'] == 1) {
                                                                                                                                echo "checked";
                                                                                                                            }
                                                                                                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Vehicle</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="vehicle" name="vehicle" value="1" <?
                                                                                                                                if ($get['vehicle'] == 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  master" 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  master" 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">Agent</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="agent" name="agent" value="1" <?
                                                                                                                            if ($get['agent'] == 1) {
                                                                                                                                echo "checked";
                                                                                                                            }
                                                                                                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Visa</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  master" id="visa" name="visa" value="1" <?
                                                                                                                        if ($get['visa'] == 1) {
                                                                                                                            echo "checked";
                                                                                                                        }
                                                                                                                        ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Envelope Print</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="envprint" name="envprint" value="1" <?
                                                                                                                            if ($get['envprint'] == 1) {
                                                                                                                                echo "checked";
                                                                                                                            }
                                                                                                                            ?>>
                                        </div>
                                    </div>
                                </div>
                                
                                <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-1" style="margin-top:6px">
                                            <input type="checkbox" class="form" id="Sfit" value="1">
                                        </div>
                                    </div>
                                    <br>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Quotation + Invoice</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  fit" id="fit_ent" name="fit_ent" value="1" <?
                                                                                                                            if ($get['fit_ent'] == 1) {
                                                                                                                                echo "checked";
                                                                                                                            }
                                                                                                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Hotel Purchase</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  fit" id="hotelpurch" name="hotelpurch" value="1" <?
                                                                                                                                    if ($get['hotelpurch'] == 1) {
                                                                                                                                        echo "checked";
                                                                                                                                    }
                                                                                                                                    ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Outstanding Receivable</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  fit" id="osbill" name="osbill" value="1" <?
                                                                                                                            if ($get['osbill'] == 1) {
                                                                                                                                echo "checked";
                                                                                                                            }
                                                                                                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Summary</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  fit" id="summary" name="summary" value="1" <?
                                                                                                                            if ($get['summary'] == 1) {
                                                                                                                                echo "checked";
                                                                                                                            }
                                                                                                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Ticket & Airline Register</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  fit" id="tiktpurchreg" name="tiktpurchreg" value="1" <?
                                                                                                                                        if ($get['tiktpurchreg'] == 1) {
                                                                                                                                            echo "checked";
                                                                                                                                        }
                                                                                                                                        ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Hotel Register</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  fit" id="hotelpurchreg" name="hotelpurchreg" value="1" <?
                                                                                                                                        if ($get['hotelpurchreg'] == 1) {
                                                                                                                                            echo "checked";
                                                                                                                                        }
                                                                                                                                        ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Laundry Register</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  fit" id="laundrypurchreg" name="laundrypurchreg" value="1" <?
                                                                                                                                            if ($get['laundrypurchreg'] == 1) {
                                                                                                                                                echo "checked";
                                                                                                                                            }
                                                                                                                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Transportation Register</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  fit" id="transpurchreg" name="transpurchreg" value="1" <?
                                                                                                                                        if ($get['transpurchreg'] == 1) {
                                                                                                                                            echo "checked";
                                                                                                                                        }
                                                                                                                                        ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Visa Register</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  fit" id="visapurchreg" name="visapurchreg" value="1" <?
                                                                                                                                        if ($get['visapurchreg'] == 1) {
                                                                                                                                            echo "checked";
                                                                                                                                        }
                                                                                                                                        ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Visa New</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  fit" id="visanew" name="visanew" value="1" <?
                                                                                                                            if ($get['visanew'] == 1) {
                                                                                                                                echo "checked";
                                                                                                                            }
                                                                                                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Received Register</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                        <input type="checkbox" class="form  fit" id="recdbook" name="recdbook" value="1" <?
                                                                                                                                        if ($get['recdbook'] == 1) {
                                                                                                                                            echo "checked";
                                                                                                                                        }
                                                                                                                                        ?>>
                                        </div>
                                    </div>
                                </div>
                                <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-1" style="margin-top:6px">
                                            <input type="checkbox" class="form " id="ShajUmrah" value="1">
                                        </div>
                                    </div>
                                    <br>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Booking Form</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  hajUmrah" id="bookform" name="bookform" value="1" <?
                                                                                                                                    if ($get['bookform'] == 1) {
                                                                                                                                        echo "checked";
                                                                                                                                    }
                                                                                                                                    ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Pax Form</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  hajUmrah" id="paxform" name="paxform" value="1" <?
                                                                                                                                if ($get['paxform'] == 1) {
                                                                                                                                    echo "checked";
                                                                                                                                }
                                                                                                                                ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Update Form</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  hajUmrah" id="updform" name="updform" value="1" <?
                                                                                                                                if ($get['updform'] == 1) {
                                                                                                                                    echo "checked";
                                                                                                                                }
                                                                                                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Class Report</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  hajUmrah" id="classrep" name="classrep" value="1" <?
                                                                                                                                    if ($get['classrep'] == 1) {
                                                                                                                                        echo "checked";
                                                                                                                                    }
                                                                                                                                    ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Monthly Class</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  hajUmrah" id="monclass" name="monclass" value="1" <?
                                                                                                                                    if ($get['monclass'] == 1) {
                                                                                                                                        echo "checked";
                                                                                                                                    }
                                                                                                                                    ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Agentwise Class</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  hajUmrah" id="agentclass" name="agentclass" value="1" <?
                                                                                                                                        if ($get['agentclass'] == 1) {
                                                                                                                                            echo "checked";
                                                                                                                                        }
                                                                                                                                        ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Main - Summary</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  hajUmrah" id="mainsum" name="mainsum" value="1" <?
                                                                                                                                if ($get['mainsum'] == 1) {
                                                                                                                                    echo "checked";
                                                                                                                                }
                                                                                                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Main - Detail</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  hajUmrah" id="maindt" name="maindt" value="1" <?
                                                                                                                                if ($get['maindt'] == 1) {
                                                                                                                                    echo "checked";
                                                                                                                                }
                                                                                                                                ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Namelist</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  hajUmrah" id="namerep" name="namerep" value="1" <?
                                                                                                                                if ($get['namerep'] == 1) {
                                                                                                                                    echo "checked";
                                                                                                                                }
                                                                                                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Airline Report</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  hajUmrah" id="airrep" name="airrep" value="1" <?
                                                                                                                                if ($get['airrep'] == 1) {
                                                                                                                                    echo "checked";
                                                                                                                                }
                                                                                                                                ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Visa </label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  hajUmrah" id="visarep" name="visarep" value="1" <?
                                                                                                                                if ($get['visarep'] == 1) {
                                                                                                                                    echo "checked";
                                                                                                                                }
                                                                                                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Passport Enquiry</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  hajUmrah" id="passexprep" name="passexprep" value="1" <?
                                                                                                                                        if ($get['passexprep'] == 1) {
                                                                                                                                            echo "checked";
                                                                                                                                        }
                                                                                                                                        ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Qurbani</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  hajUmrah" id="qurrep" name="qurrep" value="1" <?
                                                                                                                                if ($get['qurrep'] == 1) {
                                                                                                                                    echo "checked";
                                                                                                                                }
                                                                                                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Data to XL</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  hajUmrah" id="datarep" name="datarep" value="1" <?
                                                                                                                                if ($get['datarep'] == 1) {
                                                                                                                                    echo "checked";
                                                                                                                                }
                                                                                                                                ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Outstanding</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  hajUmrah" id="ostt" name="ostt" value="1" <?
                                                                                                                            if ($get['ostt'] == 1) {
                                                                                                                                echo "checked";
                                                                                                                            }
                                                                                                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Revenue</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  hajUmrah" id="revreg" name="revreg" value="1" <?
                                                                                                                                if ($get['revreg'] == 1) {
                                                                                                                                    echo "checked";
                                                                                                                                }
                                                                                                                                ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Payment Received</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  hajUmrah" id="payrecdreg" name="payrecdreg" value="1" <?
                                                                                                                                        if ($get['payrecdreg'] == 1) {
                                                                                                                                            echo "checked";
                                                                                                                                        }
                                                                                                                                        ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Receipt Book</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  hajUmrah" id="recpbook" name="recpbook" value="1" <?
                                                                                                                                    if ($get['recpbook'] == 1) {
                                                                                                                                        echo "checked";
                                                                                                                                    }
                                                                                                                                    ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Payment Book</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  hajUmrah" id="paybook" name="paybook" value="1" <?
                                                                                                                                if ($get['paybook'] == 1) {
                                                                                                                                    echo "checked";
                                                                                                                                }
                                                                                                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Agewise</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  hajUmrah" id="agewise" name="agewise" value="1" <?
                                                                                                                                if ($get['agewise'] == 1) {
                                                                                                                                    echo "checked";
                                                                                                                                }
                                                                                                                                ?>>
                                        </div>
                                    </div>
                                </div>


                                <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="Sexpenses" value="1">
                                        </div>
                                    </div>
                                    <br>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Bank Receipt</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  expenses" id="bankrecp" name="bankrecp" value="1" <?
                                                                                                                                    if ($get['bankrecp'] == 1) {
                                                                                                                                        echo "checked";
                                                                                                                                    }
                                                                                                                                    ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Cash Receipt</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form expenses" id="cashrecp" name="cashrecp" value="1" <?
                                                                                                                                    if ($get['cashrecp'] == 1) {
                                                                                                                                        echo "checked";
                                                                                                                                    }
                                                                                                                                    ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <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  expenses" id="bankpay" name="bankpay" value="1" <?
                                                                                                                                if ($get['bankpay'] == 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 expenses" 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">Ledger</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  expenses" id="ledger" name="ledger" value="1" <?
                                                                                                                                if ($get['ledger'] == 1) {
                                                                                                                                    echo "checked";
                                                                                                                                }
                                                                                                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Expense Entry-Bank</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form expenses" id="bankpayexp" name="bankpayexp" value="1" <?
                                                                                                                                        if ($get['bankpayexp'] == 1) {
                                                                                                                                            echo "checked";
                                                                                                                                        }
                                                                                                                                        ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Expense Entry-Cash</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  expenses" id="cashpayexp" name="cashpayexp" value="1" <?
                                                                                                                                        if ($get['cashpayexp'] == 1) {
                                                                                                                                            echo "checked";
                                                                                                                                        }
                                                                                                                                        ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Expense Register</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form expenses" id="expreg" name="expreg" value="1" <?
                                                                                                                                if ($get['expreg'] == 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">
                                            <input type="checkbox" class="form " id="Sdashboard" value="1">
                                        </div>
                                    </div>
                                    <br>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Tour</label>
                                        <div class="col-sm-2">
                                            <input type="checkbox" class="form  dashboard" id="tourname" name="tourname" value="1" <?
                                                                                                                                    if ($get['tourname'] == 1) {
                                                                                                                                        echo "checked";
                                                                                                                                    }
                                                                                                                                    ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Company Setup</label>
                                        <div class="col-sm-2">
                                            <input type="checkbox" class="form  dashboard" id="compsetup" name="compsetup" value="1" <?
                                                                                                                                        if ($get['compsetup'] == 1) {
                                                                                                                                            echo "checked";
                                                                                                                                        }
                                                                                                                                        ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Hotel Status</label>
                                        <div class="col-sm-2">
                                            <input type="checkbox" class="form  dashboard" id="hotelstat" name="hotelstat" value="1" <?
                                                                                                                                        if ($get['hotelstat'] == 1) {
                                                                                                                                            echo "checked";
                                                                                                                                        }
                                                                                                                                        ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Check In / Out</label>
                                        <div class="col-sm-2">
                                            <input type="checkbox" class="form  dashboard" id="checkinout" name="checkinout" value="1" <?
                                                                                                                                    if ($get['checkinout'] == 1) {
                                                                                                                                        echo "checked";
                                                                                                                                    }
                                                                                                                                    ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Waiting List</label>
                                        <div class="col-sm-2">
                                            <input type="checkbox" class="form  dashboard" id="inquiry" name="inquiry" value="1" <?
                                                                                                                                        if ($get['inquiry'] == 1) {
                                                                                                                                            echo "checked";
                                                                                                                                        }
                                                                                                                                        ?>>
                                        </div>
                                    </div>
                                </div>
                                <br>
                            </div>
                            <div class="panel-footer">
                                <?php include("includes/buttons.php"); ?>
                            </div>
                        </div>
                    </div>
                </div>

            </div>

            <div class="col-lg-6">
                <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`,`compname` 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[compname]</option>";
                                        $gcomp = mysqli_query($conn, "SELECT `code`,`compname` FROM `company` where code !='' $speccond") or die(mysqli_error($conn));
                                        while ($comp = mysqli_fetch_array($gcomp)) {
                                            echo "<option value='$comp[code]'>$comp[compname]</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` where finyear != '' group by finyear") 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`,`compname` FROM `company` where code !='' $speccond") or die(mysqli_error($conn));

                                                while ($comp = mysqli_fetch_array($gcomp)) {
                                                    echo "<option value='$comp[code]'>$comp[compname]</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` group by finyear") 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>
    </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` where code!='' $keycond") 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"); ?>