<?php
$usertype = $_SESSION["usertype_" . $dbname];
$para = $_REQUEST["para"];


if ($usertype > 1) {
    $mastadd = $_SESSION["mastadd_" . $dbname];
    $mastedit = $_SESSION["mastedit_" . $dbname];
    $mastdel = $_SESSION["mastdel_" . $dbname];
} else {
    $mastadd = 1;
    $mastedit = 1;
    $mastdel = 1;
}

if ($usertype > 1) {
    $transadd = $_SESSION["transadd_" . $dbname];
    $transedit = $_SESSION["transedit_" . $dbname];
    $transdel = $_SESSION["transdel_" . $dbname];
} else {
    $transadd = 1;
    $transedit = 1;
    $transdel = 1;
    $smdayedit = 1;
}

if ($mastadd == '') {
    $mastadd = 0;
}
if ($mastedit == '') {
    $mastedit = 0;
}
if ($mastdel == '') {
    $mastdel = 0;
}
if ($transadd == '') {
    $transadd = 0;
}
if ($transedit == '') {
    $transedit = 0;
}
if ($transdel == '') {
    $transdel = 0;
}
?>
<script type="text/javascript">
    $(document).ready(function () {
        var usertype = <?= $usertype ?>,
                transadd = <?= $transadd ?>,
                transdel = <?= $transdel ?>,
                transedit = <?= $transedit ?>;

        if (usertype > 1) {
            if (transdel == 1) {
                $("#hdelete").show();
            } else {
                $("#hdelete").hide();
            }
            if (transadd == 1) {
                $("#hadd").show();
            } else {
                $("#hadd").hide();
            }
            if (transedit == 1) {
                $("#hedit").show();
            } else {
                $("#hedit").hide();
            }
        }
    });
</script>
<div>
    <table class="table-condensed" style="margin: 0 auto;">
        <tr>
            <td class=" buttonform tooltip-bottom " id="hprevious" style="display: <? Echo $pdisabled ?>" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="Previous">
                <button id='previous' type="button" class="btn btn-pad btn-square btn-square prevBtn hvr-float-shadow" style="background-color:#B38A6C; "  onClick="window.location.href = '<?= $file . "?mode=edit&$keyfld=$prevvouch&para=$para" ?>'" <? Echo $pdisabled1 ?>>
                    <i class="fa fa-chevron-left" style="color:#ffffff"></i>
                </button>
            </td>
            <td class=" buttonform tooltip-bottom" id="hnext" style="display: <? Echo $ndisabled ?>" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="Next">
                <button id='next' type="button" class="btn btn-pad btn-square nextBtn hvr-float-shadow" style="background-color:#F89693;  " onClick="window.location.href = '<?= $file . "?mode=edit&$keyfld=$nextvouch&para=$para" ?>'" <? Echo $ndisabled1 ?>>
                    <i class="fa fa-chevron-right" style="color:#ffffff"></i>    
                </button>
            </td>
            <td class=" buttonform tooltip-bottom" id="hsearch" style="display: <? Echo $searchdisabled ?>" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="Search">
                <button id="search" type="button" class="btn btn-pad btn-square " style="background-color:#B19CD9; " data-toggle="modal" data-target=".bs-example-modal-lg" >
                    <i class="fa fa-search" style="color:#ffffff"></i>
                </button>
            </td>
            <td class=" buttonform tooltip-bottom" id="hprint" style="display: <? Echo $printdisabled ?>" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="Print">
                <a id='print' class="btn btn-pad btn-square " style="background-color:#5BC0DE;" href="<?= $printfile ?>?vouchno=<?= $qvouch; ?>" target="_blank">
                    <i class="fa fa-print" style="color:#ffffff"></i>
                </a>
            </td>
            <td class=" buttonform tooltip-bottom" id="hadd" style="display: <? Echo $adddisabled ?>" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="Add Record" >
                <button id='add' type="button" class="btn btn-pad btn-square " style="background-color:#C0CA33; " onclick="window.location.href = '<?= $file . "?mode=true&para=$para" ?>'" class="btn btn-labeled btn-success ">
                    <i class="fa fa-plus" style="color:#ffffff"></i>    
                </button>
            </td>
            <td class=" buttonform tooltip-bottom" id="hedit" style="display: <? Echo $editdisabled ?>" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="Edit Record">
                <button id='edit' type="button" style="background-color:#F0AD4E; " class="btn btn-pad btn-square">
                    <i class="fa fa-pencil" style="color:#ffffff"></i>
                </button>
            </td>

            <td class=" buttonform tooltip-bottom" id="hdelete" style="display: <? Echo $deletedisabled ?>" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="Delete Record">
                <a id='delete' class="btn btn-pad btn-square delete-entry" href="?delete&<?= $keyfld . "=" . $qvouch . "&series=$zseries" . "&source=$msource" . "&para=$para" ?>"  onClick="return confirm('Confirm Delete?');" style="background-color:#D9534F;">
                    <i class="fa fa-trash" style="color:#ffffff"></i>
                </a>
            </td>
            <td class=" buttonform tooltip-bottom" id="hexit" style="display: <? Echo $exitdisabled ?>" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="Exit">
                <button id='exit' type="button" class="btn btn-pad btn-square " style="background-color:#cccccc; "  onClick="window.location.href = '<?= 'default.php' ?>'">
                    <i class="fa fa-power-off" style="color:red"></i>
                </button>
            </td>
            <td class=" buttonform tooltip-bottom" id="ssubmit" style="display: <? Echo $savedisabled ?>" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="Save Record">
                <button id='submit' type='submit' name='submit' value='<?php echo ($addflag == 0) ? "Update" : "Save"; ?>' class="btn btn-pad btn-square " style="background-color:#008D4C; ">
                    <i class="fa fa-check" style="color:#ffffff"></i>
                </button>
            </td>
            <td class=" buttonform tooltip-bottom" id="scancel" style="display: <? Echo $canceldisabled ?>" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="Cancel Record">
                <button id='cancel' type="button" class="btn btn-pad btn-square " style="background-color:#39CCCC; "  onClick="window.location.href = '<?= $file . "?mode=last&para=$para" ?>'">
                    <i class="fa fa-times" style="color:#ffffff"></i>
                </button>
            </td>

        </tr>
    </table>
</div>