Újraengedélyezés, UI átalalkítások, üzenetküldés popup
This commit is contained in:
parent
41275dc003
commit
a476932b40
|
|
@ -1,4 +1,6 @@
|
|||
using AyCode.Core.Loggers;
|
||||
using AyCode.Core.Extensions;
|
||||
using AyCode.Core.Loggers;
|
||||
using AyCode.Services.Server.SignalRs;
|
||||
using AyCode.Services.SignalRs;
|
||||
using FruitBank.Common.Dtos;
|
||||
using FruitBank.Common.Entities;
|
||||
|
|
@ -8,6 +10,7 @@ using FruitBank.Common.Server.Services.SignalRs;
|
|||
using FruitBank.Common.SignalRs;
|
||||
using Mango.Nop.Core.Extensions;
|
||||
using Mango.Nop.Core.Loggers;
|
||||
using MessagePack.Resolvers;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
|
|
@ -23,6 +26,7 @@ using Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Models.Order;
|
|||
using Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
|
||||
using Nop.Plugin.Misc.FruitBankPlugin.Factories;
|
||||
using Nop.Plugin.Misc.FruitBankPlugin.Models.Orders;
|
||||
using Nop.Plugin.Misc.FruitBankPlugin.Services;
|
||||
using Nop.Services.Catalog;
|
||||
using Nop.Services.Common;
|
||||
using Nop.Services.Customers;
|
||||
|
|
@ -35,6 +39,7 @@ using Nop.Services.Orders;
|
|||
using Nop.Services.Payments;
|
||||
using Nop.Services.Plugins;
|
||||
using Nop.Services.Security;
|
||||
using Nop.Services.Tax;
|
||||
using Nop.Web.Areas.Admin.Controllers;
|
||||
using Nop.Web.Areas.Admin.Factories;
|
||||
using Nop.Web.Areas.Admin.Models.Orders;
|
||||
|
|
@ -45,10 +50,6 @@ using System.Text;
|
|||
using System.Text.Json.Serialization;
|
||||
using System.Xml;
|
||||
using System.Xml.Serialization;
|
||||
using AyCode.Services.Server.SignalRs;
|
||||
using AyCode.Core.Extensions;
|
||||
using MessagePack.Resolvers;
|
||||
using Nop.Services.Tax;
|
||||
|
||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||
{
|
||||
|
|
@ -78,6 +79,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
|||
protected readonly IImportManager _importManager;
|
||||
protected readonly IDateTimeHelper _dateTimeHelper;
|
||||
protected readonly ITaxService _taxService;
|
||||
protected readonly MeasurementService _measurementService;
|
||||
private static readonly char[] _separator = [','];
|
||||
// ... other dependencies
|
||||
|
||||
|
|
@ -124,7 +126,8 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
|||
IGiftCardService giftCardService,
|
||||
IImportManager importManager,
|
||||
IDateTimeHelper dateTimeHelper,
|
||||
ITaxService taxService)
|
||||
ITaxService taxService,
|
||||
MeasurementService measurementService)
|
||||
{
|
||||
_logger = new Logger<CustomOrderController>(logWriters.ToArray());
|
||||
|
||||
|
|
@ -151,6 +154,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
|||
_importManager = importManager;
|
||||
_dateTimeHelper = dateTimeHelper;
|
||||
_taxService = taxService;
|
||||
_measurementService = measurementService;
|
||||
// ... initialize other deps
|
||||
}
|
||||
|
||||
|
|
@ -408,6 +412,30 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
|||
return RedirectToAction("Edit", "Order", new { id = model.OrderId });
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> AllowRevision(OrderRevisionModel model)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
// reload order page with errors
|
||||
return RedirectToAction("Edit", "Order", new { id = model.OrderId });
|
||||
}
|
||||
|
||||
var order = await _orderService.GetOrderByIdAsync(model.OrderId);
|
||||
if (order == null)
|
||||
return RedirectToAction("List", "Order");
|
||||
|
||||
|
||||
//MeasurementService.OrderItemMeasuringReset
|
||||
//Todo: ezt orderitiemnként kéne kirakni?? - Á.
|
||||
var valami = await _measurementService.OrderItemMeasuringReset(model.OrderItemId);
|
||||
|
||||
return RedirectToAction("Edit", "Order", new { id = model.OrderId });
|
||||
}
|
||||
|
||||
|
||||
|
||||
[HttpPost]
|
||||
//[CheckPermission(StandardPermission.Orders.ORDERS_CREATE)]
|
||||
public virtual async Task<IActionResult> Create(int customerId, string orderProductsJson)
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Components
|
|||
|
||||
model.IsMeasurable = orderDto.IsMeasurable;
|
||||
model.DateOfReceipt = orderDto.DateOfReceipt;
|
||||
|
||||
model.OrderDto = orderDto;
|
||||
//var orderPickupAttributeValue = await _fruitBankAttributeService.GetGenericAttributeValueAsync<Order, DateTime?>(model.OrderId, nameof(IOrderDto.DateOfReceipt));
|
||||
|
||||
//if (orderPickupAttributeValue.HasValue && orderPickupAttributeValue.Value != DateTime.MinValue)
|
||||
|
|
|
|||
|
|
@ -132,6 +132,11 @@ public class RouteProvider : IRouteProvider
|
|||
pattern: "Admin/CustomOrder/SaveOrderAttributes",
|
||||
defaults: new { controller = "CustomOrder", action = "SaveOrderAttributes", area = AreaNames.ADMIN });
|
||||
|
||||
endpointRouteBuilder.MapControllerRoute(
|
||||
name: "Plugin.FruitBank.Admin.Orders.AllowRevision",
|
||||
pattern: "Admin/CustomOrder/AllowRevision",
|
||||
defaults: new { controller = "CustomOrder", action = "AllowRevision", area = AreaNames.ADMIN });
|
||||
|
||||
endpointRouteBuilder.MapControllerRoute(
|
||||
name: "Plugin.FruitBank.Admin.Orders.CustomerSearchAutoComplete",
|
||||
pattern: "Admin/CustomOrder/CustomerSearchAutoComplete",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using FruitBank.Common.Interfaces;
|
||||
using FruitBank.Common.Dtos;
|
||||
using FruitBank.Common.Interfaces;
|
||||
using Nop.Web.Framework.Models;
|
||||
using Nop.Web.Framework.Mvc.ModelBinding;
|
||||
|
||||
|
|
@ -14,5 +15,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Models.Orders
|
|||
[NopResourceDisplayName("Plugins.YourCompany.ProductAttributes.Fields.DateOfReceipt")]
|
||||
public DateTime? DateOfReceipt { get; set; }
|
||||
|
||||
public OrderDto OrderDto { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
using FruitBank.Common.Dtos;
|
||||
using FruitBank.Common.Interfaces;
|
||||
using Nop.Web.Framework.Models;
|
||||
using Nop.Web.Framework.Mvc.ModelBinding;
|
||||
|
||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Models.Orders
|
||||
{
|
||||
public record OrderRevisionModel : BaseNopModel
|
||||
{
|
||||
public int OrderId { get; set; }
|
||||
|
||||
public int OrderItemId { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
<div class="form-group row">
|
||||
|
||||
<div class="col-12 col-md-4">
|
||||
<div class="col-12 col-md-7">
|
||||
<div class="card card-default mb-2">
|
||||
<div class="card-header">
|
||||
<i class="fas fa-file-invoice"></i>
|
||||
|
|
@ -17,53 +17,34 @@
|
|||
</div>
|
||||
<div class="card-body">
|
||||
<div class="form-group row">
|
||||
<div class="col-md-3 text-right">
|
||||
<strong>Mérés információ</strong>
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
@(Model.IsMeasurable ? "Mérendő" : "Nem mérendő")
|
||||
|
||||
<div class="col-md-12">
|
||||
<strong>@(Model.IsMeasurable ? "Mérendő termék!" : "Nem mérendő termék")</strong>
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
<div class="form-group row">
|
||||
<div class="col-md-3">
|
||||
<nop-label asp-for="DateOfReceipt" />
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
<div class="col-md-6">
|
||||
<nop-editor asp-for="DateOfReceipt" asp-template="" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<div class="col-md-12 text-right">
|
||||
</div>
|
||||
<div class="col-md-3 text-right">
|
||||
<button type="button" id="saveAttributesBtn" class="btn btn-primary">
|
||||
<i class="fa fa-save"></i> Mentés
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-md-4">
|
||||
<div class="card card-default mb-3">
|
||||
<div class="card-header">
|
||||
<h4><i class="fas fa-cogs"></i> Üzenet küldése</h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<hr />
|
||||
<div class="form-group row">
|
||||
<div class="col-12">
|
||||
<label for="notificationMessage">Üzenet szövege:</label>
|
||||
<textarea id="notificationMessage" class="form-control" rows="3" placeholder="Írja be az üzenetet..."></textarea>
|
||||
<div class="col-md-6">
|
||||
<button type="button" class="btn btn-warning btn-block" data-toggle="modal" data-target="#allowRevisionModal">
|
||||
<i class="fa fa-redo"></i> Újramérés engedélyezése
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<div class="col-12">
|
||||
<div id="notificationStatus" class="alert" style="display: none;">
|
||||
<i class="fas fa-info-circle"></i> <span id="notificationStatusMessage"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<div class="col-12 text-right">
|
||||
<button type="button" id="sendNotificationBtn" class="btn btn-primary">
|
||||
<div class="col-md-6">
|
||||
<button type="button" class="btn btn-primary btn-block" data-toggle="modal" data-target="#sendMessageModal">
|
||||
<i class="fas fa-paper-plane"></i> Üzenet küldése
|
||||
</button>
|
||||
</div>
|
||||
|
|
@ -71,15 +52,15 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-md-4">
|
||||
<div class="col-12 col-md-5">
|
||||
<div class="card card-default mb-3">
|
||||
<div class="card-header">
|
||||
<i class="fas fa-file-invoice"></i>
|
||||
InnVoice Management
|
||||
Megrendelés beküldése Innvoice-ba
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="col-12">
|
||||
<h5><i class="fas fa-shopping-cart"></i> Megrendelés beküldése Innvoice-ba</h5>
|
||||
|
||||
<div id="orderStatus" class="alert alert-info" style="display: none;">
|
||||
<i class="fas fa-info-circle"></i> <span id="orderStatusMessage"></span>
|
||||
</div>
|
||||
|
|
@ -96,7 +77,7 @@
|
|||
|
||||
<div class="col-12 text-right float-end">
|
||||
<button type="button" id="createOrderBtn" class="btn btn-success">
|
||||
<i class="fas fa-shopping-cart"></i> Létrehozás
|
||||
<i class="fas fa-shopping-cart"></i> Megrendelés beküldése
|
||||
</button>
|
||||
<button type="button" id="checkOrderBtn" class="btn btn-secondary" style="display: none;">
|
||||
<i class="fas fa-sync"></i> Invoice adat ellenőrzése
|
||||
|
|
@ -106,33 +87,79 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@* <div class="col-12 col-md-3">
|
||||
<h5><i class="fas fa-file-invoice-dollar"></i> Invoice</h5>
|
||||
<div id="invoiceStatus" class="alert alert-info" style="display: none;">
|
||||
<i class="fas fa-info-circle"></i> <span id="invoiceStatusMessage"></span>
|
||||
</div>
|
||||
<div id="invoiceDetails" style="display: none;">
|
||||
<p><strong>Invoice Number:</strong> <span id="invoiceNumber"></span></p>
|
||||
<p><strong>Table ID:</strong> <span id="invoiceTableId"></span></p>
|
||||
<p>
|
||||
<a id="invoicePdfLink" href="#" target="_blank" class="btn btn-sm btn-info">
|
||||
<i class="fas fa-file-pdf"></i> View Invoice PDF
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
</div> *@
|
||||
|
||||
@* <div class="col-12 col-md-3 text-right">
|
||||
<button type="button" id="createInvoiceBtn" class="btn btn-success">
|
||||
<i class="fas fa-file-invoice-dollar"></i> Create Invoice
|
||||
</button>
|
||||
<button type="button" id="checkInvoiceBtn" class="btn btn-secondary" style="display: none;">
|
||||
<i class="fas fa-sync"></i> Refresh Invoice
|
||||
</button>
|
||||
</div> *@
|
||||
</div>
|
||||
|
||||
<!-- Allow Revision Modal -->
|
||||
<div class="modal fade" id="allowRevisionModal" tabindex="-1" role="dialog" aria-labelledby="allowRevisionModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="allowRevisionModalLabel">
|
||||
<i class="fa fa-redo"></i> Újramérés engedélyezése
|
||||
</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label for="revisionSubject"><strong>Válassza ki az újramérendő terméket:</strong></label>
|
||||
<select id="revisionSubject" class="form-control">
|
||||
<option value="" disabled selected>Újramérendő termék</option>
|
||||
@foreach (var orderItem in Model.OrderDto.OrderItemDtos)
|
||||
{
|
||||
<option value="@orderItem.Id">@orderItem.ProductName - @orderItem.Quantity @orderItem.IsAudited</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
<div id="revisionStatus" class="alert" style="display: none; margin-top: 15px;">
|
||||
<i class="fas fa-info-circle"></i> <span id="revisionStatusMessage"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">
|
||||
<i class="fa fa-times"></i> Mégse
|
||||
</button>
|
||||
<button type="button" id="allowRevisionBtn" class="btn btn-primary">
|
||||
<i class="fa fa-save"></i> Újramérés engedélyezése
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Send Message Modal -->
|
||||
<div class="modal fade" id="sendMessageModal" tabindex="-1" role="dialog" aria-labelledby="sendMessageModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="sendMessageModalLabel">
|
||||
<i class="fas fa-paper-plane"></i> Üzenet küldése
|
||||
</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label for="notificationMessage"><strong>Üzenet szövege:</strong></label>
|
||||
<textarea id="notificationMessage" class="form-control" rows="4" placeholder="Írja be az üzenetet..."></textarea>
|
||||
</div>
|
||||
<div id="notificationStatus" class="alert" style="display: none; margin-top: 15px;">
|
||||
<i class="fas fa-info-circle"></i> <span id="notificationStatusMessage"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">
|
||||
<i class="fa fa-times"></i> Mégse
|
||||
</button>
|
||||
<button type="button" id="sendNotificationBtn" class="btn btn-primary">
|
||||
<i class="fas fa-paper-plane"></i> Üzenet küldése
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
|
|
@ -142,6 +169,7 @@
|
|||
var createInvoiceUrl = '/Admin/Invoice/CreateInvoice';
|
||||
var getInvoiceStatusUrl = '/Admin/Invoice/GetInvoiceStatus';
|
||||
|
||||
|
||||
var orderExists = false;
|
||||
var invoiceExists = false;
|
||||
|
||||
|
|
@ -178,6 +206,62 @@
|
|||
return false;
|
||||
});
|
||||
|
||||
// Allow Revision Button (in modal)
|
||||
$("#allowRevisionBtn").click(function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
var selectedOrderItemId = $("#revisionSubject").val();
|
||||
|
||||
if (!selectedOrderItemId) {
|
||||
showRevisionStatus("Kérjük, válasszon ki egy terméket!", "warning");
|
||||
return false;
|
||||
}
|
||||
|
||||
var btn = $(this);
|
||||
btn.prop("disabled", true).html('<i class="fas fa-spinner fa-spin"></i> Mentés...');
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "@Url.Action("AllowRevision", "CustomOrder")",
|
||||
data: {
|
||||
orderId: "@Model.OrderId",
|
||||
orderItemId: selectedOrderItemId,
|
||||
__RequestVerificationToken: $('input[name="__RequestVerificationToken"]').val()
|
||||
},
|
||||
success: function () {
|
||||
btn.prop("disabled", false).html('<i class="fa fa-save"></i> Újramérés engedélyezése');
|
||||
showRevisionStatus("Újramérés sikeresen engedélyezve!", "success");
|
||||
|
||||
// Close modal after 1.5 seconds
|
||||
setTimeout(function() {
|
||||
$('#allowRevisionModal').modal('hide');
|
||||
$("#revisionSubject").val(""); // Reset select
|
||||
}, 1500);
|
||||
},
|
||||
error: function () {
|
||||
btn.prop("disabled", false).html('<i class="fa fa-save"></i> Újramérés engedélyezése');
|
||||
showRevisionStatus("Hiba történt a művelet során!", "danger");
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
function showRevisionStatus(message, type) {
|
||||
var statusDiv = $("#revisionStatus");
|
||||
statusDiv.removeClass("alert-info alert-success alert-warning alert-danger")
|
||||
.addClass("alert-" + type);
|
||||
$("#revisionStatusMessage").text(message);
|
||||
statusDiv.show();
|
||||
}
|
||||
|
||||
// Clear revision status when modal is closed
|
||||
$('#allowRevisionModal').on('hidden.bs.modal', function () {
|
||||
$("#revisionStatus").hide();
|
||||
$("#revisionSubject").val("");
|
||||
});
|
||||
|
||||
// ========== ORDER MANAGEMENT ==========
|
||||
|
||||
// Create Order
|
||||
|
|
@ -448,75 +532,87 @@
|
|||
}
|
||||
});
|
||||
|
||||
// ========== NOTIFICATION MANAGEMENT ==========
|
||||
|
||||
var sendNotificationUrl = '/Admin/CustomOrder/SendOrderNotification';
|
||||
var sendNotificationUrl = '/Admin/CustomOrder/SendOrderNotification';
|
||||
|
||||
// Send Notification
|
||||
$("#sendNotificationBtn").click(function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
// Send Notification (in modal)
|
||||
$("#sendNotificationBtn").click(function (e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
var message = $("#notificationMessage").val().trim();
|
||||
var message = $("#notificationMessage").val().trim();
|
||||
|
||||
if (!message) {
|
||||
showNotificationStatus("Kérjük, adjon meg egy üzenetet!", "warning");
|
||||
return false;
|
||||
}
|
||||
|
||||
var btn = $(this);
|
||||
btn.prop("disabled", true).html('<i class="fas fa-spinner fa-spin"></i> Küldés...');
|
||||
|
||||
showNotificationStatus("Üzenet küldése folyamatban...", "info");
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: sendNotificationUrl,
|
||||
data: {
|
||||
orderId: @Model.OrderId,
|
||||
message: message,
|
||||
__RequestVerificationToken: $('input[name="__RequestVerificationToken"]').val()
|
||||
},
|
||||
dataType: 'json',
|
||||
success: function (response) {
|
||||
console.log("Notification Response:", response);
|
||||
btn.prop("disabled", false).html('<i class="fas fa-paper-plane"></i> Üzenet küldése');
|
||||
|
||||
if (response.success) {
|
||||
showNotificationStatus("Üzenet sikeresen elküldve!", "success");
|
||||
$("#notificationMessage").val(""); // Clear the textbox
|
||||
} else {
|
||||
showNotificationStatus("Hiba: " + (response.message || "Ismeretlen hiba"), "danger");
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error("Notification AJAX Error:", xhr, status, error);
|
||||
btn.prop("disabled", false).html('<i class="fas fa-paper-plane"></i> Üzenet küldése');
|
||||
|
||||
var errorMessage = "Hiba az üzenet küldése közben";
|
||||
if (xhr.responseJSON && xhr.responseJSON.message) {
|
||||
errorMessage = xhr.responseJSON.message;
|
||||
} else if (xhr.responseText) {
|
||||
try {
|
||||
var errorObj = JSON.parse(xhr.responseText);
|
||||
errorMessage = errorObj.message || errorMessage;
|
||||
} catch (e) {
|
||||
errorMessage = "Hiba: " + xhr.status + " - " + xhr.statusText;
|
||||
}
|
||||
}
|
||||
showNotificationStatus(errorMessage, "danger");
|
||||
if (!message) {
|
||||
showNotificationStatus("Kérjük, adjon meg egy üzenetet!", "warning");
|
||||
return false;
|
||||
}
|
||||
|
||||
var btn = $(this);
|
||||
btn.prop("disabled", true).html('<i class="fas fa-spinner fa-spin"></i> Küldés...');
|
||||
|
||||
showNotificationStatus("Üzenet küldése folyamatban...", "info");
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: sendNotificationUrl,
|
||||
data: {
|
||||
orderId: @Model.OrderId,
|
||||
message: message,
|
||||
__RequestVerificationToken: $('input[name="__RequestVerificationToken"]').val()
|
||||
},
|
||||
dataType: 'json',
|
||||
success: function (response) {
|
||||
console.log("Notification Response:", response);
|
||||
btn.prop("disabled", false).html('<i class="fas fa-paper-plane"></i> Üzenet küldése');
|
||||
|
||||
if (response.success) {
|
||||
showNotificationStatus("Üzenet sikeresen elküldve!", "success");
|
||||
|
||||
// Close modal after 1.5 seconds
|
||||
setTimeout(function() {
|
||||
$('#sendMessageModal').modal('hide');
|
||||
$("#notificationMessage").val(""); // Clear the textbox
|
||||
}, 1500);
|
||||
} else {
|
||||
showNotificationStatus("Hiba: " + (response.message || "Ismeretlen hiba"), "danger");
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error("Notification AJAX Error:", xhr, status, error);
|
||||
btn.prop("disabled", false).html('<i class="fas fa-paper-plane"></i> Üzenet küldése');
|
||||
|
||||
var errorMessage = "Hiba az üzenet küldése közben";
|
||||
if (xhr.responseJSON && xhr.responseJSON.message) {
|
||||
errorMessage = xhr.responseJSON.message;
|
||||
} else if (xhr.responseText) {
|
||||
try {
|
||||
var errorObj = JSON.parse(xhr.responseText);
|
||||
errorMessage = errorObj.message || errorMessage;
|
||||
} catch (e) {
|
||||
errorMessage = "Hiba: " + xhr.status + " - " + xhr.statusText;
|
||||
}
|
||||
}
|
||||
showNotificationStatus(errorMessage, "danger");
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
function showNotificationStatus(message, type) {
|
||||
var statusDiv = $("#notificationStatus");
|
||||
statusDiv.removeClass("alert-info alert-success alert-warning alert-danger")
|
||||
.addClass("alert-" + type);
|
||||
$("#notificationStatusMessage").text(message);
|
||||
statusDiv.show();
|
||||
}
|
||||
|
||||
function showNotificationStatus(message, type) {
|
||||
var statusDiv = $("#notificationStatus");
|
||||
statusDiv.removeClass("alert-info alert-success alert-warning alert-danger")
|
||||
.addClass("alert-" + type);
|
||||
$("#notificationStatusMessage").text(message);
|
||||
statusDiv.show();
|
||||
}
|
||||
// Clear notification status when modal is closed
|
||||
$('#sendMessageModal').on('hidden.bs.modal', function () {
|
||||
$("#notificationStatus").hide();
|
||||
$("#notificationMessage").val("");
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Reference in New Issue