<?php

require __dir__ . '/init.php';

if($_SERVER['REQUEST_METHOD'] == 'POST'):
	$status = $settings->set("news", help::sanitize($_POST['message']));
	$msg = $status ? "News Saved!" : "News Not Saved!";
endif;

template::get_header();

?>


	<?php template::title( "NEWS MANAGEMENT" ); ?>
          
	<div class="card">
		<div class="card-body">
		
			<?php template::alert( $msg, $status ?? null ); ?>
			
			<form class="form-horizontal" action="inmessage.php" method="POST" >
				<legend>Add News </legend>
				<div class="form-group">
					<div class="form-group">
						<textarea placeholder="write message here" name="message" class="form-control" rows="7"></textarea>
					</div>
					<button style="" type="submit" class="btn btn-primary" name="news" > 
						<i class="fa fa-send"></i>&nbsp; Save News 
					</button>
				</div>
			</form>
			
		</div>
	</div>
	
	<div class='card'>
		<div class='card-header'>
			<h4>Current News</h4>
		</div>
		<div class='card-body'>
			<div class='bg-light p-3'>
				<?php 
					$news = nl2br( $settings->get('news') ); 
					if( empty($news) ) $news = "<h4 class='text-center mb-0'> * No news available * </h4>";
					echo $news;
				?>
			</div>
		</div>
	</div>

<?php template::get_footer(); ?>  