title = "Order detail"
url = "/order-detail/:orderId"
layout = "platform_main"
is_hidden = 0

[order]
==
<?php
function onStart(){

    $this["orderId"] = $this->param("orderId");

    $orderId = $this->param("orderId");
    $this["order"] = Romanah\Gokbakja\Models\Order::where("id", $orderId)->with(["client", "shipping"])
                    ->withCount(['order_items as order_all_amount' => function($query) {
                        $query->select(DB::raw('sum(amount)'));
                    }])
                    ->withCount(['order_items as order_all_price' => function($query) {
                        $query->select(DB::raw('sum(price)'));
                    }])
                    ->first();

    $this["all"] = ($this["order"]->order_all_amount * $this["order"]->order_all_price);

    $this["orderItems"] = Romanah\Gokbakja\Models\OrderItem::where("order_id", $orderId)->orderBy("id", "DESC")->with(["type", "size"])->get();

    $this["sizes"] = Romanah\Gokbakja\Models\BagSize::get();
    $this["types"] = Romanah\Gokbakja\Models\BagType::get();

}
?>
==
{% put styles %}
<link href="{{'assets/libs/datatables.net-bs4/css/dataTables.bootstrap4.min.css'|theme}}" rel="stylesheet"
    type="text/css" />
<link href="{{'assets/libs/datatables.net-buttons-bs4/css/buttons.bootstrap4.min.css'|theme}}" rel="stylesheet"
    type="text/css" />
<link href="{{'assets/libs/datatables.net-select-bs4/css/select.bootstrap4.min.css'|theme}}" rel="stylesheet"
    type="text/css" />

<link href="{{'assets/libs/select2/css/select2.min.css'|theme}}" rel="stylesheet" type="text/css">
{% endput %}

<div class="container-fluid">

    <!-- start page title -->
    <div class="row">
        <div class="col-12">
            <div class="page-title-box d-flex align-items-center justify-content-between">
                <h4 class="mb-0">Sargyt Maglumatlary</h4>

            </div>
        </div>
    </div>
    <!-- end page title -->

    <div class="row">
        <div class="col-12">
            <!-- Left sidebar -->
            <div class="email-leftbar card">
                {% partial "order/aside" active=1 orderId=orderId %}
            </div>
            <!-- End Left sidebar -->


            <!-- Right Sidebar -->
            <div class="email-rightbar mb-3">
                <div class="row">
                    <div class="col-md-12">
                        <div class="collapse multi-collapse" id="multiCollapseExample1">
                            <form data-request="onCreateOrderItem" data-request-flash data-request-validate>
                                <div class="card">
                                    <div class="card-body">
                                        <div class="row">
                                            <div class="col">
                                                <label class="form-label">Razmer Saýlaň</label>
                                                <select class="form-control select2" name="size_id">
                                                    <option value="0">Saýla</option>
                                                    {% for size in sizes %}
                                                    <option value="{{size.id}}">{{size.name}}</option>
                                                    {% endfor %}
                                                </select>
                                            </div>
                                            <div class="col">
                                                <label class="form-label">Görnüş Saýlaň</label>
                                                <select class="form-control select2" name="type_id">
                                                    <option value="0">Saýla</option>
                                                    {% for type in types %}
                                                    <option value="{{type.id}}">{{type.name}}</option>
                                                    {% endfor %}
                                                </select>
                                            </div>

                                            <div class="col">
                                                <div>
                                                    <label class="form-label">Bahasy</label>
                                                    <input type="number" name="price" step="0.01" class="form-control"
                                                        placeholder="Bahasy">
                                                </div>
                                            </div>

                                            <div class="col">
                                                <div>
                                                    <label class="form-label">Mukdary (kg)</label>
                                                    <input type="number" name="amount" step="0.01" class="form-control"
                                                        placeholder="Mukdary">
                                                </div>
                                            </div>

                                            <div class="col">
                                                <div>
                                                    <label class="form-label">Bellik</label>
                                                    <input type="text" name="note" class="form-control"
                                                        placeholder="Bellik">
                                                </div>
                                            </div>


                                            <div class="col">
                                                <button type="submit" class="btn btn-primary waves-effect waves-light"
                                                    style="margin-top: 30px;width: 100%;">Goş</button>
                                            </div>

                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>

                </div>

                {% partial "order/item_header" orderId=order.id clientName=order.client.name
                allAmount=order.order_all_amount allPrice=order.order_all_price all=all %}

                <div class="card">

                    <div class="card-body">

                        <div class="row">
                            <div class="col-md-6">
                                <h3 class="card-title" style="font-size: 22px;color: #1e2038;">Sargytlar</h3>
                                <p class="card-title-desc" style="color: #6c6ff5;">Hasabat</p>
                            </div>
                            <div class="col-md-6" style="text-align: right;">
                                <a class="btn btn-primary" data-bs-toggle="collapse" href="#multiCollapseExample1"
                                    role="button" aria-expanded="false" aria-controls="multiCollapseExample1">Haryt
                                    Goş</a>
                            </div>
                        </div>


                        <table id="datatable-buttons" class="table table-striped table-bordered dt-responsive nowrap"
                            style="border-collapse: collapse; border-spacing: 0; width: 100%;" data-page-length='13'>
                            <thead>
                                <tr>
                                    <th style="width: 5%;">№</th>
                                    <th>Görnüş</th>
                                    <th>Razmer</th>
                                    <th>Bahasy</th>
                                    <th>Mukdary</th>
                                    <th>Bellik</th>
                                </tr>
                            </thead>
                            <tbody id="order_item_datas">
                                {% for key, item in orderItems %}
                                <tr>
                                    <td style="font-weight: bold;">{{(key+1)}}</td>
                                    <td><a href="#" style="font-weight: bold;">{{item.type.name}}</a></td>
                                    <td>{{item.size.name}}</td>
                                    <td><a href="#" data-request="onModalSet"
                                            data-request-data="orderItemId: {{item.id}}"
                                            data-bs-toggle="modal" data-bs-target=".bs-example-modal-sm-1"
                                            class="badge badge-soft-success"
                                            style="font-size: 14px;">{{item.price|number_format}} $</a>
                                    </td>
                                    <td><a href="#" data-request="onModalSetAmount"
                                        data-request-data="orderItemId: {{item.id}}"
                                        data-bs-toggle="modal" data-bs-target=".bs-example-modal-sm-1">{{item.amount}}</a></td>
                                    <td>{{item.note}}</td>
                                </tr>
                                {% endfor %}
                            </tbody>
                            <tfoot>
                                <tr>
                                    <th style="width: 5%;">№</th>
                                    <th>Görnüş</th>
                                    <th>Razmer</th>
                                    <th>Bahasy</th>
                                    <th>Mukdary</th>
                                    <th>Bellik</th>
                                </tr>
                            </tfoot>
                        </table>
                    </div>

                    <div class="modal fade bs-example-modal-sm-1" tabindex="-1" role="dialog"
                        aria-labelledby="mySmallModalLabel" aria-hidden="true">
                        <div class="modal-dialog modal-sm">
                            <div class="modal-content" id="modal-form">



                            </div>
                        </div>
                    </div>

                </div> <!-- card -->

            </div>

        </div>
    </div>
    <!-- End row -->
</div>


{% put scripts %}

<script src="{{'assets/libs/select2/js/select2.min.js'|theme}}"></script>
<script src="{{'assets/js/pages/form-advanced.init.js'|theme}}"></script>

{% endput %}
{% partial 'dataTableJs' %}
