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

    $this["actions"] = Romanah\Gokbakja\Models\Action::select('romanah_gokbakja_action.*')
                        ->where("stock_id", $stockId)
                        ->where("status_accountant", "accept")
                        ->where("status_director", "accept")
                        ->addSelect(DB::raw("SUM(amount) as quantity"))
                        ->groupBy('romanah_gokbakja_action.product_id')
                        ->get();
        // 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;">
                                Harytlar</h3>
                            <p class="card-title-desc" style="color: #6c6ff5;">sklad</p>
                        </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>Haryt</th>
							<th>Hereket</th>
							<th>Mukdary (KG)</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="{{'action/product'|page({prodId:record.product_id})}}"
									style="font-weight: bold;color: #0005c5;">{{record.product.name}}</a></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}} kg</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>Haryt</th>
							<th>Hereket</th>
							<th>Mukdary (KG)</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' %}
