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

$formname = 'User Creation';
$maindb = 'usermain';
$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["username"];
    $password = $_POST["password"];
    $spltype = $_POST["spltype"];
    $usertype = $_POST["usertype"];

    ################## Masters ##################
    $customer = $_POST["customer"];
    $supplier = $_POST["supplier"];
    $agent    = $_POST["agent"];
    $bank     = $_POST["bank"];
    $cash     = $_POST["cash"];
    $setting  = $_POST["setting"];

    ################## HR ##################
    $hr_ent  = $_POST["hr_ent"];
    $pending = $_POST["pending"];
    $hrreg   = $_POST["hrreg"];

    ################## Courier ##################
    $courin     = $_POST["courin"];
    $courout    = $_POST["courout"];
    $pendppcour = $_POST["pendppcour"];
    
    ################## Entries ##################
    $addnewvisa     = $_POST["addnewvisa"];
    $submission_ent = $_POST["submission_ent"];
    $stampdate_upd  = $_POST["stampdate_upd"];
    $mofa_ent       = $_POST["mofa_ent"];
    $release        = $_POST["release"];
    $crm            = $_POST["crm"];
    $movefile       = $_POST["movefile"];
    
    ################## Immigration ##################
    $immig     = $_POST["immig"];
    $immiglist = $_POST["immiglist"];
    
    ################## Purchase ##################
    $tiktnew    = $_POST["tiktnew"];
    $tiktnewreg = $_POST["tiktnewreg"];
    $agentreg   = $_POST["agentreg"];
    
    ################## Invoice ##################
    $entinvoice = $_POST["entinvoice"];
    $settent = $_POST["settent"];
    $settreg = $_POST["settreg"];
    // $agentreg   = $_POST["agentreg"];
    $osbill     = $_POST["osbill"];
    
    ################## Accounts ##################
    // $agentreg = $_POST["agentreg"];
    $bankrecp = $_POST["bankrecp"];
    $bankpay  = $_POST["bankpay"];
    $cashrecp = $_POST["cashrecp"];
    $cashpay  = $_POST["cashpay"];
    $ledger   = $_POST["ledger"];
    // $agentreg = $_POST["agentreg"];
    
    ################## Reports ##################
    $visareg       = $_POST["visareg"];
    // $agentreg      = $_POST["agentreg"];
    $submission    = $_POST["submission"];
    $nonsubmission = $_POST["nonsubmission"];
    $mofalist      = $_POST["mofalist"];
    
    ################## Tools ##################
    $searchvisa   = $_POST["searchvisa"];
    $pastatus     = $_POST["pastatus"];


    if (isset($_POST["name"])) {
        $result = mysqli_query($conn, "SELECT * FROM `$maindb` WHERE `username`= '$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 `name` FROM `company` WHERE `code`='$cono'") or die(mysqli_error($conn));
                $co = mysqli_fetch_array($company);
                $cname = $co['name'];

                mysqli_query($conn, "INSERT INTO `$trandb`(`username`,`cono`,`cname`, `finyear`, `yearname`, `startdate`, `lastdate`, `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 `usermain` WHERE username='$user' 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`, `username`, `password`, `spltype`, `usertype`,
                                                        `customer`,`supplier`,`agent`,`bank`,`cash`,`hr_ent`,`pending`,`hrreg`,`courin`,`courout`,`pendppcour`,`addnewvisa`,
                                                        `submission_ent`,`stampdate_upd`,`mofa_ent`,`release`,`crm`,`movefile`,`immig`,`immiglist`,`tiktnew`,`tiktnewreg`,`entinvoice`,
                                                        `osbill`,`bankrecp`,`bankpay`,`cashrecp`,`cashpay`,`ledger`,`visareg`,`submission`,`nonsubmission`,`mofalist`, `searchvisa`,`setting`,`pastatus`,`settent`,`settreg`)
                                              VALUES('$qvouch', '$user', '$password', '$spltype', '$usertype',
                                                        '$customer','$supplier','$agent','$bank','$cash','$hr_ent','$pending','$hrreg','$courin','$courout','$pendppcour','$addnewvisa',
                                                        '$submission_ent','$stampdate_upd','$mofa_ent','$release','$crm','$movefile','$immig','$immiglist','$tiktnew','$tiktnewreg',
                                                        '$entinvoice','$osbill','$bankrecp','$bankpay','$cashrecp','$cashpay','$ledger','$visareg','$submission','$nonsubmission',
                                                        '$mofalist', '$searchvisa','$setting','$pastatus','$settent','$settreg')") 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 `usermain` WHERE username='$user' 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  `username`='$user', `password`='$password', `usertype`='$usertype',
                                                       `customer`='$customer',`supplier`='$supplier',`agent`='$agent',`bank`='$bank',`cash`='$cash',`hr_ent`='$hr_ent',`pending`='$pending',
                                                       `hrreg`='$hrreg',`courin`='$courin',`courout`='$courout',`pendppcour`='$pendppcour',`addnewvisa`='$addnewvisa',
                                                       `submission_ent`='$submission_ent',`stampdate_upd`='$stampdate_upd',`mofa_ent`='$mofa_ent',`release`='$release',`crm`='$crm',
                                                       `movefile`='$movefile',`immig`='$immig',`immiglist`='$immiglist',`tiktnew`='$tiktnew',`tiktnewreg`='$tiktnewreg',`entinvoice`='$entinvoice',
                                                       `osbill`='$osbill',`bankrecp`='$bankrecp',`bankpay`='$bankpay',`cashrecp`='$cashrecp',`cashpay`='$cashpay',`ledger`='$ledger',
                                                       `visareg`='$visareg',`submission`='$submission',`nonsubmission`='$nonsubmission',`mofalist`='$mofalist', `searchvisa`='$searchvisa',
                                                       `setting`='$setting', `pastatus`='$pastatus',`settent`='$settent',`settreg`='$settreg'
                                                        WHERE code = '$mvouch'") or die(mysqli_error($conn));
            updmess();
            //            browse($spectype); 
            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);
}

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

/* DELETE */
if (isset($_GET["delete"])) {
    delete($zdb, "$maindb", "$keyfld", $_GET[$keyfld], "$file?mode=last");
}
?>
<?php include("includes/linkshead.php"); ?>
<style>
    input[type=checkbox] {
        width: 20px;
        height: 20px;
    }
</style>
<script src="MyScript/user.js" type="text/javascript"></script>

<body>
    <!--Default box-->
    <form action='' method='POST'>
        <!--Default box-->
        <div class="">
            <div class="col-lg-7">

                <div class="panel panel-default">

                    <div class="panel-heading">
                        <h3 class="panel-title"><?php echo $formname; ?></h3>
                        <div class="actions pull-right">
                            <i class="fa fa-chevron-down"></i>
                        </div>
                    </div>
                    <div class="panel-body">


                        <div class="row">
                            <label class="col-sm-3 control-label marg">User Name</label>
                            <div class="col-sm-6">
                                <input type="text" class="form-control form username" name="username" placeholder="User" autocomplete="off" value='<? echo ($addflag != 1) ? $get['username'] : ''; ?>' 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 password" 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 confpass" placeholder="Confirm Password" required="" value='<? echo ($addflag != 1) ? $get['password'] : ''; ?>'>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-sm-6">
                                <p id="alert"></p>
                            </div>
                        </div>
                        <div class="row">
                            <label class="col-sm-3 control-label marg">User Type</label>
                            <div class="col-sm-6">

                                <select class='form-control select2 form' name="usertype" id="usertype">
                                    <?php
                                    if ($addflag != 1) {
                                        $usertyp = "";
                                        if ($get['usertype'] == 1) {
                                            $ucode = "1";
                                            $usertyp = "Supervisor";
                                        }
                                        if ($get['usertype'] == 2) {
                                            $ucode = "2";
                                            $usertyp = "Admin";
                                        }
                                        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">Admin</option>
                                    <option value="1">Supervisor</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">Master</a></li>
                                <li class=""><a href="#tab_2" data-toggle="tab" aria-expanded="false">HR / Courier</a></li>
                                <li class=""><a href="#tab_3" data-toggle="tab" aria-expanded="false">Entries</a></li>
                                <li class=""><a href="#tab_4" data-toggle="tab" aria-expanded="false">Immigration / Purchase</a></li>
                                <li class=""><a href="#tab_5" data-toggle="tab" aria-expanded="false">Invoice</a></li>
                                <li class=""><a href="#tab_6" data-toggle="tab" aria-expanded="false">Accounts</a></li>
                                <li class=""><a href="#tab_7" data-toggle="tab" aria-expanded="false">Setting</a></li>
                                <li class=""><a href="#tab_8" data-toggle="tab" aria-expanded="false">Tools</a></li>
                            </ul>
                            <div class="tab-content">
                                <div class="tab-pane active" id="tab_1">
                                    <div class="row">
                                        <label class="col-sm-4 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>

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

                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">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">Bank</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="bank" name="bank" value="1"
                                                <?
                                                if ($get['bank'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>

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

                                </div><!-- /.tab-pane -->

                                <!-- ###################### HR / Courier ############################# -->

                                <div class="tab-pane" id="tab_2">
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg selectall">Select All/UnSelect All</label>
                                        <div class="col-sm-4" style="margin-top:6px">
                                            <input type="checkbox" class="form hr" id="Shr" value="1">
                                        </div>
                                    </div>

                                    <h4 style="border-bottom: 1px solid black;width:10%; text-align:center"><strong>HR</strong></h4>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">HR</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  hr" id="hr_ent" name="hr_ent" value="1"
                                                <?
                                                if ($get['hr_ent'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Pending</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  hr" id="pending" name="pending" value="1"
                                                <?
                                                if ($get['pending'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>

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

                                    <h4 style="border-bottom: 1px solid black;width:10%; text-align:center"><strong>Courier</strong></h4>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Courier In</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  hr" id="courin" name="courin" value="1"
                                                <?
                                                if ($get['courin'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Courier Out</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  hr" id="courout" name="courout" value="1"
                                                <?
                                                if ($get['courout'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>

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

                                <!-- ###################### Entries ############################# -->

                                <div class="tab-pane" id="tab_3">
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg selectall">Select All/UnSelect All</label>
                                        <div class="col-sm-4" style="margin-top:6px">
                                            <input type="checkbox" class="form entries" id="Sentries" value="1">
                                        </div>
                                    </div>

                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Add New Entry</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  entries" id="addnewvisa" name="addnewvisa" value="1"
                                                <?
                                                if ($get['addnewvisa'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Submission Update</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  entries" id="submission_ent" name="submission_ent" value="1"
                                                <?
                                                if ($get['submission_ent'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>

                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Stamping Date Update</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  entries" id="stampdate_upd" name="stampdate_upd" value="1"
                                                <?
                                                if ($get['stampdate_upd'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Mofa Update</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  entries" id="mofa_ent" name="mofa_ent" value="1"
                                                <?
                                                if ($get['mofa_ent'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>
                                    <!-- <div class="row">
                                        <label class="col-sm-4 control-label marg">Release Update</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  entries" id="release" name="release" value="1"
                                                <?
                                                if ($get['release'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">CRM</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  entries" id="crm" name="crm" value="1"
                                                <?
                                                if ($get['crm'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div> -->
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Move File</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  entries" id="movefile" name="movefile" value="1"
                                                <?
                                                if ($get['movefile'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>
                                    <hr>
                                    <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  entries" id="visareg" name="visareg" value="1"
                                                <?
                                                if ($get['visareg'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Agent Register</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  entries" id="agentreg" name="agentreg" value="1"
                                                <?
                                                if ($get['agentreg'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>

                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Submission List</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  entries" id="submission" name="submission" value="1"
                                                <?
                                                if ($get['submission'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Non Submission List</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  entries" id="nonsubmission" name="nonsubmission" value="1"
                                                <?
                                                if ($get['nonsubmission'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Mofa List</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  entries" id="mofalist" name="mofalist" value="1"
                                                <?
                                                if ($get['mofalist'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>
                                </div>

                                <!-- ###################### Immigration / purchase ############################# -->

                                <div class="tab-pane" id="tab_4">
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg selectall">Select All/UnSelect All</label>
                                        <div class="col-sm-4" style="margin-top:6px">
                                            <input type="checkbox" class="form imigration" id="Simigration" value="1">
                                        </div>
                                    </div>

                                    <h4 style="border-bottom: 1px solid black;width:15%; text-align:center"><strong>Immigration</strong></h4>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Immigration Update</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  imigration" id="immig" name="immig" value="1"
                                                <?
                                                if ($get['immig'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Immigration Update List</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  imigration" id="immiglist" name="immiglist" value="1"
                                                <?
                                                if ($get['immiglist'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>

                                    <h4 style="border-bottom: 1px solid black;width:15%; text-align:center"><strong>Purchase</strong></h4>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Ticket Purchase</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  imigration" id="tiktnew" name="tiktnew" value="1"
                                                <?
                                                if ($get['tiktnew'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Ticket Purchase Register</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  imigration" id="tiktnewreg" name="tiktnewreg" value="1"
                                                <?
                                                if ($get['tiktnewreg'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">O/s. Payable</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  imigration" id="agentreg" name="agentreg" value="1"
                                                <?
                                                if ($get['agentreg'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>
                                </div>

                                    <!-- ###################### Invoice ############################# -->

                                <div class="tab-pane" id="tab_5">
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg selectall">Select All/UnSelect All</label>
                                        <div class="col-sm-4" style="margin-top:6px">
                                            <input type="checkbox" class="form invoice" id="Sinvoice" value="1">
                                        </div>
                                    </div>

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

                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Blank Amount</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  invoice" id="blankamt" name="blankamt" value="1"
                                                <?
                                                if ($get['blankamt'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Passport Amount Receivable</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  invoice" id="ppamtrec" name="ppamtrec" value="1"
                                                <?
                                                if ($get['ppamtrec'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">O/s. Receivable</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  invoice" id="osbill" name="osbill" value="1"
                                                <?
                                                if ($get['osbill'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>
                                </div>

                                <!-- ###################### Accounts ############################# -->


                                <div class="tab-pane" id="tab_6">
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg selectall">Select All/UnSelect All</label>
                                        <div class="col-sm-4" style="margin-top:6px">
                                            <input type="checkbox" class="form account" id="Saccount" value="1">
                                        </div>
                                    </div>

                                    <!-- <div class="row">
                                        <label class="col-sm-4 control-label marg">A/c. Entry</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  account" id="agentreg" name="agentreg" value="1"
                                                <?
                                                if ($get['agentreg'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">A/c. Register</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  account" id="agentreg" name="agentreg" value="1"
                                                <?
                                                if ($get['agentreg'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div> -->

                                    <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  account" id="bankrecp" name="bankrecp" value="1"
                                                <?
                                                if ($get['bankrecp'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Bank Payment</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  account" id="bankpay" name="bankpay" value="1"
                                                <?
                                                if ($get['bankpay'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Cash Receipt</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  account" id="cashrecp" name="cashrecp" value="1"
                                                <?
                                                if ($get['cashrecp'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Cash Payment</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  account" 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  account" id="ledger" name="ledger" value="1"
                                                <?
                                                if ($get['ledger'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">O/s. Company Wise</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  account" id="agentreg" name="agentreg" value="1"
                                                <?
                                                if ($get['agentreg'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>
                                </div>
                                <!-- ###################### Reports ############################# -->

                                <div class="tab-pane" id="tab_7">
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg selectall">Select All/UnSelect All</label>
                                        <div class="col-sm-4" style="margin-top:6px">
                                            <input type="checkbox" class="form reports" id="Sreports" value="1">
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Setting</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="setting" name="setting" value="1"
                                                <?
                                                if ($get['setting'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Setting Entry</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="settent" name="settent" value="1"
                                                <?
                                                if ($get['settent'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                    <label class="col-sm-4 control-label marg">Setting Register</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="settreg" name="settreg" value="1"
                                                <?
                                                if ($get['settreg'] == 1) {
                                                    echo "checked";
                                                }
                                                ?>>
                                        </div>
                                    </div>
                                </div>
                                <!-- ###################### Tools ############################# -->

                                <div class="tab-pane" id="tab_8">
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg selectall">Select All/UnSelect All</label>
                                        <div class="col-sm-4" style="margin-top:6px">
                                            <input type="checkbox" class="form tools" id="Stools" value="1">
                                        </div>
                                    </div>

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

                                </div>
                                <!-- ###################### Immigration / purchase ############################# -->




                            </div>
                        </div>
                    </div>
                    <div class="panel-footer">
                        <?php include("includes/buttons.php"); ?>
                    </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[username]</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"); ?>