public async Task <ActionResult> DailyChecks() { await GaneConfigurationsHelper.UpdateIsCurrentTenantFlags(); await PropertyService.UpdateAllPropertyTenantsFlags(); return(RedirectToAction("Index", "Home")); }
public async Task <JsonResult> SaveCustomEmails(OrderRecipientInfo shipmentAndRecipientInfo) { if (string.IsNullOrEmpty(shipmentAndRecipientInfo.CustomRecipients) && shipmentAndRecipientInfo.AccountEmailContacts == null) { return(Json(false, JsonRequestBehavior.AllowGet)); } else { var Order = OrderService.GetOrderById(shipmentAndRecipientInfo.orderId ?? 0); if (shipmentAndRecipientInfo.InventoryTransactionType == 8) { var orderprocess = OrderService.GetOrderProcessByOrderProcessId(shipmentAndRecipientInfo.orderId ?? 0); Order = orderprocess.Order; } AccountServices.UpdateOrderPTenantEmailRecipients(shipmentAndRecipientInfo.AccountEmailContacts, Order.OrderID, CurrentUserId); if (shipmentAndRecipientInfo.InventoryTransactionType == 8) { var report = CreateDeliveryNotePrint(shipmentAndRecipientInfo.orderId ?? 0, null); PrepareDirectory("~/UploadedFiles/reports/dn/"); var reportPath = "~/UploadedFiles/reports/dn/" + Order.OrderNumber + ".pdf"; report.ExportToPdf(Server.MapPath(reportPath)); var result = await GaneConfigurationsHelper.CreateTenantEmailNotificationQueue($"#{Order.OrderNumber} - Sales Order Confirmation", Mapper.Map(Order, new OrderViewModel()), reportPath, shipmentAndRecipientInfo : shipmentAndRecipientInfo, worksOrderNotificationType : WorksOrderNotificationTypeEnum.SalesOrderUpdateTemplate); return(Json(result, JsonRequestBehavior.AllowGet)); } else if (Order.InventoryTransactionTypeId == (int)InventoryTransactionTypeEnum.SalesOrder) { var report = CreateSalesOrderPrint(Order.OrderID); PrepareDirectory("~/UploadedFiles/reports/so/"); var reportPath = "~/UploadedFiles/reports/so/" + Order.OrderNumber + ".pdf"; report.ExportToPdf(Server.MapPath(reportPath)); var result = await GaneConfigurationsHelper.CreateTenantEmailNotificationQueue($"#{Order.OrderNumber} - Sales order", Mapper.Map(Order, new OrderViewModel()), reportPath, shipmentAndRecipientInfo : shipmentAndRecipientInfo, worksOrderNotificationType : WorksOrderNotificationTypeEnum.SalesOrderTemplate); return(Json(result, JsonRequestBehavior.AllowGet)); } else { var report = CreatePurchaseOrderPrint(Order.OrderID); PrepareDirectory("~/UploadedFiles/reports/po/"); var reportPath = "~/UploadedFiles/reports/po/" + Order.OrderNumber + ".pdf"; report.ExportToPdf(Server.MapPath(reportPath)); var result = await GaneConfigurationsHelper.CreateTenantEmailNotificationQueue($"#{Order.OrderNumber} - Purchase Order", Mapper.Map(Order, new OrderViewModel()), reportPath, shipmentAndRecipientInfo : shipmentAndRecipientInfo, worksOrderNotificationType : WorksOrderNotificationTypeEnum.PurchaseOrderTemplate); return(Json(result, JsonRequestBehavior.AllowGet)); } } }
public async Task <ActionResult> Edit([Bind(Include = "OrderID,OrderNumber,DirectShip,ExpectedDate,Note,AccountID,OrderTypeID,LoanID,OrderStatusID,AccountContactId,Posted,PPropertyId,DepartmentId,InvoiceNo,InvoiceDetails,OrderCost,IsCollectionFromCustomerSide")] Order Order, OrderRecipientInfo shipmentAndRecipientInfo, string orderSaveAndProcess, int EmailTemplate) { if (ModelState.IsValid) { var items = GaneOrderDetailsSessionHelper.GetOrderDetailSession(shipmentAndRecipientInfo.PageSessionToken); var orderNotes = GaneOrderNotesSessionHelper.GetOrderNotesSession(shipmentAndRecipientInfo.PageSessionToken); OrderService.SavePurchaseOrder(Order, shipmentAndRecipientInfo, CurrentTenantId, CurrentWarehouseId, CurrentUserId, Mapper.Map(items, new List <OrderDetail>()), orderNotes); if (shipmentAndRecipientInfo.SendEmailWithAttachment) { var report = CreatePurchaseOrderPrint(Order.OrderID); PrepareDirectory("~/UploadedFiles/reports/po/"); var reportPath = "~/UploadedFiles/reports/po/" + Order.OrderNumber + ".pdf"; report.ExportToPdf(Server.MapPath(reportPath)); var result = await GaneConfigurationsHelper.CreateTenantEmailNotificationQueue($"#{Order.OrderNumber} - Purchase order has been updated", Mapper.Map(Order, new OrderViewModel()), reportPath, shipmentAndRecipientInfo : shipmentAndRecipientInfo, worksOrderNotificationType : (WorksOrderNotificationTypeEnum)EmailTemplate); if (result != "Success") { TempData["Error"] = result; } } GaneOrderDetailsSessionHelper.ClearSessionTokenData(shipmentAndRecipientInfo.PageSessionToken); GaneOrderNotesSessionHelper.ClearSessionTokenData(shipmentAndRecipientInfo.PageSessionToken); ViewBag.Fragment = Request.Form["fragment"]; if (orderSaveAndProcess == "1") { return(Redirect(Url.RouteUrl(new { controller = "PurchaseOrders", action = "ReceivePO", id = Order.OrderID }) + "?fragment=" + ViewBag.Fragment as string)); } return(AnchoredOrderIndex("PurchaseOrders", "Index", ViewBag.Fragment as string)); } ViewBag.AllowAccountAddress = caCurrent.CurrentWarehouse()?.AllowShipToAccountAddress; ViewBag.ForceRegeneratePageToken = "True"; ViewBag.ForceRegeneratedPageToken = shipmentAndRecipientInfo.PageSessionToken ?? Guid.NewGuid().ToString(); SetViewBagItems(null, EnumAccountType.Supplier); ViewBag.SupplierID = new SelectList(AccountServices.GetAllValidAccounts(CurrentTenantId, EnumAccountType.Supplier), "SupplierID", "CompanyName", Order.AccountID); return(View(Order)); }
public async Task <ActionResult> GenerateInvoiceEmail(string OrderProcessIds) { var processIds = OrderProcessIds.Split(','); int orderId = 0; string messgae = ""; foreach (var item in processIds) { var masterInvoice = _invoiceService.GetInvoiceMasterById(item.AsInt()); var orderProcessId = masterInvoice.OrderProcessId; var OrderProcess = OrderService.GetOrderProcessByOrderProcessId(orderProcessId); orderId = OrderProcess.OrderID ?? 0; var accountContact = AccountServices.GetAllValidAccountContactsByAccountId(OrderProcess?.Order?.AccountID ?? 0, CurrentTenantId).Where(u => u.ConTypeInvoices == true).ToList(); if (accountContact.Count > 0) { var orderViewModel = Mapper.Map(OrderProcess.Order, new OrderViewModel()); orderViewModel.InvoiceId = item.AsInt(); var report = CreateInvoicePrint(masterInvoice.InvoiceMasterId); PrepareDirectory("~/UploadedFiles/reports/Invoices/"); var reportPath = "~/UploadedFiles/reports/Invoices/" + masterInvoice.InvoiceNumber + ".pdf"; report.ExportToPdf(Server.MapPath(reportPath)); var result = await GaneConfigurationsHelper.CreateTenantEmailNotificationQueue($"#{masterInvoice.InvoiceNumber} - Invoice", orderViewModel, attachmentVirtualPath : reportPath, worksOrderNotificationType : WorksOrderNotificationTypeEnum.InvoiceTemplate); if (result == "Success") { result = "Email Sent"; } messgae += $"{result} against Invoice Number: " + masterInvoice.InvoiceNumber + "\n"; } else { messgae += $"{"No invoicing email against Number: " + masterInvoice.InvoiceNumber} \n"; } } return(Json(string.IsNullOrEmpty(messgae) ? $"No Data Found Against this Invoice" : messgae, JsonRequestBehavior.AllowGet)); }
public async Task <ActionResult> Edit(Order Order, FormCollection formCollection, OrderRecipientInfo shipmentAndRecipientInfo, string orderSaveAndProcess, int EmailTemplate) { if (ModelState.IsValid) { Order.OrderNumber = Order.OrderNumber.Trim(); // get properties of user caUser user = caCurrent.CurrentUser(); Order.DateUpdated = DateTime.UtcNow; Order.UpdatedBy = user.UserId; Order.WarehouseId = CurrentWarehouseId; var items = GaneOrderDetailsSessionHelper.GetOrderDetailSession(shipmentAndRecipientInfo.PageSessionToken); var nItems = GaneOrderNotesSessionHelper.GetOrderNotesSession(shipmentAndRecipientInfo.PageSessionToken); Order = OrderService.SaveSalesOrder(Order, shipmentAndRecipientInfo, CurrentTenantId, CurrentWarehouseId, CurrentUserId, Mapper.Map(items, new List <OrderDetail>()), nItems); if (shipmentAndRecipientInfo.SendEmailWithAttachment) { var report = CreateSalesOrderPrint(Order.OrderID); PrepareDirectory("~/UploadedFiles/reports/so/"); var reportPath = "~/UploadedFiles/reports/so/" + Order.OrderNumber + ".pdf"; report.ExportToPdf(Server.MapPath(reportPath)); var result = await GaneConfigurationsHelper.CreateTenantEmailNotificationQueue($"#{Order.OrderNumber} - Sales order has been updated", Mapper.Map(Order, new OrderViewModel()), reportPath, shipmentAndRecipientInfo : shipmentAndRecipientInfo, worksOrderNotificationType : (WorksOrderNotificationTypeEnum)EmailTemplate); if (result != "Success") { TempData["Error"] = result; } } if (Order.OrderStatusID == (int)OrderStatusEnum.AwaitingAuthorisation) { var result = await GaneConfigurationsHelper.CreateTenantEmailNotificationQueue($"#{Order.OrderNumber} - Order Requires Authorisation", Mapper.Map(Order, new OrderViewModel()), null, shipmentAndRecipientInfo : shipmentAndRecipientInfo, worksOrderNotificationType : WorksOrderNotificationTypeEnum.AwaitingOrderTemplate); if (result != "Success") { TempData["Error"] = result; } } GaneOrderDetailsSessionHelper.ClearSessionTokenData(shipmentAndRecipientInfo.PageSessionToken); GaneOrderNotesSessionHelper.ClearSessionTokenData(shipmentAndRecipientInfo.PageSessionToken); ViewBag.Fragment = Request.Form["fragment"]; if (orderSaveAndProcess == "1") { return(Redirect(Url.RouteUrl(new { controller = "SalesOrders", action = "ProcessOrder", id = Order.OrderID }) + "?fragment=" + ViewBag.Fragment as string)); } return(AnchoredOrderIndex("SalesOrders", "Index", ViewBag.Fragment as string)); } ViewBag.ForceRegeneratePageToken = "True"; ViewBag.ForceRegeneratedPageToken = shipmentAndRecipientInfo.PageSessionToken ?? Guid.NewGuid().ToString(); SetViewBagItems(CurrentTenant, EnumAccountType.Customer); ViewBag.SupplierID = new SelectList(AccountServices.GetAllValidAccounts(CurrentTenantId, EnumAccountType.Supplier), "SupplierID", "CompanyName", Order.AccountID); ViewBag.AccountAddresses = new List <SelectListItem>(); if (Order.AccountID > 0) { var account = AccountServices.GetAccountsById(Order.AccountID.Value); ViewBag.AccountAddresses = new SelectList(account.AccountAddresses, "AddressID", "FullAddressValue", Order.ShipmentAccountAddressId); if (Order.ConsignmentTypeId.HasValue && Order.ConsignmentTypeId.Value != (int)ConsignmentTypeEnum.Collection && Order.ShipmentAccountAddressId > 0) { ViewBag.ShipmentAccountAddressId = Order.ShipmentAccountAddressId; ViewBag.IsShipmentToAccountAddress = true; ViewBag.IsShipmentToCustomAddress = false; } else { ViewBag.ShipmentAccountAddressId = 0; ViewBag.IsShipmentToAccountAddress = false; ViewBag.IsShipmentToCustomAddress = true; } } ViewBag.ConsignmentTypes = new SelectList(OrderService.GetAllValidConsignmentTypes(CurrentTenantId), "ConsignmentTypeId", "ConsignmentType", Order.ConsignmentTypeId); return(View(Order)); }
public async Task <ActionResult> Create(Order Order, OrderRecipientInfo shipmentAndRecipientInfo, int EmailTemplate) { try { if (ModelState.IsValid) { var tempNotesList = GaneOrderNotesSessionHelper.GetOrderNotesSession(shipmentAndRecipientInfo.PageSessionToken); var tempList = GaneOrderDetailsSessionHelper.GetOrderDetailSession(shipmentAndRecipientInfo.PageSessionToken); Order = OrderService.CreateSalesOrder(Order, shipmentAndRecipientInfo, CurrentTenantId, CurrentWarehouseId, CurrentUserId, Mapper.Map(tempList, new List <OrderDetail>()), tempNotesList); if (shipmentAndRecipientInfo.SendEmailWithAttachment) { var report = CreateSalesOrderPrint(Order.OrderID); PrepareDirectory("~/UploadedFiles/reports/so/"); var reportPath = "~/UploadedFiles/reports/so/" + Order.OrderNumber + ".pdf"; report.ExportToPdf(Server.MapPath(reportPath)); var result = await GaneConfigurationsHelper.CreateTenantEmailNotificationQueue($"#{Order.OrderNumber} - Sales order", Mapper.Map(Order, new OrderViewModel()), reportPath, shipmentAndRecipientInfo : shipmentAndRecipientInfo, worksOrderNotificationType : (WorksOrderNotificationTypeEnum)EmailTemplate); if (result != "Success") { TempData["Error"] = result; } } if (Order.OrderStatusID == (int)OrderStatusEnum.AwaitingAuthorisation) { var result = await GaneConfigurationsHelper.CreateTenantEmailNotificationQueue($"#{Order.OrderNumber} - Order Requires Authorisation", Mapper.Map(Order, new OrderViewModel()), null, shipmentAndRecipientInfo : shipmentAndRecipientInfo, worksOrderNotificationType : WorksOrderNotificationTypeEnum.AwaitingOrderTemplate); if (result != "Success") { TempData["Error"] = result; } } //send ingredients email for certain categories var productCategoryTc = _tenantServices.GetTenantConfigById(Order.TenentId)?.ProductCatagories; if (Order.InventoryTransactionTypeId == (int)InventoryTransactionTypeEnum.SalesOrder && !string.IsNullOrEmpty(productCategoryTc)) { var productcategoryList = productCategoryTc.Split(',').Select(int.Parse).ToList(); if (Order.OrderDetails.Any(x => productcategoryList.Contains((int?)x.ProductMaster?.ProductGroupId ?? 0))) { var result = await GaneConfigurationsHelper.SendStandardMailProductGroup(Order.TenentId, Order.OrderNumber, Order.AccountID ?? 0); if (result != "Success") { TempData["Error"] = result; } } } GaneOrderDetailsSessionHelper.ClearSessionTokenData(shipmentAndRecipientInfo.PageSessionToken); GaneOrderNotesSessionHelper.ClearSessionTokenData(shipmentAndRecipientInfo.PageSessionToken); return(AnchoredOrderIndex("SalesOrders", "Index", "SOA")); } int id = 0; var accountaddress = _accountServices.GetAllValidAccountContactsByAccountId(id, CurrentTenantId); ViewBag.AccountContactes = new SelectList(accountaddress, "AccountContactId", "ContactEmail", accountaddress.Select(x => x.AccountID).FirstOrDefault()); ViewBag.ForceRegeneratePageToken = "True"; ViewBag.ForceRegeneratedPageToken = shipmentAndRecipientInfo.PageSessionToken ?? Guid.NewGuid().ToString(); SetViewBagItems(CurrentTenant, EnumAccountType.Customer); ViewBag.OrderDetails = Order.OrderDetails; ViewBag.OrderProcesses = Order.OrderProcess; ViewBag.IsShipmentToAccountAddress = true; ViewBag.AccountAddresses = new List <SelectListItem>() { new SelectListItem() { Text = "Select", Value = "0" } }; ViewBag.ShipmentAccountAddressId = 0; ViewBag.IsShipmentToCustomAddress = false; ViewBag.ConsignmentTypes = new SelectList(OrderService.GetAllValidConsignmentTypes(CurrentTenantId), "ConsignmentTypeId", "ConsignmentType"); ViewBag.SupplierID = new SelectList(AccountServices.GetAllValidAccounts(CurrentTenantId, EnumAccountType.Supplier), "AccountID", "CompanyName", Order.AccountID); return(View(Order)); } catch (Exception Exp) { int ids = 0; var accountaddress = _accountServices.GetAllValidAccountContactsByAccountId(ids, CurrentTenantId); ViewBag.AccountContactes = new SelectList(accountaddress, "AccountContactId", "ContactEmail", accountaddress.Select(x => x.AccountID).FirstOrDefault()); ViewBag.IsShipmentToAccountAddress = true; ViewBag.AccountAddresses = new List <SelectListItem>() { new SelectListItem() { Text = "Select", Value = "0" } }; ViewBag.ShipmentAccountAddressId = 0; ViewBag.IsShipmentToCustomAddress = false; if (Exp.InnerException != null && Exp.InnerException.Message == "Duplicate Order Number") { ModelState.AddModelError("OrderNumber", Exp.Message); } else { ModelState.AddModelError("", Exp.Message); } var tenent = caCurrent.CurrentTenant(); SetViewBagItems(tenent, EnumAccountType.Customer); ViewBag.OrderDetails = Order.OrderDetails; ViewBag.OrderProcesses = Order.OrderProcess; ViewBag.ForceRegeneratePageToken = "True"; ViewBag.ForceRegeneratedPageToken = shipmentAndRecipientInfo.PageSessionToken ?? Guid.NewGuid().ToString(); ViewBag.ConsignmentTypes = new SelectList(OrderService.GetAllValidConsignmentTypes(CurrentTenantId), "ConsignmentTypeId", "ConsignmentType"); ViewBag.SupplierID = new SelectList(AccountServices.GetAllValidAccounts(CurrentTenantId, EnumAccountType.Supplier), "AccountID", "CompanyName", Order.AccountID); return(View(Order)); } }
public async Task <ActionResult> Create(Order Order, OrderRecipientInfo shipmentAndRecipientInfo, int EmailTemplate) { try { if (ModelState.IsValid) { if (shipmentAndRecipientInfo.ShipmentDestination == null || shipmentAndRecipientInfo.TenantAddressID == null) { ViewBag.Error = "Please choose a delivery address"; } else { var orderDetails = GaneOrderDetailsSessionHelper.GetOrderDetailSession(shipmentAndRecipientInfo.PageSessionToken); var orderNotes = GaneOrderNotesSessionHelper.GetOrderNotesSession(shipmentAndRecipientInfo.PageSessionToken); OrderService.CreatePurchaseOrder(Order, shipmentAndRecipientInfo, CurrentTenantId, CurrentWarehouseId, CurrentUserId, Mapper.Map(orderDetails, new List <OrderDetail>()), orderNotes); if (shipmentAndRecipientInfo.SendEmailWithAttachment) { var report = CreatePurchaseOrderPrint(Order.OrderID); PrepareDirectory("~/UploadedFiles/reports/po/"); var reportPath = "~/UploadedFiles/reports/po/" + Order.OrderNumber + ".pdf"; report.ExportToPdf(Server.MapPath(reportPath)); var result = await GaneConfigurationsHelper.CreateTenantEmailNotificationQueue($"#{Order.OrderNumber} - Purchase order", Mapper.Map(Order, new OrderViewModel()), reportPath, shipmentAndRecipientInfo : shipmentAndRecipientInfo, worksOrderNotificationType : (WorksOrderNotificationTypeEnum)EmailTemplate); if (result != "Success") { TempData["Error"] = result; } } GaneOrderDetailsSessionHelper.ClearSessionTokenData(shipmentAndRecipientInfo.PageSessionToken); GaneOrderNotesSessionHelper.ClearSessionTokenData(shipmentAndRecipientInfo.PageSessionToken); return(AnchoredOrderIndex("PurchaseOrders", "Index", "PO")); } } SetViewBagItems(Order, EnumAccountType.Supplier); int id = 0; ViewBag.AllowAccountAddress = caCurrent.CurrentWarehouse().AllowShipToAccountAddress; var accountaddress = _accountServices.GetAllValidAccountContactsByAccountId(id, CurrentTenantId); ViewBag.AccountContactes = new SelectList(accountaddress, "AccountContactId", "ContactEmail", accountaddress.Select(x => x.AccountID).FirstOrDefault()); var directsales = _salesServices.GetDirectSaleOrders(null); ViewBag.DirectOrderList = new SelectList(directsales, "OrderID", "OrderNumber"); if (string.IsNullOrEmpty(shipmentAndRecipientInfo.PageSessionToken)) { ViewBag.ForceRegeneratePageToken = "True"; ViewBag.ForceRegeneratedPageToken = Guid.NewGuid().ToString(); } return(View(Order)); } catch (Exception Exp) { if (Exp.InnerException != null && Exp.InnerException.Message == "Duplicate Order Number") { ModelState.AddModelError("OrderNumber", Exp.Message); } else { ModelState.AddModelError("", Exp.Message); } SetViewBagItems(Order); int id = 0; var accountaddress = _accountServices.GetAllValidAccountContactsByAccountId(id, CurrentTenantId); ViewBag.AccountContactes = new SelectList(accountaddress, "AccountContactId", "ContactEmail", accountaddress.Select(x => x.AccountID).FirstOrDefault()); ViewBag.ForceRegeneratePageToken = "True"; ViewBag.ForceRegeneratedPageToken = shipmentAndRecipientInfo.PageSessionToken ?? Guid.NewGuid().ToString(); var directsales = _salesServices.GetDirectSaleOrders(null); ViewBag.DirectOrderList = new SelectList(directsales, "OrderID", "OrderNumber"); return(View(Order)); } }
public ActionResult GetAccountContactRecipient(int id) { return(Json(GaneConfigurationsHelper.GetRecipientEmailForAccount(0, id), JsonRequestBehavior.AllowGet)); }