g_sto/themes/gokbakja/pages/orders/transportloaded.htm

327 lines
16 KiB
HTML

title = "orders/transportLoaded"
url = "/orders/transport/loaded/:orderId/:transportId?"
layout = "platform_main"
is_hidden = 0
[loadTransport]
==
<?php
function onStart(){
$this["orderId"] = $this->param("orderId");
$this["transportId"] = $this->param("transportId");
$orderId = $this->param("orderId");
$this["order"] = Romanah\Gokbakja\Models\Order::where("id", $orderId)->with(["client", "shipping"])
->withCount(['order_items as order_all_amount' => function($query) {
$query->select(DB::raw('sum(amount)'));
}])
->withCount(['order_items as order_all_price' => function($query) {
$query->select(DB::raw('sum(price)'));
}])
->first();
$this["orderItems"] = Romanah\Gokbakja\Models\OrderItem::where("order_id", $orderId)->orderBy('id', 'DESC')->get();
$this["loadedItems"] = Romanah\Gokbakja\Models\LoadTransport::where("order_id", $orderId)->where("transport_id", $this["transportId"])->with("order_item")->orderBy("id", "DESC")->get();
$this["transport"] = Romanah\Gokbakja\Models\ShippingTransport::where("id", $this["transportId"] )->first();
$this["loadedItemsSum"] = Romanah\Gokbakja\Models\LoadTransport::where("order_id", $orderId)->where("transport_id", $this["transportId"])->with("order_item")->sum("loaded_amount");
}
?>
==
{% 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">
{% 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">Transport Maglumatlary</h4>
</div>
</div>
</div>
<!-- end page title -->
<div class="row">
<div class="col-12">
<!-- Left sidebar -->
<div class="email-leftbar card">
{% partial "order/aside" active=2 orderId=orderId %}
</div>
<!-- End Left sidebar -->
<!-- Right Sidebar -->
<div class="email-rightbar mb-3">
<div class="row">
{% if crudOrders %}
<div class="col-md-12">
<div class="collapse multi-collapse" id="multiCollapseExample1">
<form data-request="onCreateLoadItem" data-request-flash data-request-validate>
<div class="card">
<div class="card-body">
<div class="row">
<div class="col">
<label class="form-label">Haryt Saýlaň</label>
<select class="form-control select2" name="order_item_id" onchange="calculateLoaded(this.value);">
<option value="0">Saýla</option>
{% for item in orderItems %}
<option value="{{item.id}}">
{% if item.order_item_type == 'rulon' %}
#{{item.id}}-Rulon, jemi: {{item.amount}} kg
{% else %}
#{{item.id}}-Halta, jemi: {{item.amount}} sany, {{item.bag_gram}} gr
{% endif %}
</option>
{% endfor %}
</select>
</div>
<div class="col" id="inStockProducts">
</div>
<div class="col">
<div>
<label class="form-label" id="loadedCalc">Ýüklenmeli Mukdar</label>
<input type="number" step="0.01" name="loaded_amount" class="form-control"
placeholder="Ýüklenmeli Mukdar">
</div>
</div>
<div class="col">
<div>
<label class="form-label">Bellik</label>
<input type="text" name="note" class="form-control"
placeholder="Bellik">
</div>
</div>
<div class="col">
<button type="submit" class="btn btn-primary waves-effect waves-light"
style="margin-top: 30px;width: 100%;">Goş</button>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
{% endif %}
</div>
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-md-9">
<h3 class="card-title" style="font-size: 22px;color: #1e2038;">
Transport kody: #{{transport.id}}
{% if transport.transport_type == "truck" %}
Tyr
{% else %}
Wagon
{% endif %}
, Sene: {{transport.date|date('d.m.Y')}},
{{transport.transport_no}},
<font style="color: darkgreen;">JEMI ÝÜKLENEN: {{loadedItemsSum}} kg</font>
</h3>
<p class="card-title-desc" style="color: #6c6ff5;font-size: 17px;" ></p>
</div>
<div class="col-md-3" style="text-align: right;">
<a href="/order-detail/logistics/{{orderId}}" style="height: 38px;" type="button" class="btn btn-danger waves-effect waves-light">
<i class="ri-arrow-left-line align-middle ms-2" style="font-size: 17px;"></i> Yza
</a>
{% if crudOrders %}
{% if order.user_id == user.id %}
{% if transport.status == 'loading' or transport.status == 'loaded' %}
<a class="btn btn-primary" data-bs-toggle="collapse" href="#multiCollapseExample1"
role="button" aria-expanded="false" aria-controls="multiCollapseExample1">Haryt Ýükle</a>
{% endif %}
{% endif %}
{% endif %}
</div>
</div>
<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='13'>
<thead>
<tr>
<th style="width: 5%;"></th>
<th>Tapgyr Kody</th>
<th>Haryt Kody</th>
<th>Haryt</th>
<th>Ýüklenen Mukdary</th>
<th>Bellik</th>
<th>Sazlamalar</th>
</tr>
</thead>
<tbody id="transport_item_datas">
{% for key, loadedItem in loadedItems %}
<tr>
<td>{{key+1}}</td>
<td>#{{loadedItem.id}}</td>
<td>#{{loadedItem.order_item_id}}</td>
<td>
{% if loadedItem.order_item.order_item_type == 'rulon' %}
Rulon, Jemi: {{loadedItem.order_item.amount}} kg
{% else %}
Halta, Jemi: {{loadedItem.order_item.amount}} sany, {{loadedItem.order_item.bag_gram}} gr
{% endif %}
</td>
<td>{{loadedItem.loaded_amount}}</td>
<td>{{loadedItem.note}}</td>
<td>
{% if order.user_id == user.id %}
<!-- <button data-request="onSetUpdateForm"
data-request-data="itemId: {{loadedItem.id}}"
data-bs-toggle="modal" data-bs-target=".bs-example-modal-sm-1" type="button" class="btn btn-warning waves-light waves-effect"><i class="fa fa-pen"></i></button> -->
{% if crudOrders %}
{% if transport.status == 'loading' or transport.status == 'loaded' %}
<button data-request="onDeleteItem"
data-request-confirm="Tapgyr #{{loadedItem.id}} pozmak isleýäňizmi?"
data-request-data="itemId: {{loadedItem.id}}"
type="button" class="btn btn-danger waves-light waves-effect"><i class="fa fa-trash-alt"></i></button>
{% endif %}
{% endif %}
{% else %}
<a href="#" style="color: orange;"> Size degişli däl </a>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
<tfoot>
<tr>
<th style="width: 5%;"></th>
<th>Tapgyr Kody</th>
<th>Haryt Kody</th>
<th>Haryt</th>
<th>Ýüklenen Mukdary</th>
<th>Bellik</th>
<th>Sazlamalar</th>
</tr>
</tfoot>
</table>
</div>
<div class="modal fade bs-example-modal-sm-1" tabindex="-1" role="dialog"
aria-labelledby="mySmallModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content" id="modal-form">
</div>
</div>
</div>
</div> <!-- card -->
</div>
</div>
</div>
<!-- End row -->
</div>
{% put scripts %}
<script>
$('#inStockProducts').hide();
function calculateLoaded(itemId) {
$.request('onCalculateLoaded', {
data: { 'item_id': itemId },
success: function (data) {
$("#loadedCalc").html(`Ýüklenmeli Mukdar <font style="color: red;"> (jemi ýüklenen: ` + data.loadedSum + `)</font>`);
$('#inStockProducts').show();
var dropDownProducts = '';
if(data.productFromStock.inStockAmount > 0){
dropDownProducts = `<label class="form-label">Sklatdan Haryt Saýlaň</label>
<select class="form-control select2" name="product_id" id="testq">
<option value="0">Saýla</option>`;
if(data.productFromStock.orderItemType == "rulon"){
var option = '';
for (var item of data.productFromStock.products) {
option += `<option value="`+item.product_id+`">#Rulon` + (item.product_id) + `- sklatda: ` + (item.quantity) + ` kg, ` + (item.product.bag_type.name)+`, Ölçegi: `+ (item.product.width)+`, ` + (item.product.gram)+ `m2, `+ (item.product.layer) + ` gat, ` + (item.product.color.name) +`</option>`;
}
dropDownProducts +=option;
// console.log(option);
}else{
var option = '';
for (var item of data.productFromStock.products) {
option += `<option value="`+item.product_id+`">#Dikiş`+ (item.product_id)+ `- sklatda: ` +(item.quantity) + ` sany ,` + (item.product.pivot_sewer[0].bag_gram)+ ` gr` +`</option>`;
}
dropDownProducts +=option;
}
dropDownProducts += `</select>`;
dropDownProducts += `<input type="hidden" name="product_type" value="`+data.productFromStock.orderItemType+`">`;
$('#inStockProducts').html(dropDownProducts);
$('#testq').select2();
}else{
dropDownProducts = `<label class="form-label">Sklatda Bu Haryt Ýok</label>
<select class="form-control" disabled>
<option value="0">Saýla</option>
</select>`;
$('#inStockProducts').html(dropDownProducts);
}
}
});
}
</script>
<script src="{{'assets/libs/bootstrap-datepicker/js/bootstrap-datepicker.min.js'|theme}}"></script>
<script src="{{'assets/libs/select2/js/select2.min.js'|theme}}"></script>
<script src="{{'assets/js/pages/form-advanced.init.js'|theme}}"></script>
{% endput %}
{% partial 'dataTableJs' %}