<?php $__env->startSection('css_page_level'); ?>
<link rel="stylesheet" type="text/css" href="<?php echo e(asset('assets/global/plugins/bootstrap-toastr/toastr.min.css')); ?>"/>
<link rel="stylesheet" type="text/css" href="<?php echo e(asset('assets/global/plugins/bootstrap-select/bootstrap-select.min.css')); ?>"/>
<link rel="stylesheet" type="text/css" href="<?php echo e(asset('assets/global/plugins/bootstrap-fileinput/bootstrap-fileinput.css')); ?>"/>
<link rel="stylesheet" type="text/css" href="<?php echo e(asset('assets/global/plugins/clockface/css/clockface.css')); ?>"/>
<link rel="stylesheet" type="text/css" href="<?php echo e(asset('assets/global/plugins/bootstrap-datepicker/css/bootstrap-datepicker3.min.css')); ?>"/>
<link rel="stylesheet" type="text/css" href="<?php echo e(asset('assets/global/plugins/bootstrap-timepicker/css/bootstrap-timepicker.min.css')); ?>"/>
<link rel="stylesheet" type="text/css" href="<?php echo e(asset('assets/global/plugins/bootstrap-daterangepicker/daterangepicker-bs3.css')); ?>"/>
<link rel="stylesheet" type="text/css" href="<?php echo e(asset('assets/global/plugins/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css')); ?>"/>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('page-content-wrapper'); ?>
	<div class="page-content-wrapper" id="main">
		<div class="page-content">
			<!-- BEGIN PAGE HEADER-->
			<h3 class="page-title">
			<?php $setting = app('anlutro\LaravelSettings\Facade'); ?>
			<?php echo e($setting::get('system_name','全方位建築智慧化管理系統')); ?> <small><?php echo e($setting::get('company_name','新保科技')); ?></small>
			</h3>
			<div class="page-bar">
				<ul class="page-breadcrumb">
					<li>
						<i class="fa fa-home"></i>
						<a href="<?php echo e(route('manage::index')); ?>"><?php echo app('translator')->get('messages.homepage'); ?></a>
						<i class="fa fa-angle-right"></i>
					</li>
					<li>
						<a href="#"><?php echo app('translator')->get('messages.community_manage'); ?></a>
						<i class="fa fa-angle-right"></i>
					</li>
					<li>
						<a href="<?php echo e(action('Manage\Platform\NewsController@index')); ?>"><?php echo app('translator')->get('messages.news_publish'); ?></a>
						<i class="fa fa-angle-right"></i>
					</li>
					<li>
						<a href="<?php echo e(action('Manage\Platform\NewsController@create')); ?>"><?php echo app('translator')->get('messages.add_news'); ?></a>
					</li>
				</ul>
				<div class="page-toolbar">

				</div>
			</div>
			<!-- END PAGE HEADER-->
			<!-- BEGIN DASHBOARD STATS -->
			<div class="row">
				<div class="col-md-12">
					<!-- BEGIN PORTLET-->
					<?php if(count($errors) > 0): ?>
						<div id="form_error_alert" class="alert alert-danger">
						<button class="close" data-close="alert"></button>
							<ul>
					            <?php foreach($errors->all() as $error): ?>
					                <li><?php echo e($error); ?></li>
					            <?php endforeach; ?>
					        </ul>
						</div>
					<?php endif; ?>
					<div id="form_error_alert" class="alert alert-danger display-hide">
						<button class="close" data-close="alert"></button>
						<?php echo app('translator')->get('messages.col_invalid'); ?>
					</div>

					<div class="portlet box blue-hoki">
						<div class="portlet-title">
							<div class="caption">
								<i class="fa fa-pencil"></i><?php echo app('translator')->get('messages.news_publish'); ?>
							</div>
						</div>
						<div class="portlet-body form">
							<form action="<?php echo e(action('Manage\Platform\NewsController@store')); ?>" method="POST" id="form_add_news" class="form-horizontal form-bordered"  enctype="multipart/form-data">
								
								<div class="form-group">
									<label class="col-md-3 control-label"><?php echo app('translator')->get('messages.title'); ?><span class="required" aria-required="true"> * </span></label>
									<div class="col-md-9">
										<input name="title" type="text" class="form-control" placeholder="<?php echo app('translator')->get('messages.news_title'); ?>" value="<?php echo e(old('title')); ?>">
									</div>
								</div>
								<div class="form-group">
									<label class="col-md-3 control-label"><?php echo app('translator')->get('messages.category'); ?><span class="required" aria-required="true"> * </span></label>
									<div class="col-md-4">
										<select name="column" class="bs-select form-control">
											<?php foreach($columns as $column): ?>
											<?php if($column->name == "最新消息" || $column->name == "管委會訊息" || $column->name == "常見FAQ"): ?>
											<option value="<?php echo e($column->name); ?>" uid="<?php echo e($column->id); ?>"><?php echo e($column->name); ?> (只在網頁顯示)</option>
											<?php else: ?>
											<option value="<?php echo e($column->name); ?>" uid="<?php echo e($column->id); ?>"><?php echo e($column->name); ?></option>
											<?php endif; ?>
											<?php endforeach; ?>
										</select>
									</div>
								</div>
								<div class="form-group">
									<label class="col-md-3 control-label"><?php echo app('translator')->get('messages.publish_dept'); ?><span class="required" aria-required="true"> * </span></label>
									<div class="col-md-4">
										<input name="author" type="text" class="form-control" placeholder="<?php echo app('translator')->get('messages.enter_publish_dept'); ?>" value="<?php echo e(old('author')); ?>">
									</div>
								</div>
								<div class="form-group cover">
									<label class="col-md-3 control-label"><?php echo app('translator')->get('messages.cover_img'); ?></label>
									<div class="col-md-4">
										<div class="fileinput fileinput-new cover_img" data-provides="fileinput">
											<div class="fileinput-preview thumbnail" data-trigger="fileinput" style="width: 200px; height: 150px;">
												<img src="http://www.placehold.it/200x150/EFEFEF/AAAAAA&amp;text=no+image" alt=""/>
											</div>
											<div>
												<span class="btn default btn-file">
												<span class="fileinput-new">
												<?php echo app('translator')->get('messages.select_img'); ?> </span>
												<span class="fileinput-exists">
												<?php echo app('translator')->get('messages.change'); ?> </span>
												<input type="file" name="cover_img" id="cover_img">
												</span>
												<a href="javascript:;" class="btn red fileinput-exists" data-dismiss="fileinput" id="cover_reset"><?php echo app('translator')->get('messages.remove'); ?> </a>
												<input type="text" readonly value="僅接受jpg、jpeg、gif格式" style="margin-left:10px;font-size:14px;color:red;border: 0px solid;">
											</div>
										</div>
									</div>
								</div>

								<div class="form-group">
									<label class="col-md-3 control-label"><?php echo app('translator')->get('messages.app_home_img_upload'); ?>
										<span class="help-block"><?php echo app('translator')->get('messages.suggest_file_size'); ?>1100px*220px</span>
									</label>
									<div class="col-md-9">
										<div class="fileinput fileinput-new" data-provides="fileinput">
											<div class="fileinput-preview thumbnail" data-trigger="fileinput" style="width: 550px; height: 110px;">
												<img src="http://www.placehold.it/550x110/EFEFEF/AAAAAA&amp;text=no+image" alt=""/>
											</div>
											<div>
												<span class="btn default btn-file">
												<span class="fileinput-new">
												<?php echo app('translator')->get('messages.select_img'); ?> </span>
												<span class="fileinput-exists">
												<?php echo app('translator')->get('messages.change'); ?> </span>
												<input type="file" name="banner_img" id="banner_img">
												</span>
												<a href="javascript:;" class="btn red fileinput-exists" data-dismiss="fileinput">
												<?php echo app('translator')->get('messages.remove'); ?> </a>
												<input type="text" readonly value="僅接受jpg、jpeg、gif格式" style="margin-left:10px;font-size:14px;color:red;border: 0px solid;">
											</div>
										</div>
									</div>
								</div>

								<div class="form-group">
									<label class="control-label col-md-3">是否於App輪播</label>
									<div class="col-md-3">
										<input type="checkbox" id="banner_status" name="banner_status" class="make-switch" data-on-text="<?php echo app('translator')->get('messages.active'); ?>" data-off-text="<?php echo app('translator')->get('messages.no_active'); ?>">
									</div>
								</div>

								<div class="form-group file">
									<label class="col-md-3 control-label"><?php echo app('translator')->get('messages.news_annex'); ?></label>
									<div class="col-md-4">
										<div class="fileinput fileinput-new" data-provides="fileinput">
											<div class="input-group input-xlarge">
												<div class="form-control uneditable-input input-fixed input-medium" data-trigger="fileinput">
													<i class="fa fa-file fileinput-exists"></i> &nbsp;<span class="fileinput-filename">
													</span>
												</div>
												<span class="btn default btn-file">
												<span class="fileinput-new">
												<?php echo app('translator')->get('messages.select_file'); ?></span>
												<span class="fileinput-exists">
												<?php echo app('translator')->get('messages.change'); ?> </span>
												<input type="file" name="file">
												</span>
												<a href="javascript:;" class="btn red fileinput-exists" data-dismiss="fileinput" id="file_reset"><?php echo app('translator')->get('messages.remove'); ?> </a>
												<input type="text" readonly value="僅接受pdf格式" style="margin-left:10px;font-size:14px;color:red;border: 0px solid;width:500px;">
											</div>
										</div>
									</div>
								</div>
								<div class="form-group">
									<label class="col-md-3 control-label"><?php echo app('translator')->get('messages.related_link'); ?></label>
									<div class="col-md-4">
										<input name="link" type="text" class="form-control" placeholder="<?php echo app('translator')->get('messages.put_related_link_here'); ?>"  value="<?php echo e(old('link')); ?>">
									</div>
								</div>
								<div class="form-group">
									<div class="col-md-12">
										<textarea name="content" id="content" rows="50" cols="80">
										 <?php echo old('content'); ?>

							            </textarea>
									</div>
								</div>
								<div class="form-actions">
									<div class="row">
										<div class="col-md-12">
											<button type="submit" class="btn purple pull-right"><i class="fa fa-check"></i> <?php echo app('translator')->get('messages.submit'); ?></button>
										</div>
									</div>
								</div>
								<input type="hidden" id="_token" name="_token" value="<?php echo e(csrf_token()); ?>">
							</form>
						</div>
					</div>
					<!-- END PORTLET-->
				</div>
			</div>

	
<?php $__env->stopSection(); ?>

<?php $__env->startSection('plugins_page_level'); ?>
<script type="text/javascript" src="<?php echo e(asset('assets/global/plugins/jquery-validation/js/jquery.validate.min.js')); ?>"></script>
<script type="text/javascript" src="<?php echo e(asset('assets/global/plugins/bootstrap-fileinput/bootstrap-fileinput.js')); ?>"></script>
<script type="text/javascript" src="<?php echo e(asset('assets/global/plugins/bootstrap-fileinput/additional-methods.js')); ?>"></script>
<script type="text/javascript" src="<?php echo e(asset('assets/global/plugins/ckeditor/ckeditor.js')); ?>"></script>
<script type="text/javascript" src="<?php echo e(asset('assets/global/plugins/clockface/js/clockface.js')); ?>"></script>
<script src="<?php echo e(asset('assets/global/plugins/bootstrap-toastr/toastr.min.js')); ?>" type="text/javascript" ></script>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('js_page_level'); ?>
<script> 
$(document).ready(function(){
    CKEDITOR.replace( 'content' );
  
    $('#form_add_news').validate({

		errorElement: 'span', //default input error message container
        errorClass: 'help-block help-block-error', // default input error message class
        focusInvalid: false, // do not focus the last invalid input
        ignore: "",  // validate all fields including form hidden input
		rules:{
			title:{
				required:true,
				minlength: 4 ,
				maxlength:30 
			},
			author:{
				required: true,
				minlength: 3 ,
				maxlength:30 
			},
			cover_img:{
				extension:"jpg|gif",
			},
			file:{
				extension:"pdf"
			}
		},
		messages:{
			title:{
				required:'<?php echo app('translator')->get('messages.mustb_enter_msg_title'); ?>',
				minlength: '<?php echo app('translator')->get('messages.enter_title_min4'); ?>' ,
				maxlength: '<?php echo app('translator')->get('messages.enter_title_max30'); ?>'
			},
			author:{
				required: '<?php echo app('translator')->get('messages.enter_publish_dept_auther'); ?>',
				minlength: '<?php echo app('translator')->get('messages.publish_dept_auther_min3'); ?>' ,
				maxlength: '<?php echo app('translator')->get('messages.publish_dept_auther_max30'); ?>' 
			},
			cover_img:{
				extension: '<?php echo app('translator')->get('messages.correct_style'); ?> jpg / gif <?php echo app('translator')->get('messages.upload'); ?>',
			},
			file:{
				extension: '<?php echo app('translator')->get('messages.correct_style'); ?> pdf <?php echo app('translator')->get('messages.upload'); ?>'
			}
		},

        invalidHandler: function (event, validator) { //display error alert on form submit   
            $('#form_error_alert').show();
            $('body').scrollTop($('#form_error_alert'));
        },

        highlight: function (element) { // hightlight error inputs
           $(element).closest('.form-group').addClass('has-error'); // set error class to the control group
        },

        unhighlight: function (error,element) { // revert the change done by hightlight
            $(element).closest('.form-group').removeClass('has-error'); // set error class to the control group
        },

        success: function (label) {
            label.closest('.form-group').removeClass('has-error'); // set success class to the control group
        },

        submitHandler: function (form) {
            $('textarea.ckeditor').each(function () {
			   var $textarea = $(this);
			   $textarea.val(CKEDITOR.instances[$textarea.attr('name')].getData());
			});

			form.submit();
        },
        errorPlacement: function(error, element) {
        	if (element.attr("name") === "cover_img" || element.attr("name") === "file") {
    			error.appendTo( element.parent().parent() );
 
    		} else {
    			error.insertAfter( element );
       		}
		},
	});

	$('.fileinput').on('change.bs.fileinput', function() {
		$("#form_add_news").validate().element('input[name=cover_img]');
		$("#form_add_news").validate().element('input[name=file]');	
	});

});
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layout.manage', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>