HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ip-172-31-18-78 6.17.0-1017-aws #17~24.04.1-Ubuntu SMP Tue May 26 21:09:53 UTC 2026 aarch64
User: ubuntu (1000)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: //var/www/selfanalyse/accounts-admin/invoice-data.php
<?php
include_once('header.php');

$PSY_INVOICE = $wpdb->prefix . PSY_INVOICE;
$PSY_PLANS = $wpdb->prefix . PSY_PLANS;

# remove filter
if(isset($_REQUEST['remove_filter'])) {
    unset($_SESSION['Inv_subQuery']);
}

if (isset($_REQUEST['search_data'])) {
    $es_stname = $_REQUEST['es_stname'];
    $es_ondate = $_REQUEST['es_ondate'];
    $es_fromdate = $_REQUEST['es_fromdate'];
    $es_todate = $_REQUEST['es_todate'];

    if ($es_stname != '') {
        $subQuery .= "and name LIKE '%$es_stname%' ";
    }
    if ($es_ondate != '') {
        $q_date = date('Y-m-d', strtotime($es_ondate));
        $subQuery .= "and date(txn_date)='$q_date'";
    }
    if ($es_fromdate != '' && $es_todate != '') {
        $fromDate = date('Y-m-d', strtotime($es_fromdate));
        $toDate = date('Y-m-d', strtotime($es_todate));
        $subQuery .= "and (date(txn_date) BETWEEN '$fromDate' AND '$toDate')";
    }
    $_SESSION['Inv_subQuery'] = $subQuery;
?>
    <script>
        window.location.href = "invoice-data"
    </script>
<?php
}
if (!empty($_SESSION['Inv_subQuery'])) {
    $mergeFilter = $_SESSION['Inv_subQuery'];
} else {
    $mergeFilter = "";
}

$thisPage = 'invoice-data';
if (isset($_REQUEST['page'])) {
    $pageno = $_REQUEST['page'];
} else {
    $pageno = 1;
}
$no_of_records_per_page = 20;
$offset = ($pageno - 1) * $no_of_records_per_page;

$i = $offset + 1;

$countQuery = "SELECT count(id) FROM $PSY_INVOICE where invoice_status='1' $mergeFilter";

$total_rows = $wpdb->get_var($countQuery);
$total_pages = ceil($total_rows / $no_of_records_per_page);

$getInvoice = $wpdb->get_results("SELECT id,type_extn,type,type_id,order_id,order_amount,transaction_id,name,email,address,state_id,gstin,gst_name,year_extn,txn_date,issue_date FROM $PSY_INVOICE where invoice_status='1' and type_extn!='WP' $mergeFilter order by id desc limit $offset,$no_of_records_per_page");

?>

<style>
    .modal-backdrop {
        z-index: 999 !important;
    }

    table.dataTable.nowrap th,
    table.dataTable.nowrap td {
        white-space: nowrap !important;
    }

    .page-title {
        float: left;
        width: 100%;
    }
    .excel {
		float: right;
		color: #fff;
	}
</style>
<div class="page-inner">
    <div class="page-title">
        <div class="col-md-4">
            <h3>MIS</h3>
            <div class="page-breadcrumb">
                <ol class="breadcrumb">
                    <li><a href="dashboard">Home</a></li>
                    <li class="active">Invoice</li>
                </ol>
            </div>
        </div>
        <div class="col-md-8">
            <div class="navbar-right">
                <ul class="navul">
                    <!--<li><a href="apt-class">Class List</a></li>-->

                </ul>
            </div>
        </div>
    </div>

    <div id="main-wrapper">
        <div class="col-md-12">
            <div class="panel panel-info">
                <div class="panel-heading clearfix">
                    <h4 class="panel-title">Search Filter</h4>
                </div>
                <div class="spacer"></div>
                <div class="panel-body">
                    <form class="form-horizontal" method="post">
                        <div class="form-group">
                            <label for="date" class="col-sm-2">Name</label>
                            <div class="col-sm-4">
                                <input type="text" class="form-control" name="es_stname" id="es_stname" placeholder="Enter student name">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="date" class="col-sm-2">On Date</label>
                            <div class="col-sm-4">
                                <input type="text" class="form-control" name="es_ondate" id="date" placeholder="On Date">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="date" class="col-sm-2">From/To Date</label>
                            <div class="col-sm-4">
                                <input type="text" class="form-control" name="es_fromdate" id="fromdate" placeholder="From Date">
                            </div>
                            <div class="col-sm-4">
                                <input type="text" class="form-control" name="es_todate" id="todate" placeholder="To Date">
                            </div>
                        </div>
                        <div class="form-group">
                            <input type="submit" class="btn btn-primary" value="Search" name="search_data">
                        </div>
                    </form>
                    <?php if(isset($_SESSION['Inv_subQuery'])){ ?>
                    <form class="form-horizontal" method="post">
                        
                        <div class="form-group">
                            Data is Filtered
                            <input type="submit" class="btn btn-danger" value="Remove Filter" name="remove_filter">
                        </div>
                    </form>
                    <?php } ?>
                </div>
            </div>
        </div>
        <div class="col-md-12" style="padding:0;">
            <div class="panel panel-info">
                <div class="panel-heading clearfix">
                    <h4 class="panel-title">Invoice List</h4>
                    <a href="invoice_data_excel" target=" _blank" class="excel">
						<i class="fa fa-file-excel-o" title="Download" style="cursor:pointer;"></i>
					</a>
                </div>
                <div class="panel-body">
                    <div class="table-responsive">
                        <table class="display " id="userList" style="font-size: 13px;">
                            <thead>
                                <tr>
                                    <th>S.no</th>
                                    <th>Invoice Id</th>
                                    <th>Type</th>
                                    <th>Plan</th>
                                    <th>Amount</th>
                                    <th>Transaction id</th>
                                    <th>Name</th>
                                    <th>Email</th>
                                    <th>Address</th>
                                    <th>State</th>
                                    <th>Gstin</th>
                                    <th>Year Extn</th>
                                    <th>Txn Date</th>
                                    <th>Issue Date</th>
                                    <th>Action</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
                                $i=1;
                                foreach ($getInvoice as $inv) {

                                    if($inv->type_extn == 'P' || $inv->type_extn == 'WP') {
                                        $planName = $wpdb->get_var("SELECT plan_name FROM $PSY_PLANS where plan_id='$inv->type_id'");
                                    } else {
                                        $planName = 'Counselor';
                                    }
                                ?>
                                    <tr>
                                        <td><?php echo $i; ?></td>
                                        <td><?php echo 'SA'.$inv->id; ?></td>
                                        <td><?php echo $inv->type; ?></td>
                                        <td><?php echo $planName; ?></td>
                                        <td><?php echo $inv->order_amount; ?></td>
                                        <td><?php echo $inv->transaction_id; ?></td>
                                        <td><?php echo $inv->name; ?></td>
                                        <td><?php echo $inv->email; ?></td>
                                        <td><?php echo $inv->address; ?></td>
                                        <td><?php echo $inv->state_id; ?></td>
                                        <td><?php echo $inv->gstin; ?></td>
                                        <td><?php echo $inv->year_extn; ?></td>
                                        <td><?php echo $inv->txn_date; ?></td>
                                        <td><?php echo $inv->issue_date; ?></td>
                                        <td>
                                            <a href="invoice-page?oId=<?php echo $inv->order_id; ?>&type=<?php echo $inv->type_extn; ?>" target="_blank">Invoice</a>
                                        </td>
                                    </tr>
                                <?php $i++;
                                } ?>
                            </tbody>
                        </table>
                        <div class="btn-group" role="group" aria-label="First group" style="float: right;">
                            <?php
                            $k = (($pageno + 4 > $total_pages) ? $total_pages - 4 : (($pageno - 4 < 1) ? 5 : $pageno));
                            if ($pageno >= 2) {
                                echo "<a class='btn btn-default' href='$thisPage?page=1'> &laquo; </a>";
                                echo "<a class='btn btn-default' href='$thisPage?page=" . ($pageno - 1) . "'> Prev </a>";
                            }
                            for ($j = -4; $j <= 4; $j++) {

                                if (($k + $j) > 0) {
                                    if ($k + $j == $pageno)
                                        $pagLink .= "<a href='$thisPage?page=" . ($k + $j) . "' class='btn btn-default active'>" . ($k + $j) . "</a>";
                                    else
                                        $pagLink .= "<a class='btn btn-default' href='$thisPage?page=" . ($k + $j) . "'>" . ($k + $j) . "</a>";
                                }
                            };
                            echo $pagLink;
                            if ($pageno < $total_pages) {
                                echo "<a class='btn btn-default' href='$thisPage?page=" . ($pageno + 1) . "'> Next </a>";
                                echo "<a class='btn btn-default' href='$thisPage?page=" . $total_pages . "'> &raquo; </a>";
                            }
                            echo '<a class="btn btn-default">| Page: ' . $total_pages . '</a><a class="btn btn-default"> | Total Data: ' . $total_rows . '</a>';
                            ?>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div><!-- Main Wrapper -->

    <!-------------------edit ability modal---------------->
    <div class="modal fade" id="editAbilityModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content" style="border: 3px solid #ccc;">
                <div class="modal-header" style="padding: 5px 10px 0px 0px; height: 20px;">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                </div>
                <div class="modal-body" id="edit_ability_modal"></div>
            </div>
        </div>
    </div>

    <div class="page-footer">
        <p class="no-s">shinemetrics.com</p>
    </div>
</div><!-- Page Inner -->


<script type="text/javascript" charset="utf-8">
    jQuery.noConflict();
    jQuery(function($) {
        $('#userList').dataTable({
            "bPaginate": false,
            "responsive": true,
        });
        $("#date").datepicker({
            changeMonth: true,
            changeYear: true
        });
        $("#todate").datepicker({
            changeMonth: true,
            changeYear: true
        });
        $("#fromdate").datepicker({
            changeMonth: true,
            changeYear: true
        });
    });
</script>
<link href="/counselor/assets/css/jquery.dataTables.min.css" rel="stylesheet">
<link href="/counselor/assets/css/responsive.dataTables.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" />
<script src="/counselor/assets/plugins/jquery-ui/jquery-ui.min.js"></script>
<script src="/counselor/assets/js/jquery.dataTables.min.js"></script>
<script src="/counselor/assets/js/dataTables.responsive.min.js"></script>

<?php
include_once('footer.php');
?>