<?php
include('views/_header.tpl.php');
if (isset($_GET['msg'])) {
	$msg = htmlentities(strip_tags($_GET['msg']));
}
?>

<style>
    .tinybutton { padding:3px 7px; background:#fff; width:65px;  min-width:65px;
        border-radius: 50px; -moz-border-radius: 50px; -webkit-border-radius: 50px; font-size:12px; }	
	.form .row-item .lbl {
	    float: left;
	    padding-top: 11px;
	    width: 90px;
	    text-align: right;
	}
	
	.cke_contents {
		max-height: 250px !important;
		height: 250px !important;
	}
	
	/* ###################################################### */
	/* ####### The Switch - the box around the slider ####### */
	/* ###################################################### */

	.switch {
	  position: relative;
	  display: inline-block;
	  width: 60px !important;
	  height: 32px;
	}

	/* Hide default HTML checkbox */
	.switch input {display:none;}

	/* The slider */
	.sliderr {
	  position: absolute;
	  cursor: pointer;
	  top: 0;
	  left: 0;
	  right: 0;
	  bottom: 0;
	  background-color: #ccc;
	  -webkit-transition: .4s;
	  transition: .4s;
	}

	.sliderr:before {
	  position: absolute;
	  content: "";
	  height: 28px;
	  width: 28px;
	  left: 2px;
	  bottom: 2px;
	  background-color: white;
	  -webkit-transition: .4s;
	  transition: .4s;
	}

	input:checked + .sliderr {
	  background-color: #98cb54;
	}

	input:focus + .sliderr {
	  box-shadow: 0 0 1px #98cb54;
	}

	input:checked + .sliderr:before {
	  -webkit-transform: translateX(28px);
	  -ms-transform: translateX(28px);
	  transform: translateX(28px);
	}

	/* Rounded sliders */
	.sliderr.round {
	  border-radius: 32px; -moz-border-radius: 32px; -webkit-border-radius: 32px;
	}

	.sliderr.round:before {
	  border-radius: 50%;
	  -moz-border-radius: 50%;
	  -webkit-border-radius: 50%;
	  
	}
	/* ##################################################### */
	/* ##############     The Switch ENDS     ############## */
	/* ##################################################### */   	
</style>

<div class="home-feature-category" style="background:none; border:none; min-height:100vh; padding-top:0px">
     <?php if(isset($_GET['msg'])) : ?>
     <div style="background:#cd1000; color:#fff; font-weight:300; height:25px; line-height:25px; margin-top:0px; text-align:center; padding:5px 0;">
         Saved Successfully! <a href="/admin/?notification&edit=<?= $notification['id'] ?>" class="tinybutton">Ok!</a>
     </div>
     <?php endif; ?>
     
	<div class="container_12 clearfix">
		<div class="grid_8 marked-category">

			<h1 style="margin-bottom:0px;"><a href="/admin/notifications">&laquo; Back</a> | <?php

			if ($notification) {
				echo "Edit";
			} else {
				echo "Add";
				$def = "/static/uploads/logos/placeholder.jpg";
			}

			?> Notification</h1>

			<form method="post" class="form form-profile" enctype="multipart/form-data" style="padding:25px 0px 0px;">
				<div class="row-item clearfix" style="padding-bottom:10px;">
				
					<label class="lbl" for="txt_name1" style="text-align:left; margin-right:5px;">ID:</label>
					<div class="val" style="margin-left:0px;">
						<input class="txt" type="text" name="id" value="<?= $notification['id'] ?>"
						 style="background:#eee; font-weight:300" readonly>
						<p class="rs description-input"></p>
					</div>	
					<br />	
					
					<label class="lbl" for="txt_name1" style="text-align:left; margin-right:5px;">Tracking:</label>
					<div class="val" style="margin-left:0px;">
						<input class="txt" type="text" name="trackid" value="<?= $notification['trackid'] ?>"
						style="font-weight:300" placeholder="uniquetrackingid">
						<p class="rs description-input" style="margin-left:94px; color:#999"><span style="color:#000; font-weight:600">Optional:</span> Unique tracking ID (lowercase, no spaces)</p>
					</div>
					<br />								

					<label class="lbl" for="txt_name1" style="text-align:left; margin-right:5px;">Title:</label>
					<div class="val" style="margin-left:0px;">
						<input class="txt" type="text" name="title" value="<?= $notification['title'] ?>" 
						style="font-weight:300">
						<p class="rs description-input"></p>
					</div>
					<br />	

					Message:<br /> 
					<div class="val" style="margin-left:0px;">
						<textarea name="message" id="ckeditor" class="ckeditor" 
							style="min-width:300px;"><?= $notification['message'] ?></textarea>
						<p class="rs description-input"></p>
					</div>
					<br />	
					
					<h3>
						Who would you like to send to?
					</h3>					

					<label class="lbl" for="txt_name1" style="text-align:left; width:auto; min-width:60px; 
					margin-right:5px; margin-top:10px;">Group:</label>
					
	                <div class="val" style="margin-left:0px; margin-top:10px;">
						<select name="group" id="" class="txt" style="background:#fff; padding:10px; font-size:15px; font-weight:300" <!--name="projectid"-->>
				           <option value="">Select Group to send to</option>
				           <option value="All" <?php if($notification['group'] == 'All') echo "selected"; ?>>All Customers/Members</option>
				           <option value="Recent" <?php if($notification['group'] == 'Recent') echo "selected"; ?>>Recently Ordered (last 7 days)</option>
				           <option value="NotRecent" <?php if($notification['group'] == 'NotRecent') echo "selected"; ?>>Hasn't Ordered (in last 7 days)</option>     
				           <option value="Subscribers" <?php if($notification['group'] == 'Subscribers') echo "selected"; ?>>All Subscribers</option>
				           <option value="Test" <?php if($notification['group'] == 'Test') echo "selected"; ?>>Test Group</option>          
				       </select> 
					   <p class="rs description-input" style="margin-left:70px;">All is default</p> 
	                </div>  					
					 
					<!-- ########################################################## -->
					
<!--					<label class="lbl" for="txt_name1" style="text-align:left; width:auto; min-width:60px; 
					margin-right:5px; margin-top:10px;">Type:</label>
					
	                <div class="val" style="margin-left:0px; margin-top:10px;">
						<select name="type" id="" class="txt" style="background:#fff; padding:10px; font-size:15px; font-weight:300">
				           <option value="">Select Type of Communication</option>
				           <option value="Message" <?php if($notification['type'] == 'Message') echo "selected"; ?>>Message (to Inboxes)</option>
				           <option value="Notification" <?php if($notification['type'] == 'Notification') 
				           echo "selected"; ?>>Notification (to Notifications)</option>
				           <option value="Alert" <?php if($notification['type'] == 'Alert') echo "selected"; ?>>Alert (to neither)</option>             
				       </select> 
					   <p class="rs description-input" style="margin-left:70px;">Types: Message, Notification, Alert</p> 
	                </div>  -->
	                
					<!-- ########################################################## -->	
					
					<br />
					<h3>
						Include a snippet of the message in the Alert(s) - ie. email, text &amp; push
					</h3>						
					
					<!-- ########### SWITCH FIELD STARTS HERE ########### -->
					<label class="lbl" for="txt_name1" style="text-align:left; width:auto; min-width:60px; margin-right:5px; margin-top:12px">Snippet</label>
					<div style="display:inline-block; float:left; width:auto; min-width:150px; height:41px; line-height:41px; 
					background:none; padding-top:9px; margin-top:5px;">
						<?php
							$is_checked7 = !empty($notification['snippet']) ? " checked='checked'" : "";
							//$is_exclude = isset($cat['is_excluded']) ? 1 : 0;
						?>
						<label class='switch'>
							<input class='' id='' data-toggle='toggle' type='checkbox' name="snippet"<?= $is_checked7 ?> /><span 
							class='sliderr round'></span>
						</label>
					</div>
					<div class="clear"></div>
					
					<!-- ########################################################## -->										
					<br />
					<h3>
						Choose which options to send by:
					</h3>					
					
					<!-- ########### SWITCH FIELD STARTS HERE ########### -->
					<label class="lbl" for="txt_name1" style="text-align:left; width:auto; min-width:60px; margin-right:5px; margin-top:12px">Inbox</label>
					<div style="display:inline-block; float:left; width:auto; min-width:150px; height:41px; line-height:41px; 
					background:none; padding-top:9px; margin-top:5px;">
						<?php
							$is_checked1 = !empty($notification['inbox']) ? " checked='checked'" : "";
							//$is_exclude = isset($cat['is_excluded']) ? 1 : 0;
						?>
						<label class='switch'>
							<input class='' id='' data-toggle='toggle' type='checkbox' name="inbox"<?= $is_checked1 ?> /><span 
							class='sliderr round'></span>
						</label>
					</div>
					<div class="clear"></div>
					
					<!-- ########### SWITCH FIELD STARTS HERE ########### -->
					<label class="lbl" for="txt_name1" style="text-align:left; width:auto; min-width:60px; margin-right:5px; margin-top:12px">Email</label>
					<div style="display:inline-block; float:left; width:auto; min-width:150px; height:41px; line-height:41px;
					background:none; padding-top:9px; margin-top:5px;">
						<?php
							$is_checked2 = !empty($notification['email']) ? " checked='checked'" : "";
						?>
						<label class='switch'>
							<input class='' id='' data-toggle='toggle' type='checkbox' name="email"<?= $is_checked2 ?> /><span
							class='sliderr round'></span>
						</label>
					</div>
					<div class="clear"></div>
					
					<!-- ########### SWITCH FIELD STARTS HERE ########### -->
					<label class="lbl" for="txt_name1" style="text-align:left; width:auto; min-width:60px; margin-right:5px; margin-top:12px">Push</label>
					<div style="display:inline-block; float:left; width:auto; min-width:150px; height:41px; line-height:41px;
					background:none; padding-top:9px; margin-top:5px;">
						<?php
							$is_checked4 = !empty($notification['push']) ? " checked='checked'" : "";
					?>
						<label class='switch'>
							<input class='' id='' data-toggle='toggle' type='checkbox' name="push"<?= $is_checked4 ?> /><span
							class='sliderr round'></span>
						</label>
					</div>
					<div class="clear"></div>					
					
					<!-- ########### SWITCH FIELD STARTS HERE ########### -->
					<label class="lbl" for="txt_name1" style="text-align:left; width:auto; min-width:60px; margin-right:5px; margin-top:12px">SMS Text</label>
					<div style="display:inline-block; float:left; width:auto; min-width:150px; height:41px; line-height:41px;
					background:none; padding-top:9px; margin-top:5px;">
						<?php
							$is_checked3 = !empty($notification['text']) ? " checked='checked'" : "";
						?>
						<label class='switch'>
							<input class='' id='' data-toggle='toggle' type='checkbox' name="text"<?= $is_checked3 ?> /><span
							class='sliderr round'></span>
						</label>
					</div>
					<div class="clear"></div>										
					  					
					<br />
					<div style="border-top:2px solid #ccc;"></div>
					<br />
					
					<label class="lbl" for="txt_name1" style="text-align:left; margin-right:5px;">Date:</label>
					<div class="val" style="margin-left:0px;">
						<input class="txt" type="text" name="date" value="<?= $notification['date'] ?>" 
						style="background:#eee; font-weight:300" readonly>
						<p class="rs description-input"></p>
					</div>
					<br />				
					
					<label class="lbl" for="txt_name1" style="text-align:left; margin-right:5px;">Status:</label>
					<div class="val" style="margin-left:0px; height:28px; line-height:28px; font-weight:800; padding-top:7px; font-size:17px">
						<?php if($notification['sent']==1){ ?>
						<span style="color:#00b900">Sent</span> <span style="font-weight:300;">on <?= date('m/d/y \a\t H:iA', strtotime($notification['date_sent'])); ?></span>
						<?php } else { ?>
							<span style="color:#aaa">Not sent</span>
						<?php } ?>						
						<p class="rs description-input"></p>
					</div>					
					
					<br />

					<?php
						$is_checked = !empty($notification['send']) ? " checked='checked'" : "";
					?>
					
					<div style="border-top:2px solid #ccc;"></div>
					<h3>
						Save a Notification first - then only check when ready to send.
					</h3>
				
					<label class="lbl" for="txt_name1" style="text-align:left; margin-right:5px;">Send now?:</label>
					<div class="val" style="margin-left:0px; height:28px; line-height:28px; font-weight:800; padding-top:7px; 
						font-size:17px; text-align:left;">
						<!--<div style="background:red; width:50px;">-->
						<input class='txt' type='checkbox' name="send"<?= $is_checked ?> style="width:20px;" />
						
						<br />
						<p class="rs description-input" style="color:#ff0000; font-size:14px;">check, then click &ldquo;Save&rdquo; button to send.</p>
					</div>				
					<br />

				</div>
				<br />
				<input type="submit" style="font-weight:300; width:150px;" class="btn btn-black" value="Save" />
				<input type="button" style="font-weight:300; width:150px;" value="Cancel" class="btn btn-black" 
				onclick="location = '/admin/notifications'" />
			</form>

		</div>
	</div>
</div>

<script src="/3rdparty/ckeditoradv/ckeditor.js?<?php echo rand() ?>"> </script>

<script>
	CKEDITOR.editorConfig = function( config ) {
		config.height = '50vh'; 
	};

//	$(function() {
//		CKEDITOR.config.height = '20vh';
//	});
//	$(function() {
//		CKEDITOR.config.height = '20vh';
//	});
//	CKEDITOR.editorConfig = function( config ) {
//		// Define changes to default configuration here. For example:
//		// config.language = 'fr';
//		// config.uiColor = '#AADC6E';
//		config.height = '20vh';
//	};
	CKEDITOR.replace( 'ckeditor' ,{
		config.height : '50vh';
	});	
</script>

<?php

include('views/_footer.tpl.php');

?>