<?php $__env->startSection('title', 'Products'); ?>


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


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

        

        <table class="table">
            <thead>
                <tr>
                    <th>Id</th>
                    <th>Is Active</th>
                    <th>SKU</th>
                    <th>Carrier</th>
                    <th>Contry</th>
                    <th>Full Amount</th>
                    <th>User Discount %</th>
                    <th>Telecom Discount %</th>
                    <!--<th>Presented Amount (Savings)</th>-->
                    <th>Is Pinless?</th>
                </tr>
            </thead>

            <tbody>
                <?php $__currentLoopData = $products; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <tr>
                        <td><?php echo e($item->id); ?></td>

                        <?php if($item->active == true): ?>
                            <td>
                                <form action="<?php echo e(route('products.update', [$item->id])); ?>" method="post">
                                    <input type="hidden" name="_method" value="put" />
                                    <input type="hidden" name="active" value="0">
                                    <button type="submit">
                                        <span class="glyphicon glyphicon-ok-sign"></span>
                                    </button>
                                    <?php echo e(csrf_field()); ?>

                                </form>
                            </td>
                        <?php else: ?>
                            <td>
                                <form action="<?php echo e(route('products.update', [$item->id])); ?>" method="post">
                                    <input type="hidden" name="_method" value="put" />
                                    <input type="hidden" name="active" value="1">
                                    <button type="submit">
                                        <span class="glyphicon glyphicon-remove-sign"></span>
                                    </button>
                                    <?php echo e(csrf_field()); ?>

                                </form>
                            </td>
                        <?php endif; ?>
                        <td><?php echo e($item->sku); ?></td>                  
                        <td><?php echo e($item->carrier); ?></td>                  
                        <td><?php echo e($item->country); ?></td>                  
                        <td>$<?php echo e(number_format( (double)preg_replace('/[^$0-9.]/', '', $item->amount ), 2)); ?></td>

                        
                        <td> 
                            <form action="<?php echo e(route('products.update', [$item->id])); ?>" method="post" class="formupdate">
                                <input type="hidden" name="_method" value="put" />
                                <input style="width: 50px" class="discount_pct" type="number" name="discount_pct" value="<?php echo e($item->discount_pct); ?>">
                                <?php echo e(csrf_field()); ?>

                                <button type="submit">
                                    <span class="glyphicon glyphicon-refresh"></span>
                                </button>
                            </form>
                        </td>
                        
                        
                        <td> 
                            <form action="<?php echo e(route('products.update', [$item->id])); ?>" method="post" class="formupdate">
                                <input type="hidden" name="_method" value="put" />
                                <input style="width: 50px" class="telecom_pct" type="number" name="telecom_pct" value="<?php echo e($item->telecom_pct); ?>">
                                <?php echo e(csrf_field()); ?>

                                <button type="submit">
                                    <span class="glyphicon glyphicon-refresh"></span>
                                </button>
                            </form>
                        </td>
                        
                        
                        <?php if($item->is_pinless == 0): ?>
                            <td>false</td>
                        <?php else: ?>
                            <td>true</td>
                        <?php endif; ?>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </tbody>

        </table>


        <?php echo e($products->links()); ?>





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


<?php $__env->startSection('js'); ?>
    
    <script type="text/javascript">


        /*$(document).ready(function(){
            
            var url = window.location.origin + '/';
            

            $.ajax({
                url: url + 'allproducts',

                success: function(result){
                    console.log(result);
                }
            });

            


        });*/


    </script>

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