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

    <br/>
    <?php if( auth()->user()->create_ ): ?>
    <a href="<?php echo e(url('/invoice/index')); ?>"  class="btn" style="background-color:#2C4E71;color:#FFF;margin-left:10px">Create Invoice </a><br/><br/>
    <?php else: ?>
	    <span>&nbsp;&nbsp;</span>
    <?php endif; ?>

 
    
    <div class="card">
               
              <!-- /.card-header -->
              <div class="card-body">
                <table id="example1" class="table table-bordered table-striped">
                  <thead>
                  
                 <tr >
                  <th style="text-align:center;vertical-align: middle;background-color:#2C4E71;color:#FFF;border-color:#0000003c;border-width: 2px;"> Date    </th>

                  <th style="text-align:center;vertical-align: middle;background-color:#2C4E71;color:#FFF;border-color:#0000003c;border-width: 2px;"> #inv num   </th>
                  <th style="text-align:center;vertical-align: middle;background-color:#2C4E71;color:#FFF;border-color:#0000003c;border-width: 2px;"> Client    </th>

                  <th style="text-align:center;vertical-align: middle;background-color:#2C4E71;color:#FFF;border-color:#0000003c;border-width: 2px;"> Discount   </th>
                   
                  <th style="text-align:center;vertical-align: middle;background-color:#2C4E71;color:#FFF;border-color:#0000003c;border-width: 2px;"> Total Price   </th>
                  <th style="text-align:center;vertical-align: middle;background-color:#2C4E71;color:#FFF;border-color:#0000003c;border-width: 2px;"> Type   </th>
                  <th style="text-align:center;vertical-align: middle;background-color:#2C4E71;color:#FFF;border-color:#0000003c;border-width: 2px;"> Actions   </th>
                  

                 </tr>
                 </thead>
              <tbody>
                           
                <?php foreach( $invoices as $invoice ): ?>   
                 
                 

                 
                <tr>
                 
                <td style="text-align:center; word-break: break-word; font-weight:900;border-color:#0000003c;font-size:18px" ><?php echo e($invoice->created_at); ?></td>
                <td style="text-align:center; word-break: break-word; font-weight:900;border-color:#0000003c;font-size:18px" >#<?php echo e($invoice->id); ?></td>
                <td style="text-align:center; word-break: break-word; font-weight:900;border-color:#0000003c;font-size:18px" ><?php echo e($invoice->client->name); ?></td>

                <td style="text-align:center; word-break: break-word; font-weight:900;border-color:#0000003c;font-size:18px" ><?php echo e($invoice->discount); ?></td>
                 
                <td style="text-align:center; word-break: break-word; font-weight:900;border-color:#0000003c;font-size:18px" ><?php echo e($invoice->total_price); ?></td>
                <td style="text-align:center; word-break: break-word; font-weight:900;border-color:#0000003c;font-size:18px" >

                <?php if($invoice->confirmed == "confirmed"): ?>
                <img src='<?php echo e(asset("theme/dist/img/done.png")); ?>' alt="Egwaste"  style="height:40px"   />
                <?php elseif( $invoice->confirmed == NULL ): ?> 
                <img src='<?php echo e(asset("theme/dist/img/waiting.png")); ?>' alt="Egwaste"  style="height:40px"   />
                <?php else: ?> 
                <img src='<?php echo e(asset("theme/dist/img/delet.png")); ?>' alt="Egwaste"  style="height:40px"   />
                <?php endif; ?>
                </td>

                <td style="text-align:center; width:50px;word-break: break-word;" > 
                  
                  <a   href='<?php echo e(url("invoice/details/{$invoice->id}")); ?>'> Details</a>
                   
                  
                </td>

                </tr>
               <?php endforeach; ?>
                </tbody>
                </table>
                
                
                
                
                
                <div style="display: flex; justify-content: center; margin: 20px 0; font-family: Arial, sans-serif;">
    <div style="display: inline-flex; border-radius: 5px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.2);">
        <?php /* Previous Page Link */ ?>
        <?php if($invoices->currentPage() <= 1): ?>
            <span style="padding: 8px 12px; background: #f0f0f0; color: #aaa; border-right: 1px solid #ddd;">
                &laquo;
            </span>
        <?php else: ?>
            <a href="<?php echo e($invoices->url($invoices->currentPage() - 1)); ?>" style="padding: 8px 12px; background: #fff; color: #337ab7; text-decoration: none; border-right: 1px solid #ddd; transition: all 0.3s;">
                &laquo;
            </a>
        <?php endif; ?>

        <?php /* Pagination Elements */ ?>
        <?php 
            // Calculate start and end pages
            $current = $invoices->currentPage();
            $last = $invoices->lastPage();
            $start = max($current - 2, 1);
            $end = min($current + 2, $last);
            
            // Always show first page
            if ($start > 1) {
                $start = 1;
            }
         ?>

        <?php for($i = $start; $i <= $end; $i++): ?>
            <?php if($i == $invoices->currentPage()): ?>
                <span style="padding: 8px 12px; background: #337ab7; color: white; border-right: 1px solid #2a6496;">
                    <?php echo e($i); ?>

                </span>
            <?php else: ?>
                <a href="<?php echo e($invoices->url($i)); ?>" style="padding: 8px 12px; background: #fff; color: #337ab7; text-decoration: none; border-right: 1px solid #ddd; transition: all 0.3s;">
                    <?php echo e($i); ?>

                </a>
            <?php endif; ?>
        <?php endfor; ?>

        <?php /* Next Page Link */ ?>
        <?php if($invoices->currentPage() >= $invoices->lastPage()): ?>
            <span style="padding: 8px 12px; background: #f0f0f0; color: #aaa;">
                &raquo;
            </span>
        <?php else: ?>
            <a href="<?php echo e($invoices->url($invoices->currentPage() + 1)); ?>" style="padding: 8px 12px; background: #fff; color: #337ab7; text-decoration: none; transition: all 0.3s;">
                &raquo;
            </a>
        <?php endif; ?>
    </div>
</div>
                
                
                
              </div>
              <!-- /.card-body -->
            </div>  

<?php $__env->stopSection(); ?>

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