
    <div class="tab-pane fade  " id="deficit" role="tabpanel" aria-labelledby="deficit-tab">
        <div class="table-responsive">
            <table class="table display table-responsive-md card-table deficit-tab">
                <thead>
                    <tr>
                        <th>رقم الطرمبة</th>
                        <th>نوع الطرمبة</th>
                        <th>العامل</th>
                        <th>قراءةالصباح</th>
                        <th>قراءة المساء</th>
                        <th>فارق القراءات</th>
                        <th>المسحوب الفعلي</th>
                        <th>الفارق اليومي</th>
                        <th>العمليات</th>
                    </tr>
                </thead>
                <tbody>
                    <?php if(isset($deficits)): ?>
                        <?php $__currentLoopData = $deficits; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $deficit): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?> 
                        <?php if($deficit->type == -1): ?>
                        <tr class="odd" role="row">
                            <td>
                                <?php if(isset($deficit->reading->pump_id)): ?>
                                    <?php echo e($deficit->reading->pump_id); ?>

                                <?php endif; ?>
                            </td>
                            <td>
                                <?php if(isset($deficit->reading->pump->tank->type)): ?>
                                    <?php if($deficit->reading->pump->tank->type == 0): ?>
                                        بترول
                                    <?php else: ?>
                                        ديزل
                                    <?php endif; ?>
                                <?php endif; ?>
                            </td>
                            <td>
                                <?php if(isset($deficit->reading->employee->name)): ?>
                                    <?php echo e($deficit->reading->employee->name); ?>

                                <?php endif; ?>
                            </td>

                            <td>
                                <?php if(isset($deficit->reading->start_of_day_read)): ?>
                                    <?php echo e($deficit->reading->start_of_day_read); ?>

                                <?php endif; ?>
                            </td>
                            <td>
                                <?php if(isset($deficit->reading->end_of_day_read)): ?>
                                    <?php echo e($deficit->reading->end_of_day_read); ?>

                                <?php endif; ?>
                            </td>
                            <td>
                                
                                <?php if(isset($deficit->reading->start_of_day_read)): ?>
                                    <?php if(isset($deficit->reading->end_of_day_read)): ?>
                                        <?php if($deficit->reading->end_of_day_read - $deficit->reading->start_of_day_read > 0): ?>
                                            <span
                                                style="color: green"><?php echo e($deficit->reading->end_of_day_read - $deficit->reading->start_of_day_read); ?></span>
                                        <?php else: ?>
                                            <span
                                                style="color: red"><?php echo e($deficit->reading->end_of_day_read - $deficit->reading->start_of_day_read); ?></span>
                                        <?php endif; ?>
                                    <?php endif; ?>
                                <?php endif; ?>
                            </td>
                            <td>
                            <?php if(isset($deficit->daily_draw)): ?>
                                <?php echo e($deficit->daily_draw); ?>

                            <?php endif; ?>

                            </td>
                            <td>
                                <?php if(isset($deficit->daily_draw )): ?>
                                <?php if(isset( $deficit->reading->end_of_day_read )): ?>
                                <?php if(isset($deficit->reading->start_of_day_read)): ?>
                                    
                                <?php if($deficit->daily_draw - ($deficit->reading->end_of_day_read - $deficit->reading->start_of_day_read) > 0): ?>
                               <span style="color: green"><?php echo e($deficit->daily_draw - ($deficit->reading->end_of_day_read - $deficit->reading->start_of_day_read)); ?></span>
                                <?php elseif($deficit->daily_draw - ($deficit->reading->end_of_day_read - $deficit->reading->start_of_day_read) < 0): ?>
                                     <span
                                            style="color: red"><?php echo e($deficit->daily_draw - ($deficit->reading->end_of_day_read - $deficit->reading->start_of_day_read)); ?></span>
                                <?php else: ?>
                              <span
                                    style="color: rgb(11, 10, 10)"><?php echo e($deficit->daily_draw - ($deficit->reading->end_of_day_read - $deficit->reading->start_of_day_read)); ?></span>
                                <?php endif; ?>
                            </td>
                            <td>
                                <div class="dropdown dropstart">
                                    <a href="javascript:void(0);" class="btn-link" data-bs-toggle="dropdown" aria-expanded="false">
                                        <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
                                            <path d="M12 13C12.5523 13 13 12.5523 13 12C13 11.4477 12.5523 11 12 11C11.4477 11 11 11.4477 11 12C11 12.5523 11.4477 13 12 13Z" stroke="#575757" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>
                                            <path d="M12 6C12.5523 6 13 5.55228 13 5C13 4.44772 12.5523 4 12 4C11.4477 4 11 4.44772 11 5C11 5.55228 11.4477 6 12 6Z" stroke="#575757" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>
                                            <path d="M12 20C12.5523 20 13 19.5523 13 19C13 18.4477 12.5523 18 12 18C11.4477 18 11 18.4477 11 19C11 19.5523 11.4477 20 12 20Z" stroke="#575757" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>
                                        </svg>
                                    </a>
                                    <div class="dropdown-menu">
                                        <?php if($deficit->daily_draw - ($deficit->reading->end_of_day_read - $deficit->reading->start_of_day_read)!=0): ?>
                                        <a
                                        href="<?php echo e(route('new_deficit_surpluses', ['id' => $deficit->reading->id, 'quantity' => $deficit->daily_draw - ($deficit->reading->end_of_day_read - $deficit->reading->start_of_day_read),'deficit_statues'=>$deficit->status])); ?>">
                                        <button type="button" value=""  class="edit dropdown-item" href="edit all-details.html"><i class="bi bi-pencil-square text-success ms-3"></i>معالجة </button>
                                         </a>
                                        <?php else: ?>
                                        <a
                                        href="<?php echo e(route('new_deficit_surpluses', ['id' => $deficit->reading->id, 'quantity' => $deficit->daily_draw - ($deficit->reading->end_of_day_read - $deficit->reading->start_of_day_read),'deficit_statues'=>$deficit->status])); ?>">
                                        <button type="button" value=""  class="edit dropdown-item" href="edit all-details.html"><i class="bi bi-pencil-square text-success ms-3"></i>عرض التسوية </button>
                                         </a>
                                        <?php endif; ?>
                                        

                                    </div>
                                </div>
                            </td>
                        </tr>
                            <?php endif; ?>
                            <?php endif; ?>
                            <?php endif; ?>
                        <?php endif; ?>                           
                          
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    <?php endif; ?>
                    <tr>
                        <td>الاجمالي</td>
                        <td>-</td>
                        <td>-</td>
                        <td>
                        
                            
                        </td>
                        <td>
                         
                            
                        </td>
                        <td>
                            <?php
                                $totalReadQuantity = 0;
                                if (isset($deficits)) {
                                    foreach ($deficits as $deficit) {
                                        if(isset($deficit->reading)){
                                            $totalReadQuantity += $deficit->reading->end_of_day_read - $deficit->reading->start_of_day_read;
                                        }
                                    }
                                }
                            ?>
            
                            <?php if($totalReadQuantity > 0): ?>
                                <span style="color: green"><?php echo e($totalReadQuantity); ?></span>
                            <?php else: ?>
                                <span style="color: red"><?php echo e($totalReadQuantity); ?></span>
                            <?php endif; ?>
                        </td>
                        <td>
                            
                             <?php
                                $drawsTotalQuantity = 0;
                                
                               if (isset($deficits)) {
                                    foreach ($deficits as $deficit) {
                                        if(isset($deficit->daily_draw)){
                                        $drawsTotalQuantity += $deficit->daily_draw;
                                        }
                                    }
                                }
                            ?>
                            <?php echo e($drawsTotalQuantity); ?> 
                        </td>
                        <td>  
                            <?php if($drawsTotalQuantity - $totalReadQuantity > 0): ?>
                                <span
                                    style="color: green"><?php echo e($drawsTotalQuantity - $totalReadQuantity); ?></span>
                            <?php else: ?>
                                <span
                                    style="color: red"><?php echo e($drawsTotalQuantity - $totalReadQuantity); ?></span>
                            <?php endif; ?>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div><?php /**PATH C:\Users\Nasser\Desktop\petrol_store\resources\views/deficit_surpluses/tables/deficit.blade.php ENDPATH**/ ?>