<?php

ob_start();

require("includes/check_auth_user.php");

require("includes/dbconnect.php");

include('includes/function.php');



$formname = "Expense Position";

$file = "expenseposn.php";

$grid = "";

$zroot = $_SESSION["zdbroot"];



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

$zdb = $_SESSION["zdbyear_" . $dbname];

$myyear = $_SESSION[$myyear];



$zyear = right($zdb, 4);

$mfrdate = getzdates($zyear, 'S');

$mtodate = getzdates($zyear, 'E');



mysqli_select_db($conn, $zdb);



$seriescond = "";

include("includes/linkshead.php");

include("includes/searchrow.php");



?>

<link href="MyStyle/rep_format.css" type="text/css">

<style type="text/css">
    #tabital {

        font-style: italic;

    }

    #font1 {

        font-style: italic;

    }

    #boldfont {

        font-weight: bold;

    }

    .mtotclr {

        color: #0098DA;

    }

    .ttotclr {

        color: #ed3237;

    }

    .getdtl {

        font-size: 14px;

    }





    /* CSS */

    .button-1 {

        position: relative;

        border: none;

        background: transparent;

        padding: 0;

        cursor: pointer;

        outline-offset: 4px;

        transition: filter 250ms;

        user-select: none;

        -webkit-user-select: none;

        touch-action: manipulation;

    }



    .button-1-shadow {

        position: absolute;

        top: 0;

        left: 0;

        width: 100%;

        height: 100%;

        border-radius: 12px;

        background: hsl(0deg 0% 0% / 0.25);

        will-change: transform;

        transform: translateY(2px);

        transition:

            transform 600ms cubic-bezier(.3, .7, .4, 1);

    }



    .button-1-edge {

        position: absolute;

        top: 0;

        left: 0;

        width: 100%;

        height: 100%;

        border-radius: 12px;

        background: linear-gradient(to left,

                hsl(340deg 100% 16%) 0%,

                hsl(340deg 100% 32%) 8%,

                hsl(340deg 100% 32%) 92%,

                hsl(340deg 100% 16%) 100%);

    }



    .button-1-front {

        display: block;

        position: relative;

        padding: 12px 27px;

        border-radius: 12px;

        font-size: 15px;

        font-weight: bold;

        color: white;

        background: grey;

        will-change: transform;

        transform: translateY(-4px);

        transition:

            transform 600ms cubic-bezier(.3, .7, .4, 1);

    }



    @media (min-width: 768px) {

        .button-1-front {

            font-size: 25px;

            padding: 6px 23px;

        }

    }



    .button-1:hover {

        filter: brightness(110%);

        -webkit-filter: brightness(110%);

    }



    .button-1:hover .button-1-front {

        transform: translateY(-6px);

        transition:

            transform 250ms cubic-bezier(.3, .7, .4, 1.5);

    }


    .BtnAli {
        align-items: center;
        appearance: none;
        background: transparent;
        border: 3px solid #A53860;
        border-radius: 6px;
        box-sizing: border-box;
        color: #A53860;
        cursor: pointer;
        display: inline-flex;
        font-family: "JetBrains Mono", monospace;
        height: 38px;
        width: 150px;
        justify-content: center;
        line-height: 1;
        list-style: none;
        overflow: hidden;
        padding-left: 16px;
        padding-right: 16px;
        position: relative;
        text-align: left;
        text-decoration: none;
        transition: box-shadow .15s, transform .15s;
        user-select: none;
        -webkit-user-select: none;
        touch-action: manipulation;
        white-space: nowrap;
        will-change: box-shadow, transform;
        font-size: 18px;
    }

    .BtnAli:active {
        box-shadow: #A53860 0 3px 7px inset;
        transform: translateY(2px);
    }

    a {
        color: #000000 !important;
    }

    a:hover {
        color: #000000 !important;
        text-decoration: none;
    }

    .table-hover>tbody>tr:hover {
        color: #000000 !important;
        font-weight: bold;
        background-color: #e396b2;
    }


    /*

        .button-1:active .button-1-front {

            transform: translateY(-2px);

            transition: transform 34ms;

        }*/
</style>

<script src="MyScript/expense_search.js?a=<?= mt_rand() ?>" type="text/javascript"></script>



</head>

<body>

    <div class="container">

        <div class="row" style="padding-top:1%">
            <div class="col-lg-2 col-md-1 col-sm-2 col-xs-2 pad text-center">
                <a href="expense.php?mode=true" class="BtnAli">Add New</a>
            </div>
        </div>


        <div class="row">

            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 pad">

                <table class="table1 table-bordered myTable table-hover" style="width:100%">

                    <thead class="mySearchTr">

                        <tr>

                            <center>
                                <h3 style="background-color:#A53860;color:whitesmoke;border: 1px solid black;">EXPENSE
                                    POSITIONS</h3>
                            </center>

                        </tr>

                        <tr style="height:30px">

                            <th style="color:black;width:20%" colspan="2"><b>Account</b></th>

                            <th style="color:black;width:9%" class="text-right"><b>Amount</b></th>

                            <th style="color:black;width:5%" class="text-center"><b>View</b></th>

                        </tr>

                    </thead>

                    <tr class='filters noPrint' style="height:30px">

                        <th style="width:20%;" class="filter-container" colspan="2"><input type="text" class="filter"
                                name="account" placeholder="Account" data-col="account"></th>

                        <th style="width:9%;" class="filter-container"><input type="text" class="filter text-right"
                                name="inr" placeholder="Amount" data-col="inr"></th>

                        <th style="width:5%;" class="filter-container"></th>

                    </tr>

                    <tbody>

                        <?php



                        $getdata = mysqli_query($conn, "SELECT * FROM accmast WHERE grpcode = '012'") or die(mysqli_error($conn));



                        while ($pmain = mysqli_fetch_array($getdata)) {

                            $maccode = $pmain['accode'];

                            $mopbal = $pmain['openbal'];

                            $mdc = $pmain['dc'];



                            if ($mdc == "D") {

                                $opbal = $mopbal * -1;

                            } else {

                                $opbal = $mopbal;

                            }


                            $getdep = mysqli_query($conn, "SELECT sum(amount) as tamt FROM `actran` WHERE accode = '$maccode'") or die(mysqli_error($conn));

                            $fetdep = mysqli_fetch_array($getdep);

                            $abalamt = $fetdep['tamt'];

                            $balamt = ($opbal + $abalamt) * -1;

                            // if ($tbal != 0) {
                        
                            $file = "expense.php?accode=$maccode&mode=edit";

                            echo "<tr class='getdtl' style='height:30px;'  >";
                            echo "<td colspan='2' style ='font-size:13px;font-weight:bold'><a href='expensedet.php?accode=$maccode'>$pmain[name]</a></td>";
                            echo "<td class='getdtl text-right'>$balamt</td>";
                            echo "<td align='center'><a href='$file'><i class='fa fa-1x fa-desktop'></i></a></td>";
                            echo "</tr>";

                            $totbalamt = $totbalamt + $balamt;

                            // }
                        }



                        echo "<tr class='getdtl' style='height:30px;background-color:#c1c1c1'>";

                        echo "<td colspan='2' class='getdtl text-right'><b>Total</b></td>";

                        echo "<td class='getdtl text-right'><b>$totbalamt</b></td>";

                        echo "<td align='center'></td>";

                        echo "</tr>";



                        ?>

                    </tbody>

                </table>

            </div>

        </div>

    </div>

    <div class="modal fade bs-example-modal-lg searchModal" 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="row">

                        <div class="col-lg-2">

                            <select class="form-control sfield">

                                <option value="1">Name</option>

                            </select>

                        </div>

                        <div class="col-lg-2">

                            <select class="form-control soperator">

                                <option value="">Type of Search</option>

                                <option value="%">Like</option>

                                <option value="=">Exactly</option>

                            </select>

                        </div>

                        <div class="col-lg-2">

                            <select class="form-control sortBy">

                                <option value="">Sort By</option>

                                <option value="1">Name</option>

                            </select>

                        </div>

                        <div class="col-lg-2">

                            <select class="form-control orderAs">

                                <option value="desc">Desc</option>

                                <option value="asc">Asc</option>

                            </select>

                        </div>

                        <div class="col-lg-2">

                            <input type="text" value="" class="form-control ssearch" placeholder="Search Here">

                        </div>

                        <div class="col-lg-2">

                            <input type="button" class="btn btn-primary sload" value="Search">

                        </div>

                    </div>

                    <div class="col-lg-12 sloader text-center">

                        <!--<img src="images/search.gif" alt="loading">-->

                    </div>

                    <div class="col-lg-12 snoRecord text-center">

                        <h3>NO RECORDS FOUND</h3>

                    </div>

                    <div class="table-responsive" style="max-height: 400px;overflow: auto;">

                        <table id="" class="table table-striped table-condensed table-bordered" width="100%">

                            <thead>

                                <tr class="mySearchTr" style="">

                                    <th width="90%">Name</th>

                                    <th width="10%">Action</th>

                                </tr>

                            </thead>

                            <tbody class="sTbody">

                            </tbody>

                        </table>

                    </div>

                    <div class="row">

                        <div class="col-xs-12 text-right search-action-bar">

                            <input type="button" class="btn btn-primary sprev" value="Previous">

                            <input type="button" class="btn btn-primary snext" value="Next">

                        </div>

                    </div>



                </div>

                <div class="modal-footer"></div>

            </div>

        </div>

    </div>

    <?php include("includes/linksfoot.php");

    ?>

</body>

</html>