<?php $__env->startSection('css_page_level'); ?>
<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')); ?>">首頁</a>
						<i class="fa fa-angle-right"></i>
					</li>
					<li>
						<a href="javascript:;">社區平台管理</a>
						<i class="fa fa-angle-right"></i>
					</li>
					<li>
						<a href="<?php echo e(action('Manage\Platform\FestivalController@index')); ?>">熱門節慶</a>
						<i class="fa fa-angle-right"></i>
					</li>
					<li>
						<a href="<?php echo e(action('Manage\Platform\FestivalController@edit',['id'=>$festival->id])); ?>">編輯熱門節慶</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_add_Festival_error" class="alert alert-danger display-hide">
						<button class="close" data-close="alert"></button>
						您似乎有部分欄位有錯誤，請查看後再送出。
					</div>
					<div id="form_add_Festival_success" class="alert alert-success display-hide">
						<button class="close" data-close="alert"></button>
						新增成功。
					</div>
					<div class="portlet box purple-studio">
						<div class="portlet-title">
							<div class="caption">
								<i class="fa fa-album"></i>編輯熱門節慶
							</div>
						</div>
						<div class="portlet-body form">
							<form action="<?php echo e(action('Manage\Platform\FestivalController@update' ,['id'=>$festival->id])); ?>" method="POST" id="form_edit_festival" class="form-horizontal form-bordered"  enctype="multipart/form-data">
								<input type="hidden" name="id" value="<?php echo e($festival->id); ?>">
								<input type="hidden" name="_token" value="<?php echo e(csrf_token()); ?>">
								
							<div class="form-group">
									<label class="col-md-3 control-label">標題<span class="required" aria-required="true"> * </span></label>
									<div class="col-md-6">
										<input name="title" type="text" class="form-control" placeholder="請輸入標題" value="<?php echo e($festival->title); ?>">
									</div>
								</div>
									<div class="form-group">
										<label class="col-md-3 control-label">類別<span class="required" aria-required="true"> * </span></label>
										<div class="col-md-4">
											<select name="type" class="bs-select form-control">
												<optgroup>
											        <option value="<?php echo e($festival->type); ?>"><?php echo e($festival->type); ?></option>
											    </optgroup>
												<optgroup>
													<option value="食">食</option>
													<option value="衣">衣</option>
													<option value="住">住</option>
													<option value="行">行</option>
													<option value="育">育</option>
													<option value="樂">樂</option>
												</optgroup>
											</select>
										</div>
									</div>
                                <div class="form-group cover">
									<label class="col-md-3 control-label">封面圖檔<span class="required" aria-required="true"> * </span></label>
									<div class="col-md-4">
										<div class="fileinput fileinput-new" data-provides="fileinput">
											<div class="fileinput-preview thumbnail" data-trigger="fileinput" style="width: 200px; height: 150px;">
												<?php if($festival->cover_img != ''): ?>
												<img src="<?php echo e($festival->cover_img); ?>" alt=""/>
												<?php else: ?>
												<img src="http://www.placehold.it/200x150/EFEFEF/AAAAAA&amp;text=no+image" alt=""/>
												<?php endif; ?>
											</div>
											<div>
												<span class="btn default btn-file">
												<span class="fileinput-new">
												選擇圖片 </span>
												<span class="fileinput-exists">
												更換 </span>
												<input type="file" name="cover_img" id="cover_img">
												</span>
												<a href="javascript:;" id="cover_reset" class="btn red fileinput" data-dismiss="fileinput">
												移除 </a>
											</div>
										</div>
									</div>
								</div>
								<div class="form-group">
										<label class="col-md-3 control-label">節慶介紹<span class="required" aria-required="true"> * </span></label>
										<div class="col-md-6">
											<textarea name="introduce" class="form-control" rows="3"><?php echo e($festival->introduce); ?></textarea>
										</div>
								</div>
							    <div class="form-group">
										<label class="col-md-3 control-label">位置<span class="required" aria-required="true"> * </span></label>
										<div class="col-md-6">
											<input name="map" type="text" class="form-control" placeholder="請輸入位置。例如：台北市中正區信義路x段x號x樓x室" value="<?php echo e($festival->map); ?>">
									</div>
								</div>
								<div class="form-group">
										<label class="col-md-3 control-label">交通資訊</label>
										<div class="col-md-6">
											<input name="info" type="text" class="form-control" placeholder="請輸入交通資訊" value="<?php echo e($festival->info); ?>">
									</div>
								</div>
								<div class="form-group">
								<div class="form-group file">
									<label class="col-md-3 control-label">相關下載</label>
									<div class="col-md-4">
										<div class="fileinput fileinput-new" data-provides="fileinput">
										<?php if($festival->file != ''): ?>
										<a type="button" class="btn green btn-xs" href="<?php echo e($festival->file); ?>"><?php echo e($original_filename); ?></a>
										<?php endif; ?>
											<div class="input-group input-large">
												<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="input-group-addon btn default btn-file">
												<span class="fileinput-new">
												選擇檔案 </span>
												<span class="fileinput-exists">
												更換 </span>
												<input type="file" name="file">
												</span>
												<a href="javascript:;" id="file_reset" class="input-group-addon btn red fileinput-exists" data-dismiss="fileinput">
												移除 </a>
											</div>
										</div>
									</div>
								</div>
							    <div class="form-group">
										<label class="col-md-3 control-label">安全事項</label>
										<div class="col-md-6">
											<textarea name="safe_note" class="form-control" rows="3"><?php echo e($festival->safe_note); ?></textarea>
										</div>
								</div>
								<div class="form-group">
								<label class="col-md-3 control-label">相簿</label>
                                    <input name="_token" type="hidden" value="<?php echo e(csrf_token()); ?>"/>
									<div class="col-md-6">
                                    <div class="fileinput fileinput-new cover_album1" data-provides="fileinput">
                                        <div class="fileinput-preview thumbnail" data-trigger="fileinput" style="width: 200px; height: 150px;">
                                            <?php if($festival->image1 != ''): ?>
											<img src="<?php echo e($festival->image1); ?>" alt=""/>
											<?php else: ?>
											<img src="http://www.placehold.it/200x150/EFEFEF/AAAAAA&amp;text=no+image" alt=""/>
											<?php endif; ?>
                                        </div>
                                        <div>
                                            <span class="btn default btn-file">
                                            <span class="fileinput-new">
                                            選擇圖片 </span>
                                            <span class="fileinput-exists">
                                            更換 </span>
                                            <input type="file" name="image1" id="image1">
                                            </span>
                                            <a href="javascript:;" id="cover_album_reset1" class="btn red fileinput" data-dismiss="fileinput">
                                            移除 </a>
                                        </div>
                                     </div>
                                     <div class="fileinput fileinput-new cover_album2" data-provides="fileinput">
                                        <div class="fileinput-preview thumbnail" data-trigger="fileinput" style="width: 200px; height: 150px;">
                                            <?php if($festival->image2 != ''): ?>
											<img src="<?php echo e($festival->image2); ?>" alt=""/>
											<?php else: ?>
											<img src="http://www.placehold.it/200x150/EFEFEF/AAAAAA&amp;text=no+image" alt=""/>
											<?php endif; ?>
                                        </div>
                                        <div>
                                            <span class="btn default btn-file">
                                            <span class="fileinput-new">
                                            選擇圖片 </span>
                                            <span class="fileinput-exists">
                                            更換 </span>
                                            <input type="file" name="image2" id="image2">
                                            </span>
                                            <a href="javascript:;" id="cover_album_reset2" class="btn red fileinput" data-dismiss="fileinput">
                                            移除 </a>
                                        </div>
                                     </div>
                                     <div class="fileinput fileinput-new cover_album3" data-provides="fileinput">
                                        <div class="fileinput-preview thumbnail" data-trigger="fileinput" style="width: 200px; height: 150px;">
                                            <?php if($festival->image3 != ''): ?>
											<img src="<?php echo e($festival->image3); ?>" alt=""/>
											<?php else: ?>
											<img src="http://www.placehold.it/200x150/EFEFEF/AAAAAA&amp;text=no+image" alt=""/>
											<?php endif; ?>
                                        </div>
                                        <div>
                                            <span class="btn default btn-file">
                                            <span class="fileinput-new">
                                            選擇圖片 </span>
                                            <span class="fileinput-exists">
                                            更換 </span>
                                            <input type="file" name="image3" id="image3">
                                            </span>
                                            <a href="javascript:;" id="cover_album_reset3" class="btn red fileinput" data-dismiss="fileinput">
                                            移除 </a>
                                        </div>
                                     </div> 
                                     <div class="fileinput fileinput-new cover_album4" data-provides="fileinput">
                                        <div class="fileinput-preview thumbnail" data-trigger="fileinput" style="width: 200px; height: 150px;">
                                            <?php if($festival->image4 != ''): ?>
											<img src="<?php echo e($festival->image4); ?>" alt=""/>
											<?php else: ?>
											<img src="http://www.placehold.it/200x150/EFEFEF/AAAAAA&amp;text=no+image" alt=""/>
											<?php endif; ?>
                                        </div>
                                        <div>
                                            <span class="btn default btn-file">
                                            <span class="fileinput-new">
                                            選擇圖片 </span>
                                            <span class="fileinput-exists">
                                            更換 </span>
                                            <input type="file" name="image4" id="image4">
                                            </span>
                                            <a href="javascript:;" id="cover_album_reset4" class="btn red fileinput" data-dismiss="fileinput">
                                            移除 </a>
                                        </div>
                                     </div>
                                     <div class="fileinput fileinput-new cover_album5" data-provides="fileinput">
                                        <div class="fileinput-preview thumbnail" data-trigger="fileinput" style="width: 200px; height: 150px;">
                                            <?php if($festival->image5 != ''): ?>
											<img src="<?php echo e($festival->image5); ?>" alt=""/>
											<?php else: ?>
											<img src="http://www.placehold.it/200x150/EFEFEF/AAAAAA&amp;text=no+image" alt=""/>
											<?php endif; ?>
                                        </div>
                                        <div>
                                            <span class="btn default btn-file">
                                            <span class="fileinput-new">
                                            選擇圖片 </span>
                                            <span class="fileinput-exists">
                                            更換 </span>
                                            <input type="file" name="image5" id="image5">
                                            </span>
                                            <a href="javascript:;" id="cover_album_reset5" class="btn red fileinput" data-dismiss="fileinput">
                                            移除 </a>
                                        </div>
                                     </div>
									 </div>
								</div>
								<div class="form-group">
									<label class="col-md-2">詳細介紹</label>
									<div class="col-md-12">
										<textarea name="content" id="content" rows="50" cols="80">
										<?php echo e($festival->content); ?>

							            </textarea>
									</div>
								</div>
								<div class="form-actions">
									<div class="row">
										<div class="col-md-offset-3 col-md-9">
											<button type="submit" class="btn purple pull-right"><i class="fa fa-check"></i> 儲存 </button>
										</div>
									</div>
								</div>
							</form>
						</div>
					</div>
					<!-- END PORTLET-->
				</div>
			</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/bootstrap-datepicker/js/bootstrap-datepicker.min.js')); ?>"></script>
<script type="text/javascript" src="<?php echo e(asset('assets/global/plugins/bootstrap-timepicker/js/bootstrap-timepicker.min.js')); ?>"></script>
<script type="text/javascript" src="<?php echo e(asset('assets/global/plugins/clockface/js/clockface.js')); ?>"></script>
<script type="text/javascript" src="<?php echo e(asset('assets/global/plugins/bootstrap-daterangepicker/moment.min.js')); ?>"></script>
<script type="text/javascript" src="<?php echo e(asset('assets/global/plugins/bootstrap-daterangepicker/daterangepicker.js')); ?>"></script>
<script type="text/javascript" src="<?php echo e(asset('assets/global/plugins/bootstrap-colorpicker/js/bootstrap-colorpicker.js')); ?>"></script>
<script type="text/javascript" src="<?php echo e(asset('assets/global/plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js')); ?>"></script>
<?php $__env->stopSection(); ?>

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

    $(".form_datetime").datetimepicker({autoclose: true});
	
	$('#form_edit_festival').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 
			},
			type:{
				required:true 
			},
			introduce:{
				required:true 
			},
			map:{
				required:true 
			},
			cover_img:{
				extension:"jpg|gif",
			},/*
			image1:{
				extension:"jpg|gif",
			},
			image2:{
				extension:"jpg|gif",
			},
			image3:{
				extension:"jpg|gif",
			},
			image4:{
				extension:"jpg|gif",
			},
			image5:{
				extension:"jpg|gif",
			},*/
			file:{
				extension:"pdf"
			}
		},
		messages:{
			title:{
				required:'請輸入本次節慶名稱'  ,
				minlength: '標題最少4個字元' ,
				maxlength: '標題最多30個字元'
			},
			map:{
				required:'請輸入位置'
			},
			type:{
				required:'請輸入熱門節慶的類別'
			},
			introduce:{
				required:'請輸入節慶介紹內容'
			},
			cover_img:{
				extension: '請使用正確格式 jpg / gif上傳'
			},/*
			image1:{
				extension: '請使用正確格式 jpg / gif上傳',
			},
			image2:{
				extension: '請使用正確格式 jpg / gif上傳',
			},
			image3:{
				extension: '請使用正確格式 jpg / gif上傳',
			},
			image4:{
				extension: '請使用正確格式 jpg / gif上傳',
			},
			image5:{
				extension: '請使用正確格式 jpg / gif上傳',
			},*/
			file:{
				extension: '請使用正確格式 pdf 上傳'
			}
		},

        invalidHandler: function (event, validator) { //display error alert on form submit   
            $('#form_edit_festival_success').hide();
            $('#form_edit_festival_error').show();
        },

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

        unhighlight: function (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") === "image1" || element.attr("name") === "image2" || element.attr("name") === "image3" || element.attr("name") === "image4" || element.attr("name") === "image5" || element.attr("name") === "file") {
    			error.appendTo( element.parent().parent() );
 
    		} else {
    			error.insertAfter( element );
       		}
		},
	});

	$('.fileinput').on('change.bs.fileinput', function() {
			$("#form_edit_festival").validate().element('input[name=cover_img]');
			$("#form_edit_festival").validate().element('input[name=image1]');
			$("#form_edit_festival").validate().element('input[name=image2]');
			$("#form_edit_festival").validate().element('input[name=image3]');
			$("#form_edit_festival").validate().element('input[name=image4]');
			$("#form_edit_festival").validate().element('input[name=image5]');
			$("#form_edit_festival").validate().element('input[name=file]');	
	});

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