<?php
global $wpdb;
if($_POST)
{
	$option_value['currency'] = $_POST['currency'];
	$option_value['currencysym'] = $_POST['currencysym']; 
	$option_value['site_email'] = $_POST['site_email'];
	$option_value['site_email_name'] = $_POST['site_email_name']; 
	$option_value['is_user_addevent'] = $_POST['is_user_addevent'];	
	$option_value['list_type_title1'] = $_POST['list_type_title1'];
	$option_value['list_type_price1'] = $_POST['list_type_price1'];
	$option_value['list_type_days1'] = $_POST['list_type_days1'];
	$option_value['list_type_days_type1'] = $_POST['list_type_days_type1'];
	$option_value['list_type_feature1'] = $_POST['list_type_feature1'];
	$option_value['list_type_title2'] = $_POST['list_type_title2'];
	$option_value['list_type_price2'] = $_POST['list_type_price2'];
	$option_value['list_type_days2'] = $_POST['list_type_days2'];
	$option_value['list_type_days_type2'] = $_POST['list_type_days_type2'];
	$option_value['list_type_feature2'] = $_POST['list_type_feature2'];	
	$option_value['approve_status'] = $_POST['approve_status'];	
	$option_value['is_allow_user_add'] = $_POST['is_allow_user_add'];
	$option_value['is_allow_ssl'] = $_POST['is_allow_ssl'];
	$message = "Updated Succesfully.";
	foreach($option_value as $key=>$val)
	{
		if($key){
		update_option($key,$val);	
		}
	}
}
if(get_option('currency')=='')
{
	$paymethodinfo = array(
						"currency"		=> 'USD',
						"currencysym"	=> '$',
						"site_email"	=> get_option('admin_email'),
						"site_email_name"=>	get_option('blogname'),
						"is_user_addevent"		=>	"1",
						"list_type_title1"	=>	"Free",
						"list_type_price1"	=>	"0.00",
						"list_type_days1"	=>	"30",
						"list_type_feature1"	=>	"0",						
						"list_type_days_type1"	=>	"days",
						"list_type_title2"	=>	"Featured",
						"list_type_price2"	=>	"30.00",
						"list_type_days2"	=>	"90",
						"list_type_days_type2"	=>	"days",
						"list_type_feature2"	=>	"1",
						"approve_status"	=>	"publish",
						"is_allow_ssl"		=>	"0",
						);
	foreach($paymethodinfo as $key=>$val)
	{
		if($key){
		update_option($key,$val);	
		}
	}
}

//$cartsql = "select * from $wpdb->options where option_name like 'mysite_general_settings'";
//$cartinfo = $wpdb->get_results($cartsql);
if(1)
{	
	$currency = stripslashes(get_option('currency'));
	$currencysym = stripslashes(get_option('currencysym'));
	$site_email = stripslashes(get_option('site_email'));
	$site_email_name = stripslashes(get_option('site_email_name'));
	$area_unit = stripslashes(get_option('area_unit'));
	$is_user_addevent = stripslashes(get_option('is_user_addevent'));
	
	$list_type_title1 = stripslashes(get_option('list_type_title1'));
	$list_type_price1 = stripslashes(get_option('list_type_price1'));
	$list_type_days1 = stripslashes(get_option('list_type_days1'));
	$list_type_days_type1 = stripslashes(get_option('list_type_days_type1'));
	$list_type_feature1 = stripslashes(get_option('list_type_feature1'));
	$list_type_title2 = stripslashes(get_option('list_type_title2'));
	$list_type_price2 = stripslashes(get_option('list_type_price2'));
	$list_type_days2 = stripslashes(get_option('list_type_days2'));
	$list_type_days_type2 = stripslashes(get_option('list_type_days_type2'));
	$list_type_feature2 = stripslashes(get_option('list_type_feature2'));
	$approve_status = stripslashes(get_option('approve_status'));
	$related_property = stripslashes(get_option('related_property'));
	$area_srch_setting = stripslashes(get_option('area_srch_setting'));
	$price_srch_setting = stripslashes(get_option('price_srch_setting'));
	$is_allow_user_add = stripslashes(get_option('is_allow_user_add'));
	$max_bathrooms = stripslashes(get_option('max_bathrooms'));
	$max_bedrooms = stripslashes(get_option('max_bedrooms'));
	$location_srch_setting = stripslashes(get_option('location_srch_setting'));
	$is_allow_ssl = stripslashes(get_option('is_allow_ssl'));
}
?>

<form action="<?php echo get_option( 'siteurl' );?>/wp-admin/admin.php?page=product_menu.php" method="post">
  <style>
h2 { color:#464646;font-family:Georgia,"Times New Roman","Bitstream Charter",Times,serif;
font-size:24px;
font-size-adjust:none;
font-stretch:normal;
font-style:italic;
font-variant:normal;
font-weight:normal;
line-height:35px;
margin:0;
padding:14px 15px 3px 0;
text-shadow:0 1px 0 #FFFFFF;  }
</style>
  <h2><?php _e('General Settings');?></h2>
  <?php if($message){?>
  <div class="updated fade below-h2" id="message" style="background-color: rgb(255, 251, 204);" >
    <p><?php _e($message);?> </p>
  </div>
  <?php }?>
  <table  cellpadding="5" class="widefat post  general_settings" >
    <thead>
      <tr>
        <td width="45%"><?php _e('Sender (Name that will be shown as email sender when users receive emails from this site)');?></td>
        <td width="50"><input type="text" name="site_email_name" value="<?php echo $site_email_name;?>" /></td>
      </tr>
      <tr>
        <td><?php _e('Email Address (emails to users will be sent via this mail ID)');?></td>
        <td><input type="text" name="site_email" value="<?php echo $site_email;?>" /></td>
      </tr>
      <tr>
        <td><?php _e('Default Currency (Ex.: USD)');?></td>
        <td><input type="text" name="currency" value="<?php echo $currency;?>" /></td>
      </tr>
      <tr>
        <td><?php _e('Default Currency Symbol (Ex.: $)');?></td>
        <td><input type="text" name="currencysym" value="<?php echo $currencysym;?>" /></td>
      </tr>
	   <tr>
        <td><?php _e('Use SSL when clicking on Submit');?></td>
        <td><input type="radio" name="is_allow_ssl" <?php if($is_allow_ssl=='1'){ echo 'checked="checked"';}?>  value="1" /> <?php _e('Yes');?>  <input type="radio" name="is_allow_ssl" <?php if($is_allow_ssl=='0'){ echo 'checked="checked"';}?> value="0" /> <?php _e('No');?></td>
      </tr>
      <tr>
        <td></td>
        <td><h2><input type="submit" name="submit" value="<?php _e('Submit');?>" class="button-secondary action" /></h2></td>
      </tr>
    </thead>
  </table>
</form>