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

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

//$zdb = $_SESSION["zdbyear_" . $dbname];
//mysqli_select_db($conn, $zdb);


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

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

if (isset($_POST["submit"])) {
    $a = 1;
    $user = $_POST["user"];
    $password = $_POST["password"];
    $usertype = $_POST["usertype"];
    ################## MASTERS ##################
    $customer = $_POST["customer"];
    $supplier = $_POST["supplier"];
    $brand = $_POST["brand"];
    $item = $_POST["item"];
    $balewgt = $_POST["balewgt"];
    $currency = $_POST["currency"];
    $transport = $_POST["transport"];
    $expense = $_POST["expense"];
    $cash = $_POST["cash"];
    $opbal = $_POST["opbal"];
    $godown = $_POST["godown"];
    $changeRate = $_POST["changeRate"];
    $shipper = $_POST["shipper"];
    $purexpense = $_POST["purexpense"];
    $narration = $_POST["narration"];
    $address = $_POST["address"];

    ################## TRANSACTION ##################
    $purchase = $_POST["purchase"];
    $sale = $_POST["sale"];
    $creditnote = $_POST["creditnote"];
    $damaged = $_POST["damaged"];
    $inward = $_POST["inward"];
    $outward = $_POST["outward"];
    $cashrecp = $_POST["cashrecp"];
    $cashpay = $_POST["cashpay"];
    $eta = $_POST["eta"];
    $proforma = $_POST["proforma"];
    $shipperent = $_POST["shipperent"];

    ################## REGISTERS ##################
    $rgsale = $_POST["rgsale"];
    $rgpurchase = $_POST["rgpurchase"];
    $rgcreditnote = $_POST["rgcreditnote"];
    $rgdamaged = $_POST["rgdamaged"];
    $rginward = $_POST["rginward"];
    $rgoutward = $_POST["rgoutward"];
    $etareg = $_POST["etareg"];

    ################## REPORTS ##################
    $rpstocknew = $_POST["rpstocknew"];
    $rpledger = $_POST["rpledger"];
    $rpcashbook = $_POST["rpcashbook"];
    $rpitemhist = $_POST["rpitemhist"];
    $rpdeadstock = $_POST["rpdeadstock"];
    $rpdailyrep = $_POST["rpdailyrep"];

    ################## FINALIZATIONS ##################
  
    $trbal = $_POST["trbal"];
    $closstk = $_POST["closstk"];
    $profit = $_POST["profit"];
    $profshar = $_POST["profshar"];
    $balsheet = $_POST["balsheet"];
   
    
    ################## TOOLS ##################
    $tlcompany = $_POST["tlcompany"];
    $tlbackup = $_POST["tlbackup"];
    $tlprofile = $_POST["tlprofile"];
    $dstock = $_POST["dstock"];

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

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

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

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

        if ($addflag == 1) {

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

            mysqli_query($conn, "INSERT INTO `$maindb`(code, `user`, `password`, `usertype`, `item`, `customer`, `supplier`, `balewgt`, 
                                `currency`, `transport`, `brand`, `opbal`, `cash`, `expense`, `purchase`, `sale`,  
                                `creditnote`,`damaged`, `inward`, `outward`, `cashrecp`, `cashpay`, `eta`, 
                                `rpstocknew`, `rpledger`, `rpdailyrep`, `rpcashbook`, `rpitemhist`, `rpdeadstock`, `rgsale`, 
                                `rgpurchase`, `rgcreditnote`, `rgdamaged`, `rginward`, `rgoutward`, `tlcompany`, `tlbackup`, `tlprofile`, `dstock`,
                                `trbal`, `closstk`, `profit`, `profshar`, `balsheet`,`proforma`,`shipper`,`purexpense`,`shipperent`,`etareg`)
                        VALUES($qvouch, '$user', '$password', '$usertype',  '$item', '$customer', '$supplier', '$balewgt', 
                                '$currency', '$transport', '$brand', '$opbal', '$cash', '$expense', '$purchase','$sale',
                                '$creditnote', '$damaged', '$inward', '$outward', '$cashrecp', '$cashpay', '$eta',
                                '$rpstocknew', '$rpledger', '$rpdailyrep', '$rpcashbook', '$rpitemhist', '$rpdeadstock', '$rgsale',
                                '$rgpurchase', '$rgcreditnote', '$rgdamaged', '$rginward', '$rgoutward', '$tlcompany', '$tlbackup', '$tlprofile', '$dstock',
                                '$trbal', '$closstk', '$profit', '$profshar', '$balsheet','$proforma','$shipper','$purexpense','$shipperent','$etareg')") or die(mysqli_error($conn));
            insmess();
            $mvouch = $qvouch;
            header("refresh: 1; $file?$keyfld=$mvouch&mode=edit");
        } else {
            $mvouch = $qvouch;

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

            mysqli_query($conn, "UPDATE `$maindb` SET code='$qvouch', `user`='$user', `password`='$password', `usertype`='$usertype',`item`='$item',
                                        `customer`='$customer', `supplier`='$supplier', `balewgt`='$balewgt',`currency`='$currency',
                                        `transport`='$transport', `brand`='$brand', `opbal`='$opbal',`cash`='$cash',
                                        `expense`='$expense',  `purchase`='$purchase', `sale`='$sale', `creditnote`='$creditnote', `damaged`='$damaged', 
                                        `inward`='$inward', `outward`='$outward', `cashrecp`='$cashrecp', `cashpay`='$cashpay', `eta`='$eta',
                                        `rpstocknew`='$rpstocknew', `rpledger`='$rpledger', `rpdailyrep`='$rpdailyrep', `rpcashbook`='$rpcashbook',
                                        `rpitemhist`='$rpitemhist',`rpdeadstock`='$rpdeadstock', `rgsale`='$rgsale', `rgpurchase`='$rgpurchase',
                                        `rgcreditnote`='$rgcreditnote', `rgdamaged`='$rgdamaged', `rginward`='$rginward', `rgoutward`='$rgoutward',
                                        `tlcompany`='$tlcompany', `tlbackup`='$tlbackup', `tlprofile`='$tlprofile',
                                        `dstock`='$dstock', `trbal`='$trbal', `closstk`='$closstk', `profit`='$profit', `profshar`='$profshar',
                                         `balsheet`='$balsheet',`proforma`='$proforma',`shipper`='$shipper',`purexpense`='$purexpense'
                                         ,`shipperent`='$shipperent',`etareg`='$etareg'    WHERE code = '$mvouch' ") or die(mysqli_error($conn));
            updmess();
            header("refresh: 1; $file?$keyfld=$mvouch&mode=edit");
        }
    }
}

if ($addflag != 1) {

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

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

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

/* DELETE */
if (isset($_GET["delete"])) {
    delete($zdb, "$maindb", "$keyfld", $_GET[$keyfld], "$file?mode=last");
}
?>

<?php include("includes/linkshead.php"); ?>
<script>
    $(document).ready(function () {
        $("#branch").on('change keyup blur', GetPlace);

        function GetPlace() {
            var brch = $('#branch').val();
            $.post('getplace.php', {branch: brch}, function (data) {
                $("#place").val(data);
            });
        }

        $("#Smasters").click(function () {
            $(".masters").prop('checked', $(this).prop('checked'));
        });
        $("#Stransactions").click(function () {
            $(".transactions").prop('checked', $(this).prop('checked'));
        });
        $("#Sreports").click(function () {
            $(".reports").prop('checked', $(this).prop('checked'));
        });
        $("#Sregisters").click(function () {
            $(".registers").prop('checked', $(this).prop('checked'));
        });
        $("#Stools").click(function () {
            $(".tools").prop('checked', $(this).prop('checked'));
        });
        $("#Sfinalizations").click(function () {
            $(".finalizations").prop('checked', $(this).prop('checked'));
        });
        $("#Sdashboard").click(function () {
            $(".dashboard").prop('checked', $(this).prop('checked'));
        });

        $("#confpass").blur(function () {
            var pass = $("#password").val();
            var cpass = $("#confpass").val();
            if (pass !== cpass) {
                $("#alert").html("<b style='color:red;'>Password Doesn't Match</b>");
            } else {
                $("#alert").html("<b style='color:green;'>Password Matched</b>");
            }
        });
    });
</script>

<body>
    <!-- Default box -->
    <form action='' method='POST'>
        <!-- Default box -->
        <div class="row">
            <div class="col-lg-6">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title"><?php Echo $formname; ?></h3>
                        <div class="actions pull-right">
                            <i class="fa fa-chevron-down"></i>
                        </div>
                    </div>
                    <div class="panel-body">
                        <div class="row">
                            <label class="col-sm-3 control-label marg">User Name</label>
                            <div class="col-sm-6">
                                <input type="text" class="form-control form" name="user" placeholder="User Name" autocomplete="off" value='<? echo ($addflag != 1) ? $get['user'] : ''; ?>' required="" autofocus>
                            </div>
                        </div>
                        <div class="row">
                            <label class="col-sm-3 control-label marg">Password</label>
                            <div class="col-sm-6">
                                <input type="password" class="form-control form" name="password" id="password" autocomplete="off" placeholder="Password" value='<? echo ($addflag != 1) ? $get['password'] : ''; ?>' required="">
                            </div>
                        </div>
                        <div class="row">
                            <label class="col-sm-3 control-label marg">Confirm Pass</label>
                            <div class="col-sm-6">
                                <input type="password" name="confpass" id="confpass" class="form-control form"  placeholder="Cofirm Password" required="" value='<? echo ($addflag != 1) ? $get['password'] : ''; ?>'>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-sm-6">
                                <p id="alert"></p>
                            </div>
                        </div>
                        <!--                        <div class="row">
                                                    <label class="col-sm-3 control-label marg">Agent</label>
                                                    <div class="col-sm-6">
                                                        <input type="text" class="form-control form" name="agent" placeholder="Agent Name" autocomplete="off" value='<? echo ($addflag != 1) ? $get['agentname'] : ''; ?>'>
                                                    </div>
                                                </div>-->
                        <div class="row">
                            <label class="col-sm-3 control-label marg">User Type</label>
                            <div class="col-sm-6">

                                <select class='form-control select2 form' name="usertype" id="usertype">                                    
                                    <?php
                                    if ($addflag != 1) {
                                        $usertyp = "";
                                        if ($get['usertype'] == 1) {
                                            $ucode = "1";
                                            $usertyp = "Admin";
                                        }
                                        if ($get['usertype'] == 2) {
                                            $ucode = "2";
                                            $usertyp = "Supervisor";
                                        }
                                        if ($get['usertype'] == 3) {
                                            $ucode = "3";
                                            $usertyp = "Staff";
                                        }
                                        echo "<option value='$ucode'>$usertyp</option>";
                                    }
                                    ?>
                                    <option value=""></option>
                                    <option value="3">Staff</option>
                                    <option value="2">Supervisor</option>
                                    <option value="1">Admin</option>
                                </select>
                            </div>
                        </div>
                        <div class="nav-tabs-custom">
                            <ul class="nav nav-tabs">
                                <li class="active"><a href="#tab_1" data-toggle="tab" aria-expanded="true">Masters</a></li>
                                <li class=""><a href="#tab_2" data-toggle="tab" aria-expanded="false">Transaction</a></li>
                                <li class=""><a href="#tab_3" data-toggle="tab" aria-expanded="false">Registers</a></li>
                                <li class=""><a href="#tab_4" data-toggle="tab" aria-expanded="false">Reports</a></li>
                                <li class=""><a href="#tab_5" data-toggle="tab" aria-expanded="false">Finalization</a></li>
                                <li class=""><a href="#tab_6" data-toggle="tab" aria-expanded="false">Tools & DashBoard</a></li>
                            </ul>
                            <div class="tab-content">
                                <div class="tab-pane active" id="tab_1">
                                    <div class="row">
                                        <label class="col-sm-6 control-label marg selectall">Select All/UnSelect All</label>
                                        <div class="col-sm-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">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">Brand/Logo</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="brand" name="brand" value="1" <?
                                            if ($get['brand'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Item</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="item" name="item" value="1" <?
                                            if ($get['item'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Bale Weight</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="balewgt" name="balewgt" value="1" <?
                                            if ($get['balewgt'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Currency</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  masters" id="currency" name="currency" value="1" <?
                                            if ($get['currency'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>

                                    </div>
                                    <div class="row">

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

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

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


                                </div><!-- /.tab-pane -->
                                <div class="tab-pane" id="tab_2">
                                    <div class="row">
                                        <label class="col-sm-6 control-label marg selectall">Select All/UnSelect All</label>
                                        <div class="col-sm-4" style="margin-top:6px">
                                            <input type="checkbox" class="form " id="Stransactions" value="1">
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Purchase</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="purchase" name="purchase" value="1" <?
                                            if ($get['purchase'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>

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

                                    </div>

                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Credit Note / Sale Return</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="creditnote" name="creditnote" value="1" <?
                                            if ($get['creditnote'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>

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

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

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

                                    </div>



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

                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">ETA</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="eta" name="eta" value="1" <?
                                            if ($get['eta'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Proforma</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="proforma" name="proforma" value="1" <?
                                            if ($get['proforma'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Container ETA</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  transactions" id="shipperent" name="shipperent" value="1" <?
                                            if ($get['shipperent'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                </div><!-- /.tab-pane -->

                                <div class="tab-pane" id="tab_3">
                                    <div class="row">
                                        <label class="col-sm-6 control-label marg selectall">Select All/UnSelect All</label>
                                        <div class="col-sm-4" style="margin-top:6px">
                                            <input type="checkbox" class="form " id="Sregisters" value="1">
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Purchase</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  registers" id="rgpurchase" name="rgpurchase" value="1" <?
                                            if ($get['rgpurchase'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Sale</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  registers" id="rgsale" name="rgsale" value="1" <?
                                            if ($get['rgsale'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">

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

                                        <label class="col-sm-4 control-label marg">Damaged</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  registers" id="rgdamaged" name="rgdamaged" value="1" <?
                                            if ($get['rgdamaged'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Inward</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  registers" id="rginward" name="rginward" value="1" <?
                                            if ($get['rginward'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Outward</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  registers" id="rgoutward" name="rgoutward" value="1" <?
                                            if ($get['rgoutward'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Container ETA</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  registers" id="etareg" name="etareg" value="1" <?
                                            if ($get['etareg'] == 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="Sreports" value="1">
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Stock</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="rpstocknew" name="rpstocknew" value="1" <?
                                            if ($get['rpstocknew'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    
                                        <label class="col-sm-4 control-label marg">Ledger</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="rpledger" name="rpledger" value="1" <?
                                            if ($get['rpledger'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>

                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Daily Report</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="rpdailyrep" name="rpdailyrep" value="1" <?
                                            if ($get['rpdailyrep'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    
                                        <label class="col-sm-4 control-label marg">Cash Book</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="rpcashbook" name="rpcashbook" value="1" <?
                                            if ($get['rpcashbook'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        
                                    </div>
                                    
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Item History</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="rpitemhist" name="rpitemhist" value="1" <?
                                            if ($get['rpitemhist'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Dead Stock</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  reports" id="rpdeadstock" name="rpdeadstock" value="1" <?
                                            if ($get['rpdeadstock'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        
                                    </div>
                                </div>
                                <!-- /.tab-pane -->

                                <div class="tab-pane" id="tab_5">
                                    <div class="row">
                                        <label class="col-sm-6 control-label marg selectall">Select All/UnSelect All</label>
                                        <div class="col-sm-4" style="margin-top:6px">
                                            <input type="checkbox" class="form " id="Sfinalizations" value="1">
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Trial Balance</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  finalizations" id="trbal" name="trbal" value="1" <?
                                            if ($get['trbal'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Closing Stock</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  finalizations" id="closstk" name="closstk" value="1" <?
                                            if ($get['closstk'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Profit / Loss</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  finalizations" id="profit" name="profit" value="1" <?
                                            if ($get['profit'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Profit Sharing</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  finalizations" id="profshar" name="profshar" value="1" <?
                                            if ($get['profshar'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Balance Sheet</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  finalizations" id="balsheet" name="balsheet" value="1" <?
                                            if ($get['balsheet'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                       
                                    </div>
                                </div> 
                                <div class="tab-pane" id="tab_6">
                                    <div class="row">
                                        <label class="col-sm-6 control-label marg selectall">Select All/UnSelect All</label>
                                        <div class="col-sm-4" style="margin-top:6px">
                                            <input type="checkbox" class="form " id="Stools" value="1">
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Company Setup</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  tools" id="tlcompany" name="tlcompany" value="1" <?
                                            if ($get['tlcompany'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Backup</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  tools" id="tlbackup" name="tlbackup" value="1" <?
                                            if ($get['tlbackup'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <label class="col-sm-4 control-label marg">Profile</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  tools" id="tlprofile" name="tlprofile" value="1" <?
                                            if ($get['tlprofile'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                        <label class="col-sm-4 control-label marg">Stock</label>
                                        <div class="col-sm-2" style="margin-top:6px">
                                            <input type="checkbox" class="form  tools" id="dstock" name="dstock" value="1" <?
                                            if ($get['dstock'] == 1) {
                                                Echo "checked";
                                            }
                                            ?>>
                                        </div>
                                    </div>
                                </div> 
                            </div><!-- /.tab-content -->
                        </div>
                    </div>
                    <div class="panel-footer">
                        <?php include("includes/buttons.php"); ?>
                    </div>
                </div>
            </div>
        </div>
    </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 style="background-color: #1ABC9C;">
                                    <th>code</th>
                                    <th>Name</th>
                                    <th>Action</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
                                if ($addflag != 1) {
                                    $srchresult = mysqli_query($conn, "SELECT * FROM `$maindb`")or die(mysqli_error($conn));
                                    while ($row = mysqli_fetch_array($srchresult)) {
                                        echo "<tr>";
                                        echo "<td align='left'>$row[code]</td>";
                                        echo "<td align='left'>$row[user]</td>";
                                        echo "<td align='left'><a href=\"$file?mode=edit&$keyfld=$row[$keyfld]\"><i class='fa fa-pencil' style='font-size:1.3em;color:#00C0EF;cursor:pointer;'></i></a></td>";
                                        echo "</tr>";
                                    }
                                }
                                ?>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="modal-footer"></div>
            </div>
        </div>
    </div>
</body>
</html>
<?php include("includes/linksfoot.php"); ?>