@extends('backend.layouts.app')



@section('content')

<script>
    routeFormIndex = '{!! route("admin.wysiwyg.form.index") !!}';
    routeFormStore = '{!! route("admin.wysiwyg.form.store") !!}';
    routeFormUpdate = '{!! route("admin.wysiwyg.form.update",'itemid') !!}';
    routeFormDestroy = '{!! route("admin.wysiwyg.form.destroy",'itemid') !!}';     
</script>
            
{{ style('modules/wysiwyg/css/backend/form.css') }}
{{ script('modules/wysiwyg/js/backend/form.js') }}

<!-- Laravel Javascript Validation -->
<!-- Vendor JS/CSS already loaded on master layout -->
<!-- <script type="text/javascript" src="{{ asset('vendor/jsvalidation/js/jsvalidation.js')}}"></script>  -->
{!! JsValidator::formRequest('Rvsitebuilder\Wysiwyg\Http\Requests\formStoreRequest', '#create_item_form'); !!}
{!! JsValidator::formRequest('Rvsitebuilder\Wysiwyg\Http\Requests\formUpdateRequest', '#update_item_form'); !!}

<!-- *************************************************************** -->


<h2>Item LIST (AJAX)</h2>
<button class="uk-button create-post-modal" data-uk-modal="{target:'#createItemModal'}">CREATE ITEM</button> <br/><br/>

<table class="table table-bordered" id="items-table">
	<thead>

		<tr>
			<th>form_owner_id</th>
<th>form_mail_content</th>
<th>form_field_data</th>
<th>form_design_data</th>
<th>action_type</th>
<th>external_url</th>
<th>send_to_user</th>
<th>subject</th>
<th>sender_email</th>
<th>sender_name</th>
<th>reply_to_email</th>
<th>send_to_admin</th>
<th>actions</th>

        </tr>

        </thead>

        <tfoot>

        <tr>
<th>form_owner_id</th>
<th>form_mail_content</th>
<th>form_field_data</th>
<th>form_design_data</th>
<th>action_type</th>
<th>external_url</th>
<th>send_to_user</th>
<th>subject</th>
<th>sender_email</th>
<th>sender_name</th>
<th>reply_to_email</th>
<th>send_to_admin</th>
<th>actions</th>

        </tr>

        </tfoot>

        <tbody>

        @if (isset($forms)) @foreach ($forms as $form)
        <tr id="tr_{{ $form->id }}">
                <td class="item_form_owner_id">{{ $form->form_owner_id }}</td>
        <td class="item_form_mail_content">{{ $form->form_mail_content }}</td>
        <td class="item_form_field_data">{{ $form->form_field_data }}</td>
        <td class="item_form_design_data">{{ $form->form_design_data }}</td>
        <td class="item_action_type">{{ $form->action_type }}</td>
        <td class="item_external_url">{{ $form->external_url }}</td>
        <td class="item_send_to_user">{{ $form->send_to_user }}</td>
        <td class="item_subject">{{ $form->subject }}</td>
        <td class="item_sender_email">{{ $form->sender_email }}</td>
        <td class="item_sender_name">{{ $form->sender_name }}</td>
        <td class="item_reply_to_email">{{ $form->reply_to_email }}</td>
        <td class="item_send_to_admin">{{ $form->send_to_admin }}</td>
        <td>
        <button class="uk-button edit-post-modal" data-uk-modal="{target:'#editItemModal'}" data-id="{{ $form->id }}">edit</button>
        <button type="button" class="uk-button" data-id="{{ $form->id }}" onclick="UIkit.modal.confirm('Are you sure to delete <b>{{ $form->id }}</b> ?' , function(){ crud_post_delete('{{ $form->id }}'); });">x</button>
        </td>

        </tr>

		@endforeach @endif
	</tbody>
</table>

<!-- Create Item Modal -->
<div id="createItemModal" class="uk-modal" aria-hidden="true" style="display: none; overflow-y: scroll;">
    <div class="uk-modal-dialog">
        <button type="button" class="uk-modal-close uk-close"></button>
        <div class="uk-modal-header">
        <h2>CREATE Item (AJAX)</h2>
            @include('includes.partials.ajax_messages')
                    
            <div id="create-item-raise-message">
                    
                <div class="alert alert-danger">
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                    error msg
                    
                </div>
            
                <div class="alert alert-success">
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                    success msg
                </div>
            
            </div>    
            
        
        
        </div>        
        <p>     
    {!! Form::open(['route' => ['admin.wysiwyg.form.store'], 'id' => 'create_item_form', 'method' => 'post']) !!}  
    @include('wysiwyg::backend.form.includes.formmodel')   
        </p>
        <div class="uk-modal-footer uk-text-right">     
            <button type="button" class="uk-button uk-modal-close">Cancel</button>
            <button type="button" id="crud-submit-create-btn" class="uk-button uk-button-primary crud-submit-create">Save</button>
        </div>
    {!! Form::close() !!}
    </div>
</div>

<!-- Edit Item Modal -->
<div id="editItemModal" class="uk-modal" aria-hidden="true" style="display: none; overflow-y: scroll;">
    <div class="uk-modal-dialog">
        <button type="button" class="uk-modal-close uk-close"></button>
        <div class="uk-modal-header">
        <h2>Update Item (AJAX)</h2>
        @include('includes.partials.ajax_messages')
        
            <div id="create-item-raise-message">
                    
                <div class="alert alert-danger">
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                    error msg
                    
                </div>
            
                <div class="alert alert-success">
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                    success msg
                </div>
            
            </div>        
        
        </div>        
        <p>
    {!! Form::open(['route' => ['admin.wysiwyg.form.update','itemid'],'id' => 'update_item_form', 'method' => 'post']) !!} 
    @include('wysiwyg::backend.form.includes.formmodel')
        </p>
        <div class="uk-modal-footer uk-text-right">     
        <button type="button" class="uk-button uk-modal-close">Cancel</button>
            <button type="button" id="crud-submit-update-btn" class="uk-button uk-button-primary crud-submit-update">Update</button>
        </div>
    {!! Form::close() !!}
    </div>
</div>

@stop