title = "order-detail/logistics"
url = "/order-detail/logistics/: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["orderItems"] = Romanah\Gokbakja\Models\OrderItem::where("order_id", $orderId)->get();

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

    $this["transports"] = Romanah\Gokbakja\Models\ShippingTransport::where("shipping_id", $this["order"]->shipping_id)->orderBy("id", "DESC")->get();

    $this["allLoaded"] = Romanah\Gokbakja\Models\ShippingTransport::where("shipping_id", $this["order"]->shipping_id)->sum("loaded_amount");

}
?>
==
{% 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=2 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="onCreateTransportItem" data-request-flash data-request-validate>
                                <div class="card">
                                    <div class="card-body">
                                        <div class="row">
                                            <div class="col">
                                                <label class="form-label">Transport Saýlaň</label>
                                                <select class="form-control select2" name="transport_type">
                                                    <option value="0">Saýla</option>

                                                    <option value="truck">Tyr</option>
                                                    <option value="train">Wagon</option>

                                                </select>
                                            </div>

                                            <div class="col">
                                                <label class="form-label">Sargyt Harytlary</label>
                                                <select class="form-control select2" name="order_item_id">
                                                    <option value="0">Saýla</option>
                                                    {% for item in orderItems %}
                                                        <option value="{{item.id}}">#{{item.id}}
                                                            {% if item.order_item_type == 'rulon' %}
                                                                Rulon
                                                            {% else %}
                                                                Halta
                                                            {% endif %}

                                                        </option>
                                                    {% endfor %}

                                                </select>
                                            </div>

                                            <div class="col">
                                                <div>
                                                    <label class="form-label">Ýüklenen Mukdar (kg)</label>
                                                    <input type="number" name="loaded_amount" step="0.01" class="form-control"
                                                        placeholder="Ýüklenen Mukdar (kg)">
                                                </div>
                                            </div>

                                            <div class="col">
                                                <div>
                                                    <label class="form-label">Transport No</label>
                                                    <input type="text" name="transport_no" class="form-control"
                                                        placeholder="Transport No">
                                                </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;">Sargyt Logistika Maglumatlary</h3>
                                <p class="card-title-desc" style="color: #6c6ff5;font-size: 17px;" id="all_loaded">Jemi Ýüklenen Ýük: {{allLoaded|number_format(2)}} kg</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">Transport
                                    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>Transport</th>
                                    <th>Şu wagtky ýeri</th>
                                    <th>Ýüklenen Mukdar</th>
                                    <th>Transport No</th>
                                    <th>Ugramaly Sene</th>
                                    <th>Bellik</th>
                                    <th>Statusy</th>
                                    <th>Ýük Çalyşmak</th>
                                    <th>Sazlamalar</th>
                                </tr>
                            </thead>
                            <tbody id="transport_item_datas">
                                {% for key, transport in transports %}
                                <tr>
                                    <td style="font-weight: bold;">{{(key+1)}}</td>
                                    <td><a href="#" style="font-weight: bold;">{{transport.transport_type}}</a></td>
                                    <td>{{transport.place_now}}</td>
                                    <td>{{transport.loaded_amount}} kg</td>
                                    <td>{{transport.transport_no}}</td>
                                    <td>{% if transport.date %}{{transport.date|date('d.m.Y')}}{% endif %}</td>
                                    <td>{{transport.note}}</td>
                                    <td style="font-weight: bold;color: #6c6ff5;">{{transport.status}}</td>
                                    <td>
                                        {% if transport.status == "complated" %}
                                            <a href="#" style="color: darkgreen;"> {{transport.status}} </a>
                                        {% else %}
                                            <a href="#" data-request="onModalSetTransportChange"
                                            data-request-data="transportId: {{transport.id}}"
                                            data-bs-toggle="modal" data-bs-target=".bs-example-modal-sm-1" style="color: orange;"> Çalyşmak </a>
                                        {% endif %}
                                    </td>
                                    <td><a href="#" data-request="onModalSetTransport"
                                        data-request-data="transportId: {{transport.id}}"
                                        data-bs-toggle="modal" data-bs-target=".bs-example-modal-sm-1" style="color: orange;"> Täzele </a></td>
                                </tr>
                                {% endfor %}
                            </tbody>
                            <tfoot>
                                <tr>
                                    <th style="width: 5%;">№</th>
                                    <th>Transport</th>
                                    <th>Şu wagtky ýeri</th>
                                    <th>Ýüklenen Mukdar</th>
                                    <th>Transport No</th>
                                    <th>Ugramaly Sene</th>
                                    <th>Bellik</th>
                                    <th>Statusy</th>
                                    <th>Ýük Çalyşmak</th>
                                    <th>Sazlamalar</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">
                            <div class="modal-content" id="modal-form">



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

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

            </div>

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


{% put scripts %}
<script src="{{'assets/libs/bootstrap-datepicker/js/bootstrap-datepicker.min.js'|theme}}"></script>
<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' %}
