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


<?php
$PermissionsAddAccountType = App\Models\PermissionsUserModel::getPermission('Add Account', Auth::user()->id);
$PermissionsEditAccountType = App\Models\PermissionsUserModel::getPermission('Edit Account', Auth::user()->id);
$PermissionsDeleteAccountType = App\Models\PermissionsUserModel::getPermission('Delete Account', Auth::user()->id);
?>

                    <!-- Page Heading -->
                    <div class="d-sm-flex align-items-center justify-content-between mb-4">
                        <h1 class="h3 mb-0 text-gray-800">Account Types</h1>
                      </div>

                      
                      <div class="row">

                      <!-- Donut Chart -->
                      <div class="col-xl-4 col-lg-5">
                            <div class="card shadow mb-4">
                                <!-- Card Header - Dropdown -->
                                <div class="card-header py-3">
                                    <h6 class="m-0 font-weight-bold text-primary"  id="formHeader">Add Account Type</h6>
                                </div>
                                <!-- Card Body -->
                                <div class="card-body">
                                <?php if(session('success')): ?>
                            <div class="alert alert-success" id="successMessage"  style="margin: 20px;">
                                <?php echo e(session('success')); ?>

                            </div>
                        <?php endif; ?>
                      
                        <?php if($errors->any()): ?>

                                    <div class="form-group"  id="successMessage"  style="margin: 20px;">
                                        <div class="card bg-warning text-white shadow">
                                            <div class="card-body">
                                        
                                                <?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                <div style="color: red; "><?php echo e($error); ?></div>
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        
                                            </div>
                                        </div>
                                    </div>
                                    <?php endif; ?>

                            <?php if(!empty($PermissionsAddAccountType)): ?>
                            
                            <form class="card-body" action="<?php echo e(route('addAccountType')); ?>" method="post" id="accountTypeForm">
                            <?php echo csrf_field(); ?>
                            <input type="hidden" id="accountId" name="id" value="">
                                <div class="form-group">
                                        <input type="text" class="form-control form-control-user" id="name" placeholder="Account Type" name="name"  value="<?php echo e(old('name')); ?>" required>
                                    
                                </div>
                               
                               <div style="display: flex;">
                               <input type="submit" style="width: 100px;height: 40px; margin-right: 10px; margin-top: 6px" value="Create" class="btn btn-primary btn-user btn-block"  id="submitButton"/>

                                <input style="width: 100px;" onclick="refreshAccountType('', '')"  type="reset" value="Refresh" class="btn btn-secondary btn-user btn-block"  onclick="hideMessages()"/>
                                    
                               </div>
                                
                                <hr>
                             </form>
                             <?php endif; ?>

                                </div>
                            </div>
                        </div>
                        <div class="col-xl-8 col-lg-7">

                            <div class="card shadow mb-4">
                                <div class="card-header py-3">
                                    <h6 class="m-0 font-weight-bold text-primary">Available Account Types</h6>
                                </div>
                                <div class="card-body">
                                <div class="table-responsive">
                                <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
                                    <thead>
                                        <tr>
                                         
                                            <th>Account Type</th> 
                                            <th>Action</th>
                                        </tr>
                                    </thead>
                                    <tfoot>
                                        <tr>
                                           
                                            <th>Account Type</th> 
                                            <th>Action</th>

                                        </tr>
                                    </tfoot>
                                    <tbody>
                                       
                                        
                                    <?php $__currentLoopData = $accounts; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $account): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <tr>
                                        
                                                <td><?php echo e($account->Name); ?></td>
                                               
                                                <td style="justify-content: center; align-items: center;">
                                                <?php if(!empty($PermissionsEditAccountType)): ?>

                                                    <a href="" class="btn btn-primary btn-circle" onclick="editAccountType(event,'<?php echo e($account->ID); ?>', '<?php echo e($account->Name); ?>')">
                                                    <i class="fas fa-edit"></i>
                                                    </a>
                                                    <?php endif; ?>

                                                    <?php if(!empty($PermissionsDeleteAccountType)): ?>

                                                    <a href="<?php echo e(route('deleteAccountTypes', ['id' => $account->ID])); ?>" class="btn btn-danger btn-circle"  onclick="return confirmDelete('<?php echo e($account->Name); ?>');">
                                                        <i class="fas fa-trash"></i>
                                                    </a>
                                                    <?php endif; ?>
                                                </td>
                                                
                                            </tr>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                                           
                                    </tbody>
                                </table>
                            </div>
                                
                        </div>
                            
                    </div>


                           

                        
                </div>

                        
                        
            </div>

                        <script>
                             function editAccountType(event,id, name) 
                             {
                                event.preventDefault();
                                document.getElementById('accountId').value = id;
                                document.getElementById('name').value = name;
                                document.getElementById('formHeader').innerText = 'Edit Account Type';
                                document.getElementById('submitButton').value = 'Update';
                                document.getElementById('accountTypeForm').action = '<?php echo e(route("editAccountType")); ?>';
                            }
                
                            function refreshAccountType(id, name) 
                            {
                                document.getElementById('accountId').value = id;
                                document.getElementById('name').value = name;
                                document.getElementById('formHeader').innerText = 'Add Account Type';
                                document.getElementById('submitButton').value = 'Create';
                                document.getElementById('accountTypeForm').action = '<?php echo e(route("addAccountType")); ?>';
                                hideMessages();
                            
                            }

                            function confirmDelete(Name) {
                                return confirm("Are you sure you want to delete the Account Type: " + Name + "?");
                            }


                
                </script>

                    
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.nav', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/pinetopsco/public_html/re.pro/resources/views//AccountTypes.blade.php ENDPATH**/ ?>