<?php
//if(isset($_POST["submit_banner"])){
if (isset($_POST['woo2app-admin']) && wp_verify_nonce($_POST['woo2app-admin'], 'woo2app-admin')) {
	update_option("DEFAULT_FONT_APP", ($_POST['font']));
	update_option("DEFAULT_PRODUCT_CELL", ($_POST['product_cell']));
	update_option("category_them", ($_POST['category_them']));
	//update_option("category_select_btn", ($_POST['category_select_btn']));
	update_option("NAVIGATION_BUTTON", ($_POST['NAVIGATION_BUTTON']));
	update_option('woo2app_price_view', $_POST['price']); //array
	update_option('discount_label_list', ($_POST['discount_label_list']));
	update_option('quick_display_product', ($_POST['quick_display_product']));
}
$price = get_option('woo2app_price_view');
?>
<div class="wrap">
    <h3 class="background-color-e5e5e5 padding-7px">
		<?php _e('General Settings','woo2app')?>
    </h3>
    <form action="" method="post">
		<?php wp_nonce_field('woo2app-admin', 'woo2app-admin'); ?>
        <table class="form-table ">
            <tbody>
            <tr  class="" >
                <th scope="row" class="titledesc">
                    <label ><?php _e('Font','woo2app')?></label>
                </th>
                <td>
		            <?php
		            $font_app = get_option("DEFAULT_FONT_APP")
		            ?>
                    <select name="font" class="regular-text"  onchange="changeFontType(this)">
                        <option <?= selected($font_app , 1001)?> value="1001">یکان</option>
                        <option <?= selected($font_app , 1002)?> value="1002">مهر</option>
                        <option <?= selected($font_app , 1003)?> value="1003">وزیر</option>
                        <option <?= selected($font_app , 1004)?> value="1004">نازنین</option>
                        <option <?= selected($font_app , 1005)?> value="1005">ایران سنس</option>
                        <option <?= selected($font_app , 1006)?> value="1006">ایران</option>
                        <option <?= selected($font_app , 1007)?> value="1007">ایران مارکر</option>
                        <option <?= selected($font_app , 1008)?> value="1008">ایران شارپ</option>
                        <option <?= selected($font_app , 1009)?> value="1009">روستا</option>
                        <option <?= selected($font_app , 1010)?> value="1010">انجمن</option>
                        <option <?= selected($font_app , 1011)?> value="1011">فرهنگ</option>
                        <option <?= selected($font_app , 2001)?> value="2001"> Open Sans</option>
                        <option <?= selected($font_app , 2002)?> value="2002">PlayFire</option>
                        <option <?= selected($font_app , 2003)?> value="2003">Montserrat</option>
                        <option <?= selected($font_app , 2004)?> value="2004">Lato</option>
                        <option <?= selected($font_app , 2005)?> value="2005">Roboto</option>
                        <option <?= selected($font_app , 2006)?> value="2006">Maven Pro</option>
                    </select>
                    <br>
                    <small class="description"
                           id="tagline-description"><?php _e('Select the application font', 'woo2app'); ?></small>
                </td>
                <td></td>
            </tr>
            <tr>
                <th> <?php _e('Font Preview' , 'woo2app');?> </th>
                <td>
                    <img class="img_product_list <?php if($font_app != 1001) echo 'hide'; ?>" id="demo_PList_1001"  style="height: 400px" src="<?= WOO2APP_URL .'/files/img/AppFonts/1001-yekan.png'?>">
                    <img class="img_product_list <?php if($font_app != 1002) echo 'hide'; ?>" id="demo_PList_1002"  style="height: 400px" src="<?= WOO2APP_URL .'/files/img/AppFonts/1002-mehr.png'?>">
                    <img class="img_product_list <?php if($font_app != 1003) echo 'hide'; ?>" id="demo_PList_1003"  style="height: 400px" src="<?= WOO2APP_URL .'/files/img/AppFonts/1003-vazir.png'?>">
                    <img class="img_product_list <?php if($font_app != 1004) echo 'hide'; ?>" id="demo_PList_1004"  style="height: 400px" src="<?= WOO2APP_URL .'/files/img/AppFonts/1004-nazanin.png'?>">
                    <img class="img_product_list <?php if($font_app != 1005) echo 'hide'; ?>" id="demo_PList_1005"  style="height: 400px" src="<?= WOO2APP_URL .'/files/img/AppFonts/1005-iransans.png'?>">
                    <img class="img_product_list <?php if($font_app != 1006) echo 'hide'; ?>" id="demo_PList_1006"  style="height: 400px" src="<?= WOO2APP_URL .'/files/img/AppFonts/1006-iran.png'?>">
                    <img class="img_product_list <?php if($font_app != 1007) echo 'hide'; ?>" id="demo_PList_1007"  style="height: 400px" src="<?= WOO2APP_URL .'/files/img/AppFonts/1007-iranmarker.png'?>">
                    <img class="img_product_list <?php if($font_app != 1008) echo 'hide'; ?>" id="demo_PList_1008"  style="height: 400px" src="<?= WOO2APP_URL .'/files/img/AppFonts/1008-iransharp.png'?>">
                    <img class="img_product_list <?php if($font_app != 1009) echo 'hide'; ?>" id="demo_PList_1009"  style="height: 400px" src="<?= WOO2APP_URL .'/files/img/AppFonts/1009-rosta.png'?>">
                    <img class="img_product_list <?php if($font_app != 1010) echo 'hide'; ?>" id="demo_PList_1010"  style="height: 400px" src="<?= WOO2APP_URL .'/files/img/AppFonts/1010-anjoman.png'?>">
                    <img class="img_product_list <?php if($font_app != 1011) echo 'hide'; ?>" id="demo_PList_1011"  style="height: 400px" src="<?= WOO2APP_URL .'/files/img/AppFonts/1011-farhang.png'?>">
                    <img class="img_product_list <?php if($font_app != 2001) echo 'hide'; ?>" id="demo_PList_2001"  style="height: 400px" src="<?= WOO2APP_URL .'/files/img/AppFonts/2001-opensans.png'?>">
                    <img class="img_product_list <?php if($font_app != 2002) echo 'hide'; ?>" id="demo_PList_2002"  style="height: 400px" src="<?= WOO2APP_URL .'/files/img/AppFonts/2002-playfire.png'?>">
                    <img class="img_product_list <?php if($font_app != 2003) echo 'hide'; ?>" id="demo_PList_2003"  style="height: 400px" src="<?= WOO2APP_URL .'/files/img/AppFonts/2003-montserrat.png'?>">
                    <img class="img_product_list <?php if($font_app != 2004) echo 'hide'; ?>" id="demo_PList_2004"  style="height: 400px" src="<?= WOO2APP_URL .'/files/img/AppFonts/2004-lato.png'?>">
                    <img class="img_product_list <?php if($font_app != 2005) echo 'hide'; ?>" id="demo_PList_2005"  style="height: 400px" src="<?= WOO2APP_URL .'/files/img/AppFonts/2005-roboto.png'?>">
                    <img class="img_product_list <?php if($font_app != 2006) echo 'hide'; ?>" id="demo_PList_2006"  style="height: 400px" src="<?= WOO2APP_URL .'/files/img/AppFonts/2006-maven.png'?>">
                </td>
            </tr>
            <tr  class="">
                <th scope="row" class="titledesc">
                    <label><?php _e('Home Screen', 'woo2app'); ?></label>
                </th>
                <td class="forminp vertical-align-top">
                    <select name="NAVIGATION_BUTTON" class="regular-text" >
                        <option <?php echo (get_option("NAVIGATION_BUTTON") == 0) ? "selected" : ""; ?>
                                value="0">  <?php _e('Simple', 'woo2app'); ?> </option>
                        <option <?php echo (get_option("NAVIGATION_BUTTON") == 1) ? "selected" : ""; ?>
                                value="1">  <?php _e('Tab bar', 'woo2app'); ?> </option>
                    </select>
                </td>
                <td>
                </td>
            </tr>
            <tr  class="">
                <th scope="row" class="titledesc">
                    <label><?php _e("'Add to Cart' button on the list is active ?", 'woo2app'); ?></label>
                </th>
                <td class="forminp vertical-align-top">
                    <select name="product_cell" class="regular-text" onchange="change_demo_img(this)">
                        <option <?php echo (get_option("DEFAULT_PRODUCT_CELL") == 1) ? "selected" : ""; ?>
                                value="1"><?php _e('Simple', 'woo2app'); ?></option>
                        <option <?php echo (get_option("DEFAULT_PRODUCT_CELL") == 2) ? "selected" : ""; ?>
                                value="2"><?php _e('With button', 'woo2app'); ?></option>
                    </select>
                    <div class="clear"></div>
                    <div class="margin-5px">
                        <img id="demo_img_cell_1"
                             class="demo_img_cell  <?= (get_option("DEFAULT_PRODUCT_CELL") == 1) ? 'display-block' : 'display-none'; ?> width-256px"
                             src="<?=  get_locale() == 'fa_IR' ? WOO2APP_URL . 'files/img/persian_demo_img_cell_1.jpg' : WOO2APP_URL .'files/img/demo_img_cell_1.jpg' ?>">
                        <img id="demo_img_cell_2"
                             class="demo_img_cell <?= (get_option("DEFAULT_PRODUCT_CELL") == 2) ? 'display-block' : 'display-none'; ?> width-256px"
                             src="<?=  get_locale() == 'fa_IR' ? WOO2APP_URL . 'files/img/persian_demo_img_cell_2.jpg' : WOO2APP_URL .'files/img/demo_img_cell_2.jpg' ?>">
                    </div>
                </td>
                <td>
                </td>
            </tr>
            <tr  class="">
                <th scope="row" class="titledesc">
                    <label><?php _e('Discount Percent Label', 'woo2app'); ?></label>
                </th>
                <td class="forminp vertical-align-top">
                    <select name="discount_label_list" class="regular-text" >
                        <option <?php echo (get_option("discount_label_list") == 1) ? "selected" : ""; ?>
                                value="1">  <?php _e('Show', 'woo2app'); ?> </option>
                        <option <?php echo (get_option("discount_label_list") == 2) ? "selected" : ""; ?>
                                value="2">  <?php _e('Hide', 'woo2app'); ?> </option>
                    </select>
                    <br><small class="description">
			            <?php _e('Show discount label in product list', 'woo2app'); ?>
                    </small>
                </td>
                <td>
                </td>
            </tr>
            <tr  class="">
                <th scope="row" class="titledesc">
                    <label><?php _e('Product Quick View', 'woo2app'); ?></label>
                </th>
                <td class="forminp vertical-align-top">
                    <select name="quick_display_product" class="regular-text" >
                        <option <?php echo (get_option("quick_display_product") == 1) ? "selected" : ""; ?>
                                value="1"> <?php _e('Show', 'woo2app'); ?>  </option>
                        <option <?php echo (get_option("quick_display_product") == 2) ? "selected" : ""; ?>
                                value="2"> <?php _e('Hide', 'woo2app'); ?> </option>
                    </select>
                    <br>
                </td>
                <td>
                </td>
            </tr>
            </tbody>
        </table>
        <hr>

        <table class="form-table ">
            <tbody>
            <tr  class="">
                <th scope="row" class="titledesc">
                    <label>  <?php _e('Price', 'woo2app'); ?> </label>
                </th>
                <td class="forminp vertical-align-top">
                    <select name="price[variables]" class="regular-text" >
                        <option value="1" <?= selected($price['variables'],'1')?> ><?php _e('250,000$ to 500,000$' , 'woo2app');?></option>
                        <option value="2" <?= selected($price['variables'],'2')?> ><?php _e('From 250,000$ to 500,000$' , 'woo2app');?></option>
                        <option value="3" <?= selected($price['variables'],'3')?> ><?php _e('250,000$ - 500,000$' , 'woo2app');?></option>
                        <option value="4" <?= selected($price['variables'],'4')?> ><?php _e('Start from 250,000$' , 'woo2app');?></option>
                        <option value="5" <?= selected($price['variables'],'5')?> ><?php _e('From 250,000$' , 'woo2app');?></option>
                    </select>
                    <p>
	                    <?php _e('Choose how to display the price in the lists.', 'woo2app'); ?>

                    </p>
                </td>
            </tr>
            <tr  class="">
                <th scope="row" class="titledesc">
                    <label>  <?php _e('"Out Of Stock" Label', 'woo2app'); ?>  </label>
                </th>
                <td class="forminp vertical-align-top">
                    <input name="price[out_off_stock]" type="text" value="<?= $price['out_off_stock']?>" class="regular-text"/>
                </td>
            </tr>
            <tr  class="">
                <th scope="row" class="titledesc">
                    <label><?php _e('"Not For Sale" Label', 'woo2app'); ?> </label>
                </th>
                <td class="forminp vertical-align-top">
                    <input name="price[unavailable]" type="text" value="<?= $price['unavailable']?>" class="regular-text"/>
                </td>
            </tr>
            </tbody>
        </table>
        <div class="padding-left-10px">
            <input type="submit" class="button button-primary" value="<?php _e('Save Changes', 'woo2app'); ?> "
                   name="submit_banner">
        </div>
    </form>
</div>
<script>
    function change_demo_img(e) {
        //alert(e.value);
        jQuery(".demo_img_cell").attr('style','display:none');
        jQuery("#demo_img_cell_" + e.value).attr('style','display:block;width: 256px');
    }
</script>
<script>
    function changeFontType(e){
        //console.log(e.value)
        jQuery(".img_product_list").addClass('hide');
        jQuery("#demo_PList_" + e.value).removeClass('hide');
    }
</script>