

<?php $__env->startSection('content'); ?>
<!-- Content wrapper scroll start -->
<div class="content-wrapper-scroll">

<!-- Content wrapper start -->
<div class="content-wrapper">

<?php if($user_data->id == auth()->user()->id): ?>
<div>
    <h4><strong></strong>
HELLO <?= @strtoupper(auth()->user()->name )?>! YOUR SALES REPORT
</div>
<?php else: ?>
<div>
    <h4><strong></strong> DAILY SALES REPORT  FOR - <?php echo e(@strtoupper($user_data -> name)); ?>, Category Type: <?php echo e(strtoupper($user_data -> sales_person_category)); ?></h4>
</div>
<?php endif; ?>
        <!-- Row start -->
        <div class="row gutters">
            <div class="col-xl-4 col-lg-4 col-md-4 col-sm-6 col-12">
                <div class="stats-tile">
                    <div class="sale-icon">
                        <i class="icon-shopping-bag1"></i>
                    </div>
                    <?php if($user_data -> sales_person_category == "Delivery"): ?>
                    <div class="sale-details">
                        <h2><?php echo e(empty($app->currency) ? "GHS" : $app->currency); ?><?php echo number_format($branch_total_general - $deliveriesToday, 2); ?></h2>
                        <p><strong>Net Sales</strong></p>
                    </div>
                    <?php else: ?>
                    <div class="sale-details">
                        <h2><?php echo e(empty($app->currency) ? "GHS" : $app->currency); ?><?php echo number_format($branch_total_general, 2); ?></h2>
                        <p><strong>Net Sales</strong></p>
                    </div>
                    <?php endif; ?>
                </div>
            </div>
            <div class="col-xl-4 col-lg-4 col-md-4 col-sm-6 col-12">
                <div class="stats-tile">
                    <div class="sale-icon">
                        <i class="icon-shopping-bag1"></i>
                    </div>
                    <div class="sale-details">
                        <h2><?php echo e(empty($app->currency) ? "GHS" : $app->currency); ?><?php echo number_format($branch_total_house_sum, 2); ?></h2>
                        <p><a href="#onthehouse">On the House</a></p>
                    </div>
                </div>
            </div>
            <div class="col-xl-4 col-lg-4 col-md-4 col-sm-12 col-12">
                <div class="stats-tile">
                   
                    <div class="sale-details">
                        <h2><?php echo e(empty($app->currency) ? "GHS" : $app->currency); ?><?php echo number_format($branch_total_reject_sum, 2); ?></h2>
                        <p><a href="#rejected">Rejected Order</a></p>
                    </div>
                </div>
            </div>
        </div>
        <!-- end Row -->


    <!-- Row start -->
    <div class="row gutters">
        <div class="col-xl-6 col-lg-6 col-md-12 col-sm-12 col-12">
            <div class="card h-180">
                <div class="card-header">
                    <a href="<?php echo e(route('departmentSummary', $user_data->id)); ?>" class="btn btn-outline-primary btn-sm rounded-pill"> Category Report</a>
                    <a href="<?php echo e(route('ItemSummary', $user_data->id)); ?>" class="btn btn-outline-primary btn-sm rounded-pill"> Product Report</a>
                </div>
                
                <div class="card-body">
                    <div class="create-offer-container">
                    <?php echo $__env->make('inc.report-summary', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-xl-2 col-lg-2 col-md-4 col-sm-4 col-6">
            <div class="social-tile h-180">
                <p>Discounts</p>
                <h3><?php echo e(empty($app->currency) ? "GHS" : $app->currency); ?><?php echo number_format($discounts, 2); ?></h3>
                <a href="#" class="btn btn-outline-primary btn-sm rounded-pill" data-bs-toggle="modal" data-bs-target="#exampleModalFullScreen">
                <i class="icon-eye1"></i> view
            </a>
            </div>
        </div>

       <?php if($user_data ->sales_person_category == "Delivery"): ?>
        <div class="col-xl-2 col-lg-2 col-md-4 col-sm-4 col-6">
            <div class="social-tile h-180">
                <p>Delivery Total</p>
                <h3><?php echo e(empty($app->currency) ? "GHS" : $app->currency); ?><?php echo number_format($deliveriesToday, 2); ?></h3>
            </div>
        </div>
       <?php endif; ?>
        <div class="col-xl-2 col-lg-2 col-md-4 col-sm-4 col-12">
            <div class="social-tile h-180">
                <p><strong>Expected Amount</strong></p>
                <h3><?php echo e(empty($app->currency) ? "GHS" : $app->currency); ?><?php echo number_format($orders, 2); ?></h3>
            </div>
        </div>
    </div>
    <!-- Row end -->

    <!-- Row start -->
    <div class="row gutters">
        <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
            <div class="card">
                <div class="card-body">
                    <h5 style="margin-bottom:10px">Product Transactions</h5>
                    <div class="table-responsive">
                    <table id="copy-print-csv" class="table v-middle">
                                <thead>
                                    <tr>
                                        <th>Product ID.</th>
                                        <th>Date</th>
                                        <th>Product</th>
                                        <th>Quantity</th>												
                                        <th>Unit Price</th>
                                        <th>Category</th>
                                        <th>Total Price</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php $__currentLoopData = $sales_today_branch; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $list): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <tr>
                                        <td>#<?php echo e($list->invoice_number); ?></td>
                                        <td><?php echo e($list->created_at); ?></td>
                                        <td>
                                        <?php echo e($list->invoice_product_name); ?>

                                        </td>
                                        <td>
                                            <?php echo e($list->invoice_quantity); ?>

                                        </td>
                                        <td><?php echo e(empty($app->currency) ? "GHS" : $app->currency); ?><?php echo number_format($list->invoice_unit_price, 2); ?></td>
                                        <td><?php echo e($list->invoice_category); ?></td>
                                        <td><?php echo e(empty($app->currency) ? "GHS" : $app->currency); ?><?php echo number_format($list->invoice_total_price, 2); ?></td>
                                        
                                    </tr>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </tbody>
                            </table>
                            <hr>
                        </div>

                </div>
            </div>

        </div>
    </div>
    <!-- Row end -->




    <!-- on the house sales and rejected orders -->

        <!-- Row start -->
        <div class="row gutters">
        <div class="col-xl-6 col-lg-6 col-md-6 col-sm-6 col-12">

            <!-- Card start -->
            <div class="card">
                <div class="card-header">
                    <div class="card-title" id="onthehouse">No Charge Order</div>
                </div>
                <div class="card-body">
                    
                    <!-- Row start -->
                    <div class="row gutters">
                        <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12"> 
                        <div class="table-responsive">       
                        <table id="apiCallbacks" class="table custom-table">
                                <thead>
                                    <tr>
                                    <th>Product ID</th>
                                        <th>Product</th>
                                        <th>Quantity</th>												
                                        <th> Unit Price</th>
                                        <th>Total Price</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php $__currentLoopData = $branch_total_house_list; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $list): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <tr>
                                    <td>
                                    <a href="<?php echo e(route('orderTransaction', $list->invoice_number)); ?>">#
                                    <?php echo \Illuminate\Support\Str::limit($list->invoice_number, 7); ?>
                                    </a>
                                </td>
                                        <td>
                                        <?php echo e($list->invoice_product_name); ?>

                                        </td>
                                        <td>
                                            <?php echo e($list->invoice_quantity); ?>

                                        </td>
                                        <td><?php echo e(empty($app->currency) ? "GHS" : $app->currency); ?><?php echo number_format($list->invoice_unit_price, 2); ?></td>
                                        <td><?php echo e(empty($app->currency) ? "GHS" : $app->currency); ?><?php echo number_format($list->invoice_total_price, 2); ?></td>
                                    </tr>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </tbody>
                            </table>
                            </div>
                        </div>
                    </div>
                    <!-- Row end -->

                </div>
            </div>
            <!-- Card end -->

        </div>
        <div class="col-xl-6 col-lg-6 col-md-6 col-sm-6 col-12">

            <!-- Card start -->
            <div class="card">
                <div class="card-header">
                    <div class="card-title" id="rejected">Rejected Order</div>
                </div>
                <div class="card-body">
                    
                    <!-- Row start -->
                    <div class="row gutters">
                        <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
                        <div class="table-responsive"> 
                        <table id="copy-print-csv" class="table table-striped">
                                <thead>
                                    <tr>
                                        <th>Order No.</th>
                                        <th>Product</th>
                                        <th>Quantity</th>												
                                        <th> Unit Price</th>
                                        <th>Total Price</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php $__currentLoopData = $branch_total_reject_list; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $list): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <tr>
                                        <td>
                                            <a href="<?php echo e(route('orderTransaction', $list->invoice_number)); ?>">#<?php echo \Illuminate\Support\Str::limit($list->invoice_number, 7); ?></a></td>
                                        <td>
                                        <?php echo e($list->invoice_product_name); ?>

                                        </td>
                                        <td>
                                            <?php echo e($list->invoice_quantity); ?>

                                        </td>
                                        <td><?php echo e(empty($app->currency) ? "GHS" : $app->currency); ?><?php echo number_format($list->invoice_unit_price, 2); ?></td>
                                        <td><?php echo e(empty($app->currency) ? "GHS" : $app->currency); ?><?php echo number_format($list->invoice_total_price, 2); ?></td>
                                    </tr>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </tbody>
                            </table>
                           
</div>
                    </div>
                    <!-- Row end -->

                </div>
            </div>
            <!-- Card end -->

        </div>
    </div>
    <!-- Row end -->


    <!-- Row start -->
    <div class="row gutters">
        <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
        <div class="card-header">
            <div class="card-title">Transactions</div>
        </div>
            <div class="card">
                <div class="card-body">
                    <div class="table-responsive">
                        <table id="highlightRowColumn" class="table custom-table">
                            <thead>
                                <tr>
                                  <th>Invoice Number</th>
                                  <th>Created at</th>
                                  <th>Branch</th>
                                  <th>Total Cost</th>
                                  <?php if(auth()->user()->sales_person_category == "Delivery"): ?>
                                  <th>Status</th>
                                  <?php else: ?>
                                  <?php endif; ?>
                                  <th>Actions</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php $__currentLoopData = $order; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $order): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <tr>
                                    <td>
                                      <div class="media-box">
                                          <div class="media-box-body">
                                              <a href="#">#<?php echo e($order -> order_id); ?></a>
                                          </div>
                                      </div>
                                  </td>
                                  <td><?php echo e($order -> created_at); ?></td>
                                  <td><?php echo e($order -> branch); ?></td>
                                  <td><?php echo e(empty($app->currency) ? "GHS" : $app->currency); ?><?php echo number_format($order ->total_cost_order, 2); ?></td>
                                  <?php if(auth()->user()->sales_person_category == "Delivery"): ?>
                                  <td>
                                      <?php if($order -> status == 1 && $order -> dispatch_status == 1): ?>
                                      <span class="badge rounded-pill bg-success"> Completed </span>
                                      <?php else: ?>
                                      <span class="badge rounded-pill bg-primary"> Pending</span>
                                      <?php endif; ?>
                                  </td>
                                  <?php else: ?>
                                  <?php endif; ?>
                                  <td>
                                      <div class="actions">
                                          <a href="<?php echo e(route('orderTransaction', $order -> order_id)); ?>" class="text-danger">
                                              <i class="fa fa-edit"></i>
                                          </a>
                                      </div>
                                  </td>
                                </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            </tbody>
                    </table>
                    
                    </div>

                </div>
            </div>

        </div>
    </div>
    <!-- Row end -->


    <!-- Modal for Discount Orders -->
    <?php echo $__env->make('inc.discount-items', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

    

</div>
</div>
<!-- Content wrapper end -->





<!--  Small modal example -->
<div class="modal fade bs-example-modal-sm" id="viewComposition" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-sm">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="mySmallModalLabel"></h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">
                    <h5>Composition</h5>
                    <hr>
                    <div id="demoB"></div>

                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
    

<script>
        function getComposition(data) {
            const id = data.split(" - ")
        document.getElementById('mySmallModalLabel').innerHTML = id[1]

        const xhttp = new XMLHttpRequest();
            xhttp.onload = function() {
                data = JSON.parse(this.responseText);
                var list = "<ul>";
                    for (let i of data) {
                    list += `<li>${i.product_name} = ${i.unit_measure}, Total Used: ${i.unit_measure*id[2]}</li>`;
                    }
                    list += "</ul>";

                document.getElementById("demoB").innerHTML = list;

            }
            xhttp.open("GET", "/ceqa-dashboard/compostions-product/"+ id[0]);
            xhttp.send();

    }
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home2/morttacy/morttsonsposfiles/resources/views/sales/view-user-sale.blade.php ENDPATH**/ ?>