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

<style>
	#mmen { display:none; }
	.spacer { padding-top:57px; }
	.form .row-item .val { margin-bottom:10px; }
	.form .row-item .lbl { min-width:70px; margin-top:5px; }
	.form .txt {
		font-weight: 300;
		background: #eee; border:0px;
	}
	.btn { padding: 15px 25px; font-size:15px;  font-weight:300; margin-right:10px; }
	.saved  {
		background:#cd1000; margin-top:2px; color:#fff; text-align:center; padding:10px; font-size:15px;
	}
	.saved a, .saved a:active, .saved a:visited { background:#fff;  color:#28d52d; border-radius:50px; padding:3px 10px; font-weight:800; }
	.saved a:hover { color:#fff;  background:#28d52d; }

	.rounded { border-radius: 50px; -moz-border-radius: 50px; -webkit-border-radius: 50px; padding-left:20px; padding-right:20px; }	
	.cke_contents {
		max-height: 150px !important;
		height: 150px !important;
	}	
</style>

		<?php
		if (isset($saved)) {
			echo "<div class='saved' />$saved &nbsp;&nbsp;&nbsp; <a href='/admin/?service&edit={$service['id']}'>Ok</a></div>";
		}
		?>

 <div class="home-feature-category" style="background:none; border:none;">
        <div class="container_12 clearfix">
        <div class="grid_8 marked-category">

        <h1 style="margin-bottom:0px;"><a href="/admin/services">&laquo; Back</a> | <?php
        
        if ($service) {
            echo "Edit";
        } else {
            echo "Add";
			$def = "/static/images/placeholderimgg.jpg";
        }
		// onerror="this.src='/static/images/placeholderimgg.jpg'"
        ?> Service</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; font-size:17px; color:#000; font-weight:300; line-height:25px;">
                 
				<label class="lbl" for="txt_name1" 
				style="text-align:left; width:auto; margin-right:5px;">ID:</label>
				<div class="val" style="margin-left:0px; margin-top:11px">
					
					<input class="txt" type="text" name="id" value="<?= $service['id'] ?>">
					<p class="rs description-input"><?= $service['id'] ?></p>
				</div>
				<div class="clear"></div>
				
				<label class="lbl" for="txt_name1"
                style="text-align:left; width:auto; margin-right:5px;">Sort:</label>
				<div class="val" style="margin-left:0px;">
					<input class="txt" type="text" name="sort" value="<?= $service['sort'] ?>">
					<p class="rs description-input"></p>
				</div>

				<?php
				//$categoryModel = new categoryModel();
				//$categories = $categoryModel->getList();
				?>
				<label class="lbl" for="txt_name1"
                style="text-align:left; width:auto; margin-right:5px;">Category:</label>
				<div class="val" style="margin-left:0px;">
					<select name="cid" id="selectcategory" class="txt" 
					style="height:48px; line-height:48px; font-size:17px; 
					font-weight:300; width:100% !important; max-width:350px">
						<option value="">Select a Category</option>

						<?php
						foreach ($requestCategories as $category):
						$sel = $service['cid'] == $category['id'] ? ' selected="selected"' : ''; ?>
						<option value="<?= $category['id'] ?>" <?= $sel ?>><?= $category['title'] ?></option>
						<?php endforeach; ?>

					</select>
					<p class="rs description-input"></p>
				</div>

				<label class="lbl" for="txt_name1"
                style="text-align:left; width:auto; margin-right:5px;">Category:</label>
				<div class="val" style="margin-left:0px;">
					<input class="txt" type="text" id="textcat" 
					name="category" value="<?= $service['category'] ?>" readonly style="background:#ccc;">
					<p class="rs description-input"></p>
				</div>
				
				<label class="lbl" for="txt_name1"
                style="text-align:left; width:auto; margin-right:5px;">Descrip:</label>
				<div class="val" style="margin-left:0px;">
					<input class="txt" type="text" name="description" value="<?= $service['description'] ?>">
					<p class="rs description-input"></p>
				</div>               
                     
                <label class="lbl" for="txt_name1" 
                style="text-align:left; width:auto; margin-right:5px;">Subtitle:</label>
                <div class="val" style="margin-left:0px;">
					<input class="txt" type="text" name="subtitle" value="<?= $service['subtitle'] ?>">
                    <p class="rs description-input"></p>
                </div>
                
				<label class="lbl" for="txt_name1" style="text-align:left; width:auto; margin-right:5px;">Credits:</label>
				<div class="val" style="margin-left:0px;">
					<input class="txt" type="text" name="credits" value="<?= $service['credits'] ?>">
					<p class="rs description-input"></p>
				</div>   																					   				            
                      
<!--                <label class="lbl" for="txt_name1" style="text-align:left; width:auto; margin-right:5px;">Type:</label>
                <div class="val" style="margin-left:0px;">
			       <select name="type" id="" class="txt" type="number" style="background:#fff;">
			           <option value="">Select Type</option>
			           <option value="Table" <?php if($service['type'] == 'Table') echo "selected"; ?>>Table</option>
			           <option value="Station" <?php if($service['type'] == 'Station') echo "selected"; ?>>Station</option>     
			       </select>                 
                    <p class="rs description-input"></p>
                </div>-->
                
            </div>
            <br />
            <input type="submit" style="font-weight:300" class="btn btn-black" />
            <br /><br /> 
            <input type="button" value="Cancel" class="btn btn-black" onclick="location = '/admin/services'" />
        </form>

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

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

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

	//	$(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 : '20vh';
	});
</script>

<script type="text/javascript">
	$(document).ready(function() {
		// CHECKBOX, I THINK
//		$("#add_mailing_addr").change(function() {
//			if ($(this).is(":checked")) {
//				$("input[name='mailing_address']").removeProp("disabled");
//				$("input[name='mailing_address']").focus();
//			} else
//				$("input[name='mailing_address']").prop("disabled", true);
//		});
		
		$('#selectcategory').on('change', function() {
			//var optionValue = $(this).val();
			//var optionText = $('#dropdownList option[value="'+optionValue+'"]').text();
			var optionText = $("#selectcategory option:selected").text();
			$("#textcat").val(optionText);
//			if (optionText == "Male" || optionText == "Female") {
//				$("#genderlabel").hide();
//				$("#gender").hide();
//				$("#gender").val(optionText);
//			} else {
//				$("#genderlabel").show();
//				$("#gender").show();
//				$("#gender").val("");
//			}

			//alert("Selected Option Text: "+optionText);
		});
		// END OF FUNCTIONS
	});
</script>

<?php include('views/_footer.tpl.php'); ?>