<?php $__env->startSection('navBar'); ?>
    <?php echo $__env->make('layouts.navBar', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('mainMenu'); ?>
    <?php echo $__env->make('layouts.mainMenu', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>

    <div id="delete-confirmation" class="modal modal-alert modal-danger fade">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <i class="fa fa-times-circle"></i>
                </div>
                <div class="modal-title" id="confirmDeletionTitle"></div>
                <div class="modal-body">Confirm to delete this custom type</div>
                <div class="modal-footer">
                    <a id="confirmDeletionLink"
                       class="btn btn-danger" data-dismiss="modal">Confirm Deletion</a>
                </div>
            </div>
            <!-- / .modal-content -->
        </div>
        <!-- / .modal-dialog -->
    </div> <!-- / .modal -->

    <div id="addCustomTypeForm" class="modal fade" tabindex="-1" role="dialog" style="display: none;">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h4 class="modal-title" id="myModalLabel">Add New Custom Type</h4>
                </div>
                <div class="modal-body">
                    <form action="<?php echo e(URL::action('CustomTypeController@uiAdd')); ?>" class="form-horizontal"
                          method="post">
                        <div class="panel-body">
                            <div class="row">
                                <div class="col-xs-12">
                                    <input type="text" name="parent" placeholder="Parent Type"
                                           class="form-control form-group-margin"
                                            >
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-xs-12">
                                    <input type="text" name="type" placeholder="Type"
                                           class="form-control form-group-margin"
                                           required="">
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-xs-12">
                                    <input type="text" name="value" placeholder="Value"
                                           class="form-control form-group-margin"
                                           required="">
                                </div>
                            </div>
                            <input type="hidden" name="_token" value="<?php echo e(csrf_token()); ?>"/>
                        </div>
                        <div class="panel-footer text-right">
                            <button class="btn btn-primary">Add Custom Type</button>
                        </div>
                    </form>
                </div>
                <!-- / .modal-body -->
            </div>
            <!-- / .modal-content -->
        </div>
        <!-- / .modal-dialog -->
    </div> <!-- /.modal -->
    <!-- / Modal -->

    <div class="row">
        <div class="col-xs-12">
            <div class="table-bordered">
                <div class="table-header">
                    <div class="table-caption">
                        Custom Types List
                        <a class="badge" data-toggle="modal"
                           data-target="#addCustomTypeForm">
                            <i class="fa fa-plus"></i>&nbsp;Add
                        </a>
                    </div>
                </div>

                <div class="panel">
                    <div class="panel-body">
                        <div class="panel-group" id="accordion-customType">
                            <?php foreach($customTypes as $customType): ?>
                                <div class="panel">
                                    <div class="panel-heading">
                                        <a class="accordion-toggle collapsed" data-toggle="collapse"
                                           data-parent="#accordion-customType" href="#customTypeContent<?php echo e($customType['id']); ?>">
                                            <?php echo e($customType['type']); ?>

                                        </a>
                                    </div>
                                    <!-- / .panel-heading -->
                                    <div id="customTypeContent<?php echo e($customType['id']); ?>" class="panel-collapse collapse">
                                        <div class="panel-body">
                                            <table class="table table-bordered">
                                                <thead>
                                                <tr>
                                                    <th><i class="menu-icon fa fa-pencil"></i></th>
                                                    <th>Parent</th>
                                                    <th>Type</th>
                                                    <th>Value</th>
                                                </tr>
                                                </thead>
                                                <tbody>
                                                <?php foreach($customTypeValues as $customTypeValue): ?>
                                                    <?php if($customTypeValue['type']==$customType['type']): ?>
                                                    <form method="post" id="<?php echo e('UpdateCustomTypeForm'.$customTypeValue['id']); ?>"
                                                          action="<?php echo e(URL::action('CustomTypeController@uiUpdate')); ?>"
                                                          class="form-horizontal">
                                                        <tr>
                                                            <td>
                                                                <button class="btn btn-xs btn-rounded" type="submit" data-toggle="tooltip"
                                                                        data-replacement="bottom" title="Update"><i class="fa fa-edit"></i>
                                                                </button>
                                                                <a href="#delete-confirmation"
                                                                   onclick="javascript:confirmDeletionInitPost('<?php echo e(URL::action('CustomTypeController@uiDelete')); ?>', '<?php echo e($customTypeValue["id"]); ?>', '<?php echo e($customTypeValue["value"]); ?>', '<?php echo e(csrf_token()); ?>', refreshCustomTypes)"
                                                                   class="btn btn-sm btn-rounded" data-toggle="modal" title="Delete"><i
                                                                            class="fa fa-minus"></i></a>
                                                                <input type="hidden" name="_token" value="<?php echo e(csrf_token()); ?>"/>
                                                                <input type="hidden" name="id" value="<?php echo e($customTypeValue['id']); ?>"/>
                                                            </td>
                                                            <td>
                                                                <input type="text" class="form-control" name="parent"
                                                                       value="<?php echo e($customTypeValue['parent']); ?>"/>
                                                            </td>
                                                            <td>
                                                                <input type="text" class="form-control" name="type"
                                                                       value="<?php echo e($customTypeValue['type']); ?>"/>
                                                            </td>
                                                            <td>
                                                                <input type="text" class="form-control" rows="1" name="value"
                                                                       placeholder="Description"
                                                                       value="<?php echo e($customTypeValue['value']); ?>"/>
                                                            </td>
                                                        </tr>
                                                    </form>
                                                    <?php endif; ?>
                                                <?php endforeach; ?>
                                                </tbody>
                                            </table>
                                        </div>
                                        <!-- / .panel-body -->
                                    </div>
                                    <!-- / .collapse -->
                                </div>
                                <!-- / .panel -->
                            <?php endforeach; ?>
                        </div>
                        <!-- / .panel-group -->

                    </div>
                </div>
            </div>
        </div>
    </div>

    <script type="text/javascript">
        function refreshCustomTypes() {
            window.location = '<?php echo e(URL::action('CustomTypeController@uiIndex')); ?>';
        }
    </script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.master', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>