title = "produced/bag/stock"
url = "/produced/bag/stock/:stockId"
layout = "platform_main"
is_hidden = 0
==
<?php
function onStart(){
    $stockId = $this->param("stockId");

    $this["actions"] = Romanah\Gokbakja\Models\BagAction::select('romanah_gokbakja_bag_actions.*')
                        ->with(['product.rulon_action.product.bag_type', 'product.rulon_action.product.color', 'product.pivot_sewer'])
                        ->where("stock_id", $stockId)
                        //->where("status_accountant", "accept")
                        //->where("status_director", "accept")
                        ->addSelect(DB::raw("SUM(amount) as quantity"))
                        ->having('quantity', '>', 0)
                        ->groupBy('romanah_gokbakja_bag_actions.product_id')
                        ->orderBy('id', 'DESC')
                        ->get();


    $this["actionsQtyCount"] = Romanah\Gokbakja\Models\BagAction::select('romanah_gokbakja_bag_actions.*')
                        ->where("stock_id", $stockId)
                        //->where("status_accountant", "accept")
                        //->where("status_director", "accept")
                        ->sum('amount');

        // dd($this["actions"]);
}
?>
==
{% 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">

<link href="{{'assets/libs/bootstrap-datepicker/css/bootstrap-datepicker.min.css'|theme}}" rel="stylesheet">
<link href="{{'assets/libs/spectrum-colorpicker2/spectrum.min.css'|theme}}" rel="stylesheet" type="text/css">
<link href="{{'assets/libs/bootstrap-touchspin/jquery.bootstrap-touchspin.min.css'|theme}}" rel="stylesheet">
{% endput %}


<div class="container-fluid">

    <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;text-transform: capitalize;">
                               Dikilen Haltalar</h3>
                            <p class="card-title-desc" style="color: #6c6ff5;">sklad</p>
                        </div>
                        <div class="col-md-6">
                            <div class="card bg-info text-white-50">
                                <div class="card-body">
                                    <h5 class="text-white" style="text-transform: uppercase;margin-bottom: 0;"><i
                                            class="mdi mdi-bullseye-arrow me-3"></i> Umumy halta sany: {{actionsQtyCount}}</h5>
                                </div>
                            </div>
                        </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>Dikiş Kody</th>
							<th>Halta Ölçegi</th>
							<th>Halta Gramy</th>
							<th>Ulanylan Material</th>
							<th>Hereket</th>
							<th>Mukdary (sany)</th>
							<th>Sene</th>
							<th>Sklad</th>
						</tr>
					</thead>
					<tbody>
                        {% for key, record in actions %}
						<tr>
							<td style="font-weight: bold;width: 5%;">{{key + 1}}</td>
							<td><a href="/sewer/new">#Dikiş{{record.product_id}}</a></td>
							<td>ini: {{record.product.width}} x boýy: {{record.product.height}}</td>
                            <td>{{record.product.bag_gram|number_format}} gr</td>
							<td style="text-align: center;">

                                {% if record.product.rulon_action_id == 0 %}
                                <span class="badge badge-soft-warning" style="font-size: 14px;">
                                    Sürülmedik Täzeden Sürülen
                                </span>
                                {% else %}
                                <span class="badge badge-soft-primary" style="font-size: 14px;">
                                #Rulon{{record.product.rulon_action.product.id}} - {{record.product.rulon_action.product.bag_type.name}}, {{record.product.rulon_action.product.color.name}}
                                </span>
                                {% endif %}

                           </td>
							<td style="text-align: center;">
							<span class="badge badge-soft-{% if record.type == 'inbox' %}success {% else %}danger {% endif %}" style="font-size: 14px;">{{record.type}}</span></td>
							<td style="color: #500101;font-weight: bold;">{{record.quantity|number_format}} sany</td>
							<td>{{record.created_at|date('d.m.Y')}}</td>
							<td>{{record.stock.name}}</td>

						</tr>
                       {% endfor %}
					</tbody>
					<tfoot>
						<tr>
							<th style="width: 5%;">№</th>
							<th>Dikiş Kody</th>
							<th>Halta Ölçegi</th>
                            <th>Halta Gramy</th>
                            <th>Ulanylan Material</th>
							<th>Hereket</th>
							<th>Mukdary (sany)</th>
							<th>Sene</th>
							<th>Sklad</th>
						</tr>
					</tfoot>
				</table>
                </div>




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

</div>


{% put scripts %}

<script src="{{'assets/libs/select2/js/select2.min.js'|theme}}"></script>
<script src="{{'assets/libs/bootstrap-datepicker/js/bootstrap-datepicker.min.js'|theme}}"></script>
<script src="{{'assets/libs/spectrum-colorpicker2/spectrum.min.js'|theme}}"></script>
<script src="{{'assets/libs/bootstrap-touchspin/jquery.bootstrap-touchspin.min.js'|theme}}"></script>
<script src="{{'assets/libs/admin-resources/bootstrap-filestyle/bootstrap-filestyle.min.js'|theme}}"></script>
<script src="{{'assets/libs/bootstrap-maxlength/bootstrap-maxlength.min.js'|theme}}"></script>

<script src="{{'assets/js/pages/form-advanced.init.js'|theme}}"></script>
{% endput %}

{% partial 'dataTableJs' %}
