<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
?>
<table class="form-table">
    <tr valign="top">
        <th scope="row" class="align-middle">
        </th>

        <td>
            <div class="premium-feature-box">
                <div class="text-center px-4">
                    <div class="flex items-center justify-center mb-2">
                        <img class="w-6 h-6" src="<?php echo esc_url(plugins_url('../../Assets/Img/crown.svg', __FILE__ )); ?>" alt="<?php echo esc_attr( 'WP Invoices' ) ?>" />
                        <h3><?php esc_html_e( 'Premium Feature', 'kirilkirkov-pdf-invoice-manager' ); ?></h3>
                    </div>
                    <p class="mb-4"><?php esc_html_e( 'Stripe payments are available in the premium version of the plugin.', 'kirilkirkov-pdf-invoice-manager' ); ?></p>
                    <a href="<?php echo esc_url($Config::PREMIUM_LINK); ?>" target="_blank" class="kkinv-btn-primary"><?php esc_html_e( 'Get Premium Now', 'kirilkirkov-pdf-invoice-manager' ); ?></a>
                </div>
            </div>
        </td>
    </tr>

    <tr valign="top" class="premium-feature-container">
        <th scope="row" class="align-middle">
            <div class="th-div">
                <span class="mr-5"><?php esc_html_e( 'Stripe API Credentials', 'kirilkirkov-pdf-invoice-manager' ); ?></span>
                <a class="show-info" data-info="<?php esc_attr_e( 'To get the Stripe API keys, go to Stripe Dashboard then click Developers and there you can find them into API keys section under Standard keys header.', 'kirilkirkov-pdf-invoice-manager' ) ?>" href="javascript:;"></a>
            </div>
        </th>

        <td>
            <div class="mb-4">
                <?php 
                    $kirilkirkovwipdf_stripe_enabled = get_option($Config::INPUTS_PREFIX.'stripe_enabled');
                ?>
                <input type="hidden" name="<?php echo esc_attr($Config::INPUTS_PREFIX).'stripe_enabled'; ?>" value="0" />
                <label>
                    <input type="checkbox" name="<?php echo esc_attr($Config::INPUTS_PREFIX).'stripe_enabled'; ?>" value="1" <?php echo $kirilkirkovwipdf_stripe_enabled && (int)$kirilkirkovwipdf_stripe_enabled === 1 ? 'checked' : ''; ?>>
                    <?php esc_html_e( 'Enable stripe payments', 'kirilkirkov-pdf-invoice-manager' ); ?>
                </label>
            </div>

            <div class="mb-4">
                <label><?php esc_html_e( 'Public Key', 'kirilkirkov-pdf-invoice-manager' ); ?></label>
                <input type="text" name="<?php echo esc_attr($Config::INPUTS_PREFIX); ?>stripe_public_key" value="<?php echo esc_attr(sanitize_text_field(get_option( $Config::INPUTS_PREFIX.'stripe_public_key' ))); ?>" />
            </div>

            <div class="mb-4">
                <label><?php esc_html_e( 'Secret Key', 'kirilkirkov-pdf-invoice-manager' ); ?></label>
                <input type="text" name="<?php echo esc_attr($Config::INPUTS_PREFIX); ?>stripe_secret_key" value="<?php echo esc_attr(sanitize_text_field(get_option( $Config::INPUTS_PREFIX.'stripe_secret_key' ))); ?>" />
            </div>

            <p class="alert alert-success h-auto--important">
                <?php esc_html_e( 'It\'s a good idea to run the default WordPress cron to clear the PDF files stored by users in the uploads directory. WP Invoices is scheduled to clean these files hourly using cron.', 'kirilkirkov-pdf-invoice-manager' ); ?>
            </p>
        </td>
    </tr>

    <?php if($Woo->hasActiveWoocommerce()) { ?>
    <tr class="premium-feature-container">
        <th scope="row" class="align-middle">
            <div class="th-div">
                <span class="mr-5"><?php esc_html_e( 'WooCommerce', 'kirilkirkov-pdf-invoice-manager' ); ?></span>
            </div>
        </th>
        <td>
            <div class="mb-4">
                <?php
                    $kirilkirkovwipdf_wc_mark_order_as_paid_when_invoice_is_paid = get_option($Config::INPUTS_PREFIX.'wc_mark_order_as_paid_when_invoice_is_paid');
                ?>
                <div><label><?php esc_html_e( 'When an invoice is marked as paid by a payment provider, update the related WooCommerce order to:', 'kirilkirkov-pdf-invoice-manager' ); ?></label></div>
                <select name="<?php echo esc_attr($Config::INPUTS_PREFIX); ?>wc_mark_order_as_paid_when_invoice_is_paid">
                    <option <?php echo !$kirilkirkovwipdf_wc_mark_order_as_paid_when_invoice_is_paid || $kirilkirkovwipdf_wc_mark_order_as_paid_when_invoice_is_paid == '' ? 'selected="selected"' : ''; ?> value="">
                        <?php echo esc_html_e('— Do not change order status —', 'kirilkirkov-pdf-invoice-manager'); ?>
                    </option>
                    <?php
                    $kirilkirkovwipdf_order_statuses = wc_get_order_statuses();
                    foreach($kirilkirkovwipdf_order_statuses as $kirilkirkovwipdf_status_key => $kirilkirkovwipdf_status_label) {
                        $kirilkirkovwipdf_status_key = str_replace('wc-', '', $kirilkirkovwipdf_status_key);
                    ?>
                        <option <?php echo $kirilkirkovwipdf_wc_mark_order_as_paid_when_invoice_is_paid && $kirilkirkovwipdf_wc_mark_order_as_paid_when_invoice_is_paid === $kirilkirkovwipdf_status_key ? 'selected="selected"' : ''; ?> value="<?php echo esc_attr(sanitize_text_field($kirilkirkovwipdf_status_key)); ?>">
                            <?php echo esc_html(sanitize_text_field($kirilkirkovwipdf_status_label)); ?>
                        </option>
                    <?php
                    }
                    ?>
                </select>
            </div>
        </td>
    </tr>
    <?php } ?>
</table>

<input type="hidden" name="page_options" value="<?php echo esc_attr(sanitize_text_field($Config::PAYMENTS_INPUT_GROUP)); ?>" />
<?php settings_fields($Config::PAYMENTS_INPUT_GROUP); ?>