<?php
wp_register_style( 'woo2app_style', WOO2APP_CSS_URL.'woo2app_style.css'  );
wp_enqueue_style( 'woo2app_style'.WOO2APP_FILES_VER );
if(get_locale() == 'fa_IR'){
	wp_register_style('myfont', WOO2APP_CSS_URL . 'font.css');
	wp_enqueue_style( 'myfont'.WOO2APP_FILES_VER);
}

if (!defined( 'ABSPATH' )) exit;
$current_url="//".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
if(isset($_GET["tab"]))	$tab = $_GET["tab"];
else $tab = 'main';
//if(isset($_POST["submit_primary_setting_form"]) && $_POST["submit_primary_setting_form"] == "hami" ){
if (isset($_POST['woo2app-admin']) && wp_verify_nonce($_POST['woo2app-admin'], 'woo2app-admin') && isset($_POST["submit_primary_setting_form"]) && $_POST["submit_primary_setting_form"] == "hami") {
	//$font = $_POST["select_font_primary_setting"];
	$unit = ($_POST["unit_primary_setting"]);
	//$ver = $_POST["version_primary_setting"];
	//$lnk = $_POST["link_primary_setting"];
	$buy_with_login = (isset($_POST["BUY_WITH_LOGIN"]) && $_POST["BUY_WITH_LOGIN"] == 'on') ? true : false;
	$enter_with_login =  (isset($_POST["ENTER_WITH_LOGIN"]) && $_POST["ENTER_WITH_LOGIN"] == 'on') ? true : false;
	$display_btn_share =  (isset($_POST["display_btn_share"]) && $_POST["display_btn_share"] == 'on') ? true : false;
	$woo2app_googleloginkey = $_POST["woo2app_googleloginkey"] ;
	if(isset($unit)) update_option("DEFAULT_UNIT_APP" , $unit);
	update_option('BUY_WITH_LOGIN',$buy_with_login);
	update_option('ENTER_WITH_LOGIN',$enter_with_login);
	update_option('display_btn_share',$display_btn_share);
	update_option('woo2app_googleloginkey',$woo2app_googleloginkey);
	update_option('calltoprice_tell', ($_POST["calltoprice_tell"]));
	update_option('calltoprice_price', ($_POST["calltoprice_price"]));
	update_option('default_product_images', ($_POST["default_product_images"]));
	update_option('size_of_product_image_list', ($_POST["size_of_product_image_list"]));
	update_option('woo2app_taxonomy_for_app', ($_POST["woo2app_taxonomy_for_app"]));
	update_option('AppLoadingImage', ($_POST["AppLoadingImage"]));
	update_option('LoadingText', ($_POST["LoadingText"]));
	update_option('order_by_stock_status', isset($_POST["order_by_stock_status"]) && $_POST["order_by_stock_status"] == 'on' );

	$setting = array();
	$setting = get_option('woo2app_primary_setting');
	$setting = array();
	$setting['primary_setting']['register_rules']['enable'] =  $_POST['register_rules_enable']  == 'on' ? true : false;
	$setting['primary_setting']['register_rules']['btn_text'] = ($_POST['register_rules_btn_text']);
	$setting['primary_setting']['register_rules']['link'] = esc_url_raw($_POST['register_rules_link']);

	$setting['primary_setting']['order_rules']['enable'] =  $_POST['order_rules_enable']  == 'on' ? true : false;
	$setting['primary_setting']['order_rules']['btn_text'] = ($_POST['order_rules_btn_text']);
	$setting['primary_setting']['order_rules']['link'] = esc_url_raw($_POST['order_rules_link']);

	$setting['primary_setting']['payment_rules']['enable'] =  $_POST['payment_rules_enable']  == 'on' ? true : false;
	$setting['primary_setting']['payment_rules']['btn_text'] = ($_POST['payment_rules_btn_text']);
	$setting['primary_setting']['payment_rules']['link'] = esc_url_raw($_POST['payment_rules_link']);

	$setting['primary_setting']['app_success_back'] =  $_POST['app_success_back'] ;
	$setting['primary_setting']['app_fault_back'] =  $_POST['app_fault_back'] ;

	update_option('woo2app_primary_setting' , $setting);

	$update['android_ver_code'] = ($_POST['android_ver_code']);
	$update['android_update_url'] = esc_url_raw($_POST['android_update_url']);
	$update['android_update_req'] = (isset($_POST['android_update_req']) && $_POST['android_update_req'] == 'on' ) ? true : false;
	$update['ios_ver_code'] = ($_POST['ios_ver_code']);
	$update['ios_update_url'] = esc_url_raw($_POST['ios_update_url']);
	$update['description_update'] = ($_POST['description_update']);
	$update['description_update_ios'] = ($_POST['description_update_ios']);
	$update['ios_update_req'] = (isset($_POST['ios_update_req']) &&  $_POST['ios_update_req'] == 'on') ? true : false;
	update_option('woo2app_update' , $update);
}
if (isset($_POST['woo2app-admin']) && wp_verify_nonce($_POST['woo2app-admin'], 'woo2app-admin') && isset($_POST['submit_update'])) {
	$update = array();
	$update = get_option('woo2app_update');
	if(!is_array($update)){
		$update = array();
		$update['android_ver_code'] = '' ;
		$update['android_update_url'] = '' ;
		$update['android_update_req'] = false ;
		$update['ios_ver_code'] = '' ;
		$update['ios_update_url'] = '' ;
		$update['description_update'] = '' ;
		$update['description_update_ios'] = '' ;
		$update['ios_update_req'] = false ;
		update_option('woo2app_update' , $update);
	}
	$update['android_ver_code'] = ($_POST['android_ver_code']);
	$update['android_update_url'] = esc_url_raw($_POST['android_update_url']);
	$update['android_update_req'] = (isset($_POST['android_update_req']) && $_POST['android_update_req'] == 'on' ) ? true : false;
	$update['ios_ver_code'] = ($_POST['ios_ver_code']);
	$update['ios_update_url'] = esc_url_raw($_POST['ios_update_url']);
	$update['description_update'] = $_POST['description_update'];// html
	$update['description_update_ios'] = $_POST['description_update_ios']; // html
	$update['ios_update_req'] = (isset($_POST['ios_update_req']) &&  $_POST['ios_update_req'] == 'on') ? true : false;
	update_option('woo2app_update' , $update);
}
if (isset($_POST['woo2app-admin']) && wp_verify_nonce($_POST['woo2app-admin'], 'woo2app-admin') && isset($_POST['submit_limit_cart'])) {
	$limit_cart = array();
	$limit_cart = get_option('woo2app_limit_cart');
	if(!is_array($limit_cart)){
		$limit_cart = array();
		$limit_cart['buy_from_unit_store'] = false;
		$limit_cart['empty_cart_after_reopen'] = false ;
		update_option('woo2app_limit_cart' , $limit_cart);
	}
	$limit_cart['buy_from_unit_store'] = (isset($_POST['buy_from_unit_store']) && $_POST['buy_from_unit_store'] == 'on' ) ? true : false;
	$limit_cart['empty_cart_after_reopen'] = (isset($_POST['empty_cart_after_reopen']) &&  $_POST['empty_cart_after_reopen'] == 'on') ? true : false;
	update_option('woo2app_limit_cart' , $limit_cart);
	$minimum_purchase_amount = (int)($_POST["minimum_purchase_amount"]);
	update_option("minimum_purchase_amount" , $minimum_purchase_amount);
}

$primary_setting = get_option('woo2app_primary_setting');
$primary_setting = $primary_setting['primary_setting'];
?>
<div class="wrap">
    <h2 class="nav-tab-wrapper koodak">
        <a href="<?= $current_url . '&tab=main' ?>"
           class="nav-tab <?php echo ('main' == $tab) ? 'nav-tab-active' : ''; ?>"> <?php _e('Main Setting', 'woo2app'); ?> </a>
        <a href="<?= $current_url . '&tab=update' ?>"
           class="nav-tab <?php echo ('update' == $tab) ? 'nav-tab-active' : ''; ?>"> <?php _e('Update ', 'woo2app'); ?></a>
        <a href="<?= $current_url . '&tab=limit_cart' ?>"
           class="nav-tab <?php echo ('limit_cart' == $tab) ? 'nav-tab-active' : ''; ?>"> <?php _e('Cart ', 'woo2app'); ?></a>
        <a href="<?= $current_url . '&tab=category_setting' ?>"
           class="nav-tab <?php echo ('category_setting' == $tab) ? 'nav-tab-active' : ''; ?>"> <?php _e('Category', 'woo2app'); ?> </a>
        <a href="<?= $current_url . '&tab=PopUp' ?>"
           class="nav-tab <?php echo ('PopUp' == $tab) ? 'nav-tab-active' : ''; ?>"> <?php _e('PopUp', 'woo2app'); ?> </a>
    </h2>
	<?php
	if($tab == 'main'){
		?>
        <h2>
			<?php _e('Main Settings', 'woo2app'); ?>
        </h2>
        <form method="post">
			<?php wp_nonce_field('woo2app-admin', 'woo2app-admin'); ?>
            <input value="hami" name="submit_primary_setting_form" type="hidden">
            <table class="form-table ">
                <tbody>
                <tr valign="top" class="" >
                    <th scope="row" class="titledesc">
                        <label> <?php _e('Currency', 'woo2app'); ?> </label>
                    </th>
                    <td class="forminp">
                        <input type="text" class="regular-text" name="unit_primary_setting" value="<?php echo get_option("DEFAULT_UNIT_APP"); ?>">
                    </td>
                </tr>
                <tr valign="top" class="" >
                    <th scope="row" class="titledesc">
						<?php _e('Requires login to start', 'woo2app'); ?>
                    </th>
                    <td class="forminp">
                        <input type="checkbox" name="ENTER_WITH_LOGIN" <?= checked(get_option("ENTER_WITH_LOGIN")  );?> />
                        <span><?php _e('if enabled, The user must be logged in to start app', 'woo2app'); ?></span>
                    </td>
                </tr>
                <tr valign="top" class="" >
                    <th scope="row" class="titledesc">
						<?php _e('Requires login to Submit Order', 'woo2app'); ?>
                    </th>
                    <td class="forminp">
                        <input type="checkbox" name="BUY_WITH_LOGIN" <?= checked(get_option("BUY_WITH_LOGIN")  );?> />
						<?php _e('if enabled, The user must be logged in to submit order', 'woo2app'); ?>
                    </td>
                </tr>
                <tr valign="top" class="" >
                    <th scope="row" class="titledesc">
						<?php _e('Google Client ID', 'woo2app'); ?>
                    </th>
                    <td class="forminp">
                        <input type="text" class="regular-text" name="woo2app_googleloginkey" value="<?php echo get_option("woo2app_googleloginkey"); ?>">
                        <p>
                            <a target="_blank" href="http://mr2app.com/blog/login-with-google/">
								<?php _e('Guide', 'woo2app'); ?>
                            </a>
                        </p>
                    </td>
                </tr>
                <tr valign="top" class="" >
                    <th scope="row" class="titledesc">
                        <label>  <?php _e('Call To Price Phone Number', 'woo2app'); ?> </label>
                    </th>
                    <td class="forminp">
                        <input type="text" class="regular-text" name="calltoprice_tell" value="<?php echo get_option("calltoprice_tell"); ?>">
                        <p class="description">  <?php _e('Call this number when the call button is clicked', 'woo2app'); ?> </p>
                    </td>
                </tr>
                <tr valign="top" class="" >
                    <th scope="row" class="titledesc">
                        <label><?php _e('Price to display the (call to price) button', 'woo2app'); ?> </label>
                    </th>
                    <td class="forminp">
                        <input type="text" class="regular-text" name="calltoprice_price" value="<?php echo get_option("calltoprice_price"); ?>">
                        <p class="description">  <?php _e('If the price is equal to this number, display the call button', 'woo2app'); ?> </p>
                    </td>
                </tr>
                <tr>
                    <th >
                        <label dir="rtl"> <?php _e('Default Product Image', 'woo2app'); ?> </label>
                    </th>
                    <td class="forminp">
                        <input type="text" class="regular-text" id="default_product_images" value="<?= get_option('default_product_images');?>" name="default_product_images">
                        <button class="button"
                                id="div_image_item_hami"> <?php _e('Select Image', 'woo2app'); ?> </button>
                    </td>
                </tr>
                <tr>
					<?php
					$size_of_product_image_list = get_option('size_of_product_image_list');
					?>
                    <th >
						<?php _e('Product Image Size', 'woo2app'); ?>
                    </th>
                    <td class="forminp">
                        <select name="size_of_product_image_list">
                            <option <?= selected($size_of_product_image_list,'thumbnail')?> value="thumbnail"> Thumbnail  </option>
                            <option <?= selected($size_of_product_image_list,'medium')?> value="medium"> Medium  </option>
                            <option <?= selected($size_of_product_image_list,'medium_large')?> value="medium_large"> Medium Large  </option>
                            <option <?= selected($size_of_product_image_list,'large')?> value="large"> large </option>
                            <option <?= selected($size_of_product_image_list,'shop_thumbnail')?> value="shop_thumbnail"> Shop Thumbnail  </option>
                            <option <?= selected($size_of_product_image_list,'shop_catalog')?> value="shop_catalog"> Shop Catalog  </option>
                            <option <?= selected($size_of_product_image_list,'shop_single')?> value="shop_single"> Shop Single  </option>
                            <option <?= selected($size_of_product_image_list, 'main') ?>
                                    value="main"> <?php _e('Original size', 'woo2app'); ?> </option>
                        </select>
                        <p class="description">
							<?php _e('Product image quality in products list.', 'woo2app'); ?>
                        </p>
                    </td>
                </tr>
                <tr>
					<?php
					$taxonomies = get_taxonomies();
					$woo2app_taxonomy_for_app = get_option('woo2app_taxonomy_for_app');
					if($woo2app_taxonomy_for_app == 'null' || $woo2app_taxonomy_for_app == ''){
						$woo2app_taxonomy_for_app = 'product_cat';
						update_option('woo2app_taxonomy_for_app' , 'product_cat');
					}
					?>
                    <th >
                        <label dir="rtl">   <?php _e('Product Category Type', 'woo2app'); ?>   </label>
                    </th>
                    <td class="forminp">
                        <select name="woo2app_taxonomy_for_app">
							<?php
							foreach ($taxonomies as $taxonomy){
								if(strpos($taxonomy , 'product_') !==  false ){
									?>
                                    <option  <?= selected($woo2app_taxonomy_for_app , $taxonomy)?> value="<?= $taxonomy?>"><?= $taxonomy; ?></option>
									<?php
								}
							}
							?>
                        </select>
                    </td>
                </tr>

                <tr valign="top" class="">
                    <th>
						<?php _e('Enable acceptance of terms in registration', 'woo2app'); ?>
                    </th>
                    <td>
                        <input type="checkbox"  name="register_rules_enable" <?= checked($primary_setting['register_rules']['enable'] )?> />
                        <input type="text" class="regular-text"
                               placeholder="<?php _e('Label', 'woo2app'); ?>"
                               name="register_rules_btn_text"
                               value="<?= $primary_setting['register_rules']['btn_text'] ?>"/>
                        <input type="text" class="regular-text"
                               placeholder="<?php _e('Link', 'woo2app'); ?>"
                               name="register_rules_link" value="<?= $primary_setting['register_rules']['link'] ?>"/>
                    </td>
                </tr>

                <tr valign="top" class="">
                    <th>
						<?php _e('Enable acceptance of terms in order submission', 'woo2app'); ?>
                    </th>
                    <td >
                        <input type="checkbox"  name="order_rules_enable" <?= checked($primary_setting['order_rules']['enable'] )?> />
                        <input type="text" class="regular-text"
                               placeholder="<?php _e('Label', 'woo2app'); ?>"
                               name="order_rules_btn_text" value="<?= $primary_setting['order_rules']['btn_text'] ?>"/>
                        <input type="text" class="regular-text"
                               placeholder="<?php _e('Link', 'woo2app'); ?>"
                               name="order_rules_link" value="<?= $primary_setting['order_rules']['link'] ?>"/>
                    </td>
                </tr>

                <tr valign="top" class="">
                    <th>
						<?php _e('Enable acceptance of terms in order payment', 'woo2app'); ?>
                    </th>
                    <td >
                        <input type="checkbox"  name="payment_rules_enable" <?= checked($primary_setting['payment_rules']['enable'] )?> />
                        <input type="text" class="regular-text"
                               placeholder="<?php _e('Label', 'woo2app'); ?>"
                               name="payment_rules_btn_text"
                               value="<?= $primary_setting['payment_rules']['btn_text'] ?>"/>
                        <input type="text" class="regular-text"
                               placeholder="<?php _e('Link', 'woo2app'); ?>"
                               name="payment_rules_link" value="<?= $primary_setting['payment_rules']['link'] ?>"/>
                    </td>
                </tr>

                <tr valign="top" class="">
                    <th>
						<?php _e('Successful Payment Page', 'woo2app'); ?>
                    </th>
                    <td>
                        <select name="app_success_back" class="regular-text">
                            <option> <?php _e('Please Select ...', 'woo2app'); ?> </option>
							<?php
							$args = array(
								'post_type' => 'page',
								'numberposts' => -1
							);
							$pages = get_posts($args);
							foreach ($pages as $p){
								?>
                                <option <?= selected($primary_setting['app_success_back'] , get_permalink($p->ID))?> value="<?= get_permalink($p->ID)?>">
									<?= $p->post_title?>
                                </option>
								<?php
							}
							?>
                        </select>
                        <p>
                            <a href=""><?php _e('Guide', 'woo2app'); ?></a>
                        </p>
                    </td>
                </tr>
                <tr valign="top" class="">
                    <th>
						<?php _e('Failed Payment Page', 'woo2app'); ?>

                    </th>
                    <td>
                        <select name="app_fault_back" class="regular-text">
                            <option>  <?php _e('Please Select ...', 'woo2app'); ?> </option>
							<?php
							foreach ($pages as $p){
								?>
                                <option <?= selected($primary_setting['app_fault_back'] , get_permalink($p->ID))?> value="<?= get_permalink($p->ID)?>">
									<?= $p->post_title?>
                                </option>
								<?php
							}
							?>
                        </select>
                        <p>
                            <a href=""><?php _e('Guide', 'woo2app'); ?></a>
                        </p>
                    </td>
                </tr>
                <tr>
					<?php
					$AppLoadingImage = get_option('AppLoadingImage')
					?>
                    <th >
                        <label dir="rtl"> <?php _e('Loading Image', 'woo2app'); ?> </label>
                    </th>
                    <td class="forminp">
                        <input type="text" class="regular-text" id="AppLoadingImage" value="<?= $AppLoadingImage;?>" name="AppLoadingImage">
                        <button type="button"  class="button"
                                id="Sel_AppLoadingImage"> <?php _e('Select Image', 'woo2app'); ?> </button>
						<?php
						if($AppLoadingImage != ""){
							?>
                            <button type="button" class="button red" onclick="jQuery('#AppLoadingImage').val('')"
                                    id="Del_AppLoadingImage"> <?php _e('Empty', 'woo2app'); ?> </button>
							<?php
						}
						?>
                    </td>
                </tr>
                <tr valign="top" class="" >
                    <?php
                    $LoadingText = get_option("LoadingText");
                    ?>
                    <th scope="row" class="titledesc">
                        <label>  <?php _e('Loading Text', 'woo2app'); ?> </label>
                    </th>
                    <td class="forminp">
                        <input type="text" class="regular-text" name="LoadingText" value="<?= $LoadingText ?>">
                    </td>
                </tr>
               <!-- <tr valign="top" class="" >
                    <?php
                    $order_by_stock_status = get_option("order_by_stock_status");
                    ?>
                    <th scope="row" class="titledesc">
                        <label>  <?php _e('order by stock status', 'woo2app'); ?> </label>
                    </th>
                    <td class="forminp">
                        <input type="checkbox" name="order_by_stock_status" <?= checked($order_by_stock_status  );?> />
	                    <?php _e('Order product collections by stock status, instock products first.', 'woo2app'); ?>
                    </td>
                </tr>-->
                </tbody>
            </table>
            <input name="submit" id="submit" class="button button-primary"
                   value="<?php _e('Save Changes', 'woo2app'); ?>" type="submit">
        </form>
		<?php
	}
    elseif($tab == 'update'){
		$update = array();
		$update = get_option('woo2app_update');
		if(!is_array($update)){
			$update = array();
			$update['android_ver_code'] = '' ;
			$update['android_update_url'] = '' ;
			$update['android_update_req'] = false ;
			$update['ios_ver_code'] = '' ;
			$update['ios_update_url'] = '' ;
			$update['ios_update_req'] = false ;
			update_option('woo2app_update' , $update);
		}
		?>
        <h2>
			<?php _e('Update setting', 'woo2app'); ?>
        </h2>
        <form method="post">
			<?php wp_nonce_field('woo2app-admin', 'woo2app-admin'); ?>
            <table class="form-table ">
                <tbody>
                <tr>
                    <th colspan="2">
                        <h3> <?php _e('Android', 'woo2app'); ?></h3>
                    </th>
                </tr>
                <tr valign="top" class="" >
                    <th scope="row" class="titledesc">
						<?php _e('Version Code', 'woo2app'); ?>
                    </th>
                    <td class="forminp">
                        <input type="text" class="regular-text" name="android_ver_code" value="<?= $update['android_ver_code']?>">
                    </td>
                </tr>
                <tr valign="top" class="" >
                    <th scope="row" class="titledesc">
                        <label> <?php _e('Update Link ', 'woo2app'); ?></label>
                    </th>
                    <td class="forminp">
                        <input type="text" class="regular-text" name="android_update_url" value="<?= $update['android_update_url']?>">
                    </td>
                </tr>
                <tr valign="top" class="" >
                    <th scope="row" class="titledesc">
                        <label> <?php _e('Required Update', 'woo2app'); ?></label>
                    </th>
                    <td class="forminp">
                        <input type="checkbox" name="android_update_req" <?= checked( $update['android_update_req']  );?> />
                        <p class="description"><?php _e('If enabled, application updates are required for users.', 'woo2app'); ?></p>
                    </td>
                </tr>
                <tr valign="top" class="" >
                    <th scope="row" class="titledesc">
                        <label>  <?php _e('Update Description', 'woo2app'); ?> </label>
                    </th>
                    <td class="forminp">
						<?php
						wp_editor( $update['description_update'],'description_update');
						?>
                    </td>
                </tr>
                <tr>
                    <th colspan="2">
                        <h3> <?php _e('IOS', 'woo2app'); ?></h3>
                    </th>
                </tr>
                <tr valign="top" class="" >
                    <th scope="row" class="titledesc">
                        <label> <?php _e('Version Code', 'woo2app'); ?> </label>
                    </th>
                    <td class="forminp">
                        <input type="text" class="regular-text" name="ios_ver_code" value="<?= $update['ios_ver_code']?>">
                    </td>
                </tr>
                <tr valign="top" class="" >
                    <th scope="row" class="titledesc">
                        <label> <?php _e('Update Link', 'woo2app'); ?> </label>
                    </th>
                    <td class="forminp">
                        <input type="text" class="regular-text" name="ios_update_url" value="<?= $update['ios_update_url']?>">
                    </td>
                </tr>
                <tr valign="top" class="" >
                    <th scope="row" class="titledesc">
                        <label> <?php _e('Required Update', 'woo2app'); ?> </label>
                    </th>
                    <td class="forminp">
                        <input type="checkbox" name="ios_update_req" <?= checked( $update['ios_update_req']  );?> />
                        <span><?php _e('If enabled, application updates are required for users.', 'woo2app'); ?></span>
                    </td>
                </tr>

                <tr valign="top" class="" >
                    <th scope="row" class="titledesc">
                        <label><?php _e('Update Description', 'woo2app'); ?> </label>
                    </th>
                    <td class="forminp">
						<?php
						wp_editor( $update['description_update_ios'],'description_update_ios');
						?>
                    </td>
                </tr>
                </tbody>
            </table>
            <input name="submit_update" class="button button-primary" value="<?php _e('Save Change', 'woo2app'); ?>"
                   type="submit">
        </form>
		<?php
	}
    elseif($tab == 'limit_cart'){
		$limit_cart = array();
		$limit_cart = get_option('woo2app_limit_cart');
		if(!is_array($limit_cart)){
			$limit_cart = array();
			$limit_cart['buy_from_unit_store'] = false ;
			$limit_cart['empty_cart_after_reopen'] = false ;
			update_option('woo2app_limit_cart' , $limit_cart);
		}
		?>
        <h2>
			<?php _e('Cart Setting', 'woo2app'); ?>
        </h2>
        <form method="post">
			<?php wp_nonce_field('woo2app-admin', 'woo2app-admin'); ?>
            <table class="form-table " >
                <tbody>
                <tr valign="top" class="" >
                    <th scope="row" class="titledesc">
                        <label><?php _e('Minimum Cart', 'woo2app'); ?></label>
                    </th>
                    <td class="forminp">
                        <input type="text" class="regular-text" name="minimum_purchase_amount" value="<?php echo get_option("minimum_purchase_amount"); ?>">
                        <p class="description"> <?php _e('by default 0', 'woo2app'); ?> </p>
                    </td>
                </tr>
                <tr valign="top" class="" >
                    <th scope="row" class="titledesc">
                        <label> <?php _e('Buy only from one seller (Dokan)', 'woo2app'); ?> </label>
                    </th>
                    <td class="forminp">
                        <input type="checkbox" name="buy_from_unit_store" <?= checked( $limit_cart['buy_from_unit_store']  );?> />
                    </td>
                </tr>
                <hr>
                <tr valign="top" class="" >
                    <th scope="row" class="titledesc">
						<?php _e('Empty cart at open app', 'woo2app'); ?>
                    </th>
                    <td class="forminp">
                        <input type="checkbox" name="empty_cart_after_reopen" <?= checked( $limit_cart['empty_cart_after_reopen']  );?> />
                    </td>
                </tr>
                </tbody>
            </table>
            <input name="submit_limit_cart" class="button button-primary" value="<?php _e('Save Change', 'woo2app'); ?>"
                   type="submit">
        </form>
		<?php
	}
    elseif ($tab == 'category_setting'){
		require_once "category_setting.php";
	}
    elseif($tab == 'PopUp'){
		require_once "PopUp.php";
	}
	?>
</div>
<?php
wp_enqueue_media();
?>
<script>
    jQuery('#div_image_item_hami').click(function (e) {
        e.preventDefault();
        custom_uploader_hami = wp.media.frames.custom_uploader_hami = wp.media({
            title: '<?php _e('Select Image', 'woo2app'); ?>',
            library: {type: 'image'},
            button: {text: '<?php _e('Select', 'woo2app'); ?>'},
            multiple: false
        });
        custom_uploader_hami.on('select', function() {
            attachment = custom_uploader_hami.state().get('selection').first().toJSON();
            jQuery('#default_product_images').val(attachment.url);
            url_image = attachment.url;
            jQuery('#div_image_item_hami').attr("src",url_image);
        });
        custom_uploader_hami.open();
    })
    jQuery('#Sel_AppLoadingImage').click(function (e) {
        e.preventDefault();
        custom_uploader_hami = wp.media.frames.custom_uploader_hami = wp.media({
            title: '<?php _e('Select Image', 'woo2app'); ?>',
            library: {type: 'image'},
            button: {text: '<?php _e('Select', 'woo2app'); ?>'},
            multiple: false
        });
        custom_uploader_hami.on('select', function() {
            attachment = custom_uploader_hami.state().get('selection').first().toJSON();
            jQuery('#AppLoadingImage').val(attachment.url);
            url_image = attachment.url;
        });
        custom_uploader_hami.open();
    })
</script>
