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/grapossconnect/admin-dash/invoice-list.php
<?php require('include/header.php');
require('include/sidebar.php');
// ini_set('display_errors', 1);
// ini_set('display_startup_errors', 1);
// error_reporting(E_ALL);

session_start();
unset($_SESSION['date-filter']);
unset($_SESSION['get-table']);
$month = date('F');
$year = date('Y');
$msg = "Showing Data of " . $month . " month of " . $year;
//show data as per selected date
if (isset($_POST['searchDate'])) {
    $table_name = $_POST['show_table'];
    $_SESSION['get-table'] = $table_name;
    if (($_POST['fromdate'] != '') && ($_POST['todate'] == '')) {
        $date = date('Y-m-d', strtotime($_POST['fromdate']));
        $subquery = " date(invoice_issue_date)='$date'";
        $_SESSION['date-filter'] = $subquery;
        $msg = 'Showing Data of  ' . date('d F Y', strtotime($date));
    } else if (($_POST['fromdate'] != '') && ($_POST['todate'] != '')) {
        $fromdate = date('Y-m-d', strtotime($_POST['fromdate']));
        $todate1 = date('Y-m-d', strtotime($_POST['todate']));
        $todate = date('Y-m-d', strtotime("+1 day", strtotime($_REQUEST['todate'])));
        $subquery = " (invoice_issue_date >='$fromdate' AND invoice_issue_date < '$todate')";
        $_SESSION['date-filter'] = $subquery;
        $msg = 'Showing Data of between ' . date('d F Y', strtotime($fromdate)) . ' to ' . date('d F Y', strtotime($todate1));
    }
}

$show_table = " grp_gepl_invoice";
$subquery = " MONTH(invoice_issue_date) = MONTH(now()) AND YEAR(invoice_issue_date) = YEAR(now())";
// check session for subquery execution
if (isset($_SESSION['date-filter'])) {
    $subquery = $_SESSION["date-filter"];
}
// check session for table execution
if (isset($_SESSION['get-table'])) {
    $show_table = $_SESSION["get-table"];
}
// query to get detailed-list of invoice
$invoiceQry = $conn->query("SELECT invoice_id, from_domain, if_vendor, transaction_type, payment_for, payment_type, payment_gateway_name, customer_name, customer_address, customer_mobile, customer_email, transaction_date, invoice_issue_date,  product_mrp, transaction_id1 FROM $show_table WHERE $subquery ORDER BY invoice_id DESC");
?>
<style>
    .form-inline {
        display: flex;
        justify-content: left;
        gap: 20px;
        padding: 1em 0;
    }

    .search-btn {
        display: flex;
        gap: 10px;
    }

    .invoice_row {
        align-items: center;
        justify-content: center;
    }
</style>
<div id="content" class="app-content">
    <div class="d-flex align-items-center mb-3">
        <div>
            <ol class="breadcrumb">
                <li class="breadcrumb-item"><a href="dashboard.php">Home</a></li>
                <li class="breadcrumb-item"><a href="javascript:;">Invoice</a></li>
                <li class="breadcrumb-item active"><i class="fa fa-arrow-back"></i>Invoice List</li>
            </ol>
            <h1 class="page-header mb-0">Invoice List</h1>
        </div>
    </div>

    <div class="row">
        <div class="col-lg-12">
            <div class="card border-0 mb-4">
                <div class="card-header h6 mb-0 bg-none p-3">
                    <div class="row invoice_row">
                        <div class="col-md-2">
                            <i class="fa fa-user fa-lg fa-fw text-dark text-opacity-50 me-1"></i> Invoice List
                        </div>
                        <div class="col-md-6">
                            <div class="form-group">
                                <form method="post" class="form-inline" onsubmit="return checkRadio();">
                                    <div class="search-btn">
                                        <select class="form-control" name="show_table" id="show_table">
                                            <option value="grp_gepl_invoice" <?php if ($show_table == 'grp_gepl_invoice') {
                                                                                    echo "selected";
                                                                                } ?>>Invoice_2026_2027</option>
                                            <option value="grp_gepl_invoice_2025_2026" <?php if ($show_table == 'grp_gepl_invoice_2025_2026') {
                                                                                    echo "selected";
                                                                                } ?>>Invoice_2025_2026</option>
                                            <option value="grp_gepl_invoice_2024_2025" <?php if ($show_table == 'grp_gepl_invoice_2024_2025') {
                                                                                            echo "selected";
                                                                                        } ?>>Invoice_2024_2025</option>
                                            <option value="grp_gepl_invoice_2023_2024" <?php if ($show_table == 'grp_gepl_invoice_2023_2024') {
                                                                                            echo "selected";
                                                                                        } ?>>Invoice_2023_2024</option>
                                        </select>
                                    </div>
                                    <div class="search-btn">
                                        <input class="form-control" type="date" name="fromdate" id="fromdate" placeholder="From Date" />
                                    </div>
                                    <div class="search-btn">
                                        <input class="form-control" type="date" name="todate" id="todate" placeholder="To Date" />
                                    </div>
                                    <button type="submit" name="searchDate" class="btn btn-primary float-right">Search</button>
                                </form>
                            </div>
                        </div>
                        <div class="col-md-2">
                            <form method="post">
                                <button name="clearSearch" type="submit" class="btn btn-secondary">Clear</button>
                            </form>
                        </div>
                        <div class="col-md-2">
                            <a target="_blank" href="api/invoice-excel.php" class="pull-right float-right">
                                <button name="download" type="button" class="btn btn-secondary">Download Excel </button>
                            </a>
                        </div>
                    </div>
                </div>
                <div class="card-body">
                    <table id="data-table-default" class="table table-striped table-bordered table-td-valign-middle">
                        <h5> <?php echo $msg; ?></h5>
                        <thead>
                            <tr>
                                <th width="1%"></th>
                                <th>View</th>
                                <th class="text-nowrap" title="Invoice ID" width="5%">Inv ID</th>
                                <th class="text-nowrap" title="From Domain">From Domain</th>
                                <th class="text-nowrap" title="If Vendor">If Vendor</th>
                                <th class="text-nowrap" title="Transaction Type">Txn Type</th>
                                <th class="text-nowrap" title="MRP">MRP</th>
                                <th class="text-nowrap" title="Transaction Id">TxnId</th>
                                <th class="text-nowrap" title="Invoice Issue Date">Date</th>
                                <th class="text-nowrap" title="Customer Email">Email</th>
                                <th class="text-nowrap" title="Customer Name">Name</th>
                                <th class="text-nowrap" title="Customer Mobile">Mobile</th>
                                <th class="text-nowrap">Payment For</th>
                                <th class="text-nowrap" title="Transaction Date">Txn Date</th>

                            </tr>
                        </thead>
                        <tbody>
                            <?php $i = '1';
                            foreach ($invoiceQry as $invc) { ?>
                                <tr>
                                    <td width="1%" class="f-s-600 text-inverse"><?php echo $i; ?></td>
                                    <td><a href="invoice_template.php?id=<?php echo $invc['invoice_id']; ?>" target="_blank" style="cursor:pointer;" class="btn btn-danger btn-xs"><i class="fa fa-file"></i></a></td>

                                    <td><a href="javascript:void(0);" onclick="showData('<?php echo $invc['invoice_id']; ?>')" style="background-color:#0259ba;" class="btn btn-primary btn-xs"><i class="fa fa-eye"></i>&nbsp; <?php echo $invc['invoice_id']; ?></a></td>

                                    <td><?php echo $invc['from_domain']; ?></td>
                                    <td><?php echo $invc['if_vendor']; ?></td>
                                    <td><?php echo $invc['transaction_type']; ?></td>
                                    <td><?php echo $invc['product_mrp']; ?></td>
                                    <td><?php echo $invc['transaction_id1']; ?></td>
                                    <td><?php echo $invc['invoice_issue_date']; ?></td>
                                    <td><?php echo $invc['customer_email']; ?></td>
                                    <td><?php echo $invc['customer_name']; ?></td>
                                    <td><?php echo $invc['customer_mobile']; ?></td>
                                    <td><?php echo $invc['payment_for']; ?></td>
                                    <td><?php echo $invc['transaction_date']; ?></td>

                                </tr>
                            <?php $i++;
                            }
                            ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- #modal-dialog -->
<div class="modal fade" id="modal-dialog">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title">Invoice Details</h4>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-hidden="true"></button>
            </div>
            <div class="modal-body" id="show_invoice">
            </div>
        </div>
    </div>
</div>
<!-- #modal-dialog -->
<?php require('include/footer-data.php'); ?>
<script>
    function showData(id) {
        $.ajax({
            url: "api/view_invoice_details.php",
            method: "post",
            data: {
                invcid: id
            },
            success: function(data) {
                $('#show_invoice').html(data);
                $('#modal-dialog').modal("show");
            }
        });
    };
</script>
<script>
    function checkRadio() {
        var fromdate = document.getElementById('fromdate').value;
        var todate = document.getElementById('todate').value;
        if (fromdate == '') {
            document.getElementById("fromdate").focus();
            document.getElementById("fromdate").style.border = "#e66262 1px solid";
            return false;
        }
        if ((todate != '') && (fromdate == '')) {
            document.getElementById("fromdate").focus();
            document.getElementById("fromdate").style.border = "#e66262 1px solid";
            return false;
        }
        return true;
    }
</script>