<?php $__env->startSection('css_page_level'); ?>
    <link rel="stylesheet" type="text/css" href="<?php echo e(asset('assets/global/plugins/datatables/plugins/bootstrap/dataTables.bootstrap.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-daterangepicker/daterangepicker.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/select2/css/select2.css')); ?>"/>
    <link rel="stylesheet" type="text/css" href="<?php echo e(asset('assets/global/plugins/select2/css/select2-bootstrap.min.css')); ?>"/>
    <link rel="stylesheet" type="text/css" href="<?php echo e(asset('assets/global/plugins/jquery-multi-select/css/multi-select.css')); ?>"/>
    <link href="<?php echo e(asset('assets/global/plugins/bootstrap-switch/css/bootstrap-switch.min.css')); ?>" rel="stylesheet" type="text/css"/>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('page-content-wrapper'); ?>
	<style type="text/css">
		.th_display_none { display: none;}
        .disableInput {
            background-color: #ffee88 !important;
        }
        .readOnlyInput {
            background-color: #ffee88 !important;
        }
	</style>
	<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="index.html">首頁</a>
						<i class="fa fa-angle-right"></i>
					</li>
					<li>
						<a href="#">巡邏管理</a>
						<i class="fa fa-angle-right"></i>
					</li>
					<li>
						<a href="#">巡邏設定</a>
					</li>
				</ul>
				<div class="page-toolbar">

				</div>
			</div>
			<!-- END PAGE HEADER-->
			<!-- BEGIN DASHBOARD STATS -->
			<div class="row">
				<div class="col-md-12">
					<!-- BEGIN EXAMPLE TABLE PORTLET-->
					<div class="portlet light bordered">
						<div class="portlet-title">
							<div class="caption">
								<i class="icon-bar-chart font-green-sharp hide"></i>
								<span class="caption-subject font-green-sharp bold uppercase">巡邏設定</span>                                      
							</div>
						</div>
						<div class="portlet-body">
                            <form id="form_edit" action="" class="form-horizontal">
                                <input type="hidden" name="id" value="<?php echo e($data->id); ?>" />
                                <div class="form-body">
                                    <div class="form-group">
                                        <label class="col-md-3 control-label">正常狀況</label>
                                        <div class="col-md-7">
                                            <input type="text" name="normal_mins" class="form-control" placeholder="請輸入正常狀況的時間(分)" value="<?php echo e($data->normal_mins); ?>"> 
                                        </div>
                                        <div class="col-md-2">
                                            <input name="normal_active" value="1" class="make-switch" type="checkbox" data-on-text="啟用" data-off-text="停用"<?php echo e(($data->normal_active == '1') ? ' checked' : ''); ?> />
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-md-3 control-label">巡邏遲到</label>
                                        <div class="col-md-7">
                                            <input type="text" name="late_mins" class="form-control" placeholder="請輸入巡邏遲到狀況的時間(分)" value="<?php echo e($data->late_mins); ?>"> 
                                        </div>
                                        <div class="col-md-2">
                                            <input name="late_active" value="1" class="make-switch" type="checkbox" data-on-text="啟用" data-off-text="停用"<?php echo e(($data->late_active == '1') ? ' checked' : ''); ?> />
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-md-3 control-label">巡邏早到</label>
                                        <div class="col-md-7">
                                            <input type="text" name="early_mins" class="form-control" placeholder="請輸入巡邏早到狀況的時間(分)" value="<?php echo e($data->early_mins); ?>"> 
                                        </div>
                                        <div class="col-md-2">
                                            <input name="early_active" value="1" class="make-switch" type="checkbox" data-on-text="啟用" data-off-text="停用"<?php echo e(($data->early_active == '1') ? ' checked' : ''); ?> />
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-md-3 control-label">未巡邏</label>
                                        <div class="col-md-7">
                                            <input type="text" name="off_mins" class="form-control" placeholder="請輸入未巡邏狀況的時間(分)" value="<?php echo e($data->off_mins); ?>"> 
                                        </div>
                                        <div class="col-md-2">
                                            <input name="off_active" value="1" class="make-switch" type="checkbox" data-on-text="啟用" data-off-text="停用"<?php echo e(($data->off_active == '1') ? ' checked' : ''); ?> />
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-md-3 control-label">非正確人員巡邏</label>
                                        <div class="col-md-7" style="display:none;">
                                            <input type="text" name="ng_user_mins" class="form-control" placeholder="請輸入非正確人員巡邏狀況的時間(分)" value="<?php echo e($data->ng_user_mins); ?>"> 
                                        </div>
                                        <div class="col-md-2">
                                            <input name="ng_user_active" value="1" class="make-switch" type="checkbox" data-on-text="啟用" data-off-text="停用"<?php echo e(($data->ng_user_active == '1') ? ' checked' : ''); ?> />
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-md-3 control-label">非正確巡邏地點</label>
                                        <div class="col-md-7" style="display:none;">
                                            <input type="text" name="ng_location_mins" class="form-control" placeholder="請輸入非正確巡邏地點狀況的時間(分)" value="<?php echo e($data->ng_location_mins); ?>"> 
                                        </div>
                                        <div class="col-md-2">
                                            <input name="ng_location_active" value="1" class="make-switch" type="checkbox" data-on-text="啟用" data-off-text="停用"<?php echo e(($data->ng_location_active == '1') ? ' checked' : ''); ?> />
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-md-3 control-label">非巡邏時巡邏</label>
                                        <div class="col-md-9">
                                            <input name="ng_time_active" value="1" class="make-switch" type="checkbox" data-on-text="啟用" data-off-text="停用"<?php echo e(($data->ng_time_active == '1') ? ' checked' : ''); ?> />
                                        </div>
                                    </div>   
                                    <div class="form-group">
                                        <label class="col-md-3 control-label">API檢查碼</label>
                                        <div class="col-md-9">
                                            <input name="api_token" value="<?php echo e($data->api_token); ?>" class="form-control" type="text" />
                                        </div>
                                    </div> 
                                    <input type="hidden" name="_token" value="<?php echo e(csrf_token()); ?>">
                                </div>
                                <div class="form-footer" style="text-align: right;">
                                    <button type="submit" class="btn green btn_query_submit" value="add">儲存</button>
                                </div>
                            </form>
						</div>
					</div>
					<!-- END EXAMPLE TABLE PORTLET-->
				</div>
			</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/jquery-validation/js/additional-methods.min.js')); ?>"></script>
    <script type="text/javascript" src="<?php echo e(asset('assets/global/plugins/datatables/media/js/jquery.dataTables.min.js')); ?>"></script>
    <script type="text/javascript" src="<?php echo e(asset('assets/global/plugins/datatables/plugins/bootstrap/dataTables.bootstrap.js')); ?>"></script>
    <script type="text/javascript" src="<?php echo e(asset('assets/global/plugins/moment.min.js')); ?>"></script>
    <script type="text/javascript" src="<?php echo e(asset('assets/global/plugins/bootstrap-daterangepicker/daterangepicker.min.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/bootbox/bootbox.min.js')); ?>"></script>
    <script type="text/javascript" src="<?php echo e(asset('assets/global/plugins/jquery-multi-select/js/jquery.multi-select.js')); ?>"></script>
    <script type="text/javascript" src="<?php echo e(asset('assets/global/plugins/select2/js/select2.full.js')); ?>"></script>
    <script src="<?php echo e(asset('assets/global/plugins/bootstrap-switch/js/bootstrap-switch.min.js')); ?>" type="text/javascript"></script>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('js_page_level'); ?>
    <script>
        $(document).ready(function(){
            $('#form_edit').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:{
                    location:{
                        required:true,
                        maxlength: 20
                    },
                    card_no:{
                        required:true,
                        maxlength: 20
                    },
                    sort:{
                        number: true
                    },
                    api_token:{
                        required: true
                    },
                },
                messages:{
                    location:{
                        required:'請輸入地點名稱',
                        maxlength: '地點名稱長度請勿超過20個字元'
                    },
                    card_no:{
                        required:'請輸入卡號',
                        maxlength: '卡號長度請勿超過20個字元'
                    },
                    sort:{
                        number: '排序ID請輸入數字格式'
                    },
                    api_token:{
                        required: '請輸入API檢查碼'
                    },
                },

                invalidHandler: function (event, validator) { //display error alert on form submit
                    $('#form_success_alert').hide();
                    $('#form_error_alert').show();
                    $('.modal').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 (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) {
                    $('#form_success_alert').show();
                    $('#form_error_alert').hide();
                    
                    //確認表單正確，Ajax送出
                    $.ajax({
                        type: 'POST',
                        dataType: 'json',
                        url: "<?php echo e(route('manage::patrol::update_config')); ?>",
                        data: $("#form_edit").serialize(),
                        success: function(sendback){
                            toastr['info']('修改成功');
                            window.location.reload();
                        },
                        error   : function ( data )
                        {
                            toastr['error']('修改失敗');
                        }
                    });
                }
            });
        });
    </script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layout.manage', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>