<?php
$statues = json_decode(MEMBER_STATUS);
?>
<?= $this->element('page_top', array('title' => __('Edit Report Format'), 'permissions' => $user_permission)); ?>

<div class="box box-primary">
    <!-- /.box-header -->
    <div class="box-body">
        <div class="row">
            <div class="col-md-12">
                <?= $this->Form->create($report_format, ['id' => 'report_format_form', 'class'=> 'input-form-section']); ?>

                <div id="basic_info_div">

                    <div class="col-md-9 col-sm-9 col-xs-9 text-left">
                        <div class="form-group row <?php if(isset($errors['report_format_type_id'])){ echo 'has-error';} ?>">
                            <label class="control-label col-lg-3 required">Report Format Type</label>
                            <div class="col-lg-9">
                                <?php echo $this->Form->control('report_format_type_id', ['label' =>false,['class' => 'required' ], 'type' => 'select' , 'options'=>$report_format_types, 'empty' => 'Select One', 'default'=> $report_format->report_format_type_id ,'class' => 'form-control', 'required' => false]); ?>
                                <span class="help-block text-center">
                                                        <?php
                                                        if (isset($errors['report_format_type_id']['_empty'])) {
                                                            echo $errors['report_format_type_id']['_empty'];
                                                        }
                                                        ?>
                                        </span>
                            </div>
                        </div>
                        <div class="form-group row <?php if(isset($errors['name'])){ echo 'has-error';} ?>">
                            <label class="control-label col-lg-3 required">Name</label>
                            <div class="col-lg-9">
                                <?php echo $this->Form->input('name', ['label' =>false,['class' => 'required' ], 'placeholder'=>'Report Type Name', 'class' => 'form-control', 'required' => false]); ?>
                                <span class="help-block text-center">
                                                        <?php
                                                        if (isset($errors['name']['_empty'])) {
                                                            echo $errors['name']['_empty'];
                                                        }
                                                        ?>
                                        </span>
                            </div>
                        </div>
                        <div class="form-group row <?php if(isset($errors['content'])){ echo 'has-error';} ?>">
                            <label class="control-label col-lg-3 required">Content</label>
                            <div class="col-lg-9">
                            <?= $this->Form->textarea('content', ['placeholder' => __('Content'),'label'=>false,'style'=>'height:300px','class' => 'form-control editable required', 'type' => 'text','id'=>'content','required' => false,'name' => 'content' ]); ?>
                            <span class="help-block text-center">
                                                        <?php
                                                        if (isset($errors['content']['_empty'])) {
                                                            echo $errors['content']['_empty'];
                                                        }
                                                        ?>
                            </span>
                            </div>

                        </div>
                        <div class="form-group row <?php if(isset($errors['status'])){ echo 'has-error';} ?>">
                            <label class="control-label col-lg-3 required">Status</label>
                            <div class="col-lg-9">
                                <?php echo $this->Form->control('status', ['label' =>false,['class' => 'required' ], 'type' => 'select' , 'options'=>$statues, 'empty' => 'Select One', 'default'=> $report_format->status ,'class' => 'form-control', 'required' => false]); ?>
                                <span class="help-block text-center">
                                                        <?php
                                                        if (isset($errors['status']['_empty'])) {
                                                            echo $errors['status']['_empty'];
                                                        }
                                                        ?>
                                        </span>
                            </div>
                        </div>

                        <div class="form-group row ">
                            <label class="control-label col-lg-3"></label>
                            <div class="col-lg-9">
                                <?= $this->Form->button(__('Submit'), ['class' => 'btn btn-success tab3Save pull-left btn-grid btn-flat','id'=>'submit']) ?>
                                <a href="<?php echo $this->Url->build('/report-format'); ?>"  class="btn btn-default tab3Save pull-left btn-grid btn-flat btn-orange-color" id="default-btn">
                                    <?php echo __('Back'); ?>
                                </a>
                            </div>
                        </div>

                    </div>

                    <div class="col-md-3">
                        <?php echo $this->element('agreement_variable') ?>
                    </div>

                    <!-- /.form-group -->
                </div>
                <?= $this->Form->end() ?>
                <!-- /.form-group -->


            </div>
            <!-- /.row -->
        </div>
        <!-- /.box-body -->

    </div>
</div>
<?php echo $this->element('tinymce_js'); ?>

<script>

    $('#report_format_form').validate({
        rules:{
            'report_format_type_id' : 'required',
            'name':'required',
            'content':'required',
            'status':'required'
        },
        messages: {
            'name':{
                required: "Please enter report format title"
            },
            'report_format_type_id':{
                required: "Please select report format  type"
            },
            'content':{
                required: "Please enter report content"
            },
            'status':{
                required: "Please select status"
            }

        },
        highlight: function(element) {
            $(element).parent().addClass("has-error");
        },
        submitHandler: function(form) {
            form.submit();
        }
    });

</script>

