Compare commits
No commits in common. "a476932b40b6b0ac12e7ed985d5b0ee0b96dc9c0" and "78404147b2f4228e87a07b36551fa5b905517b4b" have entirely different histories.
a476932b40
...
78404147b2
|
|
@ -1,145 +0,0 @@
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Nop.Core;
|
|
||||||
using Nop.Plugin.Misc.FruitBankPlugin.Models.App;
|
|
||||||
using Nop.Services.Security;
|
|
||||||
using Nop.Web.Framework;
|
|
||||||
using Nop.Web.Framework.Controllers;
|
|
||||||
using Nop.Web.Framework.Mvc.Filters;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Controllers
|
|
||||||
{
|
|
||||||
[Area(AreaNames.ADMIN)]
|
|
||||||
[AuthorizeAdmin]
|
|
||||||
[AutoValidateAntiforgeryToken]
|
|
||||||
public class AppDownloadController : BasePluginController
|
|
||||||
{
|
|
||||||
private readonly IPermissionService _permissionService;
|
|
||||||
private readonly IWebHelper _webHelper;
|
|
||||||
private readonly IWorkContext _workContext;
|
|
||||||
|
|
||||||
public AppDownloadController(
|
|
||||||
IPermissionService permissionService,
|
|
||||||
IWebHelper webHelper,
|
|
||||||
IWorkContext workContext)
|
|
||||||
{
|
|
||||||
_permissionService = permissionService;
|
|
||||||
_webHelper = webHelper;
|
|
||||||
_workContext = workContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet]
|
|
||||||
public virtual async Task<IActionResult> Index()
|
|
||||||
{
|
|
||||||
if (!await _permissionService.AuthorizeAsync(StandardPermission.Orders.ORDERS_CREATE_EDIT_DELETE))
|
|
||||||
return AccessDeniedView();
|
|
||||||
|
|
||||||
var model = new AppDownloadModel
|
|
||||||
{
|
|
||||||
PreviousVersions = new List<AppVersionModel>()
|
|
||||||
};
|
|
||||||
|
|
||||||
var appPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "app", "versions");
|
|
||||||
|
|
||||||
if (Directory.Exists(appPath))
|
|
||||||
{
|
|
||||||
var versionFolders = Directory.GetDirectories(appPath)
|
|
||||||
.Select(d => new DirectoryInfo(d))
|
|
||||||
.OrderByDescending(d => d.Name)
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
foreach (var folder in versionFolders)
|
|
||||||
{
|
|
||||||
var apkFile = Directory.GetFiles(folder.FullName, "*.apk").FirstOrDefault();
|
|
||||||
if (apkFile != null)
|
|
||||||
{
|
|
||||||
var fileInfo = new FileInfo(apkFile);
|
|
||||||
var fileName = Path.GetFileName(apkFile);
|
|
||||||
var versionModel = new AppVersionModel
|
|
||||||
{
|
|
||||||
Version = folder.Name,
|
|
||||||
DownloadUrl = $"/app/versions/{folder.Name}/{fileName}",
|
|
||||||
FileName = fileName, // Add this
|
|
||||||
FileSizeFormatted = FormatFileSize(fileInfo.Length),
|
|
||||||
ReleaseDate = fileInfo.CreationTime
|
|
||||||
};
|
|
||||||
|
|
||||||
// Set the latest version
|
|
||||||
if (model.CurrentVersion == null)
|
|
||||||
{
|
|
||||||
model.CurrentVersion = folder.Name;
|
|
||||||
model.DownloadUrl = versionModel.DownloadUrl;
|
|
||||||
model.FileName = fileName; // Add this
|
|
||||||
model.FileSizeBytes = fileInfo.Length;
|
|
||||||
model.FileSizeFormatted = versionModel.FileSizeFormatted;
|
|
||||||
model.ReleaseDate = versionModel.ReleaseDate;
|
|
||||||
|
|
||||||
// Read changelog if exists
|
|
||||||
var changelogFile = Path.Combine(folder.FullName, "changelog.txt");
|
|
||||||
if (System.IO.File.Exists(changelogFile))
|
|
||||||
{
|
|
||||||
model.Changelog = await System.IO.File.ReadAllTextAsync(changelogFile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
model.PreviousVersions.Add(versionModel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return View("~/Plugins/Misc.FruitBankPlugin/Areas/Admin/Views/AppDownload/Index.cshtml", model);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet]
|
|
||||||
public virtual IActionResult Download(string version, string fileName)
|
|
||||||
{
|
|
||||||
// Validate inputs
|
|
||||||
if (string.IsNullOrEmpty(version) || string.IsNullOrEmpty(fileName))
|
|
||||||
return BadRequest();
|
|
||||||
|
|
||||||
// Prevent directory traversal
|
|
||||||
if (version.Contains("..") || fileName.Contains(".."))
|
|
||||||
return BadRequest();
|
|
||||||
|
|
||||||
if (!fileName.EndsWith(".apk", StringComparison.OrdinalIgnoreCase))
|
|
||||||
return BadRequest();
|
|
||||||
|
|
||||||
var filePath = Path.Combine(
|
|
||||||
Directory.GetCurrentDirectory(),
|
|
||||||
"wwwroot",
|
|
||||||
"app",
|
|
||||||
"versions",
|
|
||||||
version,
|
|
||||||
fileName);
|
|
||||||
|
|
||||||
if (!System.IO.File.Exists(filePath))
|
|
||||||
return NotFound();
|
|
||||||
|
|
||||||
var fileBytes = System.IO.File.ReadAllBytes(filePath);
|
|
||||||
|
|
||||||
// Set proper headers for APK download
|
|
||||||
Response.Headers.Add("Content-Disposition", $"attachment; filename=\"{fileName}\"");
|
|
||||||
|
|
||||||
return File(fileBytes, "application/vnd.android.package-archive", fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
private string FormatFileSize(long bytes)
|
|
||||||
{
|
|
||||||
string[] sizes = { "B", "KB", "MB", "GB", "TB" };
|
|
||||||
double len = bytes;
|
|
||||||
int order = 0;
|
|
||||||
while (len >= 1024 && order < sizes.Length - 1)
|
|
||||||
{
|
|
||||||
order++;
|
|
||||||
len = len / 1024;
|
|
||||||
}
|
|
||||||
return $"{len:0.##} {sizes[order]}";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
using AyCode.Core.Extensions;
|
using AyCode.Core.Loggers;
|
||||||
using AyCode.Core.Loggers;
|
|
||||||
using AyCode.Services.Server.SignalRs;
|
|
||||||
using AyCode.Services.SignalRs;
|
using AyCode.Services.SignalRs;
|
||||||
using FruitBank.Common.Dtos;
|
using FruitBank.Common.Dtos;
|
||||||
using FruitBank.Common.Entities;
|
using FruitBank.Common.Entities;
|
||||||
|
|
@ -10,7 +8,6 @@ using FruitBank.Common.Server.Services.SignalRs;
|
||||||
using FruitBank.Common.SignalRs;
|
using FruitBank.Common.SignalRs;
|
||||||
using Mango.Nop.Core.Extensions;
|
using Mango.Nop.Core.Extensions;
|
||||||
using Mango.Nop.Core.Loggers;
|
using Mango.Nop.Core.Loggers;
|
||||||
using MessagePack.Resolvers;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.SignalR;
|
using Microsoft.AspNetCore.SignalR;
|
||||||
|
|
@ -26,7 +23,6 @@ using Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Models.Order;
|
||||||
using Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
|
using Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
|
||||||
using Nop.Plugin.Misc.FruitBankPlugin.Factories;
|
using Nop.Plugin.Misc.FruitBankPlugin.Factories;
|
||||||
using Nop.Plugin.Misc.FruitBankPlugin.Models.Orders;
|
using Nop.Plugin.Misc.FruitBankPlugin.Models.Orders;
|
||||||
using Nop.Plugin.Misc.FruitBankPlugin.Services;
|
|
||||||
using Nop.Services.Catalog;
|
using Nop.Services.Catalog;
|
||||||
using Nop.Services.Common;
|
using Nop.Services.Common;
|
||||||
using Nop.Services.Customers;
|
using Nop.Services.Customers;
|
||||||
|
|
@ -39,7 +35,6 @@ using Nop.Services.Orders;
|
||||||
using Nop.Services.Payments;
|
using Nop.Services.Payments;
|
||||||
using Nop.Services.Plugins;
|
using Nop.Services.Plugins;
|
||||||
using Nop.Services.Security;
|
using Nop.Services.Security;
|
||||||
using Nop.Services.Tax;
|
|
||||||
using Nop.Web.Areas.Admin.Controllers;
|
using Nop.Web.Areas.Admin.Controllers;
|
||||||
using Nop.Web.Areas.Admin.Factories;
|
using Nop.Web.Areas.Admin.Factories;
|
||||||
using Nop.Web.Areas.Admin.Models.Orders;
|
using Nop.Web.Areas.Admin.Models.Orders;
|
||||||
|
|
@ -50,6 +45,10 @@ using System.Text;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using System.Xml.Serialization;
|
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
|
namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
{
|
{
|
||||||
|
|
@ -79,7 +78,6 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
protected readonly IImportManager _importManager;
|
protected readonly IImportManager _importManager;
|
||||||
protected readonly IDateTimeHelper _dateTimeHelper;
|
protected readonly IDateTimeHelper _dateTimeHelper;
|
||||||
protected readonly ITaxService _taxService;
|
protected readonly ITaxService _taxService;
|
||||||
protected readonly MeasurementService _measurementService;
|
|
||||||
private static readonly char[] _separator = [','];
|
private static readonly char[] _separator = [','];
|
||||||
// ... other dependencies
|
// ... other dependencies
|
||||||
|
|
||||||
|
|
@ -126,8 +124,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
IGiftCardService giftCardService,
|
IGiftCardService giftCardService,
|
||||||
IImportManager importManager,
|
IImportManager importManager,
|
||||||
IDateTimeHelper dateTimeHelper,
|
IDateTimeHelper dateTimeHelper,
|
||||||
ITaxService taxService,
|
ITaxService taxService)
|
||||||
MeasurementService measurementService)
|
|
||||||
{
|
{
|
||||||
_logger = new Logger<CustomOrderController>(logWriters.ToArray());
|
_logger = new Logger<CustomOrderController>(logWriters.ToArray());
|
||||||
|
|
||||||
|
|
@ -154,7 +151,6 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
_importManager = importManager;
|
_importManager = importManager;
|
||||||
_dateTimeHelper = dateTimeHelper;
|
_dateTimeHelper = dateTimeHelper;
|
||||||
_taxService = taxService;
|
_taxService = taxService;
|
||||||
_measurementService = measurementService;
|
|
||||||
// ... initialize other deps
|
// ... initialize other deps
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -412,30 +408,6 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
||||||
return RedirectToAction("Edit", "Order", new { id = model.OrderId });
|
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]
|
[HttpPost]
|
||||||
//[CheckPermission(StandardPermission.Orders.ORDERS_CREATE)]
|
//[CheckPermission(StandardPermission.Orders.ORDERS_CREATE)]
|
||||||
public virtual async Task<IActionResult> Create(int customerId, string orderProductsJson)
|
public virtual async Task<IActionResult> Create(int customerId, string orderProductsJson)
|
||||||
|
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Models.App
|
|
||||||
{
|
|
||||||
public class AppDownloadModel
|
|
||||||
{
|
|
||||||
public string CurrentVersion { get; set; }
|
|
||||||
public string DownloadUrl { get; set; }
|
|
||||||
public string FileName { get; set; } // Add this
|
|
||||||
public long FileSizeBytes { get; set; }
|
|
||||||
public string FileSizeFormatted { get; set; }
|
|
||||||
public DateTime ReleaseDate { get; set; }
|
|
||||||
public string Changelog { get; set; }
|
|
||||||
public List<AppVersionModel> PreviousVersions { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Models.App
|
|
||||||
{
|
|
||||||
|
|
||||||
public class AppVersionModel
|
|
||||||
{
|
|
||||||
public string Version { get; set; }
|
|
||||||
public string DownloadUrl { get; set; }
|
|
||||||
public string FileName { get; set; } // Add this
|
|
||||||
public string FileSizeFormatted { get; set; }
|
|
||||||
public DateTime ReleaseDate { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,167 +0,0 @@
|
||||||
@using System.IO
|
|
||||||
@model Nop.Plugin.Misc.FruitBankPlugin.Models.App.AppDownloadModel
|
|
||||||
|
|
||||||
@{
|
|
||||||
Layout = "_AdminLayout";
|
|
||||||
NopHtml.SetActiveMenuItemSystemName("FruitBank.AppDownload");
|
|
||||||
}
|
|
||||||
|
|
||||||
<div class="content-header clearfix">
|
|
||||||
<h1 class="float-left">
|
|
||||||
Android App letöltés
|
|
||||||
</h1>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<section class="content">
|
|
||||||
<div class="container-fluid">
|
|
||||||
@if (!string.IsNullOrEmpty(Model.CurrentVersion))
|
|
||||||
{
|
|
||||||
<!-- Latest Version Card -->
|
|
||||||
<div class="card card-default">
|
|
||||||
<div class="card-header">
|
|
||||||
<h3 class="card-title">
|
|
||||||
<i class="fas fa-mobile-alt"></i>
|
|
||||||
Legújabb verzió: @Model.CurrentVersion
|
|
||||||
</h3>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-8">
|
|
||||||
<div class="alert alert-info">
|
|
||||||
<i class="fas fa-info-circle"></i>
|
|
||||||
<strong>Telepítési útmutató:</strong>
|
|
||||||
<ol class="mb-0 mt-2">
|
|
||||||
<li>Engedélyezd az "Ismeretlen forrásokból" való telepítést a táblagépen (Beállítások → Biztonság)</li>
|
|
||||||
<li>Kattints a "Letöltés" gombra</li>
|
|
||||||
<li>Nyisd meg a letöltött APK fájlt</li>
|
|
||||||
<li>Kövesd a telepítési utasításokat</li>
|
|
||||||
</ol>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mb-3">
|
|
||||||
<strong>Verzió:</strong> @Model.CurrentVersion<br />
|
|
||||||
<strong>Méret:</strong> @Model.FileSizeFormatted<br />
|
|
||||||
<strong>Kiadás dátuma:</strong> @Model.ReleaseDate.ToString("yyyy-MM-dd HH:mm")
|
|
||||||
</div>
|
|
||||||
|
|
||||||
@if (!string.IsNullOrEmpty(Model.Changelog))
|
|
||||||
{
|
|
||||||
<div class="mb-3">
|
|
||||||
<strong>Változások:</strong>
|
|
||||||
<pre class="bg-light p-3 rounded">@Model.Changelog</pre>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
|
|
||||||
<a href="@Url.Action("Download", "AppDownload", new { version = Model.CurrentVersion, fileName = Model.FileName })" class="btn btn-primary btn-lg">
|
|
||||||
<i class="fas fa-download"></i>
|
|
||||||
Letöltés (@Model.FileSizeFormatted)
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-md-4">
|
|
||||||
<div class="text-center">
|
|
||||||
<!-- QR Code for easy download on tablet -->
|
|
||||||
<div id="qrcode" class="mb-3"></div>
|
|
||||||
<p class="text-muted"><small>Szkenneld be a QR kódot a táblagéppel a közvetlen letöltéshez</small></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
@if (Model.PreviousVersions != null && Model.PreviousVersions.Any())
|
|
||||||
{
|
|
||||||
<!-- Previous Versions Card -->
|
|
||||||
<div class="card card-default collapsed-card">
|
|
||||||
<div class="card-header">
|
|
||||||
<h3 class="card-title">
|
|
||||||
<i class="fas fa-history"></i>
|
|
||||||
Korábbi verziók
|
|
||||||
</h3>
|
|
||||||
<div class="card-tools">
|
|
||||||
<button type="button" class="btn btn-tool" data-card-widget="collapse">
|
|
||||||
<i class="fas fa-plus"></i>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="card-body" style="display: none;">
|
|
||||||
<table class="table table-bordered table-hover">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Verzió</th>
|
|
||||||
<th>Méret</th>
|
|
||||||
<th>Kiadás dátuma</th>
|
|
||||||
<th>Letöltés</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
@foreach (var version in Model.PreviousVersions)
|
|
||||||
{
|
|
||||||
<tr>
|
|
||||||
<td>@version.Version</td>
|
|
||||||
<td>@version.FileSizeFormatted</td>
|
|
||||||
<td>@version.ReleaseDate.ToString("yyyy-MM-dd HH:mm")</td>
|
|
||||||
<td>
|
|
||||||
<a href="@Url.Action("Download", "AppDownload", new { version = version.Version, fileName = version.FileName })" class="btn btn-sm btn-secondary" download>
|
|
||||||
<i class="fas fa-download"></i>
|
|
||||||
Letöltés
|
|
||||||
</a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<div class="card card-default">
|
|
||||||
<div class="card-body">
|
|
||||||
<div class="alert alert-warning">
|
|
||||||
<i class="fas fa-exclamation-triangle"></i>
|
|
||||||
Nincs elérhető app verzió. Kérlek, helyezd el az APK fájlt a <code>wwwroot/app/versions/</code> mappában.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/qrcodejs@1.0.0/qrcode.min.js"></script>
|
|
||||||
<script>
|
|
||||||
$(function() {
|
|
||||||
@if (!string.IsNullOrEmpty(Model.DownloadUrl))
|
|
||||||
{
|
|
||||||
<text>
|
|
||||||
var downloadUrl = window.location.origin + '@Model.DownloadUrl';
|
|
||||||
new QRCode(document.getElementById("qrcode"), {
|
|
||||||
text: downloadUrl,
|
|
||||||
width: 200,
|
|
||||||
height: 200,
|
|
||||||
colorDark: "#000000",
|
|
||||||
colorLight: "#ffffff",
|
|
||||||
correctLevel: QRCode.CorrectLevel.H
|
|
||||||
});
|
|
||||||
</text>
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
|
|
||||||
<style>
|
|
||||||
#qrcode {
|
|
||||||
display: inline-block;
|
|
||||||
padding: 10px;
|
|
||||||
background: white;
|
|
||||||
border: 1px solid #ddd;
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#qrcode img {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
@ -44,7 +44,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Components
|
||||||
|
|
||||||
model.IsMeasurable = orderDto.IsMeasurable;
|
model.IsMeasurable = orderDto.IsMeasurable;
|
||||||
model.DateOfReceipt = orderDto.DateOfReceipt;
|
model.DateOfReceipt = orderDto.DateOfReceipt;
|
||||||
model.OrderDto = orderDto;
|
|
||||||
//var orderPickupAttributeValue = await _fruitBankAttributeService.GetGenericAttributeValueAsync<Order, DateTime?>(model.OrderId, nameof(IOrderDto.DateOfReceipt));
|
//var orderPickupAttributeValue = await _fruitBankAttributeService.GetGenericAttributeValueAsync<Order, DateTime?>(model.OrderId, nameof(IOrderDto.DateOfReceipt));
|
||||||
|
|
||||||
//if (orderPickupAttributeValue.HasValue && orderPickupAttributeValue.Value != DateTime.MinValue)
|
//if (orderPickupAttributeValue.HasValue && orderPickupAttributeValue.Value != DateTime.MinValue)
|
||||||
|
|
|
||||||
|
|
@ -132,11 +132,6 @@ public class RouteProvider : IRouteProvider
|
||||||
pattern: "Admin/CustomOrder/SaveOrderAttributes",
|
pattern: "Admin/CustomOrder/SaveOrderAttributes",
|
||||||
defaults: new { controller = "CustomOrder", action = "SaveOrderAttributes", area = AreaNames.ADMIN });
|
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(
|
endpointRouteBuilder.MapControllerRoute(
|
||||||
name: "Plugin.FruitBank.Admin.Orders.CustomerSearchAutoComplete",
|
name: "Plugin.FruitBank.Admin.Orders.CustomerSearchAutoComplete",
|
||||||
pattern: "Admin/CustomOrder/CustomerSearchAutoComplete",
|
pattern: "Admin/CustomOrder/CustomerSearchAutoComplete",
|
||||||
|
|
@ -161,16 +156,6 @@ public class RouteProvider : IRouteProvider
|
||||||
name: "Plugin.FruitBank.Admin.ManagementPage.ProcessShippingDocument",
|
name: "Plugin.FruitBank.Admin.ManagementPage.ProcessShippingDocument",
|
||||||
pattern: "Admin/ManagamentPage/ProcessShippingDocument/{id}",
|
pattern: "Admin/ManagamentPage/ProcessShippingDocument/{id}",
|
||||||
defaults: new { controller = "ManagementPage", action = "ProcessShippingdocument", area = AreaNames.ADMIN });
|
defaults: new { controller = "ManagementPage", action = "ProcessShippingdocument", area = AreaNames.ADMIN });
|
||||||
|
|
||||||
endpointRouteBuilder.MapControllerRoute(
|
|
||||||
name: "Plugin.FruitBank.AppDownload",
|
|
||||||
pattern: "Admin/AppDownload",
|
|
||||||
defaults: new { controller = "AppDownload", action = "Index", area = AreaNames.ADMIN });
|
|
||||||
|
|
||||||
endpointRouteBuilder.MapControllerRoute(
|
|
||||||
name: "Plugin.FruitBank.AppDownload.Download",
|
|
||||||
pattern: "Admin/AppDownload/Download/{version}/{fileName}",
|
|
||||||
defaults: new { controller = "AppDownload", action = "Download", area = AreaNames.ADMIN });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
using FruitBank.Common.Dtos;
|
using FruitBank.Common.Interfaces;
|
||||||
using FruitBank.Common.Interfaces;
|
|
||||||
using Nop.Web.Framework.Models;
|
using Nop.Web.Framework.Models;
|
||||||
using Nop.Web.Framework.Mvc.ModelBinding;
|
using Nop.Web.Framework.Mvc.ModelBinding;
|
||||||
|
|
||||||
|
|
@ -15,7 +14,5 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Models.Orders
|
||||||
[NopResourceDisplayName("Plugins.YourCompany.ProductAttributes.Fields.DateOfReceipt")]
|
[NopResourceDisplayName("Plugins.YourCompany.ProductAttributes.Fields.DateOfReceipt")]
|
||||||
public DateTime? DateOfReceipt { get; set; }
|
public DateTime? DateOfReceipt { get; set; }
|
||||||
|
|
||||||
public OrderDto OrderDto { get; set; }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
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; }
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -167,9 +167,6 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Update="Areas\Admin\Views\AppDownload\Index.cshtml">
|
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
<None Update="Areas\Admin\Views\Order\FileUploadGridComponent.cshtml">
|
<None Update="Areas\Admin\Views\Order\FileUploadGridComponent.cshtml">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
|
|
||||||
<div class="col-12 col-md-7">
|
<div class="col-12 col-md-4">
|
||||||
<div class="card card-default mb-2">
|
<div class="card card-default mb-2">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<i class="fas fa-file-invoice"></i>
|
<i class="fas fa-file-invoice"></i>
|
||||||
|
|
@ -17,34 +17,53 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
|
<div class="col-md-3 text-right">
|
||||||
<div class="col-md-12">
|
<strong>Mérés információ</strong>
|
||||||
<strong>@(Model.IsMeasurable ? "Mérendő termék!" : "Nem mérendő termék")</strong>
|
</div>
|
||||||
|
<div class="col-md-9">
|
||||||
|
@(Model.IsMeasurable ? "Mérendő" : "Nem mérendő")
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<hr />
|
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<nop-label asp-for="DateOfReceipt" />
|
<nop-label asp-for="DateOfReceipt" />
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-9">
|
||||||
<nop-editor asp-for="DateOfReceipt" asp-template="" />
|
<nop-editor asp-for="DateOfReceipt" asp-template="" />
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-3 text-right">
|
</div>
|
||||||
|
<div class="form-group row">
|
||||||
|
<div class="col-md-12 text-right">
|
||||||
<button type="button" id="saveAttributesBtn" class="btn btn-primary">
|
<button type="button" id="saveAttributesBtn" class="btn btn-primary">
|
||||||
<i class="fa fa-save"></i> Mentés
|
<i class="fa fa-save"></i> Mentés
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<hr />
|
</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">
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<div class="col-md-6">
|
<div class="col-12">
|
||||||
<button type="button" class="btn btn-warning btn-block" data-toggle="modal" data-target="#allowRevisionModal">
|
<label for="notificationMessage">Üzenet szövege:</label>
|
||||||
<i class="fa fa-redo"></i> Újramérés engedélyezése
|
<textarea id="notificationMessage" class="form-control" rows="3" placeholder="Írja be az üzenetet..."></textarea>
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
</div>
|
||||||
<button type="button" class="btn btn-primary btn-block" data-toggle="modal" data-target="#sendMessageModal">
|
<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">
|
||||||
<i class="fas fa-paper-plane"></i> Üzenet küldése
|
<i class="fas fa-paper-plane"></i> Üzenet küldése
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -52,15 +71,15 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 col-md-5">
|
<div class="col-12 col-md-4">
|
||||||
<div class="card card-default mb-3">
|
<div class="card card-default mb-3">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<i class="fas fa-file-invoice"></i>
|
<i class="fas fa-file-invoice"></i>
|
||||||
Megrendelés beküldése Innvoice-ba
|
InnVoice Management
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="col-12">
|
<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;">
|
<div id="orderStatus" class="alert alert-info" style="display: none;">
|
||||||
<i class="fas fa-info-circle"></i> <span id="orderStatusMessage"></span>
|
<i class="fas fa-info-circle"></i> <span id="orderStatusMessage"></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -77,7 +96,7 @@
|
||||||
|
|
||||||
<div class="col-12 text-right float-end">
|
<div class="col-12 text-right float-end">
|
||||||
<button type="button" id="createOrderBtn" class="btn btn-success">
|
<button type="button" id="createOrderBtn" class="btn btn-success">
|
||||||
<i class="fas fa-shopping-cart"></i> Megrendelés beküldése
|
<i class="fas fa-shopping-cart"></i> Létrehozás
|
||||||
</button>
|
</button>
|
||||||
<button type="button" id="checkOrderBtn" class="btn btn-secondary" style="display: none;">
|
<button type="button" id="checkOrderBtn" class="btn btn-secondary" style="display: none;">
|
||||||
<i class="fas fa-sync"></i> Invoice adat ellenőrzése
|
<i class="fas fa-sync"></i> Invoice adat ellenőrzése
|
||||||
|
|
@ -87,79 +106,33 @@
|
||||||
</div>
|
</div>
|
||||||
</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>
|
</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>
|
<script>
|
||||||
|
|
@ -169,7 +142,6 @@
|
||||||
var createInvoiceUrl = '/Admin/Invoice/CreateInvoice';
|
var createInvoiceUrl = '/Admin/Invoice/CreateInvoice';
|
||||||
var getInvoiceStatusUrl = '/Admin/Invoice/GetInvoiceStatus';
|
var getInvoiceStatusUrl = '/Admin/Invoice/GetInvoiceStatus';
|
||||||
|
|
||||||
|
|
||||||
var orderExists = false;
|
var orderExists = false;
|
||||||
var invoiceExists = false;
|
var invoiceExists = false;
|
||||||
|
|
||||||
|
|
@ -206,62 +178,6 @@
|
||||||
return false;
|
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 ==========
|
// ========== ORDER MANAGEMENT ==========
|
||||||
|
|
||||||
// Create Order
|
// Create Order
|
||||||
|
|
@ -532,87 +448,75 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// ========== NOTIFICATION MANAGEMENT ==========
|
|
||||||
|
|
||||||
var sendNotificationUrl = '/Admin/CustomOrder/SendOrderNotification';
|
var sendNotificationUrl = '/Admin/CustomOrder/SendOrderNotification';
|
||||||
|
|
||||||
// Send Notification (in modal)
|
// Send Notification
|
||||||
$("#sendNotificationBtn").click(function (e) {
|
$("#sendNotificationBtn").click(function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
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");
|
|
||||||
|
|
||||||
// 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");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
if (!message) {
|
||||||
|
showNotificationStatus("Kérjük, adjon meg egy üzenetet!", "warning");
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear notification status when modal is closed
|
var btn = $(this);
|
||||||
$('#sendMessageModal').on('hidden.bs.modal', function () {
|
btn.prop("disabled", true).html('<i class="fas fa-spinner fa-spin"></i> Küldés...');
|
||||||
$("#notificationStatus").hide();
|
|
||||||
$("#notificationMessage").val("");
|
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");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
</script>
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
</script>
|
||||||
Loading…
Reference in New Issue