Merge branch '4.80' of https://git.aycode.com/Adam/Mango.Nop.Plugins into 4.80
This commit is contained in:
commit
653652f4d0
|
|
@ -0,0 +1,145 @@
|
|||
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,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)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
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; }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
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; }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,167 @@
|
|||
@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.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",
|
||||
|
|
@ -156,6 +161,16 @@ public class RouteProvider : IRouteProvider
|
|||
name: "Plugin.FruitBank.Admin.ManagementPage.ProcessShippingDocument",
|
||||
pattern: "Admin/ManagamentPage/ProcessShippingDocument/{id}",
|
||||
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>
|
||||
|
|
|
|||
|
|
@ -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; }
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -168,6 +168,9 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Areas\Admin\Views\AppDownload\Index.cshtml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Areas\Admin\Views\Order\FileUploadGridComponent.cshtml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
|
|
|
|||
|
|
@ -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