<?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; }

// SAVE CUSTOM FIELD DATE
if(isset($_POST['dtamenitites']) && current_user_can('administrator') ){
update_option("dtamenitites", $_POST['dtamenitites']);
}
// LOAD IN MAIN DEFAULTS 
$core_admin_values = get_option("core_admin_values");  
  
?>

<div class="row">

<div class="col-lg-6">

<div class="bg-white p-5  shadow" style="border-radius: 7px;">


<div class="tabheader mb-4">
 
         <h4><span>Directory Settings</span></h4>
      </div>
 
 
<div class="container px-0">
   <div class="row">
      <div class="col-9">
         <label class="txt500">Business Hours</label>
         <p class="text-muted">Here you can turn on/off the business hours setup within the theme.</p>
      </div>
      <div class="col-3">
         <div class="mt-4">
            <label class="radio off">
            <input type="radio" name="toggle" 
               value="off" onchange="document.getElementById('businesshours').value='0'">
            </label>
            <label class="radio on">
            <input type="radio" name="toggle"
               value="on" onchange="document.getElementById('businesshours').value='1'">
            </label>
            <div class="toggle <?php if(_ppt('businesshours') == '1'){  ?>on<?php } ?>">
               <div class="yes">ON</div>
               <div class="switch"></div>
               <div class="no">OFF</div>
            </div>
         </div>
         <input type="hidden" class="row-fluid" id="businesshours" name="admin_values[businesshours]" 
            value="<?php echo _ppt('businesshours'); ?>">
      </div>
   </div>
</div>

<div class="container px-0">
   <div class="row">
      <div class="col-9">
         <label class="txt500">Claim Listing</label>
         <p class="text-muted">Turn on/off the option for members to claim listings as their own.</p>
      </div>
      <div class="col-3">
         <div class="mt-4">
            <label class="radio off">
            <input type="radio" name="toggle" 
               value="off" onchange="document.getElementById('claimlisting').value='0'">
            </label>
            <label class="radio on">
            <input type="radio" name="toggle"
               value="on" onchange="document.getElementById('claimlisting').value='1'">
            </label>
            <div class="toggle <?php if(_ppt('claimlisting') == '1'){  ?>on<?php } ?>">
               <div class="yes">ON</div>
               <div class="switch"></div>
               <div class="no">OFF</div>
            </div>
         </div>
         <input type="hidden" class="row-fluid" id="claimlisting" name="admin_values[claimlisting]" 
            value="<?php echo _ppt('claimlisting'); ?>">
      </div>
   </div>
</div>


<div class="container px-0">
   <div class="row">
      <div class="col-9">
         <label class="txt500">Amenities</label>
         <p class="text-muted">Turn on/off the amenities section of your directory website.</p>
      </div>
      <div class="col-3">
         <div class="mt-4">
            <label class="radio off">
            <input type="radio" name="toggle" 
               value="off" onchange="document.getElementById('amenities').value='0'">
            </label>
            <label class="radio on">
            <input type="radio" name="toggle"
               value="on" onchange="document.getElementById('amenities').value='1'">
            </label>
            <div class="toggle <?php if(_ppt('amenities') == '1'){  ?>on<?php } ?>">
               <div class="yes">ON</div>
               <div class="switch"></div>
               <div class="no">OFF</div>
            </div>
         </div>
         <input type="hidden" class="row-fluid" id="amenities" name="admin_values[amenities]" 
            value="<?php echo _ppt('amenities'); ?>">
      </div>
   </div>
</div>

<hr />

<?php  
$dtamenitites = get_option("dtamenitites"); 
 
?> 

 

<script>
jQuery(document).ready(function() {	
    jQuery( "#customfieldlist" ).sortable(); 

});
</script>

</div></div> 
<div class="col-lg-6">

<div class="bg-white p-5  shadow" style="border-radius: 7px;">

 
 

<div class="tabheader mb-4">
 <a href="javascript:void(0);" onClick="jQuery('#customfieldlist_new').clone().prependTo('#customfieldlist');" class="btn-sm btn-primary btn float-right">Add New Field</a>	
 
         <h4><span>Amenities</span></h4>
      </div>
 
 

<ul id="customfieldlist">
<?php if(is_array($dtamenitites)){ $i=0; $setKeys = array(); $selectedcatlist = array();

foreach($dtamenitites['name'] as $data){ 

	if($dtamenitites['name'][$i] != "" ){  ?>
    
    
<li class="cfielditem closed " id="rowid-<?php echo $i; ?>">
	
    <div class="heading">
      
     	<div class="showhide">
        
         <?php if($dtamenitites['search'][$i] == "yes"){  ?><span class="badge badge-warning">searchable</span><?php } ?>
        
            <a href="javascript:void(0);" onclick="jQuery('.cf-<?php echo $i; ?>').fadeToggle();" rel="tooltip" data-original-title="Show/Hide Options" data-placement="top" class="btn btn-primary btn-sm">
            <i class="fa fa-search" aria-hidden="true"></i>
            </a>   
            
                                           
        </div>            

        <div class="name">
        
        <a href="javascript:void(0);" onClick="jQuery('#rowid-<?php echo $i; ?>').html('').hide();" rel="tooltip" data-original-title="Delete" data-placement="top" class="btn btn-primary btn-sm">
        <i class="fas fa-times" aria-hidden="true"></i>
        </a> 
        
       &nbsp; <strong><?php echo $dtamenitites['name'][$i]; ?></strong>  
        
        </div>
    
    </div>
    
    <div class="inside cf-<?php echo $i; ?>">  
         
        <label>Title <span class="required">*</span></label>      
        
        <input type="text" name="dtamenitites[name][]" id="title-<?php echo $i; ?>" value="<?php echo $dtamenitites['name'][$i]; ?>" class="form-control"  />       
        
        <div class="row mt-3">
        <div class="col-6">
        <label class="mt-1">Searchable <span class="required">*</span></label>  
  		<select class="form-control" name="dtamenitites[search][]">
        
        <option value="no">No</option>
        <option value="yes" <?php if($dtamenitites['search'][$i] == "yes"){ echo "selected=selected"; } ?>>Yes</option>
        </select>
        </div>
        <div class="col-6">        
      	<label class="mt-1">Key <small>(no spaces, max 7 chars)</small> <span class="required">*</span></label>    		
       <input type="text" name="dtamenitites[key][]" id="title-<?php echo $i; ?>" value="<?php if($dtamenitites['key'][$i] == ""){ echo "ami9".$i; }else{ echo $dtamenitites['key'][$i]; } ?>" class="form-control" maxlength="7"  />       
       </div>
       </div>
        
        
	</div>
    
</li>
 <?php $i++; } ?>    
    
<?php } ?>    

<?php } ?>  
</ul>


</div> </div> </div> 
 
<script>
function checknotblank(){
if(jQuery('#nfaqt').val() == ""){  jQuery('#nfaqt').val(' '); }
}
</script>
<div class="bg-primary p-1 text-center mt-5 shadow" style="border-radius: 7px;">

<button type="submit" class="btn btn-lg btn-primary btn-block"><?php echo __("Save Settings","premiumpress-admin"); ?></button> 

</div> 