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


    $mechanicId = $this->param("mechanicId");
    $month = $this->param("month");


    $this["mechanicProductions"] = Romanah\Gokbakja\Models\ProductionMachine::where('mechanic_id', $mechanicId)->whereMonth('created_at', $month)->whereYear('created_at', $this["currentYear"])->with(['bag_type', 'bag_size', 'machine.building', 'employee', 'mechanic'])->get();


    $this["month_all_amount"] = Romanah\Gokbakja\Models\ProductionMachine::whereMonth('created_at',  $month)
                                ->whereYear('created_at', $this["currentYear"])
                                ->sum('produced_weight');

}
?>
==
{% 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">

    <!-- 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;">Enjamlar boýunça
                                ({{month}}.{{currentYear}})</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>Bina No</th>
                                <th>Enjam No</th>
                                <th>Ölçegi</th>
                                <th>Görnüşi</th>
                                <th>Önen Önüm (kg)</th>
                                <th>Ady Familiýasy</th>
                                <th>Mehanik</th>
                                <th>Bellik</th>
                                <!--  <th>Настройки</th> -->
                            </tr>
                        </thead>
                        <tbody>

                            {% for key, machine in mechanicProductions %}
                            <tr>
                                <td style="font-weight: bold;">{{key + 1}}</td>
                                <td><a href="#" style="font-weight: bold;">{{machine.building_name}}</a></td>
                                <td>{{machine.machine.name}}</td>
                                <td>{{machine.bag_size.name}}</td>
                                <td>{{machine.bag_type.name}}</td>
                                <td><span class="badge badge-soft-success"
                                    style="font-size: 14px;">{{machine.produced_weight|number_format}} kg</span></td>
                                <td>{{machine.employee_name}}</td>
                                <td>{{machine.mechanic_name}}</td>
                                <td>{{machine.note}}</td>
                            </tr>
                            {% endfor %}

                            <tr>
                                <td style="font-weight: bold;width: 5%;">#</td>
                                <td style="font-weight: bold;width: 5%;">JEMI</td>
                                <td style="font-weight: bold;width: 5%;"></td>
                                <td style="font-weight: bold;width: 5%;"></td>
                                <td style="font-weight: bold;width: 5%;"></td>

                                <td style="text-align: center;">
                                    <span class="badge badge-soft-info"
                                    style="font-size: 14px;">{{month_all_amount|number_format}} kg</span>
                                </td>
                                <td style="font-weight: bold;width: 5%;"></td>
                                <td style="font-weight: bold;width: 5%;"></td>



                                <td style="font-weight: bold;color: #0005c5;"></td>
                            </tr>
                        </tbody>
                        <tfoot>
                            <tr>
                                <th style="width: 5%;">№</th>
                                <th>Bina No</th>
                                <th>Enjam No</th>
                                <th>Ölçegi</th>
                                <th>Görnüşi</th>
                                <th>Önen Önüm (kg)</th>
                                <th>Ady Familiýasy</th>
                                <th>Mehanik</th>
                                <th>Bellik</th>
                            </tr>
                        </tfoot>
                    </table>
                </div>



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

</div>

{% partial 'dataTableJs' %}
