<?php $__env->startSection('title', 'Viendo pedido #'.$order->id); ?>

<?php $__env->startSection('content'); ?>
    <!-- Page Header -->
    <div class="page-header">
        <div class="row align-items-center">
            <div class="col-sm mb-2 mb-sm-0">
                <nav aria-label="breadcrumb">
                    <ol class="breadcrumb breadcrumb-no-gutter">
                        <li class="breadcrumb-item"><a class="breadcrumb-link" href="javascript:;">eCommerce</a></li>
                        <li class="breadcrumb-item"><a class="breadcrumb-link" href="<?php echo e(route('backend.orders.index')); ?>">Pedidos</a></li>
                        <li class="breadcrumb-item active" aria-current="page"><?php echo $__env->yieldContent('title'); ?></li>
                    </ol>
                </nav>

                <div class="d-sm-flex align-items-sm-center">
                    <h1 class="page-header-title">Pedido #<?php echo e($order->id); ?></h1>
                    <span class="ml-2 ml-sm-3">
                                            <?php if($order->status_id == 0): ?>
                            <span class="badge badge-soft-danger">
                          <span class="legend-indicator bg-danger"></span>Sin finalizar
                        </span>
                        <?php elseif($order->status_id == 1): ?>
                            <span class="badge badge-soft-success">
                          <span class="legend-indicator bg-success"></span>Confirmado
                        </span>
                        <?php elseif($order->status_id == 2): ?>
                            <span class="badge badge-soft-primary">
                          <span class="legend-indicator bg-primary"></span>Procesado
                        </span>
                        <?php endif; ?>

                    </span>
                    <span class="ml-2 ml-sm-3">
                  <i class="tio-date-range"></i> <?php echo e($order->short_date); ?>

                </span>
                </div>
            </div>
        </div>
    </div>
    <!-- End Page Header -->

    <?php echo Form::model($order, [
        'method' => $order->exists ? 'put' : 'post',
        'route' => $order->exists ? ['backend.orders.update', $order->id] : 'backend.orders.store'
    ]); ?>

    <div class="row">
        <div class="col-lg-8 mb-3 mb-lg-0">
            <!-- Card -->
            <div class="card mb-3 mb-lg-5">
                <!-- Header -->
                <div class="card-header">
                    <h4 class="card-header-title">Detalle del pedido <span class="badge badge-soft-dark rounded-circle ml-1"><?php echo e($order->items->count()); ?></span></h4>
                </div>
                <!-- End Header -->

                <!-- Body -->
                <div class="card-body">
                    <?php $__currentLoopData = $order->items; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <!-- Media -->
                    <div class="media">
                        <?php if($item->options->image): ?>
                        <div class="avatar avatar-xl mr-3">
                            <img class="img-fluid" src="<?php echo e(asset($item->options->image)); ?>" alt="Image Description">
                        </div>
                        <?php endif; ?>

                        <div class="media-body">
                            <div class="row">
                                <div class="col-md-6 mb-3 mb-md-0">
                                    <h5><?php echo e($item->name); ?></h5>
                                </div>

                                <div class="col col-md-2 align-self-center">
                                    <h5><?php echo e(num_format($item->price)); ?></h5>
                                </div>

                                <div class="col col-md-2 align-self-center">
                                    <h5><?php echo e($item->qty); ?></h5>
                                </div>

                                <div class="col col-md-2 align-self-center text-right">
                                    <h5><?php echo e(num_format($item->qty * $item->price)); ?></h5>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- End Media -->

                    <hr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    <div class="row justify-content-md-end mb-3">
                        <div class="col-md-8 col-lg-7">
                            <dl class="row text-sm-right">
                                <dt class="col-sm-6">Subtotal:</dt>
                                <dd class="col-sm-6"><?php echo e(num_format($order->subtotal)); ?></dd>
                                <dt class="col-sm-6">Envío:</dt>
                                <dd class="col-sm-6"><?php echo e(num_format($order->shipping_price)); ?></dd>
                                <dt class="col-sm-6">Total:</dt>
                                <dd class="col-sm-6"><?php echo e(num_format($order->total)); ?></dd>
                            </dl>
                            <!-- End Row -->
                        </div>
                    </div>
                    <!-- End Row -->
                </div>
                <!-- End Body -->
            </div>
            <!-- End Card -->

            <!-- Card -->
            <div class="card">
                <!-- Header -->
                <div class="card-header">
                    <h4 class="card-header-title">
                        Estado
                        <span class="ml-1">
                                                                        <?php if($order->status_id == 0): ?>
                                <span class="badge badge-soft-danger">
                          <span class="legend-indicator bg-danger"></span>Sin finalizar
                        </span>
                            <?php elseif($order->status_id == 1): ?>
                                <span class="badge badge-soft-success">
                          <span class="legend-indicator bg-success"></span>Confirmado
                        </span>
                            <?php elseif($order->status_id == 2): ?>
                                <span class="badge badge-soft-primary">
                          <span class="legend-indicator bg-primary"></span>Procesado
                        </span>
                            <?php endif; ?>
                        </span>
                    </h4>
                </div>
                <!-- End Header -->

                <!-- Body -->
                <div class="card-body">
                    <!-- Step -->
                    <ul class="step step-icon-xs">

                        <!-- Step Item -->
                        <li class="step-item">
                            <div class="step-content-wrapper">
                                <span class="step-icon step-icon-soft-dark step-icon-pseudo"></span>

                                <div class="step-content">
                                    <h5 class="mb-1">
                                        <a class="text-dark" href="#">Pedido realizado</a>
                                    </h5>

                                    <p class="font-size-sm mb-0"><?php echo e($order->short_date); ?></p>
                                </div>
                            </div>
                        </li>
                        <!-- End Step Item -->

                    </ul>
                    <!-- End Step -->
                    <small>Última actualización: <?php echo e($order->short_updated_date); ?></small>
                </div>
                <!-- End Body -->
            </div>
            <!-- End Card -->
        </div>

        <div class="col-lg-4">
            <?php if($order->user): ?>
            <!-- Card -->
            <div class="card">
                <!-- Header -->
                <div class="card-header">
                    <h4 class="card-header-title">Cliente</h4>
                </div>
                <!-- End Header -->

                <!-- Body -->
                <div class="card-body">
                    <a class="media align-items-center" href="<?php echo e(route('backend.users.edit', $order->user->id)); ?>">
                        <?php if($order->user->user_data->image): ?>
                        <div class="avatar avatar-circle mr-3">
                            <img class="avatar-img" src="<?php echo e(asset($order->user->user_data->image)); ?>" alt="Image Description">
                        </div>
                        <?php endif; ?>
                        <div class="media-body">
                            <span class="text-body text-hover-primary"><?php echo e($order->user->full_name); ?></span>
                        </div>
                        <div class="media-body text-right">
                            <i class="tio-chevron-right text-body"></i>
                        </div>
                    </a>

                    <hr>

                    <a class="media align-items-center" href="<?php echo e(route('backend.users.edit', $order->user->id)); ?>">
                        <div class="icon icon-soft-info icon-circle mr-3">
                            <i class="tio-shopping-basket-outlined"></i>
                        </div>
                        <div class="media-body">
                            <span class="text-body text-hover-primary"><?php echo e($order->user->orders()->confirmed()->count()); ?> pedidos</span>
                        </div>
                        <div class="media-body text-right">
                            <i class="tio-chevron-right text-body"></i>
                        </div>
                    </a>

                    <hr>

                    <div class="d-flex justify-content-between align-items-center">
                        <h5>Datos de contacto</h5>
                    </div>

                    <ul class="list-unstyled list-unstyled-py-2">
                        <li>
                            <i class="tio-online mr-2"></i>
                            <?php echo e($order->email); ?>

                        </li>
                        <li>
                            <i class="tio-android-phone-vs mr-2"></i>
                            <?php echo e($order->phone); ?>

                        </li>
                    </ul>
                    <hr>

                    <div class="d-flex justify-content-between align-items-center">
                        <h5>Método de pago</h5>
                    </div>

                    <span class="d-block">
                  <?php echo e($order->payment_method); ?>

                </span>

                    <hr>

                    <div class="d-flex justify-content-between align-items-center">
                        <h5>Dirección de facturación</h5>
                    </div>

                    <span class="d-block">
                  <?php echo e($order->address); ?><br>
                        <?php echo e($order->city); ?>

                </span>

                    <hr>

                    <div class="d-flex justify-content-between align-items-center">
                        <h5>Método de envío</h5>
                    </div>

                    <span class="d-block">
                        <?php echo e($order->shipping_method); ?><br>
                </span>
                    <hr>
                    <div class="d-flex justify-content-between align-items-center">
                        <h5>Dirección de envío</h5>
                    </div>

                    <span class="d-block">
                        <?php if($order->shipping_data): ?>
                            <?php $__currentLoopData = $order->shipping_data; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <?php echo e($value); ?><br>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            <?php else: ?>
                            Misma que dirección de facturación
                        <?php endif; ?>
                        <?php if($order->feedback): ?>
                            <?php echo e($order->feedback); ?>

                        <?php endif; ?>
                </span>

                </div>
                <!-- End Body -->
            </div>
            <!-- End Card -->
            <?php endif; ?>
        </div>
    </div>
    <!-- End Row -->
    <?php echo Form::close(); ?>

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

<?php $__env->startPush('scripts'); ?>
    <!-- Modal -->
    <div class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="deleteModalLabel" aria-hidden="true">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <?php echo Form::open([
                    'method' => 'delete'
                ]); ?>

                <div class="modal-header">
                    <h5 class="modal-title" id="deleteModalLabel">Eliminar imagen</h5>
                    <button type="button" class="btn btn-xs btn-icon btn-ghost-secondary" data-dismiss="modal" aria-label="Close">
                        <i class="tio-clear tio-lg"></i>
                    </button>
                </div>
                <div class="modal-body">
                    <span></span>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-white" data-dismiss="modal">Cancelar</button>
                    <button class="btn btn-danger" type="submit">Eliminar</button>
                </div>
                <?php echo Form::close(); ?>

            </div>
        </div>
    </div>
    <!-- End Modal -->
    <script>
      $(function() {
        $('.modal-toggle-delete').on('click', function() {
          $('#deleteModal form').attr('action', $(this).attr('data-href'));
          $('#deleteModal .modal-body span').text($(this).attr('data-title'));
          $('#deleteModal').modal('show');
          return false;
        });
      });
    </script>
    <script>
      $(function() {
        // INITIALIZATION OF ADD INPUT FILED
        // =======================================================
        $('.js-add-field').each(function () {
          new HSAddField($(this), {
            addedField: function() {
              $('.js-add-field .js-select2-custom-dynamic').each(function () {
                var select2dynamic = $.HSCore.components.HSSelect2.init($(this));
              });
            }
          }).init();
        });


        // INITIALIZATION OF TAGIFY
        // =======================================================
        $('.js-tagify').each(function () {
          var tagify = $.HSCore.components.HSTagify.init($(this), {
            originalInputValueFormat: valuesArr => valuesArr.map(item => item.value).join(',')
          });
        });


        // INITIALIZATION OF DROPZONE FILE ATTACH MODULE
        // =======================================================
        $('.js-dropzone').each(function () {
          var dropzone = $.HSCore.components.HSDropzone.init('#' + $(this).attr('id'));
        });
      });
    </script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('layouts.backend', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/poshcom/bgreen.posh.com.py/resources/views/backend/orders/form.blade.php ENDPATH**/ ?>