<?php
if (!empty($_POST['cp_save'])) {

	// store options (not null or empty)
	foreach($_POST as $key => $value) {
		if ($key != 'cp_save') {
			$key_clean = str_replace('cp_', '', $key);
			$this->options["$key_clean"] = $_POST["$key"];
		}
	}
	
	// save logo/favicon
	$this->options["upload_image"] = $_POST["upload_image"];
	$this->options["upload_fav"] = $_POST["upload_fav"];

	// empty null fields must be passed manually

	update_option('live', $this->options);
	echo '<div class="updated fade" id="message"><p><strong>Settings saved.</strong></p></div>';

}
?>

<div class="wrap">
<div id="icon-themes" class="icon32"><br /></div><h2 class="nav-tab-wrapper tabs-wrap">
<a href="#" class="nav-tab" rel="first-tab">Main Options</a>
<a href="#" class="nav-tab" rel="second-tab">Manage Offer</a>
<a href="#" class="nav-tab" rel="third-tab">Home Page Buttons</a>
<a href="#" class="nav-tab" rel="fourth-tab">Banner Options</a>
<a href="#" class="nav-tab" rel="fifth-tab">Footer Options</a>
</h2>
<form action="" method="post">

<table class="form-table tab-content" id="first-tab">
<tr valign="top">
<th scope="row">Setup Logo</th>
<td><label for="upload_image">
<input id="upload_image" type="text" size="36" name="upload_image" value="<?php echo $this->options["upload_image"]; ?>" />
<input id="upload_image_button" type="button" value="Upload" />
<br />Enter an URL or click the button to upload your logo.
</label></td>
</tr>
<tr valign="top">
<th scope="row">Setup Favicon</th>
<td><label for="upload_fav">
<input id="upload_fav" type="text" size="36" name="upload_fav" value="<?php echo $this->options["upload_fav"]; ?>" />
<input id="upload_fav_button" type="button" value="Upload" />
<br />Enter an URL or click the button to upload your favicon.
</label></td>
</tr>
<tr valign="top">
<th scope="row"><label for="cp_livechat">Live Chat URL</label></th>
<td>
<input type="text" name="cp_livechat" id="cp_livechat" value="<?php echo $this->options["livechat"]; ?>" class="regular-text code" />
<span class="description">You may leave blank to disable this in header.</span>
</td>
</tr>
<tr valign="top">
<th scope="row"><label for="cp_login">Login Button URL</label></th>
<td>
<input type="text" name="cp_login" id="cp_login" value="<?php echo $this->options["login"]; ?>" class="regular-text code" />
<span class="description">You may leave blank to disable this in header.</span>
</td>
</tr>
<tr valign="top">
<th scope="row"><label for="cp_phone">Company Phone Number</label></th>
<td>
<input type="text" name="cp_phone" id="cp_phone" value="<?php echo $this->options["phone"]; ?>" class="regular-text" />
<span class="description">You may leave blank to disable this in header.</span>
</td>
</tr>
<tr valign="top">
<th scope="row"><label for="cp_email">Company E-mail Address</label></th>
<td>
<input type="text" name="cp_email" id="cp_email" value="<?php echo $this->options["email"]; ?>" class="regular-text" />
<span class="description">You may leave blank to disable this in header.</span>
</td>
</tr>
<tr valign="top">
<th scope="row"><label for="cp_contact_email">Contact Form Destination E-mail Address</label></th>
<td>
<input type="text" name="cp_contact_email" id="cp_contact_email" value="<?php echo $this->options["contact_email"]; ?>" class="regular-text" />
</td>
</tr>
<tr valign="top">
<th scope="row"><label for="cp_footer_code">Footer Code</label></th>
<td>
<textarea name="cp_footer_code" id="cp_footer_code" value="<?php echo $this->options["footer_code"]; ?>" cols="80" rows="8" class="regular-text code"></textarea><br />
<span class="description">Use this for analytics or similar code.</span>
</td>
</tr>
</table>

<table class="form-table tab-content" id="second-tab">
<tr valign="top">
<th scope="row"><label for="cp_offer">Offer / Siccor Content</label></th>
<td>
<textarea type="text" name="cp_offer" id="cp_offer" cols="100" rows="6" class="regular-text code"><?php echo stripslashes($this->options["offer"]); ?></textarea><br />
You are allowed to use regular text and HTML markup.
</td>
</tr>
</table>

<table class="form-table tab-content" id="third-tab">
<?php for ($i = 1; $i <= 3; $i++) { ?>
<tr valign="top">
<th scope="row"><label for="cp_buttont<?php echo $i; ?>">Button <?php echo $i; ?> Title</label></th>
<td>
<input type="text" name="cp_buttont<?php echo $i; ?>" id="cp_buttont<?php echo $i; ?>" value="<?php echo $this->options["buttont".$i]; ?>" class="regular-text" />
</td>
</tr>
<tr valign="top">
<th scope="row"><label for="cp_buttonu<?php echo $i; ?>">Button <?php echo $i; ?> URL</label></th>
<td>
<input type="text" name="cp_buttonu<?php echo $i; ?>" id="cp_buttonu<?php echo $i; ?>" value="<?php echo $this->options["buttonu".$i]; ?>" class="regular-text code" />
</td>
</tr>
<?php } ?>
</table>

<table class="form-table tab-content" id="fourth-tab">
<tr valign="top">
<th scope="row"><label for="cp_bheading">Banner Heading</label></th>
<td>
<input type="text" name="cp_bheading" id="cp_bheading" value="<?php echo stripslashes($this->options["bheading"]); ?>" class="large-text code" />
<span class="description">Enter the heading of your featured plan / banner in HTML format.</span>
</td>
</tr>
<tr valign="top">
<th scope="row"><label for="cp_bprice">Starting Price</label></th>
<td>
<input type="text" name="cp_bprice" id="cp_bprice" value="<?php echo $this->options["bprice"]; ?>" class="small-text" />
<span class="description">e.g. $3.98/mo</span>
</td>
</tr>
<tr valign="top">
<th scope="row"><label for="cp_bfeatures">Banner Features</label></th>
<td>
Enter the features that you want to display for this banner. Enter one feature per line.<br />
<textarea type="text" name="cp_bfeatures" id="cp_bfeatures" cols="100" rows="6" class="regular-text"><?php echo stripslashes($this->options["bfeatures"]); ?></textarea>
</td>
</tr>
<tr valign="top">
<th scope="row"><label for="cp_btext">Banner Button Text</label></th>
<td>
<input type="text" name="cp_btext" id="cp_btext" value="<?php echo $this->options["btext"]; ?>" class="regular-text" />
<span class="description">e.g. Get Started Now</span>
</td>
</tr>
<tr valign="top">
<th scope="row"><label for="cp_burl">Banner Button URL</label></th>
<td>
<input type="text" name="cp_burl" id="cp_burl" value="<?php echo $this->options["burl"]; ?>" class="regular-text code" />
<span class="description">e.g. URL of your plans or order form.</span>
</td>
</tr>
</table>

<table class="form-table tab-content" id="fifth-tab">
<tr valign="top">
<th scope="row"><label for="cp_reviewhome">Footer Testimonial</label></th>
<td>
<textarea type="text" name="cp_reviewhome" id="cp_reviewhome" cols="100" rows="6" class="regular-text code"><?php echo stripslashes($this->options["reviewhome"]); ?></textarea>
</td>
</tr>
<tr valign="top">
<th scope="row"><label for="cp_reviewlink">"See More Testimonials" URL</label></th>
<td>
<input type="text" name="cp_reviewlink" id="cp_reviewlink" value="<?php echo $this->options["reviewlink"]; ?>" class="regular-text code" />
</td>
</tr>
<tr valign="top">
<th scope="row"><label for="cp_facebook">Facebook Fan Page URL</label></th>
<td>
<input type="text" name="cp_facebook" id="cp_facebook" value="<?php echo $this->options["facebook"]; ?>" class="regular-text code" />
</td>
</tr>
<tr valign="top">
<th scope="row"><label for="cp_twitter">Twitter Page URL</label></th>
<td>
<input type="text" name="cp_twitter" id="cp_twitter" value="<?php echo $this->options["twitter"]; ?>" class="regular-text code" />
</td>
</tr>
<tr valign="top">
<th scope="row"><label for="cp_feedburner">FeedBurner URL</label></th>
<td>
<input type="text" name="cp_feedburner" id="cp_feedburner" value="<?php echo $this->options["feedburner"]; ?>" class="regular-text code" />
</td>
</tr>
<tr valign="top">
<th scope="row"><label for="cp_copyright">Website Copyright</label></th>
<td>
<textarea type="text" name="cp_copyright" id="cp_copyright" cols="100" rows="6" class="regular-text code"><?php echo stripslashes($this->options["copyright"]); ?></textarea>
</td>
</tr>
</table>

<p class="submit"><input type="submit" name="cp_save" class="button-primary" value="Save Changes" /></p>
</form>
</div>
