title = "Get Production"
url = "/get-production/:id"
layout = "platform_main"
is_hidden = 0
==
<?php
function onStart() {
    $currentDate = Carbon\Carbon::now();
    $this["currentYear"] = $currentDate->year;

    $productionId = $this->param("id");

    $this["production"] = Romanah\Gokbakja\Models\Production::where('id', $productionId)->with('pivot_production')->first();


    $productionD = $this["production"]->created_at->format('d');
    $productionM = $this["production"]->created_at->format('m');
    $productionY = $this["production"]->created_at->format('Y');

    $this["productionM"] = $this["production"]->created_at->format('m');

    $this["productions"] = Romanah\Gokbakja\Models\Production::whereDay('created_at', $productionD)->whereMonth('created_at', $productionM)->whereYear('created_at', $productionY)->with('pivot_production')->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" />
{% endput %}

<div class="container-fluid">
    <div class="row">
        <div class="col-lg-6">
            <a href="/all-productions/{{productionM}}" class="card bg-primary text-white-50">
                <div class="card-body">
                    <h5 class="mb-4 text-white"><i class="mdi mdi-bullseye-arrow me-3"></i> HEMMESI</h5>
                    <p class="card-text">Bu bölümde hasabatyň aýlar boýunça ählisini görüp bilersiňiz.</p>
                </div>
            </a>
        </div>
        <div class="col-lg-6">
            <a href="/report-production/{{currentYear}}" class="card bg-primary text-white-50">
                <div class="card-body">
                    <h5 class="mb-4 text-white"><i class="mdi mdi-bullseye-arrow me-3"></i> ORTAÇA ÖNÜMÇILIK</h5>
                    <p class="card-text">Bu bölümde ortaça önümçilik boýunça hasabat.</p>
                </div>
            </a>
        </div>
        <!-- <div class="col-lg-4">
            <div class="card bg-primary text-white-50">
                <div class="card-body">
                    <h5 class="mb-4 text-white"><i class="mdi mdi-bullseye-arrow me-3"></i> Primary Card</h5>
                    <p class="card-text">Some quick example text to build on the card title and make up the bulk of the
                        card's content.</p>
                </div>
            </div>
        </div> -->

    </div>
    <!-- end row -->
    <div class="row">
        <div class="col-md-12">
            <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;">Çig Mallar Boýunça
                                ({{production.created_at|date('d.m.Y | H:i')}})</h3>
                            <p class="card-title-desc" style="color: #6c6ff5;">Hasabat</p>
                        </div>
                        <!-- <div class="col-md-6" style="text-align: right;">
                            <button type="button" class="btn btn-primary waves-effect waves-light"
                                data-bs-toggle="offcanvas" data-bs-target="#offcanvasBottom"
                                aria-controls="offcanvasBottom">
                                <i class="ri-add-line align-middle ms-2" style="font-size: 17px;"></i> Добавить
                            </button>
                        </div> -->
                    </div>


                    <table id="datatable-buttons" class="table table-striped table-bordered dt-responsive nowrap"
                        style="border-collapse: collapse; border-spacing: 0; width: 100%;">
                        <thead>
                            <tr>
                                <th style="width: 5%;">№</th>
                                <th>Senesi</th>
                                <th>Hemmesi</th>
                                {% for key, record in production.pivot_production %}
                                <th>{{record.product_name}}</th>
                                {% endfor %}
                                <th>Bellik</th>
                                <!--  <th>Настройки</th> -->
                            </tr>
                        </thead>
                        <tbody>

                            {% for key, report in productions %}
                            <tr>
                                <td style="font-weight: bold;width: 5%;">{{key + 1}}</td>
                                <td><a href="#" style="font-weight: bold;color: #0005c5;">{{report.created_at|date('d.m.Y |
                                        H:i')}}</a></td>
                                <td style="text-align: center;">
                                    <span class="badge badge-soft-success"
                                        style="font-size: 14px;">{{report.all_amount|number_format}} kg</span>
                                </td>

                                {% for product in report.pivot_production %}
                                <td>{{product.amount_percentage}} % {% if product.amount != 0  %}<br> <span style="font-size: 12px;color: darkgray;"> {{product.amount|number_format}} kg</span> {% endif %}</td>
                                {% endfor %}

                                <td style="font-weight: bold;color: #0005c5;">{{report.note}}</td>
                            </tr>
                            {% endfor %}

                        </tbody>
                        <tfoot>
                            <tr>
                                <th style="width: 5%;">№</th>
                                <th>Senesi</th>
                                <th>Hemmesi</th>
                                {% for key, record in production.pivot_production %}
                                <th>{{record.product_name}}</th>
                                {% endfor %}
                                <th>Bellik</th>
                            </tr>
                        </tfoot>
                    </table>
                </div>



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

</div>

{% partial 'dataTableJs' %}
