|
|
|
|
@ -3,97 +3,103 @@
|
|
|
|
|
@using Nop.Core.Domain.Tax;
|
|
|
|
|
@using Nop.Core.Domain.Catalog;
|
|
|
|
|
|
|
|
|
|
<div class="card-body">
|
|
|
|
|
<div class="form-group row">
|
|
|
|
|
<div class="col-md-12" style="overflow-x: auto;">
|
|
|
|
|
@foreach (var item in Model.Items)
|
|
|
|
|
{
|
|
|
|
|
<script>
|
|
|
|
|
$(function() {
|
|
|
|
|
toggleOrderItemEdit@(item.Id)(false);
|
|
|
|
|
// Attach event listeners for automatic calculation
|
|
|
|
|
setupAutoCalculation@(item.Id)();
|
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
<script>
|
|
|
|
|
function calculateTotalGlobal(itemId, maxQuantity) {
|
|
|
|
|
//var isMeasurable = $('#pvIsMeasurable'+itemId).is(':checked');
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
// Function to automatically calculate and update total price
|
|
|
|
|
function calculateTotal@(item.Id)() {
|
|
|
|
|
// Get values
|
|
|
|
|
|
|
|
|
|
@* var isMeasurable = ($('#pvIsMeasurable@(item.Id)').val()).toLowerCase() === "true"; *@
|
|
|
|
|
|
|
|
|
|
var isMeasurable = $($('#pvIsMeasurable@(item.Id)')).is(':checked');
|
|
|
|
|
var isMeasurable = $('#pvIsMeasurable'+itemId).val().toLowerCase() === 'true';
|
|
|
|
|
console.log(isMeasurable);
|
|
|
|
|
console.log(($('#pvIsMeasurable@(item.Id)')));
|
|
|
|
|
console.log(($('#pvIsMeasurable@(item.Id)').val()));
|
|
|
|
|
console.log(($('#pvIsMeasurable@(item.Id)').val()).toLowerCase());
|
|
|
|
|
console.log($('#pvIsMeasurable'+itemId));
|
|
|
|
|
console.log($('#pvIsMeasurable'+itemId).val());
|
|
|
|
|
console.log($('#pvIsMeasurable'+itemId).val().toLowerCase());
|
|
|
|
|
console.log($('#pvNetWeight'+itemId).val());
|
|
|
|
|
|
|
|
|
|
var netWeight = parseFloat($('#pvNetWeight'+itemId).val()) || 0;
|
|
|
|
|
|
|
|
|
|
var netWeight = parseFloat($('#pvNetWeight@(item.Id)').val()) || 0;
|
|
|
|
|
var unitPriceInclTax = parseFloat($('#pvUnitPriceInclTax'+itemId).val()) || 0;
|
|
|
|
|
var unitPriceExclTax = parseFloat($('#pvUnitPriceExclTax'+itemId).val()) || 0;
|
|
|
|
|
var quantity = parseInt($('#pvQuantity'+itemId).val()) || 0;
|
|
|
|
|
var discountInclTax = parseFloat($('#pvDiscountInclTax'+itemId).val()) || 0;
|
|
|
|
|
var discountExclTax = parseFloat($('#pvDiscountExclTax'+itemId).val()) || 0;
|
|
|
|
|
|
|
|
|
|
var unitPriceInclTax = parseFloat($('#pvUnitPriceInclTax@(item.Id)').val()) || 0;
|
|
|
|
|
var unitPriceExclTax = parseFloat($('#pvUnitPriceExclTax@(item.Id)').val()) || 0;
|
|
|
|
|
var quantity = parseFloat($('#pvQuantity@(item.Id)').val()) || 0;
|
|
|
|
|
var discountInclTax = parseFloat($('#pvDiscountInclTax@(item.Id)').val()) || 0;
|
|
|
|
|
var discountExclTax = parseFloat($('#pvDiscountExclTax@(item.Id)').val()) || 0;
|
|
|
|
|
if (quantity > maxQuantity || quantity < 0) {
|
|
|
|
|
if (quantity > maxQuantity) quantity = maxQuantity; else quantity = 0;
|
|
|
|
|
$('#pvQuantity' + itemId).val(quantity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (unitPriceInclTax < 0) {
|
|
|
|
|
unitPriceInclTax = 0;
|
|
|
|
|
$('#pvUnitPriceInclTax' + itemId).val(unitPriceInclTax);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Calculate totals
|
|
|
|
|
var totalInclTax = (unitPriceInclTax * (isMeasurable ? netWeight : quantity)) - discountInclTax;
|
|
|
|
|
var totalExclTax = (unitPriceExclTax * (isMeasurable ? netWeight : quantity)) - discountExclTax;
|
|
|
|
|
|
|
|
|
|
// Update total price fields
|
|
|
|
|
$('#pvPriceInclTax@(item.Id)').val(totalInclTax.toFixed(0));
|
|
|
|
|
$('#pvPriceExclTax@(item.Id)').val(totalExclTax.toFixed(0));
|
|
|
|
|
$('#pvPriceInclTax'+itemId).val(totalInclTax.toFixed(0));
|
|
|
|
|
$('#pvPriceExclTax'+itemId).val(totalExclTax.toFixed(0));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Function to setup event listeners for automatic calculation
|
|
|
|
|
function setupAutoCalculation@(item.Id)() {
|
|
|
|
|
function setupAutoCalculationGlobal(itemId) {
|
|
|
|
|
// Attach change and input events to all relevant fields
|
|
|
|
|
$('#pvUnitPriceInclTax@(item.Id), #pvUnitPriceExclTax@(item.Id), #pvQuantity@(item.Id), #pvDiscountInclTax@(item.Id), #pvDiscountExclTax@(item.Id)').on('input change', function() {
|
|
|
|
|
calculateTotal@(item.Id)();
|
|
|
|
|
$('#pvUnitPriceInclTax'+itemId+', #pvUnitPriceExclTax'+itemId+', #pvQuantity'+itemId+', #pvDiscountInclTax'+itemId+', #pvDiscountExclTax'+itemId).on('input change', function() {
|
|
|
|
|
calculateTotalGlobal(itemId);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function toggleOrderItemEdit@(item.Id)(editMode) {
|
|
|
|
|
function toggleOrderItemEditGlobal(editMode, itemId) {
|
|
|
|
|
if (editMode) {
|
|
|
|
|
$('#pnlEditPvUnitPrice@(item.Id)').showElement();
|
|
|
|
|
$('#pnlEditPvQuantity@(item.Id)').showElement();
|
|
|
|
|
$('#pnlEditPvDiscount@(item.Id)').showElement();
|
|
|
|
|
$('#pnlEditPvPrice@(item.Id)').showElement();
|
|
|
|
|
$('#btnSaveOrderItem@(item.Id)').showElement();
|
|
|
|
|
$('#btnCancelOrderItem@(item.Id)').showElement();
|
|
|
|
|
$('#pnlEditPvUnitPrice'+itemId).showElement();
|
|
|
|
|
$('#pnlEditPvQuantity'+itemId).showElement();
|
|
|
|
|
$('#pnlEditPvDiscount'+itemId).showElement();
|
|
|
|
|
$('#pnlEditPvPrice'+itemId).showElement();
|
|
|
|
|
$('#btnSaveOrderItem'+itemId).showElement();
|
|
|
|
|
$('#btnCancelOrderItem'+itemId).showElement();
|
|
|
|
|
|
|
|
|
|
$('#pvUnitPriceInclTax@(item.Id)').prop("disabled", false);
|
|
|
|
|
$('#pvUnitPriceExclTax@(item.Id)').prop("disabled", false);
|
|
|
|
|
$('#pvQuantity@(item.Id)').prop("disabled", false);
|
|
|
|
|
$('#pvDiscountInclTax@(item.Id)').prop("disabled", false);
|
|
|
|
|
$('#pvDiscountExclTax@(item.Id)').prop("disabled", false);
|
|
|
|
|
$('#pvPriceInclTax@(item.Id)').prop("disabled", false);
|
|
|
|
|
$('#pvPriceExclTax@(item.Id)').prop("disabled", false);
|
|
|
|
|
$('#pvUnitPriceInclTax'+itemId).prop("disabled", false);
|
|
|
|
|
$('#pvUnitPriceExclTax'+itemId).prop("disabled", false);
|
|
|
|
|
$('#pvQuantity'+itemId).prop("disabled", false);
|
|
|
|
|
$('#pvDiscountInclTax'+itemId).prop("disabled", true);
|
|
|
|
|
$('#pvDiscountExclTax'+itemId).prop("disabled", true);
|
|
|
|
|
$('#pvPriceInclTax'+itemId).prop("disabled", true);
|
|
|
|
|
$('#pvPriceExclTax'+itemId).prop("disabled", true);
|
|
|
|
|
|
|
|
|
|
$('#btnEditOrderItem@(item.Id)').hideElement();
|
|
|
|
|
$('#btnDeleteOrderItem@(item.Id)').hideElement();
|
|
|
|
|
$('#btnEditOrderItem'+itemId).hideElement();
|
|
|
|
|
$('#btnDeleteOrderItem'+itemId).hideElement();
|
|
|
|
|
} else {
|
|
|
|
|
$('#pnlEditPvUnitPrice@(item.Id)').hideElement();
|
|
|
|
|
$('#pnlEditPvQuantity@(item.Id)').hideElement();
|
|
|
|
|
$('#pnlEditPvDiscount@(item.Id)').hideElement();
|
|
|
|
|
$('#pnlEditPvPrice@(item.Id)').hideElement();
|
|
|
|
|
$('#btnSaveOrderItem@(item.Id)').hideElement();
|
|
|
|
|
$('#btnCancelOrderItem@(item.Id)').hideElement();
|
|
|
|
|
$('#pnlEditPvUnitPrice'+itemId).hideElement();
|
|
|
|
|
$('#pnlEditPvQuantity'+itemId).hideElement();
|
|
|
|
|
$('#pnlEditPvDiscount'+itemId).hideElement();
|
|
|
|
|
$('#pnlEditPvPrice'+itemId).hideElement();
|
|
|
|
|
$('#btnSaveOrderItem'+itemId).hideElement();
|
|
|
|
|
$('#btnCancelOrderItem'+itemId).hideElement();
|
|
|
|
|
|
|
|
|
|
$('#pvUnitPriceInclTax@(item.Id)').prop("disabled", true);
|
|
|
|
|
$('#pvUnitPriceExclTax@(item.Id)').prop("disabled", true);
|
|
|
|
|
$('#pvQuantity@(item.Id)').prop("disabled", true);
|
|
|
|
|
$('#pvDiscountInclTax@(item.Id)').prop("disabled", true);
|
|
|
|
|
$('#pvDiscountExclTax@(item.Id)').prop("disabled", true);
|
|
|
|
|
$('#pvPriceInclTax@(item.Id)').prop("disabled", true);
|
|
|
|
|
$('#pvPriceExclTax@(item.Id)').prop("disabled", true);
|
|
|
|
|
$('#pvUnitPriceInclTax'+itemId).prop("disabled", true);
|
|
|
|
|
$('#pvUnitPriceExclTax'+itemId).prop("disabled", true);
|
|
|
|
|
$('#pvQuantity'+itemId).prop("disabled", true);
|
|
|
|
|
$('#pvDiscountInclTax'+itemId).prop("disabled", true);
|
|
|
|
|
$('#pvDiscountExclTax'+itemId).prop("disabled", true);
|
|
|
|
|
$('#pvPriceInclTax'+itemId).prop("disabled", true);
|
|
|
|
|
$('#pvPriceExclTax'+itemId).prop("disabled", true);
|
|
|
|
|
|
|
|
|
|
$('#btnEditOrderItem@(item.Id)').showElement();
|
|
|
|
|
$('#btnDeleteOrderItem@(item.Id)').showElement();
|
|
|
|
|
$('#btnEditOrderItem'+itemId).showElement();
|
|
|
|
|
$('#btnDeleteOrderItem'+itemId).showElement();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<div class="card-body">
|
|
|
|
|
<div class="form-group row">
|
|
|
|
|
<div class="col-md-12" style="overflow-x: auto;">
|
|
|
|
|
@foreach (var item in Model.ItemExtendeds)
|
|
|
|
|
{
|
|
|
|
|
<script>
|
|
|
|
|
$(function() {
|
|
|
|
|
toggleOrderItemEditGlobal(false, @(item.Id));
|
|
|
|
|
setupAutoCalculationGlobal(@(item.Id), @(item.ProductStockQuantity + item.ProductIncomingQuantity));
|
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -114,10 +120,10 @@
|
|
|
|
|
}
|
|
|
|
|
<thead>
|
|
|
|
|
<tr>
|
|
|
|
|
<th>
|
|
|
|
|
@* <th>
|
|
|
|
|
@T("Admin.Orders.Products.Picture")
|
|
|
|
|
</th>
|
|
|
|
|
<th>
|
|
|
|
|
*@ <th>
|
|
|
|
|
@T("Admin.Orders.Products.ProductName")
|
|
|
|
|
</th>
|
|
|
|
|
@if (Model.HasDownloadableProducts)
|
|
|
|
|
@ -130,16 +136,16 @@
|
|
|
|
|
@T("Admin.Orders.Products.Price")
|
|
|
|
|
</th>
|
|
|
|
|
<th>
|
|
|
|
|
@T("FruitBank.IsMeasurable")
|
|
|
|
|
@T("Admin.Orders.Products.Quantity")
|
|
|
|
|
</th>
|
|
|
|
|
<th>
|
|
|
|
|
@T("FruitBank.StockQuantity")
|
|
|
|
|
</th>
|
|
|
|
|
<th>
|
|
|
|
|
@T("Admin.Orders.Products.Quantity")
|
|
|
|
|
@T("FruitBank.NetWeight")
|
|
|
|
|
</th>
|
|
|
|
|
<th>
|
|
|
|
|
@T("FruitBank.NetWeight")
|
|
|
|
|
@T("FruitBank.IsMeasurable")
|
|
|
|
|
</th>
|
|
|
|
|
@* <th>
|
|
|
|
|
@T("Admin.Orders.Products.Discount")
|
|
|
|
|
@ -159,10 +165,10 @@
|
|
|
|
|
@foreach (var item in Model.ItemExtendeds)
|
|
|
|
|
{
|
|
|
|
|
<tr>
|
|
|
|
|
<td class="text-center preview">
|
|
|
|
|
@* <td class="text-center preview">
|
|
|
|
|
<img src="@item.PictureThumbnailUrl" alt="" title="" />
|
|
|
|
|
</td>
|
|
|
|
|
<td style="width: 25%;" class="text-left">
|
|
|
|
|
*@ <td style="width: 25%;" class="text-left">
|
|
|
|
|
<em><a asp-controller="Product" asp-action="Edit" asp-route-id="@item.ProductId">@item.ProductName</a></em>
|
|
|
|
|
@if (!string.IsNullOrEmpty(item.AttributeInfo))
|
|
|
|
|
{
|
|
|
|
|
@ -228,7 +234,7 @@
|
|
|
|
|
}
|
|
|
|
|
</td>
|
|
|
|
|
}
|
|
|
|
|
<td style="width: 15%;" class="text-center">
|
|
|
|
|
<td style="width: 13%;" class="text-center">
|
|
|
|
|
@if (Model.AllowCustomersToSelectTaxDisplayType)
|
|
|
|
|
{
|
|
|
|
|
<div>@Html.Raw(item.UnitPriceInclTax)</div>
|
|
|
|
|
@ -258,10 +264,11 @@
|
|
|
|
|
@T("Admin.Orders.Products.Edit.InclTax")
|
|
|
|
|
</div>
|
|
|
|
|
<div class="col-md-7">
|
|
|
|
|
<input name="pvUnitPriceInclTax@(item.Id)" type="text" value="@item.UnitPriceInclTaxValue" id="pvUnitPriceInclTax@(item.Id)" class="form-control input-sm" />
|
|
|
|
|
<input name="pvUnitPriceInclTax@(item.Id)" type="text" value="@(item.UnitPriceInclTaxValue)" id="pvUnitPriceInclTax@(item.Id)"
|
|
|
|
|
class="form-control input-sm" />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
@* <div class="form-group row">
|
|
|
|
|
@* <div class="form-group row">
|
|
|
|
|
<div class="col-md-5">
|
|
|
|
|
@T("Admin.Orders.Products.Edit.ExclTax")
|
|
|
|
|
</div>
|
|
|
|
|
@ -272,16 +279,8 @@
|
|
|
|
|
*@ </div>
|
|
|
|
|
</td>
|
|
|
|
|
|
|
|
|
|
<td style="width: 80px;" class="text-center">
|
|
|
|
|
<div><input type="checkbox" name="pvIsMeasurable@(item.Id)" id="pvIsMeasurable@(item.Id)" @(item.IsMeasurable ? " checked" : "") disabled /></div>
|
|
|
|
|
</td>
|
|
|
|
|
|
|
|
|
|
<td style="width: 80px;" class="text-center">
|
|
|
|
|
<div>@($"{item.ProductStockQuantity}{(item.ProductIncomingQuantity > 0 ? " (+"+item.ProductIncomingQuantity + ")" : string.Empty)}")</div>
|
|
|
|
|
</td>
|
|
|
|
|
|
|
|
|
|
<td style="width: 10%;" class="text-center">
|
|
|
|
|
<div>@item.Quantity</div>
|
|
|
|
|
<td style="width: 8%;" class="text-center">
|
|
|
|
|
<div>@(item.Quantity) kt.</div>
|
|
|
|
|
<div id="pnlEditPvQuantity@(item.Id)">
|
|
|
|
|
<div class="form-group row">
|
|
|
|
|
<div class="col-md-8 offset-md-2">
|
|
|
|
|
@ -293,8 +292,26 @@
|
|
|
|
|
</td>
|
|
|
|
|
|
|
|
|
|
<td style="width: 80px;" class="text-center">
|
|
|
|
|
@* <div name="pvNetWeight@(item.Id)" id="pvNetWeight@(item.Id)">@item.NetWeight</div> *@
|
|
|
|
|
<div><input name="pvNetWeight@(item.Id)" id="pvNetWeight@(item.Id)" value='@item.NetWeight' disabled /></div>
|
|
|
|
|
<div>
|
|
|
|
|
<span>@($"{item.ProductStockQuantity} kt.")</span><span>@($"{(item.ProductIncomingQuantity > 0 ? " (+" + item.ProductIncomingQuantity + ")" : string.Empty)}")</span>
|
|
|
|
|
</div>
|
|
|
|
|
</td>
|
|
|
|
|
|
|
|
|
|
<td style="width: 100px;" class="text-center">
|
|
|
|
|
<span>@(item.NetWeight) kg.</span>
|
|
|
|
|
<input type="hidden" name="pvNetWeight@(item.Id)" id="pvNetWeight@(item.Id)" value="@(item.NetWeight)" disabled />
|
|
|
|
|
</td>
|
|
|
|
|
|
|
|
|
|
<td style="width: 80px;" class="text-center">
|
|
|
|
|
@if(item.IsMeasurable)
|
|
|
|
|
{
|
|
|
|
|
<span class="badge badge-warning" disabled>Yes</span>
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
<span class="badge badge-secondary" disabled>No</span>
|
|
|
|
|
}
|
|
|
|
|
<input type="hidden" name="pvIsMeasurable@(item.Id)" id="pvIsMeasurable@(item.Id)" value="@(item.IsMeasurable.ToString())" disabled />
|
|
|
|
|
</td>
|
|
|
|
|
|
|
|
|
|
@* <td style="width: 15%;" class="text-center">
|
|
|
|
|
@ -370,10 +387,11 @@
|
|
|
|
|
@T("Admin.Orders.Products.Edit.InclTax")
|
|
|
|
|
</div>
|
|
|
|
|
<div class="col-md-7">
|
|
|
|
|
<input name="pvPriceInclTax@(item.Id)" disabled type="text" value="@item.SubTotalInclTaxValue" id="pvPriceInclTax@(item.Id)" class="form-control input-sm" />
|
|
|
|
|
<input name="pvPriceInclTax@(item.Id)" disabled type="text" value="@item.SubTotalInclTaxValue" id="pvPriceInclTax@(item.Id)"
|
|
|
|
|
class="form-control input-sm" />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
@* <div class="form-group row">
|
|
|
|
|
@* <div class="form-group row">
|
|
|
|
|
<div class="col-md-5">
|
|
|
|
|
@T("Admin.Orders.Products.Edit.ExclTax")
|
|
|
|
|
</div>
|
|
|
|
|
@ -385,8 +403,8 @@
|
|
|
|
|
</td>
|
|
|
|
|
@if (!Model.IsLoggedInAsVendor)
|
|
|
|
|
{
|
|
|
|
|
<td style="width: 15%;" class="text-center">
|
|
|
|
|
<button type="submit" class="btn btn-default" name="btnEditOrderItem@(item.Id)" onclick="toggleOrderItemEdit@(item.Id)(true);return false;" id="btnEditOrderItem@(item.Id)">
|
|
|
|
|
<td style="width: 17%;" class="text-center">
|
|
|
|
|
<button type="submit" class="btn btn-default" name="btnEditOrderItem@(item.Id)" onclick="toggleOrderItemEditGlobal(true, @(item.Id));return false;" id="btnEditOrderItem@(item.Id)">
|
|
|
|
|
<i class="fas fa-pencil"></i>
|
|
|
|
|
@T("Admin.Common.Edit")
|
|
|
|
|
</button>
|
|
|
|
|
@ -403,7 +421,7 @@
|
|
|
|
|
</button>
|
|
|
|
|
<nop-action-confirmation asp-button-id="@("btnSaveOrderItem" + item.Id)" />
|
|
|
|
|
|
|
|
|
|
<button type="submit" class="btn btn-default" name="btnCancelOrderItem@(item.Id)" onclick="toggleOrderItemEdit@(item.Id)(false);return false;" id="btnCancelOrderItem@(item.Id)">
|
|
|
|
|
<button type="submit" class="btn btn-default" name="btnCancelOrderItem@(item.Id)" onclick="toggleOrderItemEditGlobal(false,@(item.Id));return false;" id="btnCancelOrderItem@(item.Id)">
|
|
|
|
|
<i class="fas fa-times"></i>
|
|
|
|
|
@T("Admin.Common.Cancel")
|
|
|
|
|
</button>
|
|
|
|
|
|