title = "order-detail/payment"
url = "/order-detail/payment/: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["payments"] = Romanah\Gokbakja\Models\Payment::where("order_id", $orderId)->orderBy("id", "DESC")->get();

    $this["allPaid"] = Romanah\Gokbakja\Models\Payment::where("order_id", $orderId)->sum("amount");
    $this["allNot"] = ($this["all"] - $this["allPaid"]);

}
?>
==
{% 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=3 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="onCreatePaymentItem" data-request-flash data-request-validate>
                                <div class="card">
                                    <div class="card-body">
                                        <div class="row">


                                            <div class="col">
                                                <label class="form-label">Sene</label>
                                                <div class="input-group" id="datepicker2">
                                                    <input type="text" class="form-control" name="date" placeholder="Sene"
                                                        data-date-format="d.m.yyyy" data-date-container='#datepicker2' data-provide="datepicker"
                                                        data-date-autoclose="true">

                                                    <span class="input-group-text"><i class="mdi mdi-calendar"></i></span>
                                                </div>
                                            </div>
                                            <div class="col">
                                                <div>
                                                    <label class="form-label">Tölenen Mukdar ($)</label>
                                                    <input type="number" name="amount" step="0.01" class="form-control"
                                                        placeholder="Tölenen Mukdar ($)">
                                                </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 Töleg Maglumatlary</h3>
                                <p class="card-title-desc" style="color: darkgreen;font-size: 17px;margin-bottom: 0px;" id="all_payment">Jemi Tölenen Töleg: {{allPaid|number_format}} $</p>
                                <p class="card-title-desc" style="color: darkred;font-size: 17px;" id="all_not">Bergisi: {{allNot|number_format}} $</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">Töleg
                                    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>Mukdary</th>
                                    <th>Senesi</th>
                                    <th>Bellik</th>
                                    <th>Sazlamalar</th>
                                </tr>
                            </thead>
                            <tbody id="payment_item_datas">
                                {% for key, payment in payments %}
                                <tr>
                                    <td style="font-weight: bold;">{{(key+1)}}</td>
                                    <td><a href="#" style="font-weight: bold;">{{payment.amount}} $</a></td>
                                    <td><a href="#" style="font-weight: bold;">{{payment.date != null ? payment.date|date('d.m.Y') : ""}}</a></td>
                                    <td>{{payment.note}}</td>
                                    <td><a href="#" data-request="onModalSetPayment"
                                        data-request-data="paymentId: {{payment.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>Mukdary</th>
                                    <th>Senesi</th>
                                    <th>Bellik</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' %}
