public ActionResult Create(int?Id, string pageToken = null) { if (!caSession.AuthoriseSession()) { return(Redirect((string)Session["ErrorUrl"])); } if (Id == null) { int id = 0; 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"); Order NewOrder = new Order(); NewOrder.OrderNumber = GeneratePO((int)InventoryTransactionTypeEnum.PurchaseOrder); NewOrder.IssueDate = DateTime.Today; SetViewBagItems(null, EnumAccountType.Supplier); ViewBag.OrderDetails = new List <OrderDetail>(); ViewBag.OrderProcesses = new List <OrderProcess>(); //ViewBag.IsCollectionFromCustomerSide = true; ViewBag.AllowAccountAddress = caCurrent.CurrentWarehouse().AllowShipToAccountAddress; if (string.IsNullOrEmpty(pageToken)) { ViewBag.ForceRegeneratePageToken = "True"; ViewBag.ForceRegeneratedPageToken = Guid.NewGuid().ToString(); } NewOrder.InventoryTransactionTypeId = (int)InventoryTransactionTypeEnum.PurchaseOrder; GaneOrderDetailsSessionHelper.SetOrderDetailSessions(ViewBag.ForceRegeneratedPageToken, new List <OrderDetailSessionViewModel>()); GaneOrderNotesSessionHelper.SetOrderNotesSessions(ViewBag.ForceRegeneratedPageToken, new List <OrderNotes>()); return(View(NewOrder)); } return(View()); }
public ActionResult UpdateOrdersBulkSingle(Order Order, OrderRecipientInfo shipmentAndRecipientInfo) { // get properties of tenant try { if (ModelState.IsValid) { var orderDetailsList = GaneOrderDetailsSessionHelper.GetOrderDetailSession(shipmentAndRecipientInfo.PageSessionToken); var orderNotesList = GaneOrderNotesSessionHelper.GetOrderNotesSession(shipmentAndRecipientInfo.PageSessionToken); OrderService.UpdateWorksOrderBulkSingle(Order, shipmentAndRecipientInfo, CurrentTenantId, CurrentWarehouseId, CurrentUserId, Mapper.Map(orderDetailsList, new List <OrderDetail>()), orderNotesList); GaneOrderDetailsSessionHelper.ClearSessionTokenData(shipmentAndRecipientInfo.PageSessionToken); GaneOrderNotesSessionHelper.ClearSessionTokenData(shipmentAndRecipientInfo.PageSessionToken); return(Json(new { success = true, message = "Saved" }, JsonRequestBehavior.AllowGet)); } SetViewBagItems(); ViewBag.OrderDetails = Order.OrderDetails; ViewBag.OrderProcesses = Order.OrderProcess; ViewBag.SupplierID = new SelectList(AccountServices.GetAllValidAccounts(CurrentTenantId, EnumAccountType.Supplier), "AccountID", "CompanyName", Order.AccountID); return(Json(new { success = false, message = "Model state not valid, failed to save!" }, JsonRequestBehavior.AllowGet)); } catch (Exception Exp) { SetViewBagItems(); ViewBag.OrderDetails = Order.OrderDetails; ViewBag.OrderProcesses = Order.OrderProcess; ViewBag.SupplierID = new SelectList(AccountServices.GetAllValidAccounts(CurrentTenantId, EnumAccountType.Supplier), "AccountID", "CompanyName", Order.AccountID); ModelState.AddModelError("", Exp.Message); return(Json(new { success = false, message = Exp.Message }, JsonRequestBehavior.AllowGet)); } }
public async Task <ActionResult> Create(Order Order, OrderRecipientInfo shipmentAndRecipientInfo) { // get properties of tenant try { if (ModelState.IsValid) { var tempList = GaneOrderDetailsSessionHelper.GetOrderDetailSession(shipmentAndRecipientInfo.PageSessionToken); var orderNotesList = GaneOrderNotesSessionHelper.GetOrderNotesSession(shipmentAndRecipientInfo.PageSessionToken); OrderService.CreateWorksOrder(Order, shipmentAndRecipientInfo, CurrentTenantId, CurrentWarehouseId, CurrentUserId, Mapper.Map(tempList, new List <OrderDetail>()), orderNotesList); var result = await _ganeConfigurationsHelper.CreateTenantEmailNotificationQueue($"#{Order.OrderNumber} - Works order logged", Mapper.Map(Order, new OrderViewModel()), sendImmediately : true, shipmentAndRecipientInfo : shipmentAndRecipientInfo, worksOrderNotificationType : WorksOrderNotificationTypeEnum.WorksOrderLogTemplate); if (result != "Success") { TempData["Error"] = result; } return(AnchoredOrderIndex("WorksOrders", "Index", ViewBag.Fragment as string)); } SetViewBagItems(); ViewBag.OrderDetails = Order.OrderDetails; ViewBag.OrderProcesses = Order.OrderProcess; ViewBag.ForceRegeneratePageToken = "True"; ViewBag.ForceRegeneratedPageToken = shipmentAndRecipientInfo.PageSessionToken ?? Guid.NewGuid().ToString(); ViewBag.SupplierID = new SelectList(AccountServices.GetAllValidAccounts(CurrentTenantId, EnumAccountType.Supplier), "AccountID", "CompanyName", Order.AccountID); return(View(Order)); } catch (Exception Exp) { if (Exp.InnerException != null && Exp.InnerException.Message == "Duplicate Order Number") { ModelState.AddModelError("OrderNumber", Exp.Message); } else if (Exp.InnerException != null && Exp.InnerException.Message.Contains("Template")) { ModelState.AddModelError("PropertyTenantIds", Exp.Message); } else { ModelState.AddModelError(string.Empty, Exp.Message); } SetViewBagItems(); ViewBag.ForceRegeneratePageToken = "True"; ViewBag.ForceRegeneratedPageToken = shipmentAndRecipientInfo.PageSessionToken ?? Guid.NewGuid().ToString(); ViewBag.OrderDetails = Order.OrderDetails; ViewBag.OrderProcesses = Order.OrderProcess; ViewBag.SupplierID = new SelectList(AccountServices.GetAllValidAccounts(CurrentTenantId, EnumAccountType.Supplier), "AccountID", "CompanyName", Order.AccountID); return(View(Order)); } }
public async Task <ActionResult> Edit(Order Order, OrderRecipientInfo shipmentAndRecipientInfo, string orderSaveAndComplete, string orderSaveAndProcess) { var orderCompleted = false; if (orderSaveAndComplete == "1") { Order.OrderStatusID = (int)OrderStatusEnum.Complete; orderCompleted = true; } if (ModelState.IsValid) { var tempList = GaneOrderDetailsSessionHelper.GetOrderDetailSession(shipmentAndRecipientInfo.PageSessionToken); var orderNotesList = GaneOrderNotesSessionHelper.GetOrderNotesSession(shipmentAndRecipientInfo.PageSessionToken); OrderService.SaveWorksOrder(Order, shipmentAndRecipientInfo, CurrentTenantId, CurrentWarehouseId, CurrentUserId, orderCompleted, Mapper.Map(tempList, new List <OrderDetail>()), orderNotesList); if (orderCompleted) { try { if (shipmentAndRecipientInfo.SendEmailWithAttachment) { var result = await _ganeConfigurationsHelper.CreateTenantEmailNotificationQueue($"#{Order.OrderNumber} - Works order completed", Mapper.Map(Order, new OrderViewModel()), sendImmediately : true, shipmentAndRecipientInfo : shipmentAndRecipientInfo, worksOrderNotificationType : WorksOrderNotificationTypeEnum.WorksOrderCompletedTemplate); if (result != "Success") { TempData["Error"] = result; } } } catch (Exception ex) { throw new Exception("Exception while creating tenant email notification queue - " + ex.Message.ToString(), ex.InnerException); } } ViewBag.Fragment = Request.Form["fragment"]; if (orderSaveAndProcess == "1") { return(Redirect(Url.RouteUrl(new { controller = "WorksOrders", action = "ProcessOrder", id = Order.OrderID }) + "?fragment=" + ViewBag.Fragment as string)); } return(AnchoredOrderIndex("WorksOrders", "Index", ViewBag.Fragment as string)); } ViewBag.ForceRegeneratePageToken = "True"; ViewBag.ForceRegeneratedPageToken = shipmentAndRecipientInfo.PageSessionToken ?? Guid.NewGuid().ToString(); SetViewBagItems(Order); ViewBag.POStatusID = new SelectList(LookupServices.GetAllOrderStatuses(), "OrderStatusID", "Status", Order.OrderStatusID); ViewBag.SupplierID = new SelectList(AccountServices.GetAllValidAccounts(CurrentTenantId, EnumAccountType.Supplier), "SupplierID", "CompanyName", Order.AccountID); return(View(Order)); }
public ActionResult Edit(int?id, string pageToken) { /// Authorization Check if (!caSession.AuthoriseSession()) { return(Redirect((string)Session["ErrorUrl"])); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var Order = OrderService.GetOrderById(id.Value); if (Order == null) { return(HttpNotFound()); } SetViewBagItems(Order); ViewBag.OrderStatus = new SelectList(LookupServices.GetAllOrderStatuses(), "OrderStatusID", "Status"); ViewBag.AccountContacts = new SelectList(AccountServices.GetAllValidAccountContactsByAccountId(Order.AccountID ?? 0, CurrentTenantId), "AccountContactId", "ContactName"); if (string.IsNullOrEmpty(pageToken)) { ViewBag.ForceRegeneratePageToken = "True"; ViewBag.ForceRegeneratedPageToken = Guid.NewGuid().ToString(); } var odList = OrderService.GetAllValidOrderDetailsByOrderId(id.Value).ToList(); GaneOrderDetailsSessionHelper.SetOrderDetailSessions(ViewBag.ForceRegeneratedPageToken, Mapper.Map(odList, new List <OrderDetailSessionViewModel>())); var orderNotes = Order.OrderNotes.Where(a => a.IsDeleted != true).ToList(); GaneOrderNotesSessionHelper.SetOrderNotesSessions(ViewBag.ForceRegeneratedPageToken, orderNotes); ViewBag.Notes = new SelectList(Order.OrderNotes.Where(a => a.IsDeleted != true).Select(a => a.Notes).ToList()); return(View(Order)); }
public ActionResult CreateBulkOrder(Guid?id, string pageToken, bool?layout = false, bool?returnViews = false) { /// Authorization Check if (!caSession.AuthoriseSession()) { return(Redirect((string)Session["ErrorUrl"])); } ViewBag.Layout = layout; ViewBag.returnView = returnViews; var groupToken = id ?? Guid.NewGuid(); var NewOrder = OrderService.GetAllOrdersByGroupToken(groupToken, CurrentTenantId).FirstOrDefault() ?? new Order(); NewOrder.OrderNumber = GeneratePO(); SetViewBagItems(); List <object> expecHours = new List <object>(); for (int ctr = 1; ctr <= 10; ctr++) { expecHours.Add(new { ExpectedHours = ctr }); } ViewBag.OrderGroupToken = groupToken.ToString(); ViewBag.AuthUserId = CurrentUserId; ViewBag.AccountContacts = new SelectList(AccountServices.GetAllTopAccountContactsByTenantId(CurrentTenantId), "AccountContactId", "ContactName"); ViewBag.OrderDetails = new List <OrderDetail>(); ViewBag.OrderProcesses = new List <OrderProcess>(); if (string.IsNullOrEmpty(pageToken)) { ViewBag.ForceRegeneratePageToken = "True"; ViewBag.ForceRegeneratedPageToken = Guid.NewGuid().ToString(); } GaneOrderDetailsSessionHelper.SetOrderDetailSessions(ViewBag.ForceRegeneratedPageToken, new List <OrderDetailSessionViewModel>()); GaneOrderNotesSessionHelper.SetOrderNotesSessions(ViewBag.ForceRegeneratedPageToken, new List <OrderNotes>()); return(View("CreateBulk", NewOrder)); }
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 ActionResult EditBulkSingle(int id, string PageSessionToken) { SetViewBagItems(); List <object> expecHours = new List <object>(); for (int ctr = 1; ctr <= 10; ctr++) { expecHours.Add(new { ExpectedHours = ctr }); } var order = OrderService.GetOrderById(id); ViewBag.OrderGroupToken = order.OrderGroupToken; ViewBag.AuthUserId = CurrentUserId; ViewBag.AccountContacts = new SelectList(AccountServices.GetAllTopAccountContactsByTenantId(CurrentTenantId), "AccountContactId", "ContactName"); ViewBag.OrderDetails = order.OrderDetails; ViewBag.OrderProcesses = new List <OrderProcess>(); if (string.IsNullOrEmpty(PageSessionToken)) { ViewBag.ForceRegeneratePageToken = "True"; ViewBag.ForceRegeneratedPageToken = Guid.NewGuid().ToString(); } else { ViewBag.ForceRegeneratedPageToken = PageSessionToken; } var details = OrderService.GetAllValidOrderDetailsByOrderId(id).ToList(); GaneOrderDetailsSessionHelper.SetOrderDetailSessions(ViewBag.ForceRegeneratedPageToken, Mapper.Map(details, new List <OrderDetailSessionViewModel>())); GaneOrderNotesSessionHelper.SetOrderNotesSessions(ViewBag.ForceRegeneratedPageToken, order.OrderNotes.Where(m => m.IsDeleted != true).ToList()); return(PartialView(order)); }
public ActionResult CreateBulkSingle(string pageToken) { /// Authorization Check if (!caSession.AuthoriseSession()) { return(Redirect((string)Session["ErrorUrl"])); } Order NewOrder = new Order(); NewOrder.OrderNumber = GeneratePO(); SetViewBagItems(); List <object> expecHours = new List <object>(); for (int ctr = 1; ctr <= 10; ctr++) { expecHours.Add(new { ExpectedHours = ctr }); } ViewBag.OrderGroupToken = Guid.NewGuid().ToString(); ViewBag.AuthUserId = CurrentUserId; ViewBag.AccountContacts = new SelectList(AccountServices.GetAllTopAccountContactsByTenantId(CurrentTenantId), "AccountContactId", "ContactName"); ViewBag.OrderDetails = new List <OrderDetail>(); ViewBag.OrderProcesses = new List <OrderProcess>(); if (string.IsNullOrEmpty(pageToken)) { ViewBag.ForceRegeneratePageToken = "True"; ViewBag.ForceRegeneratedPageToken = Guid.NewGuid().ToString(); } GaneOrderDetailsSessionHelper.SetOrderDetailSessions(ViewBag.ForceRegeneratedPageToken, new List <OrderDetailSessionViewModel>()); GaneOrderNotesSessionHelper.SetOrderNotesSessions(ViewBag.ForceRegeneratedPageToken, new List <OrderNotes>()); return(PartialView(NewOrder)); }
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 ActionResult Edit(int?id, string pageToken) { if (!caSession.AuthoriseSession()) { return(Redirect((string)Session["ErrorUrl"])); } caTenant tenant = caCurrent.CurrentTenant(); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Order Order = OrderService.GetOrderById(id.Value); if (Order == null) { return(HttpNotFound()); } var list = OrderService.GetAccountContactId(id ?? 0).ToList(); var EmailAutoCheckedOnEdit = _tenantServices.GetTenantConfigById(CurrentTenantId).EmailAutoCheckedOnEdit; if (EmailAutoCheckedOnEdit) { if (list.Any()) { ViewBag.accountShip = true; } } if (string.IsNullOrEmpty(pageToken)) { ViewBag.ForceRegeneratePageToken = "True"; ViewBag.ForceRegeneratedPageToken = Guid.NewGuid().ToString(); } var odList = OrderService.GetAllValidOrderDetailsByOrderId(id.Value).ToList(); GaneOrderDetailsSessionHelper.SetOrderDetailSessions(ViewBag.ForceRegeneratedPageToken, Mapper.Map(odList, new List <OrderDetailSessionViewModel>())); SetViewBagItems(tenant, EnumAccountType.Customer, Order); //ViewBag.AccountContacts = new SelectList(AccountServices.GetAllTopAccountContactsByTenantId(CurrentTenantId), "AccountContactId", "ContactName"); int ids = 0; var accountaddress = _accountServices.GetAllValidAccountContactsByAccountId(ids, CurrentTenantId); ViewBag.AccountContactes = new SelectList(accountaddress, "AccountContactId", "ContactEmail", accountaddress.Select(x => x.AccountID).FirstOrDefault()); var odNotes = Order.OrderNotes.Where(a => a.IsDeleted != true).ToList(); GaneOrderNotesSessionHelper.SetOrderNotesSessions(ViewBag.ForceRegeneratedPageToken, odNotes); 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 Edit(int?id, string pageSessionToken = null) { if (!caSession.AuthoriseSession()) { return(Redirect((string)Session["ErrorUrl"])); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Order Order = OrderService.GetOrderById(id.Value); var accountaddressId = OrderService.GetAccountContactId(id.Value).ToList(); if (Order == null) { return(HttpNotFound()); } var list = OrderService.GetAccountContactId(id ?? 0).ToList(); var EmailAutoCheckedOnEdit = _tenantServices.GetTenantConfigById(CurrentTenantId).EmailAutoCheckedOnEdit; if (EmailAutoCheckedOnEdit) { if (list.Any()) { ViewBag.accountShip = true; } } int ids = 0; var accountaddress = _accountServices.GetAllValidAccountContactsByAccountId(ids, CurrentTenantId); ViewBag.AccountContactes = new SelectList(accountaddress, "AccountContactId", "ContactEmail"); ViewBag.AllowAccountAddress = caCurrent.CurrentWarehouse().AllowShipToAccountAddress; SetViewBagItems(Order, EnumAccountType.Supplier); if (string.IsNullOrEmpty(pageSessionToken)) { ViewBag.ForceRegeneratePageToken = "True"; ViewBag.ForceRegeneratedPageToken = Guid.NewGuid().ToString(); } var odList = OrderService.GetAllValidOrderDetailsByOrderId(id.Value).ToList(); GaneOrderDetailsSessionHelper.SetOrderDetailSessions(ViewBag.ForceRegeneratedPageToken, Mapper.Map(odList, new List <OrderDetailSessionViewModel>())); var odNotes = Order.OrderNotes.Where(a => a.IsDeleted != true).ToList(); GaneOrderNotesSessionHelper.SetOrderNotesSessions(ViewBag.ForceRegeneratedPageToken, odNotes); if (Order.ShipmentPropertyId.HasValue && Order.ShipmentPropertyId > 0) { ViewBag.IsShipmentToProperty = true; ViewBag.ShipmentPropertyId = Order.ShipmentPropertyId; } else if (Order.AccountAddressId.HasValue && Order.AccountAddressId > 0) { ViewBag.IsAccountAddressId = true; ViewBag.AccountAddressId = Order.AccountAddressId; } else if (Order.IsShippedToTenantMainLocation || Order.ShipmentWarehouseId != null) { ViewBag.IsShipmentToWarehouse = true; } else if (Order.IsCollectionFromCustomerSide) { ViewBag.IsCollectionFromCustomerSide = true; } else { ViewBag.IsShipmentToCustomAddress = true; } return(View(Order)); }