<?php
if(!defined('ABSPATH')){
    exit; // Exit if accessed directly
}
?>

<form method="post" action="options.php" id="" class="egps_options_form">

    <?php settings_fields( 'egps_prices_data' ); ?>
    <?php do_settings_sections( 'egps_prices_data' ); ?>


    <h3>Photo's Price settings</h3>
    <p>
        You can define regular and exclusive photo prices here.
        <br><b>Keep in mind:</b> 
        If one photo was purchased with exclusive price, from that point the photo will no longer available for sell.
    </p>


    <?php

        if( !Egps::egps_chk_lic() ){ 
            echo '<div class="btn btn-danger">Please insert a valid license key to sell photos.</div>';
        }

        $options = get_option('egps_prices');

        if( $options == false ){
            $options = array();
            
            $options['currencySetup'] = "";
            $options['currencySetupCode'] = "";
            $options['regularPrice'] = "";
            $options['exclusivePrice'] = "";
            $options['maxDownloadCount'] = "";
        }

    ?>


    <table class="form-table" role="presentation">
        <tbody>

        <tr>
            <th scope="row">Select currency</th>
            <td><div class="">
            <input 
                type="hidden" 
                id="egps_currency_set" 
                name="egps_prices[currencySetup]" 
                value="<?php echo esc_html($options['currencySetup']); ?>">
            <input 
                type="hidden" 
                id="egps_currency_code" 
                name="egps_prices[currencySetupCode]" 
                value="<?php echo esc_html($options['currencySetupCode']); ?>">


                <select id="currencyList">
                    <?php 
                        $currs = Egps::egps_load_currencycodes(); 


                        foreach($currs as $key => $val){
                            ?>

                            <option 
                                value="<?php echo esc_html($val); ?>" 
                                label="<?php echo esc_html($key); ?>">
                                <?php echo esc_html($key); ?>
                            </option>

                        <?php
                        }
                        
                    ?>
                </select>


                </div>
            </td>
        </tr>
        <tr>
            <th scope="row">Regular price</th>
            <td><div class="">
                    <input 
                        class="float" 
                        type="text" 
                        name="egps_prices[regularPrice]" 
                        value="<?php echo esc_html($options['regularPrice']); ?>">
                </div>
            </td>
        </tr>
        <tr>
            <th scope="row">Exclusive price</th>
            <td><div class="">
                    <input 
                        class="float" 
                        type="text" 
                        name="egps_prices[exclusivePrice]" 
                        value="<?php echo esc_html($options['exclusivePrice']); ?>">
                </div>
            </td>
        </tr>
        <tr>
            <th scope="row">Max. download count</th>
            <td><div class="">
                    Set the number of times a customer can download the same photo after purchase.
                    <br>Does not apply to exclusive photos.
                    <br><input 
                        class="integer" 
                        type="text" 
                        name="egps_prices[maxDownloadCount]" 
                        value="<?php echo esc_html($options['maxDownloadCount']); ?>">
                </div>
            </td>
        </tr>



        </tbody>
    </table>

    <?php 
        submit_button();     
    ?>

</form>


