<?php session_start(); error_reporting(0); if(!isset($_SESSION['jj_user']) && !isset($_SESSION['j_admin'])){ $url = urlencode("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]");header('location:../login/?url='.$url.''); } ?>
<!doctype html>
<html lang="en"> 
	<head>
		<?php
		require_once("../j_conn/url.php");
		require_once("../j_conn/dbc.php");
		require_once("../j_incs/functions.php");
		$page_name="Add News";
		$page_desc="$company_desc";
		$page_img="".$dir."j_files/j_img/logo/logo-meta.png";
		$page_author="$company";
		$page_keywords="".$company.", $page_name, $page_desc, ".$company_motto.", $company_desc";
		$page_url="".$dir."blog-add/";
		require_once("../j_incs/metas.php");
		require_once("../j_incs/scripts-top.php");
		?>
	</head>
	<body>
		<div class="app">
			<div class="layout">
				<?php 
				require_once("../j_incs/header.php");
				require_once("../j_incs/nav.php");
				?>
				<!-- Page Container START -->
				<div class="page-container">
					

					<!-- Content Wrapper START -->
					<div class="main-content">
						<div class="container-fluid">
							<div class="">
								<div class="col-md-11 mx-auto">
									<div class="page-header">
										<?php /*<h2 class="header-title"><?php echo $page_name; ?></h2>*/ ?>
										<div class="header-sub-title">
											<nav class="breadcrumb breadcrumb-dash">
												<a href="<?php echo $dir; ?>" class="breadcrumb-item"><i class="anticon anticon-dashboard m-r-5"></i>Dashboard</a>
												<!--<a class="breadcrumb-item" href="#"> </a>-->
												<span class="breadcrumb-item active"><?php echo $page_name; ?></span>
											</nav>
										</div>
									</div>
								</div>
							</div>
						</div>
						 
						<div class="container-fluid">
							
							
							
							
							
							<div class="row grid-margin">
								<div class="col-12">
									<div class="card">
										<div class="card-body">
											<form method="POST" action="" id="form">
												<div class="form-group  row required">
													<label class="col-sm-3 control-label">Title <sup> * </sup></label>   
													<div class="col-sm-9">
														<input placeholder="Title" name="title" type="text" class="form-control"/>
													</div>
												</div>
												
												
												<div class="form-group  row required">
													<label class="col-sm-3 control-label">Short Description <sup> * </sup></label>   
													<div class="col-sm-9">
														<input placeholder="Short Description" name="content_sm" type="text" class="form-control"/>
													</div>
												</div>
												
												
												<div class="form-group  row required">
													<label class="col-sm-3 control-label">Full Descriptiopn<sup> * </sup></label>   
													<div class="col-sm-9">
														<textarea style="min-height:150px;" rows="5"  placeholder="Content" name="content" type="text" class="form-control"></textarea>
													</div>
												</div>
												
												
												<div class="form-group  row required">
													<label class="col-sm-3 control-label">Cover Image <sup></sup>
													</label>   
													<div class="col-sm-9">
														<input placeholder="File" name="file1" type="file" class="form-control"/>
													</div>
												</div>
												
												
												
												<br>
												<p class="help-block">On submit, News will be added instantly. </p>
												<button id="submit" type="submit" class="btn btn-primary">Add Content</button>
											</form>
											
											<div id="formresult" class="mt-2"></div>
										</div>
									</div>
								</div>
							</div>
						
						
						
						
						</div>
					</div>
					<!-- Content Wrapper END -->

					<?php
					require_once("../j_incs/footer.php");
					?>

				</div>
				<!-- Page Container END -->
			</div>
		</div>
		<!-- container-scroller -->
		<?php require_once("../j_incs/scripts-bottom.php"); ?>
		<script>
	
			var form = "#form";
			var button = "#submit";
			var button_val = $(button).html();
			var result = "#formresult";
			var loader = ".j_loader";
			$(form).on('submit',(function(e) {
			e.preventDefault();
			$(button).attr('disabled', '');
			$(button).html('<span class="fa fa-circle-notch fa-spin fa-1x fa-fw"></span> PROCESSING...');
			$(loader).show('slow');
			 $(result).html("");
			var xhr = $.ajax({
			url: "save.php",
			type: "POST",
			data: new FormData(this),
			contentType: false,
			cache: false,
			processData:false,
			success: function(data)
			{
			if(data){
			 $(button).removeAttr('disabled');
			$(button).html(button_val);
			$(result).html(data);
			}else{
			$(result).html("Error occurred.");
			$(button).removeAttr('disabled');
			$(button).html(button_val);
			}
			}
			});
				setTimeout(function(){
					xhr.abort();
					$(button).removeAttr('disabled');
					$(button).html(button_val);
					//$(result).html("");
				}, 10000);
			}));
		</script>
	</body>
</html>