<?php
/* 
* Theme: PREMIUMPRESS CORE FRAMEWORK FILE
* Url: www.premiumpress.com
* Author: Mark Fail
*
* THIS FILE WILL BE UPDATED WITH EVERY UPDATE
* IF YOU WANT TO MODIFY THIS FILE, CREATE A CHILD THEME
*
* http://codex.wordpress.org/Child_Themes
*/
if (!defined('THEME_VERSION')) {	header('HTTP/1.0 403 Forbidden'); exit; }

global $CORE, $settings;
  
  $settings = array(
  
  "title" => __("Gift Images","premiumpress"), 
  "desc" => __("Here you can change the gift icons and set custom prices for each gift.","premiumpress"), 
  "back" => "overview"
  
  );
  
   _ppt_template('framework/admin/_form-wrap-top' );
   
    ?>
<div class="card card-admin">
  <div class="card-body">
   
    <div class="container px-0 border-bottom mb-3">
      <div class="row py-2">
        <div class="col-md-7">
          <label><?php echo __("Send Gifts","premiumpress"); ?></label>
          <p class="text-muted"><?php echo __("Turn on/off the option for users to send gifts.","premiumpress"); ?></p>
        </div>
        <div class="col-md-5">
          <div class="mt-3">
            <label class="radio off">
            <input type="radio" name="toggle" 
               value="off" onchange="document.getElementById('display_gifts').value='0'">
            </label>
            <label class="radio on">
            <input type="radio" name="toggle"
               value="on" onchange="document.getElementById('display_gifts').value='1'">
            </label>
            <div class="toggle <?php if( in_array(_ppt(array('gifts', 'enable')), array("", "1")) ){  ?>on<?php } ?>">
              <div class="yes">ON</div>
              <div class="switch"></div>
              <div class="no">OFF</div>
            </div>
          </div>
          <input type="hidden" id="display_gifts" name="admin_values[gifts][enable]" value="<?php if(_ppt(array('gifts', 'enable')) == ""){ echo 1; }else{ echo _ppt(array('gifts', 'enable')); } ?>">
        </div>
      </div>
    </div>
    <!-- ------------------------- -->
    <div class="container px-0 border-bottom mb-3">
 
        <div class="container">
          <div class="row">
<?php

$lst_backgrounds = array(1,2,3,4,5,6,7,8,9); 

$k=1; while($k < 13){

  $defaultimg = "";
  $customi = 0;
  if(_ppt(array('giftimg', $k)) != "" && strlen(_ppt(array('giftimg', $k))) > 2 ){ 
    $defaultimg = _ppt(array('giftimg', $k));
    $customi=1;
  }elseif(isset($lst_backgrounds[$k])){
    if(defined('THEME_KEY') && in_array(THEME_KEY, array("es")) ){
    $defaultimg = get_template_directory_uri()."/_escort/icons/".$k.".png";
    }else{
    $defaultimg = get_template_directory_uri()."/_dating/icons/".$k.".png";
    }
  }
 
?>

<div class="col-md-4">

<div class="card p-3 mb-4">
<figure>
<div class="position-relative" id="imgb<?php echo $k; ?>"> <?php if($defaultimg != ""){ ?><img data-src="<?php echo $defaultimg; ?>" alt="img" class="img-fluid lazy"><?php } ?></div>
</figure>     

<div class="input-group position-relative">


<?php if($customi){ ?>
  <button type="button" onclick="jQuery('#download_path<?php echo $k; ?>9').val('');jQuery('#priceb<?php echo $k; ?>').val('');jQuery('#imgb<?php echo $k; ?>').html('');"  class="position-absolute" style="right:10px; top:10px; z-index: 12; background:red;color:white; font-size: 11px;"><?php echo __("Delete","premiumpress"); ?></button>

  <?php }else{ ?>
<button type="button"  id="path<?php echo $k; ?>9" class="position-absolute download_path_select" style="right:10px; top:10px; z-index: 12; background:#fff; font-size: 11px;"><?php echo __("Image","premiumpress"); ?></button>
<?php } ?>
 <input class="form-control" id="download_path<?php echo $k; ?>9" name="admin_values[giftimg][<?php echo $k; ?>]" value="<?php if(_ppt(array('giftimg', $k)) == ""){ }else{ echo _ppt(array('giftimg', $k )); } ?>" />

</div>

 

<div class="form-group mt-4">
	<label><?php echo __("Gift Price","premiumpress"); ?></label>
    <div class="input-group">   
	<input class="form-control numericonly" placeholder="0" id="priceb<?php echo $k; ?>" name="admin_values[giftprice][<?php echo $k; ?>]" value="<?php echo _ppt(array('giftprice', $k)); ?>" style="padding-left:30px !important;"/>
    
    <div class="position-absolute" style="bottom: 8px;    left: 10px; z-index:100;"><?php if(strpos( _ppt(array('currency','symbol')), "fa") === false){ echo hook_currency_symbol('');  }else{ echo '<i class="'._ppt(array('currency','symbol')).'"></i>'; } ?></div>
    
   
    </div>
</div>

 
</div>

</div>      
            
            <?php $k++; } ?>
          </div>
        </div>
  </div>
    
    <div class="p-4 bg-light text-center mt-4">
      <button type="submit" data-ppt-btn class="btn-primary"><?php echo __("Save Settings","premiumpress"); ?></button>
    </div>
    
  </div>
</div>
<input type="hidden" value=""  id="current_bg_id" />
<script>

jQuery(document).ready(function() {

var my_original_editor = window.send_to_editor;


 	jQuery('.download_path_select').click(function() {     
	
	var thisid = jQuery(this).attr('id');   
	
	jQuery("#current_bg_id").val(thisid);  
           
		   tb_show('', 'media-upload.php?type=image&amp;TB_iframe=true');
		   
			window.send_to_editor = function(html) {	
			 
			 		
				var regex = /src="(.+?)"/;
				var rslt =html.match(regex);
				 
				var imgrex = /wp-image-(.+?)"/;
				var imgid = html.match(imgrex);
			 
				var imgurl = rslt[1];
				var imgaid = imgid[1];
				console.log("#download_"+jQuery("#current_bg_id").val());
				jQuery("#download_"+jQuery("#current_bg_id").val()).val(imgurl); 
				
				tb_remove();
				
				window.send_to_editor = my_original_editor;
			 
			 
			}		   
		   
		   
           return false;
    });
               		
 

}); 
</script>
 
 
<?php _ppt_template('framework/admin/_form-wrap-bottom' ); 


$settings = array(
  
  "title" => __("Escort Commission","premiumpress"), 
  "desc" => __("Here you can give a percentage of the money earned from a gift sale to the escort.","premiumpress"), 
  "back" => "overview"
  
  );
  
   _ppt_template('framework/admin/_form-wrap-top' );
   
   
   
   ?>

<div class="card card-admin">
  <div class="card-body">
   
    <div class="container px-0 border-bottom mb-3">
      <div class="row py-2">
        <div class="col-md-7">
          <label><?php echo __("Enable Gift Commission","premiumpress"); ?></label>
          <p class="text-muted"><?php echo __("Turn on/off this option.","premiumpress"); ?></p>
        </div>
        <div class="col-md-5">
          <div class="mt-3">
            <label class="radio off">
            <input type="radio" name="toggle" 
               value="off" onchange="document.getElementById('display_comission').value='0'">
            </label>
            <label class="radio on">
            <input type="radio" name="toggle"
               value="on" onchange="document.getElementById('display_comission').value='1'">
            </label>
            <div class="toggle <?php if( in_array(_ppt(array('gifts', 'comission')), array("1")) ){  ?>on<?php } ?>">
              <div class="yes">ON</div>
              <div class="switch"></div>
              <div class="no">OFF</div>
            </div>
          </div>
          <input type="hidden" id="display_comission" name="admin_values[gifts][comission]" value="<?php if(_ppt(array('gifts', 'comission')) == ""){ echo 0; }else{ echo _ppt(array('gifts', 'comission')); } ?>">
        </div>
      </div>
    </div>
    <!-- ------------------------- -->
    <div class="container px-0 border-bottom mb-3">



    <div class="row py-2">
      
      
      <div class="col-md-7">
        <label><?php echo __("Buyer Commission","premiumpress"); ?></label>
        <p class="text-muted"><?php echo __("Set a percentage or a fixed amount.","premiumpress"); ?></p>
      </div>
      <div class="col-md-5"> 
      
        <div class="input-group"> <span class="input-group-prepend input-group-text">%</span>
          <input type="text" class="form-control btn-block"  name="admin_values[gifts][comission_buyer]" value="<?php if(is_numeric(_ppt(array('gifts', 'comission_buyer')))){ echo _ppt(array('gifts', 'comission_buyer')); }else{ echo 0; } ?>" style="max-width:100px">
        </div>
        
                  <div class="input-group mt-3"> <span class="input-group-prepend input-group-text"><?php if(strpos( _ppt(array('currency','symbol')), "fa") === false){ echo hook_currency_symbol('');  }else{ echo '<i class="'._ppt(array('currency','symbol')).'"></i>'; } ?></span>
          <input type="text" class="form-control btn-block"  name="admin_values[gifts][comission_buyer_fixed]" value="<?php if(is_numeric(_ppt(array('gifts', 'comission_buyer_fixed')))){ echo _ppt(array('gifts', 'comission_buyer_fixed')); }else{ echo 0; } ?>" style="max-width:100px">
        </div> 
        
      </div>
    
</div>




    </div>
    
    <div class="p-4 bg-light text-center mt-4">
      <button type="submit" data-ppt-btn class="btn-primary"><?php echo __("Save Settings","premiumpress"); ?></button>
    </div>
    
  </div>
</div>



<?php _ppt_template('framework/admin/_form-wrap-bottom' );  ?>