<?php $_shouldextend[1]=1; ?>

<?php $this->startSection('content'); ?>
 <div>
 <?php echo $this->runChild('manager.parts.list', ['action' => 'order']); ?>
 </div>
 
 <div x-data="{ data: { id: 0 } }">
 <div id="modal-details" class="modal eins-modal" x-data="modal" @openmodal.window="open">
 <div class="modal__outer eins-modal-content">
 <div class="modal__title">
 <?php echo \htmlentities(__('manager_order.order')??'', ENT_QUOTES, 'UTF-8', false); ?> №<span x-text="data.id"></span>

 <div class="modal__close x-tool x-tool-close" x-bind="close">&nbsp;</div>
 </div>

 <div class="modal__content">
 <table class="list__table x-grid3-row-table" x-data="{
 params: 
 {
 date: '<?php echo \htmlentities(__('manager_order.date')??'', ENT_QUOTES, 'UTF-8', false); ?>',
 name: '<?php echo \htmlentities(__('manager_order.name')??'', ENT_QUOTES, 'UTF-8', false); ?>',
 phone: '<?php echo \htmlentities(__('manager_order.phone')??'', ENT_QUOTES, 'UTF-8', false); ?>',
 email: '<?php echo \htmlentities(__('manager_order.email')??'', ENT_QUOTES, 'UTF-8', false); ?>',
 deliveryTitle: '<?php echo \htmlentities(__('manager_order.delivery')??'', ENT_QUOTES, 'UTF-8', false); ?>',
 paymentTitle: '<?php echo \htmlentities(__('manager_order.payment')??'', ENT_QUOTES, 'UTF-8', false); ?>',
 payment_status: '<?php echo \htmlentities(__('manager_order.payment_status')??'', ENT_QUOTES, 'UTF-8', false); ?>',
 comment: '<?php echo \htmlentities(__('manager_order.comment')??'', ENT_QUOTES, 'UTF-8', false); ?>',
 },
 address:
 {
 country: '',
 city: '<?php echo \htmlentities(__('manager_order.city_short')??'', ENT_QUOTES, 'UTF-8', false); ?>',
 street:	'<?php echo \htmlentities(__('manager_order.street_short')??'', ENT_QUOTES, 'UTF-8', false); ?>',
 building: '<?php echo \htmlentities(__('manager_order.building_short')??'', ENT_QUOTES, 'UTF-8', false); ?>',
 flat: '<?php echo \htmlentities(__('manager_order.flat_short')??'', ENT_QUOTES, 'UTF-8', false); ?>',
 }}">
 <tbody>
 <tr>
 <td class="x-grid3-cell">
 <div class="list__value x-grid3-hd-inner">
 <?php echo \htmlentities(__('manager_order.status')??'', ENT_QUOTES, 'UTF-8', false); ?>

 </div>
 </td>
 
 <td class="x-grid3-cell">
 <div class="list__value x-grid3-hd-inner">
 <form @change="submit()">
 <input type="hidden" name="action" value="order">
 <input type="hidden" name="key" :value="data.id">

 <select name="status" x-model="data.status" :class="errors.status ? 'error' : ''">
 <?php $__currentLoopData = $order::STATUSES; $this->addLoop($__currentLoopData);$this->getFirstLoop();
 foreach($__currentLoopData as $status): $loop = $this->incrementLoopIndices();  ?>
 <option value="<?php echo \htmlentities($status??'', ENT_QUOTES, 'UTF-8', false); ?>">
 <?php echo \htmlentities(__('order.status_' . $status)??'', ENT_QUOTES, 'UTF-8', false); ?>

 </option>
 <?php endforeach; $this->popLoop(); $loop = $this->getFirstLoop(); ?>
>                                            </select>

 <div x-text="errors.status" :class="errors.status ? 'form__error' : ''"></div>
 </form>
 </div>
 </td>
 </tr>

 <template x-for="(title, key) in params">
 <tr x-show="data[key]">
 <td class="x-grid3-cell">
 <div class="list__value x-grid3-hd-inner" x-text="title"></div>
 </td>
 
 <td class="x-grid3-cell">
 <div class="list__value x-grid3-cell-inner" x-text="data[key]"></div>
 </td>
 </tr>
 </template>

 <tr>
 <td class="x-grid3-cell">
 <div class="list__value x-grid3-hd-inner">
 <?php echo \htmlentities(__('manager_order.address')??'', ENT_QUOTES, 'UTF-8', false); ?>

 </div>
 </td>
 
 <td class="x-grid3-cell">
 <div class="list__value x-grid3-cell-inner">
 <template x-for="(addressValue, addressKey) in data['address']">
 <div x-show="addressValue">
 <span x-text="address[addressKey]"></span>
 <span x-text="addressValue"></span>
 </div>
 </template>
 </div>
 </td>
 </tr>

 <template x-if="data.data && data.data.coupon">
 <tr>
 <td class="x-grid3-cell">
 <div class="list__value x-grid3-hd-inner">
 <?php echo \htmlentities(__('manager_coupon.coupon')??'', ENT_QUOTES, 'UTF-8', false); ?>

 </div>
 </td>
 
 <td class="x-grid3-cell">
 <div class="list__value x-grid3-cell-inner">
 <span x-text="data.data.coupon.id"></span> -
 <span x-text="data.data.coupon.title"></span> -
 <span x-text="data.data.coupon.percent"></span>%
 </div>
 </td>
 </tr>
 </template>
 </tbody>
 </table>
 
 <br><br>

 <div class="list x-grid3">
 <div class="x-grid3-viewport">
 <div class="x-grid3-body" x-data="{'action':'order'}">
 <div class="x-grid3-row" x-data="list" x-bind="outer">
 <table class="list__table x-grid3-row-table">
 <thead>
 <td class="x-grid3-cell" style="width: 50px">
 <div class="x-grid3-hd-inner">
 #
 </div>
 </td>

 <td class="x-grid3-cell">
 <div class="x-grid3-hd-inner">
 <?php echo \htmlentities(__('manager_order.title')??'', ENT_QUOTES, 'UTF-8', false); ?>

 </div>
 </td>

 <td class="x-grid3-cell">
 <div class="x-grid3-hd-inner">
 <?php echo \htmlentities(__('manager_order.articul')??'', ENT_QUOTES, 'UTF-8', false); ?>

 </div>
 </td>

 <td class="x-grid3-cell">
 <div class="x-grid3-hd-inner">
 <?php echo \htmlentities(__('manager_order.sumTitle')??'', ENT_QUOTES, 'UTF-8', false); ?>

 </div>
 </td>

 <td class="x-grid3-cell">
 <div class="x-grid3-hd-inner">
 <?php echo \htmlentities(__('manager_order.countTitle')??'', ENT_QUOTES, 'UTF-8', false); ?>

 </div>
 </td>
 </thead>

 <tbody>
 <template x-for="(item, key) in data.items">
 <tr>
 <td class="x-grid3-cell">
 <div class="list__value x-grid3-cell-inner" x-text="item.resource"></div>
 </td>

 <td class="x-grid3-cell">
 <div class="list__value x-grid3-cell-inner">
 <div x-text="item.title" style="font-weight: bold"></div>
 <div x-text="item.options.size.title + ': ' + item.options.size.valueTitle"></div>
 <div x-text="item.options.color.title + ': ' + item.options.color.valueTitle"></div>
 </div>
 </td>

 <td class="x-grid3-cell">
 <div class="list__value x-grid3-cell-inner" x-text="item.articul"></div>
 </td>

 <td class="x-grid3-cell">
 <div class="list__value x-grid3-cell-inner" x-text="item.price"></div>
 </td>

 <td class="x-grid3-cell">
 <div class="list__value x-grid3-cell-inner" x-text="item.count"></div>
 </td>
 </tr>
 </template>

 <template x-if="data.data && data.data.total.couponId">
 <tr>
 <td class="x-grid3-cell" colspan="3">
 <div class="list__value x-grid3-hd-inner">
 <?php echo \htmlentities(__('manager_coupon.discount')??'', ENT_QUOTES, 'UTF-8', false); ?>:
 </div>
 </td>
 
 <td class="x-grid3-cell">
 <div class="list__value x-grid3-hd-inner" x-text="data.data.total.fullSum - data.data.total.sum"></div>
 </td>
 
 <td class="x-grid3-cell"></td>
 </tr>
 </template>

 <tr>
 <td class="x-grid3-cell" colspan="3">
 <div class="list__value x-grid3-hd-inner">
 <?php echo \htmlentities(__('manager_order.total')??'', ENT_QUOTES, 'UTF-8', false); ?>:
 </div>
 </td>
 
 <td class="x-grid3-cell">
 <div class="list__value x-grid3-hd-inner" x-text="data.sum"></div>
 </td>
 
 <td class="x-grid3-cell">
 <div class="list__value x-grid3-hd-inner" x-text="data.count"></div>
 </td>
 </tr>
 </tbody>
 </table>
 </div>
 </div>
 </div>
 </div>
 </div>
 </div>
 </div>
 </div>
<?php $this->stopSection(); ?>

<?php if (isset($_shouldextend[1])) { echo $this->runChild('manager.layouts.main'); } ?>