

<?php $__env->startSection('title'); ?>
Cash Book
<?php $__env->stopSection(); ?>
<?php $__env->startSection('content'); ?>               
<?php
$PermissionsAddCashBook = App\Models\PermissionsUserModel::getPermission('Add Cash Bookr', Auth::user()->id);
$PermissionsEditCashBook = App\Models\PermissionsUserModel::getPermission('Edit Cash Book', Auth::user()->id);
$PermissionsDeleteCashBook = App\Models\PermissionsUserModel::getPermission('Delete Cash Book', Auth::user()->id);
?>

<div class="d-sm-flex align-items-center justify-content-between mb-4">
                        <h1 class="h3 mb-0 text-gray-800">Cash Book</h1>
                      </div>

                  
                    <div class="card shadow mb-4">
                        <div class="card-header py-3">
                            <h6 class="m-0 font-weight-bold text-primary"   id="formHeader">Add Cash Book</h6>
                        </div>
                        <?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($PermissionsAddCashBook)): ?>
                            <form class="card-body" action="<?php echo e(route('addcashbook')); ?>" method="post"  id="accountTypeForm">
                            <?php echo csrf_field(); ?>
                            <input type="hidden" id="accountId" name="id" value="">
                                
                                <div class="form-group row">
                                    <div class="col-sm-6 mb-3 mb-sm-0">
                                    <select class="form-control form-control-user" id="account" name="account"  value="<?php echo e(old('account')); ?>"  required>
                                        <option value="" disabled selected>Select Account</option>

                                        <?php $__currentLoopData = $Accounts; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $Account): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        
                                        <option value="<?php echo e($Account->AccCode); ?>"><?php echo e($Account->AccCode.'/'.$Account->AccName); ?></option>
                                          
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </select>
                                    </div>
                                    <div class="col-sm-6">
                                        <input type="text" class="form-control form-control-user" id="name" placeholder="Cash Book Name" name="name"  value="<?php echo e(old('name')); ?>" required >
                                    </div>
                                    
                                </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 class="card-body">
                            <div class="table-responsive">
                                <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
                                    <thead>
                                        <tr>
                                            <th>CashBook Code</th>
                                            <th>CashBook Name</th>
                                            <th>Action</th>
                                         
                                        </tr>
                                    </thead>
                                    <tfoot>
                                        <tr>
                                        
                                        
                                        <th>CashBook Code</th>
                                            <th>CashBook Name</th>
                                            <th>Action</th>
                                            

                                        </tr>
                                    </tfoot>
                                    <tbody>
                                      
                                    <?php $__currentLoopData = $cashbooks; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $cashbook): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <tr>
                                        
                                                <td><?php echo e($cashbook->AccCode); ?></td> 
                                                <td><?php echo e($cashbook->Name); ?></td>
                                                <td style="justify-content: center; align-items: center;">
                                                  <?php if(!empty($PermissionsEditCashBook)): ?>
                                                  <a href="" onclick="editAccountType(event,'<?php echo e($cashbook->ID); ?>', '<?php echo e($cashbook->AccCode); ?>', '<?php echo e($cashbook->Name); ?>')"  class="btn btn-primary btn-circle" >
                                                  <i class="fas fa-edit"></i>
                                                  </a>
                                                  <?php endif; ?>
                                                  <?php if(!empty($PermissionsDeleteCashBook)): ?>
                                                  <a href="<?php echo e(route('deletecashbook',['id'=>$cashbook->ID])); ?>" class="btn btn-danger btn-circle"   onclick="return confirmDelete('<?php echo e($cashbook->Name); ?>');" >
                                                      <i class="fas fa-trash"></i>
                                                  </a>
                                                  <?php endif; ?>
                                              </td>
                                            </tr>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

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

                    <script>
                             function editAccountType(event, id,AccCode, Name) 
                             {
                                event.preventDefault();
                                document.getElementById('accountId').value = id;
                                document.getElementById('account').value = AccCode;
                                document.getElementById('name').value = Name;
                                document.getElementById('formHeader').innerText = 'Edit Cash Book';
                                document.getElementById('submitButton').value = 'Update';
                                document.getElementById('accountTypeForm').action = '<?php echo e(route("editcashbook")); ?>';
                            }
                
                            function refreshAccountType( id,AccCode, Name) 
                            {
                                document.getElementById('accountId').value = id;
                                document.getElementById('account').value = AccCode;
                                document.getElementById('name').value = Name;
                                document.getElementById('formHeader').innerText = 'Add Cash Book';
                                document.getElementById('submitButton').value = 'Create';
                                document.getElementById('accountTypeForm').action = '<?php echo e(route("addcashbook")); ?>';
                                hideMessages();
                            
                            }

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


                
                </script>

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