<?php /* DO NOT GENERATE */ ?>

@extends('admin.pros.view')
@section('content-inner')

<div class="pb-3">

    <h5 class='my-3 d-flex stag-heading stag-heading-sub'>
        <div>Note Templates</div>
        <div class="ml-auto">
            <a class="btn btn-primary btn-sm ml-2" up-modal=".form-contents" up-preload up-delay="25" up-width="800" up-history="false" href="{{route('pros_SINGLE-ACTION_add_new_note_template_pro', ['uid' => $record->uid])}}?optimised=1"><i class='fa fa-plus-circle' aria-hidden='true'></i> Add New</a>
        </div>
    </h5>

    <div class="table-responsive p-0 bg-white border stag-table stag-table-sub">
        <table class="table table-hover text-nowrap">
            <thead>
                <tr>
                    <th>&nbsp;</th>
                    <th>NoteTemplate</th>
                    <th></th>
                    <th></th>
                </tr>
            </thead>
            <tbody class="sortable" data-url="/api/noteTemplatePro/sort">
                <?php
                if($subRecords && count($subRecords)) {
                    $subRecords = $subRecords->sortBy('position_index');
                }
                ?>
                @foreach($subRecords as $subRecord)
                    @if(!$subRecord->is_removed)
                        <tr data-uid="{{$subRecord->uid}}">
                            <td><a href=""><i class="fas fa-share-square"></i></a></td>
                            <td><?= value_from_rs($result_note_templates, 'title', [['id', '=', $subRecord->note_template_id],], 'all'); ?></td>
                            <td><a href=""><i class="fa fa-bars"></i></a></td>
                            <td><a href="#" onclick="return deleteNoteTemplate('{{$subRecord->uid}}')" class="text-danger">Remove</a></td>
                        </tr>
                    @endif
                @endforeach
            </tbody>
        </table>
    </div>

</div>

<script>
    function deleteNoteTemplate(_uid) {
        if(confirm('Are you sure?')) {
            $.post('/api/noteTemplatePro/remove', {
                uid: _uid
            }, function(_data) {
                if(_data && _data.success) {
                    window.location.reload();
                }
                else if(_data && _data.message) {
                    toastr.error(_data.message)
                }
            }, 'json');
        }
    }
</script>

@endsection
