<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
?>
<div id="kirilkirkov-inv" class="wrap wp-kkinv-list-invoices">
    <h1 class="wp-heading-inline"><?php esc_html_e('Invoices List', 'kirilkirkov-pdf-invoice-manager' ) ?></h1>
    <a href="<?php echo esc_url(admin_url('admin.php?page=' . $Config::SUB_MENU_CREATE_INVOICE_PAGE_SLUG) ); ?>" class="add-new-h2"><?php echo esc_html__('Add New', 'kirilkirkov-pdf-invoice-manager') ?></a>
    <a href="<?php echo esc_url(admin_url('options-general.php?page=' . $Config::SETTINGS_GET_PARAM)); ?>" class="add-new-h2"><?php esc_html_e( 'Settings', 'kirilkirkov-pdf-invoice-manager' ); ?></a>

    <div id="poststuff">
        <div id="post-body">
            <div id="post-body-content">
                <div>
                    <form method="post">
                        <?php
                           wp_nonce_field( 'bulk_invoices_nonce', 'bulk_invoices_nonce' );
                           
                           $table->prepare_items(); 
                           
                           $table->search_box( esc_html__( 'Find', 'kirilkirkov-pdf-invoice-manager' ), 'find-client');

                           // No nonce verification needed here – only reading a safe _REQUEST param for filtering.
                           // phpcs:ignore WordPress.Security.NonceVerification.Recommended
                           $kirilkirkovwipdf_from = ( isset( $_REQUEST['invoice_date_s'] ) && sanitize_text_field(wp_unslash($_REQUEST['invoice_date_s'])) ) ? sanitize_text_field(wp_unslash($_REQUEST['invoice_date_s'])) : '';
                        ?>
                        <div class="kkinv-filter-by-invoice-date">
                            <label for="filter-by-invoice-date" class="screen-reader-text"><?php esc_html_e('Filter Invoice Date', 'kirilkirkov-pdf-invoice-manager');?></label>
                            <input id="filter-by-invoice-date" type="text" placeholder="<?php echo esc_attr__('Invoice Date From', 'kirilkirkov-pdf-invoice-manager') ?>" name="invoice_date_s" value="<?php echo esc_attr( sanitize_text_field(wp_unslash($kirilkirkovwipdf_from) )); ?>">
                        </div>
                        <?php
                           $table->display();
                        ?>
                    </form>
                </div>
            </div>
        </div>
        <br class="clear">
    </div>
</div>