mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 23:33:10 +00:00
466 lines
No EOL
16 KiB
Text
466 lines
No EOL
16 KiB
Text
@if (step == 2)
|
|
{
|
|
<div class="modal-header">
|
|
<h5 class="modal-title font-weight-normal" id="w_order11lLabel"><a href="javascript:void()" @onclick='(e)=>step=3'><i class="material-icons">reply</i></a> Comments</h5>
|
|
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close">
|
|
@* <span aria-hidden="true">×</span> *@
|
|
</button>
|
|
</div>
|
|
<div class="modal-body">
|
|
|
|
<div class="card mb-3 cardbg p-2">
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<WorkOrderComment id="@id" step="1"></WorkOrderComment>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
}
|
|
else
|
|
{
|
|
<div class="modal-header">
|
|
<h5 class="modal-title font-weight-normal" id="w_order11lLabel">Work Order</h5>
|
|
<div class="text-end d-flex justify-content-end">
|
|
<button type="button" class="btn btn-outline-warning btn-sm mb-0 me-2" @onclick='(e)=>step=2'>
|
|
<span class="fa fa-comment me-2"></span> Comments
|
|
</button>
|
|
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close">
|
|
<span aria-hidden="true">×</span>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<div class="modal-body">
|
|
|
|
<div class="card mb-3 cardbg p-2">
|
|
<div class="row px-3">
|
|
<div class="col-12"><h6>Work Order Title: @order.WorkerOrderTitle</h6></div>
|
|
<div class="col-6">
|
|
<div class="row">
|
|
<div class="col-4">
|
|
<p class="mb-1">Workorder#: </p>
|
|
</div>
|
|
<div class="col-6">
|
|
<p class="mb-1">@order?.WorkerOrderNumber</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-6">
|
|
<div class="row">
|
|
<div class="col-4">
|
|
<p class="mb-1">Due Date:</p>
|
|
</div>
|
|
<div class="col-6">
|
|
<p class="mb-1">@order?.DueDate?.ToString("MMM dd, yyyy")</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-6">
|
|
<div class="row">
|
|
<div class="col-4">
|
|
<p class="mb-1">Assigned To:</p>
|
|
</div>
|
|
<div class="col-6">
|
|
<p class="mb-1">@order?.AssignToUser?.FirstName</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-6">
|
|
<div class="row">
|
|
<div class="col-4">
|
|
<p class="mb-1">Dispatch By::</p>
|
|
</div>
|
|
<div class="col-6">
|
|
<p class="mb-1"></p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-12">
|
|
<div class="row">
|
|
<div class="col-2">
|
|
<p class="mb-1">Location:</p>
|
|
</div>
|
|
<div class="col-10">
|
|
<p class="mb-1">@order?.Locations?.Title-@order?.Locations?.Name</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-6">
|
|
<div class="row">
|
|
<div class="col-4">
|
|
<p class="mb-1">PO #:</p>
|
|
</div>
|
|
<div class="col-6">
|
|
<p class="mb-1">@order?.PO</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-6">
|
|
<div class="row">
|
|
<div class="col-4">
|
|
<p class="mb-1">TT #:</p>
|
|
</div>
|
|
<div class="col-6">
|
|
<p class="mb-1">@order.TT</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-6">
|
|
<div class="row">
|
|
<div class="col-5">
|
|
<p class="mb-1">Scheduled Date:</p>
|
|
</div>
|
|
<div class="col-7">
|
|
<p class="mb-1"></p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-12">
|
|
<div class="row">
|
|
<div class="col-2">
|
|
<p class="mb-1">POC:</p>
|
|
</div>
|
|
<div class="col-10">
|
|
<div>
|
|
@if (order.WorkOrderContacts != null)
|
|
{
|
|
foreach (var itm in order.WorkOrderContacts)
|
|
{
|
|
<span class="badge badge-info me-2">@itm.POC.Name</span>
|
|
}
|
|
}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-12">
|
|
<div class="row">
|
|
<div class="col-2">
|
|
<p class="mb-1">Categories:</p>
|
|
</div>
|
|
<div class="col-10">
|
|
<div>
|
|
@if (order.WorkOrderCategories != null)
|
|
{
|
|
foreach (var itm in order.WorkOrderCategories)
|
|
{
|
|
<span class="badge badge-info me-2">@itm.Category.Name</span>
|
|
}
|
|
}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-12 mt-2">
|
|
<p class="mb-1">Attachments:</p>
|
|
<div>
|
|
@if (order.workOrderAttachments != null)
|
|
{
|
|
int q = 0;
|
|
foreach (var itm in order.workOrderAttachments)
|
|
{
|
|
q++;
|
|
<a href="@itm.Attachments" class="text-info" target="_blank"><u> View Attachment @q</u></a>
|
|
|
|
<br />
|
|
}
|
|
}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card mb-3 cardbg p-2">
|
|
<div class="row px-3">
|
|
<div class="col-12"><h6 class="">Sign Off</h6></div>
|
|
<div class="col-12">
|
|
<label for="exampleFormControlInput1" class="form-label">Issue : @order.BeforPhotoIssue</label>
|
|
</div>
|
|
<div class="col-12 mt-3">
|
|
<label for="exampleFormControlInput1" class="form-label">Attachments</label>
|
|
<div class="input-group input-group-outline mt-2 text-center">
|
|
<img src="@order.BeforPhotoAttachment" height="90" width="80" />
|
|
</div>
|
|
</div>
|
|
<div class="col-12 mt-3">
|
|
<label for="exampleFormControlInput1" class="form-label">Solution : @order.AfterPhotoIssue</label>
|
|
</div>
|
|
<div class="col-12">
|
|
<label for="exampleFormControlInput1" class="form-label">Attachments</label>
|
|
<div class="input-group input-group-outline mt-2 ">
|
|
<img src="@order.AfterPhotoAttachment" height="90" width="80" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card mb-3 cardbg p-2">
|
|
<div class="row px-3">
|
|
<div class="col-12"><h6>Signature</h6></div>
|
|
<div class="col-2">
|
|
<label for="exampleFormControlInput1" class="form-label">@order.SignOffName</label>
|
|
</div>
|
|
<div class="col-8">
|
|
<div class="input-group input-group-outline mt-2 text-center">
|
|
<img src="@order.SignOffSignature" height="90" width="80" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card mb-3 cardbg p-2">
|
|
<div class="row px-3">
|
|
<div class="col-12"><h6 class="ps-3">Comments</h6></div>
|
|
<div class="col-12">
|
|
<UserWorkOrderComment id="@id" step="0"></UserWorkOrderComment>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card mb-3 p-2">
|
|
<div class="row px-3">
|
|
<div class="col-12"><h6>Attached Quotes</h6></div>
|
|
<div class="col-12 ">
|
|
@if (order.Quotes != null)
|
|
{
|
|
foreach (var itm in order.Quotes.ToList())
|
|
{
|
|
<p> <a href="quotesquotes/@itm.Id" class="text-info">QO-@itm.QuotId</a></p>
|
|
}
|
|
}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
}
|
|
|
|
@if (ispdf)
|
|
{
|
|
<div @ref="htmlContentReference" class="d-none">
|
|
<WorkOrderPDF id="@id"></WorkOrderPDF>
|
|
</div>
|
|
}
|
|
|
|
|
|
@using SeaHavenIndustries.Data.IRepository;
|
|
@inject IWorkOrderRepository _service;
|
|
@using Microsoft.JSInterop
|
|
@using System.Text.Json
|
|
@using global::Data.SeaHavenIndustries
|
|
@inject IJSRuntime JSRuntime
|
|
@inject ChangeStepService StepService
|
|
@* @inject CacheService _cacheService *@
|
|
@implements IDisposable
|
|
@inject NavigationManager Navigation
|
|
@using SeaHavenIndustries.Data.Services
|
|
@inject PdfService pdfService
|
|
@code {
|
|
[Parameter]
|
|
public int? id { get; set; }
|
|
private WorkOrder order = new();
|
|
private string selectedStatus = "Open";
|
|
private bool isloading = true;
|
|
private int step = 0;
|
|
private bool ispdf = false;
|
|
private IEnumerable<WorkOrder>? list { get; set; }
|
|
public ElementReference htmlContentReference { get; set; }
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
step = 0;
|
|
isloading = true;
|
|
StepService.OnStateChange += StateHasChanged;
|
|
if (id != null)
|
|
{
|
|
var result = await _service.GetworkorderById(id.Value);
|
|
if (result != null)
|
|
{
|
|
order = result;
|
|
selectedStatus = order.Status;
|
|
// if (order.AssignTo == null)
|
|
// {
|
|
// selectedStatus = "UnAssigned";
|
|
// }
|
|
//StepService.SetCurrentstatus(selectedStatus);
|
|
// StepService.chnageactivemodel(order);
|
|
}
|
|
ispdf = true;
|
|
isloading = false;
|
|
}
|
|
//StepService.isloading = false;
|
|
|
|
// isloading = false;
|
|
|
|
}
|
|
|
|
private async Task GeneratePdf()
|
|
{
|
|
ispdf = true;
|
|
var htmlContent = await JSRuntime.InvokeAsync<string>("getHtmlContent", htmlContentReference);
|
|
var pdfBytes = await pdfService.GeneratePdf(htmlContent);
|
|
ispdf = false;
|
|
|
|
var pdfBase64 = Convert.ToBase64String(pdfBytes);
|
|
await JSRuntime.InvokeVoidAsync("downloadFile", pdfBase64, "Workorder.pdf");
|
|
|
|
}
|
|
private async Task SendPdf()
|
|
{
|
|
ispdf = true;
|
|
var htmlContent = await JSRuntime.InvokeAsync<string>("getHtmlContent", htmlContentReference);
|
|
var pdfBytes = await pdfService.GeneratePdf(htmlContent);
|
|
var result = await _service.SendEmailWorrkorder(pdfBytes, order.Id);
|
|
if (result == "success")
|
|
{
|
|
await ShowSweetAlert("Email send successfully", "success");
|
|
}
|
|
else
|
|
{
|
|
await ShowSweetAlert(result, "error");
|
|
}
|
|
ispdf = false;
|
|
}
|
|
|
|
private int eid = 0;
|
|
protected async Task Edit(int id)
|
|
{
|
|
if (id != 0)
|
|
{
|
|
eid = id;
|
|
StepService.SetValue(1);
|
|
await OnStepChange.InvokeAsync(1);
|
|
await InvokeAsync(StateHasChanged);
|
|
}
|
|
else
|
|
{
|
|
}
|
|
}
|
|
private async Task Copy(int id)
|
|
{
|
|
eid = id;
|
|
StepService.SetValue(1);
|
|
step = 1;
|
|
StepService.SetValue(1);
|
|
StepService.SetCopy(true);
|
|
await OnStepChange.InvokeAsync(1);
|
|
await InvokeAsync(StateHasChanged);
|
|
}
|
|
private async Task Settemplatecreate(int id)
|
|
{
|
|
eid = id;
|
|
StepService.SetValue(1);
|
|
step = 1;
|
|
StepService.SetValue(1);
|
|
StepService.SetTemplatecreate(true);
|
|
await OnStepChange.InvokeAsync(1);
|
|
await InvokeAsync(StateHasChanged);
|
|
}
|
|
private async Task ChangeStep()
|
|
{
|
|
StepService.SetValue(2);
|
|
await OnStepChange.InvokeAsync(2);
|
|
// StateHasChanged(); // Consider removing this line
|
|
}
|
|
private async Task Changestatus(string status)
|
|
{
|
|
// if (selectedStatus == "UnAssigned")
|
|
// {
|
|
// await ShowSweetAlert("Please first assign to any user!", "error");
|
|
// return;
|
|
// }
|
|
var res = await _service.ChangeStatus(id.Value, status);
|
|
if (res == "success")
|
|
{
|
|
selectedStatus = status;
|
|
await ShowSweetAlert("Sucessfully Saved Data", "success");
|
|
// _cacheService.Clear();
|
|
|
|
StepService.SetValue(0);
|
|
// StepService.SetCurrentstatus(status);
|
|
await StepService.GetWorkerList();
|
|
//var result2 = StepService._list;
|
|
//Navigation.NavigateTo(Navigation.Uri, forceLoad: true);
|
|
}
|
|
else
|
|
{
|
|
await ShowSweetAlert(res, "error");
|
|
}
|
|
}
|
|
[Parameter]
|
|
public EventCallback<int> OnStepChange { get; set; }
|
|
public void Dispose()
|
|
{
|
|
StepService.OnStateChange -= StateHasChanged;
|
|
}
|
|
private async Task ShowSweetAlert(string title, string icon)
|
|
{
|
|
// Display a SweetAlert dialog
|
|
await JSRuntime.InvokeVoidAsync("Swal.fire", new
|
|
{
|
|
toast = true,
|
|
showConfirmButton = false,
|
|
timer = 3000,
|
|
title = title,
|
|
icon = icon,
|
|
position = "top-end"
|
|
});
|
|
await JSRuntime.InvokeVoidAsync("closemodal");
|
|
}
|
|
private async Task Delete(int val)
|
|
{
|
|
var result = await JSRuntime.InvokeAsync<JsonElement>("Swal.fire", new
|
|
{
|
|
title = "Are you sure?",
|
|
text = "You won't be able to revert this!",
|
|
type = "warning",
|
|
showCancelButton = true,
|
|
customClass = new
|
|
{
|
|
confirmButton = "btn btn-success m-1",
|
|
cancelButton = "btn btn-danger m-1"
|
|
},
|
|
buttonsStyling = false,
|
|
confirmButtonText = "Yes, delete it!"
|
|
});
|
|
|
|
if (result.TryGetProperty("isConfirmed", out var isConfirmedProperty) && isConfirmedProperty.GetBoolean())
|
|
{
|
|
// Call your delete API here
|
|
var response = await _service.Deleteworkorder(val);
|
|
if (response == "success")
|
|
{
|
|
await JSRuntime.InvokeVoidAsync("Swal.fire", new
|
|
{
|
|
icon = "success",
|
|
title = "Deleted!",
|
|
text = "Data has been deleted.",
|
|
type = "primary",
|
|
showCancelButton = false,
|
|
customClass = new
|
|
{
|
|
confirmButton = "btn btn-success",
|
|
cancelButton = "btn btn-danger"
|
|
},
|
|
buttonsStyling = false,
|
|
confirmButtonText = "Ok"
|
|
});
|
|
list = await _service.Getworkorder();
|
|
// await JSRuntime.InvokeVoidAsync("location.reload");
|
|
}
|
|
else
|
|
{
|
|
await JSRuntime.InvokeVoidAsync("Swal.fire", new
|
|
{
|
|
title = "Not Deleted!",
|
|
text = "Unsuccessful! Cannot delete this.",
|
|
type = "danger"
|
|
});
|
|
}
|
|
}
|
|
}
|
|
} |