title = "All production by month"
url = "/all-production-month/:month/:year?"
layout = "platform_main"
is_hidden = 0
==
<?php
function onStart() {
    $currentDate = Carbon\Carbon::now();
    $this["month"] = $this->param("month");
    $year = $this->param("year");

    $this["reportProducts"] = Romanah\Gokbakja\Models\Product::where("report", "simple")->orderBy('order', 'ASC')->get();

    if($this["month"] == 'default'){
        $this["month"] = $currentDate->month;
    }

    if($year){
        $this["productions"] = Romanah\Gokbakja\Models\Production::whereMonth('date', $this["month"])->whereYear('date', $year)->with(['pivot_production'])->get();


        $this["month_all_amount_calcq"] = Romanah\Gokbakja\Models\ProductionCalculate::whereMonth('date', $this["month"])->whereYear('date', $year)->sum("amount_calc");

    }else{
        $this["productions"] = Romanah\Gokbakja\Models\Production::whereMonth('date', $this["month"])->whereYear('date', $currentDate->year)->with(['pivot_production'])->get();


        $this["month_all_amount_calcq"] = Romanah\Gokbakja\Models\ProductionCalculate::whereMonth('date', $this["month"])->whereYear('date', $currentDate->year)->sum("amount_calc");
    }
}
?>
==
{% 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">

    <!-- 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">Aýlar Boýunça {{year}}</h4>

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

    <div class="row">
        <div class="col-12">
            <!-- Left sidebar -->
            <div class="email-leftbar card">
                <a href="/excruiters" type="button" class="btn btn-danger waves-effect waves-light">
                    Täze Hasabat
                </a>
                <div class="mail-list mt-4">
                    <a href="/all-production-month/1" class="{{ month == 1 ? 'active' : '' }}"><i
                            class="mdi mdi-archive me-2 font-size-16"></i> Ýanwar</a>
                    <a href="/all-production-month/2" class="{{ month == 2 ? 'active' : '' }}"><i
                            class="mdi mdi-archive me-2 font-size-16"></i> Fewral</a>
                    <a href="/all-production-month/3" class="{{ month == 3 ? 'active' : '' }}"><i
                            class="mdi mdi-archive me-2 font-size-16"></i> Mart</a>
                    <a href="/all-production-month/4" class="{{ month == 4 ? 'active' : '' }}"><i
                            class="mdi mdi-archive me-2 font-size-16"></i> Aprel</a>
                    <a href="/all-production-month/5" class="{{ month == 5 ? 'active' : '' }}"><i
                            class="mdi mdi-archive me-2 font-size-16"></i> Maý</a>
                    <a href="/all-production-month/6" class="{{ month == 6 ? 'active' : '' }}"><i
                            class="mdi mdi-archive me-2 font-size-16"></i> Iýun</a>
                    <a href="/all-production-month/7" class="{{ month == 7 ? 'active' : '' }}"><i
                            class="mdi mdi-archive me-2 font-size-16"></i> Iýul</a>
                    <a href="/all-production-month/8" class="{{ month == 8 ? 'active' : '' }}"><i
                            class="mdi mdi-archive me-2 font-size-16"></i> Awgust</a>
                    <a href="/all-production-month/9" class="{{ month == 9 ? 'active' : '' }}"><i
                            class="mdi mdi-archive me-2 font-size-16"></i> Sentýabr</a>
                    <a href="/all-production-month/10" class="{{ month == 10 ? 'active' : '' }}"><i
                            class="mdi mdi-archive me-2 font-size-16"></i> Oktýabr</a>
                    <a href="/all-production-month/11" class="{{ month == 11 ? 'active' : '' }}"><i
                            class="mdi mdi-archive me-2 font-size-16"></i> Noýabr</a>
                    <a href="/all-production-month/12" class="{{ month == 12 ? 'active' : '' }}"><i
                            class="mdi mdi-archive me-2 font-size-16"></i> Dekabr</a>

                </div>



            </div>
            <!-- End Left sidebar -->


            <!-- Right Sidebar -->
            <div class="email-rightbar mb-3">

                <div class="card">




                    <div class="card-body">
                        <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='80'>
                            <thead>
                                <tr>
                                    <th style="width: 5%;">№</th>
                                    <th>Senesi</th>
                                    <th>Hemmesi</th>
                                    <th>Harytlar</th>
                                    <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="/get-production/{{report.id}}"
                                            style="font-weight: bold;color: #0005c5;">{{report.date|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>
                                    <td>
                                        <div class="row">
                                            {% for product in report.pivot_production %}
                                            <div class="col">
                                                <font style="font-weight: bold;"> {{product.product_code}}: </font>
                                                {{product.amount_percentage}} %
                                            </div>
                                            {% endfor %}
                                        </div>
                                    </td>
                                    <td style="font-weight: bold;color: #0005c5;">{{report.note}}</td>
                                </tr>
                                {% endfor %}


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

                                    <td style="text-align: center;">
                                        <span class="badge badge-soft-info"
                                            style="font-size: 14px;">{{month_all_amount_calcq|number_format}} kg</span>
                                    </td>
                                    <td style="text-align: center;">
                                        <div class="row">
                                            {% for key, product in reportProducts %}
                                            {% partial 'report/product-month-row' product_code=product.code
                                            prodId=product.id all_amount=month_all_amount_calc.amount_subtraction %}
                                            {% endfor %}
                                        </div>
                                    </td>
                                    <td style="font-weight: bold;color: #0005c5;"></td>
                                </tr>

                            </tbody>
                            <tfoot>
                                <tr>
                                    <th style="width: 5%;">№</th>
                                    <th>Senesi</th>
                                    <th>Hemmesi</th>
                                    <th>Harytlar</th>
                                    <th>Bellik</th>
                                </tr>
                            </tfoot>
                        </table>

                    </div>

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

            </div>

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


{% partial 'dataTableJs' %}
