mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 13:03:12 +00:00
- Replace all Contacts.Name with (FirstName + " " + LastName) pattern - Fix ContactService, Index.razor, QuotesPDF, QuotesDetails, CreateQuotes - Fix WorkOrderPDF, Viewworkorder, UserViewWordOrder, Addworkorders - Fix ViewTemplate, AddTemplate, Templates settings pages - Blazor project now builds successfully
325 lines
14 KiB
Text
325 lines
14 KiB
Text
@page "/createquotes/{id:int}"
|
|
<Header pagename="Quotes " icon='<i class="material-icons-round opacity-10">article</i>'></Header>
|
|
|
|
<style>
|
|
/* Set the color of the calendar icon to white */
|
|
input[type="date"]::-webkit-calendar-picker-indicator {
|
|
filter: invert(1);
|
|
}
|
|
</style>
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="card cardbg mt-2">
|
|
<!-- Card header -->
|
|
<div class="card-header pb-0 cardbg">
|
|
<div class="d-lg-flex">
|
|
<div>
|
|
@if (model.Id == 0)
|
|
{
|
|
<h5 class="mb-0"> <a href="quotes" style="color: #53C2F1 !important;"><i class="material-icons">reply</i> </a> New Quote</h5>
|
|
}
|
|
else
|
|
{
|
|
<h5 class="mb-0"><a href="quotes" style="color: #53C2F1 !important;"><i class="material-icons">reply</i></a> Edit Quote</h5>
|
|
}
|
|
@* <div class="col-1">
|
|
<div class="input-group input-group-static mb-2">
|
|
<label>Quote ID</label>
|
|
<input type="text" class="form-control" @bind="@random5DigitNumber" />
|
|
</div>
|
|
</div> *@
|
|
<p>Quote ID :@random5DigitNumber</p>
|
|
</div>
|
|
</div>
|
|
<div class="row justify-content-center">
|
|
<div class="col-12 text-center">
|
|
<img src="./assets/img/Logo.png" class="navbar-brand-img-1 h-90 img-fluid" alt="main_logo">
|
|
<h6 class="text-info mb-0">80 Orville Dr</h6>
|
|
<p class="mb-0"><i class="fa fa-map-marker me-1"></i> Bohemia, NY 11716</p>
|
|
<p class="mb-0"><i class="fa fa-phone me-1"></i> 516-699-2092/631-334-2594</p>
|
|
<p class="mb-0"><i class="fa fa-envelope me-1"></i> Info@seahavenindustries.com</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<hr class="horizontal light mt-3 mb-1" />
|
|
<form method="post" @onsubmit="SaveData">
|
|
<div class="card-body px-3 pb-0">
|
|
<div class="row">
|
|
<div class="col-6">
|
|
<label for="exampleFormControlInput1" class="form-label">Date:</label>
|
|
<div class="input-group input-group-outline mt-1 mb-2">
|
|
<input type="date" class="form-control" @bind="model.Date" />
|
|
</div>
|
|
</div>
|
|
<div class="col-6">
|
|
<label for="exampleFormControlInput1" class="form-label">Proposal For :</label>
|
|
<div class="input-group input-group-outline mt-1 mb-2">
|
|
<RadzenDropDown AllowClear="true" @bind-Value=model.WorkorderId
|
|
LoadData=@LoadworkorderData AllowFiltering="true" Change="OnWorkOrderChange"
|
|
Data=@order TextProperty="WorkerOrderTitle" ValueProperty="Id" Style="width: 100%;" Name="DropDownFilteringLoadData" />
|
|
</div>
|
|
</div>
|
|
<div class="col-6">
|
|
<label for="exampleFormControlInput1" class="form-label">POC :</label>
|
|
<div class="input-group input-group-outline mt-1 mb-2">
|
|
|
|
<RadzenDropDown AllowClear="true" @bind-Value=model.ContactId
|
|
LoadData=@LoadcontactData AllowFiltering="true"
|
|
Data=@contacts TextProperty="Name" ValueProperty="Id" Style="width: 100%;" Name="DropDownFilteringLoadData" />
|
|
|
|
</div>
|
|
</div>
|
|
<div class="col-6">
|
|
<label for="exampleFormControlInput1" class="form-label">PO #:</label>
|
|
<div class="input-group input-group-outline mt-1 mb-2">
|
|
<input type="text" class="form-control" @bind="model.PO" />
|
|
</div>
|
|
</div>
|
|
<div class="col-6">
|
|
<label for="exampleFormControlInput1" class="form-label">TT #:</label>
|
|
<div class="input-group input-group-outline mt-1 mb-2">
|
|
<input type="text" class="form-control" @bind="model.TT" />
|
|
</div>
|
|
</div>
|
|
<div class="col-6">
|
|
<label for="exampleFormControlInput1" class="form-label">Project Name:</label>
|
|
<div class="input-group input-group-outline mt-1 mb-2">
|
|
<input type="text" class="form-control" @bind="model.ProjectName" />
|
|
</div>
|
|
</div>
|
|
<div class="col-6">
|
|
<label for="exampleFormControlInput1" class="form-label">Site Name:</label>
|
|
<div class="input-group input-group-outline mt-1 mb-2">
|
|
<input type="text" class="form-control" @bind="model.SiteName" />
|
|
</div>
|
|
</div>
|
|
<div class="col-6">
|
|
<label for="exampleFormControlInput1" class="form-label">Site ID :</label>
|
|
<div class="input-group input-group-outline mt-1 mb-2">
|
|
<input type="text" class="form-control" @bind="model.SiteId" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<hr class="horizontal light my-2 mb-1" />
|
|
<div class="row">
|
|
|
|
<h5 class="">Address</h5>
|
|
|
|
<div class="col-12 justify-content-center">
|
|
<div class="text-center d-flex justify-content-center">
|
|
<hr class="my-3 bg-white col-10" />
|
|
</div>
|
|
</div>
|
|
<div class="col-12">
|
|
<label for="exampleFormControlInput1" class="form-label">Billing Address :</label>
|
|
<div class="input-group input-group-outline mt-1 mb-2">
|
|
<input type="text" class="form-control" @bind="model.BillingAddress" />
|
|
</div>
|
|
</div>
|
|
@* <div class="col-8">
|
|
<label for="exampleFormControlInput1" class="form-label">Shipping Address :</label>
|
|
<div class="input-group input-group-outline mt-1 mb-2">
|
|
<input type="text" class="form-control" @bind="model.ShippingAddress" />
|
|
</div>
|
|
</div> *@
|
|
</div>
|
|
<hr class="horizontal light my-2 mb-1" />
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="d-flex">
|
|
<h6>Line Items</h6>
|
|
<a class="ms-auto" @onclick="AddLineItem"><i class="fa fa-plus-circle text-info"></i></a>
|
|
</div>
|
|
|
|
@if (model != null && model.LineItems != null)
|
|
{
|
|
int i = 0;
|
|
foreach (var lineItem in model.LineItems.ToList())
|
|
{
|
|
i++;
|
|
<div class="col-12 align-items-center">
|
|
<div class="d-flex">
|
|
<input type="hidden" @bind="lineItem.Id" />
|
|
<input type="hidden" @bind="i" />
|
|
<label class="form-label">Line Item @i:</label>
|
|
<a href="javascript:;" class="ms-2 float-end ms-auto text-danger" @onclick="() => RemoveLineItem(lineItem)">
|
|
<i class="fa fa-times"></i>
|
|
</a>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-md-8">
|
|
<div class="input-group input-group-outline mt-1 mb-2">
|
|
<textarea class="form-control" placeholder="Description" @bind="lineItem.Descriptions"></textarea>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-4">
|
|
<div class="input-group input-group-outline mt-1 mb-2 d-flex">
|
|
<h6 class="me-2 mt-2">$</h6>
|
|
<input type="text" class="form-control" placeholder="Amount" @bind="lineItem.Lineitem" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
}
|
|
}
|
|
</div>
|
|
|
|
<div class="col-12 text-end mb-3">
|
|
<button type="submit" class="btn bg-gradient-info btn-sm mb-0">Save</button>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@if (isloading)
|
|
{
|
|
<div class="loading">Loading…</div>
|
|
}
|
|
@using SeaHavenIndustries.Data.IRepository;
|
|
@inject IWorkOrderRepository _service;
|
|
@inject IQuotesRepository _service1;
|
|
@using Microsoft.JSInterop
|
|
@using global::Data.SeaHavenIndustries
|
|
@inject IJSRuntime JSRuntime
|
|
@inject NavigationManager Navigation
|
|
|
|
@code {
|
|
[Parameter]
|
|
public int? id { get; set; }
|
|
private int random5DigitNumber = 0;
|
|
public bool isloading = true;
|
|
|
|
private Quotes model = new();
|
|
private IEnumerable<WorkOrder>? order { get; set; }
|
|
private IEnumerable<WorkOrder>? workorderlist { get; set; }
|
|
private IEnumerable<Contacts>? contacts { get; set; }
|
|
private IEnumerable<Contacts>? contactslist { get; set; }
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
random5DigitNumber = GenerateRandomNumber();
|
|
if (id != null && id != 0)
|
|
{
|
|
model = await _service1.GetQuotesById(id.Value);
|
|
random5DigitNumber = int.Parse(model.QuotId);
|
|
}
|
|
else
|
|
{
|
|
model.BillingAddress = "Amazon.com Services LLC 410 Terry Ave,North Seattle, Washington, 98109";
|
|
}
|
|
contacts = await _service.GetContacts();
|
|
contactslist = contacts;
|
|
order = await _service.Getworkorder();
|
|
workorderlist = order;
|
|
isloading = false;
|
|
|
|
}
|
|
protected void LoadworkorderData(LoadDataArgs args)
|
|
{
|
|
|
|
var query = workorderlist;
|
|
if (!string.IsNullOrEmpty(args.Filter))
|
|
{
|
|
query = query.Where(c => c.WorkerOrderTitle.ToLower().Contains(args.Filter.ToLower()));
|
|
}
|
|
if (query != null)
|
|
{
|
|
order = query.ToList();
|
|
}
|
|
InvokeAsync(StateHasChanged);
|
|
}
|
|
protected void LoadcontactData(LoadDataArgs args)
|
|
{
|
|
|
|
var query = contactslist;
|
|
if (!string.IsNullOrEmpty(args.Filter))
|
|
{
|
|
query = query.Where(c => (c.FirstName + " " + c.LastName).ToLower().Contains(args.Filter.ToLower()));
|
|
}
|
|
if (query != null)
|
|
{
|
|
contacts = query.ToList();
|
|
}
|
|
InvokeAsync(StateHasChanged);
|
|
}
|
|
private void OnWorkOrderChange(dynamic e)
|
|
{
|
|
if (e != null)
|
|
{
|
|
int selectedWorkOrderId = e;
|
|
var selectedWorkOrder = order.FirstOrDefault(item => item.Id == selectedWorkOrderId);
|
|
|
|
if (selectedWorkOrder != null)
|
|
{
|
|
model.PO = selectedWorkOrder.PO;
|
|
model.TT = selectedWorkOrder.TT;
|
|
if (selectedWorkOrder.Locations != null)
|
|
{
|
|
model.SiteName = selectedWorkOrder.Locations.Title;
|
|
model.SiteId = selectedWorkOrder.Locations.Name;
|
|
}
|
|
else
|
|
{
|
|
model.SiteName = string.Empty; // or any default value
|
|
model.SiteId = string.Empty; // or any default value
|
|
}
|
|
}
|
|
}
|
|
}
|
|
protected async Task SaveData()
|
|
{
|
|
model.QuotId = random5DigitNumber.ToString();
|
|
var res = await _service1.Addquotes(model);
|
|
if (res == "success")
|
|
{
|
|
await ShowSweetAlert("Sucessfully Saved Data", "success");
|
|
Navigation.NavigateTo("quotes");
|
|
}
|
|
else
|
|
{
|
|
await ShowSweetAlert(res, "error");
|
|
}
|
|
}
|
|
|
|
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");
|
|
}
|
|
|
|
public async Task AddLineItem()
|
|
{
|
|
model.LineItems = model.LineItems == null ? new List<QuotesLineItems>() : model.LineItems;
|
|
int nextLineItemNumber = model.LineItems.Count + 1;
|
|
|
|
model.LineItems.Add(new QuotesLineItems { LineitemNumber = nextLineItemNumber, Lineitem = 0 });
|
|
}
|
|
|
|
|
|
public void RemoveLineItem(QuotesLineItems lineItems)
|
|
{
|
|
model.LineItems.Remove(lineItems);
|
|
}
|
|
|
|
private int GenerateRandomNumber()
|
|
{
|
|
Random random = new Random();
|
|
return random.Next(100000, 999999); // Generates a random number between 10000 and 99999
|
|
}
|
|
|
|
|
|
}
|