<?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\FactoryController@index')); ?>">廠戶介紹</a>
						<i class="fa fa-angle-right"></i>
					</li>
					<li>
						<a href="<?php echo e(action('Manage\Platform\FactoryController@create')); ?>">新增廠戶</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_factory_error" class="alert alert-danger 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\FactoryController@store')); ?>" method="POST" id="form_add_factory" class="form-horizontal form-bordered"  enctype="multipart/form-data">

								<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="請輸入標題">
									</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">
												<option value="<?php echo app('translator')->get('messages.eating'); ?>"><?php echo app('translator')->get('messages.eating'); ?></option>
												<option value="<?php echo app('translator')->get('messages.dressing'); ?>"><?php echo app('translator')->get('messages.dressing'); ?></option>
												<option value="<?php echo app('translator')->get('messages.living'); ?>"><?php echo app('translator')->get('messages.living'); ?></option>
												<option value="<?php echo app('translator')->get('messages.going'); ?>"><?php echo app('translator')->get('messages.going'); ?></option>
												<option value="<?php echo app('translator')->get('messages.eduing'); ?>"><?php echo app('translator')->get('messages.eduing'); ?></option>
												<option value="<?php echo app('translator')->get('messages.loking'); ?>"><?php echo app('translator')->get('messages.loking'); ?></option>
											</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;">
												<img src="<?php echo e(asset('assets/images/blank_image01.jpg')); ?>" alt=""/>
											</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-exists" 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">
										<input name="store_name" type="text" class="form-control" placeholder="請輸入店家名稱">
									</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="sale" type="text" class="form-control" placeholder="請輸入特惠優惠">
									</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="location" class="bs-select form-control">
                                                <option value="臺北市">臺北市</option>
                                                <option value="新北市">新北市</option>
                                                <option value="桃園市">桃園市</option>
                                                <option value="新竹市">新竹市</option>
                                                <option value="新竹縣">新竹縣</option>
                                                <option value="苗栗縣">苗栗縣</option>
												<option value="基隆市">基隆市</option>
                                                <option value="臺中市">臺中市</option>
                                                <option value="彰化縣">彰化縣</option>
                                                <option value="南投縣">南投縣</option>
                                                <option value="雲林縣">雲林縣</option>
                                                <option value="嘉義市">嘉義市</option>
                                                <option value="嘉義縣">嘉義縣</option>
                                                <option value="臺南市">臺南市</option>
                                                <option value="高雄市">高雄市</option>
                                                <option value="屏東縣">屏東縣</option>
                                                <option value="臺東縣">臺東縣</option>
                                                <option value="花蓮縣">花蓮縣</option>
                                                <option value="宜蘭縣">宜蘭縣</option>
                                                <option value="澎湖縣">澎湖縣</option>
                                                <option value="金門縣">金門縣</option>
                                                <option value="連江縣">連江縣</option>
											</select>
										</div>
									</div>
								<div class="form-group">
									<label class="col-md-3 control-label">限時開始</label>
									<div class="col-md-6">
										<div class="input-group date form_datetime">
											<input name="time_start" type="text" size="16" readonly class="form-control">
											<span class="input-group-btn">
											<button class="btn default date-set" type="button"><i class="fa fa-calendar"></i></button>
											</span>
										</div>
									</div>
								</div>
								<div class="form-group">
										<label class="col-md-3 control-label">限時結束</label>
										<div class="col-md-6">
											<div class="input-group date form_datetime">
												<input name="time_end" type="text" size="16" readonly class="form-control">
												<span class="input-group-btn">
												<button class="btn default date-set" type="button"><i class="fa fa-calendar"></i></button>
												</span>
											</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">
											<input name="web_map" type="text" class="form-control" placeholder="請輸入網路地圖。例如：台北市中正區信義路x段x號x樓x室">
									</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室">
									</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="opening" type="text" class="form-control" placeholder="請輸入營業時間。例如：08:00~18:00">
									</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="tel" type="text" class="form-control" placeholder="請輸入連絡電話">
									</div>
								</div>
								<div class="form-group">
									<label class="col-md-3 control-label">營業項目</label>
									<div class="col-md-6">
										<input name="bus_area" type="text" class="form-control" placeholder="請輸入營業項目">
									</div>
								</div>
								<div class="form-group">
										<label class="col-md-3 control-label">廠戶地址</label>
										<div class="col-md-6">
											<input name="address" type="text" class="form-control" placeholder="請輸入網路地圖。例如：台北市中正區信義路x段x號x樓x室">
									</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="請輸入交通資訊">
									</div>
								</div>
								<div class="form-group">
								<div class="form-group">
									<label class="col-md-3 control-label">官方網站</label>
									<div class="col-md-6">
										<input name="web" type="text" class="form-control" placeholder="請輸入官方網站">
									</div>
								</div>
								<div class="form-group">
									<label class="col-md-3 control-label">推薦商品</label>
									<div class="col-md-6">
										<input name="goods" type="text" class="form-control" placeholder="請輸入推薦商品">
									</div>
								</div>
								<div class="form-group">
										<label class="col-md-3 control-label">分類標籤</label>
										<div class="col-md-6">
										<input name="tag" type="text" class="form-control" placeholder="請輸入分類標籤">
									</div>
									</div>
								<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">
											<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"></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;">
											<img src="<?php echo e(asset('assets/images/blank_image01.jpg')); ?>" alt=""/>
                                        </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-exists" 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;">
											<img src="<?php echo e(asset('assets/images/blank_image01.jpg')); ?>" alt=""/>
                                        </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-exists" 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;">
											<img src="<?php echo e(asset('assets/images/blank_image01.jpg')); ?>" alt=""/>
                                        </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-exists" 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;">
											<img src="<?php echo e(asset('assets/images/blank_image01.jpg')); ?>" alt=""/>
                                        </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-exists" 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;">
											<img src="<?php echo e(asset('assets/images/blank_image01.jpg')); ?>" alt=""/>
                                        </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-exists" 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">
							            </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>
								<input type="hidden" id="_token" name="_token" value="<?php echo e(csrf_token()); ?>">
							</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_add_factory').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 
			},
			store_name:{
				required:true 
			},
			time_start:{
				required:false 
			},
			time_end:{
				required:false 
			},
			opening:{
				required:true 
			},
			web_map:{
				required:true 
			},
			map:{
				required:true 
			},
			sale:{
				required:true 
			},
			type:{
				required:true 
			},
			tel:{
				required:true 
			},
			location:{
				required:true 
			},
			cover_img:{
				required:true,
				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個字元'
			},
			store_name:{
				required:'請輸入店家名稱'
			},
			// time_start:{
			// 	required:'請輸入限時開始時間'
			// },
			// time_end:{
			// 	required:'請輸入限時結束時間'
			// },
			opening:{
				required:'請輸入營業時間'
			},
			web_map:{
				required:'請輸入網路地圖'
			},
			map:{
				required:'請輸入位置'
			},
			sale:{
				required:'請輸入特惠優惠'
			},
			type:{
				required:'請輸入週邊商家的所屬類型'
			},
			tel:{
				required:'請輸入連絡電話'
			},
			location:{
				required:'請輸入所屬縣市'
			},
			cover_img:{
				required:'請務必輸入封面圖檔',
				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_add_factory_success').hide();
            $('#form_add_factory_error').show();
            $('.modal').scrollTop($('#form_add_factory_error'));
        },

        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_add_factory").validate().element('input[name=cover_img]');
			$("#form_add_factory").validate().element('input[name=image1]');
			$("#form_add_factory").validate().element('input[name=image2]');
			$("#form_add_factory").validate().element('input[name=image3]');
			$("#form_add_factory").validate().element('input[name=image4]');
			$("#form_add_factory").validate().element('input[name=image5]');
			$("#form_add_factory").validate().element('input[name=file]');	
	});
	
});

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